main.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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 ONE_CHANNEL: 1;
  40. uint32_t _reserv: 31;
  41. } flag_t;
  42. extern volatile flag_t Flag;
  43. typedef union {
  44. uint16_t u16; // element specifier for accessing whole u16
  45. int16_t i16; // element specifier for accessing whole i16
  46. uint8_t u8[2];
  47. struct {
  48. #ifdef LITTLE_ENDIAN // Byte-order is little endian
  49. uint8_t u8L; // element specifier for accessing low u8
  50. uint8_t u8H; // element specifier for accessing high u8
  51. #else // Byte-order is big endian
  52. uint8_t u8H; // element specifier for accessing low u8
  53. uint8_t u8L; // element specifier for accessing high u8
  54. #endif
  55. } s16; // element spec. for acc. struct with low or high u8
  56. } nt16_t;
  57. typedef union {
  58. uint32_t u32; // element specifier for accessing whole u32
  59. int32_t i32; // element specifier for accessing whole i32
  60. uint16_t u16[2];
  61. uint8_t u8[4];
  62. struct {
  63. #ifdef LITTLE_ENDIAN // Byte-order is little endian
  64. uint16_t u16L; // element specifier for accessing low u16
  65. uint16_t u16H; // element specifier for accessing high u16
  66. #else // Byte-order is big endian
  67. uint16_t u16H; // element specifier for accessing low u16
  68. uint16_t u16L; // element specifier for accessing high u16
  69. #endif
  70. } s32; // element spec. for acc. struct with low or high u16
  71. } nt32_t;
  72. /* Exported constants --------------------------------------------------------*/
  73. #ifndef true
  74. #define true 1
  75. #endif
  76. #ifndef false
  77. #define false 0
  78. #endif
  79. /* Exported macro ------------------------------------------------------------*/
  80. /* Exported functions prototypes ---------------------------------------------*/
  81. void Error_Handler(void);
  82. /* Private defines -----------------------------------------------------------*/
  83. #ifdef __cplusplus
  84. }
  85. #endif
  86. #endif /* __MAIN_H */
  87. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/