no-OS
Classes | Enumerations | Functions
no_os_dma.h File Reference

Platform independent function definitions and data types for the DMA API. More...

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "no_os_list.h"
#include "no_os_irq.h"
#include "no_os_mutex.h"
Include dependency graph for no_os_dma.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  no_os_dma_default_handler_data
 IRQ parameter for the default inter transfer handler. More...
 
struct  no_os_dma_xfer_desc
 It's used to setup a generic DMA transfer. More...
 
struct  no_os_dma_ch
 Describes the state of a DMA channel. More...
 
struct  no_os_dma_desc
 Describes the state of the DMA controller. More...
 
struct  no_os_dma_init_param
 Initialization parameter for the DMA controller. More...
 
struct  no_os_dma_platform_ops
 

Enumerations

enum  no_os_dma_xfer_type {
  MEM_TO_MEM,
  MEM_TO_DEV,
  DEV_TO_MEM
}
 Supported transfer directions. More...
 

Functions

int no_os_dma_init (struct no_os_dma_desc **, struct no_os_dma_init_param *)
 Initialize the DMA controller. More...
 
int no_os_dma_remove (struct no_os_dma_desc *)
 Remove resources allocated for the DMA controller. More...
 
int no_os_dma_config_xfer (struct no_os_dma_desc *, struct no_os_dma_xfer_desc *, uint32_t, struct no_os_dma_ch *)
 Acquire a channel and configure the list of transfers. More...
 
int no_os_dma_chan_lock (struct no_os_dma_ch *)
 Lock a DMA channel, so it won't be acquired even if it's free. More...
 
int no_os_dma_chan_unlock (struct no_os_dma_ch *)
 Unlock a DMA channel, marking it available for acquisition. More...
 
int no_os_dma_xfer_start (struct no_os_dma_desc *, struct no_os_dma_ch *)
 Acquire a channel and configure the list of transfers. More...
 
int no_os_dma_xfer_abort (struct no_os_dma_desc *, struct no_os_dma_ch *)
 Abort the ongoing and any other future transfers scheduled for a channel. More...
 
bool no_os_dma_is_completed (struct no_os_dma_desc *, struct no_os_dma_ch *)
 Get the state of a DMA channel (free or not). More...
 
bool no_os_dma_in_progress (struct no_os_dma_desc *, struct no_os_dma_ch *)
 Whether or not there is a transfer in progress on a specific channel. More...
 
int no_os_dma_acquire_channel (struct no_os_dma_desc *, struct no_os_dma_ch **)
 Get a free DMA channel. More...
 
int no_os_dma_release_channel (struct no_os_dma_desc *, struct no_os_dma_ch *)
 Free DMA channel. More...
 

Detailed Description

Platform independent function definitions and data types for the DMA API.

Author
Ciprian Regus (cipri.nosp@m.an.r.nosp@m.egus@.nosp@m.anal.nosp@m.og.co.nosp@m.m)

Copyright 2024(c) Analog Devices, Inc.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of Analog Devices, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Enumeration Type Documentation

◆ no_os_dma_xfer_type

Supported transfer directions.

Enumerator
MEM_TO_MEM 
MEM_TO_DEV 
DEV_TO_MEM 

Function Documentation

◆ no_os_dma_acquire_channel()

int no_os_dma_acquire_channel ( struct no_os_dma_desc desc,
struct no_os_dma_ch **  channel 
)

Get a free DMA channel.

Get a free DMA channel.

Parameters
desc- Structure containing the state of the DMA controller.
channel- Reference to the acquired channel.
Returns
0 in case of success, negative error code otherwise.

◆ no_os_dma_chan_lock()

int no_os_dma_chan_lock ( struct no_os_dma_ch ch)

Lock a DMA channel, so it won't be acquired even if it's free.

Prevent a channel from being acquired, even if it's free.

Parameters
ch- Reference to the DMA channel
Returns
0 in case of success, -EINVAL if a NULL channel reference is provided.

◆ no_os_dma_chan_unlock()

int no_os_dma_chan_unlock ( struct no_os_dma_ch ch)

Unlock a DMA channel, marking it available for acquisition.

Allow a channel to be acquired, in case it's free.

Parameters
ch- Reference to the DMA channel
Returns
0 in case of success, -EINVAL if a NULL channel reference is provided.

◆ no_os_dma_config_xfer()

int no_os_dma_config_xfer ( struct no_os_dma_desc desc,
struct no_os_dma_xfer_desc xfer,
uint32_t  len,
struct no_os_dma_ch ch 
)

Acquire a channel and configure the list of transfers.

Acquire a channel and add the transfers to it's SG list.

Parameters
desc- Structure containing the state of the DMA controller
xfer- Array of DMA transfers.
len- The number of transfers in the xfer list.
ch- Previously acquired channel, for which the transfer will be configured.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ no_os_dma_in_progress()

bool no_os_dma_in_progress ( struct no_os_dma_desc desc,
struct no_os_dma_ch ch 
)

Whether or not there is a transfer in progress on a specific channel.

Whether or not a specific channel has an ongoing transfer.

Parameters
desc- Reference to the DMA controller.
ch- Reference to the DMA channel.
Returns
true if a channel is free, false otherwise.

◆ no_os_dma_init()

int no_os_dma_init ( struct no_os_dma_desc **  desc,
struct no_os_dma_init_param param 
)

Initialize the DMA controller.

Initialize a DMA controller.

Parameters
desc- Structure containing the state of the DMA controller
param- Initialization parameter for the DMA controller.
Returns
0 in case of success, negative error code otherwise.

◆ no_os_dma_is_completed()

bool no_os_dma_is_completed ( struct no_os_dma_desc desc,
struct no_os_dma_ch ch 
)

Get the state of a DMA channel (free or not).

Check whether a transfer is complete. By default, it requires the interrupt handler to set the free flag for the channel.

Parameters
desc- Reference to the DMA controller.
ch- Reference to the DMA channel.
Returns
true if a channel is free, false otherwise.

◆ no_os_dma_release_channel()

int no_os_dma_release_channel ( struct no_os_dma_desc desc,
struct no_os_dma_ch channel 
)

Free DMA channel.

Free a DMA channel.

Parameters
desc- Structure containing the state of the DMA controller.
channel- Reference to the currently acquired channel.
Returns
0 in case of success, negative error code otherwise.

◆ no_os_dma_remove()

int no_os_dma_remove ( struct no_os_dma_desc desc)

Remove resources allocated for the DMA controller.

Free the resources allocated by the DMA layer. Disables the DMA controller.

Parameters
desc- Structure containing the state of the DMA controller
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ no_os_dma_xfer_abort()

int no_os_dma_xfer_abort ( struct no_os_dma_desc desc,
struct no_os_dma_ch ch 
)

Abort the ongoing and any other future transfers scheduled for a channel.

Stop the DMA transactions for a specific channel and remove the transfers from the SG list.

Parameters
desc- Structure containing the state of the DMA controller
ch- Index for the channel we want to abort the transfer.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ no_os_dma_xfer_start()

int no_os_dma_xfer_start ( struct no_os_dma_desc desc,
struct no_os_dma_ch ch 
)

Acquire a channel and configure the list of transfers.

Start the DMA transactions for a specific channel.

Parameters
desc- Structure containing the state of the DMA controller
ch- Index for the channel we want to start the transfer on.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function: