rfLPC
A low level library for using NXP's LPC17xx SoC. Config is given for MBED prototyping board
timer.h
Go to the documentation of this file.
1 /* This file is part of rflpc.
2  *
3  * rflpc is free software: you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation, either version 3 of the License, or
6  * (at your option) any later version.
7  *
8  * rflpc is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with rflpc. If not, see <http://www.gnu.org/licenses/>.
15  */
19 /*
20  Author: Michael Hauspie <michael.hauspie@univ-lille1.fr>
21  Created:
22  Time-stamp: <2013-03-01 13:48:26 (hauspie)>
23 */
24 #ifndef __RFLPC_TIMER_H__
25 #define __RFLPC_TIMER_H__
26 
27 #ifdef RFLPC_CONFIG_ENABLE_TIMERS
28 
29 #include "../nxp/LPC17xx.h"
30 #include "../clock.h"
31 #include "../tools.h"
32 #include "../interrupt.h"
33 
34 
48 typedef enum
49 {
56 
57 
59 typedef enum
60 {
66 
67 
69 enum
70 {
74 };
75 
81 extern void rflpc_timer_enable(rflpc_timer_t timer);
82 
88 extern void rflpc_timer_disable(rflpc_timer_t timer);
89 
90 
99 
106 extern void rflpc_timer_set_clock(rflpc_timer_t timer, rflpc_clock_divider_t divider);
107 
114 extern void rflpc_timer_set_callback(rflpc_timer_t timer, rflpc_irq_handler_t callback);
115 
116 
124 extern void rflpc_timer_start(rflpc_timer_t timer);
125 
132 extern void rflpc_timer_stop(rflpc_timer_t timer);
133 
137 extern void rflpc_timer_reset(rflpc_timer_t timer);
138 
147 extern uint32_t rflpc_timer_get_counter(rflpc_timer_t timer);
148 
157 extern uint32_t rflpc_timer_get_pre_scale_counter(rflpc_timer_t timer);
158 
170 
179 extern void rflpc_timer_set_counter(rflpc_timer_t timer, uint32_t value);
180 
189 extern void rflpc_timer_set_pre_scale_counter(rflpc_timer_t timer, uint32_t value);
190 
201 extern void rflpc_timer_set_pre_scale_register(rflpc_timer_t timer, uint32_t value);
202 
213 extern void rflpc_timer_set_match_value(rflpc_timer_t timer, rflpc_timer_match_t match_register, uint32_t match_value);
214 
224 extern void rflpc_timer_set_irq_on_match(rflpc_timer_t timer, rflpc_timer_match_t match_register, uint32_t options);
225 
226 
233 extern void rflpc_timer_reset_irq(rflpc_timer_t timer, rflpc_timer_match_t match_register);
234 
243 extern int rflpc_timer_test_irq(rflpc_timer_t timer, rflpc_timer_match_t match_register);
244 
247 #endif /* ENABLE_TIMERS */
248 
249 #endif
uint32_t rflpc_timer_get_pre_scale_counter(rflpc_timer_t timer)
Returns the prescale counter value.
void rflpc_timer_reset_irq(rflpc_timer_t timer, rflpc_timer_match_t match_register)
Reset the irq for a given match register.
uint32_t rflpc_timer_get_counter(rflpc_timer_t timer)
Returns the timer counter value.
Match register 1.
Definition: timer.h:62
void rflpc_timer_enable(rflpc_timer_t timer)
Power and clock the given timer.
void rflpc_timer_set_callback(rflpc_timer_t timer, rflpc_irq_handler_t callback)
Sets the timer interrupt callback.
Match register 2.
Definition: timer.h:63
PWM Timer.
Definition: timer.h:54
Match register 0.
Definition: timer.h:61
int rflpc_timer_running(rflpc_timer_t timer)
Query the running state of the timer.
Timer 0.
Definition: timer.h:50
void rflpc_timer_disable(rflpc_timer_t timer)
disable the given timer
uint32_t rflpc_timer_get_pre_scale_register(rflpc_timer_t timer)
Returns the value of the prescale register.
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 3.
Definition: timer.h:53
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.
rflpc_timer_match_t
Match registers for interrupt generation.
Definition: timer.h:59
Timer 1.
Definition: timer.h:51
void rflpc_timer_reset(rflpc_timer_t timer)
Resets the timer.
rflpc_clock_divider_t
This enums defines the different cpu clock dividers for use as peripheral clocks. ...
Definition: clock.h:38
Trigger an interrupt when counter matches the match register.
Definition: timer.h:71
void rflpc_timer_stop(rflpc_timer_t timer)
Stops the timer.
void rflpc_timer_set_clock(rflpc_timer_t timer, rflpc_clock_divider_t divider)
Sets the cpu clock divider for a given timer.
void rflpc_timer_set_pre_scale_counter(rflpc_timer_t timer, uint32_t value)
Sets the prescale counter value.
void rflpc_timer_set_pre_scale_register(rflpc_timer_t timer, uint32_t value)
Sets the value of the prescale register.
void rflpc_timer_start(rflpc_timer_t timer)
starts the given timer.
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.
rflpc_timer_t
Value to use for the timer value in functions.
Definition: timer.h:48
Timer 2.
Definition: timer.h:52
Stop the timer when the counter matches the match register.
Definition: timer.h:73
Reset the timer when counter matches the match register.
Definition: timer.h:72
Match register 3.
Definition: timer.h:64
void rflpc_timer_set_counter(rflpc_timer_t timer, uint32_t value)
Sets the timer counter value.
void(* rflpc_irq_handler_t)(void)
Interrupt handler type.
Definition: interrupt.h:62