main.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /**
  2. ******************************************************************************
  3. * @file : main.h
  4. * @brief : Header for main.c file.
  5. * This file contains the common defines of the application.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; Copyright (c) 2021 STMicroelectronics.
  10. * All rights reserved.</center></h2>
  11. *
  12. * This software component is licensed by ST under BSD 3-Clause license,
  13. * the "License"; You may not use this file except in compliance with the
  14. * License. You may obtain a copy of the License at:
  15. * opensource.org/licenses/BSD-3-Clause
  16. *
  17. ******************************************************************************
  18. */
  19. /* Define to prevent recursive inclusion -------------------------------------*/
  20. #ifndef __MAIN_H
  21. #define __MAIN_H
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. /* Includes ------------------------------------------------------------------*/
  26. #include <stdbool.h>
  27. #include "stm32g0xx.h"
  28. #include "board.h"
  29. /* Exported types ------------------------------------------------------------*/
  30. typedef enum {
  31. DOWN = 0,
  32. UP = 1
  33. } updown_t;
  34. typedef enum {
  35. OFF = 0,
  36. ON = 1
  37. } onoff_t;
  38. typedef struct t_flag {
  39. uint32_t RTC_IRQ: 1;
  40. uint32_t SPI_TX_End: 1;
  41. uint32_t I2C_TX_End: 1;
  42. uint32_t I2C_RX_End: 1;
  43. uint32_t I2C_TX_Err: 1;
  44. uint32_t I2C_RX_Err: 1;
  45. uint32_t BME280: 1;
  46. uint32_t Blink_1: 1;
  47. uint32_t Blink_2: 1;
  48. uint32_t Blink_3: 1;
  49. uint32_t Blink_4: 1;
  50. uint32_t Blink_5: 1;
  51. uint32_t Now_Day: 1;
  52. uint32_t _reserv: 19;
  53. } flag_t;
  54. extern volatile flag_t Flag;
  55. typedef union {
  56. uint16_t u16; // element specifier for accessing whole u16
  57. int16_t i16; // element specifier for accessing whole i16
  58. uint8_t u8[2];
  59. struct {
  60. #ifdef LITTLE_ENDIAN // Byte-order is little endian
  61. uint8_t u8L; // element specifier for accessing low u8
  62. uint8_t u8H; // element specifier for accessing high u8
  63. #else // Byte-order is big endian
  64. uint8_t u8H; // element specifier for accessing low u8
  65. uint8_t u8L; // element specifier for accessing high u8
  66. #endif
  67. } s16; // element spec. for acc. struct with low or high u8
  68. } nt16_t;
  69. typedef union {
  70. uint32_t u32; // element specifier for accessing whole u32
  71. int32_t i32; // element specifier for accessing whole i32
  72. uint16_t u16[2];
  73. uint8_t u8[4];
  74. struct {
  75. #ifdef LITTLE_ENDIAN // Byte-order is little endian
  76. uint16_t u16L; // element specifier for accessing low u16
  77. uint16_t u16H; // element specifier for accessing high u16
  78. #else // Byte-order is big endian
  79. uint16_t u16H; // element specifier for accessing low u16
  80. uint16_t u16L; // element specifier for accessing high u16
  81. #endif
  82. } s32; // element spec. for acc. struct with low or high u16
  83. } nt32_t;
  84. /* Exported constants --------------------------------------------------------*/
  85. #ifndef true
  86. #define true 1
  87. #endif
  88. #ifndef false
  89. #define false 0
  90. #endif
  91. /* Exported macro ------------------------------------------------------------*/
  92. /* Exported functions prototypes ---------------------------------------------*/
  93. void Error_Handler(void);
  94. /* Private defines -----------------------------------------------------------*/
  95. #ifdef __cplusplus
  96. }
  97. #endif
  98. #endif /* __MAIN_H */
  99. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/