no-OS
Loading...
Searching...
No Matches
no_os_dma.c File Reference

Platform independent implementation for the DMA API. More...

#include <inttypes.h>
#include "no_os_dma.h"
#include <stdlib.h>
#include "no_os_error.h"
#include "no_os_mutex.h"
#include "no_os_irq.h"
#include "no_os_alloc.h"
#include "no_os_list.h"
Include dependency graph for no_os_dma.c:

Functions

int no_os_dma_init (struct no_os_dma_desc **desc, const struct no_os_dma_init_param *param)
 Initialize the DMA controller.
 
int no_os_dma_remove (struct no_os_dma_desc *desc)
 Remove resources allocated for the DMA controller.
 
int no_os_dma_acquire_channel (struct no_os_dma_desc *desc, struct no_os_dma_ch **channel)
 Get a free DMA channel.
 
int no_os_dma_release_channel (struct no_os_dma_desc *desc, struct no_os_dma_ch *channel)
 Free DMA channel.
 
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.
 
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.
 
int no_os_dma_chan_unlock (struct no_os_dma_ch *ch)
 Unlock a DMA channel, marking it available for acquisition.
 
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.
 
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.
 
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).
 
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.
 

Detailed Description

Platform independent implementation 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.

SPDX-License-Identifier: BSD-3-Clause

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.

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.

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.

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.

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.

◆ 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.

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,
const struct no_os_dma_init_param * param )

Initialize the 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).

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.

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.

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

◆ 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.

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.

◆ 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.

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.