app_pwm.h
Go to the documentation of this file.
1
50 #ifndef _APP_PWM_H_
51 #define _APP_PWM_H_
52
53 #include "gr55xx_hal.h"
54 #include "app_io.h"
55 #include "app_drv_error.h"
56
57 #ifdef __cplusplus
58 extern "C" {
59 #endif
60
61 #ifdef HAL_PWM_MODULE_ENABLED
62
67 #define APP_PWM_PIN_ENABLE 1
68 #define APP_PWM_PIN_DISABLE 0
79 typedef enum
80 {
81 APP_PWM_ID_0,
82 APP_PWM_ID_1,
83 APP_PWM_ID_MAX
84 } app_pwm_id_t;
93 typedef struct
94 {
95 app_io_type_t type;
96 app_io_mux_t mux;
97 uint32_t pin;
99 app_io_pull_t pull;
100 uint8_t enable;
101 } app_pwm_pin_t;
102
103
107 typedef struct
108 {
109 app_pwm_pin_t channel_a;
110 app_pwm_pin_t channel_b;
111 app_pwm_pin_t channel_c;
112 } app_pwm_pin_cfg_t;
113
114
118 typedef struct
119 {
120 uint8_t duty;
123 uint8_t drive_polarity;
125 } app_pwm_channel_init_t;
134 typedef enum
135 {
136 APP_PWM_ACTIVE_CHANNEL_A = 0x01,
137 APP_PWM_ACTIVE_CHANNEL_B = 0x02,
138 APP_PWM_ACTIVE_CHANNEL_C = 0x04,
139 APP_PWM_ACTIVE_CHANNEL_ALL = 0x07,
140 APP_PWM_ACTIVE_CHANNEL_CLEARED = 0x00
141 } app_pwm_active_channel_t;
150 typedef struct
151 {
152 app_pwm_id_t id;
153 app_pwm_pin_cfg_t pin_cfg;
154 app_pwm_active_channel_t active_channel;
155 pwm_init_t init;
156 } app_pwm_params_t;
160 /* Exported functions --------------------------------------------------------*/
175 uint16_t app_pwm_init(app_pwm_params_t *p_params);
176
177
187 uint16_t app_pwm_deinit(app_pwm_id_t id);
188
189
199 uint16_t app_pwm_start(app_pwm_id_t id);
200
201
211 uint16_t app_pwm_stop(app_pwm_id_t id);
212
223 uint16_t app_pwm_update_freq(app_pwm_id_t id, uint32_t freq);
224
236 uint16_t app_pwm_config_channel(app_pwm_id_t id, app_pwm_active_channel_t channel, app_pwm_channel_init_t *p_config);
237
240 #endif
241
242 #ifdef __cplusplus
243 }
244 #endif
245
246 #endif
247
APP_PWM_ACTIVE_CHANNEL_A
@ APP_PWM_ACTIVE_CHANNEL_A
Definition: app_pwm.h:136
app_pwm_channel_init_t
PWM Channel init Structure definition.
Definition: app_pwm.h:119
app_pwm_params_t::init
pwm_init_t init
Definition: app_pwm.h:155
app_pwm_pin_cfg_t::channel_a
app_pwm_pin_t channel_a
Definition: app_pwm.h:109
app_pwm_pin_cfg_t::channel_b
app_pwm_pin_t channel_b
Definition: app_pwm.h:110
app_pwm_active_channel_t
app_pwm_active_channel_t
PWM active channel Enumerations definition.
Definition: app_pwm.h:135
app_pwm_pin_t
PWM IO configuration Structures.
Definition: app_pwm.h:94
pwm_init_t
PWM init Structure definition.
Definition: gr55xx_hal_pwm.h:128
app_pwm_update_freq
uint16_t app_pwm_update_freq(app_pwm_id_t id, uint32_t freq)
Update the PWM frequency on the output.
app_pwm_pin_t::enable
uint8_t enable
Definition: app_pwm.h:100
app_pwm_pin_t::pin
uint32_t pin
Definition: app_pwm.h:97
APP_PWM_ACTIVE_CHANNEL_ALL
@ APP_PWM_ACTIVE_CHANNEL_ALL
Definition: app_pwm.h:139
app_pwm_init
uint16_t app_pwm_init(app_pwm_params_t *p_params)
Initialize the pwm peripheral.
app_io_pull_t
app_io_pull_t
GPIO pull Enumerations definition.
Definition: app_io.h:187
app_io_type_t
app_io_type_t
GPIO type Enumerations definition.
Definition: app_io.h:141
APP_PWM_ACTIVE_CHANNEL_C
@ APP_PWM_ACTIVE_CHANNEL_C
Definition: app_pwm.h:138
app_pwm_params_t::id
app_pwm_id_t id
Definition: app_pwm.h:152
APP_PWM_ID_0
@ APP_PWM_ID_0
Definition: app_pwm.h:81
app_io.h
Header file containing functions prototypes of GPIO app library.
app_pwm_start
uint16_t app_pwm_start(app_pwm_id_t id)
Starts the PWM signal generation on the output.
app_pwm_pin_t::pull
app_io_pull_t pull
Definition: app_pwm.h:99
app_pwm_id_t
app_pwm_id_t
PWM module Enumerations definition.
Definition: app_pwm.h:80
APP_PWM_ID_1
@ APP_PWM_ID_1
Definition: app_pwm.h:82
app_pwm_stop
uint16_t app_pwm_stop(app_pwm_id_t id)
Stops the PWM signal generation on the output.
APP_PWM_ACTIVE_CHANNEL_B
@ APP_PWM_ACTIVE_CHANNEL_B
Definition: app_pwm.h:137
app_pwm_channel_init_t::duty
uint8_t duty
Definition: app_pwm.h:120
app_pwm_channel_init_t::drive_polarity
uint8_t drive_polarity
Definition: app_pwm.h:123
app_pwm_params_t
PWM parameters structure definition.
Definition: app_pwm.h:151
gr55xx_hal.h
This file contains all the functions prototypes for the HAL module driver.
app_pwm_pin_cfg_t
PWM configuration Structures.
Definition: app_pwm.h:108
app_pwm_config_channel
uint16_t app_pwm_config_channel(app_pwm_id_t id, app_pwm_active_channel_t channel, app_pwm_channel_init_t *p_config)
Initialize the PWM channels according to the specified parameters.
app_pwm_pin_t::type
app_io_type_t type
Definition: app_pwm.h:95
app_io_mux_t
app_io_mux_t
GPIO mux Enumerations definition.
Definition: app_io.h:198
app_pwm_params_t::pin_cfg
app_pwm_pin_cfg_t pin_cfg
Definition: app_pwm.h:153
APP_PWM_ID_MAX
@ APP_PWM_ID_MAX
Definition: app_pwm.h:83
app_pwm_deinit
uint16_t app_pwm_deinit(app_pwm_id_t id)
De-initialize the pwm peripheral.
app_pwm_pin_cfg_t::channel_c
app_pwm_pin_t channel_c
Definition: app_pwm.h:111
app_pwm_params_t::active_channel
app_pwm_active_channel_t active_channel
Definition: app_pwm.h:154
app_drv_error.h
Header file of app driver error code.
app_pwm_pin_t::mux
app_io_mux_t mux
Definition: app_pwm.h:96
APP_PWM_ACTIVE_CHANNEL_CLEARED
@ APP_PWM_ACTIVE_CHANNEL_CLEARED
Definition: app_pwm.h:140