timer_11xx.h
Go to the documentation of this file.
1 /*
2  * @brief LPC11xx 16/32-bit Timer/PWM control functions
3  *
4  * @note
5  * Copyright(C) NXP Semiconductors, 2012
6  * All rights reserved.
7  *
8  * @par
9  * Software that is described herein is for illustrative purposes only
10  * which provides customers with programming information regarding the
11  * LPC products. This software is supplied "AS IS" without any warranties of
12  * any kind, and NXP Semiconductors and its licensor disclaim any and
13  * all warranties, express or implied, including all implied warranties of
14  * merchantability, fitness for a particular purpose and non-infringement of
15  * intellectual property rights. NXP Semiconductors assumes no responsibility
16  * or liability for the use of the software, conveys no license or rights under any
17  * patent, copyright, mask work right, or any other intellectual property rights in
18  * or to any products. NXP Semiconductors reserves the right to make changes
19  * in the software without notification. NXP Semiconductors also makes no
20  * representation or warranty that such application will be suitable for the
21  * specified use without further testing or modification.
22  *
23  * @par
24  * Permission to use, copy, modify, and distribute this software and its
25  * documentation is hereby granted, under NXP Semiconductors' and its
26  * licensor's relevant copyrights in the software, without fee, provided that it
27  * is used in conjunction with NXP Semiconductors microcontrollers. This
28  * copyright, permission, and disclaimer notice must appear in all copies of
29  * this code.
30  */
31 
32 #ifndef __TIMER_11XX_H_
33 #define __TIMER_11XX_H_
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
47 typedef struct {
54  __IO uint32_t MR[4];
58  __I uint32_t RESERVED0[12];
61 } LPC_TIMER_T;
62 
64 #define TIMER_IR_CLR(n) _BIT(n)
65 
67 #define TIMER_MATCH_INT(n) (_BIT((n) & 0x0F))
68 
69 #define TIMER_CAP_INT(n) (_BIT((((n) & 0x0F) + 4)))
70 
72 #define TIMER_ENABLE ((uint32_t) (1 << 0))
73 
74 #define TIMER_RESET ((uint32_t) (1 << 1))
75 
77 #define TIMER_INT_ON_MATCH(n) (_BIT(((n) * 3)))
78 
79 #define TIMER_RESET_ON_MATCH(n) (_BIT((((n) * 3) + 1)))
80 
81 #define TIMER_STOP_ON_MATCH(n) (_BIT((((n) * 3) + 2)))
82 
84 #define TIMER_CAP_RISING(n) (_BIT(((n) * 3)))
85 
86 #define TIMER_CAP_FALLING(n) (_BIT((((n) * 3) + 1)))
87 
88 #define TIMER_INT_ON_CAP(n) (_BIT((((n) * 3) + 2)))
89 
95 void Chip_TIMER_Init(LPC_TIMER_T *pTMR);
96 
102 void Chip_TIMER_DeInit(LPC_TIMER_T *pTMR);
103 
113 {
114  return (bool) ((pTMR->IR & TIMER_MATCH_INT(matchnum)) != 0);
115 }
116 
126 {
127  return (bool) ((pTMR->IR & TIMER_CAP_INT(capnum)) != 0);
128 }
129 
138 {
139  pTMR->IR = TIMER_IR_CLR(matchnum);
140 }
141 
150 {
151  pTMR->IR = (0x10 << capnum);
152 }
153 
161 {
162  pTMR->TCR |= TIMER_ENABLE;
163 }
164 
172 {
173  pTMR->TCR &= ~TIMER_ENABLE;
174 }
175 
183 {
184  return pTMR->TC;
185 }
186 
194 {
195  return pTMR->PC;
196 }
197 
206 {
207  pTMR->PR = prescale;
208 }
209 
219 {
220  pTMR->MR[matchnum] = matchval;
221 }
222 
231 {
232  return pTMR->CR[capnum];
233 }
234 
240 void Chip_TIMER_Reset(LPC_TIMER_T *pTMR);
241 
250 {
251  pTMR->MCR |= TIMER_INT_ON_MATCH(matchnum);
252 }
253 
261 {
262  pTMR->MCR &= ~TIMER_INT_ON_MATCH(matchnum);
263 }
264 
272 {
273  pTMR->MCR |= TIMER_RESET_ON_MATCH(matchnum);
274 }
275 
283 {
284  pTMR->MCR &= ~TIMER_RESET_ON_MATCH(matchnum);
285 }
286 
295 {
296  pTMR->MCR |= TIMER_STOP_ON_MATCH(matchnum);
297 }
298 
307 {
308  pTMR->MCR &= ~TIMER_STOP_ON_MATCH(matchnum);
309 }
310 
320 {
321  pTMR->CCR |= TIMER_CAP_RISING(capnum);
322 }
323 
333 {
334  pTMR->CCR &= ~TIMER_CAP_RISING(capnum);
335 }
336 
346 {
347  pTMR->CCR |= TIMER_CAP_FALLING(capnum);
348 }
349 
359 {
360  pTMR->CCR &= ~TIMER_CAP_FALLING(capnum);
361 }
362 
372 {
373  pTMR->CCR |= TIMER_INT_ON_CAP(capnum);
374 }
375 
383 {
384  pTMR->CCR &= ~TIMER_INT_ON_CAP(capnum);
385 }
386 
396 
409 void Chip_TIMER_ExtMatchControlSet(LPC_TIMER_T *pTMR, int8_t initial_state,
410  TIMER_PIN_MATCH_STATE_T matchState, int8_t matchnum);
411 
421 
432  TIMER_CAP_SRC_STATE_T capSrc,
433  int8_t capnum)
434 {
435  pTMR->CTCR = (uint32_t) capSrc | ((uint32_t) capnum) << 2;
436 }
437 
442 #ifdef __cplusplus
443 }
444 #endif
445 
446 #endif /* __TIMER_11XX_H_ */
#define STATIC
Definition: lpc_types.h:140
__IO uint32_t CR[4]
Definition: timer_11xx.h:56
STATIC INLINE void Chip_TIMER_MatchDisableInt(LPC_TIMER_T *pTMR, int8_t matchnum)
Disables a match interrupt for a match counter.
Definition: timer_11xx.h:260
__IO uint32_t CCR
Definition: timer_11xx.h:55
__IO uint32_t MR[4]
Definition: timer_11xx.h:54
STATIC INLINE void Chip_TIMER_ClearCapture(LPC_TIMER_T *pTMR, int8_t capnum)
Clears a (pending) capture interrupt.
Definition: timer_11xx.h:149
STATIC INLINE void Chip_TIMER_StopOnMatchDisable(LPC_TIMER_T *pTMR, int8_t matchnum)
Disable stop on match for a match timer. Disables a match timer to stop the terminal count when a mat...
Definition: timer_11xx.h:306
STATIC INLINE void Chip_TIMER_PrescaleSet(LPC_TIMER_T *pTMR, uint32_t prescale)
Sets the prescaler value.
Definition: timer_11xx.h:205
enum IP_TIMER_PIN_MATCH_STATE TIMER_PIN_MATCH_STATE_T
Standard timer initial match pin state and change state.
std::int8_t int8_t
Definition: std.hpp:29
IP_TIMER_PIN_MATCH_STATE
Standard timer initial match pin state and change state.
Definition: timer_11xx.h:390
STATIC INLINE bool Chip_TIMER_MatchPending(LPC_TIMER_T *pTMR, int8_t matchnum)
Determine if a match interrupt is pending.
Definition: timer_11xx.h:112
void Chip_TIMER_DeInit(LPC_TIMER_T *pTMR)
Shutdown a timer.
STATIC INLINE void Chip_TIMER_CaptureEnableInt(LPC_TIMER_T *pTMR, int8_t capnum)
Enables interrupt on capture of selected CAP signal. For the selected capture register, an interrupt will be generated when the enabled rising or falling edge on CAPn.capnum is detected.
Definition: timer_11xx.h:371
#define TIMER_CAP_FALLING(n)
Definition: timer_11xx.h:86
#define __I
Definition: core_cm0.h:151
#define TIMER_RESET_ON_MATCH(n)
Definition: timer_11xx.h:79
STATIC INLINE uint32_t Chip_TIMER_ReadCount(LPC_TIMER_T *pTMR)
Returns the current timer count.
Definition: timer_11xx.h:182
#define TIMER_MATCH_INT(n)
Definition: timer_11xx.h:67
#define TIMER_INT_ON_MATCH(n)
Definition: timer_11xx.h:77
void Chip_TIMER_Init(LPC_TIMER_T *pTMR)
Initialize a timer.
STATIC INLINE void Chip_TIMER_ClearMatch(LPC_TIMER_T *pTMR, int8_t matchnum)
Clears a (pending) match interrupt.
Definition: timer_11xx.h:137
STATIC INLINE void Chip_TIMER_ResetOnMatchDisable(LPC_TIMER_T *pTMR, int8_t matchnum)
For the specific match counter, disables reset of the terminal count register when a match occurs...
Definition: timer_11xx.h:282
STATIC INLINE void Chip_TIMER_ResetOnMatchEnable(LPC_TIMER_T *pTMR, int8_t matchnum)
For the specific match counter, enables reset of the terminal count register when a match occurs...
Definition: timer_11xx.h:271
__IO uint32_t MCR
Definition: timer_11xx.h:53
__IO uint32_t PC
Definition: timer_11xx.h:52
STATIC INLINE void Chip_TIMER_CaptureRisingEdgeDisable(LPC_TIMER_T *pTMR, int8_t capnum)
Disables capture on on rising edge of selected CAP signal. For the selected capture register...
Definition: timer_11xx.h:332
#define __IO
Definition: core_cm0.h:154
STATIC INLINE void Chip_TIMER_TIMER_SetCountClockSrc(LPC_TIMER_T *pTMR, TIMER_CAP_SRC_STATE_T capSrc, int8_t capnum)
Sets timer count source and edge with the selected passed from CapSrc. If CapSrc selected a CAPn pin...
Definition: timer_11xx.h:431
__IO uint32_t PWMC
Definition: timer_11xx.h:60
__IO uint32_t TCR
Definition: timer_11xx.h:49
#define TIMER_INT_ON_CAP(n)
Definition: timer_11xx.h:88
std::uint32_t uint32_t
Definition: std.hpp:26
__IO uint32_t PR
Definition: timer_11xx.h:51
__IO uint32_t TC
Definition: timer_11xx.h:50
__IO uint32_t IR
Definition: timer_11xx.h:48
#define INLINE
Definition: lpc_types.h:205
#define CR
Definition: sja1000_defs.h:42
STATIC INLINE bool Chip_TIMER_CapturePending(LPC_TIMER_T *pTMR, int8_t capnum)
Determine if a capture interrupt is pending.
Definition: timer_11xx.h:125
STATIC INLINE uint32_t Chip_TIMER_ReadPrescale(LPC_TIMER_T *pTMR)
Returns the current prescale count.
Definition: timer_11xx.h:193
STATIC INLINE void Chip_TIMER_CaptureFallingEdgeDisable(LPC_TIMER_T *pTMR, int8_t capnum)
Disables capture on on falling edge of selected CAP signal. For the selected capture register...
Definition: timer_11xx.h:358
STATIC INLINE void Chip_TIMER_Enable(LPC_TIMER_T *pTMR)
Enables the timer (starts count)
Definition: timer_11xx.h:160
__IO uint32_t CTCR
Definition: timer_11xx.h:59
#define TIMER_CAP_INT(n)
Definition: timer_11xx.h:69
STATIC INLINE void Chip_TIMER_SetMatch(LPC_TIMER_T *pTMR, int8_t matchnum, uint32_t matchval)
Sets a timer match value.
Definition: timer_11xx.h:218
STATIC INLINE void Chip_TIMER_Disable(LPC_TIMER_T *pTMR)
Disables the timer (stops count)
Definition: timer_11xx.h:171
STATIC INLINE void Chip_TIMER_MatchEnableInt(LPC_TIMER_T *pTMR, int8_t matchnum)
Enables a match interrupt that fires when the terminal count matches the match counter value...
Definition: timer_11xx.h:249
STATIC INLINE void Chip_TIMER_CaptureDisableInt(LPC_TIMER_T *pTMR, int8_t capnum)
Disables interrupt on capture of selected CAP signal.
Definition: timer_11xx.h:382
#define TIMER_ENABLE
Definition: timer_11xx.h:72
#define TIMER_STOP_ON_MATCH(n)
Definition: timer_11xx.h:81
void Chip_TIMER_Reset(LPC_TIMER_T *pTMR)
Resets the timer terminal and prescale counts to 0.
enum IP_TIMER_CAP_SRC_STATE TIMER_CAP_SRC_STATE_T
Standard timer clock and edge for count source.
#define TIMER_IR_CLR(n)
Definition: timer_11xx.h:64
STATIC INLINE void Chip_TIMER_CaptureFallingEdgeEnable(LPC_TIMER_T *pTMR, int8_t capnum)
Enables capture on on falling edge of selected CAP signal. For the selected capture register...
Definition: timer_11xx.h:345
32-bit Standard timer register block structure
Definition: timer_11xx.h:47
IP_TIMER_CAP_SRC_STATE
Standard timer clock and edge for count source.
Definition: timer_11xx.h:415
STATIC INLINE void Chip_TIMER_CaptureRisingEdgeEnable(LPC_TIMER_T *pTMR, int8_t capnum)
Enables capture on on rising edge of selected CAP signal for the selected capture register...
Definition: timer_11xx.h:319
#define TIMER_CAP_RISING(n)
Definition: timer_11xx.h:84
__IO uint32_t EMR
Definition: timer_11xx.h:57
STATIC INLINE uint32_t Chip_TIMER_ReadCapture(LPC_TIMER_T *pTMR, int8_t capnum)
Reads a capture register.
Definition: timer_11xx.h:230
void Chip_TIMER_ExtMatchControlSet(LPC_TIMER_T *pTMR, int8_t initial_state, TIMER_PIN_MATCH_STATE_T matchState, int8_t matchnum)
Sets external match control (MATn.matchnum) pin control. For the pin selected with matchnum...
STATIC INLINE void Chip_TIMER_StopOnMatchEnable(LPC_TIMER_T *pTMR, int8_t matchnum)
Enable a match timer to stop the terminal count when a match count equals the terminal count...
Definition: timer_11xx.h:294


uavcan_communicator
Author(s):
autogenerated on Wed Jan 11 2023 03:59:40