global.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #ifndef __GLOBAL_H
  2. #define __GLOBAL_H
  3. #include <stm32f4xx.h>
  4. /* exact-width signed integer types */
  5. // typedef signed char int8_t;
  6. // typedef signed short int int16_t;
  7. // typedef signed int int32_t;
  8. /* exact-width unsigned integer types */
  9. // typedef unsigned char uint8_t;
  10. // typedef unsigned short int uint16_t;
  11. // typedef unsigned int uint32_t;
  12. typedef uint32_t u32;
  13. typedef uint16_t u16;
  14. typedef uint8_t u8;
  15. typedef void (*pFunction)(void);
  16. typedef struct
  17. {
  18. u8 buf[8];
  19. u32 can_id;
  20. } CanData_TypeDef;
  21. typedef struct
  22. {
  23. u8 result;
  24. } updata;
  25. updata *var_get_info(void);
  26. #ifndef VAR_DEFINE
  27. #define VAR_FUNC_DEF(TYPE, VAR) \
  28. TYPE var_get_##VAR(void); \
  29. void var_set_##VAR(value);
  30. #else
  31. #define VAR_FUNC_DEF(TYPE, VAR) \
  32. TYPE var_get_##VAR(void) \
  33. { \
  34. TYPE value; \
  35. value = var_get_info()->VAR; \
  36. return value; \
  37. } \
  38. void var_set_##VAR(value) \
  39. { \
  40. var_get_info()->VAR = value; \
  41. }
  42. #endif
  43. #define APP_ADDRESS 0x8010000
  44. #define DLC_8 8
  45. #ifndef TRUE
  46. #define TRUE 1
  47. #endif
  48. #ifndef FALSE
  49. #define FALSE 0
  50. #endif
  51. // Ñ¡ÔñCANͨѶ²¨ÌØÂÊ
  52. // #define __CAN_BAUD_500K
  53. #define __CAN_BAUD_250K
  54. // VAR_FUNC_DEF(u8, result)
  55. u8 var_get_result(void);
  56. void var_set_result(u8 value);
  57. #endif