MCUXpresso SDK API Reference Manual: PDM SDMA Driver

| MCUXpresso SDK API Reference Manual Rev 2.11.1 NXP Semiconductors

- Main Page
- Related Pages
- API Reference

All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Data Structures | Typedefs
PDM SDMA Driver
PDM: Microphone Interface

# Typical use case

More...

## Overview

## The SDMA multi fifo script support transfer data between multi peripheral fifos and memory, a typical user case is that receiving multi PDM channel data and put it into memory as

## | channel 0 | channel 1 | channel 2 | channel 3 | channel 4 | ......... |

Multi fifo script is target to implement above feature, it can supports 1.configurable fifo watermark range from 1~(2^12-1), it is a value of fifo_watermark * channel_numbers 2.configurable fifo numbers, support up to 15 continuous fifos 3.configurable fifo address offset, support address offset up to 64

/* load sdma script */
SDMA_LoadScript()
/* pdm multi channel configurations */
PDM_SetChannelConfigSDMA()
PDM_SetChannelConfigSDMA()
PDM_SetChannelConfigSDMA()
PDM_SetChannelConfigSDMA()
....
PDM_TransferReceiveSDMA

Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/pdm/pdm_sai_sdma

## Data Structures
struct | pdm_sdma_handle_t
| PDM DMA transfer handle, users should not touch the content of the handle. More...

## Typedefs
typedef void(* | pdm_sdma_callback_t )(PDM_Type *base, pdm_sdma_handle_t *handle, status_t status, void *userData)
| PDM eDMA transfer callback function for finish and error.

## Driver version
#define | FSL_PDM_SDMA_DRIVER_VERSION (MAKE_VERSION(2, 6, 0))
| Version 2.6.0.

## eDMA Transactional
void | PDM_TransferCreateHandleSDMA (PDM_Type *base, pdm_sdma_handle_t *handle, pdm_sdma_callback_t callback, void *userData, sdma_handle_t *dmaHandle, uint32_t eventSource)
| Initializes the PDM eDMA handle. More...
status_t | PDM_TransferReceiveSDMA (PDM_Type *base, pdm_sdma_handle_t *handle, pdm_transfer_t *xfer)
| Performs a non-blocking PDM receive using eDMA. More...
void | PDM_TransferAbortReceiveSDMA (PDM_Type *base, pdm_sdma_handle_t *handle)
| Aborts a PDM receive using eDMA. More...
void | PDM_SetChannelConfigSDMA (PDM_Type *base, pdm_sdma_handle_t *handle, uint32_t channel, const pdm_channel_config_t *config)
| PDM channel configurations. More...

## Data Structure Documentation

struct _pdm_sdma_handle

### Data Fields
sdma_handle_t * | dmaHandle
| DMA handler for PDM send.
uint8_t | nbytes
| eDMA minor byte transfer count initially configured. More...
uint8_t | fifoWidth
| fifo width
uint8_t | endChannel
| The last enabled channel.
uint8_t | channelNums
| total channel numbers
uint32_t | count
| The transfer data count in a DMA request.
uint32_t | state
| Internal state for PDM eDMA transfer.
uint32_t | eventSource
| PDM event source number.
pdm_sdma_callback_t | callback
| Callback for users while transfer finish or error occurs.
void * | userData
| User callback parameter.
sdma_buffer_descriptor_t | bdPool [PDM_XFER_QUEUE_SIZE]
| BD pool for SDMA transfer. More...
pdm_transfer_t | pdmQueue [PDM_XFER_QUEUE_SIZE]
| Transfer queue storing queued transfer. More...
size_t | transferSize [PDM_XFER_QUEUE_SIZE]
| Data bytes need to transfer.
volatile uint8_t | queueUser
| Index for user to queue transfer. More...
volatile uint8_t | queueDriver
| Index for driver to get the transfer data and size.

#### Field Documentation

uint8_t pdm_sdma_handle_t::nbytes

sdma_buffer_descriptor_t pdm_sdma_handle_t::bdPool[PDM_XFER_QUEUE_SIZE]

pdm_transfer_t pdm_sdma_handle_t::pdmQueue[PDM_XFER_QUEUE_SIZE]

volatile uint8_t pdm_sdma_handle_t::queueUser

## Function Documentation

void PDM_TransferCreateHandleSDMA | ( | PDM_Type * | base,
|  | pdm_sdma_handle_t * | handle,
|  | pdm_sdma_callback_t | callback,
|  | void * | userData,
|  | sdma_handle_t * | dmaHandle,
|  | uint32_t | eventSource
| ) |  |

This function initializes the PDM DMA handle, which can be used for other PDM master transactional APIs. Usually, for a specified PDM instance, call this API once to get the initialized handle.

Parameters

  base | PDM base pointer.
  handle | PDM eDMA handle pointer.
  callback | Pointer to user callback function.
  userData | User parameter passed to the callback function.
  dmaHandle | eDMA handle pointer, this handle shall be static allocated by users.
  eventSource | PDM event source number.

status_t PDM_TransferReceiveSDMA | ( | PDM_Type * | base,
|  | pdm_sdma_handle_t * | handle,
|  | pdm_transfer_t * | xfer
| ) |  |

Note
  This interface returns immediately after the transfer initiates. Call the PDM_GetReceiveRemainingBytes to poll the transfer status and check whether the PDM transfer is finished.

Parameters

  base | PDM base pointer
  handle | PDM eDMA handle pointer.
  xfer | Pointer to DMA transfer structure.

Return values

  kStatus_Success | Start a PDM eDMA receive successfully.
  kStatus_InvalidArgument | The input argument is invalid.
  kStatus_RxBusy | PDM is busy receiving data.

void PDM_TransferAbortReceiveSDMA | ( | PDM_Type * | base,
|  | pdm_sdma_handle_t * | handle
| ) |  |

Parameters

  base | PDM base pointer
  handle | PDM eDMA handle pointer.

void PDM_SetChannelConfigSDMA | ( | PDM_Type * | base,
|  | pdm_sdma_handle_t * | handle,
|  | uint32_t | channel,
|  | const pdm_channel_config_t * | config
| ) |  |

Parameters

  base | PDM base pointer.
  handle | PDM eDMA handle pointer.
  channel | channel number.
  config | channel configurations.