gossamer 0.0.1
a very lightweight app framework for SAMD and SAML chips
|
Functions for using the ADC peripheral. More...
Functions | |
void | adc_init (void) |
Initializes the ADC peripheral, but does not enable it. | |
void | adc_enable (void) |
Enables the ADC peripheral. | |
void | adc_set_sampling_length (uint8_t length) |
Sets the sampling length for the ADC. | |
uint16_t | adc_get_analog_value (uint8_t pin) |
Gets the analog value on the given ADC pin. | |
uint16_t | adc_get_analog_value_for_channel (uint8_t channel) |
Gets the analog value on the given ADC channel. | |
void | adc_disable (void) |
Disables the ADC peripheral. | |
Functions for using the ADC peripheral.
uint16_t adc_get_analog_value | ( | uint8_t | pin | ) |
Gets the analog value on the given ADC pin.
pin | The ADC pin you wish to read (i.e. HAL_GPIO_A0_pin() ) |
uint16_t adc_get_analog_value_for_channel | ( | uint8_t | channel | ) |
Gets the analog value on the given ADC channel.
channel | The ADC channel you wish to read (this will come from the datasheet) |
void adc_init | ( | void | ) |
Initializes the ADC peripheral, but does not enable it.
This function sets up some sensible defaults for basic use cases:
void adc_set_sampling_length | ( | uint8_t | length | ) |
Sets the sampling length for the ADC.
The sampling length sets the number of ADC clock cycles for which the ADC will sample the input, less 1 (so 0 represents 1 clock cycle). The default is 0, which is a good choice for inputs with impedance up to 28 kOhm. Each additional clock cycle of sampling time adds about 32 kOhm to the maximum input impedance.