u_global.h 2.4 KB

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