| Kinetis SDK API Reference Manual 1.0.0-beta Freescale Semiconductor, Inc.

- Introduction
- Related Pages
- API Usage

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
Data Structures | Enumerations
DMA HAL driver
Direct Memory Access (DMA)

The section describes the programming interface of the DMA HAL driver. More...

## Data Structures
struct | dma_channel_link_config_t
| Data structure for data structure configuration. More...
union | dma_error_status_t
| Data structure to get status of the DMA channel status. More...

## Enumerations
enum | dma_status_t { kStatus_DMA_Success = 0U, kStatus_DMA_InvalidArgument = 1U, kStatus_DMA_Fail = 2U }
| DMA status. More...
enum | dma_transfer_size_t { kDmaTransfersize32bits = 0x0U, kDmaTransfersize8bits = 0x1U, kDmaTransfersize16bits = 0x2U }
| DMA transfer size type. More...
enum | dma_modulo_t { kDmaModuloDisable = 0x0U, kDmaModulo16Bytes = 0x1U, kDmaModulo32Bytes = 0x2U, kDmaModulo64Bytes = 0x3U, kDmaModulo128Bytes = 0x4U, kDmaModulo256Bytes = 0x5U, kDmaModulo512Bytes = 0x6U, kDmaModulo1KBytes = 0x7U, kDmaModulo2KBytes = 0x8U, kDmaModulo4KBytes = 0x9U, kDmaModulo8KBytes = 0xaU, kDmaModulo16KBytes = 0xbU, kDmaModulo32KBytes = 0xcU, kDmaModulo64KBytes = 0xdU, kDmaModulo128KBytes = 0xeU, kDmaModulo256KBytes = 0xfU }
| Configuration type for the DMA modulo.
enum | dma_channel_link_type_t { kDmaChannelLinkDisable = 0x0U, kDmaChannelLinkChan1AndChan2 = 0x1U, kDmaChannelLinkChan1 = 0x2U, kDmaChannelLinkChan1AfterBCR0 = 0x3 }
| DMA channel link type. More...

## DMA HAL channel configuration
static void | dma_hal_configure_source_address (uint32_t instance, uint32_t channel, uint32_t address)
| Configures the source address. More...
static void | dma_hal_configure_dest_address (uint32_t instance, uint32_t channel, uint32_t address)
| Configures the source address. More...
static void | dma_hal_configure_count (uint32_t instance, uint32_t channel, uint32_t count)
| Configures the bytes to be transferred. More...
static uint32_t | dma_hal_get_unfinished_bytes (uint32_t instance, uint32_t channel)
| Gets the left bytes not to be transferred. More...
static void | dma_hal_enable_interrupt (uint32_t instance, uint8_t channel)
| Enables the interrupt for the DMA channel after the work is done. More...
static void | dma_hal_disable_interrupt (uint32_t instance, uint8_t channel)
| Disables the interrupt for the DMA channel after the work is done. More...
static void | dma_hal_set_cycle_steal (uint32_t instance, uint8_t channel, bool isCycleSteal)
| Configure the DMA transfer mode to cycle steal or continuous modes. More...
static void | dma_hal_set_autoalign_ability (uint32_t instance, uint8_t channel, bool isEnabled)
| Configures the auto-align feature. More...
static void | dma_hal_set_async_dma_request_ability (uint32_t instance, uint8_t channel, bool isEnabled)
| Configures the a-sync DMA request feature. More...
static void | dma_hal_set_source_increment (uint32_t instance, uint32_t channel, bool isEnabled)
| Enables/Disables the source increment. More...
static void | dma_hal_set_dest_increment (uint32_t instance, uint32_t channel, bool isEnabled)
| Enables/Disables destination increment. More...
static void | dma_hal_configure_source_transfersize (uint32_t instance, uint32_t channel, dma_transfer_size_t transfersize)
| Configures the source transfer size. More...
static void | dma_hal_configure_dest_transfersize (uint32_t instance, uint32_t channel, dma_transfer_size_t transfersize)
| Configures the destination transfer size. More...
static void | dma_hal_trigger_start (uint32_t instance, uint32_t channel)
| Triggers the start. More...
static void | dma_hal_configure_source_modulo (uint32_t instance, uint32_t channel, dma_modulo_t modulo)
| Configures the modulo for source address. More...
static void | dma_hal_configure_dest_modulo (uint32_t instance, uint32_t channel, dma_modulo_t modulo)
| Configures the modulo for destination address. More...
static void | dma_hal_set_dma_request (uint32_t instance, uint32_t channel, bool isEnabled)
| Enables/Disables the DMA request. More...
static void | dma_hal_set_disable_dma_request_after_done (uint32_t instance, uint32_t channel, bool isDisabled)
| Configures the DMA request state after the work is done. More...
void | dma_hal_set_channel_link (uint32_t instance, uint8_t channel, dma_channel_link_config_t *mode)
| Configures the channel link feature. More...
static void | dma_hal_clear_status (uint32_t instance, uint8_t channel)
| Clears the status of DMA channel. More...
static dma_error_status_t | dma_hal_get_status (uint32_t instance, uint8_t channel)
| Gets the DMA controller channel status. More...

### DMA HAL Driver

# Overview

The DMA HAL driver is used to mask the hardware and provide user a comprehensible way to use dma hardware.

## Data Structure Documentation

struct dma_channel_link_config_t

### Data Fields
dma_channel_link_type_t | linkType
| Channel link type.
uint32_t | channel1
| Channel 1 configuration.
uint32_t | channel2
| Channel 2 configuration.

union dma_error_status_t

### Data Fields
struct {
uint32_t dmaBytesToBeTransffered: 24
| Bytes to be transferred.
uint32_t dmaTransDone: 1
| DMA channel transfer is done. More...
uint32_t dmaBusy: 1
| DMA is running. More...
uint32_t dmaPendingRequest: 1
| A transfer remains. More...
uint32_t _reserved1: 1
uint32_t dmaDestBusError: 1
| Bus error on destination address.
uint32_t dmaSourceBusError: 1
| Bus error on source address.
uint32_t dmaConfigError: 1
| Configuration error.
uint32_t _reserved0: 1
} | u
uint32_t | b

#### Field Documentation

uint32_t dma_error_status_t::dmaTransDone

uint32_t dma_error_status_t::dmaBusy

uint32_t dma_error_status_t::dmaPendingRequest

## Enumeration Type Documentation

enum dma_status_t

Enumerator
kStatus_DMA_InvalidArgument | Parameter is not available for the current configuration.
kStatus_DMA_Fail | Function operation failed.

enum dma_transfer_size_t

Enumerator
kDmaTransfersize32bits | 32 bits are transferred for every read/write
kDmaTransfersize8bits | 8 bits are transferred for every read/write
kDmaTransfersize16bits | 16b its are transferred for every read/write

enum dma_channel_link_type_t

Enumerator
kDmaChannelLinkDisable | No channel link.
kDmaChannelLinkChan1AndChan2 | Perform a link to channel 1 after each cycle-steal transfer followed by a link and to channel 2 after the BCR decrements to zeros.
kDmaChannelLinkChan1 | Perform a link to channel 1 after each cycle-steal transfer.
kDmaChannelLinkChan1AfterBCR0 | Perform a link to channel1 after the BCR decrements to zero.

## Function Documentation

static void dma_hal_configure_source_address | ( | uint32_t | instance,
|  | uint32_t | channel,
|  | uint32_t | address
| ) |  |
| inline static

Each SAR contains the byte address used by the DMA to read data. The SARn is typically aligned on a 0-modulo-size boundary-that is on the natural alignment of the source data. Bits 31-20 of this register must be written with one of the only four allowed values. Each of these allowed values corresponds to a valid region of the devices' memory map. The allowed values are: 0x000x_xxxx 0x1FFx_xxxx 0x200x_xxxx 0x400x_xxxx After they are written with one of the allowed values, bits 31-20 read back as the written value. After they are written with any other value, bits 31-20 read back as an indeterminate value.

This function enables the request for a specified channel.

Parameters

  instance | DMA instance.
  channel | DMA channel.
  address | memory address pointing to the source address.

static void dma_hal_configure_dest_address | ( | uint32_t | instance,
|  | uint32_t | channel,
|  | uint32_t | address
| ) |  |
| inline static

Each DAR contains the byte address used by the DMA to read data. The DARn is typically aligned on a 0-modulo-size boundary-that is on the natural alignment of the source data. Bits 31-20 of this register must be written with one of the only four allowed values. Each of these allowed values corresponds to a valid region of the devices' memory map. The allowed values are: 0x000x_xxxx 0x1FFx_xxxx 0x200x_xxxx 0x400x_xxxx After they are written with one of the allowed values, bits 31-20 read back as the written value. After they are written with any other value, bits 31-20 read back as an indeterminate value.

This function enables the request for specified channel.

Parameters

  instance | DMA instance.
  channel | DMA channel.

static void dma_hal_configure_count | ( | uint32_t | instance,
|  | uint32_t | channel,
|  | uint32_t | count
| ) |  |
| inline static

Transfer bytes must be written with a value equal to or less than 0F_FFFFh. After being written with a value in this range, bits 23-20 of the BCR read back as 1110b. A write to the BCR with a value greater than 0F_FFFFh causes a configuration error when the channel starts to execute. After they are written with a value in this range, bits 23-20 of BCR read back as 1111b.

Parameters

  instance | DMA instance.
  channel | DMA channel.
  count | bytes to be transferred.

static uint32_t dma_hal_get_unfinished_bytes | ( | uint32_t | instance,
|  | uint32_t | channel
| ) |  |
| inline static

Parameters

  instance | DMA instance.
  channel | DMA channel.

Returns
  unfinished bytes.

static void dma_hal_enable_interrupt | ( | uint32_t | instance,
|  | uint8_t | channel
| ) |  |
| inline static

This function enables the request for specified channel.

Parameters

  instance | DMA instance.
  channel | DMA channel.

static void dma_hal_disable_interrupt | ( | uint32_t | instance,
|  | uint8_t | channel
| ) |  |
| inline static

This function disables the request for a specified channel.

Parameters

  instance | DMA instance.
  channel | DMA channel.

static void dma_hal_set_cycle_steal | ( | uint32_t | instance,
|  | uint8_t | channel,
|  | bool | isCycleSteal
| ) |  |
| inline static

If continuous mode is enabled, DMA continuously makes write/read transfers until BCR decrement to 0. If continuous mode is disabled, DMA write/read is only triggered on every request. s

Parameters

  instance | DMA instance.
  channel | DMA channel.
  isContinue | 0 means cycle-steal mode, 1 means continuous mode.

static void dma_hal_set_autoalign_ability | ( | uint32_t | instance,
|  | uint8_t | channel,
|  | bool | isEnabled
| ) |  |
| inline static

If auto-align is enabled, the appropriate address register increments, regardless of whether it is a source increment or a destination increment.

Parameters

  instance | DMA instance.
  channel | DMA channel.
  isEnable | 0 means disable auto-align. 1 means enable auto-align.

static void dma_hal_set_async_dma_request_ability | ( | uint32_t | instance,
|  | uint8_t | channel,
|  | bool | isEnabled
| ) |  |
| inline static

Enables/Disables the a-synchronization mode in a STOP mode for each DMA channel.

Parameters

  instance | DMA instance.
  channel | DMA channel.
  isEnable | 0 means disable DMA request a-sync. 1 means enable DMA request -.

static void dma_hal_set_source_increment | ( | uint32_t | instance,
|  | uint32_t | channel,
|  | bool | isEnabled
| ) |  |
| inline static

Controls whether the source address increments after each successful transfer. If enabled, the SAR increments by 1,2,4 as determined by the transfer size.

Parameters

  instance | DMA instance.
  channel | DMA channel.
  isEnabled | Enabled/Disable increment.

static void dma_hal_set_dest_increment | ( | uint32_t | instance,
|  | uint32_t | channel,
|  | bool | isEnabled
| ) |  |
| inline static

Controls whether the destination address increments after each successful transfer. If enabled, the DAR increments by 1,2,4 as determined by the transfer size.

Parameters

  instance | DMA instance.
  channel | DMA channel.
  isEnabled | Enabled/Disable increment.

static void dma_hal_configure_source_transfersize | ( | uint32_t | instance,
|  | uint32_t | channel,
|  | dma_transfer_size_t | transfersize
| ) |  |
| inline static

Parameters

  instance | DMA instance.
  channel | DMA channel.
  transfersize | enum type for transfer size.

static void dma_hal_configure_dest_transfersize | ( | uint32_t | instance,
|  | uint32_t | channel,
|  | dma_transfer_size_t | transfersize
| ) |  |
| inline static

Parameters

  instance | DMA instance.
  channel | DMA channel.
  transfersize | enum type for transfer size.

static void dma_hal_trigger_start | ( | uint32_t | instance,
|  | uint32_t | channel
| ) |  |
| inline static

When the DMA begins the transfer, the START bit is cleared automatically after one module clock and always reads as logic 0.

Parameters

  instance | DMA instance.
  channel | DMA channel.

static void dma_hal_configure_source_modulo | ( | uint32_t | instance,
|  | uint32_t | channel,
|  | dma_modulo_t | modulo
| ) |  |
| inline static

Parameters

  instance | DMA instance.
  channel | DMA channel.
  modulo | enum data type for source modulo.

static void dma_hal_configure_dest_modulo | ( | uint32_t | instance,
|  | uint32_t | channel,
|  | dma_modulo_t | modulo
| ) |  |
| inline static

Parameters

  instance | DMA instance.
  channel | DMA channel.
  modulo | enum data type for dest modulo.

static void dma_hal_set_dma_request | ( | uint32_t | instance,
|  | uint32_t | channel,
|  | bool | isEnabled
| ) |  |
| inline static

Parameters

  instance | DMA instance.
  channel | DMA channel.
  isEnabled |

static void dma_hal_set_disable_dma_request_after_done | ( | uint32_t | instance,
|  | uint32_t | channel,
|  | bool | isDisabled
| ) |  |
| inline static

Disables/Enables the DMA request after a DMA DONE is generated. If it works in the loop mode, this bit should not be set.

Parameters

  channel | DMA channel.
  isDisabled | 0 means DMA request would not be disabled after work done. 1 means disable.

void dma_hal_set_channel_link | ( | uint32_t | instance,
|  | uint8_t | channel,
|  | dma_channel_link_config_t * | mode
| ) |  |

Parameters

  channel | DMA channel.
  mode | Mode of channel link in DMA.

static void dma_hal_clear_status | ( | uint32_t | instance,
|  | uint8_t | channel
| ) |  |
| inline static

This function clears all status for specified DMA channel. The error status and DONE status would all be cleared.

Parameters

  channel | DMA channel.

static dma_error_status_t dma_hal_get_status | ( | uint32_t | instance,
|  | uint8_t | channel
| ) |  |
| inline static

Gets the status of the DMA channel. The user can get the error status, as to whether the descriptor is finished or there are bytes left.

Parameters

  channel | DMA channel.
  mode | Mode of channel link in DMA.

Returns
  Status of the DMA channel.