ChibiOS/RT Logo ChibiOS/RT

Architecture - Reference Manual - Guides

Modules | Enumerations | Functions

ADC Driver
[HAL]

Generic ADC Driver. More...

Collaboration diagram for ADC Driver:


Description

Generic ADC Driver.

This module implements a generic ADC driver. The driver implements a state machine internally:

inline_dotgraph_16.dot

The driver supports a continuous conversion mode with circular buffer, callback functions allow to process the converted data in real time. Please refer to the documentation of the function adcStartConversion().

Modules

 ADC Low Level Driver
 

ADC Driver low level driver template.


Enumerations

enum  adcstate_t {
  ADC_UNINIT = 0, ADC_STOP = 1, ADC_READY = 2, ADC_RUNNING = 3,
  ADC_COMPLETE = 4
}
 

Driver state machine possible states.

More...

Functions

void adcInit (void)
 ADC Driver initialization.
void adcObjectInit (ADCDriver *adcp)
 Initializes the standard part of a ADCDriver structure.
void adcStart (ADCDriver *adcp, const ADCConfig *config)
 Configures and activates the ADC peripheral.
void adcStop (ADCDriver *adcp)
 Deactivates the ADC peripheral.
bool_t adcStartConversion (ADCDriver *adcp, const ADCConversionGroup *grpp, adcsample_t *samples, size_t depth, adccallback_t callback)
 Starts an ADC conversion.
void adcStopConversion (ADCDriver *adcp)
 Stops an ongoing conversion.
msg_t adcWaitConversion (ADCDriver *adcp, systime_t timeout)
 Waits for completion.

Enumeration Type Documentation

enum adcstate_t

Driver state machine possible states.

Enumerator:
ADC_UNINIT 

Not initialized.

ADC_STOP 

Stopped.

ADC_READY 

Ready.

ADC_RUNNING 

Conversion running.

ADC_COMPLETE 

Conversion complete.

Definition at line 63 of file adc.h.


Function Documentation

void adcInit ( void   ) 

ADC Driver initialization.

Definition at line 59 of file adc.c.

References adc_lld_init().

Referenced by halInit().

Here is the call graph for this function:

void adcObjectInit ( ADCDriver adcp  ) 

Initializes the standard part of a ADCDriver structure.

Parameters:
[in] adcp pointer to the ADCDriver object

Definition at line 69 of file adc.c.

References ADCDriver::ad_callback, ADCDriver::ad_config, ADCDriver::ad_depth, ADCDriver::ad_grpp, ADCDriver::ad_samples, ADCDriver::ad_sem, ADCDriver::ad_state, and chSemInit().

Here is the call graph for this function:

void adcStart ( ADCDriver adcp,
const ADCConfig config 
)

Configures and activates the ADC peripheral.

Parameters:
[in] adcp pointer to the ADCDriver object
[in] config pointer to the ADCConfig object

Definition at line 86 of file adc.c.

References ADCDriver::ad_config, ADCDriver::ad_state, adc_lld_start(), ADC_READY, ADC_STOP, chDbgAssert, chDbgCheck, chSysLock, and chSysUnlock.

Here is the call graph for this function:

void adcStop ( ADCDriver adcp  ) 

Deactivates the ADC peripheral.

Parameters:
[in] adcp pointer to the ADCDriver object

Definition at line 105 of file adc.c.

References ADCDriver::ad_state, ADC_COMPLETE, adc_lld_stop(), ADC_READY, ADC_STOP, chDbgAssert, chDbgCheck, chSysLock, and chSysUnlock.

Here is the call graph for this function:

bool_t adcStartConversion ( ADCDriver adcp,
const ADCConversionGroup grpp,
adcsample_t samples,
size_t  depth,
adccallback_t  callback 
)

Starts an ADC conversion.

Starts a conversion operation, there are two kind of conversion modes:

  • LINEAR, in this mode the buffer is filled once and then the conversion stops automatically.
  • CIRCULAR, in this mode the conversion never stops and the buffer is filled circularly.
    During the conversion the callback function is invoked when the buffer is 50% filled and when the buffer is 100% filled, this way is possible to process the conversion stream in real time. This kind of conversion can only be stopped by explicitly invoking adcStopConversion().
Note:
The buffer is organized as a matrix of M*N elements where M is the channels number configured into the conversion group and N is the buffer depth. The samples are sequentially written into the buffer with no gaps.
Parameters:
[in] adcp pointer to the ADCDriver object
[in] grpp pointer to a ADCConversionGroup object
[out] samples pointer to the samples buffer
[in] depth buffer depth (matrix rows number). The buffer depth must be one or an even number.
[in] callback pointer to the conversion callback function, this parameter can be NULL if a callback is not required
Returns:
The operation status.
Return values:
FALSE the conversion has been started.
TRUE the driver is busy, conversion not started.

Definition at line 150 of file adc.c.

References ADCDriver::ad_callback, ADCDriver::ad_depth, ADCDriver::ad_grpp, ADCDriver::ad_samples, ADCDriver::ad_state, ADC_COMPLETE, adc_lld_start_conversion(), ADC_READY, ADC_RUNNING, chDbgAssert, chDbgCheck, chSysLock, and chSysUnlock.

Here is the call graph for this function:

void adcStopConversion ( ADCDriver adcp  ) 

Stops an ongoing conversion.

Parameters:
[in] adcp pointer to the ADCDriver object

Definition at line 185 of file adc.c.

References ADCDriver::ad_grpp, ADCDriver::ad_sem, ADCDriver::ad_state, ADC_COMPLETE, adc_lld_stop_conversion(), ADC_READY, ADC_RUNNING, chDbgAssert, chDbgCheck, chSchRescheduleS(), chSemResetI(), chSysLock, and chSysUnlock.

Here is the call graph for this function:

msg_t adcWaitConversion ( ADCDriver adcp,
systime_t  timeout 
)

Waits for completion.

If the conversion is not completed or not yet started then the invoking thread waits for a conversion completion event.

Parameters:
[in] adcp pointer to the ADCDriver object
[in] timeout the number of ticks before the operation timeouts, the following special values are allowed:

  • TIME_IMMEDIATE immediate timeout.
  • TIME_INFINITE no timeout.
Returns:
The operation result.
Return values:
RDY_OK conversion finished.
RDY_TIMEOUT conversion not finished within the specified time.

Definition at line 222 of file adc.c.

References ADCDriver::ad_sem, ADCDriver::ad_state, ADC_COMPLETE, ADC_READY, ADC_RUNNING, chDbgAssert, chSemWaitTimeoutS(), chSysLock, chSysUnlock, and RDY_TIMEOUT.

Here is the call graph for this function:


Generated on Sun Nov 28 2010 14:09:57 for ChibiOS/RT by doxygen 1.7.1