示例#1
0
文件: pwmout_api.c 项目: pan-/mbed
void pwmout_pulsewidth_us(pwmout_t *obj, int us)
{
    pwm_t * pwm = (pwm_t *) obj->pwm_struct;
    MBED_ASSERT(pwm);
    
    uint16_t ticks = nrf_timer_us_to_ticks((uint32_t)us, nrf_timer_frequency_get(pwm->timer_reg));
    pwm_ticks_set(pwm, obj->pwm_channel, ticks);
}
示例#2
0
uint32_t nrf_drv_timer_ms_to_ticks(nrf_drv_timer_t const * const p_instance,
                                   uint32_t                      time_ms)
{
    uint32_t freq_in_kHz = 16000;

    freq_in_kHz   = (freq_in_kHz) / (uint32_t)(1 << (nrf_timer_frequency_get(p_instance->p_reg)));
    return (time_ms * freq_in_kHz);
}