Classes | Macros | Typedefs | Enumerations | Functions
CHIP: LPC11xx A/D conversion driver

Classes

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

Macros

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

Typedefs

typedef enum CHIP_ADC_CHANNEL ADC_CHANNEL_T
 
typedef enum CHIP_ADC_EDGE_CFG ADC_EDGE_CFG_T
 
typedef enum CHIP_ADC_RESOLUTION ADC_RESOLUTION_T
 
typedef enum CHIP_ADC_START_MODE ADC_START_MODE_T
 
typedef enum IP_ADC_STATUS ADC_STATUS_T
 ADC status register used for IP drivers. More...
 

Enumerations

enum  CHIP_ADC_CHANNEL {
  ADC_CH0 = 0, ADC_CH1, ADC_CH2, ADC_CH3,
  ADC_CH4, ADC_CH5, ADC_CH6, ADC_CH7
}
 
enum  CHIP_ADC_EDGE_CFG { ADC_TRIGGERMODE_RISING = 0, ADC_TRIGGERMODE_FALLING }
 
enum  CHIP_ADC_RESOLUTION {
  ADC_10BITS = 0, ADC_9BITS, ADC_8BITS, ADC_7BITS,
  ADC_6BITS, ADC_5BITS, ADC_4BITS, ADC_3BITS
}
 
enum  CHIP_ADC_START_MODE {
  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
}
 
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 Chip_ADC_DeInit (LPC_ADC_T *pADC)
 Shutdown ADC. More...
 
void Chip_ADC_EnableChannel (LPC_ADC_T *pADC, ADC_CHANNEL_T channel, FunctionalState NewState)
 Enable or disable the ADC channel on ADC peripheral. More...
 
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. More...
 
void Chip_ADC_Int_SetChannelCmd (LPC_ADC_T *pADC, uint8_t channel, FunctionalState NewState)
 Enable/Disable interrupt for ADC channel. More...
 
STATIC INLINE void Chip_ADC_Int_SetGlobalCmd (LPC_ADC_T *pADC, FunctionalState NewState)
 Enable/Disable global interrupt for ADC channel. More...
 
Status Chip_ADC_ReadByte (LPC_ADC_T *pADC, ADC_CHANNEL_T channel, uint8_t *data)
 Read the ADC value and convert it to 8bits value. More...
 
FlagStatus Chip_ADC_ReadStatus (LPC_ADC_T *pADC, uint8_t channel, uint32_t StatusType)
 Read the ADC channel status. More...
 
Status Chip_ADC_ReadValue (LPC_ADC_T *pADC, uint8_t channel, uint16_t *data)
 Read the ADC value from a channel. More...
 
void Chip_ADC_SetBurstCmd (LPC_ADC_T *pADC, FunctionalState NewState)
 Enable burst mode. More...
 
void Chip_ADC_SetResolution (LPC_ADC_T *pADC, ADC_CLOCK_SETUP_T *ADCSetup, ADC_RESOLUTION_T resolution)
 Set the ADC accuracy bits. More...
 
void Chip_ADC_SetSampleRate (LPC_ADC_T *pADC, ADC_CLOCK_SETUP_T *ADCSetup, uint32_t rate)
 Set the ADC Sample rate. More...
 
void Chip_ADC_SetStartMode (LPC_ADC_T *pADC, ADC_START_MODE_T mode, ADC_EDGE_CFG_T EdgeOption)
 Select the mode starting the AD conversion. More...
 

Detailed Description

This ADC driver is for LPC11xx variants except for LPC1125.

Macro Definition Documentation

◆ ADC_CR_BITACC

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

Number of ADC accuracy bits

Definition at line 65 of file adc_11xx.h.

◆ ADC_CR_BURST

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

Repeated conversions A/D enable bit

Definition at line 71 of file adc_11xx.h.

◆ ADC_CR_CH_SEL

#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 69 of file adc_11xx.h.

◆ ADC_CR_CLKDIV

#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 70 of file adc_11xx.h.

◆ ADC_CR_EDGE

#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_11xx.h.

◆ ADC_CR_PDN

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

ADC convert is operational

Definition at line 72 of file adc_11xx.h.

◆ ADC_CR_START_ADCTRIG0

#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_11xx.h.

◆ ADC_CR_START_ADCTRIG1

#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_11xx.h.

◆ ADC_CR_START_CTOUT15

#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_11xx.h.

◆ ADC_CR_START_CTOUT8

#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_11xx.h.

◆ ADC_CR_START_MASK

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

ADC start mask bits

Definition at line 73 of file adc_11xx.h.

◆ ADC_CR_START_MCOA2

#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_11xx.h.

◆ ADC_CR_START_MODE_SEL

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

Select Start Mode

Definition at line 74 of file adc_11xx.h.

◆ ADC_CR_START_NOW

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

Start conversion now

Definition at line 75 of file adc_11xx.h.

◆ ADC_DR_DONE

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

Mask for reading the ADC done status

Definition at line 67 of file adc_11xx.h.

◆ ADC_DR_OVERRUN

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

Mask for reading the ADC overrun status

Definition at line 68 of file adc_11xx.h.

◆ ADC_DR_RESULT

#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 64 of file adc_11xx.h.

◆ ADC_MAX_SAMPLE_RATE

#define ADC_MAX_SAMPLE_RATE   400000

Definition at line 47 of file adc_11xx.h.

◆ ADC_SAMPLE_RATE_CONFIG_MASK

#define ADC_SAMPLE_RATE_CONFIG_MASK   (ADC_CR_CLKDIV(0xFF) | ADC_CR_BITACC(0x07))

Definition at line 82 of file adc_11xx.h.

Typedef Documentation

◆ ADC_CHANNEL_T

The channels on one ADC peripheral

◆ ADC_EDGE_CFG_T

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

◆ ADC_RESOLUTION_T

The number of bits of accuracy of the result in the LS bits of ADDR

◆ ADC_START_MODE_T

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

◆ ADC_STATUS_T

ADC status register used for IP drivers.

Enumeration Type Documentation

◆ CHIP_ADC_CHANNEL

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

Definition at line 94 of file adc_11xx.h.

◆ CHIP_ADC_EDGE_CFG

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

Definition at line 118 of file adc_11xx.h.

◆ CHIP_ADC_RESOLUTION

The number of bits of accuracy of the result in the LS bits of ADDR

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

Definition at line 106 of file adc_11xx.h.

◆ CHIP_ADC_START_MODE

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

Definition at line 124 of file adc_11xx.h.

◆ IP_ADC_STATUS

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 87 of file adc_11xx.h.

Function Documentation

◆ Chip_ADC_DeInit()

void Chip_ADC_DeInit ( LPC_ADC_T pADC)

Shutdown ADC.

Parameters
pADC: The base of ADC peripheral on the chip
Returns
Nothing

◆ Chip_ADC_EnableChannel()

void Chip_ADC_EnableChannel ( LPC_ADC_T pADC,
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

◆ Chip_ADC_Init()

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

◆ Chip_ADC_Int_SetChannelCmd()

void Chip_ADC_Int_SetChannelCmd ( 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

◆ Chip_ADC_Int_SetGlobalCmd()

STATIC INLINE void Chip_ADC_Int_SetGlobalCmd ( 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 199 of file adc_11xx.h.

◆ Chip_ADC_ReadByte()

Status Chip_ADC_ReadByte ( LPC_ADC_T pADC,
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
channelselected channel
data: Storage for data
Returns
Status : ERROR or SUCCESS

◆ Chip_ADC_ReadStatus()

FlagStatus Chip_ADC_ReadStatus ( 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

◆ Chip_ADC_ReadValue()

Status Chip_ADC_ReadValue ( 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

◆ Chip_ADC_SetBurstCmd()

void Chip_ADC_SetBurstCmd ( 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

◆ Chip_ADC_SetResolution()

void Chip_ADC_SetResolution ( LPC_ADC_T pADC,
ADC_CLOCK_SETUP_T ADCSetup,
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

◆ Chip_ADC_SetSampleRate()

void Chip_ADC_SetSampleRate ( 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

◆ Chip_ADC_SetStartMode()

void Chip_ADC_SetStartMode ( LPC_ADC_T pADC,
ADC_START_MODE_T  mode,
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


uavcan_communicator
Author(s):
autogenerated on Fri Dec 13 2024 03:10:04