pwm: add option to set channel output polarity with IOCTL command

Channel polarity can now be set with PWMIOC_SETCHARACTERISTICS ioctl
command as field cpol was added to pwm_info_s structure. This way the
polarity can be easily set from application layer for each channel
apart and also can be change on at runtime if required (although this is
not likely).

Helper defines were also added to simplify the definition of low and high
polarity level. Architecture level should take care of writing the
polarity to correct MCU registers.

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
This commit is contained in:
Michal Lenc
2023-08-23 18:01:34 +02:00
committed by Alan Carvalho de Assis
parent 9117cf44e1
commit f851b79f89
+13
View File
@@ -114,6 +114,17 @@
#define PWMIOC_START _PWMIOC(3)
#define PWMIOC_STOP _PWMIOC(4)
/* PWM channel polarity *****************************************************/
/* These are helper definitions for setting PWM channel output polarity to
* logical low or high level. The pulsed output should start with this
* logical value and should return to it when the output is disabled.
*/
#define PWM_CPOL_NDEF 0 /* Not defined, default value by arch driver should be used */
#define PWM_CPOL_LOW 1 /* Logical zero */
#define PWM_CPOL_HIGH 2 /* Logical one */
/****************************************************************************
* Public Types
****************************************************************************/
@@ -134,6 +145,7 @@ struct pwm_chan_s
ub16_t dead_time_a;
ub16_t dead_time_b;
#endif
uint8_t cpol;
int8_t channel;
};
#endif
@@ -161,6 +173,7 @@ struct pwm_info_s
uint32_t count; /* The number of pulse to generate. 0 means to
* generate an indefinite number of pulses */
# endif
uint8_t cpol; /* Channel polarity */
#endif /* CONFIG_PWM_MULTICHAN */
FAR void *arg; /* User provided argument to be used in the