您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

61 行
1.4 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. *
  42. * @param[out] *timObj 接收定时器参数地址
  43. *
  44. * @return int8_t 返回结果
  45. * @retval 0 成功
  46. * @retval -1 失败
  47. *
  48. * @note *timName "timx" x : 10、11、13、14
  49. */
  50. int8_t GetTimObj(char *timName, TIM_OBJ *timObj);
  51. #endif