mikroSDK Reference Manual
|
ADC Driver API Reference. More...
Functions list | |
void | analog_in_configure_default (analog_in_config_t *config) |
Configure ADC configuration structure. More... | |
err_t | analog_in_open (analog_in_t *obj, analog_in_config_t *config) |
Open the ADC driver object on selected pin. More... | |
err_t | analog_in_set_resolution (analog_in_t *obj, analog_in_resolution_t resolution) |
Set ADC driver sample resolution. More... | |
err_t | analog_in_set_vref_input (analog_in_t *obj, analog_in_vref_t vref) |
Set ADC driver voltage reference source. More... | |
err_t | analog_in_set_vref_value (analog_in_t *obj, float vref_value) |
Set ADC driver voltage reference value. More... | |
err_t | analog_in_read (analog_in_t *obj, uint16_t *readDatabuf) |
Read analog value from pin. More... | |
err_t | analog_in_read_voltage (analog_in_t *obj, float *readDatabuf) |
Read analog voltage value from pin. More... | |
err_t | analog_in_close (analog_in_t *obj) |
Close ADC driver context object. More... | |
The ADC driver provides standard ADC functionality including setting the analog pin and reading the ADC value from it. It also allows configuration of ADC resolution, voltage reference source and value.
void analog_in_configure_default | ( | analog_in_config_t * | config | ) |
Configures ADC configuration structure to default initialization values. Take into consideration that this is just structure variable initial values setting. Values need to be redefined by user.
[in,out] | config | ADC driver configuration settings. See analog_in_config_t structure definition for detailed explanation. |
Default values:
Function | Default value |
---|---|
Input pin | 0xFFFFFFFF (invalid pin) |
Resolution | 12 bit |
Vref input | External reference voltage |
Vref value | -1 (invalid reference voltage value) |
Example
err_t analog_in_open | ( | analog_in_t * | obj, |
analog_in_config_t * | config | ||
) |
Opens the ADC driver object on selected pins. Allocates memory and pin for specified object.
[in,out] | obj | ADC driver object. See analog_in_t structure definition for detailed explanation. |
[in] | config | ADC driver configuration settings. See analog_in_config_t structure definition for detailed explanation. |
config
structure has been adequately populated beforehand. See analog_in_configure_default definition for detailed explanation. Example
err_t analog_in_set_resolution | ( | analog_in_t * | obj, |
analog_in_resolution_t | resolution | ||
) |
Sets ADC driver resolution to passed value if possible. If not possible, returns error. Make sure to check for return value. Take into consideration that the driver will be re-initialized on the hardware level.
[in] | obj | ADC driver context object. |
[in] | resolution | ADC driver sample resolution value. See analog_in_resolution_t for valid values. |
Example
err_t analog_in_set_vref_input | ( | analog_in_t * | obj, |
analog_in_vref_t | vref | ||
) |
Sets ADC driver voltage reference source to passed value if possible. If not possible, returns error. Make sure to check for return value. Take into consideration that the driver will be re-initialized on the hardware level.
[in] | obj | ADC driver context object. |
[in] | vref | ADC driver voltage reference source value. See analog_in_vref_t for valid values. |
Example
err_t analog_in_set_vref_value | ( | analog_in_t * | obj, |
float | vref_value | ||
) |
Sets ADC driver voltage reference value to passed value if possible. If not possible, returns error. Make sure to check for return value. Take into consideration that the driver will be re-initialized on the hardware level.
[in] | obj | ADC driver context object. |
[in] | vref_value | ADC driver voltage reference value. |
Example
err_t analog_in_read | ( | analog_in_t * | obj, |
uint16_t * | readDatabuf | ||
) |
Function perform a read on the configured analog pin.
[in] | obj | Analog input driver object. See analog_in_t structure definition for detailed explanation. |
[out] | readDatabuf | Data buffer to place read data in. |
Example
err_t analog_in_read_voltage | ( | analog_in_t * | obj, |
float * | readDatabuf | ||
) |
Function perform a read on the configured analog pin and converts it into voltage.
[in] | obj | Analog input driver object. See analog_in_t structure definition for detailed explanation. |
[out] | readDatabuf | Data buffer to place read data in. |
Example
err_t analog_in_close | ( | analog_in_t * | obj | ) |
De-allocates hardware resources for specific driver object.
[in] | obj | ADC driver object. |
Example