PER Firmware
Loading...
Searching...
No Matches
dma_priv.h
Go to the documentation of this file.
1
8#ifndef PHAL_G4_DMA_PRIV_H
9#define PHAL_G4_DMA_PRIV_H
10
12
13
14// Every DMA1/DMA2 channel register block is this many bytes apart
15// (RM0440 11: CCR, CNDTR, CPAR, CMAR, plus one reserved word = 20 bytes)
16static constexpr uint32_t PHAL_DMA_PRIV_DMA_CHANNEL_MEM_STRIDE = 0x14U;
17
19void PHAL_DMA_priv_enableClock(const DMA_TypeDef *periph);
20
22DMA_Channel_TypeDef *PHAL_DMA_priv_getChannel(const DMA_TypeDef *periph, uint8_t channel_idx);
23
24// Get the NVIC IRQn for (periph, channel_idx). channel_idx must be 1-8
25IRQn_Type PHAL_DMA_priv_getIRQn(DMA_TypeDef *periph, uint8_t channel_idx);
26
28void PHAL_DMA_priv_disableChannel(DMA_Channel_TypeDef *channel);
29
31void PHAL_DMA_priv_enableChannel(DMA_Channel_TypeDef *channel);
32
34bool PHAL_DMA_priv_isChannelEnabled(const DMA_Channel_TypeDef *channel);
35
37void PHAL_DMA_priv_clearFlags(DMA_TypeDef *periph, uint8_t channel_idx);
38
40void PHAL_DMA_priv_configChannel(DMA_Channel_TypeDef *channel,
41 const PHAL_DMA_Wiring_t *wiring,
42 const PHAL_DMA_Params_t *params);
43
46
48void PHAL_DMA_priv_setPeriphAddress(DMA_Channel_TypeDef *channel, uint32_t address);
49
51void PHAL_DMA_priv_setMemAddress(DMA_Channel_TypeDef *channel, uint32_t address);
52
54void PHAL_DMA_priv_setLength(DMA_Channel_TypeDef *channel, uint16_t length);
55
57uint16_t PHAL_DMA_priv_getRemainingLength(DMA_Channel_TypeDef *channel);
58
60bool PHAL_DMA_priv_readCompleteFlag(const DMA_TypeDef *periph, uint8_t channel_idx);
61
63bool PHAL_DMA_priv_readErrorFlag(const DMA_TypeDef *periph, uint8_t channel_idx);
64
65#endif // PHAL_G4_DMA_PRIV_H
uint16_t PHAL_DMA_priv_getRemainingLength(DMA_Channel_TypeDef *channel)
Read how many elements are still outstanding (CNDTR)
Definition dma_priv.c:143
void PHAL_DMA_priv_setMemAddress(DMA_Channel_TypeDef *channel, uint32_t address)
Write the memory-side address (CMAR)
Definition dma_priv.c:133
DMA_Channel_TypeDef * PHAL_DMA_priv_getChannel(const DMA_TypeDef *periph, uint8_t channel_idx)
Look up the channel instance for (periph, channel_idx). channel_idx must be 1-8.
Definition dma_priv.c:25
void PHAL_DMA_priv_setPeriphAddress(DMA_Channel_TypeDef *channel, uint32_t address)
Write the peripheral-side address (CPAR)
Definition dma_priv.c:128
bool PHAL_DMA_priv_isChannelEnabled(const DMA_Channel_TypeDef *channel)
True if the channel is currently enabled.
Definition dma_priv.c:56
void PHAL_DMA_priv_configChannel(DMA_Channel_TypeDef *channel, const PHAL_DMA_Wiring_t *wiring, const PHAL_DMA_Params_t *params)
Configure CCR (data sizes, priority, increment modes, mode, ISR enables) from wiring+params.
Definition dma_priv.c:95
bool PHAL_DMA_priv_readErrorFlag(const DMA_TypeDef *periph, uint8_t channel_idx)
True if the transfer-error flag is currently set for (periph, channel_idx)
Definition dma_priv.c:78
void PHAL_DMA_priv_disableChannel(DMA_Channel_TypeDef *channel)
Disable a channel and block until hardware confirms it is off.
Definition dma_priv.c:37
IRQn_Type PHAL_DMA_priv_getIRQn(DMA_TypeDef *periph, uint8_t channel_idx)
Definition dma_priv.c:32
void PHAL_DMA_priv_enableClock(const DMA_TypeDef *periph)
Enable DMAMUX1's clock plus the given DMA peripheral's clock.
Definition dma_priv.c:10
void PHAL_DMA_priv_configMux(const PHAL_DMA_Wiring_t *wiring)
Route wiring->mux_request to (periph, channel_idx)'s DMAMUX channel.
Definition dma_priv.c:115
static constexpr uint32_t PHAL_DMA_PRIV_DMA_CHANNEL_MEM_STRIDE
Definition dma_priv.h:16
void PHAL_DMA_priv_setLength(DMA_Channel_TypeDef *channel, uint16_t length)
Write the transfer length (CNDTR)
Definition dma_priv.c:138
bool PHAL_DMA_priv_readCompleteFlag(const DMA_TypeDef *periph, uint8_t channel_idx)
True if the transfer-complete flag is currently set for (periph, channel_idx)
Definition dma_priv.c:71
void PHAL_DMA_priv_enableChannel(DMA_Channel_TypeDef *channel)
Enable a channel, starting its transfer.
Definition dma_priv.c:49
void PHAL_DMA_priv_clearFlags(DMA_TypeDef *periph, uint8_t channel_idx)
Clear every latched status flag (global/complete/half/error) for one channel.
Definition dma_priv.c:60
G4 DMA Peripheral public API implementation.
Per-transfer parameters (user can configure)
Definition dma.h:35
Fixed hardware wiring for one peripheral + direction's DMA use.
Definition dma_wiring.h:64