u_global.h 2.5 KB

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