# mcbsp_pvt.h File Reference

Header file conataining the driver internal definitions and data structures. More...

`#include <ti/csl/cslr_mcbsp.h>`
`#include <ti/sdo/edma3/drv/edma3_drv.h>`
`#include <ti/drv/mcbsp/mcbsp_drv.h>`

## Data Structures

struct | Mcbsp_ChannelObj_t
| Mcbsp channel Object. More...
struct | Mcbsp_Object_Unpadded
| Mcbsp instance Object. More...

## Defines

#define | Mcbsp_MAXLINKCNT (2u)
#define | Mcbsp_TXEVENTQUE (1u)
#define | Mcbsp_RXEVENTQUE (2u)
#define | Mcbsp_CNT_MAX_VAL (0xFFFFu)
#define | Mcbsp_STATUS_INVALID (0xFFFF)
#define | Mcbsp_STATUS_VALID (0x1)
#define | Mcbsp_MAX_IOBUF_SIZE (32768u)
#define | Mcbsp_FRAME_LENGTH (127u)

## Typedefs

typedef enum Mcbsp_DriverState_t | Mcbsp_DriverState
| Mcbsp driver state.
typedef enum Mcbsp_SpcrCtrl_t | Mcbsp_SpcrCtrl
| Mcbsp SPCR control enums.
typedef struct Mcbsp_ChannelObj_t | Mcbsp_ChannelObj
| Mcbsp channel Object.

## Enumerations

enum | Mcbsp_DriverState_t
| Mcbsp driver state. More...
enum | Mcbsp_SpcrCtrl_t { Mcbsp_SpcrCtrl_RX_ENABLE = (1u), Mcbsp_SpcrCtrl_TX_ENABLE = (2u), Mcbsp_SpcrCtrl_RX_DISABLE = (4u), Mcbsp_SpcrCtrl_TX_DISABLE = (8u), Mcbsp_SpcrCtrl_FSYNC_ENABLE = (16u), Mcbsp_SpcrCtrl_SRG_ENABLE = (32u), Mcbsp_SpcrCtrl_FSYNC_DISABLE = (64u), Mcbsp_SpcrCtrl_SRG_DISABLE = (128u)
}
| Mcbsp SPCR control enums. More...

## Functions

int32_t | Mcbsp_localResetCtrl (Mcbsp_Object_Unpadded *instHandle, uint32_t selectMask)
| McBSP SPCR configuration function.
void | Mcbsp_localCompleteCurrentIo (Mcbsp_ChannelObj *chanHandle)
| This function completes the current pending request and then invokes the application registered callback.
void | Mcbsp_localEdmaCallback (uint32_t tcc, EDMA3_RM_TccStatus status, void *data)
| This calls the registered application callback for the current receive request and processes the next request in queue. This is a mcbsp edma callback function called in edma context.
void | Mcbsp_localAbortReset (Mcbsp_ChannelObj *chanHandle)
| Abort the queued up requests.
void | Mcbsp_localGetNextIndex (uint32_t *index)
| This function toggles the index of the edma params.
int32_t | Mcbsp_localSetupEdmaDuringOpen (Mcbsp_ChannelObj *chanHandle)
| Function to intialize and set up the edma for transfer.
int32_t | Mcbsp_localSubmitIoctl (Mcbsp_ChannelObj *chanHandle, Mcbsp_IOCTL cmd, void *arg, void *param)
| Implements the IOCTLS for McBSP driver.
int32_t | Mcbsp_localUpdtDtPktToLnkPrms (Mcbsp_ChannelObj *chanHandle, Mcbsp_IOBuf *const ioBuf)
| This function updates the link param set accordingly with data or loopjobbuffer. This uses properly maintained index to identify to what param set the info has to be updated.
int32_t | Mcbsp_localEdmaChanPaRAMsetup (Mcbsp_ChannelObj *chanHandle)
| setup the EDMA channel for the specific channel requested.
int32_t | Mcbsp_localEdmaProcessPkt (Mcbsp_ChannelObj *chanHandle, Mcbsp_IOBuf *ioBuf)
| Process the buffer and update the EDMA paramset.
void | Mcbsp_localCancelAndAbortAllIo (Mcbsp_ChannelObj *chanHandle)
| This is going to complete the current request and abort all other reqest.
int32_t | Mcbsp_localGetIndicesSyncType (Mcbsp_ChannelObj *chanHandle, volatile int16_t *bIndex, volatile int16_t *cIndex, volatile uint16_t *aCnt, volatile uint16_t *bCnt, volatile uint16_t *cCnt, EDMA3_DRV_SyncType *syncType, Bool forLoopJobBuf)
| Mcbsp_localGetIndicesSyncType.
int32_t | Mcbsp_localConfigureSrgr (Mcbsp_Object_Unpadded *instHandle, Mcbsp_ChannelObj *chanHandle)
| This function configures the sample rate generator and frame sync properties.
int32_t | Mcbsp_localConfigureRcvChannel (Mcbsp_Object_Unpadded *instHandle, Mcbsp_ChanParams *params)
| This function configures the receives section of the mcbsp.
int32_t | Mcbsp_localConfigureXmtChannel (Mcbsp_Object_Unpadded *instHandle, Mcbsp_ChanParams *params)
| This function configures the transmit section of the mcbsp sync properties.
void | Mcbsp_localLoadPktToEdma (Mcbsp_ChannelObj *chanHandle, Mcbsp_IOBuf *ioBuf)
| This function loads the buffers to the actual EDMA paramset.
int32_t | Mcbsp_localModifySampleRate (Mcbsp_ChannelObj *chanHandle, void *arg)
| Function to modify the sample rate generator configuration.
void | Mcbsp_TxFifo (int32_t arg0, int32_t arg1)
| This function waits for the FIFO to be emptied(if enabled) and the TX empty bit to be set so that the TX section could be disabled when there is no data present.

## Detailed Description

Header file conataining the driver internal definitions and data structures.

(C) Copyright 2012, Texas Instruments, Inc

## Define Documentation

#define Mcbsp_CNT_MAX_VAL (0xFFFFu)

Max possible value of aCnt, bCnt and cCnt

#define Mcbsp_FRAME_LENGTH (127u)

No of frames Max supported by the mcbsp

#define Mcbsp_MAX_IOBUF_SIZE (32768u)

Maximum sixe of the I/O buffer programmable

#define Mcbsp_MAXLINKCNT (2u)

Maximum number of EDMA jobs linked at a time (Must be 2).

#define Mcbsp_RXEVENTQUE (2u)

Receive EDMA channel event queue number

#define Mcbsp_STATUS_INVALID (0xFFFF)

Generic invalidate status

#define Mcbsp_STATUS_VALID (0x1)

Generic validate status

#define Mcbsp_TXEVENTQUE (1u)

Transmit EDMA channel event queue number

## Typedef Documentation

typedef struct Mcbsp_ChannelObj_t Mcbsp_ChannelObj

Mcbsp channel Object.

This structure maintains the current channel state. It also holds information on DMA channel being used and holds the application callback function to be called in case of an interrupt.

This structure is initialized by mdCreateChan and a pointer to this is passed down to all other channel related functions. Lifetime of the data structure is from its creation by mdCreateChan till it is invalidated by mdDeleteChan.each instance object will have two channel object one for TX and one for the RX channel. Mcbsp channel Object

typedef enum Mcbsp_DriverState_t Mcbsp_DriverState

Mcbsp driver state.

Mcbsp driver state enums used to track the driver and channel state. Mcbsp driver and channel states

typedef enum Mcbsp_SpcrCtrl_t Mcbsp_SpcrCtrl

Mcbsp SPCR control enums.

These enums are used to control the settings of the SPCR register. Mcbsp SPCR control enums

## Enumeration Type Documentation

enum Mcbsp_DriverState_t

Mcbsp driver state.

Mcbsp driver state enums used to track the driver and channel state.

enum Mcbsp_SpcrCtrl_t

Mcbsp SPCR control enums.

These enums are used to control the settings of the SPCR register.

Enumerator:

  Mcbsp_SpcrCtrl_RX_ENABLE | To enable receiver in resetControl Function
  Mcbsp_SpcrCtrl_TX_ENABLE | To enable Transmitter in resetControl Function
  Mcbsp_SpcrCtrl_RX_DISABLE | To disable Receiver in resetControl Function
  Mcbsp_SpcrCtrl_TX_DISABLE | To disable Transmitter in resetControl Function
  Mcbsp_SpcrCtrl_FSYNC_ENABLE | To enable Frame Sync Generation in resetControl Function
  Mcbsp_SpcrCtrl_SRG_ENABLE | To enable Sample Rate Generator in resetControl Function
  Mcbsp_SpcrCtrl_FSYNC_DISABLE | To disable Frame Sync Generation in resetControl Function
  Mcbsp_SpcrCtrl_SRG_DISABLE | To disable Sample Rate Generator in resetControl Function

## Function Documentation

void Mcbsp_localAbortReset | ( | Mcbsp_ChannelObj * | chanHandle | ) |

Abort the queued up requests.

This commands aborts all the pending IO requests and returns them to the application. The current state of the IO request will be set to ABORTED.

Parameters:

  | chanHandle | [IN] Handle to the channel whose requests are to be aborted

Returns:
  None

void Mcbsp_localCancelAndAbortAllIo | ( | Mcbsp_ChannelObj * | chanHandle | ) |

This is going to complete the current request and abort all other reqest.

Parameters:

  | chanHandle | [IN] Channel handle

Returns:
  None

chanHandle is a valid non null pointer

Not implemented

void Mcbsp_localCompleteCurrentIo | ( | Mcbsp_ChannelObj * | chanHandle | ) |

This function completes the current pending request and then invokes the application registered callback.

Parameters:

  | chanHandle | [IN] Handle to the channel

Returns:
  None

chanHandle is a valid non null pointer

Not implemented

int32_t Mcbsp_localConfigureRcvChannel | ( | Mcbsp_Object_Unpadded * | instHandle,
|  | Mcbsp_ChanParams * | params |
| ) |  |  |

This function configures the receives section of the mcbsp.

Parameters:

  | instHandle | [IN] pointer to the instance object.
  | params | [IN] User supplied channel parameters

Returns:
  MCBSP_ERR_BADARGS if configuration fails. MCBSP_STATUS_COMPLETED if confioguration is sucessful.

int32_t Mcbsp_localConfigureSrgr | ( | Mcbsp_Object_Unpadded * | instHandle,
|  | Mcbsp_ChannelObj * | chanHandle |
| ) |  |  |

This function configures the sample rate generator and frame sync properties.

Parameters:

  | instHandle | [IN] pointer to the instance object.
  | chanHandle | [IN] Handle to the channel.

Returns:
  MCBSP_ERR_BADARGS if calculation fails. MCBSP_STATUS_COMPLETED if calculation is sucessful.

int32_t Mcbsp_localConfigureXmtChannel | ( | Mcbsp_Object_Unpadded * | instHandle,
|  | Mcbsp_ChanParams * | params |
| ) |  |  |

This function configures the transmit section of the mcbsp sync properties.

Parameters:

  | instHandle | [IN] pointer to the instance object.
  | params | [IN] User supplied channel parameters

Returns:
  MCBSP_ERR_BADARGS if configuration fails. MCBSP_STATUS_COMPLETED if configuration is sucessful.

void Mcbsp_localEdmaCallback | ( | uint32_t | tcc,
|  | EDMA3_RM_TccStatus | edmaStatus,
|  | void * | data |
| ) |  |  |

This calls the registered application callback for the current receive request and processes the next request in queue. This is a mcbsp edma callback function called in edma context.

Parameters:

  | tcc | [IN] tcc number of EDMA
  | edmaStatus | [IN] status of EDMA transaction
  | data | [IN] paramaters sent to EDMA ISR (chan handler)

Returns:
  Nothing

tcc should be a valid value status should be a valid value data should be a non NULL and valid pointer

Not implemented

int32_t Mcbsp_localEdmaChanPaRAMsetup | ( | Mcbsp_ChannelObj * | chanHandle | ) |

setup the EDMA channel for the specific channel requested.

This function configures the McBSP synchonized EDMA channel PaRAM entries it also configures the various other parameters like source and destination address / modes

Parameters:

  | chanHandle | [IN] Channel handle

Returns:
  MCBSP_STATUS_COMPLETED if setup successful Appropriate MCBSP driver error code if configuration has any error

int32_t Mcbsp_localEdmaProcessPkt | ( | Mcbsp_ChannelObj * | chanHandle,
|  | Mcbsp_IOBuf * | ioBuf |
| ) |  |  |

Process the buffer and update the EDMA paramset.

For the transmit operation, the eDMA channel's destination port is tied to the MCBSP DAT port. In case of receive, the eDMA channel's source port is tied to the MCBSP DAT port. The source address for transmit eDMA channel and the destination address for the receive eDMA channel are set here.

Parameters:

  | chanHandle | [IN] Pointer to channel
  | ioBuf | [IN] Pointer to request to be processed

Returns:
  MCBSP_STATUS_COMPLETED, if the address is set correctly MCBSP_ERR_BADIO otherwise

int32_t Mcbsp_localGetIndicesSyncType | ( | Mcbsp_ChannelObj * | chanHandle,
|  | volatile int16_t * | bIndex,
|  | volatile int16_t * | cIndex,
|  | volatile uint16_t * | aCnt,
|  | volatile uint16_t * | bCnt,
|  | volatile uint16_t * | cCnt,
|  | EDMA3_DRV_SyncType * | syncType,
|  | Bool | forLoopJobBuf |
| ) |  |  |

Mcbsp_localGetIndicesSyncType.

This function computes the parameters requied to configure EDMA 3 based on the buffer format seleted while creating the driver.

Entry Criteria : This function expects channel variables such as no of slots length of buffers is updated.

Parameters:

  | chanHandle | [IN] Pointer to channel handle
  | bIndex | [IN] Pointer to stores computed bIndex
  | cIndex | [IN] Pointer to stores computed cIndex
  | aCnt | [IN] Pointer to stores computed aCnt
  | bCnt | [IN] Pointer to stores computed bCnt
  | cCnt | [IN] Pointer to stores computed cCnt
  | syncType | [IN] Pointer to stores computed mode of EDMA
  | forLoopJobBuf | [IN] To calucalate above for loopJob or data

CAUTION: This function could be called with pointer pointing to EDMA 3 paramset pointer (avoiding couple of variables). Care should be take to ensure that data types used in EDMA 3 paramset is consistent with EDMA 3 defined data types.

Returns:
  MCBSP_ERR_BADARGS on invalid buffer format, else MCBSP_STATUS_COMPLETED

void Mcbsp_localGetNextIndex | ( | uint32_t * | index | ) |

This function toggles the index of the edma params.

Parameters:

  | index | [IN] pointer to current index

Returns:
  None

index is a valid non null pointer

Not implemented

void Mcbsp_localLoadPktToEdma | ( | Mcbsp_ChannelObj * | chanHandle,
|  | Mcbsp_IOBuf * | ioBuf |
| ) |  |  |

This function loads the buffers to the actual EDMA paramset.

Parameters:

  | chanHandle | [IN] Handle to channel.
  | ioBuf | [IN] pointer to the ioBuf

Returns:
  None

Not implemented

Not implemented

int32_t Mcbsp_localModifySampleRate | ( | Mcbsp_ChannelObj * | chanHandle,
|  | void * | arg |
| ) |  |  |

Function to modify the sample rate generator configuration.

Parameters:

  | chanHandle | [IN] Handle to the channel
  | arg | [IN] pointer to the srg config setup

Returns:
  None

int32_t Mcbsp_localResetCtrl | ( | Mcbsp_Object_Unpadded * | instHandle,
|  | uint32_t | selectMask |
| ) |  |  |

McBSP SPCR configuration function.

This Function is used to set/reset specific bit of SPCR as specified in the given mask.

Parameters:

  | instHandle | [IN] pointer to the mcbsp instance object.
  | selectMask | [IN] the SPCR control mask

Returns:
  MCBSP_STATUS_COMPLETED if successful

MCBSP_ERR_BADARGS if not successful

int32_t Mcbsp_localSetupEdmaDuringOpen | ( | Mcbsp_ChannelObj * | chanHandle | ) |

Function to intialize and set up the edma for transfer.

This function does the following 1) Requests the EDMA channel from the edma driver. 2) Requests the link channels for linking (exclusive for tx & rx) 3) set up the param set of main xfer channel (for loopjob transfers) 4) set up the param sets of all link channel (for loopjob transfers) 5) link the last link channel to itself (this channel will be linked to main xfer channel later and to supply the loopjob xfer information infinely this is done so; other link channels are setup here just for completion sake

Parameters:

  | chanHandle | [IN] Handle to the channel for which the edma is setup

Returns:
  status MCBSP_STATUS_COMPLETED if is sucess error id in case of failure

int32_t Mcbsp_localSubmitIoctl | ( | Mcbsp_ChannelObj * | chanHandle,
|  | Mcbsp_IOCTL | cmd,
|  | void * | arg,
|  | void * | param |
| ) |  |  |

Implements the IOCTLS for McBSP driver.

This function implements the McBSP device specific control operations including Start/Stop, Pause/Resume, Channel and Device Reset, Mute-ON/OFF, McBSP sample rate generator configuration etc.

Parameters:

  | chanHandle | [IN] Handle to channel
  | cmd | [IN] Control command number
  | arg | [IN] Arguments for control command
  | param | [IN] user defined data structure

Returns:
  MCBSP_STATUS_COMPLETED in case of sucess. MCBSP_ERR_NOTIMPL in case the command is not supported. MCBSP driver error code in case of any error.

int32_t Mcbsp_localUpdtDtPktToLnkPrms | ( | Mcbsp_ChannelObj * | chanHandle,
|  | Mcbsp_IOBuf *const | ioBuf |
| ) |  |  |

This function updates the link param set accordingly with data or loopjobbuffer. This uses properly maintained index to identify to what param set the info has to be updated.

Parameters:

  | chanHandle | [IN] Handle to the mcbsp channel
  | ioBuf | [IN] Pointer to I/O buffer

Returns:
  MCBSP_STATUS_COMPLETED in case of sucess else Error code in case of failure

chanHandle should be non NULL and valid pointer ioBuf should be non NULL and valid pointer

Not implemented

void Mcbsp_TxFifo | ( | int32_t | arg0,
|  | int32_t | arg1 |
| ) |  |  |

This function waits for the FIFO to be emptied(if enabled) and the TX empty bit to be set so that the TX section could be disabled when there is no data present.

Parameters:

  | arg0 | [IN] Handle to the TX channel
  | arg1 | [IN] unused

Returns:
  None

arg0 is a valid non null pointer

Not implemented

Copyright 2012, Texas Instruments Incorporated