main.h 5.5 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. ** 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 "TCS34725.h"
  53. #include "RGB_Sensor.h"
  54. #include "stdlib.h"
  55. #include "string.h"
  56. #include "stm32f1xx_hal_flash_ex.h"
  57. #include "stm32f1xx_hal_flash.h"
  58. /* USER CODE END Includes */
  59. /* Exported types ------------------------------------------------------------*/
  60. /* USER CODE BEGIN ET */
  61. #define buf_size 50
  62. typedef enum{
  63. Bluecell_STX = 0,
  64. Bluecell_Type = 1,
  65. Bluecell_Length = 2,
  66. Bluecell_DATA = 3,
  67. }Protocol_t;
  68. typedef enum{ // RGB Sensor Enum
  69. bluecell_stx = 0,
  70. bluecell_type,
  71. bluecell_length,
  72. bluecell_srcid,
  73. bluecell_clear_H,
  74. bluecell_clear_L,
  75. bluecell_red_H,
  76. bluecell_red_L,
  77. bluecell_green_H,
  78. bluecell_green_L,
  79. bluecell_blue_H,
  80. bluecell_blue_L,
  81. bluecell_dstid,
  82. bluecell_crc,
  83. bluecell_etx,
  84. }RGB_Protocol_t;
  85. typedef enum
  86. {
  87. TCS34725_INTEGRATIONTIME_2_4MS = 0xFF, /**< 2.4ms - 1 cycle - Max Count: 1024 */
  88. TCS34725_INTEGRATIONTIME_24MS = 0xF6, /**< 24ms - 10 cycles - Max Count: 10240 */
  89. TCS34725_INTEGRATIONTIME_50MS = 0xEB, /**< 50ms - 20 cycles - Max Count: 20480 */
  90. TCS34725_INTEGRATIONTIME_101MS = 0xD5, /**< 101ms - 42 cycles - Max Count: 43008 */
  91. TCS34725_INTEGRATIONTIME_154MS = 0xC0, /**< 154ms - 64 cycles - Max Count: 65535 */
  92. TCS34725_INTEGRATIONTIME_700MS = 0x00 /**< 700ms - 256 cycles - Max Count: 65535 */
  93. }
  94. tcs34725IntegrationTime_t;
  95. typedef enum
  96. {
  97. TCS34725_GAIN_1X = 0x00, /**< No gain */
  98. TCS34725_GAIN_4X = 0x01, /**< 4x gain */
  99. TCS34725_GAIN_16X = 0x02, /**< 16x gain */
  100. TCS34725_GAIN_60X = 0x03 /**< 60x gain */
  101. }
  102. tcs34725Gain_t;
  103. typedef enum{
  104. RGB_Status_Data_Request = 0x01,
  105. RGB_ControllerID_SET ,
  106. RGB_SensorID_SET ,
  107. RGB_SensorID_SET_Success,
  108. RGB_Status_Data_Response ,
  109. RGB_ControllerLimitSet ,
  110. RGB_Sensor_Start ,
  111. RGB_Sensor_Check ,
  112. RGB_Sensor_Ack,
  113. RGB_Reset,
  114. RGB_ID_Allocate_Request,
  115. }RGB_CMD_T;
  116. extern I2C_HandleTypeDef hi2c1;
  117. /* USER CODE END ET */
  118. /* Exported constants --------------------------------------------------------*/
  119. /* USER CODE BEGIN EC */
  120. /* USER CODE END EC */
  121. /* Exported macro ------------------------------------------------------------*/
  122. /* USER CODE BEGIN EM */
  123. /* USER CODE END EM */
  124. /* Exported functions prototypes ---------------------------------------------*/
  125. void Error_Handler(void);
  126. /* USER CODE BEGIN EFP */
  127. void Uart2_Data_Send(uint8_t* data,uint8_t size); // Controller Comunication Cable
  128. /* USER CODE END EFP */
  129. /* Private defines -----------------------------------------------------------*/
  130. /* USER CODE BEGIN Private defines */
  131. /* USER CODE END Private defines */
  132. #ifdef __cplusplus
  133. }
  134. #endif
  135. #endif /* __MAIN_H */
  136. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/