no-OS
pwm.h
Go to the documentation of this file.
1 /***************************************************************************/
39 #ifndef PWM_H_
40 #define PWM_H_
41 
42 /******************************************************************************/
43 /***************************** Include Files **********************************/
44 /******************************************************************************/
45 #include <stdint.h>
46 #include <stdbool.h>
47 
48 /******************************************************************************/
49 /*************************** Types Declarations *******************************/
50 /******************************************************************************/
60 };
61 
68  uint32_t id;
70  uint32_t period_ns;
72  uint32_t duty_cycle_ns;
74  uint32_t phase_ns;
78  void *extra;
79 };
80 
85 struct pwm_desc {
87  uint32_t id;
89  uint32_t period_ns;
91  uint32_t duty_cycle_ns;
93  uint32_t phase_ns;
97  bool enabled;
99  void *extra;
100 };
101 
102 /******************************************************************************/
103 /************************ Functions Declarations ******************************/
104 /******************************************************************************/
105 /* Initialize the PWM generator device */
106 int32_t pwm_init(struct pwm_desc **desc,
107  const struct pwm_init_param *param);
108 
109 /* Free the resources used by the PWM generator device */
110 int32_t pwm_remove(struct pwm_desc *desc);
111 
112 /* Enable PWM generator device */
113 int32_t pwm_enable(struct pwm_desc *desc);
114 
115 /* Disable PWM generator device */
116 int32_t pwm_disable(struct pwm_desc *desc);
117 
118 /* Set period of PWM generator device */
119 int32_t pwm_set_period(struct pwm_desc *desc,
120  uint32_t period_ns);
121 
122 /* Get period of PWM generator device */
123 int32_t pwm_get_period(struct pwm_desc *desc,
124  uint32_t *period_ns);
125 
126 /* Set duty cycle of PWM generator device */
127 int32_t pwm_set_duty_cycle(struct pwm_desc *desc,
128  uint32_t duty_cycle_ns);
129 
130 /* Get period of PWM generator device */
131 int32_t pwm_get_duty_cycle(struct pwm_desc *desc,
132  uint32_t *duty_cycle_ns);
133 
134 /* Set the phase of PWM generator channel */
135 int32_t pwm_set_phase(struct pwm_desc *desc,
136  uint32_t phase_ns);
137 
138 /* Get the phase of PWM generator channel */
139 int32_t pwm_get_phase(struct pwm_desc *desc,
140  uint32_t *phase_ns);
141 
142 /* Set polarity of PWM generator device */
143 int32_t pwm_set_polarity(struct pwm_desc *desc,
144  enum pwm_polarity polarity);
145 
146 /* Set polarity of PWM generator device */
147 int32_t pwm_get_polarity(struct pwm_desc *desc,
148  enum pwm_polarity *polarity);
149 
150 #endif
pwm_set_phase
int32_t pwm_set_phase(struct pwm_desc *desc, uint32_t phase_ns)
Set phase of PWM generator device.
Definition: axi_pwm.c:237
pwm_enable
int32_t pwm_enable(struct pwm_desc *desc)
Enable PWM generator device.
Definition: axi_pwm.c:107
pwm_init_param::phase_ns
uint32_t phase_ns
Definition: pwm.h:74
pwm_get_polarity
int32_t pwm_get_polarity(struct pwm_desc *desc, enum pwm_polarity *polarity)
Definition: pwm.c:293
PWM_POLARITY_HIGH
@ PWM_POLARITY_HIGH
Definition: pwm.h:57
pwm_get_period
int32_t pwm_get_period(struct pwm_desc *desc, uint32_t *period_ns)
Get period of PWM generator device.
Definition: axi_pwm.c:178
pwm_init
int32_t pwm_init(struct pwm_desc **desc, const struct pwm_init_param *param)
Initialize the pwm axi generator and the handler associated with it.
Definition: axi_pwm.c:278
pwm_desc::polarity
enum pwm_polarity polarity
Definition: pwm.h:95
pwm_disable
int32_t pwm_disable(struct pwm_desc *desc)
Disable PWM generator device.
Definition: axi_pwm.c:128
pwm_init_param
Structure containing the init parameters needed by the PWM generator.
Definition: pwm.h:66
pwm_set_duty_cycle
int32_t pwm_set_duty_cycle(struct pwm_desc *desc, uint32_t duty_cycle_ns)
Set duty cycle of PWM generator device.
Definition: axi_pwm.c:193
pwm_desc::extra
void * extra
Definition: pwm.h:99
pwm_set_period
int32_t pwm_set_period(struct pwm_desc *desc, uint32_t period_ns)
Set period of PWM generator device.
Definition: axi_pwm.c:150
pwm_polarity
pwm_polarity
Possible polarities of the PWM signal.
Definition: pwm.h:55
PWM_POLARITY_LOW
@ PWM_POLARITY_LOW
Definition: pwm.h:59
pwm_init_param::extra
void * extra
Definition: pwm.h:78
pwm_desc::phase_ns
uint32_t phase_ns
Definition: pwm.h:93
pwm_desc::duty_cycle_ns
uint32_t duty_cycle_ns
Definition: pwm.h:91
pwm_init_param::duty_cycle_ns
uint32_t duty_cycle_ns
Definition: pwm.h:72
pwm_init_param::period_ns
uint32_t period_ns
Definition: pwm.h:70
pwm_desc::enabled
bool enabled
Definition: pwm.h:97
pwm_desc
Structure representing an PWM generator device.
Definition: pwm.h:85
pwm_desc::id
uint32_t id
Definition: pwm.h:87
pwm_init_param::id
uint32_t id
Definition: pwm.h:68
pwm_get_phase
int32_t pwm_get_phase(struct pwm_desc *desc, uint32_t *phase_ns)
Get phase of PWM generator device.
Definition: axi_pwm.c:264
pwm_remove
int32_t pwm_remove(struct pwm_desc *desc)
Free the memory allocated by axi_pwmgen_init().
Definition: axi_pwm.c:370
pwm_get_duty_cycle
int32_t pwm_get_duty_cycle(struct pwm_desc *desc, uint32_t *duty_cycle_ns)
Get duty cycle of PWM generator device.
Definition: axi_pwm.c:223
pwm_desc::period_ns
uint32_t period_ns
Definition: pwm.h:89
pwm_set_polarity
int32_t pwm_set_polarity(struct pwm_desc *desc, enum pwm_polarity polarity)
Definition: pwm.c:281
pwm_init_param::polarity
enum pwm_polarity polarity
Definition: pwm.h:76