EVE 1.0
Collaboration diagram for nRF52 ADC driver:

Data Structures

struct  adc_state_t
 
struct  adc_streamer_state_t
 
struct  adc_mux_config_t
 
struct  adc_analog_config_t
 
struct  adc_digital_config_t
 
struct  adc_channel_t
 
struct  adc_streamer_t
 
struct  adc_schedule_t
 

Typedefs

typedef void(* adc_callback_t) (enum adc_cb_parameter_t AdcCbParameter)
 
typedef void(* adc_streamer_callback_t) (const struct adc_streamer_t *Adc, uint8_t SampleBufIndex)
 

Enumerations

Functions called from application programs

void Adc0Init (const struct adc_schedule_t *AdcSchedule)
 Name: Adc0Init
Initializes pointers used by ADC scheduler. Called from main program level. More...
 
bool Adc0ChannelConfig (const struct adc_channel_t *Adc, int Index, const struct adc_analog_config_t *Config)
 Name: Adc0ChannelConfig
Configures an analog channel in scan mode. More...
 
bool Adc0ChannelStart (const struct adc_channel_t *Adc, uint32_t TimeRef)
 Name: Adc0ChannelStart
Starts one ADC channel scheduler based on input parameters. More...
 
void Adc0ManualScheduler (const struct adc_channel_t *Adc)
 Name: Adc0ManualScheduler
Called by application for manual data scheduling. More...
 
void Adc0ChannelDisable (const struct adc_channel_t *Adc)
 Name: Adc0ChannelDisable
Disables one ADC channel scheduler based on input parameters. When all channels are disabled, the scheduler is stopped. More...
 
void Adc0ChannelDisableAll (void)
 Name: Adc0ChannelDisableAll
Disables all ADC channel schedulers and stops the scheduler.
 
uint16_t Adc0GetMuxValue (const struct adc_channel_t *Adc, uint8_t MuxChannel)
 Name: Adc0GetMuxValue
Starts ADC for selected ADC channel and mux input. More...
 
static uint16_t Adc0GetValue (const struct adc_channel_t *Adc)
 Name: Adc0GetValue
Starts ADC for selected ADC channel. More...
 
uint16_t Adc0GetLastMuxValue (const struct adc_channel_t *Adc, uint8_t MuxChannel)
 Name: Adc0GetLastMuxValue Returns last converted ADC value for selected ADC channel and mux input. More...
 
static uint16_t Adc0GetLastValue (const struct adc_channel_t *Adc)
 Name: Adc0GetLastValue Returns last converted ADC value for selected ADC channel. More...
 
uint32_t Adc0GetIntegratedMuxValue (const struct adc_channel_t *Adc, uint8_t MuxChannel, uint16_t *Count)
 Name: Adc0GetIntegratedMuxValue Returns integrated ADC value for selected ADC channel and mux input. More...
 
static uint32_t Adc0GetIntegratedValue (const struct adc_channel_t *Adc, uint16_t *Count)
 Name: Adc0GetIntegratedValue Returns integrated ADC value for selected ADC channel. More...
 
uint16_t Adc0GetMeanMuxValue (const struct adc_channel_t *Adc, uint8_t MuxChannel)
 Name: Adc0GetMeanMuxValue Returns mean ADC value for selected ADC channel and mux input. More...
 
static uint16_t Adc0GetMeanValue (const struct adc_channel_t *Adc)
 Name: Adc0GetMeanValue Returns mean ADC value for selected ADC channel. More...
 
bool Adc0StreamerStart (const struct adc_streamer_t *Adc)
 Name: Adc0StreamerStart
Starts continous sampling and streaming of data. More...
 
void Adc0StreamerDisable (const struct adc_streamer_t *Adc)
 Name: Adc0StreamerDisable
Stops continous sampling and streaming of data. More...
 

Detailed Description

This ADC driver can be used for ADC0.

All ADC channels must be initialized before the ADC driver may be used. An ADC channel can be configured to have an analog mux (1-64 mux inputs). If an ADC channel has an analog multiplexer, the MUX control lines must be controlled by the same IO port with consecutive port pins. For each configured ADC input, individually voltage reference etc. can be set. Individual buffers must be allocated.

It is possible to just start a single AD convertion. It is also possible that each configured ADC input can be started with its own scanning scheduler. Scanning interval is is set with resolution 1/1.024 ms and is based on the mwork scheduler. If multiple configured ADC channels should have the same starting time in the scheduler even though they are started sequentially, they can be started based on a common read time reference. If the Interval parameter is set to zero/0, the application may call the Adc0ManualScheduler() function and do the scheduler timing itself. This manual scheduler will use the same Buffer and IntegratedValue as the automatic mwork scheduler.

If the configured ADC input has mux, the allocated buffer will be shared linearly for all the mux inputs. While AD convertion is in progress, or while the scheduler is doing AD convertions, the clock is locked and energy mode EM1 is minimum required.

Typedef Documentation

typedef void(* adc_callback_t) (enum adc_cb_parameter_t AdcCbParameter)

adc_callback_t Prototype ADC driver callback function.

Definition at line 120 of file adc0.h.

typedef void(* adc_streamer_callback_t) (const struct adc_streamer_t *Adc, uint8_t SampleBufIndex)

adc_streamer_callback_t Prototype ADC driver callback function.

Definition at line 126 of file adc0.h.

Enumeration Type Documentation

adc_cb_parameter_t enum holds parameter used by the ADC driver callback function.

Definition at line 110 of file adc0.h.

Function Documentation

void Adc0Init ( const struct adc_schedule_t AdcSchedule)

Name: Adc0Init
Initializes pointers used by ADC scheduler. Called from main program level.

Parameters
AdcSchedulePointer to ADC scheduler table in application layer.
bool Adc0ChannelConfig ( const struct adc_channel_t Adc,
int  Index,
const struct adc_analog_config_t Config 
)

Name: Adc0ChannelConfig
Configures an analog channel in scan mode.

Parameters
AdcConfiguration structure for ADC input to be used
IndexScan index. 0 for the main channel, > 0 enables scan and correspondes to the particular scan slot.
ConfigAnalog channel configuration
bool Adc0ChannelStart ( const struct adc_channel_t Adc,
uint32_t  TimeRef 
)

Name: Adc0ChannelStart
Starts one ADC channel scheduler based on input parameters.

Parameters
AdcConfiguration structure for ADC input to be used
TimeRefTime reference tick got from clock_time() function
Returns
true if the ADC input was successfully started, otherwise false
void Adc0ManualScheduler ( const struct adc_channel_t Adc)

Name: Adc0ManualScheduler
Called by application for manual data scheduling.

Parameters
AdcConfiguration structure for ADC input to be used
void Adc0ChannelDisable ( const struct adc_channel_t Adc)

Name: Adc0ChannelDisable
Disables one ADC channel scheduler based on input parameters. When all channels are disabled, the scheduler is stopped.

Parameters
AdcConfiguration structure for ADC input to be used
uint16_t Adc0GetMuxValue ( const struct adc_channel_t Adc,
uint8_t  MuxChannel 
)

Name: Adc0GetMuxValue
Starts ADC for selected ADC channel and mux input.

Parameters
AdcConfiguration structure for ADC input to be used
MuxChannel
Returns
Converted ADC value for selected channel and mux input

Referenced by Adc0GetValue().

static uint16_t Adc0GetValue ( const struct adc_channel_t Adc)
inlinestatic

Name: Adc0GetValue
Starts ADC for selected ADC channel.

Parameters
AdcConfiguration structure for ADC input to be used
Returns
Converted ADC value for selected channel

Definition at line 300 of file adc0.h.

References Adc0GetLastMuxValue(), and Adc0GetMuxValue().

uint16_t Adc0GetLastMuxValue ( const struct adc_channel_t Adc,
uint8_t  MuxChannel 
)

Name: Adc0GetLastMuxValue Returns last converted ADC value for selected ADC channel and mux input.

Parameters
AdcConfiguration structure for ADC input to be used
MuxChannel
Returns
Last converted ADC value for selected ADC channel and mux input

Referenced by Adc0GetLastValue(), and Adc0GetValue().

static uint16_t Adc0GetLastValue ( const struct adc_channel_t Adc)
inlinestatic

Name: Adc0GetLastValue Returns last converted ADC value for selected ADC channel.

Parameters
AdcConfiguration structure for ADC input to be used
Returns
Last converted ADC value for selected ADC channel

Definition at line 324 of file adc0.h.

References Adc0GetIntegratedMuxValue(), and Adc0GetLastMuxValue().

uint32_t Adc0GetIntegratedMuxValue ( const struct adc_channel_t Adc,
uint8_t  MuxChannel,
uint16_t *  Count 
)

Name: Adc0GetIntegratedMuxValue Returns integrated ADC value for selected ADC channel and mux input.

Parameters
AdcConfiguration structure for ADC input to be used
MuxChannel
CountNumber of samples in the integrated value is returned in Count
Returns
Integrated ADC value for selected channel and mux input

Referenced by Adc0GetIntegratedValue(), and Adc0GetLastValue().

static uint32_t Adc0GetIntegratedValue ( const struct adc_channel_t Adc,
uint16_t *  Count 
)
inlinestatic

Name: Adc0GetIntegratedValue Returns integrated ADC value for selected ADC channel.

Parameters
AdcConfiguration structure for ADC input to be used
CountNumber of samples in the integrated value is returned in Count
Returns
Integrated ADC value for selected channel

Definition at line 350 of file adc0.h.

References Adc0GetIntegratedMuxValue(), and Adc0GetMeanMuxValue().

uint16_t Adc0GetMeanMuxValue ( const struct adc_channel_t Adc,
uint8_t  MuxChannel 
)

Name: Adc0GetMeanMuxValue Returns mean ADC value for selected ADC channel and mux input.

Parameters
AdcConfiguration structure for ADC input to be used
MuxChannel
Returns
Mean ADC value for selected channel and mux input

Referenced by Adc0GetIntegratedValue(), and Adc0GetMeanValue().

static uint16_t Adc0GetMeanValue ( const struct adc_channel_t Adc)
inlinestatic

Name: Adc0GetMeanValue Returns mean ADC value for selected ADC channel.

Parameters
AdcConfiguration structure for ADC input to be used
Returns
Mean ADC value for selected channel

Definition at line 374 of file adc0.h.

References Adc0GetMeanMuxValue(), Adc0StreamerDisable(), and Adc0StreamerStart().

bool Adc0StreamerStart ( const struct adc_streamer_t Adc)

Name: Adc0StreamerStart
Starts continous sampling and streaming of data.

Parameters
AdcConfiguration structure for the streamer
Returns
true if the streamer was started, false otherwise

Referenced by Adc0GetMeanValue().

void Adc0StreamerDisable ( const struct adc_streamer_t Adc)

Name: Adc0StreamerDisable
Stops continous sampling and streaming of data.

Parameters
AdcConfiguration structure for the streamer

Referenced by Adc0GetMeanValue().