rfLPC
A low level library for using NXP's LPC17xx SoC. Config is given for MBED prototyping board
|
All four timers provides the same functionality. More...
Enumerations | |
enum | rflpc_timer_t { RFLPC_TIMER0, RFLPC_TIMER1, RFLPC_TIMER2, RFLPC_TIMER3, RFLPC_TIMER_PWM } |
Value to use for the timer value in functions. More... | |
enum | rflpc_timer_match_t { RFLPC_TIMER_MATCH0, RFLPC_TIMER_MATCH1, RFLPC_TIMER_MATCH2, RFLPC_TIMER_MATCH3 } |
Match registers for interrupt generation. More... | |
enum | { RFLPC_TIMER_IRQ_ON_MATCH = 1, RFLPC_TIMER_RESET_ON_MATCH = 2, RFLPC_TIMER_STOP_ON_MATCH = 4 } |
Options for interrupt generation. More... | |
Functions | |
void | rflpc_timer_enable (rflpc_timer_t timer) |
Power and clock the given timer. More... | |
void | rflpc_timer_disable (rflpc_timer_t timer) |
disable the given timer More... | |
int | rflpc_timer_running (rflpc_timer_t timer) |
Query the running state of the timer. More... | |
void | rflpc_timer_set_clock (rflpc_timer_t timer, rflpc_clock_divider_t divider) |
Sets the cpu clock divider for a given timer. More... | |
void | rflpc_timer_set_callback (rflpc_timer_t timer, rflpc_irq_handler_t callback) |
Sets the timer interrupt callback. More... | |
void | rflpc_timer_start (rflpc_timer_t timer) |
starts the given timer. More... | |
void | rflpc_timer_stop (rflpc_timer_t timer) |
Stops the timer. More... | |
void | rflpc_timer_reset (rflpc_timer_t timer) |
Resets the timer. More... | |
uint32_t | rflpc_timer_get_counter (rflpc_timer_t timer) |
Returns the timer counter value. More... | |
uint32_t | rflpc_timer_get_pre_scale_counter (rflpc_timer_t timer) |
Returns the prescale counter value. More... | |
uint32_t | rflpc_timer_get_pre_scale_register (rflpc_timer_t timer) |
Returns the value of the prescale register. More... | |
void | rflpc_timer_set_counter (rflpc_timer_t timer, uint32_t value) |
Sets the timer counter value. More... | |
void | rflpc_timer_set_pre_scale_counter (rflpc_timer_t timer, uint32_t value) |
Sets the prescale counter value. More... | |
void | rflpc_timer_set_pre_scale_register (rflpc_timer_t timer, uint32_t value) |
Sets the value of the prescale register. More... | |
void | rflpc_timer_set_match_value (rflpc_timer_t timer, rflpc_timer_match_t match_register, uint32_t match_value) |
Set the match register value for a given timer. More... | |
void | rflpc_timer_set_irq_on_match (rflpc_timer_t timer, rflpc_timer_match_t match_register, uint32_t options) |
Enable IRQ generation when the timer counter reaches the value of a match register. More... | |
void | rflpc_timer_reset_irq (rflpc_timer_t timer, rflpc_timer_match_t match_register) |
Reset the irq for a given match register. More... | |
int | rflpc_timer_test_irq (rflpc_timer_t timer, rflpc_timer_match_t match_register) |
Check if an interrupt has been generated for a given match register. More... | |
All four timers provides the same functionality.
The prescale counter is incremented at each timer clock tick. When the prescale counter reaches the prescale register value, the counter is incremented. The value of the counter can then be used as time value or match against four match registers to trigger an interrupt.
anonymous enum |
Options for interrupt generation.
enum rflpc_timer_match_t |
enum rflpc_timer_t |
void rflpc_timer_disable | ( | rflpc_timer_t | timer | ) |
disable the given timer
timer |
void rflpc_timer_enable | ( | rflpc_timer_t | timer | ) |
Power and clock the given timer.
timer |
uint32_t rflpc_timer_get_counter | ( | rflpc_timer_t | timer | ) |
Returns the timer counter value.
This value is incremented each time the prescale counter matches the prescale register.
timer |
uint32_t rflpc_timer_get_pre_scale_counter | ( | rflpc_timer_t | timer | ) |
Returns the prescale counter value.
This value is incremented at each clock cycle.
timer |
uint32_t rflpc_timer_get_pre_scale_register | ( | rflpc_timer_t | timer | ) |
Returns the value of the prescale register.
This register contains the number of clock cycle needed to increment the timer counter. That is, at each clock cycle, the prescale counter is incrementer and when it reaches the prescale register, the timer counter is incremented.
timer |
void rflpc_timer_reset | ( | rflpc_timer_t | timer | ) |
Resets the timer.
timer |
void rflpc_timer_reset_irq | ( | rflpc_timer_t | timer, |
rflpc_timer_match_t | match_register | ||
) |
Reset the irq for a given match register.
timer | |
match_register |
int rflpc_timer_running | ( | rflpc_timer_t | timer | ) |
Query the running state of the timer.
timer |
void rflpc_timer_set_callback | ( | rflpc_timer_t | timer, |
rflpc_irq_handler_t | callback | ||
) |
Sets the timer interrupt callback.
Also enables timer interrupt to be received.
timer | |
callback |
void rflpc_timer_set_clock | ( | rflpc_timer_t | timer, |
rflpc_clock_divider_t | divider | ||
) |
Sets the cpu clock divider for a given timer.
timer | |
divider |
void rflpc_timer_set_counter | ( | rflpc_timer_t | timer, |
uint32_t | value | ||
) |
Sets the timer counter value.
This value is incremented each time the prescale counter matches the prescale register.
timer | |
value |
void rflpc_timer_set_irq_on_match | ( | rflpc_timer_t | timer, |
rflpc_timer_match_t | match_register, | ||
uint32_t | options | ||
) |
Enable IRQ generation when the timer counter reaches the value of a match register.
timer | |
match_register | |
options | a bitwise ORed value of RFLPC_TIMER_IRQ_ON_MATCH, RFLPC_TIMER_RESET_ON_MATCH and RFLPC_TIMER_STOP_ON_MATCH |
void rflpc_timer_set_match_value | ( | rflpc_timer_t | timer, |
rflpc_timer_match_t | match_register, | ||
uint32_t | match_value | ||
) |
Set the match register value for a given timer.
Interrupt can be generated when timer counter reaches a match register's value
timer | |
match_register | |
match_value |
void rflpc_timer_set_pre_scale_counter | ( | rflpc_timer_t | timer, |
uint32_t | value | ||
) |
Sets the prescale counter value.
This value is incremented at each clock cycle.
timer | |
value |
void rflpc_timer_set_pre_scale_register | ( | rflpc_timer_t | timer, |
uint32_t | value | ||
) |
Sets the value of the prescale register.
This register contains the number of clock cycle needed to increment the timer counter. That is, at each clock cycle, the prescale counter is incrementer and when it reaches the prescale register, the timer counter is incremented.
timer | |
value |
void rflpc_timer_start | ( | rflpc_timer_t | timer | ) |
starts the given timer.
This does not modify timer register value. It just starts to count
timer |
void rflpc_timer_stop | ( | rflpc_timer_t | timer | ) |
Stops the timer.
Does not modify timer registers value
timer |
int rflpc_timer_test_irq | ( | rflpc_timer_t | timer, |
rflpc_timer_match_t | match_register | ||
) |
Check if an interrupt has been generated for a given match register.
timer | |
match_register |