main.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. */
  8. /* Define to prevent recursive inclusion -------------------------------------*/
  9. #ifndef _MAIN_H_
  10. #define _MAIN_H_
  11. #ifdef __cplusplus
  12. extern "C" {
  13. #endif
  14. /* Includes ------------------------------------------------------------------*/
  15. #include <stdint.h>
  16. #include <stdlib.h>
  17. #include "stm32f0xx.h"
  18. /* Private includes ----------------------------------------------------------*/
  19. #include "board.h"
  20. #include "rtos.h"
  21. #include "i2c.h"
  22. #include "ds3231.h"
  23. #include "display.h"
  24. #include "event-system.h"
  25. #include "clock.h"
  26. /* Exported types ------------------------------------------------------------*/
  27. typedef enum {
  28. Down = 0,
  29. Up = 1
  30. } updown_t;
  31. typedef enum {
  32. Off = 0,
  33. On = 1
  34. } onoff_t;
  35. typedef struct t_flag {
  36. uint32_t RTC_IRQ: 1;
  37. uint32_t I2C_TX_Err: 1;
  38. uint32_t I2C_TX_End: 1;
  39. uint32_t I2C_RX_Err: 1;
  40. uint32_t I2C_RX_End: 1;
  41. uint32_t DISP_BSY: 1;
  42. uint32_t _reserv: 26;
  43. } flag_t;
  44. extern volatile flag_t Flag;
  45. typedef union {
  46. uint16_t u16; // element specifier for accessing whole u16
  47. int16_t i16; // element specifier for accessing whole i16
  48. uint8_t u8[2];
  49. struct {
  50. #ifdef LITTLE_ENDIAN // Byte-order is little endian
  51. uint8_t u8L; // element specifier for accessing low u8
  52. uint8_t u8H; // element specifier for accessing high u8
  53. #else // Byte-order is big endian
  54. uint8_t u8H; // element specifier for accessing low u8
  55. uint8_t u8L; // element specifier for accessing high u8
  56. #endif
  57. } s16; // element spec. for acc. struct with low or high u8
  58. } nt16_t;
  59. typedef union {
  60. uint32_t u32; // element specifier for accessing whole u32
  61. int32_t i32; // element specifier for accessing whole i32
  62. uint16_t u16[2];
  63. uint8_t u8[4];
  64. struct {
  65. #ifdef LITTLE_ENDIAN // Byte-order is little endian
  66. uint16_t u16L; // element specifier for accessing low u16
  67. uint16_t u16H; // element specifier for accessing high u16
  68. #else // Byte-order is big endian
  69. uint16_t u16H; // element specifier for accessing low u16
  70. uint16_t u16L; // element specifier for accessing high u16
  71. #endif
  72. } s32; // element spec. for acc. struct with low or high u16
  73. } nt32_t;
  74. /* Exported constants --------------------------------------------------------*/
  75. /* Exported macro ------------------------------------------------------------*/
  76. /* Exported functions prototypes ---------------------------------------------*/
  77. void Error_Handler(void);
  78. void NMI_Handler(void);
  79. void HardFault_Handler(void);
  80. void SVC_Handler(void);
  81. void PendSV_Handler(void);
  82. /* Private defines -----------------------------------------------------------*/
  83. #ifdef __cplusplus
  84. }
  85. #endif
  86. #endif /* _MAIN_H_ */