adc.h

Low-level ADC peripheral driver interface definitions.

ADC_UNDEF

Default ADC undefined value.

1
(UINT_MAX)
ADC_LINE( x)

Default ADC line access macro.

1
(x)
enum adc_res_t
ADC_RES_7BIT =             (0 << 4)
ADC resolution: 7 bit.
ADC_RES_9BIT =             (1 << 4)
ADC resolution: 9 bit.
ADC_RES_11BIT
ADC resolution: 11 bit.
ADC_RES_6BIT =             (0xa00)
not supported by hardware
ADC_RES_8BIT =             (0xb00)
not supported by hardware
ADC_RES_10BIT =             (2 << 4)
ADC resolution: 10 bit.
ADC_RES_12BIT =             (3 << 4)
ADC resolution: 12 bit.
ADC_RES_14BIT =             (0xc00)
not supported by hardware
ADC_RES_16BIT =             (0xd00)
not supported by hardware
unsigned int adc_t

Define default ADC type identifier.

int adc_init(adc.h::adc_t line)

Initialize the given ADC line.

The ADC line is initialized in synchronous, blocking mode.

Parameters

line:line to initialize

Return values

  • 0 on success
  • -1 on invalid ADC line
int adc_sample(adc.h::adc_t line, cc2538/include/periph_cpu.h::adc_res_t res)

Sample a value from the given ADC line.

This function blocks until the conversion has finished. Please note, that if more than one line share the same ADC device, and if these lines are sampled at the same time (e.g. from different threads), the one called secondly waits for the first to finish before its conversion starts.

Parameters

line:line to sample
res:resolution to use for conversion

Return values

  • the sampled value on success
  • -1 if resolution is not applicable