api_sysclk.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #ifndef _API_SYSCLK_H_
  2. #define _API_SYSCLK_H_
  3. enum {
  4. SYS_RC2M,
  5. SYS_24M,
  6. SYS_48M,
  7. SYS_60M,
  8. SYS_80M,
  9. SYS_120M,
  10. SYS_160M,
  11. };
  12. enum {
  13. CLK_31K25,
  14. CLK_RCDIV,
  15. };
  16. enum {
  17. INDEX_VOICE = 0,
  18. INDEX_DECODE,
  19. INDEX_STACK,
  20. INDEX_USER,
  21. INDEX_MAX_NB,
  22. };
  23. /**
  24. * @brief Get the clock value last set for the function sys_clk_set()
  25. * @return [SYS_RC2M - SYS_160M]
  26. */
  27. u8 sys_clk_get(void);
  28. /**
  29. * @brief Get the current clock of the system
  30. * @return [SYS_RC2M - SYS_160M]
  31. */
  32. u8 sys_clk_get_cur(void);
  33. u32 sys_clk_nhz_get(void);
  34. /**
  35. * @brief Get RC2M clk frequency
  36. * @param type: 0: system rc2m 1:rtc rc2m
  37. * @return RC2M clk frequency
  38. */
  39. u32 rc2m_clk_nhz_get(u8 type);
  40. u32 pll_clk_nhz_get(void);
  41. /**
  42. * @brief Set system clock,
  43. * @attention If the clock to be set is lower than the value which be set by the function sys_clk_lower_limit_unlock, the setting will not take effect now
  44. * @param [SYS_RC2M, SYS_160M]
  45. */
  46. void sys_clk_set(u32 clk_sel);
  47. bool sys_clk_lower_limit_all_unlock(void);
  48. /**
  49. * @brief Unset the value which be set by sys_clk_lower_limit_lock
  50. * @param index: [INDEX_VOICE, INDEX_MAX_NB)
  51. * @return true or false
  52. */
  53. bool sys_clk_lower_limit_unlock(uint8_t index);
  54. /**
  55. * @brief Set the minimum clock frequency for the system
  56. * @attention If the clock to be set is lower than the current clock of the system, the setting will not take effect now
  57. * @param index: [INDEX_VOICE, INDEX_MAX_NB) sys_clk:[SYS_RC2M - SYS_160M]
  58. * @return true or false
  59. */
  60. bool sys_clk_lower_limit_lock(uint8_t index, uint8_t sys_clk);
  61. #endif