APM:Libraries
Functions | Variables
dma.c File Reference
#include "dma.h"
#include "bitband.h"
#include <string.h>
#include "util.h"
#include "nvic.h"
Include dependency graph for dma.c:

Go to the source code of this file.

Functions

void dma_init (dma_stream stream)
 Initialize a DMA device. More...
 
void dma_attach_interrupt (dma_stream stream, Handler handler, uint8_t flag)
 Attach an interrupt to a DMA transfer. More...
 
void dma_detach_interrupt (dma_stream stream)
 Detach a DMA transfer interrupt handler. More...
 
void dma_init_transfer (dma_stream stream, DMA_InitType *v)
 
void dma_set_num_transfers (dma_stream stream, uint16_t num_transfers)
 
void dma_enable (dma_stream stream)
 
void dma_disable (dma_stream stream)
 
uint8_t dma_is_stream_enabled (dma_stream stream)
 Check if a DMA stream is enabled. More...
 
void dma_clear_isr_bits (dma_stream stream)
 Clear the ISR status bits for a given DMA stream. More...
 
uint8_t dma_get_isr_bits (dma_stream stream)
 Get the ISR status bits for a DMA stream. More...
 
static void dispatch_handler (dma_stream stream)
 
void DMA1_Stream0_IRQHandler (void)
 
void DMA1_Stream1_IRQHandler (void)
 
void DMA1_Stream2_IRQHandler (void)
 
void DMA1_Stream3_IRQHandler (void)
 
void DMA1_Stream4_IRQHandler (void)
 
void DMA1_Stream5_IRQHandler (void)
 
void DMA1_Stream6_IRQHandler (void)
 
void DMA1_Stream7_IRQHandler (void)
 
void DMA2_Stream0_IRQHandler (void)
 
void DMA2_Stream1_IRQHandler (void)
 
void DMA2_Stream2_IRQHandler (void)
 
void DMA2_Stream3_IRQHandler (void)
 
void DMA2_Stream4_IRQHandler (void)
 
void DMA2_Stream5_IRQHandler (void)
 
void DMA2_Stream6_IRQHandler (void)
 
void DMA2_Stream7_IRQHandler (void)
 

Variables

static Handler dma1_handlers [8] IN_CCM
 
static const dma_dev dma1
 
static const dma_dev dma2
 
static const dma_dev *const DMAS [] = { &dma1, &dma2 }
 

Function Documentation

◆ dispatch_handler()

static void dispatch_handler ( dma_stream  stream)
static

Definition at line 321 of file dma.c.

Referenced by DMA1_Stream0_IRQHandler(), DMA1_Stream1_IRQHandler(), DMA1_Stream2_IRQHandler(), DMA1_Stream3_IRQHandler(), DMA1_Stream4_IRQHandler(), DMA1_Stream5_IRQHandler(), DMA1_Stream6_IRQHandler(), DMA1_Stream7_IRQHandler(), DMA2_Stream0_IRQHandler(), DMA2_Stream1_IRQHandler(), DMA2_Stream2_IRQHandler(), DMA2_Stream3_IRQHandler(), DMA2_Stream4_IRQHandler(), DMA2_Stream5_IRQHandler(), DMA2_Stream6_IRQHandler(), and DMA2_Stream7_IRQHandler().

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

◆ DMA1_Stream0_IRQHandler()

void DMA1_Stream0_IRQHandler ( void  )

Definition at line 339 of file dma.c.

Here is the call graph for this function:

◆ DMA1_Stream1_IRQHandler()

void DMA1_Stream1_IRQHandler ( void  )

Definition at line 343 of file dma.c.

Here is the call graph for this function:

◆ DMA1_Stream2_IRQHandler()

void DMA1_Stream2_IRQHandler ( void  )

Definition at line 347 of file dma.c.

Here is the call graph for this function:

◆ DMA1_Stream3_IRQHandler()

void DMA1_Stream3_IRQHandler ( void  )

Definition at line 351 of file dma.c.

Here is the call graph for this function:

◆ DMA1_Stream4_IRQHandler()

void DMA1_Stream4_IRQHandler ( void  )

Definition at line 355 of file dma.c.

Here is the call graph for this function:

◆ DMA1_Stream5_IRQHandler()

void DMA1_Stream5_IRQHandler ( void  )

Definition at line 359 of file dma.c.

Here is the call graph for this function:

◆ DMA1_Stream6_IRQHandler()

void DMA1_Stream6_IRQHandler ( void  )

Definition at line 363 of file dma.c.

Here is the call graph for this function:

◆ DMA1_Stream7_IRQHandler()

void DMA1_Stream7_IRQHandler ( void  )

Definition at line 367 of file dma.c.

Here is the call graph for this function:

◆ DMA2_Stream0_IRQHandler()

void DMA2_Stream0_IRQHandler ( void  )

Definition at line 371 of file dma.c.

Here is the call graph for this function:

◆ DMA2_Stream1_IRQHandler()

void DMA2_Stream1_IRQHandler ( void  )

Definition at line 375 of file dma.c.

Here is the call graph for this function:

◆ DMA2_Stream2_IRQHandler()

void DMA2_Stream2_IRQHandler ( void  )

Definition at line 379 of file dma.c.

Here is the call graph for this function:

◆ DMA2_Stream3_IRQHandler()

void DMA2_Stream3_IRQHandler ( void  )

Definition at line 383 of file dma.c.

Here is the call graph for this function:

◆ DMA2_Stream4_IRQHandler()

void DMA2_Stream4_IRQHandler ( void  )

Definition at line 387 of file dma.c.

Here is the call graph for this function:

◆ DMA2_Stream5_IRQHandler()

void DMA2_Stream5_IRQHandler ( void  )

Definition at line 391 of file dma.c.

Here is the call graph for this function:

◆ DMA2_Stream6_IRQHandler()

void DMA2_Stream6_IRQHandler ( void  )

Definition at line 395 of file dma.c.

Here is the call graph for this function:

◆ DMA2_Stream7_IRQHandler()

void DMA2_Stream7_IRQHandler ( void  )

Definition at line 399 of file dma.c.

Here is the call graph for this function:

◆ dma_attach_interrupt()

void dma_attach_interrupt ( dma_stream  stream,
Handler  handler,
uint8_t  flag 
)

Attach an interrupt to a DMA transfer.

Interrupts are enabled using appropriate mode flags in dma_setup_transfer().

Parameters
devDMA device
streamStream to attach handler to
handlerInterrupt handler to call when channel interrupt fires.
See also
dma_setup_transfer()
dma_detach_interrupt()

Definition at line 108 of file dma.c.

Referenced by F4Light::SPIDevice::setup_dma_transfer().

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

◆ dma_clear_isr_bits()

void dma_clear_isr_bits ( dma_stream  stream)

Clear the ISR status bits for a given DMA stream.

Parameters
devDMA device
streamStream whose ISR bits to clear.

Definition at line 237 of file dma.c.

Referenced by F4Light::SPIDevice::disable_dma(), dispatch_handler(), and F4Light::SPIDevice::setup_dma_transfer().

Here is the caller graph for this function:

◆ dma_detach_interrupt()

void dma_detach_interrupt ( dma_stream  stream)

Detach a DMA transfer interrupt handler.

After calling this function, the given channel's interrupts will be disabled.

Parameters
devDMA device
streamStream whose handler to detach Clears interrupt enable bits in the channel's CCR register.
See also
dma_attach_interrupt()

Definition at line 132 of file dma.c.

Referenced by F4Light::SPIDevice::disable_dma().

Here is the caller graph for this function:

◆ dma_disable()

void dma_disable ( dma_stream  stream)

Definition at line 219 of file dma.c.

Referenced by F4Light::SPIDevice::disable_dma().

Here is the caller graph for this function:

◆ dma_enable()

void dma_enable ( dma_stream  stream)

Definition at line 213 of file dma.c.

Referenced by F4Light::SPIDevice::setup_dma_transfer().

Here is the caller graph for this function:

◆ dma_get_isr_bits()

uint8_t dma_get_isr_bits ( dma_stream  stream)

Get the ISR status bits for a DMA stream.

The bits are returned right-aligned, in the following order: transfer error flag, half-transfer flag, transfer complete flag, global interrupt flag.

Parameters
devDMA device
streamStream whose ISR bits to return.

Definition at line 272 of file dma.c.

◆ dma_init()

void dma_init ( dma_stream  stream)

Initialize a DMA device.

Parameters
devDevice to initialize.

Definition at line 85 of file dma.c.

Referenced by F4Light::SPIDevice::setup_dma_transfer().

Here is the caller graph for this function:

◆ dma_init_transfer()

void dma_init_transfer ( dma_stream  stream,
DMA_InitType v 
)

Definition at line 144 of file dma.c.

Referenced by F4Light::SPIDevice::setup_dma_transfer().

Here is the caller graph for this function:

◆ dma_is_stream_enabled()

uint8_t dma_is_stream_enabled ( dma_stream  stream)

Check if a DMA stream is enabled.

Parameters
devDMA device
streamStream whose enabled bit to check.

Definition at line 230 of file dma.c.

Referenced by F4Light::SPIDevice::get_dma_ready().

Here is the caller graph for this function:

◆ dma_set_num_transfers()

void dma_set_num_transfers ( dma_stream  stream,
uint16_t  num_transfers 
)

Definition at line 206 of file dma.c.

Variable Documentation

◆ dma1

const dma_dev dma1
static
Initial value:
= {
.regs = (dma_reg_map *)DMA1_BASE,
.clk_id = RCC_AHB1Periph_DMA1,
.irq_lines = { DMA1_Stream0_IRQn, DMA1_Stream1_IRQn, DMA1_Stream2_IRQn, DMA1_Stream3_IRQn, DMA1_Stream4_IRQn, DMA1_Stream5_IRQn, DMA1_Stream6_IRQn, DMA1_Stream7_IRQn},
.handlers = dma1_handlers
}
DMA register map type.
Definition: dma.h:83

Definition at line 52 of file dma.c.

◆ dma2

const dma_dev dma2
static
Initial value:
= {
.regs = (dma_reg_map *)DMA2_BASE,
.clk_id = RCC_AHB1Periph_DMA2,
.irq_lines = { DMA2_Stream0_IRQn, DMA2_Stream1_IRQn, DMA2_Stream2_IRQn, DMA2_Stream3_IRQn, DMA2_Stream4_IRQn, DMA2_Stream5_IRQn, DMA2_Stream6_IRQn, DMA2_Stream7_IRQn},
.handlers = dma2_handlers
}
DMA register map type.
Definition: dma.h:83

Definition at line 64 of file dma.c.

◆ DMAS

const dma_dev* const DMAS[] = { &dma1, &dma2 }
static

DMA2 device

Definition at line 74 of file dma.c.

◆ IN_CCM

Handler dma2_handlers [8] IN_CCM
static

Direct Memory Access peripheral support

!!! read this first!!! https://blog.frankvh.com/2012/01/13/stm32f2xx-stm32f4xx-dma-maximum-transactions/

DMA1 device

Definition at line 50 of file dma.c.