Exemplo n.º 1
0
void stm32_timer_start(EXO* exo, TIMER_NUM num, TIMER_VALUE_TYPE value_type, unsigned int value)
{
    switch (value_type)
    {
    case TIMER_VALUE_HZ:
        stm32_timer_setup_hz(exo, num, value);
        break;
    case TIMER_VALUE_US:
        stm32_timer_setup_us(exo, num, value);
        break;
    default:
        stm32_timer_setup_clk(num, value);
    }

    TIMER_REGS[num]->CNT = 0;
    TIMER_REGS[num]->EGR = TIM_EGR_UG;
    TIMER_REGS[num]->CR1 |= TIM_CR1_CEN;
}
Exemplo n.º 2
0
static inline void stm32_timer_setup_hz(EXO* exo, TIMER_NUM num, unsigned int hz)
{
    unsigned int clk;
    clk = stm32_timer_get_clock(exo, num) / hz;
    stm32_timer_setup_clk(num, clk);
}
Exemplo n.º 3
0
static inline void stm32_timer_setup_us(EXO* exo, TIMER_NUM num, unsigned int us)
{
    unsigned int clk;
    clk = stm32_timer_get_clock(exo, num) / 1000000 * us;
    stm32_timer_setup_clk(num, clk);
}
Exemplo n.º 4
0
static inline void stm32_timer_setup_hz(CORE* core, TIMER_NUM num, unsigned int hz)
{
    unsigned int clk;
    clk = stm32_timer_get_clock(core, num) / hz;
    stm32_timer_setup_clk(num, clk);
}