drv_hwtimer.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * Copyright (c) 2006-2018, Synwit Technology Co.,Ltd.
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2018-12-10 Zohar_Lee first version
  9. * 2020-07-10 lik rewrite
  10. */
  11. #ifndef __DRV_HWTIMER_H__
  12. #define __DRV_HWTIMER_H__
  13. #include "board.h"
  14. struct swm_hwtimer_cfg
  15. {
  16. char *name;
  17. TIMR_TypeDef *TIMRx;
  18. };
  19. struct swm_hwtimer
  20. {
  21. struct swm_hwtimer_cfg *cfg;
  22. rt_hwtimer_t time_device;
  23. };
  24. #ifndef TIM_DEV_INFO_CONFIG
  25. #define TIM_DEV_INFO_CONFIG \
  26. { \
  27. .maxfreq = 120000000, \
  28. .minfreq = 120000000, \
  29. .maxcnt = 0xFFFFFFFF, \
  30. .cntmode = HWTIMER_CNTMODE_DW, \
  31. }
  32. #endif /* TIM_DEV_INFO_CONFIG */
  33. #ifdef BSP_USING_TIM0
  34. #ifndef TIM0_CFG
  35. #define TIM0_CFG \
  36. { \
  37. .name = "timer0", \
  38. .TIMRx = TIMR0, \
  39. }
  40. #endif /* TIM0_CFG */
  41. #endif /* BSP_USING_TIM0 */
  42. #ifdef BSP_USING_TIM1
  43. #ifndef TIM1_CFG
  44. #define TIM1_CFG \
  45. { \
  46. .name = "timer1", \
  47. .TIMRx = TIMR1, \
  48. }
  49. #endif /* TIM1_CFG */
  50. #endif /* BSP_USING_TIM1 */
  51. #ifdef BSP_USING_TIM2
  52. #ifndef TIM2_CFG
  53. #define TIM2_CFG \
  54. { \
  55. .name = "timer2", \
  56. .TIMRx = TIMR2, \
  57. }
  58. #endif /* TIM2_CFG */
  59. #endif /* BSP_USING_TIM2 */
  60. #ifdef BSP_USING_TIM3
  61. #ifndef TIM3_CFG
  62. #define TIM3_CFG \
  63. { \
  64. .name = "timer3", \
  65. .TIMRx = TIMR3, \
  66. }
  67. #endif /* TIM3_CFG */
  68. #endif /* BSP_USING_TIM3 */
  69. #ifdef BSP_USING_TIM4
  70. #ifndef TIM4_CFG
  71. #define TIM4_CFG \
  72. { \
  73. .name = "timer4", \
  74. .TIMRx = TIMR4, \
  75. }
  76. #endif /* TIM4_CFG */
  77. #endif /* BSP_USING_TIM4 */
  78. #ifdef BSP_USING_TIM5
  79. #ifndef TIM5_CFG
  80. #define TIM5_CFG \
  81. { \
  82. .name = "timer5", \
  83. .TIMRx = TIMR5, \
  84. }
  85. #endif /* TIM5_CFG */
  86. #endif /* BSP_USING_TIM5 */
  87. int rt_hw_hwtimer_init(void);
  88. #endif /* __DRV_HWTIMER_H__ */