24#ifndef LIBBSP_ARM_LPC176X_TIMER_DEFS_H
25#define LIBBSP_ARM_LPC176X_TIMER_DEFS_H
34#define LPC176X_TMR0_BASE_ADDR 0x40004000U
36#define LPC176X_T0IR ( *(volatile uint32_t *) ( LPC176X_TMR0_BASE_ADDR + \
38#define LPC176X_T0TCR ( *(volatile uint32_t *) ( LPC176X_TMR0_BASE_ADDR + \
40#define LPC176X_T0TC ( *(volatile uint32_t *) ( LPC176X_TMR0_BASE_ADDR + \
42#define LPC176X_T0PR ( *(volatile uint32_t *) ( LPC176X_TMR0_BASE_ADDR + \
44#define LPC176X_T0PC ( *(volatile uint32_t *) ( LPC176X_TMR0_BASE_ADDR + \
46#define LPC176X_T0MCR ( *(volatile uint32_t *) ( LPC176X_TMR0_BASE_ADDR + \
48#define LPC176X_T0MR0 ( *(volatile uint32_t *) ( LPC176X_TMR0_BASE_ADDR + \
50#define LPC176X_T0MR1 ( *(volatile uint32_t *) ( LPC176X_TMR0_BASE_ADDR + \
52#define LPC176X_T0MR2 ( *(volatile uint32_t *) ( LPC176X_TMR0_BASE_ADDR + \
54#define LPC176X_T0MR3 ( *(volatile uint32_t *) ( LPC176X_TMR0_BASE_ADDR + \
56#define LPC176X_T0CCR ( *(volatile uint32_t *) ( LPC176X_TMR0_BASE_ADDR + \
58#define LPC176X_T0CR0 ( *(volatile uint32_t *) ( LPC176X_TMR0_BASE_ADDR + \
60#define LPC176X_T0CR1 ( *(volatile uint32_t *) ( LPC176X_TMR0_BASE_ADDR + \
62#define LPC176X_T0CR2 ( *(volatile uint32_t *) ( LPC176X_TMR0_BASE_ADDR + \
64#define LPC176X_T0CR3 ( *(volatile uint32_t *) ( LPC176X_TMR0_BASE_ADDR + \
66#define LPC176X_T0EMR ( *(volatile uint32_t *) ( LPC176X_TMR0_BASE_ADDR + \
68#define LPC176X_T0CTCR ( *(volatile uint32_t *) ( LPC176X_TMR0_BASE_ADDR + \
72#define LPC176X_TMR1_BASE_ADDR 0x40008000U
74#define LPC176X_T1IR ( *(volatile uint32_t *) ( LPC176X_TMR1_BASE_ADDR + \
76#define LPC176X_T1TCR ( *(volatile uint32_t *) ( LPC176X_TMR1_BASE_ADDR + \
78#define LPC176X_T1TC ( *(volatile uint32_t *) ( LPC176X_TMR1_BASE_ADDR + \
80#define LPC176X_T1PR ( *(volatile uint32_t *) ( LPC176X_TMR1_BASE_ADDR + \
82#define LPC176X_T1PC ( *(volatile uint32_t *) ( LPC176X_TMR1_BASE_ADDR + \
84#define LPC176X_T1MCR ( *(volatile uint32_t *) ( LPC176X_TMR1_BASE_ADDR + \
86#define LPC176X_T1MR0 ( *(volatile uint32_t *) ( LPC176X_TMR1_BASE_ADDR + \
88#define LPC176X_T1MR1 ( *(volatile uint32_t *) ( LPC176X_TMR1_BASE_ADDR + \
90#define LPC176X_T1MR2 ( *(volatile uint32_t *) ( LPC176X_TMR1_BASE_ADDR + \
92#define LPC176X_T1MR3 ( *(volatile uint32_t *) ( LPC176X_TMR1_BASE_ADDR + \
94#define LPC176X_T1CCR ( *(volatile uint32_t *) ( LPC176X_TMR1_BASE_ADDR + \
96#define LPC176X_T1CR0 ( *(volatile uint32_t *) ( LPC176X_TMR1_BASE_ADDR + \
98#define LPC176X_T1CR1 ( *(volatile uint32_t *) ( LPC176X_TMR1_BASE_ADDR + \
100#define LPC176X_T1CR2 ( *(volatile uint32_t *) ( LPC176X_TMR1_BASE_ADDR + \
102#define LPC176X_T1CR3 ( *(volatile uint32_t *) ( LPC176X_TMR1_BASE_ADDR + \
104#define LPC176X_T1EMR ( *(volatile uint32_t *) ( LPC176X_TMR1_BASE_ADDR + \
106#define LPC176X_T1CTCR ( *(volatile uint32_t *) ( LPC176X_TMR1_BASE_ADDR + \
110#define LPC176X_TMR2_BASE_ADDR 0x40090000U
112#define LPC176X_T2IR ( *(volatile uint32_t *) ( LPC176X_TMR2_BASE_ADDR + \
114#define LPC176X_T2TCR ( *(volatile uint32_t *) ( LPC176X_TMR2_BASE_ADDR + \
116#define LPC176X_T2TC ( *(volatile uint32_t *) ( LPC176X_TMR2_BASE_ADDR + \
118#define LPC176X_T2PR ( *(volatile uint32_t *) ( LPC176X_TMR2_BASE_ADDR + \
120#define LPC176X_T2PC ( *(volatile uint32_t *) ( LPC176X_TMR2_BASE_ADDR + \
122#define LPC176X_T2MCR ( *(volatile uint32_t *) ( LPC176X_TMR2_BASE_ADDR + \
124#define LPC176X_T2MR0 ( *(volatile uint32_t *) ( LPC176X_TMR2_BASE_ADDR + \
126#define LPC176X_T2MR1 ( *(volatile uint32_t *) ( LPC176X_TMR2_BASE_ADDR + \
128#define LPC176X_T2MR2 ( *(volatile uint32_t *) ( LPC176X_TMR2_BASE_ADDR + \
130#define LPC176X_T2MR3 ( *(volatile uint32_t *) ( LPC176X_TMR2_BASE_ADDR + \
132#define LPC176X_T2CCR ( *(volatile uint32_t *) ( LPC176X_TMR2_BASE_ADDR + \
134#define LPC176X_T2CR0 ( *(volatile uint32_t *) ( LPC176X_TMR2_BASE_ADDR + \
136#define LPC176X_T2CR1 ( *(volatile uint32_t *) ( LPC176X_TMR2_BASE_ADDR + \
138#define LPC176X_T2CR2 ( *(volatile uint32_t *) ( LPC176X_TMR2_BASE_ADDR + \
140#define LPC176X_T2CR3 ( *(volatile uint32_t *) ( LPC176X_TMR2_BASE_ADDR + \
142#define LPC176X_T2EMR ( *(volatile uint32_t *) ( LPC176X_TMR2_BASE_ADDR + \
144#define LPC176X_T2CTCR ( *(volatile uint32_t *) ( LPC176X_TMR2_BASE_ADDR + \
148#define LPC176X_TMR3_BASE_ADDR 0x40094000U
150#define LPC176X_T3IR ( *(volatile uint32_t *) ( LPC176X_TMR3_BASE_ADDR + \
152#define LPC176X_T3TCR ( *(volatile uint32_t *) ( LPC176X_TMR3_BASE_ADDR + \
154#define LPC176X_T3TC ( *(volatile uint32_t *) ( LPC176X_TMR3_BASE_ADDR + \
156#define LPC176X_T3PR ( *(volatile uint32_t *) ( LPC176X_TMR3_BASE_ADDR + \
158#define LPC176X_T3PC ( *(volatile uint32_t *) ( LPC176X_TMR3_BASE_ADDR + \
160#define LPC176X_T3MCR ( *(volatile uint32_t *) ( LPC176X_TMR3_BASE_ADDR + \
162#define LPC176X_T3MR0 ( *(volatile uint32_t *) ( LPC176X_TMR3_BASE_ADDR + \
164#define LPC176X_T3MR1 ( *(volatile uint32_t *) ( LPC176X_TMR3_BASE_ADDR + \
166#define LPC176X_T3MR2 ( *(volatile uint32_t *) ( LPC176X_TMR3_BASE_ADDR + \
168#define LPC176X_T3MR3 ( *(volatile uint32_t *) ( LPC176X_TMR3_BASE_ADDR + \
170#define LPC176X_T3CCR ( *(volatile uint32_t *) ( LPC176X_TMR3_BASE_ADDR + \
172#define LPC176X_T3CR0 ( *(volatile uint32_t *) ( LPC176X_TMR3_BASE_ADDR + \
174#define LPC176X_T3CR1 ( *(volatile uint32_t *) ( LPC176X_TMR3_BASE_ADDR + \
176#define LPC176X_T3CR2 ( *(volatile uint32_t *) ( LPC176X_TMR3_BASE_ADDR + \
178#define LPC176X_T3CR3 ( *(volatile uint32_t *) ( LPC176X_TMR3_BASE_ADDR + \
180#define LPC176X_T3EMR ( *(volatile uint32_t *) ( LPC176X_TMR3_BASE_ADDR + \
182#define LPC176X_T3CTCR ( *(volatile uint32_t *) ( LPC176X_TMR3_BASE_ADDR + \
192 volatile uint32_t
IR;
200 volatile uint32_t
TC;
204 volatile uint32_t
PR;
208 volatile uint32_t
PC;
216 volatile uint32_t MR[ 4 ];
224 volatile uint32_t CR[ 2 ];
225 volatile uint32_t reserved0;
226 volatile uint32_t reserved1;
231 volatile uint32_t reserved2[ 12 ];
238#define LPC176X_PIN_SELECT_TIMER 3U
239#define LPC176X_PINSEL_NO_PORT 999U
241#define LPC176X_TIMER_RESET ( 1U << 1U )
242#define LPC176X_TIMER_START 1U
243#define LPC176X_TIMER_MODE_COUNTER_SOURCE_CAP0 0U
244#define LPC176X_TIMER_MODE_COUNTER_SOURCE_CAP1 ( 1U << 2U )
245#define LPC176X_TIMER0_CAPTURE_PORTS { 58U, 59U }
246#define LPC176X_TIMER1_CAPTURE_PORTS { 50U, 51U }
247#define LPC176X_TIMER2_CAPTURE_PORTS { 4U, 5U }
248#define LPC176X_TIMER3_CAPTURE_PORTS { 23U, 24U }
249#define LPC176X_TIMER0_EMATCH_PORTS { 60U, \
251 LPC176X_PINSEL_NO_PORT, \
252 LPC176X_PINSEL_NO_PORT }
253#define LPC176X_TIMER1_EMATCH_PORTS { 54U, \
255 LPC176X_PINSEL_NO_PORT, \
256 LPC176X_PINSEL_NO_PORT }
257#define LPC176X_TIMER2_EMATCH_PORTS { 6U, 7U, 8U, 9U }
258#define LPC176X_TIMER3_EMATCH_PORTS { 10U, \
260 LPC176X_PINSEL_NO_PORT, \
261 LPC176X_PINSEL_NO_PORT }
262#define LPC176X_TIMER_DEFAULT_RESOLUTION 1U
263#define LPC176X_TIMER_MCR_MASK 7U
264#define LPC176X_TIMER_MCR_MASK_SIZE 3U
265#define LPC176X_TIMER_CCR_MASK 7U
266#define LPC176X_TIMER_CCR_MASK_SIZE 3U
267#define LPC176X_TIMER_EMR_MASK 3U
268#define LPC176X_TIMER_EMR_MASK_SIZE 2U
269#define LPC176X_TIMER_EMR_MASK_OFFSET 4U
270#define LPC176X_TIMER_CLEAR_FUNCTION 0U
271#define LPC176X_TIMER_PRESCALER_DIVISOR 1000000U
272#define LPC176X_TIMER_VECTOR_NUMBER( timernumber ) ( timernumber + 1U )
273#define LPC176X_TIMER_INTERRUPT_SOURCE_BIT( i ) ( 1U << i )
274#define LPC176X_TIMER_MATCH_FUNCTION_COUNT 8U
275#define LPC176X_TIMER_CAPTURE_FUNCTION_COUNT 8U
277#define LPC176X_ISR_NAME_STRING_SIZE 10U
279#define LPC176X_SET_MCR( mcr, match_port, function ) \
282 ( 0x7U << ( 3U * match_port ) ), \
283 ( 3U * match_port ) )
284#define LPC176X_SET_CCR( mcr, capture_port, function ) \
285 SET_FIELD( mcr, function, ( 0x7U << ( 3U * capture_port ) ), \
286 ( 3U * capture_port ) )
287#define LPC176X_SET_EMR( mcr, match_port, function ) \
288 SET_FIELD( mcr, function, ( 0x3U << ( 2U * match_port + 4U ) ), \
289 ( 2U * match_port + 4U ) )
299 LPC176X_CAPTURE_PORTS_COUNT
312 LPC176X_EMATCH_PORTS_COUNT
321 LPC176X_TIMER_MODE_TIMER,
322 LPC176X_TIMER_MODE_COUNTER_RISING_CAP0,
323 LPC176X_TIMER_MODE_COUNTER_FALLING_CAP0,
324 LPC176X_TIMER_MODE_COUNTER_BOTH_CAP0,
325 LPC176X_TIMER_MODE_COUNTER_RISING_CAP1 = ( 1U & ( 1U << 2U ) ),
326 LPC176X_TIMER_MODE_COUNTER_FALLING_CAP1 = ( 2U & ( 1U << 2U ) ),
327 LPC176X_TIMER_MODE_COUNTER_BOTH_CAP1 = ( 3U & ( 1U << 2U ) ),
350 LPC176X_MAT0_ISR_FUNCTION,
351 LPC176X_MAT1_ISR_FUNCTION,
352 LPC176X_MAT2_ISR_FUNCTION,
353 LPC176X_MAT3_ISR_FUNCTION,
354 LPC176X_CAP0_ISR_FUNCTION,
355 LPC176X_CAP1_ISR_FUNCTION,
356 LPC176X_ISR_FUNCTIONS_COUNT
367 LPC176X_TIMER_MATCH_FUNCTION_NONE = 0U,
368 LPC176X_TIMER_MATCH_FUNCTION_INTERRUPT = 1U,
369 LPC176X_TIMER_MATCH_FUNCTION_RESET = ( 1U << 1U ),
370 LPC176X_TIMER_MATCH_FUNCTION_STOP = ( 1U << 2U )
381 LPC176X_TIMER_CAPTURE_FUNCTION_NONE = 0U,
382 LPC176X_TIMER_CAPTURE_FUNCTION_RISING = 1U,
383 LPC176X_TIMER_CAPTURE_FUNCTION_FALLING = ( 1U << 1U ),
384 LPC176X_TIMER_CAPTURE_FUNCTION_INTERRUPT = ( 1U << 2U )
394 LPC176X_TIMER_EXTMATCH_FUNCTION_NONE,
395 LPC176X_TIMER_EXTMATCH_FUNCTION_CLEAR,
396 LPC176X_TIMER_EXTMATCH_FUNCTION_SET,
397 LPC176X_TIMER_EXTMATCH_FUNCTION_TOGGLE
413 LPC176X_ISR_FUNCTIONS_COUNT ];
Definitions types used by some devices in common.
lpc176x_module
lpc176x module representation.
Definition: common-types.h:46
uint32_t lpc176x_pin_number
A pin of the board.
Definition: common-types.h:34
Represents the timer device registers.
Definition: timer-defs.h:188
volatile uint32_t MCR
Match Control Register.
Definition: timer-defs.h:212
volatile uint32_t TC
Timer Counter.
Definition: timer-defs.h:200
volatile uint32_t PR
Prescale Register.
Definition: timer-defs.h:204
volatile uint32_t EMR
External Match Register.
Definition: timer-defs.h:230
volatile uint32_t PC
Prescale Counter.
Definition: timer-defs.h:208
volatile uint32_t TCR
Timer Control Register.
Definition: timer-defs.h:196
volatile uint32_t CCR
Capture Control Register.
Definition: timer-defs.h:220
volatile uint32_t CTCR
Count Control Register.
Definition: timer-defs.h:235
volatile uint32_t IR
Interrupt Register.
Definition: timer-defs.h:192
The Timer functions.
Definition: timer-defs.h:440
const lpc176x_isr_funct_vector * funct_vector
The vector of isr functions for this timer.
Definition: timer-defs.h:444
The Timer device representation.
Definition: timer-defs.h:418
lpc176x_timer_device *const device
The address of the controlling registers for the timer.
Definition: timer-defs.h:422
const lpc176x_module module
The module for the RTEMS module starting (power and clock).
Definition: timer-defs.h:426
void(* lpc176x_isr_funct)(const lpc176x_timer_number tnumber)
A function that attends an interruption for a timer.
Definition: timer-defs.h:406
lpc176x_ext_match_function
The possible functions at match, for the external ports.
Definition: timer-defs.h:393
lpc176x_timer_number
The timer devices in the board.
Definition: timer-defs.h:335
lpc176x_isr_funct const lpc176x_isr_funct_vector[LPC176X_ISR_FUNCTIONS_COUNT]
The vector of functions that attends each possible interrupt source for a timer.
Definition: timer-defs.h:413
lpc176x_match_port
Match ports of a timer.
Definition: timer-defs.h:307
lpc176x_match_function
The possible functions at match. This options could be used together.
Definition: timer-defs.h:366
lpc176x_capture_function
The possible functions at capture. This options could be used together.
Definition: timer-defs.h:380
lpc176x_isr_function
The index for the isr_funct_vector representing the functions that attends each possible interrupt so...
Definition: timer-defs.h:349
lpc176x_timer_mode
Timer modes of a timer.
Definition: timer-defs.h:320
lpc176x_capture_port
Capture ports of a timer.
Definition: timer-defs.h:296