//########################################################################### // // FILE: mcbsp.h // // TITLE: C28x McBSP driver. // //########################################################################### // $Copyright: // Copyright (C) 2022 Texas Instruments Incorporated - http://www.ti.com // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // // Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the // distribution. // // Neither the name of Texas Instruments Incorporated nor the names of // its contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // $ //########################################################################### #ifndef MCBSP_H #define MCBSP_H //***************************************************************************** // // If building with a C++ compiler, make all of the definitions in this header // have a C binding. // //***************************************************************************** #ifdef __cplusplus extern "C" { #endif //***************************************************************************** // //! \addtogroup mcbsp_api McBSP //! @{ // //***************************************************************************** #include "inc/hw_ints.h" #include "inc/hw_types.h" #include "inc/hw_mcbsp.h" #include "inc/hw_memmap.h" #include "debug.h" #include "interrupt.h" //***************************************************************************** // // Defines for the API. // //***************************************************************************** //***************************************************************************** // // Define to specify mask for setting the word and frame length in // McBSP_setTxDataSize() anf McBSP_setRxDataSize(). // //***************************************************************************** #define MCBSP_XCR1_M (MCBSP_XCR1_XWDLEN1_M | \ MCBSP_XCR1_XFRLEN1_M) #define MCBSP_RCR1_M (MCBSP_RCR1_RWDLEN1_M | \ MCBSP_RCR1_RFRLEN1_M) #define MCBSP_XCR2_M (MCBSP_XCR2_XWDLEN2_M | \ MCBSP_XCR2_XFRLEN2_M) #define MCBSP_RCR2_M (MCBSP_RCR2_RWDLEN2_M | \ MCBSP_RCR2_RFRLEN2_M) //***************************************************************************** // // Defines the values that can be returned by McBSP_getRxErrorStatus() when // there is an error in Rx. // //***************************************************************************** #define MCBSP_RX_NO_ERROR 0x0U //!< No error. #define MCBSP_RX_BUFFER_ERROR 0x4U //!< Buffer Full. #define MCBSP_RX_FRAME_SYNC_ERROR 0x8U //!< Frame sync error. #define MCBSP_RX_BUFFER_FRAME_SYNC_ERROR 0xCU //!< Buffer and frame sync error. //***************************************************************************** // // Defines the values that can be returned by McBSP_getTxErrorStatus() when // there is an error in Tx. // //***************************************************************************** #define MCBSP_TX_NO_ERROR 0x0U //!< No error. #define MCBSP_TX_BUFFER_ERROR 0x4U //!< Buffer overrun. #define MCBSP_TX_FRAME_SYNC_ERROR 0x8U //!< Frame sync error. #define MCBSP_TX_BUFFER_FRAME_SYNC_ERROR 0xCU //!< Buffer and frame sync error. //***************************************************************************** // // Values that can be returned by McBSP_configureTxMultichannel() and // McBSP_configureRxMultichannel(). // //***************************************************************************** #define MCBSP_ERROR_EXCEEDED_CHANNELS 0x1U //!< Exceeded number of channels. #define MCBSP_ERROR_2_PARTITION_A 0x2U //!< Error in 2 partition A setup. #define MCBSP_ERROR_2_PARTITION_B 0x4U //!< Error in 2 partition B setup. #define MCBSP_ERROR_INVALID_MODE 0x8U //!< Invalid mode. //***************************************************************************** // //! Values that can be passed to McBSP_setRxSignExtension() as the \e //! mode parameters. // //***************************************************************************** typedef enum { MCBSP_RIGHT_JUSTIFY_FILL_ZERO = 0x0000U, //!< Right justify and //!< zero fill MSB. MCBSP_RIGHT_JUSTIFY_FILL_SIGN = 0x2000U, //!< Right justified sign //!< extended into MSBs. MCBSP_LEFT_JUSTIFY_FILL_ZER0 = 0x4000U //!< Left justifies LBS //!< filled with zero. }McBSP_RxSignExtensionMode; //***************************************************************************** // //! Values that can be passed to McBSP_setClockStopMode() as the \e mode //! parameter. // //***************************************************************************** typedef enum { MCBSP_CLOCK_MCBSP_MODE = 0x0000U, //!< Disables clock stop mode. MCBSP_CLOCK_SPI_MODE_NO_DELAY = 0x1000U, //!< Enables clock stop mode. MCBSP_CLOCK_SPI_MODE_DELAY = 0x1800U //!< Enables clock stop mode //!< with half cycle delay. }McBSP_ClockStopMode; //***************************************************************************** // //! Values that can be passed to McBSP_setRxInterruptSource() as the //! \e interruptSource parameter. // //***************************************************************************** typedef enum { MCBSP_RX_ISR_SOURCE_SERIAL_WORD = 0x0000U, //!> 1U) << 7U)); } //***************************************************************************** // //! Configures transmitter input clock source for sample generator. //! //! \param base is the base address of the McBSP module. //! \param srgClockSource is clock source for the sample generator. //! //! This functions sets the clock source for the sample rate generator. //! Valid values for \e clockSource are //! - \b MCBSP_SRG_TX_CLOCK_SOURCE_LSPCLK for LSPCLK. //! - \b MCBSP_SRG_TX_CLOCK_SOURCE_MCLKR_PIN for external clock at MCLKR pin. //! MCLKX pin will be an output driven by sample rate generator. //! //! \return None. // //***************************************************************************** static inline void McBSP_setTxSRGClockSource(uint32_t base, const McBSP_SRGTxClockSource srgClockSource) { // // Check the arguments. // ASSERT(McBSP_isBaseValid(base)); // // Set or clear CLKSM bit. // HWREGH(base + MCBSP_O_SRGR2) = ((HWREGH(base + MCBSP_O_SRGR2) & ~MCBSP_SRGR2_CLKSM) | ((uint16_t)((uint16_t)srgClockSource & 0x1U) << 13U)); // // Set or clear SCLKME bit. // HWREGH(base + MCBSP_O_PCR) = ((HWREGH(base + MCBSP_O_PCR) & ~MCBSP_PCR_SCLKME) | (uint16_t)(((uint16_t)srgClockSource >> 1U) << 7U)); } //***************************************************************************** // //! Sets the mode for transmitter internal frame sync signal. //! //! \param base is the base address of the McBSP module. //! \param syncMode is the frame sync mode. //! //! This function sets the frame sync signal generation mode. The signal can be //! generated based on clock divider as set in McBSP_setFrameSyncPulsePeriod() //! function or when data is transferred from DXR registers to XSR registers. //! Valid input for syncMode are: //! //! - \b MCBSP_TX_INTERNAL_FRAME_SYNC_DATA - frame sync signal is //! generated when data is transferred from //! DXR registers to XSR registers. //! - \b MCBSP_TX_INTERNAL_FRAME_SYNC_SRG - frame sync signal is //! generated based on the clock counter //! value as defined in //! McBSP_setFrameSyncPulsePeriod() //! function. //! //! \return None. // //***************************************************************************** static inline void McBSP_setTxInternalFrameSyncSource(uint32_t base, const McBSP_TxInternalFrameSyncSource syncMode) { // // Check the arguments. // ASSERT(McBSP_isBaseValid(base)); // // Set or clear FSGM bit. // HWREGH(base + MCBSP_O_SRGR2) = ((HWREGH(base + MCBSP_O_SRGR2) & ~MCBSP_SRGR2_FSGM) | (uint16_t)syncMode); } //***************************************************************************** // //! Set Multichannel receiver partitions. //! //! \param base is the base address of the McBSP module. //! \param partition is the number of partitions. //! //! This function sets the partitions for Multichannel receiver. Valid values //! for partition are \b MCBSP_MULTICHANNEL_TWO_PARTITION or \b //! MCBSP_MULTICHANNEL_EIGHT_PARTITION for 2 and 8 partitions respectively. //! //! \return None. // //***************************************************************************** static inline void McBSP_setRxMultichannelPartition(uint32_t base, const McBSP_MultichannelPartition partition) { // // Check the arguments. // ASSERT(McBSP_isBaseValid(base)); // // Set or Clear RMCME bit. // HWREGH(base + MCBSP_O_MCR1) = ((HWREGH(base + MCBSP_O_MCR1) & ~MCBSP_MCR1_RMCME) | (uint16_t)partition); } //***************************************************************************** // //! Sets block to receiver in two partition configuration. //! //! \param base is the base address of the McBSP module. //! \param block is the block to assign to the partition. //! //! This function assigns the block the user provides to the appropriate //! receiver partition. //! If user sets the value of block to 0,2,4 or 6 the API will assign the //! blocks to partition A. If values 1,3,5,or 7 are set to block, then //! the API assigns the block to partition B. //! //! \note This function should be used with the two partition configuration //! only and not with eight partition configuration. //! //! \return None. // //***************************************************************************** static inline void McBSP_setRxTwoPartitionBlock(uint32_t base, const McBSP_PartitionBlock block) { // // Check the arguments. // ASSERT(McBSP_isBaseValid(base)); // //Check the block value if it is 0,2,4,6 or 1,3,5,7. // if(((uint16_t)block == 0U) || ((uint16_t)block == 2U) || ((uint16_t)block == 4U) || ((uint16_t)block == 6U)) { // // write to RPABLK bits. // HWREGH(base + MCBSP_O_MCR1) = ((HWREGH(base + MCBSP_O_MCR1) & ~MCBSP_MCR1_RPABLK_M) | (uint16_t)(((uint16_t)block >> 1U)<< 5U)); } else { // // write to RPBBLK bits. // HWREGH(base + MCBSP_O_MCR1) = ((HWREGH(base + MCBSP_O_MCR1) & ~MCBSP_MCR1_RPBBLK_M) | (uint16_t)(((uint16_t)block >> 1U)<< 7U)); } } //***************************************************************************** // //! Returns the current active receiver block number. //! //! \param base is the base address of the McBSP module. //! //! This function returns the current active receiver block involved in McBSP //! reception. //! //! \return Active block in McBSP reception. Returned values range from 0 to 7 //! representing the respective active block number . // //***************************************************************************** static inline uint16_t McBSP_getRxActiveBlock(uint32_t base) { // // Check the arguments. // ASSERT(McBSP_isBaseValid(base)); // // return RCBLK bits. // return((HWREGH(base + MCBSP_O_MCR1) & MCBSP_MCR1_RCBLK_M) >> MCBSP_MCR1_RCBLK_S); } //***************************************************************************** // //! Configure channel selection mode for receiver. //! //! \param base is the base address of the McBSP module. //! \param channelMode is the channel selection mode. //! //! This function configures the channel selection mode. The following are //! valid values for channelMode: //! //! - \b MCBSP_ALL_RX_CHANNELS_ENABLED - enables all channels. //! - \b MCBSP_RX_CHANNEL_SELECTION_ENABLED - lets the user enable desired //! channels by using McBSP_enableRxChannel(). //! //! \return None. // //***************************************************************************** static inline void McBSP_setRxChannelMode(uint32_t base, const McBSP_RxChannelMode channelMode) { // // Check the arguments. // ASSERT(McBSP_isBaseValid(base)); // // Set or clear RMCM bit. // HWREGH(base + MCBSP_O_MCR1) = ((HWREGH(base + MCBSP_O_MCR1) & ~MCBSP_MCR1_RMCM) | (uint16_t)channelMode); } //***************************************************************************** // //! Set Multichannel transmitter partitions. //! //! \param base is the base address of the McBSP module. //! \param partition is the number of partitions. //! //! This function sets the partitions for Multichannel transmitter. Valid //! values for partition are \b MCBSP_MULTICHANNEL_TWO_PARTITION or \b //! MCBSP_MULTICHANNEL_EIGHT_PARTITION for 2 and 8 partitions respectively. //! //! \return None. // //***************************************************************************** static inline void McBSP_setTxMultichannelPartition(uint32_t base, const McBSP_MultichannelPartition partition) { // // Check the arguments. // ASSERT(McBSP_isBaseValid(base)); // // Set or clear XMCME bit. // HWREGH(base + MCBSP_O_MCR2) = ((HWREGH(base + MCBSP_O_MCR2) & ~MCBSP_MCR2_XMCME) | (uint16_t)partition); } //***************************************************************************** // //! Sets block to transmitter in two partition configuration. //! //! \param base is the base address of the McBSP module. //! \param block is the block to assign to the partition. //! //! This function assigns the block the user provides to the appropriate //! transmitter partition. //! If user sets the value of block to 0,2,4 or 6 the API will assign the //! blocks to partition A. If values 1,3,5,or 7 are set to block, then //! the API assigns the block to partition B. //! //! \note This function should be used with the two partition configuration //! only and not with eight partition configuration. //! //! \return None. // //***************************************************************************** static inline void McBSP_setTxTwoPartitionBlock(uint32_t base, const McBSP_PartitionBlock block) { // // Check the arguments. // ASSERT(McBSP_isBaseValid(base)); if(((uint16_t)block == 0U) || ((uint16_t)block == 2U) || ((uint16_t)block == 4U) || ((uint16_t)block == 6U)) { // // write to XPABLK bits. // HWREGH(base + MCBSP_O_MCR2) = ((HWREGH(base + MCBSP_O_MCR2) & ~MCBSP_MCR2_XPABLK_M) | ((uint16_t)((uint16_t)block >> 1U)<< 5U)); } else { // // write to XPBBLK bits. // HWREGH(base + MCBSP_O_MCR2) = ((HWREGH(base + MCBSP_O_MCR2) & ~MCBSP_MCR2_XPBBLK_M) | ((uint16_t)((uint16_t)block >> 1U)<< 7U)); } } //***************************************************************************** // //! Returns the current active transmitter block number. //! //! \param base is the base address of the McBSP module. //! //! This function returns the current active transmitter block involved in //! McBSP transmission. //! //! \return Active block in McBSP transmission. Returned values range from //! 0 to 7 representing the respective active block number. // //***************************************************************************** static inline uint16_t McBSP_getTxActiveBlock(uint32_t base) { // // Check the arguments. // ASSERT(McBSP_isBaseValid(base)); // // return XCBLK bits. // return((HWREGH(base + MCBSP_O_MCR2) & MCBSP_MCR2_XCBLK_M) >> MCBSP_MCR2_XCBLK_S); } //***************************************************************************** // //! Configure channel selection mode for transmitter. //! //! \param base is the base address of the McBSP module. //! \param channelMode is the channel selection mode. //! //! This function configures the channel selection mode. The following are //! valid values for channelMode: //! //! - \b MCBSP_ALL_TX_CHANNELS_ENABLED - enables and unmasks all channels //! - \b MCBSP_TX_CHANNEL_SELECTION_ENABLED - lets the user enable and unmask //! desired channels by using McBSP_enableTxChannel() //! - \b MCBSP_ENABLE_MASKED_TX_CHANNEL_SELECTION - All channels enables but //! until enabled by McBSP_enableTxChannel() //! - \b MCBSP_SYMMERTIC_RX_TX_SELECTION - Symmetric transmission and //! reception. //! //! \return None. // //***************************************************************************** static inline void McBSP_setTxChannelMode(uint32_t base, const McBSP_TxChannelMode channelMode) { // // Check the arguments. // ASSERT(McBSP_isBaseValid(base)); // // Set values to the XMCM bits. // HWREGH(base + MCBSP_O_MCR2) = ((HWREGH(base + MCBSP_O_MCR2) & ~MCBSP_MCR2_XMCM_M) | (uint16_t)channelMode); } //***************************************************************************** // //! Select the transmitter frame sync signal source. //! //! \param base is the base address of the McBSP module. //! \param syncSource is the transmitter frame sync source. //! //! This function sets external or internal sync signal source based on the //! syncSource selection. Valid input for syncSource are: //! //! - \b MCBSP_TX_EXTERNAL_FRAME_SYNC_SOURCE - frame sync signal is supplied //! externally by pin FSX. //! - \b MCBSP_TX_INTERNAL_FRAME_SYNC_SOURCE - frame sync signal is supplied //! internally. //! //! \return None. // //***************************************************************************** static inline void McBSP_setTxFrameSyncSource(uint32_t base, const McBSP_TxFrameSyncSource syncSource) { // // Check the arguments. // ASSERT(McBSP_isBaseValid(base)); // //Set or Clear the FSXM bit. // HWREGH(base + MCBSP_O_PCR) = ((HWREGH(base + MCBSP_O_PCR) & ~MCBSP_PCR_FSXM) | (uint16_t)syncSource); } //***************************************************************************** // //! Select receiver frame sync signal source. //! //! \param base is the base address of the McBSP module. //! \param syncSource is the receiver frame sync source. //! //! This function sets external or internal sync signal source based on the //! syncSource selection. Valid input for syncSource are: //! //! - \b MCBSP_RX_EXTERNAL_FRAME_SYNC_SOURCE - frame sync signal is supplied //! externally by pin FSR. //! - \b MCBSP_RX_INTERNAL_FRAME_SYNC_SOURCE - frame sync signal is supplied //! by SRG. //! //! \return None. // //***************************************************************************** static inline void McBSP_setRxFrameSyncSource(uint32_t base, const McBSP_RxFrameSyncSource syncSource) { // // Check the arguments. // ASSERT(McBSP_isBaseValid(base)); // // Set or clear FSRM bit. // HWREGH(base + MCBSP_O_PCR) = ((HWREGH(base + MCBSP_O_PCR) & ~MCBSP_PCR_FSRM) | (uint16_t)syncSource); } //***************************************************************************** // //! Configures the Transmit clock source. //! //! \param base is the base address of the McBSP module. //! \param clockSource is clock source for the transmission pin. //! //! This function configures the clock source for the transmitter. Valid input //! for rxClockSource are: //! - \b MCBSP_INTERNAL_TX_CLOCK_SOURCE - internal clock source. SRG is the //! source. //! - \b MCBSP_EXTERNAL_TX_CLOCK_SOURCE - external clock source. //! //! \return None. // //***************************************************************************** static inline void McBSP_setTxClockSource(uint32_t base, const McBSP_TxClockSource clockSource) { // // Check the arguments. // ASSERT(McBSP_isBaseValid(base)); // // Set or clear CLKXM bit. // HWREGH(base + MCBSP_O_PCR) = ((HWREGH(base + MCBSP_O_PCR) & ~MCBSP_PCR_CLKXM ) | (uint16_t)clockSource); } //***************************************************************************** // //! Configures the Receive clock source. //! //! \param base is the base address of the McBSP module. //! \param clockSource is clock source for the reception pin. //! //! This function configures the clock source for the receiver. Valid input //! for base are: //! - \b MCBSP_INTERNAL_RX_CLOCK_SOURCE - internal clock source. Sample Rate //! Generator will be used. //! - \b MCBSP_EXTERNAL_RX_CLOCK_SOURCE - external clock will drive the data. //! //! \return None. // //***************************************************************************** static inline void McBSP_setRxClockSource(uint32_t base, const McBSP_RxClockSource clockSource) { // // Check the arguments. // ASSERT(McBSP_isBaseValid(base)); // // Set or clear CLKRM bit. // HWREGH(base + MCBSP_O_PCR) = ((HWREGH(base + MCBSP_O_PCR) & ~MCBSP_PCR_CLKRM) | (uint16_t)clockSource); } //***************************************************************************** // //! Sets transmitter frame sync polarity. //! //! \param base is the base address of the McBSP module. //! \param syncPolarity is the polarity of frame sync pulse. //! //! This function sets the polarity (rising or falling edge)of the frame sync //! on FSX pin. Use \b MCBSP_TX_FRAME_SYNC_POLARITY_LOW for active low //! frame sync pulse and \b MCBSP_TX_FRAME_SYNC_POLARITY_HIGH for active //! high sync pulse. //! //! \return None. // //***************************************************************************** static inline void McBSP_setTxFrameSyncPolarity(uint32_t base, const McBSP_TxFrameSyncPolarity syncPolarity) { // // Check the arguments. // ASSERT(McBSP_isBaseValid(base)); // // Set or clear FSXP bit. // HWREGH(base + MCBSP_O_PCR) = ((HWREGH(base + MCBSP_O_PCR) & ~MCBSP_PCR_FSXP) | (uint16_t)syncPolarity); } //***************************************************************************** //! Sets receiver frame sync polarity. //! //! \param base is the base address of the McBSP module. //! \param syncPolarity is the polarity of frame sync pulse. //! //! This function sets the polarity (rising or falling edge)of the frame sync //! on FSR pin. Use \b MCBSP_RX_FRAME_SYNC_POLARITY_LOW for active low //! frame sync pulse and \b MCBSP_RX_FRAME_SYNC_POLARITY_HIGH for active //! high sync pulse. //! //! \return None. // //***************************************************************************** static inline void McBSP_setRxFrameSyncPolarity(uint32_t base, const McBSP_RxFrameSyncPolarity syncPolarity) { // // Check the arguments. // ASSERT(McBSP_isBaseValid(base)); // // Set or clear FSRP bit. // HWREGH(base + MCBSP_O_PCR) = ((HWREGH(base + MCBSP_O_PCR) & ~MCBSP_PCR_FSRP) | (uint16_t)syncPolarity); } //***************************************************************************** //! Sets transmitter clock polarity when using external clock source. //! //! \param base is the base address of the McBSP module. //! \param clockPolarity is the polarity of external clock. //! //! This function sets the polarity (rising or falling edge) of the transmitter //! clock on MCLKX pin. //! Valid values for clockPolarity are: //! - \b MCBSP_TX_POLARITY_RISING_EDGE for rising edge. //! - \b MCBSP_TX_POLARITY_FALLING_EDGE for falling edge. //! //! \return None. // //***************************************************************************** static inline void McBSP_setTxClockPolarity(uint32_t base, const McBSP_TxClockPolarity clockPolarity) { // // Check the arguments. // ASSERT(McBSP_isBaseValid(base)); // // Clear CLKXP bit first , then set or clear CLKXP bit. // HWREGH(base + MCBSP_O_PCR) = ((HWREGH(base + MCBSP_O_PCR) & ~MCBSP_PCR_CLKXP) | (uint16_t)clockPolarity); } //***************************************************************************** //! Sets receiver clock polarity when using external clock source. //! //! \param base is the base address of the McBSP module. //! \param clockPolarity is the polarity of external clock. //! //! This function sets the polarity (rising or falling edge) of the receiver //! clock on MCLKR pin. If external clock is used, the polarity will affect //! CLKG signal. //! Valid values for clockPolarity are: //! - \b MCBSP_RX_POLARITY_RISING_EDGE for rising edge. //! - \b MCBSP_RX_POLARITY_FALLING_EDGE for falling edge. //! //! \return None. // //***************************************************************************** static inline void McBSP_setRxClockPolarity(uint32_t base, const McBSP_RxClockPolarity clockPolarity) { // // Check the arguments. // ASSERT(McBSP_isBaseValid(base)); // // Clear CLKRP bit first , then set or clear CLKRP bit. // HWREGH(base + MCBSP_O_PCR) = ((HWREGH(base + MCBSP_O_PCR) & ~MCBSP_PCR_CLKRP) | (uint16_t)clockPolarity); } //***************************************************************************** // //! Read 8,12 or 16 bit data word from McBSP data receive registers. //! //! \param base is the base address of the McBSP port. //! //! This function returns the data value in data receive register. //! //! \return received data. // //***************************************************************************** static inline uint16_t McBSP_read16bitData(uint32_t base) { // // Check the arguments. // ASSERT(McBSP_isBaseValid(base)); // // Read DRR1 register. // return(HWREGH(base + MCBSP_O_DRR1)); } //***************************************************************************** // //! Read 20, 24 or 32 bit data word from McBSP data receive registers. //! //! \param base is the base address of the McBSP port. //! //! This function returns the data values in data receive registers. //! //! \return received data. // //***************************************************************************** static inline uint32_t McBSP_read32bitData(uint32_t base) { // // Check the arguments. // ASSERT(McBSP_isBaseValid(base)); // // Read DDR1 register and return DDR2:DDR1. // return((((uint32_t)HWREGH(base + MCBSP_O_DRR2) << 16U) | HWREGH(base + MCBSP_O_DRR1))); } //***************************************************************************** // //! Write 8,12 or 16 bit data word to McBSP data transmit registers. //! //! \param base is the base address of the McBSP port. //! \param data is the data to be written. //! //! This function writes 8,12 or 16 bit data to data transmit register. //! //! \return None. // //***************************************************************************** static inline void McBSP_write16bitData(uint32_t base, uint16_t data) { // // Check the arguments. // ASSERT(McBSP_isBaseValid(base)); // // Write to DXR1 register. // HWREGH(base + MCBSP_O_DXR1) = data; } //***************************************************************************** // //! Write 20, 24 or 32 bit data word to McBSP data transmit registers. //! //! \param base is the base address of the McBSP port. //! \param data is the data to be written. //! //! This function writes 20, 24 or 32 bit data to data transmit registers. //! //! \return None. // //***************************************************************************** static inline void McBSP_write32bitData(uint32_t base, uint32_t data) { // // Check the arguments. // ASSERT(McBSP_isBaseValid(base)); // // Write to DXR2 register first. // HWREGH(base + MCBSP_O_DXR2) = data >> 16U; // // Write to DXR1 register. // HWREGH(base + MCBSP_O_DXR1) = data & 0xFFFFU; } //***************************************************************************** // //! Return left justified for data for U Law or A Law companding. //! //! \param data is the 14 bit word. //! \param compandingType specifies the type comapnding desired. //! //! This functions returns U law or A law adjusted word. //! //! \return U law or A law left justified word. // //***************************************************************************** static inline uint16_t McBSP_getLeftJustifyData(uint16_t data, const McBSP_CompandingType compandingType) { return(data << (uint16_t)compandingType); } //***************************************************************************** // //! Enable Recieve Interrupt. //! //! \param base is the base address of the McBSP module. //! //! This function enables Recieve Interrupt on RRDY. //! //! \return None. // //***************************************************************************** static inline void McBSP_enableRxInterrupt(uint32_t base) { // // Check the arguments. // ASSERT(McBSP_isBaseValid(base)); // // Set RINT ENA bit. // HWREGH(base + MCBSP_O_MFFINT) |= MCBSP_MFFINT_RINT; } //***************************************************************************** // //! Disable Recieve Interrupt. //! //! \param base is the base address of the McBSP module. //! //! This function disables Recieve Interrupt on RRDY. //! //! \return None. // //***************************************************************************** static inline void McBSP_disableRxInterrupt(uint32_t base) { // // Check the arguments. // ASSERT(McBSP_isBaseValid(base)); // // Clear RINT ENA bit. // HWREGH(base + MCBSP_O_MFFINT) |= ~(MCBSP_MFFINT_RINT); } //***************************************************************************** // //! Enable Transmit Interrupt. //! //! \param base is the base address of the McBSP module. //! //! This function enables Transmit Interrupt on XRDY. //! //! \return None. // //***************************************************************************** static inline void McBSP_enableTxInterrupt(uint32_t base) { // // Check the arguments. // ASSERT(McBSP_isBaseValid(base)); // // Set XINT ENA bit. // HWREGH(base + MCBSP_O_MFFINT) |= MCBSP_MFFINT_XINT; } //***************************************************************************** // //! Disable Transmit Interrupt. //! //! \param base is the base address of the McBSP module. //! //! This function disables Transmit Interrupt on XRDY. //! //! \return None. // //***************************************************************************** static inline void McBSP_disableTxInterrupt(uint32_t base) { // // Check the arguments. // ASSERT(McBSP_isBaseValid(base)); // // Clear XINT ENA bit. // HWREGH(base + MCBSP_O_MFFINT) |= ~(MCBSP_MFFINT_XINT); } //***************************************************************************** // //! Write 8,12 or 16 bit data word to McBSP data transmit registers //! //! \param base is the base address of the McBSP port. //! \param data is the data to be written. //! //! This function sends 16 bit or less data to the transmitter buffer. //! //! \return None. //! //! \return None. // //***************************************************************************** extern void McBSP_transmit16BitDataNonBlocking(uint32_t base, uint16_t data); //***************************************************************************** // //! Write 8,12 or 16 bit data word to McBSP data transmit registers //! //! \param base is the base address of the McBSP port. //! \param data is the data to be written. //! //! This function sends 16 bit or less data to the transmitter buffer. If //! transmit buffer is not ready the function will wait until transmit buffer //! is empty. If the transmitter buffer is empty the data will be written to //! the data registers. //! //! \return None. // //***************************************************************************** extern void McBSP_transmit16BitDataBlocking(uint32_t base, uint16_t data); //***************************************************************************** // //! Write 20 , 24 or 32 bit data word to McBSP data transmit registers //! //! \param base is the base address of the McBSP port. //! \param data is the data to be written. //! //! This function sends 20 , 24 or 32 bit data to the transmitter buffer. If //! the transmitter buffer is empty the data will be written to the data //! registers. //! //! \return None. // //***************************************************************************** extern void McBSP_transmit32BitDataNonBlocking(uint32_t base, uint32_t data); //***************************************************************************** // //! Write 20 , 24 or 32 bit data word to McBSP data transmit registers //! //! \param base is the base address of the McBSP port. //! \param data is the data to be written. //! //! This function sends 20 , 24 or 32 bit data to the transmitter buffer. If //! transmit buffer is not ready the function will wait until transmit buffer //! is empty. If the transmitter buffer is empty the data will be written //! to the data registers. //! //! \return None. // //***************************************************************************** extern void McBSP_transmit32BitDataBlocking(uint32_t base, uint32_t data); //***************************************************************************** // //! Read 8,12 or 16 bit data word from McBSP data receive registers //! //! \param base is the base address of the McBSP port. //! \param receiveData is the pointer to the receive data. //! //! This function reads 8,12 or 16 bit data from the receiver buffer. //! If the receiver buffer has new data, the data will be read. //! //! \return None. // //***************************************************************************** extern void McBSP_receive16BitDataNonBlocking(uint32_t base, uint16_t *receiveData); //***************************************************************************** // //! Read 8,12 or 16 bit data word from McBSP data receive registers //! //! \param base is the base address of the McBSP port. //! \param receiveData is the pointer to the receive data. //! //! This function reads 8,12 or 16 bit data from the receiver buffer. If //! receiver buffer is not ready the function will wait until receiver buffer //! has new data. //! If the receiver buffer has new data, the data will be read. //! //! \return None. // //***************************************************************************** extern void McBSP_receive16BitDataBlocking(uint32_t base, uint16_t *receiveData); //***************************************************************************** // //! Read 20, 24 or 32 bit data word from McBSP data receive registers //! //! \param base is the base address of the McBSP port. //! \param receiveData is the pointer to the receive data. //! //! This function reads 20, 24 or 32 bit data from the receiver buffer. //! If the receiver buffer has new data, the data will be read. //! //! \return None. // //***************************************************************************** extern void McBSP_receive32BitDataNonBlocking(uint32_t base, uint32_t *receiveData); //***************************************************************************** // //! Read 20, 24 or 32 bit data word from McBSP data receive registers //! //! \param base is the base address of the McBSP port. //! \param receiveData is the pointer to the receive data. //! //! This function reads 20, 24 or 32 bit data from the receiver buffer. If //! receiver buffer is not ready the function will wait until receiver buffer //! has new data. //! If the receiver buffer has new data, the data will be read. //! //! \return None. // //***************************************************************************** extern void McBSP_receive32BitDataBlocking(uint32_t base, uint32_t *receiveData); //***************************************************************************** // //! Sets number of words per frame and bits per word for data Reception. //! //! \param base is the base address of the McBSP module. //! \param dataFrame is the data frame phase. //! \param bitsPerWord is the number of bits per word. //! \param wordsPerFrame is the number of words per frame per phase. //! //! This function sets the number of bits per word and the number of words per //! frame for the given phase. //! Valid inputs for phase are \b MCBSP_PHASE_ONE_FRAME or \b //! MCBSP_PHASE_TWO_FRAME representing the first or second frame phase //! respectively. Valid value for bitsPerWord are: //! - \b MCBSP_BITS_PER_WORD_8 8 bit word. //! - \b MCBSP_BITS_PER_WORD_12 12 bit word. //! - \b MCBSP_BITS_PER_WORD_16 16 bit word. //! - \b MCBSP_BITS_PER_WORD_20 20 bit word. //! - \b MCBSP_BITS_PER_WORD_24 24 bit word. //! - \b MCBSP_BITS_PER_WORD_32 32 bit word. //! The maximum value for wordsPerFrame is 127 (128 - 1)representing 128 words. //! //! \return None. // //***************************************************************************** extern void McBSP_setRxDataSize(uint32_t base, const McBSP_DataPhaseFrame dataFrame, const McBSP_DataBitsPerWord bitsPerWord, uint16_t wordsPerFrame); //***************************************************************************** // //! Sets number of words per frame and bits per word for data Transmission. //! //! \param base is the base address of the McBSP module. //! \param dataFrame is the data frame phase. //! \param bitsPerWord is the number of bits per word. //! \param wordsPerFrame is the number of words per frame per phase. //! //! This function sets the number of bits per word and the number of words per //! frame for the given phase. //! Valid inputs for phase are \b MCBSP_PHASE_ONE_FRAME or \b //! MCBSP_PHASE_TWO_FRAME representing single or dual phase respectively. //! Valid values for bitsPerWord are: //! - \b MCBSP_BITS_PER_WORD_8 8 bit word. //! - \b MCBSP_BITS_PER_WORD_12 12 bit word. //! - \b MCBSP_BITS_PER_WORD_16 16 bit word. //! - \b MCBSP_BITS_PER_WORD_20 20 bit word. //! - \b MCBSP_BITS_PER_WORD_24 24 bit word. //! - \b MCBSP_BITS_PER_WORD_32 32 bit word. //! The maximum value for wordsPerFrame is 127 (128 - 1)representing 128 words. //! //! \return None. // //***************************************************************************** extern void McBSP_setTxDataSize(uint32_t base, const McBSP_DataPhaseFrame dataFrame, const McBSP_DataBitsPerWord bitsPerWord, uint16_t wordsPerFrame); //***************************************************************************** // //! Disables a channel in an eight partition receiver //! //! \param base is the base address of the McBSP module. //! \param partition is the partition of the channel. //! \param channel is the receiver channel number to be enabled. //! //! This function disables the given receiver channel number for the partition //! provided. //! Valid values for partition are \b MCBSP_MULTICHANNEL_TWO_PARTITION or //! \b MCBSP_MULTICHANNEL_EIGHT_PARTITION for 2 or 8 partitions respectively. //! Valid values for channel range from 0 to 127. //! //! \return None. // //***************************************************************************** extern void McBSP_disableRxChannel(uint32_t base, const McBSP_MultichannelPartition partition, uint16_t channel); //***************************************************************************** // //! Enables a channel for eight partition receiver //! //! \param base is the base address of the McBSP module. //! \param partition is the partition of the channel. //! \param channel is the receiver channel number to be enabled. //! //! This function enables the given receiver channel number for the partition //! provided. //! Valid values for partition are \b MCBSP_MULTICHANNEL_TWO_PARTITION or //! \b MCBSP_MULTICHANNEL_EIGHT_PARTITION for 2 or 8 partitions respectively. //! Valid values for channel range from 0 to 127. //! //! \return None. // //***************************************************************************** extern void McBSP_enableRxChannel(uint32_t base, const McBSP_MultichannelPartition partition, uint16_t channel); //***************************************************************************** // //! Disables a channel in an eight partition transmitter //! //! \param base is the base address of the McBSP module. //! \param partition is the partition of the channel. //! \param channel is the transmitter channel number to be enabled. //! //! This function disables the given transmitter channel number for the //! partition provided. //! Valid values for partition are \b MCBSP_MULTICHANNEL_TWO_PARTITION or //! \b MCBSP_MULTICHANNEL_EIGHT_PARTITION for 2 or 8 partitions respectively. //! Valid values for channel range from 0 to 127. //! //! \return None. // //***************************************************************************** extern void McBSP_disableTxChannel(uint32_t base, const McBSP_MultichannelPartition partition, uint16_t channel); //***************************************************************************** // //! Enables a channel for eight partition transmitter //! //! \param base is the base address of the McBSP module. //! \param partition is the partition of the channel. //! \param channel is the transmitter channel number to be enabled. //! //! This function enables the given transmitter channel number for the //! partition provided. //! Valid values for partition are \b MCBSP_MULTICHANNEL_TWO_PARTITION or //! \b MCBSP_MULTICHANNEL_EIGHT_PARTITION for 2 or 8 partitions respectively. //! Valid values for channel range from 0 to 127. //! //! \return None. // //***************************************************************************** extern void McBSP_enableTxChannel(uint32_t base, const McBSP_MultichannelPartition partition, uint16_t channel); //***************************************************************************** // //! Configures transmitter clock //! //! \param base is the base address of the McBSP module. //! \param ptrClockParams is a pointer to a structure containing \e clock //! parameters McBSP_ClockParams. //! This function sets up the transmitter clock. The following are valid //! values and ranges for the parameters of the McBSP_TxFsyncParams. //! - \b clockSRGSyncFSR - true to sync with signal on FSR pin, //! false to ignore signal on FSR pin. //! the pulse on FSR pin. //! - \b clockSRGDivider - Maximum valid value is 255. //! - \b clockSource - MCBSP_EXTERNAL_TX_CLOCK_SOURCE or //! MCBSP_INTERNAL_TX_CLOCK_SOURCE //! - \b clockTxSRGSource - MCBSP_SRG_TX_CLOCK_SOURCE_LSPCLK or //! MCBSP_SRG_TX_CLOCK_SOURCE_MCLKR_PIN //! - \b clockMCLKXPolarity - Output polarity on MCLKX pin. //! - MCBSP_TX_POLARITY_RISING_EDGE //! - MCBSP_TX_POLARITY_FALLING_EDGE //! - \b clockMCLKRPolarity - Input polarity on MCLKR pin (if SRG is //! sourced from MCLKR pin). //! - MCBSP_RX_POLARITY_FALLING_EDGE //! - MCBSP_RX_POLARITY_RISING_EDGE //! //! \note Make sure the clock divider is such that, the McBSP clock is not //! running faster than 1/2 the speed of the source clock. //! //! \return None. // //***************************************************************************** extern void McBSP_configureTxClock(uint32_t base, const McBSP_ClockParams * ptrClockParams); //***************************************************************************** // //! Configures receiver clock //! //! \param base is the base address of the McBSP module. //! \param ptrClockParams is a pointer to a structure containing \e clock //! parameters McBSP_ClockParams. //! This function sets up the receiver clock. The following are valid //! values and ranges for the parameters of the McBSP_TxFsyncParams. //! - \b clockSRGSyncFlag - true to sync with signal on FSR pin, false to //! ignore the pulse on FSR pin. //! - \b clockSRGDivider - Maximum valid value is 255. //! - \b clockSource - MCBSP_EXTERNAL_RX_CLOCK_SOURCE or //! MCBSP_INTERNAL_RX_CLOCK_SOURCE //! - \b clockRxSRGSource - MCBSP_SRG_RX_CLOCK_SOURCE_LSPCLK or //! MCBSP_SRG_RX_CLOCK_SOURCE_MCLKX_PIN //! - \b clockMCLKRPolarity- output polarity on MCLKR pin. //! - MCBSP_RX_POLARITY_FALLING_EDGE or //! - MCBSP_RX_POLARITY_RISING_EDGE //! - \b clockMCLKXPolarity- Input polarity on MCLKX pin (if SRG is sourced //! from MCLKX pin). //! - MCBSP_TX_POLARITY_RISING_EDGE or //! - MCBSP_TX_POLARITY_FALLING_EDGE //! //! \note Make sure the clock divider is such that, the McBSP clock is not //! running faster than 1/2 the speed of the source clock. //! //! \return None. // //***************************************************************************** extern void McBSP_configureRxClock(uint32_t base, const McBSP_ClockParams * ptrClockParams); //***************************************************************************** // //! Configures transmitter frame sync. //! //! \param base is the base address of the McBSP module. //! \param ptrFsyncParams is a pointer to a structure containing \e frame sync //! parameters McBSPTxFsyncParams. //! This function sets up the transmitter frame sync. The following are valid //! values and ranges for the parameters of the McBSPTxFsyncParams. //! - \b syncSRGSyncFSRFlag - true to sync with signal on FSR pin, false to //! ignore the pulse on FSR pin.This value has to //! be similar to the value of //! McBSP_ClockParams.clockSRGSyncFlag. //! - \b syncErrorDetect - true to enable frame sync error detect. false //! to disable. //! - \b syncClockDivider - Maximum valid value is 4095. //! - \b syncPulseDivider - Maximum valid value is 255. //! - \b syncSourceTx - MCBSP_TX_INTERNAL_FRAME_SYNC_SOURCE or //! MCBSP_TX_EXTERNAL_FRAME_SYNC_SOURCE //! - \b syncIntSource - MCBSP_TX_INTERNAL_FRAME_SYNC_DATA or //! MCBSP_TX_INTERNAL_FRAME_SYNC_SRG //! - \b syncFSXPolarity - MCBSP_TX_FRAME_SYNC_POLARITY_LOW or //! MCBSP_TX_FRAME_SYNC_POLARITY_HIGH. //! //! \return None. // //***************************************************************************** extern void McBSP_configureTxFrameSync(uint32_t base, const McBSP_TxFsyncParams * ptrFsyncParams); //***************************************************************************** // //! Configures receiver frame sync. //! //! \param base is the base address of the McBSP module. //! \param ptrFsyncParams is a pointer to a structure containing \e frame sync //! parameters McBSP_RxFsyncParams. //! This function sets up the receiver frame sync. The following are valid //! values and ranges for the parameters of the McBSPTxFsyncParams. //! - \b syncSRGSyncFSRFlag - true to sync with signal on FSR pin, //! false to ignore the pulse on FSR pin. //! This value has to be similar to the value of //! McBSP_ClockParams.clockSRGSyncFlag. //! - \b syncErrorDetect - true to enable frame sync error detect. //! false to disable. //! - \b syncClockDivider - Maximum valid value is 4095. //! - \b syncPulseDivider - Maximum valid value is 255. //! - \b syncSourceRx - MCBSP_RX_INTERNAL_FRAME_SYNC_SOURCE or //! MCBSP_RX_EXTERNAL_FRAME_SYNC_SOURCE //! - \b syncFSRPolarity - MCBSP_RX_FRAME_SYNC_POLARITY_LOW or //! MCBSP_RX_FRAME_SYNC_POLARITY_HIGH //! //! \return None. // //***************************************************************************** extern void McBSP_configureRxFrameSync(uint32_t base, const McBSP_RxFsyncParams * ptrFsyncParams); //***************************************************************************** // //! Configures transmitter data format. //! //! \param base is the base address of the McBSP module. //! \param ptrDataParams is a pointer to a structure containing \e data format //! parameters McBSPTxDataParams. //! This function sets up the transmitter data format and properties. The //! following are valid values and ranges for the parameters of the //! McBSPTxDataParams. //! - \b loopbackModeFlag - true for digital loop-back mode. //! false for no loop-back mode. //! - \b twoPhaseModeFlag - true for two phase mode. //! false for single phase mode. //! - \b pinDelayEnableFlag - true to enable DX pin delay. //! false to disable DX pin delay. //! - \b phase1FrameLength - maximum value of 127. //! - \b phase2FrameLength - maximum value of 127. //! - \b clockStopMode - MCBSP_CLOCK_SPI_MODE_NO_DELAY or //! MCBSP_CLOCK_SPI_MODE_DELAY //! - \b phase1WordLength - MCBSP_BITS_PER_WORD_x , x = 8,12,16,20,24,32 //! - \b phase2WordLength - MCBSP_BITS_PER_WORD_x , x = 8,12,16,20,24,32 //! - \b compandingMode - MCBSP_COMPANDING_NONE, //! MCBSP_COMPANDING_NONE_LSB_FIRST //! MCBSP_COMPANDING_U_LAW_SET or //! MCBSP_COMPANDING_A_LAW_SET. //! - \b dataDelayBits - MCBSP_DATA_DELAY_BIT_0, //! MCBSP_DATA_DELAY_BIT_1 or //! MCBSP_DATA_DELAY_BIT_2 //! - \b interruptMode - MCBSP_TX_ISR_SOURCE_TX_READY, //! MCBSP_TX_ISR_SOURCE_END_OF_BLOCK, //! MCBSP_TX_ISR_SOURCE_FRAME_SYNC or //! MCBSP_TX_ISR_SOURCE_SYNC_ERROR //! //! \b Note - When using companding,phase1WordLength and phase2WordLength //! must be 8 bits wide. //! //! \return None. // //***************************************************************************** extern void McBSP_configureTxDataFormat(uint32_t base, const McBSP_TxDataParams * ptrDataParams); //***************************************************************************** // //! Configures receiver data format. //! //! \param base is the base address of the McBSP module. //! \param ptrDataParams is a pointer to a structure containing data format //! parameters McBSP_RxDataParams. //! This function sets up the transmitter data format and properties. The //! following are valid values and ranges for the parameters of the //! McBSP_RxDataParams. //! - \b loopbackModeFlag - true for digital loop-back mode. //! false for non loop-back mode. //! - \b twoPhaseModeFlag - true for two phase mode. //! false for single phase mode. //! - \b phase1FrameLength - maximum value of 127. //! - \b phase2FrameLength - maximum value of 127. //! - \b phase1WordLength - MCBSP_BITS_PER_WORD_x , x = 8,12,16,20,24,32 //! - \b phase2WordLength - MCBSP_BITS_PER_WORD_x , x = 8,12,16,20,24,32 //! - \b compandingMode - MCBSP_COMPANDING_NONE, //! MCBSP_COMPANDING_NONE_LSB_FIRST //! MCBSP_COMPANDING_U_LAW_SET or //! MCBSP_COMPANDING_A_LAW_SET. //! - \b dataDelayBits - MCBSP_DATA_DELAY_BIT_0, //! MCBSP_DATA_DELAY_BIT_1 or //! MCBSP_DATA_DELAY_BIT_2 //! - \b signExtMode - MCBSP_RIGHT_JUSTIFY_FILL_ZERO, //! MCBSP_RIGHT_JUSTIFY_FILL_SIGN or //! MCBSP_LEFT_JUSTIFY_FILL_ZER0 //! - \b interruptMode - MCBSP_RX_ISR_SOURCE_SERIAL_WORD, //! MCBSP_RX_ISR_SOURCE_END_OF_BLOCK, //! MCBSP_RX_ISR_SOURCE_FRAME_SYNC or //! MCBSP_RX_ISR_SOURCE_SYNC_ERROR //! //! \b Note - When using companding,phase1WordLength and phase2WordLength //! must be 8 bits wide. //! //! \return None. // //***************************************************************************** extern void McBSP_configureRxDataFormat(uint32_t base, const McBSP_RxDataParams * ptrDataParams); //***************************************************************************** // //! Configures transmitter multichannel. //! //! \param base is the base address of the McBSP module. //! \param ptrMchnParams is a pointer to a structure containing multichannel //! parameters McBSP_TxMultichannelParams. //! //! This function sets up the transmitter multichannel mode. The following are //! valid values and ranges for the parameters of the //! McBSP_TxMultichannelParams. //! - \b channelCount - Maximum value of 128 for partition 8 //! Maximum value of 32 for partition 2 //! - \b ptrChannelsList - Pointer to an array of size channelCount that //! has unique channels. //! - \b multichannelMode - MCBSP_ALL_TX_CHANNELS_ENABLED, //! MCBSP_TX_CHANNEL_SELECTION_ENABLED, //! MCBSP_ENABLE_MASKED_TX_CHANNEL_SELECTION or //! MCBSP_SYMMERTIC_RX_TX_SELECTION //! - \b partition - MCBSP_MULTICHANNEL_TWO_PARTITION or //! MCBSP_MULTICHANNEL_EIGHT_PARTITION //! \note - In 2 partition mode only channels that belong to a single even or //! odd block number should be listed. It is valid to have an even and //! odd channels. For example you can have channels [48 -63] and //! channels [96 - 111] enables as one belongs to an even block and //! the other to an odd block or two partitions. But not channels //! [48 - 63] and channels [112 - 127] since they both are even blocks //! or similar partitions. //! //! \return returns the following error codes. //! - \b MCBSP_ERROR_EXCEEDED_CHANNELS - number of channels exceeds 128 //! - \b MCBSP_ERROR_2_PARTITION_A - invalid channel combination for //! partition A //! - \b MCBSP_ERROR_2_PARTITION_B - invalid channel combination for //! partition B //! - \b MCBSP_ERROR_INVALID_MODE - invalid transmitter channel mode. //! //! \return Returns the following error codes. //! - \b MCBSP_ERROR_EXCEEDED_CHANNELS - Exceeded number of channels. //! - \b MCBSP_ERROR_2_PARTITION_A - Error in 2 partition A setup. //! - \b MCBSP_ERROR_2_PARTITION_B - Error in 2 partition B setup. //! - \b MCBSP_ERROR_INVALID_MODE - Invalid mode. // //***************************************************************************** extern uint16_t McBSP_configureTxMultichannel(uint32_t base, const McBSP_TxMultichannelParams * ptrMchnParams); //***************************************************************************** // //! Configures receiver multichannel. //! //! \param base is the base address of the McBSP module. //! \param ptrMchnParams is a pointer to a structure containing multichannel //! parameters McBSP_RxMultiChannelParams. //! //! This function sets up the receiver multichannel mode. The following are //! valid values and ranges for the parameters of the McBSPMultichannelParams. //! - \b channelCount - Maximum value of 128 for partition 8 //! Maximum value of 32 for partition 2 //! - \b ptrChannelsList - Pointer to an array of size channelCount that //! has unique channels. //! - \b multichannelMode - MCBSP_ALL_RX_CHANNELS_ENABLED, //! MCBSP_RX_CHANNEL_SELECTION_ENABLED, //! - \b partition - MCBSP_MULTICHANNEL_TWO_PARTITION or //! MCBSP_MULTICHANNEL_EIGHT_PARTITION //! \note - In 2 partition mode only channels that belong to a single even or //! odd block number should be listed. It is valid to have an even //! and odd channels. For example you can have channels [48 - 63] and //! channels [96 - 111] enables as one belongs to an even block and //! the other to an odd block or two partitions. But not channels //! [48 - 63]and channels [112 - 127] since they both are even blocks //! or similar partitions. //! //! \return returns the following error codes. //! - \b MCBSP_ERROR_EXCEEDED_CHANNELS - number of channels exceeds 128 //! - \b MCBSP_ERROR_2_PARTITION_A - invalid channel combination for //! partition A //! - \b MCBSP_ERROR_2_PARTITION_B - invalid channel combination for //! partition B //! - \b MCBSP_ERROR_INVALID_MODE - invalid transmitter channel mode. //! //! \return Returns the following error codes. //! - \b MCBSP_ERROR_EXCEEDED_CHANNELS - Exceeded number of channels. //! - \b MCBSP_ERROR_2_PARTITION_A - Error in 2 partition A setup. //! - \b MCBSP_ERROR_2_PARTITION_B - Error in 2 partition B setup. //! - \b MCBSP_ERROR_INVALID_MODE - Invalid mode. // //***************************************************************************** extern uint16_t McBSP_configureRxMultichannel(uint32_t base, const McBSP_RxMultichannelParams * ptrMchnParams); //***************************************************************************** // //! Configures McBSP in SPI master mode //! //! \param base is the base address of the McBSP module. //! \param ptrSPIMasterMode is a pointer to a structure containing SPI //! parameters McBSP_SPIMasterModeParams. //! This function sets up the McBSP module in SPI master mode.The following are //! valid values and ranges for the parameters of the //! McBSP_SPIMasterModeParams. //! - \b loopbackModeFlag - true for digital loop-back //! false for no loop-back //! - \b clockStopMode - MCBSP_CLOCK_SPI_MODE_NO_DELAY or //! MCBSP_CLOCK_SPI_MODE_DELAY //! - \b wordLength - MCBSP_BITS_PER_WORD_x , x = 8,12,16,20,24,32 //! - \b spiMode It represents the clock polarity can take values: //! - MCBSP_TX_POLARITY_RISING_EDGE or //! MCBSP_TX_POLARITY_FALLING_EDGE //! - \b clockSRGDivider - Maximum valid value is 255. //! //! \note Make sure the clock divider is such that, the McBSP clock is not //! running faster than 1/2 the speed of the source clock. //! //! \return None. // //***************************************************************************** extern void McBSP_configureSPIMasterMode(uint32_t base, const McBSP_SPIMasterModeParams * ptrSPIMasterMode); //***************************************************************************** // //! Configures McBSP in SPI slave mode //! //! \param base is the base address of the McBSP module. //! \param ptrSPISlaveMode is a pointer to a structure containing SPI //! parameters McBSP_SPISlaveModeParams. //! This function sets up the McBSP module in SPI slave mode.The following are //! valid values and ranges for the parameters of the McBSP_SPISlaveModeParams. //! - \b loopbackModeFlag - true for digital loop-back //! false for no loop-back //! - \b clockStopMode - MCBSP_CLOCK_SPI_MODE_NO_DELAY or //! MCBSP_CLOCK_SPI_MODE_DELAY //! - \b wordLength - MCBSP_BITS_PER_WORD_x , x = 8,12,16,20,24,32 //! - \b spiMode It represents the clock polarity and can take //! values: //! - MCBSP_RX_POLARITY_FALLING_EDGE or //! MCBSP_RX_POLARITY_RISING_EDGE //! //! \return None. // //***************************************************************************** extern void McBSP_configureSPISlaveMode(uint32_t base, const McBSP_SPISlaveModeParams * ptrSPISlaveMode); //***************************************************************************** // // Close the Doxygen group. //! @} // //***************************************************************************** //***************************************************************************** // // Mark the end of the C bindings section for C++ compilers. // //***************************************************************************** #ifdef __cplusplus } #endif #endif // MCBSP_H