u_global.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. #ifndef _U_GLOBAL_H_
  2. #define _U_GLOBAL_H_
  3. #include <stdint.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. //#include "u_uart.h"
  7. //#include "driver_gpio.h"
  8. //#include "u_main.h"
  9. //typedef unsigned char u8;
  10. //typedef unsigned short u16;
  11. //#define u32 (unsigned int);
  12. // Firmware Revision
  13. #define U_DIS_FW_REV_STR ("0130")
  14. #define U_DIS_FW_REV_STR_LEN strlen(U_DIS_FW_REV_STR)
  15. #define U_DIS_HW_REV_STR ("HW: v0.0 PT: v0.0.0")
  16. #define U_DIS_HW_REV_STR_LEN strlen(U_DIS_HW_REV_STR)
  17. #define GPIO_BIT(x) ((x >> 4) * 8 + (x & 0x0f))
  18. #define SYS_TIMER_TIME (10/10) //定时时间(ms) / 固定值
  19. #define GPIO_LVL_HIGH (1)
  20. #define GPIO_LVL_LOW (0)
  21. #define SYS_TICK (10)
  22. #define SYS_EVENT_MAX_NUM (32)
  23. //extern signed int bprintf(const char *fmt, ...);
  24. //#define U_UART_PRINTF bprintf
  25. extern void MyPrintf(char *format, ...);
  26. #define U_UART_PRINTF MyPrintf
  27. enum
  28. {
  29. CLR_TS_TYPE_8_32,
  30. CLR_TS_TYPE_32_8,
  31. };
  32. typedef enum //_ag_timer_id
  33. {
  34. AG_TIMER_ID_GLO_TASK,
  35. AG_TIMER_ID_LIGHT_EFFECT,
  36. AG_TIMER_ID_RHYTHM,
  37. AG_TIMER_ID_LIGHT_TIME,
  38. AG_TIMER_ID_FLASH_SAVE,
  39. AG_TIMER_ID_POWER_CHECK,
  40. AG_TIMER_ID_TEST,
  41. AG_TIMER_ID_MAX,
  42. }AgTimerId;
  43. typedef enum
  44. {
  45. SYS_STATE_NULL = 0,
  46. }SysRun_t;
  47. typedef struct _g_sys
  48. {
  49. SysRun_t run_state;
  50. }Sys_t;
  51. extern Sys_t g_sys;
  52. typedef struct _sys_event
  53. {
  54. uint32_t enent_flag;
  55. }SysEvent;
  56. typedef struct _sys_event_info
  57. {
  58. uint32_t enent_flag_bit;
  59. uint32_t execute_time;
  60. void (*execute_cb)(void);
  61. }SysEvenInfo;
  62. typedef struct _analog_timer
  63. {
  64. uint8_t timer_id;
  65. void (*cb)(void);
  66. //volatile uint8_t en;
  67. volatile uint16_t timing;
  68. volatile uint32_t record_time;
  69. }AnalogTimer_t;
  70. uint32_t get_sys_time(void);
  71. //其他项
  72. enum
  73. {
  74. GLO_DEFAULT_VAL = 0xFF, //通用缺省值
  75. GLO_RESET = 0,
  76. GLO_NO_ERR = 0,
  77. GLO_ERR = 1,
  78. GLO_DIS = 0,
  79. GLO_EN = 1,
  80. AG_TIMER_RECOVER = 0,
  81. };
  82. void clr_format_transition(uint8_t ts_type, uint8_t ts_num, uint8_t *clr_8, uint32_t *clr_32);
  83. void sys_param_init(void);
  84. void ag_timer_sched(void);
  85. uint32_t u_get_sys_time(void);
  86. uint8_t u_ag_timer_start(AgTimerId timer_id, uint16_t timing, void (*callback)(void));
  87. uint8_t u_ag_timer_stop(AgTimerId timer_id);
  88. void sys_event_init(void);
  89. uint8_t sys_event_new(uint16_t dely_time, void (*execute_cb)(void));
  90. void sys_event_sched(void);
  91. #endif