Functions for using analog-to-digital (ADC) conversion peripheral. More...

Modules

Types
Hardware ADC data types.
 

Functions

gos_result_t gos_adc_init (gos_gpio_t gpio, const gos_adc_config_t *config)
 Initialize GPIO's ADC function. More...
 
gos_result_t gos_adc_deinit (gos_gpio_t gpio)
 Deinitialize GPIO's ADC function. More...
 
gos_result_t gos_adc_sample (gos_gpio_t gpio, uint16_t *value_ptr, gos_adc_sample_type_t type)
 Take an ADC sample from the specified GPIO. More...
 
gos_result_t gos_adc_sample_stream (gos_gpio_t gpio, uint16_t *buffer, uint16_t sample_count)
 Take multiple ADC readings and store to given buffer. More...
 
gos_result_t gos_adc_prepare_lut (const char *filename, gos_adc_lut_t *lut_ptr)
 Add Lookup Table (LUT) to ADC. More...
 
gos_result_t gos_adc_destroy_lut (const gos_adc_lut_t lut)
 Cleanup the memory used by a Lookup Table (LUT) More...
 
gos_result_t gos_adc_sample_and_convert (gos_gpio_t gpio, gos_adc_lut_t lut, float *conv_value_ptr)
 Table ADC sample and convert to corresponding value in Lookup Table. More...
 

Detailed Description

Functions for using analog-to-digital (ADC) conversion peripheral.

Function Documentation

◆ gos_adc_deinit()

gos_result_t gos_adc_deinit ( gos_gpio_t  gpio)

Deinitialize GPIO's ADC function.

Parameters
[in]gpioThe GPIO to deinitialize ADC function
Returns
gos_result_t result of api call

◆ gos_adc_destroy_lut()

gos_result_t gos_adc_destroy_lut ( const gos_adc_lut_t  lut)

Cleanup the memory used by a Lookup Table (LUT)

Clean up a gos_adc_lut_t initialized with gos_adc_prepare_lut()

Parameters
lutLookup Table reference
Returns
gos_result_t result of api call
Examples:
peripheral/adc/main.c.

◆ gos_adc_init()

gos_result_t gos_adc_init ( gos_gpio_t  gpio,
const gos_adc_config_t config 
)

Initialize GPIO's ADC function.

See Gecko OS Command API documentation: adc_take_sample

Note
This does not support the Lookup Table (LUT) feature. Refer to gos_adc_prepare_lut() for this functionality.
Parameters
[in]gpioThe GPIO to initialize for ADC
[in]configADC configuration, see gos_adc_config_t
Returns
gos_result_t result of api call
Examples:
network/http_server_stream/main.c, and peripheral/adc/main.c.

◆ gos_adc_prepare_lut()

gos_result_t gos_adc_prepare_lut ( const char *  filename,
gos_adc_lut_t lut_ptr 
)

Add Lookup Table (LUT) to ADC.

This reads a LUT file and prepares a table to be used to convert raw ADC readings into a corresponding value.

Use gos_adc_sample_and_convert() to get a converted value. Use gos_adc_destroy_lut() to cleanup the LUT from memory.

Parameters
filenamethe filename of the LUT
lut_ptrPointer to allocated lut
Returns
gos_result_t result of api call
Examples:
peripheral/adc/main.c.

◆ gos_adc_sample()

gos_result_t gos_adc_sample ( gos_gpio_t  gpio,
uint16_t *  value_ptr,
gos_adc_sample_type_t  type 
)

Take an ADC sample from the specified GPIO.

See Gecko OS Command API documentation: adc_take_sample

Note
This does not support the Lookup Table (LUT) feature. Refer to gos_adc_sample_and_convert() for this functionality.
Parameters
[in]gpioThe GPIO to take reading
[out]value_ptrHolds ADC reading value
[in]typeThe type of ADC reading, gos_adc_sample_type_t
Returns
gos_result_t result of api call
Examples:
network/http_server_stream/main.c, and peripheral/adc/main.c.

◆ gos_adc_sample_and_convert()

gos_result_t gos_adc_sample_and_convert ( gos_gpio_t  gpio,
gos_adc_lut_t  lut,
float *  conv_value_ptr 
)

Table ADC sample and convert to corresponding value in Lookup Table.

Call gos_adc_prepare_lut() first to associate a LUT with the ADC.

Parameters
[in]gpioThe GPIO to take reading
[in]lutLookup Table reference
[out]conv_value_ptrThe converted ADC sample
Returns
gos_result_t result of api call
Examples:
peripheral/adc/main.c.

◆ gos_adc_sample_stream()

gos_result_t gos_adc_sample_stream ( gos_gpio_t  gpio,
uint16_t *  buffer,
uint16_t  sample_count 
)

Take multiple ADC readings and store to given buffer.

Note
gos_adc_init() MUST be called first.
Parameters
[in]gpioThe GPIO to take reading
[out]bufferBuffer to hold sample_count raw 16-bit ADC readings
[in]sample_countNumber of ADC samples to take
Returns
gos_result_t result of api call