libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
LPTIM Defines

libopencm3 Defined Constants and Types for the STM32F4xx Low Power Timer More...

Collaboration diagram for LPTIM Defines:

Modules

 Low Power Timer register base addresses
 
 LPTIM_ISR Interrupt and Status Register
 
 LPTIM_ICR Interrupt Clear Register
 
 LPTIM_IER Interrupt Enable Register
 
 LPTIM_CFGR Configuration Register
 
 LPTIM_CR Control Register
 

Macros

#define LPTIM_ISR(tim_base)   MMIO32((tim_base) + 0x00)
 
#define LPTIM_ICR(tim_base)   MMIO32((tim_base) + 0x04)
 
#define LPTIM_IER(tim_base)   MMIO32((tim_base) + 0x08)
 
#define LPTIM_CFGR(tim_base)   MMIO32((tim_base) + 0x0C)
 
#define LPTIM_CR(tim_base)   MMIO32((tim_base) + 0x10)
 
#define LPTIM_CMP(tim_base)   MMIO32((tim_base) + 0x14)
 
#define LPTIM_ARR(tim_base)   MMIO32((tim_base) + 0x18)
 
#define LPTIM_CNT(tim_base)   MMIO32((tim_base) + 0x1C)
 
#define LPTIM1_ISR   LPTIM_ISR(LPTIM1_BASE)
 
#define LPTIM1_ICR   LPTIM_ICR(LPTIM1_BASE)
 
#define LPTIM1_IER   LPTIM_IER(LPTIM1_BASE)
 
#define LPTIM1_CFGR   LPTIM_CFGR(LPTIM1_BASE)
 
#define LPTIM1_CR   LPTIM_CR(LPTIM1_BASE)
 
#define LPTIM1_CMP   LPTIM_CMP(LPTIM1_BASE)
 
#define LPTIM1_ARR   LPTIM_ARR(LPTIM1_BASE)
 
#define LPTIM1_CNT   LPTIM_CNT(LPTIM1_BASE)
 

Functions

void lptimer_enable (uint32_t timer_peripheral)
 Enable lptimer. More...
 
void lptimer_disable (uint32_t timer_peripheral)
 Disable lptimer. More...
 
void lptimer_start_counter (uint32_t timer_peripheral, uint32_t mode)
 Start lptimer in a given mode. More...
 
void lptimer_set_counter (uint32_t timer_peripheral, uint16_t count)
 Set lptimer Counter. More...
 
uint16_t lptimer_get_counter (uint32_t timer_peripheral)
 Read lptimer Counter. More...
 
void lptimer_set_compare (uint32_t timer_peripheral, uint16_t compare_value)
 Set lptimer counter Compare Value. More...
 
void lptimer_set_period (uint32_t lptimer_peripheral, uint16_t period_value)
 Set lptimer period. More...
 
void lptimer_enable_preload (uint32_t lptimer_peripheral)
 Enable lptimer Preload mode. More...
 
void lptimer_disable_preload (uint32_t lptimer_peripheral)
 Disable lptimer Preload mode. More...
 
void lptimer_set_waveform_polarity_high (uint32_t lptimer_peripheral)
 Set lptimer Waveform Output Polarity High. More...
 
void lptimer_set_waveform_polarity_low (uint32_t lptimer_peripheral)
 Set lptimer Waveform Output Polarity Low. More...
 
void lptimer_set_prescaler (uint32_t timer_peripheral, uint32_t prescaler)
 Set lptimer clock prescaler. More...
 
void lptimer_enable_trigger (uint32_t lptimer_peripheral, uint32_t trigen)
 Enable lptimer External Trigger. More...
 
void lptimer_select_trigger_source (uint32_t lptimer_peripheral, uint32_t trigger_source)
 Select lptimer Trigger Source. More...
 
void lptimer_set_internal_clock_source (uint32_t timer_peripheral)
 Set lptimer Internal Clock source. More...
 
void lptimer_set_external_clock_source (uint32_t timer_peripheral)
 Set lptimer External Clock source. More...
 
void lptimer_clear_flag (uint32_t timer_peripheral, uint32_t flag)
 Clear lptimer Status Flag. More...
 
bool lptimer_get_flag (uint32_t timer_peripheral, uint32_t flag)
 Read lptimer Status Flag. More...
 
void lptimer_enable_irq (uint32_t timer_peripheral, uint32_t irq)
 Enable lptimer interrupts. More...
 
void lptimer_disable_irq (uint32_t timer_peripheral, uint32_t irq)
 Disable lptimer Interrupts. More...
 

Detailed Description

libopencm3 Defined Constants and Types for the STM32F4xx Low Power Timer

Version
1.0.0

LGPL License Terms libopencm3 License

Author
© 2009 Piotr Esden-Tempski piotr.nosp@m.@esd.nosp@m.en.ne.nosp@m.t
© 2019 Guillaume Revaillot g.rev.nosp@m.aill.nosp@m.ot@gm.nosp@m.ail..nosp@m.com

Macro Definition Documentation

◆ LPTIM1_ARR

#define LPTIM1_ARR   LPTIM_ARR(LPTIM1_BASE)

Definition at line 52 of file lptimer_common_all.h.

◆ LPTIM1_CFGR

#define LPTIM1_CFGR   LPTIM_CFGR(LPTIM1_BASE)

Definition at line 49 of file lptimer_common_all.h.

◆ LPTIM1_CMP

#define LPTIM1_CMP   LPTIM_CMP(LPTIM1_BASE)

Definition at line 51 of file lptimer_common_all.h.

◆ LPTIM1_CNT

#define LPTIM1_CNT   LPTIM_CNT(LPTIM1_BASE)

Definition at line 53 of file lptimer_common_all.h.

◆ LPTIM1_CR

#define LPTIM1_CR   LPTIM_CR(LPTIM1_BASE)

Definition at line 50 of file lptimer_common_all.h.

◆ LPTIM1_ICR

#define LPTIM1_ICR   LPTIM_ICR(LPTIM1_BASE)

Definition at line 47 of file lptimer_common_all.h.

◆ LPTIM1_IER

#define LPTIM1_IER   LPTIM_IER(LPTIM1_BASE)

Definition at line 48 of file lptimer_common_all.h.

◆ LPTIM1_ISR

#define LPTIM1_ISR   LPTIM_ISR(LPTIM1_BASE)

Definition at line 46 of file lptimer_common_all.h.

◆ LPTIM_ARR

#define LPTIM_ARR (   tim_base)    MMIO32((tim_base) + 0x18)

Definition at line 43 of file lptimer_common_all.h.

◆ LPTIM_CFGR

#define LPTIM_CFGR (   tim_base)    MMIO32((tim_base) + 0x0C)

Definition at line 40 of file lptimer_common_all.h.

◆ LPTIM_CMP

#define LPTIM_CMP (   tim_base)    MMIO32((tim_base) + 0x14)

Definition at line 42 of file lptimer_common_all.h.

◆ LPTIM_CNT

#define LPTIM_CNT (   tim_base)    MMIO32((tim_base) + 0x1C)

Definition at line 44 of file lptimer_common_all.h.

◆ LPTIM_CR

#define LPTIM_CR (   tim_base)    MMIO32((tim_base) + 0x10)

Definition at line 41 of file lptimer_common_all.h.

◆ LPTIM_ICR

#define LPTIM_ICR (   tim_base)    MMIO32((tim_base) + 0x04)

Definition at line 38 of file lptimer_common_all.h.

◆ LPTIM_IER

#define LPTIM_IER (   tim_base)    MMIO32((tim_base) + 0x08)

Definition at line 39 of file lptimer_common_all.h.

◆ LPTIM_ISR

#define LPTIM_ISR (   tim_base)    MMIO32((tim_base) + 0x00)

Definition at line 37 of file lptimer_common_all.h.

Function Documentation

◆ lptimer_clear_flag()

void lptimer_clear_flag ( uint32_t  lptimer_peripheral,
uint32_t  flag 
)

Clear lptimer Status Flag.

Parameters
[in]lptimer_peripherallptimer base address (Low Power Timer register base addresses)
[in]flagStatus Register clear flag (LPTIM_ICR Interrupt Clear Register)

Definition at line 90 of file lptimer_common_all.c.

References LPTIM_ICR.

◆ lptimer_disable()

void lptimer_disable ( uint32_t  lptimer_peripheral)

Disable lptimer.

Parameters
[in]lptimer_peripherallptimer base address (Low Power Timer register base addresses)

Definition at line 141 of file lptimer_common_all.c.

References LPTIM_CR.

◆ lptimer_disable_irq()

void lptimer_disable_irq ( uint32_t  lptimer_peripheral,
uint32_t  irq 
)

Disable lptimer Interrupts.

Parameters
[in]lptimer_peripherallptimer base address (Low Power Timer register base addresses)
[in]irqLogical or of all interrupt enable bits to be cleared (LPTIM_IER Interrupt Enable Register)

Definition at line 123 of file lptimer_common_all.c.

References LPTIM_IER.

◆ lptimer_disable_preload()

void lptimer_disable_preload ( uint32_t  lptimer_peripheral)

Disable lptimer Preload mode.

Disable lptimer preload mode, ensureing updated period and compare registers values are taken in account immediatly.

Parameters
[in]lptimer_peripherallptimer base address (Low Power Timer register base addresses)

Definition at line 246 of file lptimer_common_all.c.

References LPTIM_CFGR.

◆ lptimer_enable()

void lptimer_enable ( uint32_t  lptimer_peripheral)

Enable lptimer.

Parameters
[in]lptimer_peripherallptimer base address (Low Power Timer register base addresses)

Definition at line 132 of file lptimer_common_all.c.

References LPTIM_CR, and LPTIM_CR_ENABLE.

◆ lptimer_enable_irq()

void lptimer_enable_irq ( uint32_t  lptimer_peripheral,
uint32_t  irq 
)

Enable lptimer interrupts.

Parameters
[in]lptimer_peripherallptimer base address (Low Power Timer register base addresses)
[in]irqLogical or of all interrupt enable bits to be set (LPTIM_IER Interrupt Enable Register)

Definition at line 112 of file lptimer_common_all.c.

References LPTIM_IER.

◆ lptimer_enable_preload()

void lptimer_enable_preload ( uint32_t  lptimer_peripheral)

Enable lptimer Preload mode.

Enable lptimer preload mode, delaying update of period and compare registers to the end of current period.

Parameters
[in]lptimer_peripherallptimer base address (Low Power Timer register base addresses)

Definition at line 234 of file lptimer_common_all.c.

References LPTIM_CFGR, and LPTIM_CFGR_PRELOAD.

◆ lptimer_enable_trigger()

void lptimer_enable_trigger ( uint32_t  lptimer_peripheral,
uint32_t  trigen 
)

Enable lptimer External Trigger.

Parameters
[in]lptimer_peripherallptimer base address (Low Power Timer register base addresses)
[in]trigenEnable Trigger

Definition at line 181 of file lptimer_common_all.c.

References LPTIM_CFGR, LPTIM_CFGR_TRIGEN_MASK, and LPTIM_CFGR_TRIGEN_SHIFT.

◆ lptimer_get_counter()

uint16_t lptimer_get_counter ( uint32_t  lptimer_peripheral)

Read lptimer Counter.

Read back the value of lptimer counter.

Parameters
[in]lptimer_peripherallptimer base address (Low Power Timer register base addresses)
Returns
Counter value.

Definition at line 80 of file lptimer_common_all.c.

References LPTIM_CNT.

◆ lptimer_get_flag()

bool lptimer_get_flag ( uint32_t  lptimer_peripheral,
uint32_t  flag 
)

Read lptimer Status Flag.

Parameters
[in]lptimer_peripherallptimer base address (Low Power Timer register base addresses)
[in]flagStatus Register flag (LPTIM_ISR Interrupt and Status Register)
Returns
flag set.

Definition at line 101 of file lptimer_common_all.c.

References LPTIM_ISR.

◆ lptimer_select_trigger_source()

void lptimer_select_trigger_source ( uint32_t  lptimer_peripheral,
uint32_t  trigger_source 
)

Select lptimer Trigger Source.

Select timer external trigger source.

Parameters
[in]lptimer_peripherallptimer base address (Low Power Timer register base addresses)
[in]trigger_sourceTrigger selector (LPTIM_CFGR TRIGSEL Trigger selector)

Definition at line 195 of file lptimer_common_all.c.

References LPTIM_CFGR, LPTIM_CFGR_TRIGSEL_MASK, and LPTIM_CFGR_TRIGSEL_SHIFT.

◆ lptimer_set_compare()

void lptimer_set_compare ( uint32_t  lptimer_peripheral,
uint16_t  compare_value 
)

Set lptimer counter Compare Value.

Set the timer compare value. Must only be set with timer enabled.

Parameters
[in]lptimer_peripherallptimer base address (Low Power Timer register base addresses)
[in]compare_valueCompare value.

Definition at line 209 of file lptimer_common_all.c.

References LPTIM_CMP.

◆ lptimer_set_counter()

void lptimer_set_counter ( uint32_t  lptimer_peripheral,
uint16_t  count 
)

Set lptimer Counter.

Set the value of a lptimer counter.

Parameters
[in]lptimer_peripherallptimer base address (Low Power Timer register base addresses)
[in]countCounter value.

Definition at line 68 of file lptimer_common_all.c.

References LPTIM_CNT.

◆ lptimer_set_external_clock_source()

void lptimer_set_external_clock_source ( uint32_t  lptimer_peripheral)

Set lptimer External Clock source.

Parameters
[in]lptimer_peripherallptimer base address (Low Power Timer register base addresses)

Definition at line 265 of file lptimer_common_all.c.

References LPTIM_CFGR, and LPTIM_CFGR_CKSEL.

◆ lptimer_set_internal_clock_source()

void lptimer_set_internal_clock_source ( uint32_t  lptimer_peripheral)

Set lptimer Internal Clock source.

Parameters
[in]lptimer_peripherallptimer base address (Low Power Timer register base addresses)

Definition at line 256 of file lptimer_common_all.c.

References LPTIM_CFGR.

◆ lptimer_set_period()

void lptimer_set_period ( uint32_t  lptimer_peripheral,
uint16_t  period_value 
)

Set lptimer period.

Set the timer period in the auto-reload register. Must only be set with timer enabled.

Parameters
[in]lptimer_peripherallptimer base address (Low Power Timer register base addresses)
[in]period_valueAutoreload value. Must be greater that CMP value.

Definition at line 222 of file lptimer_common_all.c.

References LPTIM_ARR.

◆ lptimer_set_prescaler()

void lptimer_set_prescaler ( uint32_t  lptimer_peripheral,
uint32_t  prescaler 
)

Set lptimer clock prescaler.

Parameters
[in]lptimer_peripherallptimer base address (Low Power Timer register base addresses)
[in]prescalerClock prescaler (LPTIM_CFGR PRESC Clock prescaler)

Definition at line 169 of file lptimer_common_all.c.

References LPTIM_CFGR, LPTIM_CFGR_PRESC_MASK, and LPTIM_CFGR_PRESC_SHIFT.

◆ lptimer_set_waveform_polarity_high()

void lptimer_set_waveform_polarity_high ( uint32_t  lptimer_peripheral)

Set lptimer Waveform Output Polarity High.

Set lptimer waveform output to reflect compare result between LPTIN_CNT and LPTIM_CMP.

Parameters
[in]lptimer_peripherallptimer base address (Low Power Timer register base addresses)

Definition at line 277 of file lptimer_common_all.c.

References LPTIM_CFGR, and LPTIM_CFGR_WAVPOL.

◆ lptimer_set_waveform_polarity_low()

void lptimer_set_waveform_polarity_low ( uint32_t  lptimer_peripheral)

Set lptimer Waveform Output Polarity Low.

Set lptimer waveform output to reflect the inverse of the compare result between LPTIN_CNT and LPTIM_CMP.

Parameters
[in]lptimer_peripherallptimer base address (Low Power Timer register base addresses)

Definition at line 289 of file lptimer_common_all.c.

References LPTIM_CFGR.

◆ lptimer_start_counter()

void lptimer_start_counter ( uint32_t  lptimer_peripheral,
uint32_t  mode 
)

Start lptimer in a given mode.

Starts the timer in specified mode - Either Single (LPTIM_CR_SNGSTRT) or Continuous mode (LPTIM_CR_CNTSTRT). In Single mode, the timer will stop at next match on compare or period value. If LPTIM_CR_SNGSTRT is set while timer is started in countious mode, it will stop at next match on compare or period value. If Software trigger is disabled, start will be delayed until programmed triggers is detected.

Parameters
[in]lptimer_peripherallptimer base address (Low Power Timer register base addresses)
[in]modelptimer start mode (LPTIM_CR_SNGSTRT or LPTIM_CR_CNTSTRT)

Definition at line 159 of file lptimer_common_all.c.

References LPTIM_CR.