Analog-to-digital converters, read one channel at a time.
More...
Analog-to-digital converters, read one channel at a time.
A consumer takes a channel from the io-channels property of its node, as a struct pbl_adc_channel, and reads it in microvolts:
int32_t uv;
int pbl_adc_read(const struct pbl_adc_channel *channel, int32_t *microvolt)
Convert a channel once.
Reads take the device lock and may sleep: they are for threads, not interrupts.
◆ pbl_adc_state
| Data Fields |
|
struct pbl_mutex |
lock |
Device lock. |
◆ pbl_adc
| Data Fields |
|
struct pbl_device |
dev |
Device. |
|
uint8_t |
num_channels |
Number of channels. |
|
const struct pbl_adc_ops * |
ops |
Driver operations. |
|
struct pbl_adc_state * |
state |
Runtime state. |
◆ pbl_adc_channel
| Data Fields |
|
const struct pbl_adc * |
adc |
ADC. |
|
uint32_t |
id |
Channel number. |
◆ PBL_ADC_CHANNEL
| #define PBL_ADC_CHANNEL |
( |
|
_adc, |
|
|
|
_id |
|
) |
| {.adc = (_adc), .id = (_id)} |
◆ pbl_adc_read()
| int pbl_adc_read |
( |
const struct pbl_adc_channel * |
channel, |
|
|
int32_t * |
microvolt |
|
) |
| |
Convert a channel once.
- Parameters
-
| channel | Channel. |
| [out] | microvolt | Voltage at the input, in microvolts. |
- Return values
-
| 0 | Success. |
| -ENODEV | The ADC is not ready. |
| -EINVAL | No such channel. |
- Returns
- Another negative errno on a conversion error.