air105_timer.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. * Copyright (c) 2022 OpenLuat & AirM2M
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  5. * this software and associated documentation files (the "Software"), to deal in
  6. * the Software without restriction, including without limitation the rights to
  7. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  8. * the Software, and to permit persons to whom the Software is furnished to do so,
  9. * subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in all
  12. * copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  16. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  17. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  18. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  19. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  20. */
  21. #ifndef __AIR105_TIMER_H
  22. #define __AIR105_TIMER_H
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26. /* Includes ------------------------------------------------------------------*/
  27. #include "air105.h"
  28. /* Exported types ------------------------------------------------------------*/
  29. typedef enum
  30. {
  31. TIM_0 = 0,
  32. TIM_1,
  33. TIM_2,
  34. TIM_3,
  35. TIM_4,
  36. TIM_5,
  37. TIM_6,
  38. TIM_7,
  39. }TIM_NumTypeDef;
  40. typedef struct
  41. {
  42. TIM_NumTypeDef TIMx;
  43. uint32_t TIM_Period; /*!< Specifies the period value to be loaded into the active
  44. Auto-Reload Register at the next update event.
  45. This parameter must be a number between 0x0000 and 0xFFFFFFFF. */
  46. }TIM_InitTypeDef;
  47. typedef struct
  48. {
  49. TIM_NumTypeDef TIMx;
  50. uint32_t TIM_LowLevelPeriod;
  51. uint32_t TIM_HighLevelPeriod;
  52. }TIM_PWMInitTypeDef;
  53. typedef enum
  54. {
  55. TIM_Mode_General = 0,
  56. TIM_Mode_PWM = 1
  57. }TIM_ModeTypeDef;
  58. #define IS_TIM_MODE(MODE) (MODE == TIM_Mode_General || MODE == TIM_Mode_PWM)
  59. void TIM_DeInit(TIM_Module_TypeDef *TIMMx);
  60. void TIM_Init(TIM_Module_TypeDef* TIMMx, TIM_InitTypeDef* TIM_InitStruct);
  61. void TIM_PWMInit(TIM_Module_TypeDef* TIMMx, TIM_PWMInitTypeDef* TIM_PWMInitStruct);
  62. void TIM_Cmd(TIM_Module_TypeDef* TIMMx, TIM_NumTypeDef TIMx, FunctionalState NewState);
  63. void TIM_ModeConfig(TIM_Module_TypeDef* TIMMx, TIM_NumTypeDef TIMx, TIM_ModeTypeDef TIM_Mode);
  64. void TIM_SetPeriod(TIM_Module_TypeDef* TIMMx, TIM_NumTypeDef TIMx, uint32_t Period);
  65. void TIM_SetPWMPeriod(TIM_Module_TypeDef* TIMMx, TIM_NumTypeDef TIMx, uint32_t PWM_LowLevelPeriod, uint32_t PWM_HighLevelPeriod);
  66. void TIM_ITConfig(TIM_Module_TypeDef* TIMMx, TIM_NumTypeDef TIMx, FunctionalState NewState);
  67. void TIM_ClearITPendingBit(TIM_Module_TypeDef* TIMMx, TIM_NumTypeDef TIMx);
  68. void TIM_PWMSinglePulseConfig(TIM_Module_TypeDef* TIMMx, TIM_NumTypeDef TIMx, FunctionalState NewState);
  69. void TIM_PWMReloadSinglePulse(TIM_Module_TypeDef *TIMMx, TIM_NumTypeDef TIMx);
  70. ITStatus TIM_GetITStatus(TIM_Module_TypeDef* TIMMx, TIM_NumTypeDef TIMx);
  71. uint32_t TIM_GetAllITStatus(TIM_Module_TypeDef* TIMMx);
  72. ITStatus TIM_GetRawITStatus(TIM_Module_TypeDef* TIMMx, TIM_NumTypeDef TIMx);
  73. uint32_t TIM_GetAllRawITStatus(TIM_Module_TypeDef* TIMMx);
  74. uint32_t TIM_GetCounter(TIM_Module_TypeDef *TIMMx, TIM_NumTypeDef TIMx);
  75. #ifdef __cplusplus
  76. }
  77. #endif
  78. #endif
  79. /************************** (C) COPYRIGHT Megahunt *****END OF FILE****/