NRF9E51读IC卡卡号,并把读取到的数据传送出去
TR2=1; while(!over1_flag) {;} //Delay100us(1); // data1=1; //Delay100us(10); } else { data0=0; count1=0; over1_flag=0; TR2=1; while(!over1_flag) {;} //Delay100us(1); //data0=1; //Delay100us(10); } } /*void rst_wdog() { if((REGX_CTRL&0x10)!=0x10) { REGX_MSB=0x75; REGX_LSB=0x30; // REGX_CTRL=0x08; } }*/ unsigned char SpiReadWrite(unsigned char b) { EXIF &= ~0x20; // Clear SPI interrupt SPI_DATA = b; // Move byte to send to SPI data register while((EXIF & 0x20) == 0x00) // Wait until SPI hs finished transmitting ; return SPI_DATA; } void TransmitPacket() { unsigned char i; CE = 1; Delay100us(0); // All packets start with the receiver address: for(i=0;i SpiReadWrite(tconf.buf[ADDR_INDEX+i]); SpiReadWrite(array[0]); SpiReadWrite(array[1]); SpiReadWrite(array[2]); CE = 0; Delay100us(3); // Wait ~300us } ///led000000000000000000000000000000000000 /*定时器0和定时器1的定时间是10ms*/ void InitTimer(void) { TR0 = 0; TMOD &= ~0x33; TMOD |= 0x11; // mode 1 CKCON |= 0x98; // T0M = 1 (/4 timer clock) t0lrel = 0xC0; // 1KHz tick... t0hrel = 0x63; // ... = 65536-16e6/(4*1e3) = F060h TF0 = 0; // Clear any pending Timer0 interrupts ET0 = 1; // Enable Timer0 interrupt TR1=0; t1lrel=0xC0; t1hrel=0x63; TF1 = 0; // Clear any pending Timer0 interrupts ET1 = 1; T2CON=0x00; RCAP2H=0xFE; RCAP2L=0x70; ET2=1; } void Timer0ISR (void) interrupt 1 { TF0 = 0; // Clear Timer0 interrupt TH0 = t0hrel; // Reload Timer0 high byte TL0 = t0lrel; // Reload Timer0 low byte count0++; if (count0==300) { LED=0; // Led off TR0 = 0; // Stop timer } } void Timer1ISR(void) interrupt 3 { TF1 = 0; // Clear Timer1 interrupt TH1 = t1hrel; // Reload Timer1 high byte TL1 = t1lrel; // Reload Timer1 low byte count++; if (count == 120) { count=0; over_flag=1; TR1=0; } } void Timer2ISR (void) interrupt 5 using 2 { TF2 = 0; count1++; if (count1==1) { data0=1; data1=1; } else if(count1==11) { count1=0; over1_flag=1; TR2=0; } } void Receiver(void) { unsigned char b; CS = 1; Delay100us(0); for(b=0;b SpiReadWrite(rconf.buf[b]); } CS = 0; for(;;) { CE = 1; while(DR1 == 0) { //rst_wdog(); nop(); } a[0]=SpiReadWrite(0); a[1]=SpiReadWrite(1); a[2]= SpiReadWrite(2); CE = 0; LED=1; count0=0; TR0 = 1; if(fsen==0) { fs(); } //rst_wdog(); } } void Transmitter(void) { unsigned char b; CS = 1; Delay100us(0); for(b=0;b SpiReadWrite(tconf.buf[b]); } CS = 0; for(;;) { //rst_wdog(); TransmitPacket(); // Transmit data over_flag=0; TR1=1; LED=1; while(!over_flag) { nop(); } } } void Init(void) { uchar i; uchar j; P0_DIR=0x00; P0=0xfb; P1=0xff; SPICLK=1; SPI_CTRL=0x02; //连接到RADIO上 PWR_UP = 1; // Turn on Radio on 24E1 Delay100us(30); // Wait > 3ms InitTimer(); EA = 1; for(j=0;j<2;j++) { LED=1; for(i=0;i<10;i++) { Delay100us(250); Delay100us(250); } LED=0; for(i=0;i<10;i++) { Delay100us(250); Delay100us(250); } } } void main(void) { Init(); /*f((REGX_CTRL&0x10)!=0x10) { REGX_MSB=0x75; REGX_LSB=0x30; REGX_CTRL=0x08; } */ //Recei
NRF9E51IC卡卡 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)