driver_lpwm.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * @File name : driver_lpwm.h
  3. * @Author : Bluetrum IOT Team
  4. * @Date : 2023-03-06
  5. * @Description : This file contains all the functions prototypes for the LPWM library.
  6. *
  7. * Copyright (c) by Bluetrum, All Rights Reserved.
  8. */
  9. #ifndef _DRIVER_LPWM_H
  10. #define _DRIVER_LPWM_H
  11. #include "driver_com.h"
  12. /**
  13. * @brief LPWM Pend Flag Definition
  14. */
  15. typedef enum {
  16. LPWM_FLAG_L_STAGE = 0x01,
  17. } LPWM_FLAG_TYPEDEF;
  18. /**
  19. * @brief LPWM Stage Select Enumeration
  20. */
  21. typedef enum {
  22. LPWM_STAGE_A = 0x01,
  23. LPWM_STAGE_B = 0x02,
  24. LPWM_STAGE_C = 0x04,
  25. LPWM_STAGE_D = 0x08,
  26. LPWM_STAGE_E = 0x10,
  27. LPWM_STAGE_F = 0x20,
  28. LPWM_STAGE_L = 0x40,
  29. LPWM_STAGE_H = 0x80,
  30. } LPWM_STAGE_TYPEDEF;
  31. /**
  32. * @brief LPWM Mode Select Enumeration
  33. */
  34. typedef enum {
  35. LPWM_MODE_NORMAL = 0x00000000,
  36. LPWM_MODE_BREATH = 0x00000002,
  37. } LPWM_MODE_TYPEDEF;
  38. /**
  39. * @brief LPWM Breath Mode Change Dir Select Enumeration
  40. */
  41. typedef enum {
  42. LPWM_DIR_INCREASE = 0x00000000,
  43. LPWM_DIR_DECREASE = 0x00000800,
  44. } LPWM_DIR_TYPEDEF;
  45. /**
  46. * @brief LPWM Stage Init Structure
  47. */
  48. typedef struct {
  49. uint8_t step;
  50. uint16_t repeat;
  51. uint16_t start_duty;
  52. } lpwm_stage_init_typedef;
  53. /**
  54. * @brief LPWM Init Structure
  55. */
  56. typedef struct {
  57. LPWM_MODE_TYPEDEF mode;
  58. LPWM_DIR_TYPEDEF breath_start_dir;
  59. uint16_t period;
  60. uint16_t first_duty;
  61. } lpwm_base_init_typedef;
  62. /********************* Function used to config LPWM peripheral *********************/
  63. void lpwm_init(lpwm_base_init_typedef *lpwm_base_init_struct);
  64. void lpwm_deinit(void);
  65. void lpwm_stage_config(LPWM_STAGE_TYPEDEF stage, lpwm_stage_init_typedef *stage_init_struct, FUNCTIONAL_STATE state);
  66. void lpwm_cmd(FUNCTIONAL_STATE state);
  67. FLAG_STATE lpwm_get_flag(LPWM_FLAG_TYPEDEF flag_type);
  68. void lpwm_clear_flag(LPWM_FLAG_TYPEDEF flag_type);
  69. #endif // _DRIVER_LPWM_H