~ruther/uni-mam-arm

ref: 327c9f42f5485a6520d317dc6bd1c8acd240e9bc uni-mam-arm/arm03/include/timer.h -rw-r--r-- 734 bytes
327c9f42 — Rutherther Init arm01, arm02, arm03 4 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <stm32f4xx.h>

#ifndef TIMER_H
#define TIMER_H

typedef struct {
  TIM_TypeDef* timer;
  uint8_t idx;
} timer_t;

void timer_init(timer_t* timer, TIM_TypeDef* peripheral, uint8_t timer_idx);
void timer_enable(timer_t* timer);
void timer_disable(timer_t* timer);

void timer_set_refresh(timer_t* timer, uint32_t refresh_value);
void timer_set_counter(timer_t* timer, uint32_t counter);

// TODO: rest of parameters...?
void timer_configure(timer_t* timer, uint8_t buffered_reload, uint16_t prescaler, uint8_t one_pulse_mode);

void timer_enable_interrupt(timer_t* timer);
void timer_disable_interrupt(timer_t* timer);
uint32_t timer_is_interrupt(timer_t* timer);
void timer_clear_interrupt(timer_t* timer);

#endif // TIMER_H
Do not follow this link