rfLPC
A low level library for using NXP's LPC17xx SoC. Config is given for MBED prototyping board
sys_tick_timer.h
Go to the documentation of this file.
1 /* This file is part of rflpc. Copyright 2010-2011 Michael Hauspie
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: <2012-03-21 09:07:57 (hauspie)>
23 */
24 #ifndef __RFLPC_SYS_TICK_TIMER_H__
25 #define __RFLPC_SYS_TICK_TIMER_H__
26 
27 #ifdef RFLPC_CONFIG_ENABLE_SYS_TICK_TIMER
28 
47 #include "../interrupt.h"
48 #include "../nxp/LPC17xx.h"
49 
51 extern void rflpc_sys_timer_init();
52 
54 static inline void rflpc_sys_timer_start()
55 {
56  SysTick->CTRL |= 1;
57 }
58 
60 static inline void rflpc_sys_timer_stop()
61 {
62  SysTick->CTRL &= ~1UL;
63 }
64 
67 {
68  /* Enable systick interrupt */
69  SysTick->CTRL |= (1 << 1);
70 
71  rflpc_irq_set_handler(SysTick_IRQn, c);
72 }
73 
77 extern void rflpc_sys_timer_set_period(uint32_t micros_time);
78 
83 extern void rflpc_sys_timer_set_tick_period(uint32_t ticks);
84 
87 #endif /* ENABLE_SYS_TICK_TIMER */
88 
89 #endif
static void rflpc_sys_timer_start()
starts the system timer
void rflpc_sys_timer_set_tick_period(uint32_t ticks)
initializes the timer with a given tick count This automatically starts the timer even if it was stop...
static void rflpc_sys_timer_stop()
stops the system timer
static void rflpc_sys_timer_set_callback(rflpc_irq_handler_t c)
sets the callback for the timer interrupt
void rflpc_irq_set_handler(IRQn_Type irq, rflpc_irq_handler_t handler)
Sets an handler for the given IRQ.
void rflpc_sys_timer_init()
initializes the system timer
void rflpc_sys_timer_set_period(uint32_t micros_time)
initializes the timer with a given period (in µs) This automatically starts the timer even if it was ...
void(* rflpc_irq_handler_t)(void)
Interrupt handler type.
Definition: interrupt.h:62