Firmware SDK
twr_dma

Driver for DMA. More...

Data Structures

struct  twr_dma_channel_config_t
 DMA channel configuration. More...
 

Enumerations

enum  twr_dma_channel_t {
  TWR_DMA_CHANNEL_1 = 0 ,
  TWR_DMA_CHANNEL_2 = 1 ,
  TWR_DMA_CHANNEL_3 = 2 ,
  TWR_DMA_CHANNEL_4 = 3 ,
  TWR_DMA_CHANNEL_5 = 4 ,
  TWR_DMA_CHANNEL_6 = 5 ,
  TWR_DMA_CHANNEL_7 = 6
}
 DMA channels. More...
 
enum  twr_dma_request_t {
  TWR_DMA_REQUEST_0 = 0 ,
  TWR_DMA_REQUEST_1 = 1 ,
  TWR_DMA_REQUEST_2 = 2 ,
  TWR_DMA_REQUEST_3 = 3 ,
  TWR_DMA_REQUEST_4 = 4 ,
  TWR_DMA_REQUEST_5 = 5 ,
  TWR_DMA_REQUEST_6 = 6 ,
  TWR_DMA_REQUEST_7 = 7 ,
  TWR_DMA_REQUEST_8 = 8 ,
  TWR_DMA_REQUEST_9 = 9 ,
  TWR_DMA_REQUEST_10 = 10 ,
  TWR_DMA_REQUEST_11 = 11 ,
  TWR_DMA_REQUEST_12 = 12 ,
  TWR_DMA_REQUEST_13 = 13 ,
  TWR_DMA_REQUEST_14 = 14 ,
  TWR_DMA_REQUEST_15 = 15
}
 DMA requests. More...
 
enum  twr_dma_direction_t {
  TWR_DMA_DIRECTION_TO_PERIPHERAL = 0 ,
  TWR_DMA_DIRECTION_TO_RAM = 1
}
 DMA channel directions. More...
 
enum  twr_dma_size_t {
  TWR_DMA_SIZE_1 = 0 ,
  TWR_DMA_SIZE_2 = 1 ,
  TWR_DMA_SIZE_4 = 2
}
 DMA channel data size. More...
 
enum  twr_dma_mode_t {
  TWR_DMA_MODE_STANDARD = 0 ,
  TWR_DMA_MODE_CIRCULAR = 1
}
 DMA channel mode. More...
 
enum  twr_dma_event_t {
  TWR_DMA_EVENT_ERROR = 0 ,
  TWR_DMA_EVENT_HALF_DONE = 1 ,
  TWR_DMA_EVENT_DONE = 2
}
 DMA channel event. More...
 
enum  twr_dma_priority_t {
  TWR_DMA_PRIORITY_LOW = 0 ,
  TWR_DMA_PRIORITY_MEDIUM = 1 ,
  TWR_DMA_PRIORITY_HIGH = 2 ,
  TWR_DMA_PRIORITY_VERY_HIGH = 3
}
 DMA channel priority. More...
 

Functions

void twr_dma_init (void)
 Initialize DMA.
 
void twr_dma_channel_config (twr_dma_channel_t channel, twr_dma_channel_config_t *config)
 Configure DMA channel. More...
 
void twr_dma_set_event_handler (twr_dma_channel_t channel, void(*event_handler)(twr_dma_channel_t, twr_dma_event_t, void *), void *event_param)
 Set callback function. More...
 
void twr_dma_channel_run (twr_dma_channel_t channel)
 Start DMA channel. More...
 
void twr_dma_channel_stop (twr_dma_channel_t channel)
 Stop DMA channel. More...
 
size_t twr_dma_channel_get_length (twr_dma_channel_t channel)
 

Detailed Description

Driver for DMA.

Enumeration Type Documentation

◆ twr_dma_channel_t

DMA channels.

Enumerator
TWR_DMA_CHANNEL_1 

DMA channel 1.

TWR_DMA_CHANNEL_2 

DMA channel 2.

TWR_DMA_CHANNEL_3 

DMA channel 3.

TWR_DMA_CHANNEL_4 

DMA channel 4.

TWR_DMA_CHANNEL_5 

DMA channel 5, used for SPI.

TWR_DMA_CHANNEL_6 

DMA channel 6.

TWR_DMA_CHANNEL_7 

DMA channel 7.

Definition at line 12 of file twr_dma.h.

◆ twr_dma_direction_t

DMA channel directions.

Enumerator
TWR_DMA_DIRECTION_TO_PERIPHERAL 

DMA channel direction from RAM to peripheral.

TWR_DMA_DIRECTION_TO_RAM 

DMA channel direction from peripheral to RAM.

Definition at line 93 of file twr_dma.h.

◆ twr_dma_event_t

DMA channel event.

Enumerator
TWR_DMA_EVENT_ERROR 

DMA channel event error.

TWR_DMA_EVENT_HALF_DONE 

DMA channel event half done.

TWR_DMA_EVENT_DONE 

DMA channel event done.

Definition at line 132 of file twr_dma.h.

◆ twr_dma_mode_t

DMA channel mode.

Enumerator
TWR_DMA_MODE_STANDARD 

DMA channel mode standard.

TWR_DMA_MODE_CIRCULAR 

DMA channel mode circular.

Definition at line 120 of file twr_dma.h.

◆ twr_dma_priority_t

DMA channel priority.

Enumerator
TWR_DMA_PRIORITY_LOW 

DMA channel priority is low.

TWR_DMA_PRIORITY_MEDIUM 

DMA channel priority is medium.

TWR_DMA_PRIORITY_HIGH 

DMA channel priority is high.

TWR_DMA_PRIORITY_VERY_HIGH 

DMA channel priority is very high.

Definition at line 147 of file twr_dma.h.

◆ twr_dma_request_t

DMA requests.

Enumerator
TWR_DMA_REQUEST_0 

DMA request 0.

TWR_DMA_REQUEST_1 

DMA request 1.

TWR_DMA_REQUEST_2 

DMA request 2.

TWR_DMA_REQUEST_3 

DMA request 3.

TWR_DMA_REQUEST_4 

DMA request 4.

TWR_DMA_REQUEST_5 

DMA request 5.

TWR_DMA_REQUEST_6 

DMA request 6.

TWR_DMA_REQUEST_7 

DMA request 7.

TWR_DMA_REQUEST_8 

DMA request 8.

TWR_DMA_REQUEST_9 

DMA request 9.

TWR_DMA_REQUEST_10 

DMA request 10.

TWR_DMA_REQUEST_11 

DMA request 11.

TWR_DMA_REQUEST_12 

DMA request 12.

TWR_DMA_REQUEST_13 

DMA request 13.

TWR_DMA_REQUEST_14 

DMA request 14.

TWR_DMA_REQUEST_15 

DMA request 15.

Definition at line 39 of file twr_dma.h.

◆ twr_dma_size_t

DMA channel data size.

Enumerator
TWR_DMA_SIZE_1 

DMA channel data size 1B.

TWR_DMA_SIZE_2 

DMA channel data size 2B.

TWR_DMA_SIZE_4 

DMA channel data size 4B.

Definition at line 105 of file twr_dma.h.

Function Documentation

◆ twr_dma_channel_config()

void twr_dma_channel_config ( twr_dma_channel_t  channel,
twr_dma_channel_config_t config 
)

Configure DMA channel.

Parameters
[in]channelDMA channel
[in]configPointer to DMA channel configuration

Definition at line 95 of file twr_dma.c.

Referenced by twr_dac_async_run(), twr_spi_async_transfer(), and twr_uart_async_read_start().

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

◆ twr_dma_channel_run()

void twr_dma_channel_run ( twr_dma_channel_t  channel)

Start DMA channel.

Parameters
[in]channelDMA channel

Definition at line 179 of file twr_dma.c.

Referenced by twr_dac_async_run(), twr_spi_async_transfer(), and twr_uart_async_read_start().

Here is the caller graph for this function:

◆ twr_dma_channel_stop()

void twr_dma_channel_stop ( twr_dma_channel_t  channel)

Stop DMA channel.

Parameters
[in]channelDMA channel

Definition at line 184 of file twr_dma.c.

Referenced by twr_dac_async_stop(), and twr_uart_async_read_cancel().

Here is the caller graph for this function:

◆ twr_dma_set_event_handler()

void twr_dma_set_event_handler ( twr_dma_channel_t  channel,
void(*)(twr_dma_channel_t, twr_dma_event_t, void *)  event_handler,
void *  event_param 
)

Set callback function.

Parameters
[in]channelDMA channel
[in]event_handlerFunction address
[in]event_paramOptional event parameter (can be NULL)

Definition at line 173 of file twr_dma.c.

Referenced by twr_dac_async_run(), and twr_spi_init().

Here is the caller graph for this function: