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

📄 9e5quickbootloader.c

📁 nrf9e5 nordic公司出品的带有无线发送接收的单片机的bootloader程序。支持xmodem下载
💻 C
字号:
/*===============================================================================================
 *
 * Copyright (C) 2004 
 *
 * This file is distributed in the hope that it will be useful, but WITHOUT
 * WARRANTY OF ANY KIND.
 *
 * Author(s):
 *
 * DESCRIPTION: for nRF9E5
 *
 *  nRF9E5/nRF24E1 range demo. Select receiver by shorting P03 and P05 and transmitter by shorting
 *  P05 and P06. Uncomment/comment the appropriate #define below to select nRF9E5 or nRF24E1.
 *
 *  The transmitter continously send one byte packets. Each time the receiver receives a packet the
 *  P00 pin is set low (LED1 is turned on on the 9E5 eval board). At the same time a 20ms timer is
 *  started and if a new packets is not received before the 20ms time-out the P00 pin is set high
 *  (LED1 is turned off). If a new packet is received before the time-out a new 20ms time-out period
 *  is started.
 *
 *  Please remember to turn off the RS232 switch on the receiver and transmitter boards. On the
 *  nRF9E5 board turn off all dip-switches on the transmitter and turn on only the LED1 switch on
 *  the receiver.
 *
 * COMPILER:
 *  
 *  This program has been tested with Keil C51 V7.09
 *
 * $Revision: 1 $
 *
 *==================================================================================================
*/
// Comment out the following line for nRF24E1
#include "reg9e5.h"
#include "serial.h"
#include "spi.h"
#include "timer0.h"
#include "25lc320.h"
#include "PubFunc.h"
#include "xmodem.h"

extern void SwitchToAppBank();
extern void  CopyUserProgram(void);

BYTE code UpDataStr[] = "\r\nBoot Ver: 1.00\n\r";
void updata(void)
{
	CUSTOM_TIMER tmrWaiting;
	SetCustomTimer(&tmrWaiting, SECONDS(3));
	while (!IsTimeOut(&tmrWaiting)) {		
			if (XmodemRecvBuf[0] == 'U' || XmodemRecvBuf[0] == 'u') {
					SIOSendData("\r\nCompile Time :", sizeof("\r\nCompile Time :"));
					SIOSendData(__DATE__, sizeof(__DATE__));
					SIOSendData(" ",1);
				SIOSendData(__TIME__, sizeof(__TIME__));
					SIOSendData(UpDataStr, sizeof(UpDataStr));
					
				
				xmodem();
//					SIOSendData("Program Swith\r\n",sizeof("Program Swith\r\n"));
			}
		 serial_recv_num=0;
	}
}

 void init(void)
{
	BYTE data buf[2];
	
	//uart initial
	SCON = 0x50;					//	Serial mode1, enable receiver
	TMOD = TMOD & 0x0F | 0x20;		//	Timer1 8bit auto reload 
	PCON = PCON | 0x80;				//	SMOD=1 (double baud rate)
#ifdef TIME1_4CLK_INTERVAL
	CKCON |= 0x10;					//	T1M=1 (/4 timer clock)
	TH1 = TIME1;//	0xF3;			//	19200@16MHz (when T1M=1 and SMOD=1)
#else
	CKCON &= 0xEF;
#endif
	TR1 = 1;						//	Start timer1
	
	P0_ALT |= 0x06;					//	Select alternate functions on pins P0.1 and P0.2
    P0_DIR = 0xE2;					//	P0.0 out,P0.1 input(RXD),P0.2 P0.3 P0.4 output,P0.5 P0.6 P0.7 input
	ES = 1;
	serial_recv_num=0;				//number of serial recev buffer
	
	//init timer0	
	TR0 = 0;
	TMOD |= 0x01;
#ifdef TIME0_4CLK_INTERVAL
	CKCON |= 0x08;
#else
	CKCON &= 0xF7;
#endif
	TR0 = 0;
 	RELOAD_TIMER0
	TR0 = 1;					//  启动定时器
	ET0 = 1;
	gwSystemTime=0;
	EA = 1;						//int open
		
	//init clk
	ChoiceSPIModule(INTERNAL);
	buf[0] = RRC | 0x09;
	SPIReadWrite(buf, 2);

	buf[1] &= 0xC3;
	buf[1] |= 0x1C;
	
 	buf[0] = WRC | 0x09;
	SPIReadWrite(buf, 2);
	
}

void main(void)
{
	init();
	Init25lc320();
	
	updata();

	SwitchToAppBank();					//copy copyprogram to 0x0FA0
	ChoiceSPIModule(EXTERNAL);			
	CopyUserProgram();					//copy user program to 0x0000

}

⌨️ 快捷键说明

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