LPCOpen Platform
LPCOpen Platform for NXP LPC Microcontrollers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
IP: 10 or 12-bit ADC register block and driver

Data Structures

struct  IP_ADC_001_Type
 10 or 12-bit ADC register block structure More...
 

Macros

#define ADC_DR_RESULT(n)   ((((n) >> 6) & 0x3FF))
 ADC register support bitfields and mask.
 
#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_BITACC(n)   ((((n) & 0x7) << 17))
 
#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))
 

Enumerations

enum  IP_ADC_Status { 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_Type *pADC, uint32_t adcRate, uint32_t adcPerClock, uint8_t bitsAccuracy)
 Initialize for ADC.
 
void IP_ADC_DeInit (IP_ADC_001_Type *pADC)
 Shutdown ADC.
 
void IP_ADC_SetBurstMode (IP_ADC_001_Type *pADC, FunctionalState NewState)
 Set burst mode for ADC.
 
Status IP_ADC_Get_Val (IP_ADC_001_Type *pADC, uint8_t channel, uint16_t *data)
 Get the ADC value.
 
FlagStatus IP_ADC_GetStatus (IP_ADC_001_Type *pADC, uint8_t channel, uint32_t StatusType)
 Get ADC Channel status from ADC data register.
 
void IP_ADC_EdgeStartConfig (IP_ADC_001_Type *pADC, uint8_t edge_mode)
 Set the edge start condition.
 
void IP_ADC_SetChannelNumber (IP_ADC_001_Type *pADC, uint8_t channel, FunctionalState NewState)
 Enable/Disable ADC channel number.
 
void IP_ADC_SetStartMode (IP_ADC_001_Type *pADC, uint8_t start_mode)
 Set start mode for ADC.
 
void IP_ADC_Int_Enable (IP_ADC_001_Type *pADC, uint8_t channel, FunctionalState NewState)
 Enable/Disable interrupt for ADC channel.
 

Detailed Description

Macro Definition Documentation

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

Number of ADC accuracy bits

Definition at line 71 of file adc_001.h.

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

Repeated conversions A/D enable bit

Definition at line 70 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 68 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 69 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 81 of file adc_001.h.

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

ADC convert in power down mode

Definition at line 72 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 78 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 79 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 76 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 77 of file adc_001.h.

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

ADC start mask bits

Definition at line 73 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 80 of file adc_001.h.

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

Select Start Mode

Definition at line 74 of file adc_001.h.

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

Start conversion now

Definition at line 75 of file adc_001.h.

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

Mask for reading the ADC done status

Definition at line 66 of file adc_001.h.

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

Mask for reading the ADC overrun status

Definition at line 67 of file adc_001.h.

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

ADC register support bitfields and mask.

Mask for getting the ADC data read value

Definition at line 65 of file adc_001.h.

Enumeration Type Documentation

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 86 of file adc_001.h.

Function Documentation

void IP_ADC_DeInit ( IP_ADC_001_Type pADC)

Shutdown ADC.

Parameters
pADC: The base of ADC peripheral on the chip
Returns
Nothing Reset the ADC control and INTEN Register to reset values (disabled)

Definition at line 80 of file adc_001.c.

void IP_ADC_EdgeStartConfig ( IP_ADC_001_Type pADC,
uint8_t  edge_mode 
)

Set the edge start condition.

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

Definition at line 132 of file adc_001.c.

Status IP_ADC_Get_Val ( IP_ADC_001_Type 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 98 of file adc_001.c.

FlagStatus IP_ADC_GetStatus ( IP_ADC_001_Type 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 112 of file adc_001.c.

void IP_ADC_Init ( IP_ADC_001_Type pADC,
uint32_t  adcRate,
uint32_t  adcPerClock,
uint8_t  bitsAccuracy 
)

Initialize for ADC.

Parameters
pADC: The base of ADC peripheral on the chip
adcRate: Sample rate of A/D converter
adcPerClock: The APB clock
bitsAccuracy: The accuracy of LSB value, should be ADC_10BITS -> ADC_3BITS
Returns
Nothing Disable all ADC interrupts, set bit PDN, set ADC clock frequency This is not the sample rate, but the clock for the ADC machine, and is usually set to maximum. Applications may choose a lower frequency if they have high-impedance sources. This is because a lower clock frequency produces a longer sampling time.

Definition at line 72 of file adc_001.c.

void IP_ADC_Int_Enable ( IP_ADC_001_Type 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 162 of file adc_001.c.

void IP_ADC_SetBurstMode ( IP_ADC_001_Type 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 87 of file adc_001.c.

void IP_ADC_SetChannelNumber ( IP_ADC_001_Type 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 143 of file adc_001.c.

void IP_ADC_SetStartMode ( IP_ADC_001_Type 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 155 of file adc_001.c.