Pwm#

group bsp_pwm

Control the PWM peripherals.

Author

Alexandre Abadie alexandre.abadie@inria.fr

Copyright

Inria, 2022

Typedefs

typedef uint8_t pwm_t#

PWM peripheral index.

Functions

void db_pwm_init(pwm_t pwm, const gpio_t *pins, size_t num_channels, uint16_t mtop)#

Initialize the PWM interface (uses the PWM0 peripheral)

PWM frequency = 10Khz PWM resolution = 100 units (1us resolution)

The number of channels must not exceed the size of the array containing the pins.

Parameters:
  • pwm[in] index of the PWM peripheral to initialize

  • pins[in] pointer to array of pointer to GPIO pins

  • num_channels[in] number of channels to configure

  • mtop[in] max value of the PWM counter register

void db_pwm_channel_set(pwm_t pwm, uint8_t channel, uint16_t value)#

Set the value of a PWM channel.

The channel value must be lower or equal to 3.

Parameters:
  • pwm[in] index of the PWM peripheral

  • channel[in] index of channel to set

  • value[in] value to set to the channel

void db_pwm_channels_set(pwm_t pwm, uint16_t *values)#

Set the values of all PWM channels.

The array of values must be 4 bytes long exactly.

Parameters:
  • pwm[in] index of the PWM peripheral

  • values[in] pointer to the array containing the values to set