SmartSnippets DA1459x SDK
Files | Data Structures | Macros | Typedefs | Enumerations | Functions
SDADC Adapter

Sigma Delta Analog-Digital Converter adapter. More...

Files

file  ad_sdadc.h
 SDADC adapter API.
 

Data Structures

struct  ad_sdadc_io_conf
 SDADC I/O configuration. More...
 
struct  ad_sdadc_controller_conf
 SDADC controller configuration. More...
 

Macros

#define HW_SDADC   ((void *)SDADC_BASE)
 SDADC Id.
 

Typedefs

typedef struct ad_sdadc_io_conf ad_sdadc_io_conf_t
 SDADC I/O configuration.
 
typedef hw_sdadc_config_t ad_sdadc_driver_conf_t
 SDADC driver configuration. More...
 
typedef struct ad_sdadc_controller_conf ad_sdadc_controller_conf_t
 SDADC controller configuration. More...
 
typedef void * ad_sdadc_handle_t
 SDADC Handle returned by ad_sdadc_open()
 
typedef void(* ad_sdadc_user_cb) (void *user_data, uint32_t conversions)
 Asynchronous callback function. More...
 

Enumerations

enum  AD_SDADC_ERROR
 Error Codes. More...
 

Functions

void ad_sdadc_init (void)
 Initialize SDADC adapter and some required variables. More...
 
ad_sdadc_handle_t ad_sdadc_open (const ad_sdadc_controller_conf_t *conf)
 Open SDADC controller. More...
 
int ad_sdadc_reconfig (const ad_sdadc_handle_t handle, const ad_sdadc_driver_conf_t *drv)
 Reconfigure SDADC controller. More...
 
int ad_sdadc_close (const ad_sdadc_handle_t handle, bool forced)
 Close SDADC controller. More...
 
int ad_sdadc_io_config (const HW_SDADC_ID id, const ad_sdadc_io_conf_t *io, AD_IO_CONF_STATE state)
 Initialize controller pins to on / off io configuration. More...
 
int ad_sdadc_read_async (const ad_sdadc_handle_t handle, uint32_t nof_conv, uint16_t *outbuf, ad_sdadc_user_cb read_async_cb, void *user_data)
 Read asynchronously nof_conv conversions from the selected source. More...
 
int ad_sdadc_read (const ad_sdadc_handle_t handle, uint32_t nof_conv, uint16_t *outbuf)
 Read synchronously nof_conv conversions from the selected source. More...
 
__STATIC_FORCEINLINE int32_t ad_sdadc_conv_to_mvolt (const ad_sdadc_controller_conf_t *conf, uint32_t raw_value)
 Convert raw value read from SDADC to voltage in mV. The same configuration which was used to obtain the adc_value is needed for the conversion. More...
 
__STATIC_FORCEINLINE void ad_sdadc_store_ext_ref_calibration_values (int16_t gain, int16_t offset)
 Store external reference voltage calibration values. More...
 

Detailed Description

Sigma Delta Analog-Digital Converter adapter.

Typedef Documentation

◆ ad_sdadc_controller_conf_t

SDADC controller configuration.

Configuration of SDADC controller

Note
There may be more than one controller configurations needed (e.g DMA)

◆ ad_sdadc_driver_conf_t

SDADC driver configuration.

Configuration of the SDADC low level driver

Note
There may be more than one driver configurations needed (e.g DMA)

◆ ad_sdadc_user_cb

typedef void(* ad_sdadc_user_cb) (void *user_data, uint32_t conversions)

Asynchronous callback function.

Parameters
[in]user_datapointer to user data
[in]conversionsnumber of remaining conversions

Enumeration Type Documentation

◆ AD_SDADC_ERROR

Error Codes.

Function Documentation

◆ ad_sdadc_close()

int ad_sdadc_close ( const ad_sdadc_handle_t  handle,
bool  forced 
)

Close SDADC controller.

This function:

  • Aborts ongoing transactions
  • De-initializes the drivers associated with the controller
  • Resets controller interface IOs (as specified in ad_xxx_open())
  • If DMA configuration has changed returns error
  • Releases the controller resources
Parameters
[in]handlehandle returned from ad_sdadc_open()
[in]forcedforce adapter closing
See also
ad_sdadc_open()
AD_SDADC_ERROR
Returns
0: success, <0: error code

◆ ad_sdadc_conv_to_mvolt()

__STATIC_FORCEINLINE int32_t ad_sdadc_conv_to_mvolt ( const ad_sdadc_controller_conf_t conf,
uint32_t  raw_value 
)

Convert raw value read from SDADC to voltage in mV. The same configuration which was used to obtain the adc_value is needed for the conversion.

Parameters
[in]confcontroller configuration
[in]raw_valuevalue returned from ad_sdadc_read()/ad_sdadc_read_async()
Returns
voltage in mV

◆ ad_sdadc_init()

void ad_sdadc_init ( void  )

Initialize SDADC adapter and some required variables.

Note
: It should ONLY be called by the system.

◆ ad_sdadc_io_config()

int ad_sdadc_io_config ( const HW_SDADC_ID  id,
const ad_sdadc_io_conf_t io,
AD_IO_CONF_STATE  state 
)

Initialize controller pins to on / off io configuration.

This function should be called for setting pins to the correct level before external devices are powered up (e.g on system init). It does not need to be called before every ad_sdadc_open() call.

Parameters
[in]idcontroller instance
[in]iocontroller io configuration
[in]stateon/off io configuration
See also
AD_SDADC_ERROR
Returns
0: success, <0: error code

◆ ad_sdadc_open()

ad_sdadc_handle_t ad_sdadc_open ( const ad_sdadc_controller_conf_t conf)

Open SDADC controller.

This function:

  • Acquires the resources needed for using the controller
  • Configures the controller interface IOs
  • Initializes the drivers associated with the controller
Parameters
[in]confcontroller configuration
Returns
>0: handle that should be used in subsequent API calls, NULL: error
Note
The function will block until it acquires all controller resources

◆ ad_sdadc_read()

int ad_sdadc_read ( const ad_sdadc_handle_t  handle,
uint32_t  nof_conv,
uint16_t *  outbuf 
)

Read synchronously nof_conv conversions from the selected source.

This function starts synchronous measurement read. The caller task will block until the resource becomes available. Upon the resource acquisition, ΣΔ start conversion(s) using the interrupt mode.

Parameters
[in]handlehandle to SDADC source
[in]nof_convnumber of conversions to be delivered. Must be non-zero
[out]outbufpointer to conversion results buffer. Output buffer contains raw values
See also
ad_sdadc_open()
ad_sdadc_close()
Returns
0 on success, negative value on error

◆ ad_sdadc_read_async()

int ad_sdadc_read_async ( const ad_sdadc_handle_t  handle,
uint32_t  nof_conv,
uint16_t *  outbuf,
ad_sdadc_user_cb  read_async_cb,
void *  user_data 
)

Read asynchronously nof_conv conversions from the selected source.

This function starts asynchronous measurement read. Non blocking read operation

Parameters
[in]handlehandle to SDADC source
[in]nof_convnumber of conversions to be delivered. Must be non-zero
[out]outbufpointer to conversion results buffer. Output buffer contains raw values
[in]read_async_cbuser callback fired after read operation completes
[in]user_datapointer to user data passed to callback
See also
ad_sdadc_open()
ad_sdadc_close()
Returns
0 on success, negative value on error

◆ ad_sdadc_reconfig()

int ad_sdadc_reconfig ( const ad_sdadc_handle_t  handle,
const ad_sdadc_driver_conf_t drv 
)

Reconfigure SDADC controller.

This function will apply a new SDADC driver configuration.

Parameters
[in]handlehandle returned from ad_sdadc_open()
[in]drvnew driver configuration
See also
ad_sdadc_open()
AD_SDADC_ERROR
Returns
0: success, <0: error code

◆ ad_sdadc_store_ext_ref_calibration_values()

__STATIC_FORCEINLINE void ad_sdadc_store_ext_ref_calibration_values ( int16_t  gain,
int16_t  offset 
)

Store external reference voltage calibration values.

Parameters
[in]gaingain correction value
[in]offsetoffset correction value
Note
In case of external VREF, this function must be called before ad_sdadc_open().