# GPDMA
[HAL]

General purpose DMA management. More...

Collaboration diagram for GPDMA:

## Data Structures
struct | hal_dma_desc_tag
| General purpose DMA descriptor definition. More...
struct | hal_dma_env_tag
| Environment structure definition. More...
## Defines
#define | DMA_LLICTRL(index)
| Configure the bridge DMA control field.
#define | HAL_DMA_POOL (RW_BFMER_EN)
| Indicate if a pool of GP DMA Descriptors have to be allocated.
#define | HAL_DMA_DESC_POOL_SIZE (10)
| Number of descriptors in pool of General Purpose DMA descriptors.
## Typedefs
typedef void(* | cb_dma_func_ptr )(void *, int)
| Pointer to callback function.
## Enumerations
enum | { DMA_DL, DMA_UL, DMA_MAX }
| General purpose DMA direction. More...
## Functions
void | hal_dma_init (void)
| Initialize the general purpose DMA module.
void | hal_dma_push (struct hal_dma_desc_tag *desc, int type)
| Push a DMA request.
void | hal_dma_evt (int dma_queue)
| Handler for the general purpose DMA event.
void | hal_dma_dl_irq (void)
| Interrupt handler for the general purpose DMA download interrupt.
void | hal_dma_ul_irq (void)
| Interrupt handler for the general purpose DMA upload interrupt.
struct hal_dma_desc_tag * | hal_dma_get_desc (void)
| Return a struct hal_dma_desc_tag object extracted from the pool of descriptors.
void | hal_dma_release_desc (struct hal_dma_desc_tag *gp_dma_desc)
| Add back a GP DMA descriptor to the pool of descriptors.
## Variables
const uint8_t | dma2chan [DMA_MAX]
| Array of conversion between the DMA transfer type and the DMA channel that is used.
const uint8_t | dma2lli [DMA_MAX]
| Array of conversion between the DMA transfer type and the DMA LLI that is used.
struct hal_dma_env_tag | hal_dma_env
| HAL DMA environment variable.
struct hal_dma_env_tag | hal_dma_env
| HAL DMA environment variable.

## Detailed Description

General purpose DMA management.

## Define Documentation

#define DMA_LLICTRL | ( | index |  | ) |

Value:

    (IPC_DMA_LLI_COUNTER_EN|(dma2lli[index]<<IPC_DMA_LLI_COUNTER_POS) \
                               | IPC_DMA_LLI_IRQ_EN|(dma2lli[index] << IPC_DMA_LLI_IRQ_POS))

Configure the bridge DMA control field.

Definition at line 52 of file hal_dma.c.

## Enumeration Type Documentation

anonymous enum

General purpose DMA direction.

Enumerator:

  DMA_DL | A general purpose DMA download.
  DMA_UL | A general purpose DMA upload.
  DMA_MAX | Number of general purpose DMA directions.

Definition at line 64 of file hal_dma.h.

## Function Documentation

void hal_dma_dl_irq | ( | void |  | ) |

Interrupt handler for the general purpose DMA download interrupt.

void hal_dma_evt | ( | int | dma_queue | ) |

Handler for the general purpose DMA event.

Parameters:

  `[in]` | dma_queue | DMA queue index (DL or UL)

struct hal_dma_desc_tag* hal_dma_get_desc | ( | void |  | ) | `[read]`

Return a struct hal_dma_desc_tag object extracted from the pool of descriptors.

If the descriptor is pushed, it will be automatically inserted back in the pool of descriptors upon confirmation of the DMA transfer. If the descriptor is not pushed and must be released, use hal_dma_release_desc function.

Returns:
  The allocated HAL DMA descriptor

void hal_dma_push | ( | struct hal_dma_desc_tag * | desc,
|  | int | type |
| ) |  |  |

Push a DMA request.

Parameters:

  `[in]` | desc | Pointer to the DMA descriptor to be used for the transfer
  `[in]` | type | Type of transfer (i.e DMA_DL or DMA_UL)

Referenced by mm_bcn_update(), and scanu_ie_download().

void hal_dma_release_desc | ( | struct hal_dma_desc_tag * | gp_dma_desc | ) |

Add back a GP DMA descriptor to the pool of descriptors.

Parameters:

  `[in]` | gp_dma_desc | Descriptor to be released

void hal_dma_ul_irq | ( | void |  | ) |

Interrupt handler for the general purpose DMA upload interrupt.

## Variable Documentation

const uint8_t dma2chan[DMA_MAX]

Initial value:

    {
        [DMA_DL] = IPC_DMA_CHANNEL_CTRL_TX,
        [DMA_UL] = IPC_DMA_CHANNEL_CTRL_RX,
    }

Array of conversion between the DMA transfer type and the DMA channel that is used.

Definition at line 38 of file hal_dma.c.

const uint8_t dma2lli[DMA_MAX]

Initial value:

    {
        [DMA_DL] = IPC_DMA_LLI_GP_DL,
        [DMA_UL] = IPC_DMA_LLI_GP_UL,
    }

Array of conversion between the DMA transfer type and the DMA LLI that is used.

Definition at line 45 of file hal_dma.c.