| 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 | Enumerations | Functions
CHIP: LPC13xx A/D conversion driver
LPC13xx chip specific drivers

## Detailed Description

## Data Structures
struct | ADC_Clock_Setup_T
| Clock setup structure for ADC controller passed to the initialize function. More...

## Enumerations
enum | CHIP_ADC_CHANNEL_T { ADC_CH0 = 0, ADC_CH1, ADC_CH2, ADC_CH3, ADC_CH4, ADC_CH5, ADC_CH6, ADC_CH7, ADC_CH0 = 0, ADC_CH1, ADC_CH2, ADC_CH3, ADC_CH4, ADC_CH5, ADC_CH6, ADC_CH7, ADC_CH0 = 0, ADC_CH1, ADC_CH2, ADC_CH3, ADC_CH4, ADC_CH5, ADC_CH6, ADC_CH7, ADC_CH0 = 0, ADC_CH1, ADC_CH2, ADC_CH3, ADC_CH4, ADC_CH5, ADC_CH6, ADC_CH7 }
enum | CHIP_ADC_RESOLUTION_T { ADC_10BITS = 0, ADC_9BITS, ADC_8BITS, ADC_7BITS, ADC_6BITS, ADC_5BITS, ADC_4BITS, ADC_3BITS, ADC_12BITS = 0, ADC_10BITS = 1, ADC_10BITS = 0, ADC_9BITS, ADC_8BITS, ADC_7BITS, ADC_6BITS, ADC_5BITS, ADC_4BITS, ADC_3BITS }
enum | CHIP_ADC_EDGE_CFG_T { ADC_TRIGGERMODE_RISING = 0, ADC_TRIGGERMODE_FALLING, ADC_TRIGGERMODE_RISING = 0, ADC_TRIGGERMODE_FALLING, ADC_TRIGGERMODE_RISING = 0, ADC_TRIGGERMODE_FALLING, ADC_TRIGGERMODE_RISING = 0, ADC_TRIGGERMODE_FALLING }
enum | CHIP_ADC_START_MODE_T { ADC_NO_START = 0, ADC_START_NOW, ADC_START_ON_CTOUT15, ADC_START_ON_CTOUT8, ADC_START_ON_ADCTRIG0, ADC_START_ON_ADCTRIG1, ADC_START_ON_MCOA2, ADC_NO_START = 0, ADC_START_NOW, ADC_START_ON_CTOUT15, ADC_START_ON_CTOUT8, ADC_START_ON_ADCTRIG0, ADC_START_ON_ADCTRIG1, ADC_START_ON_MCOA2, ADC_NO_START = 0, ADC_START_NOW, ADC_START_ON_CTOUT15, ADC_START_ON_CTOUT8, ADC_START_ON_ADCTRIG0, ADC_START_ON_ADCTRIG1, ADC_START_ON_MCOA2, ADC_NO_START = 0, ADC_START_NOW, ADC_START_ON_CTOUT15, ADC_START_ON_CTOUT8, ADC_START_ON_ADCTRIG0, ADC_START_ON_ADCTRIG1, ADC_START_ON_MCOA2 }

## Functions
STATIC INLINE Status | Chip_ADC_Read_Value (LPC_ADC_T *pADC, uint8_t channel, uint16_t *data)
| Read the ADC value from a channel.
STATIC INLINE FlagStatus | Chip_ADC_Read_Status (LPC_ADC_T *pADC, uint8_t channel, uint32_t StatusType)
| Read the ADC channel status.
STATIC INLINE void | Chip_ADC_Channel_Int_Cmd (LPC_ADC_T *pADC, uint8_t channel, FunctionalState NewState)
| Enable/Disable interrupt for ADC channel.
STATIC INLINE void | Chip_ADC_Global_Int_Cmd (LPC_ADC_T *pADC, FunctionalState NewState)
| Enable/Disable global interrupt for ADC channel.
void | Chip_ADC_DeInit (LPC_ADC_T *pADC)
| Shutdown ADC.
void | Chip_ADC_Init (LPC_ADC_T *pADC, ADC_Clock_Setup_T *ADCSetup)
| Initialize the ADC peripheral and the ADC setup structure to default value.
void | Chip_ADC_Set_StartMode (LPC_ADC_T *pADC, CHIP_ADC_START_MODE_T mode, CHIP_ADC_EDGE_CFG_T EdgeOption)
| Select the mode starting the AD conversion.
void | Chip_ADC_Set_SampleRate (LPC_ADC_T *pADC, ADC_Clock_Setup_T *ADCSetup, uint32_t rate)
| Set the ADC Sample rate.
void | Chip_ADC_Set_Resolution (LPC_ADC_T *pADC, ADC_Clock_Setup_T *ADCSetup, CHIP_ADC_RESOLUTION_T resolution)
| Set the ADC accuracy bits.
void | Chip_ADC_Channel_Enable_Cmd (LPC_ADC_T *pADC, CHIP_ADC_CHANNEL_T channel, FunctionalState NewState)
| Enable or disable the ADC channel on ADC peripheral.
void | Chip_ADC_Burst_Cmd (LPC_ADC_T *pADC, FunctionalState NewState)
| Enable burst mode.
Status | Chip_ADC_Read_Byte (LPC_ADC_T *pADC, CHIP_ADC_CHANNEL_T channel, uint8_t *data)
| Read the ADC value and convert it to 8bits value.

## Enumeration Type Documentation

enum CHIP_ADC_CHANNEL_T

The channels on one ADC peripheral

Enumerator:

  ADC_CH0 | ADC channel 0
  ADC_CH1 | ADC channel 1
  ADC_CH2 | ADC channel 2
  ADC_CH3 | ADC channel 3
  ADC_CH4 | ADC channel 4
  ADC_CH5 | ADC channel 5
  ADC_CH6 | ADC channel 6
  ADC_CH7 | ADC channel 7
  ADC_CH0 | ADC channel 0
  ADC_CH1 | ADC channel 1
  ADC_CH2 | ADC channel 2
  ADC_CH3 | ADC channel 3
  ADC_CH4 | ADC channel 4
  ADC_CH5 | ADC channel 5
  ADC_CH6 | ADC channel 6
  ADC_CH7 | ADC channel 7
  ADC_CH0 | ADC channel 0
  ADC_CH1 | ADC channel 1
  ADC_CH2 | ADC channel 2
  ADC_CH3 | ADC channel 3
  ADC_CH4 | ADC channel 4
  ADC_CH5 | ADC channel 5
  ADC_CH6 | ADC channel 6
  ADC_CH7 | ADC channel 7
  ADC_CH0 | ADC channel 0
  ADC_CH1 | ADC channel 1
  ADC_CH2 | ADC channel 2
  ADC_CH3 | ADC channel 3
  ADC_CH4 | ADC channel 4
  ADC_CH5 | ADC channel 5
  ADC_CH6 | ADC channel 6
  ADC_CH7 | ADC channel 7

Definition at line 45 of file adc_13xx.h.

enum CHIP_ADC_EDGE_CFG_T

Edge configuration, which controls rising or falling edge on the selected signal for the start of a conversion

Enumerator:

  ADC_TRIGGERMODE_RISING | Trigger event: rising edge
  ADC_TRIGGERMODE_FALLING | Trigger event: falling edge
  ADC_TRIGGERMODE_RISING | Trigger event: rising edge
  ADC_TRIGGERMODE_FALLING | Trigger event: falling edge
  ADC_TRIGGERMODE_RISING | Trigger event: rising edge
  ADC_TRIGGERMODE_FALLING | Trigger event: falling edge
  ADC_TRIGGERMODE_RISING | Trigger event: rising edge
  ADC_TRIGGERMODE_FALLING | Trigger event: falling edge

Definition at line 77 of file adc_13xx.h.

enum CHIP_ADC_RESOLUTION_T

Enumerator:

  ADC_10BITS | ADC 10 bits
  ADC_9BITS | ADC 9 bits
  ADC_8BITS | ADC 8 bits
  ADC_7BITS | ADC 7 bits
  ADC_6BITS | ADC 6 bits
  ADC_5BITS | ADC 5 bits
  ADC_4BITS | ADC 4 bits
  ADC_3BITS | ADC 3 bits
  ADC_12BITS | ADC 12 bits
  ADC_10BITS | ADC 10 bits
  ADC_10BITS | ADC 10 bits
  ADC_9BITS | ADC 9 bits
  ADC_8BITS | ADC 8 bits
  ADC_7BITS | ADC 7 bits
  ADC_6BITS | ADC 6 bits
  ADC_5BITS | ADC 5 bits
  ADC_4BITS | ADC 4 bits
  ADC_3BITS | ADC 3 bits

Definition at line 70 of file adc_13xx.h.

enum CHIP_ADC_START_MODE_T

Start mode, which controls the start of an A/D conversion when the BURST bit is 0.

Enumerator:

  ADC_NO_START |
  ADC_START_NOW | Start conversion now
  ADC_START_ON_CTOUT15 | Start conversion when the edge selected by bit 27 occurs on CTOUT_15
  ADC_START_ON_CTOUT8 | Start conversion when the edge selected by bit 27 occurs on CTOUT_8
  ADC_START_ON_ADCTRIG0 | Start conversion when the edge selected by bit 27 occurs on ADCTRIG0
  ADC_START_ON_ADCTRIG1 | Start conversion when the edge selected by bit 27 occurs on ADCTRIG1
  ADC_START_ON_MCOA2 | Start conversion when the edge selected by bit 27 occurs on Motocon PWM output MCOA2
  ADC_NO_START |
  ADC_START_NOW | Start conversion now
  ADC_START_ON_CTOUT15 | Start conversion when the edge selected by bit 27 occurs on CTOUT_15
  ADC_START_ON_CTOUT8 | Start conversion when the edge selected by bit 27 occurs on CTOUT_8
  ADC_START_ON_ADCTRIG0 | Start conversion when the edge selected by bit 27 occurs on ADCTRIG0
  ADC_START_ON_ADCTRIG1 | Start conversion when the edge selected by bit 27 occurs on ADCTRIG1
  ADC_START_ON_MCOA2 | Start conversion when the edge selected by bit 27 occurs on Motocon PWM output MCOA2
  ADC_NO_START |
  ADC_START_NOW | Start conversion now
  ADC_START_ON_CTOUT15 | Start conversion when the edge selected by bit 27 occurs on CTOUT_15
  ADC_START_ON_CTOUT8 | Start conversion when the edge selected by bit 27 occurs on CTOUT_8
  ADC_START_ON_ADCTRIG0 | Start conversion when the edge selected by bit 27 occurs on ADCTRIG0
  ADC_START_ON_ADCTRIG1 | Start conversion when the edge selected by bit 27 occurs on ADCTRIG1
  ADC_START_ON_MCOA2 | Start conversion when the edge selected by bit 27 occurs on Motocon PWM output MCOA2
  ADC_NO_START |
  ADC_START_NOW | Start conversion now
  ADC_START_ON_CTOUT15 | Start conversion when the edge selected by bit 27 occurs on CTOUT_15
  ADC_START_ON_CTOUT8 | Start conversion when the edge selected by bit 27 occurs on CTOUT_8
  ADC_START_ON_ADCTRIG0 | Start conversion when the edge selected by bit 27 occurs on ADCTRIG0
  ADC_START_ON_ADCTRIG1 | Start conversion when the edge selected by bit 27 occurs on ADCTRIG1
  ADC_START_ON_MCOA2 | Start conversion when the edge selected by bit 27 occurs on Motocon PWM output MCOA2

Definition at line 83 of file adc_13xx.h.

## Function Documentation

void Chip_ADC_Burst_Cmd | ( | LPC_ADC_T * | pADC,
|  | FunctionalState | NewState
| ) |  |

Enable burst mode.

Parameters

  pADC | : The base of ADC peripheral on the chip
  NewState | : New state, should be: ENABLE DISABLE

Returns
  Nothing

Definition at line 138 of file adc_11xx.c.

void Chip_ADC_Channel_Enable_Cmd | ( | LPC_ADC_T * | pADC,
|  | CHIP_ADC_CHANNEL_T | channel,
|  | FunctionalState | NewState
| ) |  |

Enable or disable the ADC channel on ADC peripheral.

Parameters

  pADC | : The base of ADC peripheral on the chip
  channel | : Channel to be enable or disable
  NewState | : New state, should be: ENABLE DISABLE

Returns
  Nothing

Definition at line 132 of file adc_11xx.c.

STATIC INLINE void Chip_ADC_Channel_Int_Cmd | ( | LPC_ADC_T * | pADC,
|  | uint8_t | channel,
|  | FunctionalState | NewState
| ) |  |

Enable/Disable interrupt for ADC channel.

Parameters

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

Returns
  SET or RESET

Definition at line 131 of file adc_13xx.h.

void Chip_ADC_DeInit | ( | LPC_ADC_T * | pADC | ) |

Shutdown ADC.

Parameters

  pADC | : The base of ADC peripheral on the chip

Returns
  Nothing

Definition at line 77 of file adc_11xx.c.

STATIC INLINE void Chip_ADC_Global_Int_Cmd | ( | LPC_ADC_T * | pADC,
|  | FunctionalState | NewState
| ) |  |

Enable/Disable global interrupt for ADC channel.

Parameters

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

Returns
  Nothing

Definition at line 142 of file adc_13xx.h.

void Chip_ADC_Init | ( | LPC_ADC_T * | pADC,
|  | ADC_Clock_Setup_T * | ADCSetup
| ) |  |

Initialize the ADC peripheral and the ADC setup structure to default value.

Parameters

  pADC | : The base of ADC peripheral on the chip
  ADCSetup | : ADC setup structure to be set

Returns
  Nothing

Note
  Default setting for ADC is 400kHz - 10bits

Definition at line 89 of file adc_11xx.c.

Status Chip_ADC_Read_Byte | ( | LPC_ADC_T * | pADC,
|  | CHIP_ADC_CHANNEL_T | channel,
|  | uint8_t * | data
| ) |  |

Read the ADC value and convert it to 8bits value.

Parameters

  pADC | : The base of ADC peripheral on the chip
  channel | : selected channel
  data | : Storage for data

Returns
  Status : ERROR or SUCCESS

Parameters

  pADC | : The base of ADC peripheral on the chip
  channel,: | selected channel
  data | : Storage for data

Returns
  Status : ERROR or SUCCESS

Definition at line 145 of file adc_11xx.c.

STATIC INLINE FlagStatus Chip_ADC_Read_Status | ( | LPC_ADC_T * | pADC,
|  | uint8_t | channel,
|  | uint32_t | StatusType
| ) |  |

Read the ADC channel status.

Parameters

  pADC | : The base of ADC peripheral on the chip
  channel | : ADC channel to read
  StatusType | : Status type of ADC_DR_*

Returns
  SET or RESET

Definition at line 119 of file adc_13xx.h.

STATIC INLINE Status Chip_ADC_Read_Value | ( | LPC_ADC_T * | pADC,
|  | uint8_t | channel,
|  | uint16_t * | data
| ) |  |

Read the ADC value from a channel.

Parameters

  pADC | : The base of ADC peripheral on the chip
  channel | : ADC channel to read
  data | : Pointer to where to put data

Returns
  SUCCESS or ERROR if no conversion is ready

Definition at line 107 of file adc_13xx.h.

void Chip_ADC_Set_Resolution | ( | LPC_ADC_T * | pADC,
|  | ADC_Clock_Setup_T * | ADCSetup,
|  | CHIP_ADC_RESOLUTION_T | resolution
| ) |  |

Set the ADC accuracy bits.

Parameters

  pADC | : The base of ADC peripheral on the chip
  ADCSetup | : ADC setup structure to be modified
  resolution | : The resolution, should be ADC_10BITS -> ADC_3BITS

Returns
  Nothing

Definition at line 125 of file adc_11xx.c.

void Chip_ADC_Set_SampleRate | ( | LPC_ADC_T * | pADC,
|  | ADC_Clock_Setup_T * | ADCSetup,
|  | uint32_t | rate
| ) |  |

Set the ADC Sample rate.

Parameters

  pADC | : The base of ADC peripheral on the chip
  ADCSetup | : ADC setup structure to be modified
  rate | : Sample rate, should be set so the clock for A/D converter is less than or equal to 4.5MHz.

Returns
  Nothing

Definition at line 115 of file adc_11xx.c.

void Chip_ADC_Set_StartMode | ( | LPC_ADC_T * | pADC,
|  | CHIP_ADC_START_MODE_T | mode,
|  | CHIP_ADC_EDGE_CFG_T | EdgeOption
| ) |  |

Select the mode starting the AD conversion.

Parameters

  pADC | : The base of ADC peripheral on the chip
  mode | : Stating mode, should be : ADC_NO_START : Must be set for Burst mode ADC_START_NOW : Start conversion now ADC_START_ON_CTOUT15 : Start conversion when the edge selected by bit 27 occurs on CTOUT_15 ADC_START_ON_CTOUT8 : Start conversion when the edge selected by bit 27 occurs on CTOUT_8 ADC_START_ON_ADCTRIG0 : Start conversion when the edge selected by bit 27 occurs on ADCTRIG0 ADC_START_ON_ADCTRIG1 : Start conversion when the edge selected by bit 27 occurs on ADCTRIG1 ADC_START_ON_MCOA2 : Start conversion when the edge selected by bit 27 occurs on Motocon PWM output MCOA2
  EdgeOption | : Stating Edge Condition, should be : ADC_TRIGGERMODE_RISING : Trigger event on rising edge ADC_TRIGGERMODE_FALLING : Trigger event on falling edge

Returns
  Nothing

Definition at line 106 of file adc_11xx.c.