You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

56 lines
1.2 KiB

  1. /**
  2. * @file time.h
  3. * @author zhangcheng
  4. * @brief 定时器及PWM输出接口文件
  5. * @version v0.1
  6. * @date 2025-08-06
  7. *
  8. * @copyright Copyright (c) 2025
  9. */
  10. #ifndef _time_H
  11. #define _time_H
  12. #include "stm32f4xx.h"
  13. /**
  14. * @brief 定时器数据结构
  15. * @details
  16. * @note
  17. * @attention
  18. */
  19. typedef struct TIM
  20. {
  21. TIM_TypeDef *TIM;
  22. int8_t (*init)(struct TIM *tim, uint16_t psc, uint32_t per);
  23. void (*deInit)(struct TIM *tim);
  24. void (*setPsc)(struct TIM *tim, uint16_t psc);
  25. void (*setPer)(struct TIM *tim, uint32_t per);
  26. void (*open)(struct TIM *tim);
  27. void (*close)(struct TIM *tim);
  28. void (*openIrq)(struct TIM *tim);
  29. void (*closeIrq)(struct TIM *tim);
  30. void (*registerIrq)(struct TIM *tim, void (*registerFunc)(void *pArg),
  31. void *pArg);
  32. void (*pwmInit)(struct TIM *tim);
  33. void (*pwmDeInit)(struct TIM *tim);
  34. void (*pwmSetPulse)(struct TIM *tim, uint32_t pulse);
  35. } TIM_OBJ;
  36. /**
  37. * @brief 获取定时器
  38. * @details
  39. *
  40. * @param[in] *timName 定时器名称
  41. * @param "timx" x : 10、11、13、14
  42. *
  43. * @return TIM 定时器结构体
  44. */
  45. TIM_OBJ GetTimObj(char *timName);
  46. #endif