main.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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 "SX1276.h"
  57. /* USER CODE END Includes */
  58. /* Exported types ------------------------------------------------------------*/
  59. /* USER CODE BEGIN ET */
  60. typedef enum{ //LIMIT SET enum
  61. bluecell_stx = 0,
  62. bluecell_type,
  63. bluecell_length,
  64. bluecell_srcid,
  65. bluecell_red_H,
  66. bluecell_red_L,
  67. bluecell_green_H,
  68. bluecell_green_L,
  69. bluecell_blue_H,
  70. bluecell_blue_L,
  71. bluecell_dstid,
  72. bluecell_crc,
  73. bluecell_etx,
  74. }RGB_Protocol_t;
  75. /* USER CODE END ET */
  76. /* Exported constants --------------------------------------------------------*/
  77. /* USER CODE BEGIN EC */
  78. /* USER CODE END EC */
  79. /* Exported macro ------------------------------------------------------------*/
  80. /* USER CODE BEGIN EM */
  81. extern void Uart3_Data_Send(uint8_t* data,uint8_t size);
  82. extern void RGB_SensorIDAutoSet(uint8_t set);
  83. extern uint8_t RGB_SensorIDAutoGet(void);
  84. extern void Flash_write(uint8_t*);
  85. extern void LoraDataSendSet(uint8_t val);
  86. extern uint8_t LoraDataSendGet(void);
  87. /* USER CODE END EM */
  88. /* Exported functions prototypes ---------------------------------------------*/
  89. void Error_Handler(void);
  90. /* USER CODE BEGIN EFP */
  91. extern uint8_t MyControllerID;
  92. extern uint8_t SensorID;
  93. extern uint8_t Lora_Buf[100];
  94. typedef enum{
  95. RGB_Status_Data_Request = 0x01,
  96. RGB_ControllerID_SET , //2
  97. RGB_SensorID_SET , //3
  98. RGB_SensorID_SET_Success, //4
  99. RGB_Status_Data_Response , //5
  100. RGB_ControllerLimitSet , //6
  101. RGB_Sensor_Start , //7
  102. RGB_Sensor_Check ,//8
  103. RGB_Sensor_Ack, //9
  104. RGB_Reset,//a
  105. RGB_ID_Allocate_Request,//b
  106. RGB_Lora_Data_Report,//c
  107. }RGB_CMD_T;
  108. #define RGB_ControllerID_SET_Length 10
  109. #define RGB_SensorID_SET_Length 10
  110. #define RGB_SensorDataRequest_Length 7
  111. #define RGB_SensorIDAutoSetRequest_Length 7
  112. #define RGB_SensorIDCheckSetRequest_Length 4
  113. #define RGB_SensorDataResponse_Length 15
  114. #define RGB_SensorDataResponseData_Length RGB_SensorDataResponse_Length - 3
  115. #define Lora_Max_Amount 60
  116. /* USER CODE END EFP */
  117. /* Private defines -----------------------------------------------------------*/
  118. #define BOOT_LED_Pin GPIO_PIN_15
  119. #define BOOT_LED_GPIO_Port GPIOC
  120. #define SX1276_DIO0_Pin GPIO_PIN_4
  121. #define SX1276_DIO0_GPIO_Port GPIOA
  122. #define SX1276_DIO1_Pin GPIO_PIN_5
  123. #define SX1276_DIO1_GPIO_Port GPIOA
  124. #define SX1276_DIO2_Pin GPIO_PIN_6
  125. #define SX1276_DIO2_GPIO_Port GPIOA
  126. #define SX1276_DIO3_Pin GPIO_PIN_7
  127. #define SX1276_DIO3_GPIO_Port GPIOA
  128. #define SX1276_DIO4_Pin GPIO_PIN_4
  129. #define SX1276_DIO4_GPIO_Port GPIOC
  130. #define SX1276_DIO5_Pin GPIO_PIN_5
  131. #define SX1276_DIO5_GPIO_Port GPIOC
  132. #define SX1276_RESET_Pin GPIO_PIN_0
  133. #define SX1276_RESET_GPIO_Port GPIOB
  134. #define LED_ALARM_Pin GPIO_PIN_12
  135. #define LED_ALARM_GPIO_Port GPIOB
  136. #define SENSOR_EN1_Pin GPIO_PIN_13
  137. #define SENSOR_EN1_GPIO_Port GPIOB
  138. #define SENSOR_EN2_Pin GPIO_PIN_14
  139. #define SENSOR_EN2_GPIO_Port GPIOB
  140. #define SENSOR_EN3_Pin GPIO_PIN_15
  141. #define SENSOR_EN3_GPIO_Port GPIOB
  142. #define SENSOR_EN4_Pin GPIO_PIN_6
  143. #define SENSOR_EN4_GPIO_Port GPIOC
  144. #define SENSOR_EN5_Pin GPIO_PIN_7
  145. #define SENSOR_EN5_GPIO_Port GPIOC
  146. #define SENSOR_EN6_Pin GPIO_PIN_8
  147. #define SENSOR_EN6_GPIO_Port GPIOC
  148. #define SENSOR_EN7_Pin GPIO_PIN_9
  149. #define SENSOR_EN7_GPIO_Port GPIOC
  150. #define SENSOR_EN8_Pin GPIO_PIN_8
  151. #define SENSOR_EN8_GPIO_Port GPIOA
  152. #define SX1276_NSS_Pin GPIO_PIN_15
  153. #define SX1276_NSS_GPIO_Port GPIOA
  154. #define LED_CH1_Pin GPIO_PIN_10
  155. #define LED_CH1_GPIO_Port GPIOC
  156. #define LED_CH2_Pin GPIO_PIN_11
  157. #define LED_CH2_GPIO_Port GPIOC
  158. #define LED_CH3_Pin GPIO_PIN_12
  159. #define LED_CH3_GPIO_Port GPIOC
  160. #define LED_CH4_Pin GPIO_PIN_2
  161. #define LED_CH4_GPIO_Port GPIOD
  162. #define SX1276_CLK_Pin GPIO_PIN_3
  163. #define SX1276_CLK_GPIO_Port GPIOB
  164. #define SX1276_MISO_Pin GPIO_PIN_4
  165. #define SX1276_MISO_GPIO_Port GPIOB
  166. #define SX1276_MOSI_Pin GPIO_PIN_5
  167. #define SX1276_MOSI_GPIO_Port GPIOB
  168. #define LED_CH5_Pin GPIO_PIN_6
  169. #define LED_CH5_GPIO_Port GPIOB
  170. #define LED_CH6_Pin GPIO_PIN_7
  171. #define LED_CH6_GPIO_Port GPIOB
  172. #define LED_CH7_Pin GPIO_PIN_8
  173. #define LED_CH7_GPIO_Port GPIOB
  174. #define LED_CH8_Pin GPIO_PIN_9
  175. #define LED_CH8_GPIO_Port GPIOB
  176. /* USER CODE BEGIN Private defines */
  177. #define buf_size 100
  178. /* USER CODE END Private defines */
  179. #ifdef __cplusplus
  180. }
  181. #endif
  182. #endif /* __MAIN_H */
  183. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/