|
enum | hal_timer_channel_t {
HAL_TIMER_CH1 = 0u,
HAL_TIMER_CH2 = 1u,
HAL_TIMER_CH3 = 2u,
HAL_TIMER_CH4 = 3u,
HAL_TIMER_CH1N = 16u,
HAL_TIMER_CH2N = 17u,
HAL_TIMER_CH3N = 18u
} |
| Defines the capture / compare channel of a timer. More...
|
|
enum | hal_timer_mode_t {
HAL_TIMER_MODE_UP = 0x0,
HAL_TIMER_MODE_DOWN = 0x1,
HAL_TIMER_MODE_CENTER1 = 0x2,
HAL_TIMER_MODE_CENTER2 = 0x4,
HAL_TIMER_MODE_CENTER3 = 0x6
} |
| Defines counting mode of timer. More...
|
|
enum | hal_timer_run_t { HAL_TIMER_RUN_CONTINOUS = 0x0,
HAL_TIMER_RUN_ONCE = 0x1
} |
| Defines run mode of timer. More...
|
|
enum | hal_timer_irq_t {
HAL_TIMER_IRQ_UE = 0x01,
HAL_TIMER_IRQ_CC1 = 0x02,
HAL_TIMER_IRQ_CC2 = 0x04,
HAL_TIMER_IRQ_CC3 = 0x08,
HAL_TIMER_IRQ_CC4 = 0x10,
HAL_TIMER_IRQ_TRIGGER = 0x40
} |
| Defines the different interrupts used by the timer. More...
|
|
enum | hal_timer_dmasrc_t {
HAL_TIMER_DMA_UDE = 0x0100,
HAL_TIMER_DMA_CC1 = 0x0200,
HAL_TIMER_DMA_CC2 = 0x0400,
HAL_TIMER_DMA_CC3 = 0x0800,
HAL_TIMER_DMA_CC4 = 0x1000,
HAL_TIMER_DMA_TRG = 0x4000
} |
|
enum | hal_timer_mastermode_t {
HAL_TIMER_MASTER_RESET = 0u,
HAL_TIMER_MASTER_ENABLE = 1u,
HAL_TIMER_MASTER_UPDATE = 2u,
HAL_TIMER_MASTER_COMPARE = 3u,
HAL_TIMER_MASTER_COMPOC1 = 4u,
HAL_TIMER_MASTER_COMPOC2 = 5u,
HAL_TIMER_MASTER_COMPOC3 = 6u,
HAL_TIMER_MASTER_COMPOC4 = 7u
} |
|
enum | hal_timer_polarity_t { HAL_TIMER_POLARITY_HIGH = 0x0,
HAL_TIMER_POLARITY_LOW = 0x1,
HAL_TIMER_POLARITY_BOTH = 0x5
} |
| Defines polarity. More...
|
|
enum | hal_timer_psc_t { HAL_TIMER_PSC_OFF = 0x0,
HAL_TIMER_PSC_DIV2 = 0x1,
HAL_TIMER_PSC_DIV4 = 0x2,
HAL_TIMER_PSC_DIV8 = 0x3
} |
| Defines the filter prescaler. More...
|
|
enum | hal_timer_filter_t {
HAL_TIMER_FILTER_OFF = 0u,
HAL_TIMER_FILTER_INT_N2 = 1u,
HAL_TIMER_FILTER_INT_N4 = 2u,
HAL_TIMER_FILTER_INT_N8 = 3u,
HAL_TIMER_FILTER_DTS2_N6 = 4u,
HAL_TIMER_FILTER_DTS2_N8 = 5u,
HAL_TIMER_FILTER_DTS4_N6 = 6u,
HAL_TIMER_FILTER_DTS4_N8 = 7u,
HAL_TIMER_FILTER_DTS8_N6 = 8u,
HAL_TIMER_FILTER_DTS8_N8 = 9u,
HAL_TIMER_FILTER_DTS16_N5 = 10u,
HAL_TIMER_FILTER_DTS16_N6 = 11u,
HAL_TIMER_FILTER_DTS16_N8 = 12u,
HAL_TIMER_FILTER_DTS32_N5 = 13u,
HAL_TIMER_FILTER_DTS32_N6 = 14u,
HAL_TIMER_FILTER_DTS32_N8 = 15u
} |
|
enum | hal_timer_oc_mode_t {
HAL_TIMER_OCMODE_NONE = 0x0,
HAL_TIMER_OCMODE_ACTIVE = 0x1,
HAL_TIMER_OCMODE_INACTIVE = 0x2,
HAL_TIMER_OCMODE_TOGGLE = 0x3,
HAL_TIMER_OCMODE_PWM1 = 0x6,
HAL_TIMER_OCMODE_PWM2 = 0x7
} |
| Defines mode of the output capture unit. More...
|
|
enum | hal_timer_ic_sel_t { HAL_TIMER_IC_SEL_DIRECT = 0x1,
HAL_TIMER_IC_SEL_INDIRECT = 0x2,
HAL_TIMER_IC_SEL_TRC = 0x3
} |
| Defines the route for trigger input. More...
|
|
enum | hal_timer_source_t { HAL_TIMER_CLKSRC_INT,
HAL_TIMER_CLKSRC_ETRF,
HAL_TIMER_CLKSRC_TRGI
} |
| Defines the source for the counter source. More...
|
|
enum | hal_timer_clk_dts_t { HAL_TIMER_CLK_OFF = 0x00,
HAL_TIMER_CLK_DIV2 = 0x01,
HAL_TIMER_CLK_DIV4 = 0x02
} |
| Divider used for generating sampling clock for digital filters. More...
|
|
enum | hal_timer_trgsrc_t {
HAL_TIMER_TRGSRC_ITR0 = 0u,
HAL_TIMER_TRGSRC_ITR1 = 1u,
HAL_TIMER_TRGSRC_ITR2 = 2u,
HAL_TIMER_TRGSRC_ITR3 = 3u,
HAL_TIMER_TRGSRC_TI1F_ED = 4u,
HAL_TIMER_TRGSRC_TI1FP = 5u,
HAL_TIMER_TRGSRC_TI2FP = 6u,
HAL_TIMER_TRGSRC_ETRF = 7u
} |
| Defines the source for TRG. More...
|
|
enum | hal_timer_slavemode_t {
HAL_TIMER_SLAVE_OFF = 0u,
HAL_TIMER_SLAVE_ENC1 = 1u,
HAL_TIMER_SLAVE_ENC2 = 2u,
HAL_TIMER_SLAVE_ENC3 = 3u,
HAL_TIMER_SLAVE_RESET = 4u,
HAL_TIMER_SLAVE_GATED = 5u,
HAL_TIMER_SLAVE_TRIGGER = 6u,
HAL_TIMER_SLAVE_EXT = 7u
} |
|
|
void | hal_timer_reset (reg_tim_t *timer) __attribute__((deprecated("Please use ATIMx_RESET()."))) |
| Resets the specified timer to its default values. More...
|
|
void | hal_timer_init_base (reg_tim_t *timer, hal_timer_base_init_t init) |
| Initializes the basic timer according to the specified parameters. More...
|
|
void | hal_timer_init_clock (reg_tim_t *timer, hal_timer_clock_init_t init) |
| Initializes the clock source to be used by timer. More...
|
|
void | hal_timer_init_input (reg_tim_t *timer, hal_timer_channel_t channel, hal_timer_input_init_t init) |
| Configures the specified channel and timer input capture mode. More...
|
|
void | hal_timer_init_output (reg_tim_t *timer, hal_timer_channel_t channel, hal_timer_output_init_t init) |
| Configures the specified channel and timer output compare mode. More...
|
|
void | hal_timer_start (reg_tim_t *timer) |
| Start specified timer. More...
|
|
void | hal_timer_stop (reg_tim_t *timer) |
| Stops specified timer. More...
|
|
void | hal_timer_channel_set (reg_tim_t *timer, hal_timer_channel_t channel, hal_bool_t status) |
| Enables channel on specified timer. More...
|
|
void | hal_timer_irq_set (reg_tim_t *timer, hal_timer_irq_t irq, hal_bool_t status) |
| Enables interrupt on specified timer. More...
|
|
hal_bool_t | hal_timer_irq_status (reg_tim_t *timer, hal_timer_irq_t irq) |
| Return status of specified timers interrupt. More...
|
|
void | hal_timer_irq_clear (reg_tim_t *timer, hal_timer_irq_t irq) |
| Clear specified timers interrupt. More...
|
|
void | hal_timer_dma_set (reg_tim_t *timer, hal_timer_dmasrc_t dma, hal_bool_t status) |
| Enable DMA for specific timer. More...
|
|
uint32_t | hal_timer_counter_read (reg_tim_t *timer) |
| Return value of specified timers counter register. More...
|
|
void | hal_timer_reload_write (reg_tim_t *timer, uint32_t value) |
| Set reload value of specified timer. More...
|
|
void | hal_timer_prescaler_write (reg_tim_t *timer, uint32_t value) |
| Set prescaler value of specified timer. More...
|
|
uint32_t | hal_timer_compare_read (reg_tim_t *timer, hal_timer_channel_t channel) |
| Return compare register value of specified timer and channel. More...
|
|
int8_t | hal_timer_compare_write (reg_tim_t *timer, hal_timer_channel_t channel, uint32_t value) |
| Set value of compare register of specified timer and channel. More...
|
|
Interface of module hal_timer.
Example of programming a basic timer:
Additional pwm channel:
Additional output compare (oc) mode:
- enable gpio peripheral clock -> GPIOx_ENABLE();
- fill gpio output struct to define outputpin -> hal_gpio_output_t gpio = ...;
- init gpio as alternative functions to specific timer -> hal_gpio_init_alternate();
- fill output compare init struct -> hal_timer_output_init_t timer_output = ...;
- hal_timer_init_output(TIM1, HAL_TIMER_CHx, hal_timer_output_init_t);
Additional Input capture (ic) mode:
Only for external capture trigger
- enable gpio peripheral clock -> GPIOx_ENABLE();
- fill gpio output struct to defnine inputpin -> hal_gpio_output_t;
- init gpio as alternative functions to specific timer -> hal_gpio_init_alternate();
For all Input capture trigger sources
- start/stop timer -> hal_timer_start(TIM1); -> hal_timer_stop(TIM1);
$Id$