| LPCOpen Platform v1.03 LPCOpen Platform for NXP LPC Microcontrollers

- Main Page
- Modules
- Data Structures
- Files
- Related Pages

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Enumerations | Functions
IP: Timer register block and driver
IP drivers: Common drivers used on multiple NXP devices

## Detailed Description

## Data Structures
struct | IP_TIMER_001_T
| 32-bit Standard timer register block structure More...

## Macros
#define | TIMER_IR_CLR(n) _BIT(n)
#define | TIMER_MATCH_INT(n) (_BIT((n) & 0x0F))
#define | TIMER_CAP_INT(n) (_BIT((((n) & 0x0F) + 4)))
#define | TIMER_ENABLE ((uint32_t) (1 << 0))
#define | TIMER_RESET ((uint32_t) (1 << 1))
#define | TIMER_INT_ON_MATCH(n) (_BIT(((n) * 3)))
#define | TIMER_RESET_ON_MATCH(n) (_BIT((((n) * 3) + 1)))
#define | TIMER_STOP_ON_MATCH(n) (_BIT((((n) * 3) + 2)))
#define | TIMER_CAP_RISING(n) (_BIT(((n) * 3)))
#define | TIMER_CAP_FALLING(n) (_BIT((((n) * 3) + 1)))
#define | TIMER_INT_ON_CAP(n) (_BIT((((n) * 3) + 2)))

## Enumerations
enum | IP_TIMER_PIN_MATCH_STATE_T { TIMER_EXTMATCH_DO_NOTHING = 0, TIMER_EXTMATCH_CLEAR = 1, TIMER_EXTMATCH_SET = 2, TIMER_EXTMATCH_TOGGLE = 3 }
| Standard timer initial match pin state and change state. More...
enum | IP_TIMER_CAP_SRC_STATE_T { TIMER_CAPSRC_RISING_PCLK = 0, TIMER_CAPSRC_RISING_CAPN = 1, TIMER_CAPSRC_FALLING_CAPN = 2, TIMER_CAPSRC_BOTH_CAPN = 3 }
| Standard timer clock and edge for count source. More...

## Functions
STATIC INLINE bool | IP_TIMER_MatchPending (IP_TIMER_001_T *pTimer, int8_t matchnum)
| Determine if a match interrupt is pending.
STATIC INLINE bool | IP_TIMER_CapturePending (IP_TIMER_001_T *pTimer, int8_t capnum)
| Determine if a capture interrupt is pending.
STATIC INLINE void | IP_TIMER_ClearMatch (IP_TIMER_001_T *pTimer, int8_t matchnum)
| Clears a (pending) match interrupt.
STATIC INLINE void | IP_TIMER_ClearCapture (IP_TIMER_001_T *pTimer, int8_t capnum)
| Clears a (pending) capture interrupt.
STATIC INLINE void | IP_TIMER_Enable (IP_TIMER_001_T *pTimer)
| Enables the timer (starts count)
STATIC INLINE void | IP_TIMER_Disable (IP_TIMER_001_T *pTimer)
| Disables the timer (stops count)
STATIC INLINE uint32_t | IP_TIMER_ReadCount (IP_TIMER_001_T *pTimer)
| Returns the current timer count.
STATIC INLINE uint32_t | IP_TIMER_ReadPrescale (IP_TIMER_001_T *pTimer)
| Returns the current prescale count.
STATIC INLINE void | IP_TIMER_PrescaleSet (IP_TIMER_001_T *pTimer, uint32_t prescale)
| Sets the prescaler value.
STATIC INLINE void | IP_TIMER_SetMatch (IP_TIMER_001_T *pTimer, int8_t matchnum, uint32_t matchval)
| Sets a timer match value.
STATIC INLINE uint32_t | IP_TIMER_ReadCapture (IP_TIMER_001_T *pTimer, int8_t capnum)
| Reads a capture register.
void | IP_TIMER_Reset (IP_TIMER_001_T *pTimer)
| Resets the timer terminal and prescale counts to 0.
STATIC INLINE void | IP_TIMER_MatchEnableInt (IP_TIMER_001_T *pTimer, int8_t matchnum)
| Enables a match interrupt that fires when the terminal count matches the match counter value.
STATIC INLINE void | IP_TIMER_MatchDisableInt (IP_TIMER_001_T *pTimer, int8_t matchnum)
| Disables a match interrupt for a match counter.
STATIC INLINE void | IP_TIMER_ResetOnMatchEnable (IP_TIMER_001_T *pTimer, int8_t matchnum)
| For the specific match counter, enables reset of the terminal count register when a match occurs.
STATIC INLINE void | IP_TIMER_ResetOnMatchDisable (IP_TIMER_001_T *pTimer, int8_t matchnum)
| For the specific match counter, disables reset of the terminal count register when a match occurs.
STATIC INLINE void | IP_TIMER_StopOnMatchEnable (IP_TIMER_001_T *pTimer, int8_t matchnum)
| Enable a match timer to stop the terminal count when a match count equals the terminal count.
STATIC INLINE void | IP_TIMER_StopOnMatchDisable (IP_TIMER_001_T *pTimer, int8_t matchnum)
| Disable stop on match for a match timer. Disables a match timer to stop the terminal count when a match count equals the terminal count.
STATIC INLINE void | IP_TIMER_CaptureRisingEdgeEnable (IP_TIMER_001_T *pTimer, int8_t capnum)
| Enables capture on on rising edge of selected CAP signal for the selected capture register, enables the selected CAPn.capnum signal to load the capture register with the terminal coount on a rising edge.
STATIC INLINE void | IP_TIMER_CaptureRisingEdgeDisable (IP_TIMER_001_T *pTimer, int8_t capnum)
| Disables capture on on rising edge of selected CAP signal. For the selected capture register, disables the selected CAPn.capnum signal to load the capture register with the terminal coount on a rising edge.
STATIC INLINE void | IP_TIMER_CaptureFallingEdgeEnable (IP_TIMER_001_T *pTimer, int8_t capnum)
| Enables capture on on falling edge of selected CAP signal. For the selected capture register, enables the selected CAPn.capnum signal to load the capture register with the terminal coount on a falling edge.
STATIC INLINE void | IP_TIMER_CaptureFallingEdgeDisable (IP_TIMER_001_T *pTimer, int8_t capnum)
| Disables capture on on falling edge of selected CAP signal. For the selected capture register, disables the selected CAPn.capnum signal to load the capture register with the terminal coount on a falling edge.
STATIC INLINE void | IP_TIMER_CaptureEnableInt (IP_TIMER_001_T *pTimer, 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.
STATIC INLINE void | IP_TIMER_CaptureDisableInt (IP_TIMER_001_T *pTimer, int8_t capnum)
| Disables interrupt on capture of selected CAP signal.
void | IP_TIMER_ExtMatchControlSet (IP_TIMER_001_T *pTimer, int8_t initial_state, IP_TIMER_PIN_MATCH_STATE_T matchState, int8_t matchnum)
| Sets external match control (MATn.matchnum) pin control.
void | IP_TIMER_SetCountClockSrc (IP_TIMER_001_T *pTimer, IP_TIMER_CAP_SRC_STATE_T capSrc, int8_t capnum)
| Sets timer count source and edge with the selected passed from CapSrc.

## Macro Definition Documentation

#define TIMER_CAP_FALLING | ( |  | n | ) | (_BIT((((n) * 3) + 1)))

Bit location for CAP.n on CRx falling edge, n = 0 to 3

Definition at line 92 of file timer_001.h.

#define TIMER_CAP_INT | ( |  | n | ) | (_BIT((((n) & 0x0F) + 4)))

Macro for getting a capture event interrupt bit

Definition at line 75 of file timer_001.h.

#define TIMER_CAP_RISING | ( |  | n | ) | (_BIT(((n) * 3)))

Bit location for CAP.n on CRx rising edge, n = 0 to 3

Definition at line 90 of file timer_001.h.

#define TIMER_ENABLE ((uint32_t) (1 << 0))

Timer/counter enable bit

Definition at line 78 of file timer_001.h.

#define TIMER_INT_ON_CAP | ( |  | n | ) | (_BIT((((n) * 3) + 2)))

Bit location for CAP.n on CRx interrupt enable, n = 0 to 3

Definition at line 94 of file timer_001.h.

#define TIMER_INT_ON_MATCH | ( |  | n | ) | (_BIT(((n) * 3)))

Bit location for interrupt on MRx match, n = 0 to 3

Definition at line 83 of file timer_001.h.

#define TIMER_IR_CLR | ( |  | n | ) | _BIT(n)

Macro to clear interrupt pending

Definition at line 70 of file timer_001.h.

#define TIMER_MATCH_INT | ( |  | n | ) | (_BIT((n) & 0x0F))

Macro for getting a timer match interrupt bit

Definition at line 73 of file timer_001.h.

#define TIMER_RESET ((uint32_t) (1 << 1))

Timer/counter reset bit

Definition at line 80 of file timer_001.h.

#define TIMER_RESET_ON_MATCH | ( |  | n | ) | (_BIT((((n) * 3) + 1)))

Bit location for reset on MRx match, n = 0 to 3

Definition at line 85 of file timer_001.h.

#define TIMER_STOP_ON_MATCH | ( |  | n | ) | (_BIT((((n) * 3) + 2)))

Bit location for stop on MRx match, n = 0 to 3

Definition at line 87 of file timer_001.h.

## Enumeration Type Documentation

enum IP_TIMER_CAP_SRC_STATE_T

Standard timer clock and edge for count source.

Enumerator:

  TIMER_CAPSRC_RISING_PCLK | Timer ticks on PCLK rising edge
  TIMER_CAPSRC_RISING_CAPN | Timer ticks on CAPn.x rising edge
  TIMER_CAPSRC_FALLING_CAPN | Timer ticks on CAPn.x falling edge
  TIMER_CAPSRC_BOTH_CAPN | Timer ticks on CAPn.x both edges

Definition at line 405 of file timer_001.h.

enum IP_TIMER_PIN_MATCH_STATE_T

Standard timer initial match pin state and change state.

Enumerator:

  TIMER_EXTMATCH_DO_NOTHING | Timer match state does nothing on match pin
  TIMER_EXTMATCH_CLEAR | Timer match state sets match pin low
  TIMER_EXTMATCH_SET | Timer match state sets match pin high
  TIMER_EXTMATCH_TOGGLE | Timer match state toggles match pin

Definition at line 382 of file timer_001.h.

## Function Documentation

STATIC INLINE void IP_TIMER_CaptureDisableInt | ( | IP_TIMER_001_T * | pTimer,
|  | int8_t | capnum
| ) |  |

Disables interrupt on capture of selected CAP signal.

Parameters

  pTimer | : Pointer to timer IP register address
  capnum | : Capture signal/register to use

Returns
  Nothing

Definition at line 374 of file timer_001.h.

STATIC INLINE void IP_TIMER_CaptureEnableInt | ( | IP_TIMER_001_T * | pTimer,
|  | 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.

Parameters

  pTimer | : Pointer to timer IP register address
  capnum | : Capture signal/register to use

Returns
  Nothing

Definition at line 363 of file timer_001.h.

STATIC INLINE void IP_TIMER_CaptureFallingEdgeDisable | ( | IP_TIMER_001_T * | pTimer,
|  | int8_t | capnum
| ) |  |

Disables capture on on falling edge of selected CAP signal. For the selected capture register, disables the selected CAPn.capnum signal to load the capture register with the terminal coount on a falling edge.

Parameters

  pTimer | : Pointer to timer IP register address
  capnum | : Capture signal/register to use

Returns
  Nothing

Definition at line 350 of file timer_001.h.

STATIC INLINE void IP_TIMER_CaptureFallingEdgeEnable | ( | IP_TIMER_001_T * | pTimer,
|  | int8_t | capnum
| ) |  |

Enables capture on on falling edge of selected CAP signal. For the selected capture register, enables the selected CAPn.capnum signal to load the capture register with the terminal coount on a falling edge.

Parameters

  pTimer | : Pointer to timer IP register address
  capnum | : Capture signal/register to use

Returns
  Nothing

Definition at line 337 of file timer_001.h.

STATIC INLINE bool IP_TIMER_CapturePending | ( | IP_TIMER_001_T * | pTimer,
|  | int8_t | capnum
| ) |  |

Determine if a capture interrupt is pending.

Parameters

  pTimer | : Pointer to timer IP register address
  capnum | : Capture interrupt number to check

Returns
  false if the interrupt is not pending, otherwise true

Note
  Determine if the capture interrupt for the passed capture pin is pending.

Definition at line 117 of file timer_001.h.

STATIC INLINE void IP_TIMER_CaptureRisingEdgeDisable | ( | IP_TIMER_001_T * | pTimer,
|  | int8_t | capnum
| ) |  |

Disables capture on on rising edge of selected CAP signal. For the selected capture register, disables the selected CAPn.capnum signal to load the capture register with the terminal coount on a rising edge.

Parameters

  pTimer | : Pointer to timer IP register address
  capnum | : Capture signal/register to use

Returns
  Nothing

Definition at line 324 of file timer_001.h.

STATIC INLINE void IP_TIMER_CaptureRisingEdgeEnable | ( | IP_TIMER_001_T * | pTimer,
|  | int8_t | capnum
| ) |  |

Enables capture on on rising edge of selected CAP signal for the selected capture register, enables the selected CAPn.capnum signal to load the capture register with the terminal coount on a rising edge.

Parameters

  pTimer | : Pointer to timer IP register address
  capnum | : Capture signal/register to use

Returns
  Nothing

Definition at line 311 of file timer_001.h.

STATIC INLINE void IP_TIMER_ClearCapture | ( | IP_TIMER_001_T * | pTimer,
|  | int8_t | capnum
| ) |  |

Clears a (pending) capture interrupt.

Parameters

  pTimer | : Pointer to timer IP register address
  capnum | : Capture interrupt number to clear

Returns
  Nothing

Note
  Clears a pending timer capture interrupt.

Definition at line 141 of file timer_001.h.

STATIC INLINE void IP_TIMER_ClearMatch | ( | IP_TIMER_001_T * | pTimer,
|  | int8_t | matchnum
| ) |  |

Clears a (pending) match interrupt.

Parameters

  pTimer | : Pointer to timer IP register address
  matchnum | : Match interrupt number to clear

Returns
  Nothing

Note
  Clears a pending timer match interrupt.

Definition at line 129 of file timer_001.h.

STATIC INLINE void IP_TIMER_Disable | ( | IP_TIMER_001_T * | pTimer | ) |

Disables the timer (stops count)

Parameters

  pTimer | : Pointer to timer IP register address

Returns
  Nothing

Note
  Disables the timer to stop counting.

Definition at line 163 of file timer_001.h.

STATIC INLINE void IP_TIMER_Enable | ( | IP_TIMER_001_T * | pTimer | ) |

Enables the timer (starts count)

Parameters

  pTimer | : Pointer to timer IP register address

Returns
  Nothing

Note
  Enables the timer to start counting.

Definition at line 152 of file timer_001.h.

void IP_TIMER_ExtMatchControlSet | ( | IP_TIMER_001_T * | pTimer,
|  | int8_t | initial_state,
|  | IP_TIMER_PIN_MATCH_STATE_T | matchState,
|  | int8_t | matchnum
| ) |  |

Sets external match control (MATn.matchnum) pin control.

Parameters

  pTimer | : Pointer to timer IP register address
  initial_state | : Initial state of the pin, high(1) or low(0)
  matchState | : Selects the match state for the pin
  matchnum | : MATn.matchnum signal to use

Returns
  Nothing

Note
  For the pin selected with matchnum, sets the function of the pin that occurs on a terminal count match for the match count.

Definition at line 71 of file timer_001.c.

STATIC INLINE void IP_TIMER_MatchDisableInt | ( | IP_TIMER_001_T * | pTimer,
|  | int8_t | matchnum
| ) |  |

Disables a match interrupt for a match counter.

Parameters

  pTimer | : Pointer to timer IP register address
  matchnum | : Match timer, 0 to 3

Returns
  Nothing

Definition at line 252 of file timer_001.h.

STATIC INLINE void IP_TIMER_MatchEnableInt | ( | IP_TIMER_001_T * | pTimer,
|  | int8_t | matchnum
| ) |  |

Enables a match interrupt that fires when the terminal count matches the match counter value.

Parameters

  pTimer | : Pointer to timer IP register address
  matchnum | : Match timer, 0 to 3

Returns
  Nothing

Definition at line 241 of file timer_001.h.

STATIC INLINE bool IP_TIMER_MatchPending | ( | IP_TIMER_001_T * | pTimer,
|  | int8_t | matchnum
| ) |  |

Determine if a match interrupt is pending.

Parameters

  pTimer | : Pointer to timer IP register address
  matchnum | : Match interrupt number to check

Returns
  false if the interrupt is not pending, otherwise true

Note
  Determine if the match interrupt for the passed timer and match counter is pending.

Definition at line 104 of file timer_001.h.

STATIC INLINE void IP_TIMER_PrescaleSet | ( | IP_TIMER_001_T * | pTimer,
|  | uint32_t | prescale
| ) |  |

Sets the prescaler value.

Parameters

  pTimer | : Pointer to timer IP register address
  prescale | : Prescale value to set the prescale register to

Returns
  Nothing

Note
  Sets the prescale count value.

Definition at line 197 of file timer_001.h.

STATIC INLINE uint32_t IP_TIMER_ReadCapture | ( | IP_TIMER_001_T * | pTimer,
|  | int8_t | capnum
| ) |  |

Reads a capture register.

Parameters

  pTimer | : Pointer to timer IP register address
  capnum | : Capture register to read

Returns
  The selected capture register value

Note
  Returns the selected capture register value.

Definition at line 222 of file timer_001.h.

STATIC INLINE uint32_t IP_TIMER_ReadCount | ( | IP_TIMER_001_T * | pTimer | ) |

Returns the current timer count.

Parameters

  pTimer | : Pointer to timer IP register address

Returns
  Current timer terminal count value

Note
  Returns the current timer terminal count.

Definition at line 174 of file timer_001.h.

STATIC INLINE uint32_t IP_TIMER_ReadPrescale | ( | IP_TIMER_001_T * | pTimer | ) |

Returns the current prescale count.

Parameters

  pTimer | : Pointer to timer IP register address

Returns
  Current timer prescale count value

Note
  Returns the current prescale count.

Definition at line 185 of file timer_001.h.

void IP_TIMER_Reset | ( | IP_TIMER_001_T * | pTimer | ) |

Resets the timer terminal and prescale counts to 0.

Parameters

  pTimer | : Pointer to timer IP register address

Returns
  Nothing

Definition at line 51 of file timer_001.c.

STATIC INLINE void IP_TIMER_ResetOnMatchDisable | ( | IP_TIMER_001_T * | pTimer,
|  | int8_t | matchnum
| ) |  |

For the specific match counter, disables reset of the terminal count register when a match occurs.

Parameters

  pTimer | : Pointer to timer IP register address
  matchnum | : Match timer, 0 to 3

Returns
  Nothing

Definition at line 274 of file timer_001.h.

STATIC INLINE void IP_TIMER_ResetOnMatchEnable | ( | IP_TIMER_001_T * | pTimer,
|  | int8_t | matchnum
| ) |  |

For the specific match counter, enables reset of the terminal count register when a match occurs.

Parameters

  pTimer | : Pointer to timer IP register address
  matchnum | : Match timer, 0 to 3

Returns
  Nothing

Definition at line 263 of file timer_001.h.

void IP_TIMER_SetCountClockSrc | ( | IP_TIMER_001_T * | pTimer,
|  | IP_TIMER_CAP_SRC_STATE_T | capSrc,
|  | int8_t | capnum
| ) |  |

Sets timer count source and edge with the selected passed from CapSrc.

Parameters

  pTimer | : Pointer to timer IP register address
  capSrc | : timer clock source and edge
  capnum | : CAPn.capnum pin to use (if used)

Returns
  Nothing

Note
  If CapSrc selected a CAPn pin, select the specific CAPn pin with the capnum value.

STATIC INLINE void IP_TIMER_SetMatch | ( | IP_TIMER_001_T * | pTimer,
|  | int8_t | matchnum,
|  | uint32_t | matchval
| ) |  |

Sets a timer match value.

Parameters

  pTimer | : Pointer to timer IP register address
  matchnum | : Match timer to set match count for
  matchval | : Match value for the selected match count

Returns
  Nothing

Note
  Sets ones of the timer match values.

Definition at line 210 of file timer_001.h.

STATIC INLINE void IP_TIMER_StopOnMatchDisable | ( | IP_TIMER_001_T * | pTimer,
|  | int8_t | matchnum
| ) |  |

Disable stop on match for a match timer. Disables a match timer to stop the terminal count when a match count equals the terminal count.

Parameters

  pTimer | : Pointer to timer IP register address
  matchnum | : Match timer, 0 to 3

Returns
  Nothing

Definition at line 298 of file timer_001.h.

STATIC INLINE void IP_TIMER_StopOnMatchEnable | ( | IP_TIMER_001_T * | pTimer,
|  | int8_t | matchnum
| ) |  |

Enable a match timer to stop the terminal count when a match count equals the terminal count.

Parameters

  pTimer | : Pointer to timer IP register address
  matchnum | : Match timer, 0 to 3

Returns
  Nothing

Definition at line 286 of file timer_001.h.