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

📄 main.c

📁 C6000DSP下的BOIS
💻 C
字号:
/*
 *  Copyright 2002 by Texas Instruments Incorporated.
 *  All rights reserved. Property of Texas Instruments Incorporated.
 *  Restricted rights to use, duplicate or disclose this code are
 *  granted through contract.
 *  
 */
/* "@(#) DSP/BIOS 4.80.208 12-06-02 (barracuda-l19)" */
/******************************************************************************\
*           Copyright (C) 2000 Texas Instruments Incorporated.
*                           All Rights Reserved
*------------------------------------------------------------------------------
* FILENAME...... main.c
* DATE CREATED.. 01/11/2000
* LAST MODIFIED. 09/11/2001
*
\******************************************************************************/


/* Header file created by DSP/BIOS tool */
#include "mcbsp1cfg.h"

/*----------------------------------------------------------------------------*/
extern far LOG_Obj LogMain;

/*----------------------------------------------------------------------------*/



/*----------------------------------------------------------------------------*/
void main() {

  volatile Uint32 x,y;
  int success = 1;


  LOG_printf(&LogMain,"<MCBSP1>");
   
  /**************************************************************\
  * The following code                                         *
  * configures the serial port for digital loopback mode. We   *
  * then use the CPU to write/read from the port. In loopback  *
  * mode, we should read the same value as written, this is    *
  * checked for in a loop.                                     *
  \**************************************************************/
  /******************************************************************************\ 
  * Let's use the pre-initialized serial port 1 defined under mcbsp1cfg_c.c file 
  * - Open serial Port 
  *    hMcbsp1    
  * - Create config. structure defined 
  *   mcbspcfg1 :  spcr = 0x00008000 enable DLP   
  *                xcr  = 0x000000A0 ( 32-bits data)
  *                rcr  = 0x000000A0  (32-bits data)      
  *                srgr = 0x203F1F0F                                            
  *                     MCBSP_SRGR_GSYNC_FREE,
  *                     MCBSP_SRGR_CLKSP_RISING,
  *                     MCBSP_SRGR_CLKSM_INTERNAL,
  *                     MCBSP_SRGR_FSGM_DXR2XSR,
  *                     MCBSP_SRGR_FPER_OF(63),
  *                     MCBSP_SRGR_FWID_OF(31),
  *                     MCBSP_SRGR_CLKGDV_OF(15)
  *               pcr = 0x00000A00 
  *                   ( Transmit as output -Receiver as input)
  * 
  \******************************************************************************/
  
  /* Now that the port is setup, let's enable it in steps. */
 // MCBSP_enableSrgr(hMcbsp1);
 // MCBSP_enableRcv(hMcbsp1);
 // MCBSP_enableXmt(hMcbsp1);
 
MCBSP_start(hMcbsp1,MCBSP_RCV_START | MCBSP_XMIT_START | MCBSP_SRGR_START| MCBSP_SRGR_FRAMESYNC, 0);
  
  /* Now we'll loop for a while writing values out to the port */
  /* then reading them back in. This should take a few seconds.*/
  for (y=0; y<0x00080000; y++) {  
  
    /* wait until the transmitter is ready for a sample then write to it */
    while (!MCBSP_xrdy(hMcbsp1));                       
    MCBSP_write(hMcbsp1,y);
  
    /* now wait until the value is received then read it */
    while (!MCBSP_rrdy(hMcbsp1));           
    x = MCBSP_read(hMcbsp1);
    
    /* check to make sure they match */
    if (x != y) {
      success = 0;
      break;
    }
  }
  
  /* All done now, close the port open by CSL_cfgInit(). */
  MCBSP_close(hMcbsp1); 
  
  LOG_printf(&LogMain,"success=%d",success);
  LOG_printf(&LogMain,"<DONE>");
}

/*----------------------------------------------------------------------------*/

/******************************************************************************\
* End of main.c
\******************************************************************************/

⌨️ 快捷键说明

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