Skip to content

Class AdcHAL

ClassList > AdcHAL

Handles the ADC for the spin board. More...

  • #include <AdcHAL.h>

Public Functions

Type Name
void configureDiscontinuousMode (uint8_t adc_number, uint32_t dicontinuous_count)
Set the discontinuous count for an ADC. By default, ADCs are not in discontinuous mode.
void configureTriggerSource (uint8_t adc_number, adc_ev_src_t trigger_source)
Change the trigger source of an ADC. By default, triggger source for ADC 1/2 is on HRTIM1, and ADC 3/4 is software-triggered.
void disableChannel (uint8_t adc_number, uint8_t channel)
Removes a channel from the list of channels that are acquired by an ADC.
void enableChannel (uint8_t adc_number, uint8_t channel)
Add a channel to the list of channels to be acquired for an ADC. The order in which channels are acquired is determined by the order in which they are enabled.
void enableDma (uint8_t adc_number, bool use_dma)
ADC DMA mode configuration. Enables DMA and circular mode on an ADC.
uint32_t getEnabledChannelsCount (uint8_t adc_number)
Returns the number of enabled channels for an ADC.
void startAllAdcs ()
Start all configured ADCs.
void stopAllAdcs ()
Stop all configured ADCs.
void triggerSoftwareConversion (uint8_t adc_number, uint8_t number_of_acquisitions)
Triggers a conversion on an ADC which is configured as software triggered.

Detailed Description

Note:

Use this element to call functions linked to the ADC for the SPIN board

Public Functions Documentation

function configureDiscontinuousMode

Set the discontinuous count for an ADC. By default, ADCs are not in discontinuous mode.

void AdcHAL::configureDiscontinuousMode (
    uint8_t adc_number,
    uint32_t dicontinuous_count
) 

Applied configuration will only be set when ADC is started. If ADC is already started, it must be stopped then started again.

Parameters:

  • adc_number Number of the ADC to configure.
  • discontinuous_count Number of channels to acquire on each trigger event. 0 to disable discontinuous mode (default).

function configureTriggerSource

Change the trigger source of an ADC. By default, triggger source for ADC 1/2 is on HRTIM1, and ADC 3/4 is software-triggered.

void AdcHAL::configureTriggerSource (
    uint8_t adc_number,
    adc_ev_src_t trigger_source
) 

Applied configuration will only be set when ADC is started. If ADC is already started, it must be stopped then started again.

Parameters:

  • adc_number Number of the ADC to configure
  • trigger_source Source of the trigger

function disableChannel

Removes a channel from the list of channels that are acquired by an ADC.

void AdcHAL::disableChannel (
    uint8_t adc_number,
    uint8_t channel
) 

Note:

If a channel has been enabled multiple times, then only the first occurence in the list will be removed.

Applied configuration will only be set when ADC is started. If ADC is already started, it must be stopped then started again.

Parameters:

  • adc_number Number of the ADC to configure.
  • channel Number of the channel to to no longer be acquired.

function enableChannel

Add a channel to the list of channels to be acquired for an ADC. The order in which channels are acquired is determined by the order in which they are enabled.

void AdcHAL::enableChannel (
    uint8_t adc_number,
    uint8_t channel
) 

Applied configuration will only be set when ADC is started. If ADC is already started, it must be stopped then started again.

Parameters:

  • adc_number Number of the ADC to configure.
  • channel Number of the channel to to be acquired.

function enableDma

ADC DMA mode configuration. Enables DMA and circular mode on an ADC.

void AdcHAL::enableDma (
    uint8_t adc_number,
    bool use_dma
) 

Applied configuration will only be set when ADC is started. If ADC is already started, it must be stopped then started again.

Parameters:

  • adc_num Number of the ADC on which to enable DMA.
  • use_dma Set to true to use DMA for this ADC, false to not use it (default).

function getEnabledChannelsCount

Returns the number of enabled channels for an ADC.

uint32_t AdcHAL::getEnabledChannelsCount (
    uint8_t adc_number
) 

Parameters:

  • adc_number Number of the ADC to fetch.

Returns:

Number of enabled channels on the given ADC.


function startAllAdcs

void AdcHAL::startAllAdcs () 

function stopAllAdcs

void AdcHAL::stopAllAdcs () 

function triggerSoftwareConversion

Triggers a conversion on an ADC which is configured as software triggered.

void AdcHAL::triggerSoftwareConversion (
    uint8_t adc_number,
    uint8_t number_of_acquisitions
) 

Note:

Software trigger is default for all ADCs unless configured differently by the user or another module.

Parameters:

  • adc_number Number of the ADC to fetch.
  • number_of_acquisitions Number of channels to acquire.


The documentation for this class was generated from the following file docs/core/zephyr/modules/owntech_spin_api/zephyr/src/AdcHAL.h