wm_cpu.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /**
  2. * @file wm_cpu.h
  3. *
  4. * @brief cpu driver module
  5. *
  6. * @author dave
  7. *
  8. * @copyright (c) 2014 Winner Microelectronics Co., Ltd.
  9. */
  10. #ifndef __WM_CPU_H__
  11. #define __WM_CPU_H__
  12. #include "wm_hal.h"
  13. /**BASE PLL CLOCK*/
  14. #define W805_PLL_CLK_MHZ (480)
  15. #define IS_NVIC_DEVICE_IRQ(IRQ) ((IRQ) >= (IRQn_Type)0x00U)
  16. enum CPU_CLK{
  17. CPU_CLK_240M = 2,
  18. CPU_CLK_160M = 3,
  19. CPU_CLK_80M = 6,
  20. CPU_CLK_40M = 12,
  21. CPU_CLK_2M = 240,
  22. };
  23. typedef union {
  24. struct {
  25. uint32_t CPU: 8; /*!< bit: 0.. 7 cpu clock divider */
  26. uint32_t WLAN: 8; /*!< bit: 8.. 15 Wlan clock divider */
  27. uint32_t BUS2: 8; /*!< bit: 16.. 23 clock dividing ratio of bus2 & bus1 */
  28. uint32_t PD: 4; /*!< bit: 24.. 27 peripheral divider */
  29. uint32_t RSV: 3; /*!< bit: 28.. 30 Reserved */
  30. uint32_t DIV_EN: 1; /*!< bit: 31 divide frequency enable */
  31. } b;
  32. uint32_t w;
  33. } clk_div_reg;
  34. #define UNIT_MHZ (1000000)
  35. typedef struct{
  36. uint32_t apbclk;
  37. uint32_t cpuclk;
  38. uint32_t wlanclk;
  39. }wm_sys_clk;
  40. typedef enum
  41. {
  42. HAL_TICK_FREQ_10HZ = 10,
  43. HAL_TICK_FREQ_100HZ = 100,
  44. HAL_TICK_FREQ_1KHZ = 1000,
  45. HAL_TICK_FREQ_DEFAULT = HAL_TICK_FREQ_1KHZ
  46. } HAL_TickFreqTypeDef;
  47. void SystemClock_Config(uint32_t clk);
  48. void SystemClock_Get(wm_sys_clk *sysclk);
  49. HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority);
  50. void HAL_IncTick(void);
  51. uint32_t HAL_GetTick(void);
  52. void HAL_Delay(uint32_t Delay);
  53. void HAL_NVIC_SetPriority(IRQn_Type IRQn, uint32_t Priority);
  54. void HAL_NVIC_EnableIRQ(IRQn_Type IRQn);
  55. void HAL_NVIC_DisableIRQ(IRQn_Type IRQn);
  56. #endif /* WM_CPU_H */