/* Set period & pulse of the PWM channel, remain disabled. Make sure PWM clock is ON for writing registers.  */
static rt_err_t pwm_device_set(struct rt_device_pwm *device, struct rt_pwm_configuration *configuration)
/* Set period & pulse of the PWM channel, remain disabled. Make sure PWM clock is ON for writing registers.  */
static rt_err_t pwm_device_set(struct rt_device_pwm *device, struct rt_pwm_configuration *configuration)
{
    struct pwm_device *pwm_device = (struct pwm_device *)device;
    uint32_t channel = configuration->channel;
    rt_err_t res;
    res = pwm_channel_period(device, channel, configuration->period);
    if (res == RT_EOK)
    {
        res = pwm_channel_pulse(device, channel, configuration->pulse);
        if (res == RT_EOK)
        {
            rt_pin_mode(pwmx_pin[channel], PIN_MODE_OUTPUT);
            pwm_channel_enable(device, channel, RT_FALSE);
        }
    }
    return res;
}