⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mcbsp.c

📁 OMAP1030 处理器的ARM 侧硬件测试代码 OMAP1030 是TI的双核处理器
💻 C
📖 第 1 页 / 共 2 页
字号:
REG16(MCBSP_PCR_REG) = value;
}


//---------------------------------------------------------------------------
// NAME        : MCBSP_SetRX1ControlRegister
// DESCRIPTION : Configure the Receive Control Register 1
// RETURN VALUE: None
// LIMITATIONS : None
//---------------------------------------------------------------------------
void  MCBSP_SetRX1ControlRegister(MCBSP_WordLength_t RXWordLength,
                                  MCBSP_FrameLength_t RXFrameLength)
{
// Read the Receive Control Register 1
UWORD16 value = REG16(MCBSP_RCR1_REG);

// Clear all bits
value = 0;

// Set all bits
value |= RXWordLength << (RWDLEN1 - RWDLEN1_SZ + 1);
value |= RXFrameLength << (RFRLEN1 - RFRLEN1_SZ + 1);

// Write the Receive Control Register 1
REG16(MCBSP_RCR1_REG) = value;
}


//---------------------------------------------------------------------------
// NAME        : MCBSP_SetRX2ControlRegister
// DESCRIPTION : Configure the Receive Control Register 2
// RETURN VALUE: None
// LIMITATIONS : None
//---------------------------------------------------------------------------
void  MCBSP_SetRX2ControlRegister(MCBSP_DataDelay_t RXDataDelay,
                                  MCBSP_FrameIgnore_t RXFrameIgnore,
                                  MCBSP_Companding_t RXCompanding,
                                  MCBSP_WordLength_t RXWordLength,
                                  MCBSP_FrameLength_t RXFrameLength,
                                  MCBSP_Phase_t RXPhase)
{
// Read the Receive Control Register 2
UWORD16 value = REG16(MCBSP_RCR2_REG);

// Clear all bits
value = 0;

// Set all bits
value |= RXDataDelay << (RDATDLY - RDATDLY_SZ + 1);
value |= RXFrameIgnore << (RFIG - RFIG_SZ + 1);
value |= RXCompanding << (RCOMPAND - RCOMPAND_SZ + 1);
value |= RXWordLength << (RWDLEN2 - RWDLEN2_SZ + 1);
value |= RXFrameLength << (RFRLEN2 - RFRLEN2_SZ + 1);
value |= RXPhase << (RPHASE - RPHASE_SZ + 1);

// Write the Receive Control Register 2
REG16(MCBSP_RCR2_REG) = value;
}


//---------------------------------------------------------------------------
// NAME        : MCBSP_SetTX1ControlRegister
// DESCRIPTION : Configure the Transmit Control Register 1
// RETURN VALUE: None
// LIMITATIONS : None
//---------------------------------------------------------------------------
void  MCBSP_SetTX1ControlRegister(MCBSP_WordLength_t TXWordLength,
                                  MCBSP_FrameLength_t TXFrameLength)
{
// Read the Transmit Control Register 1
UWORD16 value = REG16(MCBSP_XCR1_REG);

// Clear all bits
value = 0;

// Set all bits
value |= TXWordLength << (XWDLEN1 - XWDLEN1_SZ + 1);
value |= TXFrameLength << (XFRLEN1 - XFRLEN1_SZ + 1);

// Write the Transmit Control Register 1
REG16(MCBSP_XCR1_REG) = value;
}


//---------------------------------------------------------------------------
// NAME        : MCBSP_SetTX2ControlRegister
// DESCRIPTION : Configure the Transmit Control Register 2
// RETURN VALUE: None
// LIMITATIONS : None
//---------------------------------------------------------------------------
void  MCBSP_SetTX2ControlRegister(MCBSP_DataDelay_t TXDataDelay,
                                  MCBSP_FrameIgnore_t TXFrameIgnore,
                                  MCBSP_Companding_t TXCompanding,
                                  MCBSP_WordLength_t TXWordLength,
                                  MCBSP_FrameLength_t TXFrameLength,
                                  MCBSP_Phase_t TXPhase)
{
// Read the Transmit Control Register 2
UWORD16 value = REG16(MCBSP_XCR2_REG);

// Clear all bits
value = 0;

// Set all bits
value |= TXDataDelay << (XDATDLY - XDATDLY_SZ + 1);
value |= TXFrameIgnore << (XFIG - XFIG_SZ + 1);
value |= TXCompanding << (XCOMPAND - XCOMPAND_SZ + 1);
value |= TXWordLength << (XWDLEN2 - XWDLEN2_SZ + 1);
value |= TXFrameLength << (XFRLEN2 - XFRLEN2_SZ + 1);
value |= TXPhase << (XPHASE - XPHASE_SZ + 1);

// Write the Transmit Control Register 2
REG16(MCBSP_XCR2_REG) = value;
}


//---------------------------------------------------------------------------
// NAME        : MCBSP_SetSampleRegister1
// DESCRIPTION : Configure the Sample Rate Generator Configuration Register 1
// RETURN VALUE: None
// LIMITATIONS : None
//---------------------------------------------------------------------------
void  MCBSP_SetSampleRegister1(MCBSP_ClockDivider_t ClockDivider,
                               MCBSP_FrameWidth_t FrameWidth)
{
// Read the Sample Rate Generator Configuration Register 1
UWORD16 value = REG16(MCBSP_SRGR1_REG);

// Clear all bits
value = 0;

// Set all bits
value |= ClockDivider << (CLKGDV - CLKGDV_SZ + 1);
value |= FrameWidth << (FWID - FWID_SZ + 1);

// Write the Sample Rate Generator Configuration Register 1
REG16(MCBSP_SRGR1_REG) = value;
}


//---------------------------------------------------------------------------
// NAME        : MCBSP_SetSampleRegister2
// DESCRIPTION : Configure the Sample Rate Generator Configuration Register 2
// RETURN VALUE: None
// LIMITATIONS : None
//---------------------------------------------------------------------------
void  MCBSP_SetSampleRegister2(MCBSP_FramePeriod_t FramePeriod,
                               MCBSP_FSMode_t FSMode,
                               MCBSP_SampleMode_t SampleMode,
                               MCBSP_CLKSPol_t CLKSPol,
                               MCBSP_SampleSync_t SampleSync)
{
// Read the Sample Rate Generator Configuration Register 2
UWORD16 value = REG16(MCBSP_SRGR2_REG);

// Clear all bits
value = 0;

// Set all bits
value |= FramePeriod << (FPER - FPER_SZ + 1);
value |= FSMode << (FSGM - FSGM_SZ + 1);
value |= SampleMode << (CLKSM - CLKSM_SZ + 1);
value |= CLKSPol << (CLKSP - CLKSP_SZ + 1);
value |= SampleSync << (GSYNC - GSYNC_SZ + 1);

// Write the Sample Rate Generator Configuration Register 2
REG16(MCBSP_SRGR2_REG) = value;
}


//---------------------------------------------------------------------------
// NAME        : MCBSP_EnableRX
// DESCRIPTION : Configure the Serial Port Control Register 1 to reset and enable the receiver
// RETURN VALUE: None
// LIMITATIONS : None
//---------------------------------------------------------------------------
void  MCBSP_EnableRX(void)
{
// Read the Serial Port Control Register 1
UWORD16 value = REG16(MCBSP_SPCR1_REG);

// Clear RRST bit
value &= ~(RRST_MASK << (RRST - RRST_SZ + 1));

// Set bit RRST
value |= MCBSP_Enable << (RRST - RRST_SZ + 1);

// Write the Serial Port Control Register 1
REG16(MCBSP_SPCR1_REG) = value;
}


//---------------------------------------------------------------------------
// NAME        : MCBSP_EnableTX
// DESCRIPTION : Configure the Serial Port Control Register 2 to reset and enable the transmitter
// RETURN VALUE: None
// LIMITATIONS : None
//---------------------------------------------------------------------------
void  MCBSP_EnableTX(void)
{
// Read the Serial Port Control Register 2
UWORD16 value = REG16(MCBSP_SPCR2_REG);

// Clear XRST bit
value &= ~(XRST_MASK << (XRST - XRST_SZ + 1));

// Set bit RRST
value |= MCBSP_Enable << (XRST - XRST_SZ + 1);

// Write the Serial Port Control Register 2
REG16(MCBSP_SPCR2_REG) = value;
}


//---------------------------------------------------------------------------
// NAME        : MCBSP_ReadData
// DESCRIPTION : Read Received Data from Data Receive Register 2 and 1
// RETURN VALUE: Data read
// LIMITATIONS : None
//---------------------------------------------------------------------------
UWORD16 MCBSP_ReadData(MCBSP_DataRegister_t DataRegister)
{
UWORD16 value;

  switch (DataRegister)
  {
    case MCBSP_DRR2:
      // Read the Data Receive Register 2
      value = REG16(MCBSP_DRR2_REG);
      break;
    case MCBSP_DRR1:
      // Read the Data Receive Register 1
      value = REG16(MCBSP_DRR1_REG);
      break;
    default :
      break;
  }
  return (value);
}

//---------------------------------------------------------------------------
// NAME        : MCBSP_EnableSpiMode
// DESCRIPTION : Configure the Serial Port Control Register 1 to reset and enable the receiver
// RETURN VALUE: None
// LIMITATIONS : None
//---------------------------------------------------------------------------
void  MCBSP_EnableSpiMode(MCBSP_CLKSTP_t Clock_Stop_Mode)
{
// Read the Serial Port Control Register 1
UWORD16 value = REG16(MCBSP_SPCR1_REG);

// Set bit RRST
value |= Clock_Stop_Mode << (CLKSTP - CLKSTP_SZ + 1);

// Write the Serial Port Control Register 1
REG16(MCBSP_SPCR1_REG) = value;
}

//---------------------------------------------------------------------------
// NAME        : MCBSP_WriteData
// DESCRIPTION : Write Data to transmit in Data Transmit Register 2 and 1
// RETURN VALUE: None
// LIMITATIONS : None
//---------------------------------------------------------------------------
void MCBSP_WriteData(MCBSP_DataRegister_t DataRegister, UWORD16 Data)
{
  switch (DataRegister)
  {
    case MCBSP_DXR2:
      // Write the Data Transmit Register 2
      REG16(MCBSP_DXR2_REG) = Data;
      break;
    case MCBSP_DXR1:
      // Write the Data Transmit Register 1
      REG16(MCBSP_DXR1_REG) = Data;
      break;
    default :
      break;
  }
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -