main.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /* USER CODE BEGIN Header */
  2. /**
  3. ******************************************************************************
  4. * @file : main.h
  5. * @brief : Header for main.c file.
  6. * This file contains the common defines of the application.
  7. ******************************************************************************
  8. * @attention
  9. *
  10. * <h2><center>&copy; Copyright (c) 2021 STMicroelectronics.
  11. * All rights reserved.</center></h2>
  12. *
  13. * This software component is licensed by ST under BSD 3-Clause license,
  14. * the "License"; You may not use this file except in compliance with the
  15. * License. You may obtain a copy of the License at:
  16. * opensource.org/licenses/BSD-3-Clause
  17. *
  18. ******************************************************************************
  19. */
  20. /* USER CODE END Header */
  21. /* Define to prevent recursive inclusion -------------------------------------*/
  22. #ifndef __MAIN_H
  23. #define __MAIN_H
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. /* Includes ------------------------------------------------------------------*/
  28. #include "stm32g0xx_ll_dma.h"
  29. #include "stm32g0xx.h"
  30. #include "stm32g0xx_ll_i2c.h"
  31. #include "stm32g0xx_ll_rcc.h"
  32. #include "stm32g0xx_ll_bus.h"
  33. #include "stm32g0xx_ll_system.h"
  34. #include "stm32g0xx_ll_exti.h"
  35. #include "stm32g0xx_ll_cortex.h"
  36. #include "stm32g0xx_ll_utils.h"
  37. #include "stm32g0xx_ll_pwr.h"
  38. #include "stm32g0xx_ll_spi.h"
  39. #include "stm32g0xx_ll_tim.h"
  40. #include "stm32g0xx_ll_gpio.h"
  41. #if defined(USE_FULL_ASSERT)
  42. #include "stm32_assert.h"
  43. #endif /* USE_FULL_ASSERT */
  44. /* Private includes ----------------------------------------------------------*/
  45. /* USER CODE BEGIN Includes */
  46. #include "gpio.h"
  47. #include "ds3231.h"
  48. /* USER CODE END Includes */
  49. /* Exported types ------------------------------------------------------------*/
  50. /* USER CODE BEGIN ET */
  51. typedef enum {
  52. DOWN = 0,
  53. UP = 1
  54. } updown_t;
  55. typedef enum {
  56. OFF = 0,
  57. ON = 1
  58. } onoff_t;
  59. volatile struct {
  60. uint32_t RTC_IRQ: 1;
  61. uint32_t SPI_TX_End: 1;
  62. uint32_t I2C_TX_End: 1;
  63. uint32_t I2C_RX_End: 1;
  64. uint32_t _reserv: 28;
  65. } Flag;
  66. /* USER CODE END ET */
  67. /* Exported constants --------------------------------------------------------*/
  68. /* USER CODE BEGIN EC */
  69. /* USER CODE END EC */
  70. /* Exported macro ------------------------------------------------------------*/
  71. /* USER CODE BEGIN EM */
  72. #define LATCH_DOWN GPIOA->BRR = 0x8000
  73. #define LATCH_UP GPIOA->BSRR = 0x8000
  74. #define TUBE_PWR_ON GPIOA->BRR = 0x10
  75. #define TUBE_PWR_OFF GPIOA->BSRR = 0x10
  76. #define IN15_P GPIOA->BSRR = 0x1
  77. #define IN15_Plus GPIOA->BSRR = 0x2
  78. #define IN15_Minus GPIOA->BSRR = 0x4
  79. #define IN15_Percent GPIOA->BSRR = 0x8
  80. #define IN15_OFF GPIOA->BRR = 0xF
  81. #define COLOR_R(x) TIM3->CCR1 = x
  82. #define COLOR_B(x) TIM3->CCR2 = x
  83. #define COLOR_G(x) TIM3->CCR3 = x
  84. #define COLOR_RGB(r, g, b) TIM3->CCR1 = r; TIM3->CCR3 = g; TIM3->CCR2 = b
  85. /* USER CODE END EM */
  86. /* Exported functions prototypes ---------------------------------------------*/
  87. void Error_Handler(void);
  88. /* USER CODE BEGIN EFP */
  89. /* USER CODE END EFP */
  90. /* Private defines -----------------------------------------------------------*/
  91. #define LC0_Pin LL_GPIO_PIN_0
  92. #define LC0_GPIO_Port GPIOA
  93. #define LC1_Pin LL_GPIO_PIN_1
  94. #define LC1_GPIO_Port GPIOA
  95. #define LC2_Pin LL_GPIO_PIN_2
  96. #define LC2_GPIO_Port GPIOA
  97. #define LC3_Pin LL_GPIO_PIN_3
  98. #define LC3_GPIO_Port GPIOA
  99. #define SHDN_Pin LL_GPIO_PIN_4
  100. #define SHDN_GPIO_Port GPIOA
  101. #define PWM_R_Pin LL_GPIO_PIN_6
  102. #define PWM_R_GPIO_Port GPIOA
  103. #define PWM_G_Pin LL_GPIO_PIN_7
  104. #define PWM_G_GPIO_Port GPIOA
  105. #define PWM_B_Pin LL_GPIO_PIN_0
  106. #define PWM_B_GPIO_Port GPIOB
  107. #define PWM_T_Pin LL_GPIO_PIN_1
  108. #define PWM_T_GPIO_Port GPIOB
  109. #define BTN1_Pin LL_GPIO_PIN_8
  110. #define BTN1_GPIO_Port GPIOA
  111. #define BTN2_Pin LL_GPIO_PIN_9
  112. #define BTN2_GPIO_Port GPIOA
  113. #define BTN3_Pin LL_GPIO_PIN_10
  114. #define BTN3_GPIO_Port GPIOA
  115. #define BTN4_Pin LL_GPIO_PIN_11
  116. #define BTN4_GPIO_Port GPIOA
  117. #define Latch_Pin LL_GPIO_PIN_15
  118. #define Latch_GPIO_Port GPIOA
  119. #define IRQ_Pin LL_GPIO_PIN_8
  120. #define IRQ_GPIO_Port GPIOB
  121. #define IRQ_EXTI_IRQn EXTI4_15_IRQn
  122. /* USER CODE BEGIN Private defines */
  123. #define USE_FULL_LL_DRIVER 1
  124. /* 0xd0 */
  125. #define I2C_ADDR_RTC 0x68
  126. /* 0x76 */
  127. #define I2C_ADDR_BME 0x3b
  128. /* USER CODE END Private defines */
  129. #ifdef __cplusplus
  130. }
  131. #endif
  132. #endif /* __MAIN_H */
  133. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/