PER Firmware
Loading...
Searching...
No Matches
adc.h File Reference
#include "common/phal_F4_F7/phal_F4_F7.h"

Go to the source code of this file.

Classes

struct  ADCInitConfig_t
 
struct  ADCChannelConfig_t
 

Macros

#define ADC1_DMA_CONT_CONFIG(mem_addr_, tx_size_, priority_)
 

Enumerations

enum  ADCResolution_t { ADC_RES_12_BIT = 0b00 , ADC_RES_10_BIT = 0b01 , ADC_RES_8_BIT = 0b10 , ADC_RES_6_BIT = 0b11 }
 
enum  ADCClkPrescaler_t { ADC_CLK_PRESC_2 = 0b00 , ADC_CLK_PRESC_4 = 0b01 , ADC_CLK_PRESC_6 = 0b10 , ADC_CLK_PRESC_8 = 0b11 }
 
enum  ADCDMAMode_t { ADC_DMA_OFF = 0b00 , ADC_DMA_ONE_SHOT = 0b01 , ADC_DMA_CIRCULAR = 0b11 }
 
enum  ADCDataAlign_t { ADC_DATA_ALIGN_RIGHT = 0b0 , ADC_DATA_ALIGN_LEFT = 0b1 }
 
enum  ADCChannelSampleCycles_t {
  ADC_CHN_SMP_CYCLES_3 = 0b000 , ADC_CHN_SMP_CYCLES_15 = 0b001 , ADC_CHN_SMP_CYCLES_28 = 0b010 , ADC_CHN_SMP_CYCLES_56 = 0b011 ,
  ADC_CHN_SMP_CYCLES_84 = 0b100 , ADC_CHN_SMP_CYCLES_112 = 0b101 , ADC_CHN_SMP_CYCLES_144 = 0b110 , ADC_CHN_SMP_CYCLES_480 = 0b111
}
 

Functions

bool PHAL_initADC (ADC_TypeDef *adc, ADCInitConfig_t *config, ADCChannelConfig_t channels[], uint8_t num_channels)
 Initializes the ADC, requires GPIO config prior.
 
bool PHAL_startADC (ADC_TypeDef *adc)
 Starts the ADC conversions, requires PHAL_initADC to be called prior.
 
bool PHAL_stopADC (ADC_TypeDef *adc)
 Stops the ADC conversions, requires PHAL_initADC to be called prior.
 
uint16_t PHAL_readADC (ADC_TypeDef *adc)
 Reads the ADC data register.
 

Detailed Description

Author
Chris McGalliard - port of L4 HAL by Luke Oxley (lcoxl.nosp@m.ey@p.nosp@m.urdue.nosp@m..edu)
Version
0.1
Date
2023-09-17

Macro Definition Documentation

◆ ADC1_DMA_CONT_CONFIG

#define ADC1_DMA_CONT_CONFIG ( mem_addr_,
tx_size_,
priority_ )
Value:
{.periph_addr = (uint32_t)&(ADC1->DR), .mem_addr = mem_addr_, .tx_size = tx_size_, .increment = true, .circular = true, .dir = 0b0, .mem_inc = true, .periph_inc = false, .mem_to_mem = false, .priority = priority_, .mem_size = 0b01, .periph_size = 0b01, .tx_isr_en = false, .dma_chan_request = 0b0000, .stream_idx = 0, .periph = DMA2, .stream = DMA2_Stream0}

Function Documentation

◆ PHAL_initADC()

bool PHAL_initADC ( ADC_TypeDef * adc,
ADCInitConfig_t * config,
ADCChannelConfig_t channels[],
uint8_t num_channels )

Initializes the ADC, requires GPIO config prior.

Parameters
adcADC handle
configADC initial config settings
channelsList of channel configurations
num_channelsNumber of channels in the channel configuration list

◆ PHAL_readADC()

uint16_t PHAL_readADC ( ADC_TypeDef * adc)

Reads the ADC data register.

Parameters
adcADC handle
Returns
contents of the data register

◆ PHAL_startADC()

bool PHAL_startADC ( ADC_TypeDef * adc)

Starts the ADC conversions, requires PHAL_initADC to be called prior.

Parameters
adcADC handle

◆ PHAL_stopADC()

bool PHAL_stopADC ( ADC_TypeDef * adc)

Stops the ADC conversions, requires PHAL_initADC to be called prior.

Parameters
adcADC handle