| 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: 10 or 12-bit ADC register block and driver
IP drivers: Common drivers used on multiple NXP devices

## Detailed Description

## Data Structures
struct | IP_ADC_001_T
| 10 or 12-bit ADC register block structure More...

## Macros
#define | ADC_ACC_10BITS
#define | ADC_DR_RESULT(n) ((((n) >> 6) & 0x3FF))
| ADC register support bitfields and mask.
#define | ADC_CR_BITACC(n) ((((n) & 0x7) << 17))
#define | ADC_DR_DONE(n) (((n) >> 31))
#define | ADC_DR_OVERRUN(n) ((((n) >> 30) & (1UL)))
#define | ADC_CR_CH_SEL(n) ((1UL << (n)))
#define | ADC_CR_CLKDIV(n) ((((n) & 0xFF) << 8))
#define | ADC_CR_BURST ((1UL << 16))
#define | ADC_CR_PDN ((1UL << 21))
#define | ADC_CR_START_MASK ((7UL << 24))
#define | ADC_CR_START_MODE_SEL(SEL) ((SEL << 24))
#define | ADC_CR_START_NOW ((1UL << 24))
#define | ADC_CR_START_CTOUT15 ((2UL << 24))
#define | ADC_CR_START_CTOUT8 ((3UL << 24))
#define | ADC_CR_START_ADCTRIG0 ((4UL << 24))
#define | ADC_CR_START_ADCTRIG1 ((5UL << 24))
#define | ADC_CR_START_MCOA2 ((6UL << 24))
#define | ADC_CR_EDGE ((1UL << 27))
#define | ADC_CONFIG_MASK (ADC_CR_CLKDIV(0xFF) | ADC_CR_BITACC(0x07) | ADC_CR_PDN)

## Enumerations
enum | IP_ADC_STATUS_T { ADC_DR_DONE_STAT, ADC_DR_OVERRUN_STAT, ADC_DR_ADINT_STAT }
| ADC status register used for IP drivers. More...

## Functions
void | IP_ADC_Init (IP_ADC_001_T *pADC, uint8_t div, uint8_t bitsAcc, uint32_t flag)
| Initialize for ADC.
void | IP_ADC_DeInit (IP_ADC_001_T *pADC)
| Shutdown ADC.
void | IP_ADC_SetBurstMode (IP_ADC_001_T *pADC, FunctionalState NewState)
| Set burst mode for ADC.
Status | IP_ADC_Get_Val (IP_ADC_001_T *pADC, uint8_t channel, uint16_t *data)
| Get the ADC value.
FlagStatus | IP_ADC_GetStatus (IP_ADC_001_T *pADC, uint8_t channel, uint32_t StatusType)
| Get ADC Channel status from ADC data register.
void | IP_ADC_EdgeStartConfig (IP_ADC_001_T *pADC, uint8_t edge_mode)
| Set the edge start condition.
void | IP_ADC_SetChannelNumber (IP_ADC_001_T *pADC, uint8_t channel, FunctionalState NewState)
| Enable/Disable ADC channel number.
void | IP_ADC_SetStartMode (IP_ADC_001_T *pADC, uint8_t start_mode)
| Set start mode for ADC.
void | IP_ADC_Int_Enable (IP_ADC_001_T *pADC, uint8_t channel, FunctionalState NewState)
| Enable/Disable interrupt for ADC channel.

## Macro Definition Documentation

#define ADC_ACC_10BITS

Definition at line 51 of file adc_001.h.

#define ADC_CONFIG_MASK (ADC_CR_CLKDIV(0xFF) | ADC_CR_BITACC(0x07) | ADC_CR_PDN)

Definition at line 106 of file adc_001.h.

#define ADC_CR_BITACC | ( |  | n | ) | ((((n) & 0x7) << 17))

Number of ADC accuracy bits

Definition at line 76 of file adc_001.h.

#define ADC_CR_BURST ((1UL << 16))

Repeated conversions A/D enable bit

Definition at line 83 of file adc_001.h.

#define ADC_CR_CH_SEL | ( |  | n | ) | ((1UL << (n)))

Selects which of the AD0.0:7 pins is (are) to be sampled and converted

Definition at line 81 of file adc_001.h.

#define ADC_CR_CLKDIV | ( |  | n | ) | ((((n) & 0xFF) << 8))

The APB clock (PCLK) is divided by (this value plus one) to produce the clock for the A/D

Definition at line 82 of file adc_001.h.

#define ADC_CR_EDGE ((1UL << 27))

Start conversion on a falling edge on the selected CAP/MAT signal

Definition at line 98 of file adc_001.h.

#define ADC_CR_PDN ((1UL << 21))

ADC convert is operational

Definition at line 88 of file adc_001.h.

#define ADC_CR_START_ADCTRIG0 ((4UL << 24))

Start conversion when the edge selected by bit 27 occurs on ADCTRIG0

Definition at line 95 of file adc_001.h.

#define ADC_CR_START_ADCTRIG1 ((5UL << 24))

Start conversion when the edge selected by bit 27 occurs on ADCTRIG1

Definition at line 96 of file adc_001.h.

#define ADC_CR_START_CTOUT15 ((2UL << 24))

Start conversion when the edge selected by bit 27 occurs on CTOUT_15

Definition at line 93 of file adc_001.h.

#define ADC_CR_START_CTOUT8 ((3UL << 24))

Start conversion when the edge selected by bit 27 occurs on CTOUT_8

Definition at line 94 of file adc_001.h.

#define ADC_CR_START_MASK ((7UL << 24))

ADC start mask bits

Definition at line 90 of file adc_001.h.

#define ADC_CR_START_MCOA2 ((6UL << 24))

Start conversion when the edge selected by bit 27 occurs on Motocon PWM output MCOA2

Definition at line 97 of file adc_001.h.

#define ADC_CR_START_MODE_SEL | ( |  | SEL | ) | ((SEL << 24))

Select Start Mode

Definition at line 91 of file adc_001.h.

#define ADC_CR_START_NOW ((1UL << 24))

Start conversion now

Definition at line 92 of file adc_001.h.

#define ADC_DR_DONE | ( |  | n | ) | (((n) >> 31))

Mask for reading the ADC done status

Definition at line 79 of file adc_001.h.

#define ADC_DR_OVERRUN | ( |  | n | ) | ((((n) >> 30) & (1UL)))

Mask for reading the ADC overrun status

Definition at line 80 of file adc_001.h.

#define ADC_DR_RESULT | ( |  | n | ) | ((((n) >> 6) & 0x3FF))

ADC register support bitfields and mask.

Mask for getting the 10 bits ADC data read value

Definition at line 75 of file adc_001.h.

## Enumeration Type Documentation

enum IP_ADC_STATUS_T

ADC status register used for IP drivers.

Enumerator:

  ADC_DR_DONE_STAT | ADC data register staus
  ADC_DR_OVERRUN_STAT | ADC data overrun staus
  ADC_DR_ADINT_STAT | ADC interrupt status

Definition at line 112 of file adc_001.h.

## Function Documentation

void IP_ADC_DeInit | ( | IP_ADC_001_T * | pADC | ) |

Shutdown ADC.

Parameters

  pADC | : The base of ADC peripheral on the chip

Returns
  Nothing

Note
  Reset the ADC control and INTEN Register to reset values (disabled)

Definition at line 70 of file adc_001.c.

void IP_ADC_EdgeStartConfig | ( | IP_ADC_001_T * | pADC,
|  | uint8_t | edge_mode
| ) |  |

Set the edge start condition.

Parameters

  pADC | : The base of ADC peripheral on the chip
  edge_mode | : 0 = rising, !0 = falling

Returns
  Nothing

Definition at line 125 of file adc_001.c.

Status IP_ADC_Get_Val | ( | IP_ADC_001_T * | pADC,
|  | uint8_t | channel,
|  | uint16_t * | data
| ) |  |

Get the ADC value.

Parameters

  pADC | : The base of ADC peripheral on the chip
  channel | : Channel to be read value, should be 0..7
  data | : Data buffer to store the A/D value

Returns
  Status : SUCCESS or ERROR

Definition at line 91 of file adc_001.c.

FlagStatus IP_ADC_GetStatus | ( | IP_ADC_001_T * | pADC,
|  | uint8_t | channel,
|  | uint32_t | StatusType
| ) |  |

Get ADC Channel status from ADC data register.

Parameters

  pADC | : The base of ADC peripheral on the chip
  channel | : Channel number, should be 0..7
  StatusType | : Register to read, ADC_DR_DONE_STAT, ADC_DR_OVERRUN_STAT, or ADC_DR_ADINT_STAT

Returns
  Channel status, SET or RESET

Definition at line 105 of file adc_001.c.

void IP_ADC_Init | ( | IP_ADC_001_T * | pADC,
|  | uint8_t | div,
|  | uint8_t | bitsAcc,
|  | uint32_t | flag
| ) |  |

Initialize for ADC.

Parameters

  pADC | : The base of ADC peripheral on the chip
  div | : Clock divide value
  bitsAcc | : Number of bits of accuracy of the conversion result
  flag | : ADC mode flag.

Returns
  Nothing

Note
  bitsAcc only make sense in 10-bit converter. And, it should be ADC_3BITS ->ADC_10BITS. ADC mode flag is or-ed bit values of the following flags:
  - ADC_CR_PDN: The A/D converter is operational. If this flag isn't set, the ADC is in power-down mode. This flag isn't available in LPC13xx.
  - ADC_CR_LPWRMODE: The analog circuitry is automatically powered-down when no conversions are taking place. This flag is only available in LPC1347.
  - ADC_CR_MODE10BIT: Enable the 10-bit conversion rate mode with high conversion rate. This flag is only available in LPC1347.

Definition at line 51 of file adc_001.c.

void IP_ADC_Int_Enable | ( | IP_ADC_001_T * | pADC,
|  | uint8_t | channel,
|  | FunctionalState | NewState
| ) |  |

Enable/Disable interrupt for ADC channel.

Parameters

  pADC | : The base of ADC peripheral on the chip
  channel | : Channel assert the interrupt
  NewState | : New state, ENABLE or DISABLE

Returns
  Nothing

Definition at line 156 of file adc_001.c.

void IP_ADC_SetBurstMode | ( | IP_ADC_001_T * | pADC,
|  | FunctionalState | NewState
| ) |  |

Set burst mode for ADC.

Parameters

  pADC | : The base of ADC peripheral on the chip
  NewState | : ENABLE for burst mode, or DISABLE for normal mode

Returns
  Nothing

Definition at line 77 of file adc_001.c.

void IP_ADC_SetChannelNumber | ( | IP_ADC_001_T * | pADC,
|  | uint8_t | channel,
|  | FunctionalState | NewState
| ) |  |

Enable/Disable ADC channel number.

Parameters

  pADC | : The base of ADC peripheral on the chip
  channel | : Channel number
  NewState | : New state, ENABLE or DISABLE

Returns
  Nothing

Definition at line 136 of file adc_001.c.

void IP_ADC_SetStartMode | ( | IP_ADC_001_T * | pADC,
|  | uint8_t | start_mode
| ) |  |

Set start mode for ADC.

Parameters

  pADC | : The base of ADC peripheral on the chip
  start_mode | : Start mode choose one of modes in 'ADC_START_*' enumeration type definitions

Returns
  Nothing

Definition at line 148 of file adc_001.c.