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

📄 testuarta.c

📁 TITMS6000 DM642 串口程序 uart
💻 C
字号:
/* ======================================================================== */
/* NAME                                                                     */
/*     testuartA.c 										                        */
/* DESCRIPTION                                                              */
/*             UARTA module loopback for the jydVCM                                      */
/* ------------------------------------------------------------------------ */
/*         Copyright (c) 2006 Wintech Digital System Technology Corp.       */
/*                           All Rights Reserved.                           */
/* ======================================================================== */
//date:2006 08 22
//auther:mahj 

/* ======================================================================== */
/* basic header includes                                                    */
/* ======================================================================== */
#include "testuartcfg.h"

/*
 *  The POST uses the Chip Support Library for basic definitions as well as
 *  McBSP manipulation.  Programs that use the CSL must include the
 *  appropriate header files.
 */
#include <stdio.h>
#include <std.h>
#include <sys.h>
#include <csl.h>
#include <csl_mcbsp.h>
#include <csl_timer.h>
#include <csl_edma.h>
#include <csl_vic.h>
#include <csl_mcasp.h>
#include <csl_gpio.h>
#include <csl_pci.h>
   
/*
 *  The DM642 EVM Board Support Library is divided into several modules, each
 *  of which has its own include file.  The file DM643.h must be included
 *  in every program that uses the BSL.  This example also includes
 *  DM643_aic23.h, DM643_led.h and DM643_flash.h because it uses
 *  their respective BSL modules.
 */
#include "DM643.h"
#include "DM643_led.h"
#include "DM643_aic23.h"
#include "DM643_flash.h"
#include "DM643_eeprom.h"
#include "DM643_uart.h"
#include "DM643_apll.h"
#include "DM643_pci.h"

/* Length of sine wave table */
#define SINE_TABLE_SIZE  48

/* Number of elements for DMA and McBSP loopback tests */
#define N                16

/* Define source and destination arrays for DMA and loopback tests */
Uint16 src[N], dst[N], buffer[256];
volatile Uint32 sleepCount = 0;
void sleepIsr()
{
    sleepCount++;
}

Int16 TEST_uartA()
{
    
    Int16 i;
    DM643_UART_Handle hUart;
    DM643_UART_Config uartcfg = {
        0x00,  // IER
        0x57,  // FCR - FIFO Mode, 16 character trigger level
        0x03,  // LCR - 8 bits, no parity, 1 stop
        0x00   // MCR
    };
    
    /* Open UART */
    hUart = DM643_UART_open(DM643_UARTA, DM643_UART_BAUD115200, &uartcfg);
	
	//*((Uint32 *)0x90030000) = 0x0000; 
    /* Loop through 256 bytes */
    for (i = 0; i < 256; i++)
    {
    	//buffer[i] = 0x31;
        //set S_RT TO LOW
		//*((Uint32 *)0x90030000) = 0x0000;
        //DM643_UART_putChar(hUart, buffer[i]);

        buffer[i] = DM643_UART_getChar(hUart);
        
        //set S_RT TO HIGH
		//*((Uint32 *)0x90030000) = 0x1000;
        DM643_UART_putChar(hUart, buffer[i]);
        //printf("%x\n", (i + 1) & 0xff);
        printf("%d,  %x\n", i,buffer[i]);
       // printf("%x\n", i);
      
      

    }
    //*((Uint32 *)0x90030000) = 0x0000;  //set 485 port to receive mode
   //printf("%x\n", buffer[5]);
	
    /* Verify data */
   /* for (i = 0; i < 256; i++)
    {
        if (buffer[i] != ((i+1) & 0xff))
            return 1;
    }*/
}    



main()
{
    int i;
    /* Call BSL init */
    DM643_init();
    
    /* Set initial LED state */
    DM643_LED_init();
    //for(i=0;i<10000000;i++)
    	//{
  		//*((Uint32 *)0xB0030000) = 0x1000;  //add by mahj
  		//*((Uint32 *)0xB0030000) = 0x0000;  //add by mahj
  		//}
  		
  		//DM643_waitusec(10);
  	printf("\n***test uarta start***\n");
    TEST_uartA( );

}

⌨️ 快捷键说明

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