Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
hal_stm32_dma.c File Reference

STM32 DMA subsystem driver header. More...

#include "hal_stm32_dma.h"
#include "string.h"
+ Include dependency graph for hal_stm32_dma.c:

Go to the source code of this file.

Functions

static void dma_lld_serve_interrupt (DMADriver *dmap, uint32_t flags)
 DMA ISR service routine. More...
 
void dmaObjectInit (DMADriver *dmap)
 
bool dmaStart (DMADriver *dmap, const DMAConfig *cfg)
 Configures and activates the DMA peripheral. More...
 
bool dmaReloadConf (DMADriver *dmap, const DMAConfig *cfg)
 Configures and activates the DMA peripheral. More...
 
void dmaStop (DMADriver *dmap)
 Deactivates the DMA peripheral. More...
 
bool dmaStartTransfert (DMADriver *dmap, volatile void *periphp, void *mem0p, const size_t size)
 Starts a DMA transaction. More...
 
bool dmaStartTransfertI (DMADriver *dmap, volatile void *periphp, void *mem0p, const size_t size)
 Starts a DMA transaction. More...
 
void dmaGetRegisters (DMADriver *dmap, volatile void *periphp, void *mem0p, const size_t size, DMA_Stream_TypeDef *registers)
 copy the dma register to memory. More...
 
void dmaStopTransfert (DMADriver *dmap)
 Stops an ongoing transaction. More...
 
void dmaStopTransfertI (DMADriver *dmap)
 Stops an ongoing transaction. More...
 
uint8_t dmaGetStreamIndex (DMADriver *dmap)
 
msg_t dmaTransfertTimeout (DMADriver *dmap, volatile void *periphp, void *mem0p, const size_t size, sysinterval_t timeout)
 Performs a DMA transaction. More...
 
void dmaAcquireBus (DMADriver *dmap)
 Gains exclusive access to the DMA peripheral. More...
 
void dmaReleaseBus (DMADriver *dmap)
 Releases exclusive access to the DMA peripheral. More...
 
bool dma_lld_start (DMADriver *dmap, bool allocate_stream)
 Configures and activates the DMA peripheral. More...
 
static size_t getCrossCacheBoundaryAwareSize (const void *memp, const size_t dsize)
 
void dma_lld_get_registers (DMADriver *dmap, volatile void *periphp, void *mem0p, const size_t size, DMA_Stream_TypeDef *registers)
 Copy the register of a ready stream. More...
 
bool dma_lld_start_transfert (DMADriver *dmap, volatile void *periphp, void *mem0p, const size_t size)
 Starts a DMA transaction. More...
 
void dma_lld_stop_transfert (DMADriver *dmap)
 Stops an ongoing transaction. More...
 
void dma_lld_stop (DMADriver *dmap)
 Deactivates the DMA peripheral. More...
 

Detailed Description

STM32 DMA subsystem driver header.

Author
Alexandre Bustico @maintainer Gautier Hattenberger gauti.nosp@m.er.h.nosp@m.atten.nosp@m.berg.nosp@m.er@en.nosp@m.ac.f.nosp@m.r

Definition in file hal_stm32_dma.c.

Function Documentation

◆ dma_lld_get_registers()

void dma_lld_get_registers ( DMADriver dmap,
volatile void *  periphp,
void *  mem0p,
const size_t  size,
DMA_Stream_TypeDef *  registers 
)

Copy the register of a ready stream.

Parameters
[in]dmappointer to the DMADriver object
Note
: main use is preparing link list of transactions for mdma use @notapi

Definition at line 865 of file hal_stm32_dma.c.

References DMADriver::config, DMADriver::dmamode, DMADriver::dmastream, and DMAConfig::op_mode.

Referenced by dmaGetRegisters().

+ Here is the caller graph for this function:

◆ dma_lld_serve_interrupt()

static void dma_lld_serve_interrupt ( DMADriver dmap,
uint32_t  flags 
)
static

DMA ISR service routine.

DMA DMA ISR service routine.

Parameters
[in]dmappointer to the DMADriver object
[in]flagspre-shifted content of the ISR register

Definition at line 972 of file hal_stm32_dma.c.

References _dma_isr_error_code(), _dma_isr_full_code(), _dma_isr_half_code(), DMADriver::config, DMAConfig::direction, DMA_ACTIVE, DMA_DIR_M2M, DMA_DIR_M2P, DMA_DIR_P2M, DMA_ERR_DIRECTMODE_ERROR, DMA_ERR_FIFO_EMPTY, DMA_ERR_FIFO_ERROR, DMA_ERR_FIFO_FULL, DMA_ERR_TRANSFER_ERROR, getCrossCacheBoundaryAwareSize(), DMADriver::mem0p, DMAConfig::msize, DMAConfig::psize, DMADriver::size, and DMADriver::state.

Referenced by dma_lld_start().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dma_lld_start()

bool dma_lld_start ( DMADriver dmap,
bool  allocate_stream 
)

◆ dma_lld_start_transfert()

bool dma_lld_start_transfert ( DMADriver dmap,
volatile void *  periphp,
void *  mem0p,
const size_t  size 
)

Starts a DMA transaction.

Parameters
[in]dmappointer to the DMADriver object

@notapi

Definition at line 897 of file hal_stm32_dma.c.

References DMADriver::config, DMAConfig::direction, DMA_DIR_P2M, DMADriver::dmamode, DMADriver::dmastream, getCrossCacheBoundaryAwareSize(), DMADriver::mem0p, DMAConfig::msize, DMAConfig::op_mode, and DMADriver::size.

Referenced by dmaStartTransfertI().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dma_lld_stop()

void dma_lld_stop ( DMADriver dmap)

Deactivates the DMA peripheral.

Parameters
[in]dmappointer to the DMADriver object

@notapi

Definition at line 952 of file hal_stm32_dma.c.

References DMADriver::dmastream.

Referenced by dmaStop().

+ Here is the caller graph for this function:

◆ dma_lld_stop_transfert()

void dma_lld_stop_transfert ( DMADriver dmap)

Stops an ongoing transaction.

Parameters
[in]dmappointer to the DMADriver object

@notapi

Definition at line 940 of file hal_stm32_dma.c.

References DMADriver::dmastream.

Referenced by _dma_isr_error_code(), _dma_isr_full_code(), dmaStopTransfert(), and dmaStopTransfertI().

+ Here is the caller graph for this function:

◆ dmaAcquireBus()

void dmaAcquireBus ( DMADriver dmap)

Gains exclusive access to the DMA peripheral.

This function tries to gain ownership to the DMA bus, if the bus is already being used then the invoking thread is queued.

Precondition
In order to use this function the option DMA_USE_MUTUAL_EXCLUSION must be enabled.
Parameters
[in]dmappointer to the DMADriver object

@api

Definition at line 502 of file hal_stm32_dma.c.

◆ dmaGetRegisters()

void dmaGetRegisters ( DMADriver dmap,
volatile void *  periphp,
void *  mem0p,
const size_t  size,
DMA_Stream_TypeDef *  registers 
)

copy the dma register to memory.

mainly used to preapare mdma linked list chained transferts

Parameters
[in]dmappointer to the DMADriver object
[in,out]periphppointer to a peripheral register address
[in,out]mem0ppointer to the data buffer
[in]sizebuffer size. The buffer size must be one or an even number.
[out]registerspointer to structure representing a DMA stream set of registers

@iclass

Definition at line 328 of file hal_stm32_dma.c.

References DMADriver::config, DMA_CONTINUOUS_HALF_BUFFER, dma_lld_get_registers(), DMA_READY, DMAConfig::inc_peripheral_addr, DMAConfig::msize, DMAConfig::op_mode, DMAConfig::psize, and DMADriver::state.

+ Here is the call graph for this function:

◆ dmaGetStreamIndex()

uint8_t dmaGetStreamIndex ( DMADriver dmap)

Definition at line 438 of file hal_stm32_dma.c.

References DMADriver::dmastream.

◆ dmaObjectInit()

void dmaObjectInit ( DMADriver dmap)

Definition at line 69 of file hal_stm32_dma.c.

References DMADriver::config, DMA_STOP, DMADriver::mem0p, and DMADriver::state.

Referenced by dshotStart(), initCache(), and light_ws2812_arch_init().

+ Here is the caller graph for this function:

◆ dmaReleaseBus()

void dmaReleaseBus ( DMADriver dmap)

Releases exclusive access to the DMA peripheral.

Precondition
In order to use this function the option DMA_USE_MUTUAL_EXCLUSION must be enabled.
Parameters
[in]dmappointer to the DMADriver object

@api

Definition at line 519 of file hal_stm32_dma.c.

◆ dmaReloadConf()

bool dmaReloadConf ( DMADriver dmap,
const DMAConfig cfg 
)

Configures and activates the DMA peripheral.

Parameters
[in]dmappointer to the DMADriver object
[in]configpointer to the DMAConfig object.
Returns
The operation result.
Return values
truedma driver is OK
falseincoherencies has been found in config @api

Definition at line 138 of file hal_stm32_dma.c.

References DMADriver::config, dma_lld_start(), DMA_READY, DMAConfig::op_mode, and DMADriver::state.

+ Here is the call graph for this function:

◆ dmaStart()

bool dmaStart ( DMADriver dmap,
const DMAConfig cfg 
)

Configures and activates the DMA peripheral.

Parameters
[in]dmappointer to the DMADriver object
[in]configpointer to the DMAConfig object.
Returns
The operation result.
Return values
truedma driver is OK
falseincoherencies has been found in config @api

Definition at line 105 of file hal_stm32_dma.c.

References DMADriver::config, dma_lld_start(), DMA_READY, DMA_STOP, DMAConfig::op_mode, and DMADriver::state.

Referenced by dshotStart(), initCache(), and light_ws2812_arch_init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dmaStartTransfert()

bool dmaStartTransfert ( DMADriver dmap,
volatile void *  periphp,
void *  mem0p,
const size_t  size 
)

Starts a DMA transaction.

Starts one or many asynchronous dma transaction(s) depending on continuous field

Postcondition
The callbacks associated to the DMA config will be invoked on buffer fill and error events, and timeout events in case STM32_DMA_USE_ASYNC_TIMOUT == TRUE
Note
The datas are sequentially written into the buffer with no gaps.
Parameters
[in]dmappointer to the DMADriver object
[in,out]periphppointer to a peripheral register address
[in,out]mem0ppointer to the data buffer
[in]sizebuffer size. The buffer size must be one or an even number.

@api

Definition at line 201 of file hal_stm32_dma.c.

References dmaStartTransfertI().

Referenced by dshotRpmCatchErps(), and light_ws2812_arch_init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dmaStartTransfertI()

bool dmaStartTransfertI ( DMADriver dmap,
volatile void *  periphp,
void *  mem0p,
const size_t  size 
)

Starts a DMA transaction.

Starts one or many asynchronous dma transaction(s) depending on continuous field

Postcondition
The callbacks associated to the DMA config will be invoked on buffer fill and error events, and timeout events in case STM32_DMA_USE_ASYNC_TIMOUT == TRUE
Note
The datas are sequentially written into the buffer with no gaps.
Parameters
[in]dmappointer to the DMADriver object
[in,out]periphppointer to a peripheral register address
[in,out]mem0ppointer to the data buffer
[in]sizebuffer size. The buffer size must be one or an even number.

@iclass

Definition at line 226 of file hal_stm32_dma.c.

References DMADriver::config, DMA_ACTIVE, DMA_COMPLETE, DMA_CONTINUOUS_HALF_BUFFER, DMA_ERROR, dma_lld_start_transfert(), DMA_READY, DMAConfig::inc_peripheral_addr, DMAConfig::msize, DMAConfig::op_mode, DMAConfig::psize, DMADriver::size, and DMADriver::state.

Referenced by dmaStartTransfert(), and dmaTransfertTimeout().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dmaStop()

void dmaStop ( DMADriver dmap)

Deactivates the DMA peripheral.

Parameters
[in]dmappointer to the DMADriver object

@api

Definition at line 167 of file hal_stm32_dma.c.

References DMADriver::config, dma_lld_stop(), DMA_READY, DMA_STOP, DMADriver::mem0p, and DMADriver::state.

Referenced by dshotStop().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dmaStopTransfert()

void dmaStopTransfert ( DMADriver dmap)

Stops an ongoing transaction.

This function stops the currently ongoing transaction and returns the driver in the DMA_READY state. If there was no transaction being processed then the function does nothing.

Parameters
[in]dmappointer to the DMADriver object

@api

Definition at line 393 of file hal_stm32_dma.c.

References _dma_reset_s, DMA_ACTIVE, dma_lld_stop_transfert(), DMA_READY, and DMADriver::state.

Referenced by dshotStop().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dmaStopTransfertI()

void dmaStopTransfertI ( DMADriver dmap)

Stops an ongoing transaction.

This function stops the currently ongoing transaction and returns the driver in the DMA_READY state. If there was no transaction being processed then the function does nothing.

Parameters
[in]dmappointer to the DMADriver object

@iclass

Definition at line 421 of file hal_stm32_dma.c.

References _dma_reset_i, DMA_ACTIVE, DMA_COMPLETE, dma_lld_stop_transfert(), DMA_READY, and DMADriver::state.

Referenced by dmaTransfertTimeout(), and dshotRpmCatchErps().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dmaTransfertTimeout()

msg_t dmaTransfertTimeout ( DMADriver dmap,
volatile void *  periphp,
void *  mem0p,
const size_t  size,
sysinterval_t  timeout 
)

Performs a DMA transaction.

Performs one synchronous dma transaction

Note
The datas are sequentially written into the buffer with no gaps.
Parameters
[in]dmappointer to the DMADriver object
[in,out]periphppointer to a peripheral register address
[in,out]mem0ppointer to the data buffer
[in]sizebuffer size. The buffer size must be one or an even number.
[in]timeoutfunction will exit after timeout is transaction is not done can be TIME_INFINITE (but not TIME_IMMEDIATE)
Returns
The operation result.
Return values
MSG_OKTransaction finished.
MSG_RESETThe transaction has been stopped using dmaStopTransaction() or dmaStopTransactionI(), the result buffer may contain incorrect data.
MSG_TIMEOUTThe transaction has been stopped because of hardware error or timeout limit reach

@api

Definition at line 472 of file hal_stm32_dma.c.

References DMADriver::config, DMA_ONESHOT, dmaStartTransfertI(), dmaStopTransfertI(), msg, DMAConfig::op_mode, and timeout.

Referenced by dmaTransfert().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCrossCacheBoundaryAwareSize()

static size_t getCrossCacheBoundaryAwareSize ( const void *  memp,
const size_t  dsize 
)
inlinestatic

Definition at line 838 of file hal_stm32_dma.c.

Referenced by dma_lld_serve_interrupt(), and dma_lld_start_transfert().

+ Here is the caller graph for this function: