📄 main.c
字号:
#include "..\inc\function.h"
#include "..\inc\44b.h"
#include "def.h"
#include "constant.h"
#include "..\inc\globalv.h"
//----------------------------------------------------------------------------------
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "..\inc\44blib.h"
/*
#include "..\inc\option.h"
#include "..\inc\def.h"
#include "..\inc\44b.h"
#include "..\inc\flash.h"
#include "..\inc\download.h"
#include "..\inc\usb.h"
#include "..\inc\cache.h"
#include "..\inc\lcd.h"
#include "..\inc\ata.h"
//following is CPU test functions include
#include "..\inc\cputest\adc.h"
#include "..\inc\cputest\etc.h"
#include "..\inc\cputest\dma.h"
#include "..\inc\cputest\eint.h"
#include "..\inc\cputest\extdma.h"
#include "..\inc\cputest\idle.h"
#include "..\inc\cputest\iic.h"
#include "..\inc\cputest\iis.h"
#include "..\inc\cputest\nwait.h"
#include "..\inc\cputest\power.h"
#include "..\inc\cputest\rtc.h"
#include "..\inc\cputest\sio.h"
#include "..\inc\cputest\stop.h"
#include "..\inc\cputest\timer.h"
#include "..\inc\cputest\uart.h"
#include "..\inc\usb\def9603.h"
*/
//---------------------------------------------------------------------------
/*
void* function[][2]=
{
0,0,
(void *)Test_SLIdleMode, "1、SL_IDLE Mode ",
(void *)Test_SLIdleMode20, "2、SL_IDLE Mode20 ",
(void *)Test_IdleMode, "3、IDLE Mode ",
(void *)Test_IdleModeHard, "4、IDLE(hard) ",
(void *)Test_WaitPin, "5、nWAIT pin ",
(void *)Test_ZDma0Xdreq, "6、nXDREQ0 ",
(void *)Test_Adc, "7、Adc 0,1,2,3 ",
(void *)Test_DMA_Adc, "8、Adc with DMA ",
(void *)Test_Uart0, "9、UART 0 ",
(void *)Test_Uart0Fifo, "10、UART 0 FIFO ",
(void *)Test_Uart1, "11、UART 1 ",
(void *)Test_Uart1Fifo, "12、UART 1 FIFO ",
(void *)Test_SlowMode, "13、SLOW Mode ",
(void *)Test_HoldMode, "14、HOLD Mode ",
(void *)Test_StopMode, "15、STOP Mode ",
(void *)Test_Zdma0, "16、Zdma0 ",
(void *)Test_Zdma1, "17、Zdma1 ",
(void *)Test_Sio, "18、SIO Tx/Rx ",
(void *)Test_SIOTX_BDMA0, "19、SIO Tx BDMA0 ",
(void *)Test_SIORX_BDMA1, "20、SIO Rx BDMA1 ",
(void *)Test_WDTimer, "21、WDTimer ",
(void *)Display_Rtc, "22、RTC(display) ",
(void *)Test_Rtc_Alarm, "23、RTC(Test) ",
(void *)Test_Rtc_Tick, "24、RTC Tick ",
(void *)Test_Iic, "25、IIC(AT24LCxx) ",
(void *)Test_Iis, "26、IIS(uda1341) ",
(void *)Iis_Tx, "27、IIS Tx(Slave) ",
(void *)Iis_Rx, "28、IIS Rx(Master) ",
(void *)Test_TimerInt, "29、Timer Int ",
(void *)Test_Timer, "30、Tout test ",
(void *)Test_Eint, "31、Ext. Int ",
(void *)Etc, "32、Etc... ",
(void *)Test_UartAFC_Tx, "33、Test AFC(Tx) ",
(void *)Test_UartAFC_Rx, "34、Test AFC(Rx) ",
0,0
};
void UartInit(void);
//////////////////////////////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////////////////////
int main()
{
int i;
//********************************初始化****************************************
Port_Init(); //I/O端口初始化
rPDATE &= ~BIT7;
rI_ISPC=BIT_UTXD0;
InitVar();
UartInit();
Uart_Printf("\nTest begin:!");
Uart_Select(0); //Select UART0//
while(1){
//------------------------------------------------------------------------
i = -1;
Uart_Printf("\nSelect the function to test?");
i = Uart_GetIntNum();
Uart_Printf("\n%2d:%s",i,function[i][1]);
//**********************************************************
//**********************************************************
#ifdef DEBUG
{
int m;
void *p ;
void (*q)();
p = (int*)Test_UartAFC_Tx;
q=Test_UartAFC_Tx;
((void((*)()))p)();
(*q)();
m = sizeof(function)/8;
Uart_Printf("\nfunction_size=%d",m);
//Uart_Printf("\n%2d:%s",i,function[i][0]);
}
#endif
//if(i>=0 && (i<(sizeof(function)/8)) )
( (void (*)(void)) (function[i][0]) )();
}
}*/
//----------------------------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////////////////////
volatile static char *uart0TxStr;
//************************************************************************************************
//----------------------------------------------------------------------------------------------
void __irq Uart0_TxInt(void)
{
// rI_ISPC=BIT_UTXD0; //This cann't make the pending bit be cleared in the level trigger mode.
//Uart_Printf("[***This is __irq Uart0_TxInt(void)***]\n");
if(*uart0TxStr != '\0')
{
WrUTXH0(*uart0TxStr++);
rI_ISPC=BIT_UTXD0; //Because UART operates using level trigger mode.
}
else
// {
// rUCON0 &= 0x3f3; //workaround
// rI_ISPC=BIT_UTXD0; //This cann't make the pending bit be cleared in the level trigger mode.
// rINTMSK|=BIT_UTXD0;
// }
// WrUTXH0('@');
{ //ES3
rINTMSK |= BIT_UTXD0; //ES3
rI_ISPC=BIT_UTXD0; //ES3
} //ES3
}
//----------------------------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////////////////////
void UartInit(void)
{
/*
rULCON0 = 0x3;
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
rUCON0 |= 0x1 |
(0x1<<2) |
// (0x1<<5) |
(0x1<<7) |
(0x1<<8) |
(0x1<<9) ;
rUFCON0 |= 0x1|
// (0x1<<1) | (0x1<<2)|
(0x1<<4) | (0x1<<6);
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
*/
//*************************************************************
//初始化端口
rPCONE |= (2<<2)|(2<<4); //rxd txd
//rPCONE |= (0x01<<2)|(0x01<<4); //rxd txd 第一次竟然写成了这个
rPDATG &= ~BIT1; //RTS 为0请求接收;
rPCONG |= (1<<2);
//rxd txd rts cts
//======================================
//初始化寄存器
rUFCON0=0x0; //FIFO disable
rUFCON1=0x0;
rUMCON0=0x0;
rUMCON1=0x0;
//UART0
rULCON0=0x3; //Normal,No parity,1 stop,8 bit
rUCON0=0x045; //0000,0100,0101。rx=edge,tx=level,disable timeout int.,enable rx error int.,normal,interrupt or polling
//======================================
rUBRDIV0 = (int)(60000000 / (115200 * 16)+0.5 ) -1;
}
////////////////////////////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------------------------------
int main()
{
BYTE data;
//Port_Init(); //I/O端口初始化
rPDATE &= ~BIT7; //关蜂鸣器
UartInit();
Uart_Printf("\nTest begin:!");
uart0TxStr="UART0 Tx interrupt test is good!!!!\r\n";
pISR_UTXD0 = (unsigned)Uart0_TxInt;
rINTCON = 0;
rINTMSK =~ (BIT_GLOBAL|BIT_UTXD0);
rINTMOD = 0;
//WrUTXH0(*uart0TxStr++);
rUCON0 = 0x185; //0001, 1000, 0101
while(1)
{
//data = RdURXH0();
//WrUTXH0(data);
}
}
////////////////////////////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////////////////////
void __irq usb_isr(void){}
void init_usb(){}
void write_usb(unsigned char adr,unsigned char dat){}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -