30#if defined(LIBOPENCM3_LPTIMER_H)
32#ifndef LIBOPENCM3_LPTIMER_COMMON_H
33#define LIBOPENCM3_LPTIMER_COMMON_H
37#define LPTIM_ISR(tim_base) MMIO32((tim_base) + 0x00)
38#define LPTIM_ICR(tim_base) MMIO32((tim_base) + 0x04)
39#define LPTIM_IER(tim_base) MMIO32((tim_base) + 0x08)
40#define LPTIM_CFGR(tim_base) MMIO32((tim_base) + 0x0C)
41#define LPTIM_CR(tim_base) MMIO32((tim_base) + 0x10)
42#define LPTIM_CMP(tim_base) MMIO32((tim_base) + 0x14)
43#define LPTIM_ARR(tim_base) MMIO32((tim_base) + 0x18)
44#define LPTIM_CNT(tim_base) MMIO32((tim_base) + 0x1C)
46#define LPTIM1_ISR LPTIM_ISR(LPTIM1_BASE)
47#define LPTIM1_ICR LPTIM_ICR(LPTIM1_BASE)
48#define LPTIM1_IER LPTIM_IER(LPTIM1_BASE)
49#define LPTIM1_CFGR LPTIM_CFGR(LPTIM1_BASE)
50#define LPTIM1_CR LPTIM_CR(LPTIM1_BASE)
51#define LPTIM1_CMP LPTIM_CMP(LPTIM1_BASE)
52#define LPTIM1_ARR LPTIM_ARR(LPTIM1_BASE)
53#define LPTIM1_CNT LPTIM_CNT(LPTIM1_BASE)
55#if defined(LPTIM2_BASE)
56#define LPTIM2_ISR LPTIM_ISR(LPTIM2_BASE)
57#define LPTIM2_ICR LPTIM_ICR(LPTIM2_BASE)
58#define LPTIM2_IER LPTIM_IER(LPTIM2_BASE)
59#define LPTIM2_CFGR LPTIM_CFGR(LPTIM2_BASE)
60#define LPTIM2_CR LPTIM_CR(LPTIM2_BASE)
61#define LPTIM2_CMP LPTIM_CMP(LPTIM2_BASE)
62#define LPTIM2_ARR LPTIM_ARR(LPTIM2_BASE)
63#define LPTIM2_CNT LPTIM_CNT(LPTIM2_BASE)
70#define LPTIM_ISR_CMPM (1 << 0)
73#define LPTIM_ISR_ARRM (1 << 1)
76#define LPTIM_ISR_EXTTRIG (1 << 2)
79#define LPTIM_ISR_CMPOK (1 << 3)
82#define LPTIM_ISR_ARROK (1 << 4)
85#define LPTIM_ISR_UP (1 << 5)
88#define LPTIM_ISR_DOWN (1 << 6)
96#define LPTIM_ICR_CMPMCF (1 << 0)
99#define LPTIM_ICR_ARRMCF (1 << 1)
102#define LPTIM_ICR_EXTTRIGCF (1 << 2)
105#define LPTIM_ICR_CMPOKCF (1 << 3)
108#define LPTIM_ICR_ARROKCF (1 << 4)
111#define LPTIM_ICR_UPCF (1 << 5)
114#define LPTIM_ICR_DOWNCF (1 << 6)
122#define LPTIM_IER_CMPMIE (1 << 0)
125#define LPTIM_IER_ARRMIE (1 << 1)
128#define LPTIM_IER_EXTTRIGIE (1 << 2)
131#define LPTIM_IER_CMPOKIE (1 << 3)
134#define LPTIM_IER_ARROKIE (1 << 4)
137#define LPTIM_IER_UPIE (1 << 5)
140#define LPTIM_IER_DOWNIE (1 << 6)
148#define LPTIM_CFGR_CKSEL (1 << 0)
150#define LPTIM_CFGR_CKPOL_SHIFT 1
151#define LPTIM_CFGR_CKPOL_MASK 0x03
152#define LPTIM_CFGR_CKPOL (3 << LPTIM_CFGR_CKPOL_SHIFT)
155#define LPTIM_CFGR_CKPOL_RISING (0 << LPTIM_CFGR_CKPOL_SHIFT)
156#define LPTIM_CFGR_CKPOL_FALLING (1 << LPTIM_CFGR_CKPOL_SHIFT)
157#define LPTIM_CFGR_CKPOL_BOTH (2 << LPTIM_CFGR_CKPOL_SHIFT)
158#define LPTIM_CFGR_CKPOL_ENC_1 (0 << LPTIM_CFGR_CKPOL_SHIFT)
159#define LPTIM_CFGR_CKPOL_ENC_2 (1 << LPTIM_CFGR_CKPOL_SHIFT)
160#define LPTIM_CFGR_CKPOL_ENC_3 (2 << LPTIM_CFGR_CKPOL_SHIFT)
163#define LPTIM_CFGR_CKFLT_SHIFT 3
164#define LPTIM_CFGR_CKFLT_MASK 0x03
165#define LPTIM_CFGR_CKFLT (3 << LPTIM_CFGR_CKFLT_SHIFT)
168#define LPTIM_CFGR_CKFLT_2 (1 << LPTIM_CFGR_CKFLT_SHIFT)
169#define LPTIM_CFGR_CKFLT_4 (2 << LPTIM_CFGR_CKFLT_SHIFT)
170#define LPTIM_CFGR_CKFLT_8 (3 << LPTIM_CFGR_CKFLT_SHIFT)
173#define LPTIM_CFGR_TRGFLT_SHIFT 6
174#define LPTIM_CFGR_TRGFLT_MASK 0x03
175#define LPTIM_CFGR_TRGFLT (3 << LPTIM_CFGR_TRGFLT_SHIFT)
178#define LPTIM_CFGR_TRGFLT_2 (1 << LPTIM_CFGR_TRGFLT_SHIFT)
179#define LPTIM_CFGR_TRGFLT_4 (2 << LPTIM_CFGR_TRGFLT_SHIFT)
180#define LPTIM_CFGR_TRGFLT_8 (3 << LPTIM_CFGR_TRGFLT_SHIFT)
183#define LPTIM_CFGR_PRESC_SHIFT 9
184#define LPTIM_CFGR_PRESC_MASK 0x07
185#define LPTIM_CFGR_PRESC (7 << LPTIM_CFGR_PRESC_SHIFT)
188#define LPTIM_CFGR_PRESC_1 (0 << LPTIM_CFGR_PRESC_SHIFT)
189#define LPTIM_CFGR_PRESC_2 (1 << LPTIM_CFGR_PRESC_SHIFT)
190#define LPTIM_CFGR_PRESC_4 (2 << LPTIM_CFGR_PRESC_SHIFT)
191#define LPTIM_CFGR_PRESC_8 (3 << LPTIM_CFGR_PRESC_SHIFT)
192#define LPTIM_CFGR_PRESC_16 (4 << LPTIM_CFGR_PRESC_SHIFT)
193#define LPTIM_CFGR_PRESC_32 (5 << LPTIM_CFGR_PRESC_SHIFT)
194#define LPTIM_CFGR_PRESC_64 (6 << LPTIM_CFGR_PRESC_SHIFT)
195#define LPTIM_CFGR_PRESC_128 (7 << LPTIM_CFGR_PRESC_SHIFT)
198#define LPTIM_CFGR_TRIGSEL_SHIFT 13
199#define LPTIM_CFGR_TRIGSEL_MASK 0x07
200#define LPTIM_CFGR_TRIGSEL (7 << LPTIM_CFGR_TRIGSEL_SHIFT)
203#define LPTIM_CFGR_TRIGSEL_EXT_TRIG0 (0 << LPTIM_CFGR_TRIGSEL_SHIFT)
204#define LPTIM_CFGR_TRIGSEL_EXT_TRIG1 (1 << LPTIM_CFGR_TRIGSEL_SHIFT)
205#define LPTIM_CFGR_TRIGSEL_EXT_TRIG2 (2 << LPTIM_CFGR_TRIGSEL_SHIFT)
206#define LPTIM_CFGR_TRIGSEL_EXT_TRIG3 (3 << LPTIM_CFGR_TRIGSEL_SHIFT)
207#define LPTIM_CFGR_TRIGSEL_EXT_TRIG4 (4 << LPTIM_CFGR_TRIGSEL_SHIFT)
209#define LPTIM_CFGR_TRIGSEL_EXT_TRIG6 (6 << LPTIM_CFGR_TRIGSEL_SHIFT)
210#define LPTIM_CFGR_TRIGSEL_EXT_TRIG7 (7 << LPTIM_CFGR_TRIGSEL_SHIFT)
213#define LPTIM_CFGR_TRIGEN_SHIFT 17
214#define LPTIM_CFGR_TRIGEN_MASK 0x07
215#define LPTIM_CFGR_TRIGEN (3 << LPTIM_CFGR_TRIGEN_SHIFT)
218#define LPTIM_CFGR_TRIGEN_SW (0 << LPTIM_CFGR_TRIGEN_SHIFT)
219#define LPTIM_CFGR_TRIGEN_RISING (1 << LPTIM_CFGR_TRIGEN_SHIFT)
220#define LPTIM_CFGR_TRIGEN_FALLING (2 << LPTIM_CFGR_TRIGEN_SHIFT)
221#define LPTIM_CFGR_TRIGEN_BOTH (3 << LPTIM_CFGR_TRIGEN_SHIFT)
225#define LPTIM_CFGR_TIMOUT (1 << 19)
228#define LPTIM_CFGR_WAVE (1 << 20)
231#define LPTIM_CFGR_WAVPOL (1 << 21)
234#define LPTIM_CFGR_PRELOAD (1 << 22)
237#define LPTIM_CFGR_COUNTMODE (1 << 23)
240#define LPTIM_CFGR_ENC (1 << 24)
248#define LPTIM_CR_ENABLE (1 << 0)
251#define LPTIM_CR_SNGSTRT (1 << 1)
254#define LPTIM_CR_CNTSTRT (1 << 2)
292#warning "lptimer_common_all.h should not be included directly, only via lptimer.h"
void lptimer_set_waveform_polarity_high(uint32_t lptimer_peripheral)
Set lptimer Waveform Output Polarity High.
void lptimer_set_waveform_polarity_low(uint32_t lptimer_peripheral)
Set lptimer Waveform Output Polarity Low.
uint16_t lptimer_get_counter(uint32_t timer_peripheral)
Read lptimer Counter.
void lptimer_enable_preload(uint32_t lptimer_peripheral)
Enable lptimer Preload mode.
void lptimer_disable_irq(uint32_t timer_peripheral, uint32_t irq)
Disable lptimer Interrupts.
void lptimer_start_counter(uint32_t timer_peripheral, uint32_t mode)
Start lptimer in a given mode.
void lptimer_enable_irq(uint32_t timer_peripheral, uint32_t irq)
Enable lptimer interrupts.
void lptimer_set_internal_clock_source(uint32_t timer_peripheral)
Set lptimer Internal Clock source.
void lptimer_enable_trigger(uint32_t lptimer_peripheral, uint32_t trigen)
Enable lptimer External Trigger.
void lptimer_disable(uint32_t timer_peripheral)
Disable lptimer.
void lptimer_set_prescaler(uint32_t timer_peripheral, uint32_t prescaler)
Set lptimer clock prescaler.
void lptimer_disable_preload(uint32_t lptimer_peripheral)
Disable lptimer Preload mode.
bool lptimer_get_flag(uint32_t timer_peripheral, uint32_t flag)
Read lptimer Status Flag.
void lptimer_set_period(uint32_t lptimer_peripheral, uint16_t period_value)
Set lptimer period.
void lptimer_set_compare(uint32_t timer_peripheral, uint16_t compare_value)
Set lptimer counter Compare Value.
void lptimer_set_external_clock_source(uint32_t timer_peripheral)
Set lptimer External Clock source.
void lptimer_set_counter(uint32_t timer_peripheral, uint16_t count)
Set lptimer Counter.
void lptimer_clear_flag(uint32_t timer_peripheral, uint32_t flag)
Clear lptimer Status Flag.
void lptimer_enable(uint32_t timer_peripheral)
Enable lptimer.
void lptimer_select_trigger_source(uint32_t lptimer_peripheral, uint32_t trigger_source)
Select lptimer Trigger Source.