PER Firmware
Loading...
Searching...
No Matches
adc.h
Go to the documentation of this file.
1
7#ifndef PHAL_G4_ADC_H
8#define PHAL_G4_ADC_H
9
10#include <stdbool.h>
11#include <stddef.h>
12#include <stdint.h>
13
14#include "stm32g474xx.h"
15
17
19static constexpr uint8_t PHAL_ADC_MAX_CHANNEL_COUNT = 16U;
20
22static constexpr uint8_t PHAL_ADC_MAX_CHANNEL_NUMBER = 18U;
23
30typedef struct {
31 uint8_t channel;
33
44typedef struct {
45 ADC_TypeDef *instance;
49
56typedef struct {
59 volatile bool busy;
60 volatile bool transfer_error;
62
88
109bool PHAL_ADC_readDMA(PHAL_ADC_Handle_t *handle, uint16_t *buffer, uint16_t length);
110
128bool PHAL_ADC_readBlocking(PHAL_ADC_Handle_t *handle, uint16_t *buffer, uint16_t length, uint32_t timeout);
129
139bool PHAL_ADC_stop(PHAL_ADC_Handle_t *handle);
140
146bool PHAL_ADC_busy(const PHAL_ADC_Handle_t *handle);
147
159
160#endif // PHAL_G4_ADC_H
static ethernet_config_t config
Definition ethernet.c:22
bool PHAL_ADC_readBlocking(PHAL_ADC_Handle_t *handle, uint16_t *buffer, uint16_t length, uint32_t timeout)
Synchronous one-buffer conversion using the DMA engine.
Definition adc.c:155
bool PHAL_ADC_stop(PHAL_ADC_Handle_t *handle)
Abort any transfer in flight and leave the ADC idle.
Definition adc.c:197
bool PHAL_ADC_readDMA(PHAL_ADC_Handle_t *handle, uint16_t *buffer, uint16_t length)
Start an asynchronous circular-DMA conversion into buffer
Definition adc.c:133
static constexpr uint8_t PHAL_ADC_MAX_CHANNEL_COUNT
Maximum number of channels one ADC conversion sequence can hold.
Definition adc.h:19
void PHAL_ADC_conversionCompleteCallback(PHAL_ADC_Handle_t *handle)
Weak callback fired once per completed DMA buffer.
Definition adc.c:258
static constexpr uint8_t PHAL_ADC_MAX_CHANNEL_NUMBER
Highest ADC channel number (IN18 on the G474)
Definition adc.h:22
bool PHAL_ADC_init(PHAL_ADC_Handle_t *handle, const PHAL_ADC_Config_t *config)
Configure an ADC instance and its DMA channel.
Definition adc.c:94
bool PHAL_ADC_busy(const PHAL_ADC_Handle_t *handle)
Check whether a transfer is currently in flight.
Definition adc.c:209
G4 DMA Peripheral public API implementation.
One entry in the conversion sequence.
Definition adc.h:30
uint8_t channel
Definition adc.h:31
Static configuration for one ADC instance.
Definition adc.h:44
ADC_TypeDef * instance
Definition adc.h:45
size_t channel_count
Definition adc.h:47
const PHAL_ADC_ChannelConfig_t * channels
Definition adc.h:46
Runtime handle for one ADC instance.
Definition adc.h:56
PHAL_DMA_Handle_t dma
Definition adc.h:58
volatile bool busy
Definition adc.h:59
volatile bool transfer_error
Definition adc.h:60
const PHAL_ADC_Config_t * config
Definition adc.h:57
A configured DMA transfer: fixed wiring + chosen parameters.
Definition dma.h:77