main.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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. #include "bme280.h"
  49. #include "rtos.h"
  50. /* USER CODE END Includes */
  51. /* Exported types ------------------------------------------------------------*/
  52. /* USER CODE BEGIN ET */
  53. typedef enum {
  54. DOWN = 0,
  55. UP = 1
  56. } updown_t;
  57. typedef enum {
  58. OFF = 0,
  59. ON = 1
  60. } onoff_t;
  61. volatile struct {
  62. uint32_t RTC_IRQ: 1;
  63. uint32_t SPI_TX_End: 1;
  64. uint32_t I2C_TX_End: 1;
  65. uint32_t I2C_RX_End: 1;
  66. uint32_t I2C_TX_Err: 1;
  67. uint32_t I2C_RX_Err: 1;
  68. uint32_t BME280: 1;
  69. uint32_t _reserv: 25;
  70. } Flag;
  71. typedef union {
  72. uint16_t u16; // element specifier for accessing whole u16
  73. int16_t i16; // element specifier for accessing whole i16
  74. struct {
  75. #ifdef LITTLE_ENDIAN // Byte-order is little endian
  76. uint8_t u8L; // element specifier for accessing low u8
  77. uint8_t u8H; // element specifier for accessing high u8
  78. #else // Byte-order is big endian
  79. uint8_t u8H; // element specifier for accessing low u8
  80. uint8_t u8L; // element specifier for accessing high u8
  81. #endif
  82. } s16; // element spec. for acc. struct with low or high u8
  83. } nt16_t;
  84. typedef union {
  85. uint32_t u32; // element specifier for accessing whole u32
  86. int32_t i32; // element specifier for accessing whole i32
  87. struct {
  88. #ifdef LITTLE_ENDIAN // Byte-order is little endian
  89. uint16_t u16L; // element specifier for accessing low u16
  90. uint16_t u16H; // element specifier for accessing high u16
  91. #else // Byte-order is big endian
  92. uint16_t u16H; // element specifier for accessing low u16
  93. uint16_t u16L; // element specifier for accessing high u16
  94. #endif
  95. } s32; // element spec. for acc. struct with low or high u16
  96. } nt32_t;
  97. /* USER CODE END ET */
  98. /* Exported constants --------------------------------------------------------*/
  99. /* USER CODE BEGIN EC */
  100. #define I2C_RET_OK (int8_t)0
  101. #define I2C_RET_NACK (int8_t)-1
  102. #define I2C_RET_ERR (int8_t)-2
  103. /* USER CODE END EC */
  104. /* Exported macro ------------------------------------------------------------*/
  105. /* USER CODE BEGIN EM */
  106. #define LATCH_DOWN GPIOA->BRR = 0x8000
  107. #define LATCH_UP GPIOA->BSRR = 0x8000
  108. #define TUBE_PWR_ON GPIOA->BRR = 0x10
  109. #define TUBE_PWR_OFF GPIOA->BSRR = 0x10
  110. #define IN15_P GPIOA->BSRR = 0x1
  111. #define IN15_Plus GPIOA->BSRR = 0x2
  112. #define IN15_Minus GPIOA->BSRR = 0x4
  113. #define IN15_Percent GPIOA->BSRR = 0x8
  114. #define IN15_OFF GPIOA->BRR = 0xF
  115. #define COLOR_R(x) TIM3->CCR1 = x
  116. #define COLOR_B(x) TIM3->CCR2 = x
  117. #define COLOR_G(x) TIM3->CCR3 = x
  118. #define COLOR_RGB(r, g, b) TIM3->CCR1 = r; TIM3->CCR3 = g; TIM3->CCR2 = b
  119. /* USER CODE END EM */
  120. /* Exported functions prototypes ---------------------------------------------*/
  121. void Error_Handler(void);
  122. /* USER CODE BEGIN EFP */
  123. /* USER CODE END EFP */
  124. /* Private defines -----------------------------------------------------------*/
  125. #define LC0_Pin LL_GPIO_PIN_0
  126. #define LC0_GPIO_Port GPIOA
  127. #define LC1_Pin LL_GPIO_PIN_1
  128. #define LC1_GPIO_Port GPIOA
  129. #define LC2_Pin LL_GPIO_PIN_2
  130. #define LC2_GPIO_Port GPIOA
  131. #define LC3_Pin LL_GPIO_PIN_3
  132. #define LC3_GPIO_Port GPIOA
  133. #define SHDN_Pin LL_GPIO_PIN_4
  134. #define SHDN_GPIO_Port GPIOA
  135. #define PWM_R_Pin LL_GPIO_PIN_6
  136. #define PWM_R_GPIO_Port GPIOA
  137. #define PWM_G_Pin LL_GPIO_PIN_7
  138. #define PWM_G_GPIO_Port GPIOA
  139. #define PWM_B_Pin LL_GPIO_PIN_0
  140. #define PWM_B_GPIO_Port GPIOB
  141. #define PWM_T_Pin LL_GPIO_PIN_1
  142. #define PWM_T_GPIO_Port GPIOB
  143. #define BTN1_Pin LL_GPIO_PIN_8
  144. #define BTN1_GPIO_Port GPIOA
  145. #define BTN2_Pin LL_GPIO_PIN_9
  146. #define BTN2_GPIO_Port GPIOA
  147. #define BTN3_Pin LL_GPIO_PIN_10
  148. #define BTN3_GPIO_Port GPIOA
  149. #define BTN4_Pin LL_GPIO_PIN_11
  150. #define BTN4_GPIO_Port GPIOA
  151. #define Latch_Pin LL_GPIO_PIN_15
  152. #define Latch_GPIO_Port GPIOA
  153. #define IRQ_Pin LL_GPIO_PIN_8
  154. #define IRQ_GPIO_Port GPIOB
  155. #define IRQ_EXTI_IRQn EXTI4_15_IRQn
  156. /* USER CODE BEGIN Private defines */
  157. #define USE_FULL_LL_DRIVER 1
  158. /* USER CODE END Private defines */
  159. #ifdef __cplusplus
  160. }
  161. #endif
  162. #endif /* __MAIN_H */
  163. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/