PER Firmware
Loading...
Searching...
No Matches
adc.h
Go to the documentation of this file.
1
9#ifndef _PHAL_ADC_H
10#define _PHAL_ADC_H
11
12#include "phal_F4/phal_F4.h"
13
14typedef enum {
18 ADC_RES_6_BIT = 0b11
20
27
28typedef enum {
31 ADC_DMA_CIRCULAR = 0b11
33
38
46
57
58typedef struct {
59 uint32_t channel; // not the GPIO channel, use the ADC channel
60 uint32_t rank; // order at which the channels will be polled, starting at 1
63
64// TODO DMA CONFIGS FOR ADC
65#define ADC1_DMA_CONT_CONFIG(mem_addr_, tx_size_, priority_) \
66 {.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}
67
76bool PHAL_initADC(ADCInitConfig_t* config, ADCChannelConfig_t channels[], uint8_t num_channels);
77
82bool PHAL_startADC(void);
87bool PHAL_stopADC(void);
88
94uint16_t PHAL_readADC(void);
95
96#endif
static ethernet_config_t config
Definition ethernet.c:22
bool PHAL_startADC(void)
Starts ADC1 conversions, requires PHAL_initADC to be called prior.
Definition adc.c:85
ADCDMAMode_t
Definition adc.h:28
@ ADC_DMA_ONE_SHOT
Definition adc.h:30
@ ADC_DMA_OFF
Definition adc.h:29
@ ADC_DMA_CIRCULAR
Definition adc.h:31
ADCResolution_t
Definition adc.h:14
@ ADC_RES_6_BIT
Definition adc.h:18
@ ADC_RES_10_BIT
Definition adc.h:16
@ ADC_RES_8_BIT
Definition adc.h:17
@ ADC_RES_12_BIT
Definition adc.h:15
ADCChannelSampleCycles_t
Definition adc.h:47
@ ADC_CHN_SMP_CYCLES_84
Definition adc.h:52
@ ADC_CHN_SMP_CYCLES_56
Definition adc.h:51
@ ADC_CHN_SMP_CYCLES_144
Definition adc.h:54
@ ADC_CHN_SMP_CYCLES_112
Definition adc.h:53
@ ADC_CHN_SMP_CYCLES_480
Definition adc.h:55
@ ADC_CHN_SMP_CYCLES_3
Definition adc.h:48
@ ADC_CHN_SMP_CYCLES_15
Definition adc.h:49
@ ADC_CHN_SMP_CYCLES_28
Definition adc.h:50
uint16_t PHAL_readADC(void)
Reads the ADC1 data register.
Definition adc.c:95
ADCDataAlign_t
Definition adc.h:34
@ ADC_DATA_ALIGN_RIGHT
Definition adc.h:35
@ ADC_DATA_ALIGN_LEFT
Definition adc.h:36
ADCClkPrescaler_t
Definition adc.h:21
@ ADC_CLK_PRESC_6
Definition adc.h:24
@ ADC_CLK_PRESC_2
Definition adc.h:22
@ ADC_CLK_PRESC_4
Definition adc.h:23
@ ADC_CLK_PRESC_8
Definition adc.h:25
bool PHAL_stopADC(void)
Stops ADC1 conversions, requires PHAL_initADC to be called prior.
Definition adc.c:90
bool PHAL_initADC(ADCInitConfig_t *config, ADCChannelConfig_t channels[], uint8_t num_channels)
Initializes ADC1, requires GPIO config prior.
Definition adc.c:11
Definition adc.h:58
uint32_t rank
Definition adc.h:60
uint32_t channel
Definition adc.h:59
ADCChannelSampleCycles_t sampling_time
Definition adc.h:61
Definition adc.h:39
ADCResolution_t resolution
Definition adc.h:41
ADCDataAlign_t data_align
Definition adc.h:42
ADCDMAMode_t dma_mode
Definition adc.h:44
ADCClkPrescaler_t clock_prescaler
Definition adc.h:40
bool cont_conv_mode
Definition adc.h:43