HAL  v0.6.1
Hardware Abstraction Layer
Loading...
Searching...
No Matches
hal_adc.h File Reference
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include "hal_gpio.h"
Include dependency graph for hal_adc.h:

Data Structures

struct  adc_channel_attr_t
 

Enumerations

enum  adc_result_t {
  ADC_RESULT_OK ,
  ADC_RESULT_INVALID ,
  ADC_RESULT_UNSUPPORTED ,
  ADC_RESULT_OVERRUN ,
  ADC_RESULT_OVERFLOW ,
  ADC_RESULT_ERR ,
  TOTAL_ADC_RESULT
}
 
enum  adc_mode_t {
  ADC_MODE_SINGLE_ENDED ,
  ADC_MODE_DIFFERENTIAL ,
  TOTAL_ADC_MODE
}
 
enum  adc_conv_egde_t {
  ADC_CONV_EDGE_FALLING ,
  ADC_CONV_EDGE_RISING ,
  TOTAL_ADC_CONV_EDGE
}
 
enum  adc_conv_int_t {
  ADC_CONV_INTERRUPT_EVERY_CONV ,
  ADC_CONV_INTERRUPT_EVERY_SEQUENCE ,
  TOTAL_ADC_CONV_INTERRUPT
}
 
enum  adc_clock_mode_t {
  ADC_CLOCK_MODE_SYNCHRONOUS ,
  ADC_CLOCK_MODE_ASYNCHRONOUS ,
  TOTAL_ADC_CLOCK_MODE
}
 
enum  adc_resolution_t {
  ADC_RESOLUTION_6_BITS ,
  ADC_RESOLUTION_8_BITS ,
  ADC_RESOLUTION_10_BITS ,
  ADC_RESOLUTION_12_BITS ,
  ADC_RESOLUTION_16_BITS ,
  ADC_RESOLUTION_24_BITS ,
  TOTAL_ADC_RESOLUTION
}
 

Functions

adc_result_t hal_adc_init (const adc_channel_attr_t attr)
 Configure ADC channel.
 
adc_result_t hal_adc_calibrate (const float vref)
 Calibrate ADC reference voltage.
 
uint32_t hal_adc_read (const gpio_pin_t pin)
 Read ADC pin value.
 
float hal_adc_read_volt (const gpio_pin_t pin)
 Read ADC pin voltage.