main.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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. ** This notice applies to any and all portions of this file
  9. * that are not between comment pairs USER CODE BEGIN and
  10. * USER CODE END. Other portions of this file, whether
  11. * inserted by the user or by software development tools
  12. * are owned by their respective copyright owners.
  13. *
  14. * COPYRIGHT(c) 2019 STMicroelectronics
  15. *
  16. * Redistribution and use in source and binary forms, with or without modification,
  17. * are permitted provided that the following conditions are met:
  18. * 1. Redistributions of source code must retain the above copyright notice,
  19. * this list of conditions and the following disclaimer.
  20. * 2. Redistributions in binary form must reproduce the above copyright notice,
  21. * this list of conditions and the following disclaimer in the documentation
  22. * and/or other materials provided with the distribution.
  23. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  24. * may be used to endorse or promote products derived from this software
  25. * without specific prior written permission.
  26. *
  27. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  28. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  29. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  30. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  31. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  32. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  33. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  34. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  35. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  36. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  37. *
  38. ******************************************************************************
  39. */
  40. /* USER CODE END Header */
  41. /* Define to prevent recursive inclusion -------------------------------------*/
  42. #ifndef __MAIN_H
  43. #define __MAIN_H
  44. #ifdef __cplusplus
  45. extern "C" {
  46. #endif
  47. /* Includes ------------------------------------------------------------------*/
  48. #include "stm32f1xx_hal.h"
  49. /* Private includes ----------------------------------------------------------*/
  50. /* USER CODE BEGIN Includes */
  51. #include "sth30_crc.h"
  52. #include <string.h>
  53. #include "RGB_Controller.h"
  54. #include "core_cm3.h"
  55. #include <stdint.h>
  56. #include "Uart.h"
  57. #include "SX1276.h"
  58. /* USER CODE END Includes */
  59. /* Exported types ------------------------------------------------------------*/
  60. /* USER CODE BEGIN ET */
  61. typedef enum{ //LIMIT SET enum
  62. blucell_stx = 0,
  63. blucell_type,
  64. blucell_length,
  65. blucell_srcid,
  66. blucell_red_H,
  67. blucell_red_L,
  68. blucell_green_H,
  69. blucell_green_L,
  70. blucell_blue_H,
  71. blucell_blue_L,
  72. blucell_dstid,
  73. blucell_crc,
  74. blucell_etx,
  75. }RGB_Protocol_t;
  76. /* USER CODE END ET */
  77. /* Exported constants --------------------------------------------------------*/
  78. /* USER CODE BEGIN EC */
  79. /* USER CODE END EC */
  80. /* Exported macro ------------------------------------------------------------*/
  81. /* USER CODE BEGIN EM */
  82. extern void Uart3_Data_Send(uint8_t* data,uint8_t size);
  83. extern void RGB_SensorIDAutoSet(uint8_t set);
  84. extern uint8_t RGB_SensorIDAutoGet(void);
  85. extern void Flash_write(uint8_t*);
  86. extern void UartDataRecvSet(uint8_t val);
  87. extern void Uart_dataCheck(uint8_t Usart_Num ,uint8_t* cnt);
  88. extern void Uart1_Data_Send(uint8_t* data,uint8_t size);
  89. /* USER CODE END EM */
  90. /* Exported functions prototypes ---------------------------------------------*/
  91. void Error_Handler(void);
  92. /* USER CODE BEGIN EFP */
  93. extern uint8_t MyControllerID;
  94. extern uint8_t SensorID;
  95. typedef enum{
  96. RGB_Status_Data_Request = 0x01,
  97. RGB_ControllerID_SET ,
  98. RGB_SensorID_SET ,
  99. RGB_SensorID_SET_Success,
  100. RGB_Status_Data_Response ,
  101. RGB_ControllerLimitSet ,
  102. RGB_Sensor_Start ,
  103. RGB_Sensor_Check ,
  104. RGB_Sensor_Ack,
  105. RGB_Reset,
  106. }RGB_CMD_T;
  107. #define RGB_ControllerID_SET_Length 10
  108. #define RGB_SensorID_SET_Length 10
  109. #define RGB_SensorDataRequest_Length 7
  110. #define RGB_SensorIDAutoSetRequest_Length 7
  111. #define RGB_SensorIDCheckSetRequest_Length 4
  112. #define RGB_SensorDataResponse_Length 15
  113. #define RGB_SensorDataResponseData_Length RGB_SensorDataResponse_Length - 3
  114. extern uint8_t buf[USART_CNT][buf_size];
  115. extern uint8_t count_in1 ;//, count_out ;
  116. extern uint8_t count_in2 ;//, count_out ;
  117. extern uint8_t count_in3 , count_out ;
  118. extern uint8_t rx1_data[1];
  119. extern uint8_t rx2_data[1];
  120. extern uint8_t rx3_data[1];
  121. /* USER CODE END EFP */
  122. /* Private defines -----------------------------------------------------------*/
  123. #define BOOT_LED_Pin GPIO_PIN_15
  124. #define BOOT_LED_GPIO_Port GPIOC
  125. #define SX1276_DIO0_Pin GPIO_PIN_4
  126. #define SX1276_DIO0_GPIO_Port GPIOA
  127. #define SX1276_DIO1_Pin GPIO_PIN_5
  128. #define SX1276_DIO1_GPIO_Port GPIOA
  129. #define SX1276_DIO2_Pin GPIO_PIN_6
  130. #define SX1276_DIO2_GPIO_Port GPIOA
  131. #define SX1276_DIO3_Pin GPIO_PIN_7
  132. #define SX1276_DIO3_GPIO_Port GPIOA
  133. #define SX1276_DIO4_Pin GPIO_PIN_4
  134. #define SX1276_DIO4_GPIO_Port GPIOC
  135. #define SX1276_DIO5_Pin GPIO_PIN_5
  136. #define SX1276_DIO5_GPIO_Port GPIOC
  137. #define SX1276_RESET_Pin GPIO_PIN_0
  138. #define SX1276_RESET_GPIO_Port GPIOB
  139. #define LED_ALARM_Pin GPIO_PIN_12
  140. #define LED_ALARM_GPIO_Port GPIOB
  141. #define SENSOR_EN1_Pin GPIO_PIN_13
  142. #define SENSOR_EN1_GPIO_Port GPIOB
  143. #define SENSOR_EN2_Pin GPIO_PIN_14
  144. #define SENSOR_EN2_GPIO_Port GPIOB
  145. #define SENSOR_EN3_Pin GPIO_PIN_15
  146. #define SENSOR_EN3_GPIO_Port GPIOB
  147. #define SENSOR_EN4_Pin GPIO_PIN_6
  148. #define SENSOR_EN4_GPIO_Port GPIOC
  149. #define SENSOR_EN5_Pin GPIO_PIN_7
  150. #define SENSOR_EN5_GPIO_Port GPIOC
  151. #define SENSOR_EN6_Pin GPIO_PIN_8
  152. #define SENSOR_EN6_GPIO_Port GPIOC
  153. #define SENSOR_EN7_Pin GPIO_PIN_9
  154. #define SENSOR_EN7_GPIO_Port GPIOC
  155. #define SENSOR_EN8_Pin GPIO_PIN_8
  156. #define SENSOR_EN8_GPIO_Port GPIOA
  157. #define SX1276_NSS_Pin GPIO_PIN_15
  158. #define SX1276_NSS_GPIO_Port GPIOA
  159. #define LED_CH1_Pin GPIO_PIN_10
  160. #define LED_CH1_GPIO_Port GPIOC
  161. #define LED_CH2_Pin GPIO_PIN_11
  162. #define LED_CH2_GPIO_Port GPIOC
  163. #define LED_CH3_Pin GPIO_PIN_12
  164. #define LED_CH3_GPIO_Port GPIOC
  165. #define LED_CH4_Pin GPIO_PIN_2
  166. #define LED_CH4_GPIO_Port GPIOD
  167. #define SX1276_CLK_Pin GPIO_PIN_3
  168. #define SX1276_CLK_GPIO_Port GPIOB
  169. #define SX1276_MISO_Pin GPIO_PIN_4
  170. #define SX1276_MISO_GPIO_Port GPIOB
  171. #define SX1276_MOSI_Pin GPIO_PIN_5
  172. #define SX1276_MOSI_GPIO_Port GPIOB
  173. #define LED_CH5_Pin GPIO_PIN_6
  174. #define LED_CH5_GPIO_Port GPIOB
  175. #define LED_CH6_Pin GPIO_PIN_7
  176. #define LED_CH6_GPIO_Port GPIOB
  177. #define LED_CH7_Pin GPIO_PIN_8
  178. #define LED_CH7_GPIO_Port GPIOB
  179. #define LED_CH8_Pin GPIO_PIN_9
  180. #define LED_CH8_GPIO_Port GPIOB
  181. /* USER CODE BEGIN Private defines */
  182. /* USER CODE END Private defines */
  183. #ifdef __cplusplus
  184. }
  185. #endif
  186. #endif /* __MAIN_H */
  187. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/