main.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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.h"
  29. #include "stm32g0xx_ll_dma.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. #include "stm32g0xx_ll_usart.h"
  42. #if defined(USE_FULL_ASSERT)
  43. #include "stm32_assert.h"
  44. #endif /* USE_FULL_ASSERT */
  45. /* Private includes ----------------------------------------------------------*/
  46. /* USER CODE BEGIN Includes */
  47. #include "board.h"
  48. #include "sensor.h"
  49. #include "i2c.h"
  50. #include "ds3231.h"
  51. #include "bme280.h"
  52. #include "rtos.h"
  53. #include "event-system.h"
  54. #include "list_event.h"
  55. /* USER CODE END Includes */
  56. /* Exported types ------------------------------------------------------------*/
  57. /* USER CODE BEGIN ET */
  58. typedef enum {
  59. DOWN = 0,
  60. UP = 1
  61. } updown_t;
  62. typedef enum {
  63. OFF = 0,
  64. ON = 1
  65. } onoff_t;
  66. typedef struct {
  67. uint32_t RTC_IRQ: 1;
  68. uint32_t SPI_TX_End: 1;
  69. uint32_t I2C_TX_End: 1;
  70. uint32_t I2C_RX_End: 1;
  71. uint32_t I2C_TX_Err: 1;
  72. uint32_t I2C_RX_Err: 1;
  73. uint32_t BME280: 1;
  74. uint32_t Blink_1: 1;
  75. uint32_t Blink_2: 1;
  76. uint32_t Blink_3: 1;
  77. uint32_t Blink_4: 1;
  78. uint32_t Blink_5: 1;
  79. uint32_t _reserv: 20;
  80. } flag_t;
  81. extern volatile flag_t Flag;
  82. typedef union {
  83. uint16_t u16; // element specifier for accessing whole u16
  84. int16_t i16; // element specifier for accessing whole i16
  85. struct {
  86. #ifdef LITTLE_ENDIAN // Byte-order is little endian
  87. uint8_t u8L; // element specifier for accessing low u8
  88. uint8_t u8H; // element specifier for accessing high u8
  89. #else // Byte-order is big endian
  90. uint8_t u8H; // element specifier for accessing low u8
  91. uint8_t u8L; // element specifier for accessing high u8
  92. #endif
  93. } s16; // element spec. for acc. struct with low or high u8
  94. } nt16_t;
  95. typedef union {
  96. uint32_t u32; // element specifier for accessing whole u32
  97. int32_t i32; // element specifier for accessing whole i32
  98. struct {
  99. #ifdef LITTLE_ENDIAN // Byte-order is little endian
  100. uint16_t u16L; // element specifier for accessing low u16
  101. uint16_t u16H; // element specifier for accessing high u16
  102. #else // Byte-order is big endian
  103. uint16_t u16H; // element specifier for accessing low u16
  104. uint16_t u16L; // element specifier for accessing high u16
  105. #endif
  106. } s32; // element spec. for acc. struct with low or high u16
  107. } nt32_t;
  108. /* USER CODE END ET */
  109. /* Exported constants --------------------------------------------------------*/
  110. /* USER CODE BEGIN EC */
  111. /* USER CODE END EC */
  112. /* Exported macro ------------------------------------------------------------*/
  113. /* USER CODE BEGIN EM */
  114. /* USER CODE END EM */
  115. /* Exported functions prototypes ---------------------------------------------*/
  116. void Error_Handler(void);
  117. /* USER CODE BEGIN EFP */
  118. /* USER CODE END EFP */
  119. /* Private defines -----------------------------------------------------------*/
  120. /* USER CODE BEGIN Private defines */
  121. /* time constant in ms */
  122. #define BTN_SCAN_PERIOD 10
  123. #define BTN_SCAN_PAUSE 200
  124. #define BTN_TIME_PRESSED 30
  125. #define BTN_TIME_HOLDED 500
  126. #define BTN_TIME_REPEATED 50
  127. typedef struct {
  128. uint8_t time;
  129. es_event_t pressed;
  130. es_event_t holded;
  131. uint32_t pin;
  132. //(GPIO_TypeDef *) GPIOA; // ?->IDR
  133. } btn_t;
  134. /* USER CODE END Private defines */
  135. #ifdef __cplusplus
  136. }
  137. #endif
  138. #endif /* __MAIN_H */
  139. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/