Function riot_sys::pwm_init

source ·
pub unsafe extern "C" fn pwm_init(
    dev: pwm_t,
    mode: pwm_mode_t,
    freq: u32,
    res: u16
) -> u32
Expand description

@brief Initialize a PWM device

The PWM module is based on virtual PWM devices, which can have one or more channels. The PWM devices can be configured to run with a given frequency and resolution, which are always identical for the complete device, hence for every channel on a device.

The desired frequency and resolution may not be possible on a given device when chosen too large. In this case the PWM driver will always keep the resolution and decrease the frequency if needed. To verify the correct settings compare the returned value which is the actually set frequency.

@param[in] dev PWM device to initialize @param[in] mode PWM mode, left, right or center aligned @param[in] freq PWM frequency in Hz @param[in] res PWM resolution

@return actual PWM frequency on success @return 0 on error