AM62Px MCU+ SDK  10.01.00
MCASP

The Multi Channel Audio Seiral Peripheral (MCASP) driver is a generic, full-duplex driver that transmits and receives data using the MCASP interface. This is specially designed to transmit and receive the digital audio data.

Features Supported

  • Interrupt mode operation
  • DMA mode operation
  • Internal Loopback
  • Transmit and Receive in TDM format with multi-serializer, multi-slot support.
  • SysConfig support for driver parameter configuration and initialization.

SysConfig Features

Attention
The instances for McASP needs to be selected the same for serializers for the instance. Syscfg will automatically assign different instances for all and user will be required to assign same instance and choose to ignore the warning.
Note
It is strongly recommend to use SysConfig where it is available instead of using direct SW API calls. This will help simplify the SW application and also catch common mistakes early in the development cycle.

Features NOT Supported

  • Transmit in DIT mode
  • Burst Mode
  • Different audio buffer format for application

Usage Overview

API Sequence

To use the MCASP driver to send data over the MCASP interface, the application calls the following APIs:

Loopjob Configuration

Mcasp driver allows loopjob enabled/disabled configuration to handle delayed application buffer submission at run time. Loopjob is a default buffer that gets transmitted / received into if the application fails to submit the buffers in time. When loopjob is disabled the last 2 application buffers will be re programmed and re used. The application callback corresponding to the re programmed buffers is not called.

  • Loopjob buffer is programmed in sys config. Sys config will define a uint8_t array and initialize it to 0.
  • Application can access the buffer and optionally initialize the data.
  • If the loopjob buffer is programmed, after sending the full loopjob buffer next submitted buffer is programmed.

Buffer Queuing

  • The application buffers need to be programmed before starting the transfer.
  • If the loopjob is enabled application can start without queuing any buffers, Driver will work with the loopjob buffers till application queues the actual buffers.
  • If loopjob is disabled at least 2 buffers should be queued before starting the mcasp transfer. New buffer will be programmed in the interrupt callback corresponding to current transfer. the application is expected to submit the new buffer before that else the same buffer is re programmed, so it is recommended to start the transfer with at least 3 buffers queued.

Example Usage

Include the below file to access the APIs

#include <drivers/mcasp.h>

Instance Open Example

MCASP_OpenParams mcaspParams;
MCASP_openParamsInit(&mcaspParams); /* Initialize mcasp parameters */
mcaspParams.edmaInst = 0;
mcaspParams.edmaInst = CONFIG_EDMA0,
mcaspParams.txCallbackFxn = mcasp_loopback_txcb,
mcaspParams.rxCallbackFxn = mcasp_loopback_rxcb,
gMcaspHandle = MCASP_open(CONFIG_MCASP0, &mcaspParams);
DebugP_assert(gMcaspHandle != NULL);

Instance Close Example

MCASP_close(gMcaspHandle);

Start McASP Transfer Example

MCASP_Transaction txnTx[APP_MCASP_MSG_COUNT] = {0};
MCASP_Transaction txnRx[APP_MCASP_MSG_COUNT] = {0};
uint8_t mcaspTxBuffer[APP_MCASP_MSG_COUNT][APP_MCASP_MSGSIZE];
uint8_t mcaspRxBuffer[APP_MCASP_MSG_COUNT][APP_MCASP_MSGSIZE];
uint32_t i;
for (i = 0U; i < APP_MCASP_MSG_COUNT; i++)
{
txnTx[i].buf = (void*) &mcaspTxBuffer[i][0];
txnTx[i].count = APP_MCASP_MSGSIZE/4;
txnTx[i].timeout = 0xFFFFFF;
MCASP_submitTx(gMcaspHandle, &txnTx[i]);
}
for (i = 0U; i < APP_MCASP_MSG_COUNT; i++)
{
txnRx[i].buf = (void*) &mcaspRxBuffer[i][0];
txnRx[i].count = APP_MCASP_MSGSIZE/4;
txnRx[i].timeout = 0xFFFFFF;
MCASP_submitRx(gMcaspHandle, &txnRx[i]);
}
MCASP_startTransferRx(gMcaspHandle);
MCASP_startTransferTx(gMcaspHandle);

Stop McASP Transfer Example

MCASP_stopTransferTx(gMcaspHandle);
MCASP_stopTransferRx(gMcaspHandle);
/* withdraw the buffers submitted to driver. */
{
MCASP_Transaction *transaction;
do {
transaction = MCASP_withdrawRx(gMcaspHandle);
}while (transaction != NULL);
do {
transaction = MCASP_withdrawTx(gMcaspHandle);
}while (transaction != NULL);
}

API

APIs for MCASP

MCASP_withdrawRx
MCASP_Transaction * MCASP_withdrawRx(MCASP_Handle handle)
Function to withdraw the buffer submitted to McASP driver for reception. This should be called after ...
MCASP_close
void MCASP_close(MCASP_Handle handle)
Function to close a MCASP peripheral specified by the MCASP handle.
MCASP_submitRx
int32_t MCASP_submitRx(MCASP_Handle handle, MCASP_Transaction *txn)
Function to submit the buffer to McASP driver for reception. Transaction object is held by the driver...
MCASP_withdrawTx
MCASP_Transaction * MCASP_withdrawTx(MCASP_Handle handle)
Function to withdraw the buffer submitted to McASP driver for transmission. This should be called aft...
NULL
#define NULL
Define NULL if not defined.
Definition: csl_types.h:100
MCASP_OpenParams::rxCallbackFxn
MCASP_RxCallbackFxn rxCallbackFxn
Definition: mcasp/v1/mcasp.h:522
MCASP_open
MCASP_Handle MCASP_open(uint32_t index, const MCASP_OpenParams *openParams)
This function opens a given MCASP peripheral.
MCASP_Transaction
Data structure used with transfer call.
Definition: mcasp/v1/mcasp.h:339
MCASP_OpenParams
MCASP Parameters.
Definition: mcasp/v1/mcasp.h:501
MCASP_stopTransferRx
int32_t MCASP_stopTransferRx(MCASP_Handle handle)
Function to stop McASP reception.
MCASP_OpenParams::transferMode
uint32_t transferMode
Definition: mcasp/v1/mcasp.h:502
MCASP_Transaction::count
uint32_t count
Definition: mcasp/v1/mcasp.h:346
MCASP_startTransferTx
int32_t MCASP_startTransferTx(MCASP_Handle handle)
Function to start McASP transmission.
MCASP_OpenParams::txCallbackFxn
MCASP_TxCallbackFxn txCallbackFxn
Definition: mcasp/v1/mcasp.h:520
mcasp.h
MCASP_openParamsInit
static void MCASP_openParamsInit(MCASP_OpenParams *openPrms)
Function to initialize the MCASP_OpenParams struct to its defaults.
Definition: mcasp/v1/mcasp.h:876
MCASP_startTransferRx
int32_t MCASP_startTransferRx(MCASP_Handle handle)
Function to start McASP reception.
MCASP_Transaction::timeout
uint32_t timeout
Definition: mcasp/v1/mcasp.h:350
DebugP_assert
#define DebugP_assert(expression)
Function to call for assert check.
Definition: DebugP.h:175
MCASP_Transaction::buf
void * buf
Definition: mcasp/v1/mcasp.h:343
MCASP_submitTx
int32_t MCASP_submitTx(MCASP_Handle handle, MCASP_Transaction *txn)
Function to submit the buffer to McASP driver for transmission. Transaction object is held by the dri...
MCASP_TRANSFER_MODE_DMA
#define MCASP_TRANSFER_MODE_DMA
MCASP read/write APIs does not block code execution and will use DMA for transfers.
Definition: mcasp/v1/mcasp.h:158
MCASP_stopTransferTx
int32_t MCASP_stopTransferTx(MCASP_Handle handle)
Function to stop McASP transmission.