nu_timer.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /**************************************************************************//**
  2. * @file timer.h
  3. * @brief N9H30 series TIMER driver header file
  4. *
  5. * @note
  6. * SPDX-License-Identifier: Apache-2.0
  7. * Copyright (C) 2018 Nuvoton Technology Corp. All rights reserved.
  8. *****************************************************************************/
  9. #ifndef __NU_TIMER_H__
  10. #define __NU_TIMER_H__
  11. #ifdef __cplusplus
  12. extern "C"
  13. {
  14. #endif
  15. #include "N9H30.h"
  16. #define TIMER_COUNTER_ENABLE (1UL << 30) /*!< Timer counter enable */
  17. #define TIMER_INTERRUPT_ENABLE (1UL << 29) /*!< Timer interrupt enable */
  18. #define TIMER_ONESHOT_MODE (0UL) /*!< Timer working in one shot mode */
  19. #define TIMER_PERIODIC_MODE (1UL << 27) /*!< Timer working in periodic mode */
  20. #define TIMER_CONTINUOUS_MODE (3UL << 27) /*!< Timer working in continuous mode */
  21. #define TIMER_COUNTER_RESET (1UL << 26) /*!< Timer reset counter */
  22. #define TIMER_IS_ALIVE (1UL << 25) /*!< Timer is alive */
  23. static __inline void TIMER_ClearIntFlag(uint32_t timer)
  24. {
  25. outpw(REG_TMR_ISR, (1 << timer));
  26. }
  27. static __inline uint32_t TIMER_GetIntFlag(uint32_t timer)
  28. {
  29. return inpw(REG_TMR_ISR) & (1 << timer);
  30. }
  31. void TIMER_SET_CMP_VALUE(uint32_t timer, uint32_t u32Cmpr);
  32. void TIMER_SET_OPMODE(uint32_t timer, uint32_t u32OpMode);
  33. void TIMER_SET_PRESCALE_VALUE(uint32_t timer, uint32_t u32PreScale);
  34. uint32_t TIMER_GetModuleClock(uint32_t timer);
  35. void TIMER_Start(uint32_t timer);
  36. void TIMER_Stop(uint32_t timer);
  37. void TIMER_ClearCounter(uint32_t timer);
  38. uint32_t TIMER_GetCounter(uint32_t timer);
  39. uint32_t TIMER_GetCompareData(uint32_t timer);
  40. void TIMER_EnableInt(uint32_t timer);
  41. void TIMER_DisableInt(uint32_t timer);
  42. void TIMER_Close(uint32_t timer);
  43. uint32_t TIMER_Open(uint32_t timer, uint32_t u32Mode, uint32_t u32Freq);
  44. __inline void TIMER_ClearIntFlag(uint32_t timer);
  45. __inline uint32_t TIMER_GetIntFlag(uint32_t timer);
  46. #ifdef __cplusplus
  47. }
  48. #endif
  49. #endif //__NU_TIMER_H__
  50. /*** (C) COPYRIGHT 2018 Nuvoton Technology Corp. ***/