group::ADC

ADC Interface Spec

The ADC peripheral driver allows access to the MCU’s built-in ADC. Each peripheral is opened using a unique port number and mode settings. Once open, any channel from the ADC can be read. Closing the peripheral will disable power to the ADC. More information about accessing hardware is in the Device Interface section.

The following is an example of how to read the ADC in an OS environment:


Details

defineADC_IOC_IDENT_CHAR


defineADC_VERSION


defineI_ADC_GETVERSION


defineI_ADC_GETINFO

This requests reads the ADC attributes.

Example:

#include <dev/adc.h>
adc_attr_t attr;
int adc_fd;
...
ioctl(adc_fd, I_ADC_GETINFO, &attr);

defineI_ADC_SETATTR

This requests writes the ADC attributes.

Example:

#include <dev/adc.h>
adc_attr_t attr;
int adc_fd;
...
ioctl(adc_fd, I_ADC_SETATTR, &attr);

defineI_ADC_SETACTION


enumadc_flag_t

  • ADC_LOC_IS_GROUP Set loc value when reading ADC to read the group)
  • ADC_FLAG_SET_CONVERTER Configure the ADC
  • ADC_FLAG_IS_LEFT_JUSTIFIED Left Align data
  • ADC_FLAG_IS_RIGHT_JUSTIFIED Right align data
  • ADC_FLAG_SET_MASTER Used with MCUs that have more than one ADC that can operate in master/slave mode
  • ADC_FLAG_SET_SLAVE Used with MCUs that have more than one ADC that can operate in master/slave mode
  • ADC_FLAG_IS_TRIGGER_TMR Used to trigger the ADC read on a timer event
  • ADC_FLAG_IS_TRIGGER_EINT Used to trigger the ADC read on a external interrupt
  • ADC_FLAG_SET_CHANNELS Configure the channels withouth changing ADC settings
  • ADC_FLAG_IS_SCAN_MODE ADC will read every enabled channel when reading rather than the channel based on the location value
  • ADC_FLAG_IS_TRIGGER_EINT_EDGE_RISING
  • ADC_FLAG_IS_TRIGGER_EINT_EDGE_FALLING
  • ADC_FLAG_IS_GROUP
  • ADC_FLAG_IS_CONTINOUS_CONVERSION


date: “2019-06-27” layout: post title: struct::adc_info_t katex: true

categories: struct

Methods

Details

public u32o_flags

A bitmask for the supported features


public u32o_events

Events supported by this driver


public u32freq

The maximum frequency


public u32maximum

The maximum value returned by the ADC


public u32reference_mv

The reference voltage in millivolts


public u8resolution

The number of bits supported by the ADC


public u8bytes_per_sample

The number of bytes in each sample


public u8resd_align


public u32resd



date: “2019-06-27” layout: post title: struct::adc_pin_assignment_t katex: true

categories: struct

Methods

Details

publicmcu_pin_tchannel

Pins to use with the ADC. If more than 4 are needed, make multiple calls to I_ADC_SETATTR



date: “2019-06-27” layout: post title: struct::adc_attr_t katex: true

categories: struct

Methods

Details

public u32o_flags

The flag bitmask used with the ADC


publicadc_pin_assignment_tpin_assignment

The pins to assigned to the ADC


public u32freq

Target frequency when setting ADC


publicmcu_pin_ttrigger

Pin or Timer trigger


public u8width

Bit resolution (if variable resolution is supported)


public u8channel_count

Number of channels to convert when ADC_FLAG_IS_SCAN_MODE is set


public u16channel

Channel number when using ADC_FLAG_SET_CHANNELS with ADC_FLAG_IS_GROUP


public u32rank

Rank when using ADC_FLAG_SET_CHANNELS with ADC_FLAG_IS_GROUP


public u32sampling_time

Sampling time (in ADC clock cycles) when using ADC_FLAG_SET_CHANNELS with ADC_FLAG_IS_GROUP


public u32resd


X

Thanks for Coming!

Subscribe to news and updates