lpc_timers.h
Go to the documentation of this file.
1 /*
2  * SocialLedge.com - Copyright (C) 2013
3  *
4  * This file is part of free software framework for embedded processors.
5  * You can use it and/or distribute it as long as this copyright header
6  * remains unmodified. The code is free for personal use and requires
7  * permission to use in a commercial product.
8  *
9  * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
10  * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
12  * I SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
13  * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
14  *
15  * You can reach the author of this software at :
16  * p r e e t . w i k i @ g m a i l . c o m
17  */
18 
26 #ifndef LPC_TIMERS_H__
27 #define LPC_TIMERS_H__
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 #include <stdint.h>
32 #include "LPC17xx.h"
33 
34 
35 
41 typedef enum {
46 } lpc_timer_t;
47 
51 static inline LPC_TIM_TypeDef* lpc_timer_get_struct(const lpc_timer_t timer)
52 {
53  const uint32_t timer_mem_bases[] = { LPC_TIM0_BASE, LPC_TIM1_BASE, LPC_TIM2_BASE, LPC_TIM3_BASE };
54  return (LPC_TIM_TypeDef*) timer_mem_bases[timer];
55 }
56 
60 static inline IRQn_Type lpc_timer_get_irq_num(const lpc_timer_t timer)
61 {
63  return irqs[timer];
64 }
65 
74 void lpc_timer_enable(const lpc_timer_t timer, const uint32_t us_per_tick);
75 
81 uint32_t lpc_timer_get_value(const lpc_timer_t timer);
82 
89 void lpc_timer_set_value(const lpc_timer_t timer, const uint32_t value);
90 
91 
92 
93 #ifdef __cplusplus
94 }
95 #endif
96 #endif /* LPC_TIMERS_H__ */
Definition: LPC17xx.h:68
Definition: LPC17xx.h:67
Definition: LPC17xx.h:70
Definition: lpc_timers.h:43
Definition: lpc_timers.h:42
Definition: LPC17xx.h:290
#define LPC_TIM3_BASE
Definition: LPC17xx.h:970
Definition: LPC17xx.h:69
void lpc_timer_set_value(const lpc_timer_t timer, const uint32_t value)
Definition: lpc_timers.c:48
#define LPC_TIM1_BASE
Definition: LPC17xx.h:948
CMSIS Cortex-M3 Core Peripheral Access Layer Header File for NXP LPC17xx Device Series.
Definition: lpc_timers.h:45
#define LPC_TIM0_BASE
Definition: LPC17xx.h:947
Definition: lpc_timers.h:44
uint32_t lpc_timer_get_value(const lpc_timer_t timer)
Definition: lpc_timers.c:43
void lpc_timer_enable(const lpc_timer_t timer, const uint32_t us_per_tick)
Definition: lpc_timers.c:24
enum IRQn IRQn_Type
#define LPC_TIM2_BASE
Definition: LPC17xx.h:969
lpc_timer_t
Definition: lpc_timers.h:41