ADC
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] gpio
The 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
-
lut
Lookup 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] gpio
The GPIO to initialize for ADC [in] config
ADC configuration, see gos_adc_config_t
- Returns
- gos_result_t result of api call
- Examples:
- 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
-
filename
the filename of the LUT lut_ptr
Pointer 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] gpio
The GPIO to take reading [out] value_ptr
Holds ADC reading value [in] type
The type of ADC reading, gos_adc_sample_type_t
- Returns
- gos_result_t result of api call
- Examples:
- 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] gpio
The GPIO to take reading [in] lut
Lookup Table reference [out] conv_value_ptr
The 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] gpio
The GPIO to take reading [out] buffer
Buffer to hold sample_count raw 16-bit ADC readings [in] sample_count
Number of ADC samples to take
- Returns
- gos_result_t result of api call