api_sys.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. #ifndef _API_SYS_H_
  2. #define _API_SYS_H_
  3. #define CACHE_ADDR 0x70000
  4. typedef uint8_t flash_id_t[16];
  5. /**
  6. * @brief Sets whether to call the timer2 interrupt callback function
  7. * @param tmr5ms_en: set to true, usr_tmr5ms_thread_callback will be called once in 5ms
  8. * @param tmr1ms_en: set to true, usr_tmr1ms_isr_callback will be called once in 1ms
  9. */
  10. void sys_set_tmr_enable(bool tmr5ms_en, bool tmr1ms_en);
  11. /**
  12. * @brief system reset init
  13. * @param wk pin 10s reset config
  14. * @return system reset source
  15. reset source: BIT(31):PWRUP_RST
  16. BIT(24):SW_RST
  17. BIT(19):WK Pin 10S_RST
  18. BIT(18):WAKEUP_RST
  19. BIT(17):VUSB_RST
  20. BIT(16):WDT_RST
  21. BIT(20)|BIT(7):LVD_RST
  22. */
  23. u32 sys_rst_init(bool wko10s_rst);
  24. /**
  25. * @brief dump the system reset source info
  26. * @param reason: system reset source, can be get by the return value of the function sys_rst_init
  27. */
  28. void sys_rst_dump(u32 reason);
  29. /**
  30. * @brief The system reset can be triggered by software
  31. * @param software reset source, it can be define by the user
  32. */
  33. void sw_reset_kick(u8 source);
  34. /**
  35. * @brief Get the software reset source,it must be called as soon as the system is reset
  36. * @return software reset source
  37. */
  38. u8 sw_reset_source_get(void);
  39. void xosc_init(void);
  40. /**
  41. * @brief Gets a random number between 0 and num
  42. * @param number
  43. */
  44. u16 get_random(u16 num);
  45. /**
  46. * @brief get the number of bytes used by the UTF8 character
  47. * @param Returns the number of bytes used by the UTF8 character
  48. */
  49. u8 utf8_char_size_get(u8 code);
  50. /**
  51. * @brief utf8 convert to unicode
  52. * @param in
  53. * @param char_size
  54. */
  55. u16 utf8_convert_to_unicode(u8 *in, u8 char_size);
  56. int s_abs(int x);
  57. bool bt_get_ft_trim_value(void *rf_param);
  58. void io_sleep(void);
  59. void io_resume(void);
  60. /**
  61. * @brief Read data from the chip's built-in flash
  62. * @param buf
  63. * @param flash address to read
  64. * @param len
  65. */
  66. uint os_spiflash_read(void *buf, u32 addr, uint len);
  67. /**
  68. * @brief Program data to the chip's built-in flash
  69. * @param buf
  70. * @param flash address to program to
  71. * @param len, must be less than or equal to 256
  72. */
  73. void os_spiflash_program(void *buf, u32 addr, uint len);
  74. /**
  75. * @brief Erase the chip's built-in flash
  76. * @param flash base addresses that need to be erased, erase 4K bytes at a time
  77. */
  78. void os_spiflash_erase(u32 addr);
  79. /**
  80. * @brief Get the chip's built-in flash id
  81. * @param flash id buf
  82. */
  83. void os_spiflash_id_get(flash_id_t id);
  84. #endif // _API_SYS_H_