nRF2401RX.LST
上传用户:gxz1972
上传日期:2019-09-13
资源大小:323k
文件大小:38k
- C51 COMPILER V7.02b NRF2401RX 11/30/2007 14:07:15 PAGE 1
- C51 COMPILER V7.02b, COMPILATION OF MODULE NRF2401RX
- OBJECT MODULE PLACED IN nRF2401RX.OBJ
- COMPILER INVOKED BY: C:KeilC51BINc51.exe nRF2401RX.c DB OE
- stmt level source
- 1 //-----------------------------------------------------------------------------
- 2 // nRF2401RX.c
- 3 //-----------------------------------------------------------------------------
- 4 // Copyright 2007 Vson Technology, Inc.
- 5 // http://www.usbmcu.com
- 6 //
- 7 // Program Description:
- 8 //
- 9 //
- 10 //
- 11 //
- 12 //
- 13 // MCU: C8051F347
- 14 // Tool chain: Keil C51 7.50 / Keil EVAL C51
- 15 // Silicon Laboratories IDE version 2.6
- 16 // Command Line:
- 17 // Project Name: TR1000
- 18 //
- 19 //
- 20 // Release 1.0
- 21 // -All changes by Brin
- 22 // -24 JUL 2007
- 23 //
- 24 // 2007.10.19更改 1. 丢弃包序相同的数据——》丢弃ID相同且包序号相同的数据(建1K缓冲区存 ID号 包序号)
- 25 //
- 26
- 27
- 28 #include "Include_H.h"
- 29
- 30 #define _RF_PADLOAD_TEST_
- 31 void nRF2401Configuration(void)
- 32 {
- 33 1 unsigned char i;
- 34 1 /*==================================================*/
- 35 1 //config channeal 1
- 36 1 /*==================================================*/
- 37 1 //Configuration initial
- 38 1 //BS CONFIG_PORT,PWR_UP //
- 39 1 sbitRfCE1 = 0;
- 40 1 sbitRfCS1 = 0;//BC CONFIG_PORT,CS //CE==1
- 41 1 sbitRfCLK1 = 0;//BC CONFIG_PORT,CLK
- 42 1 sbitRfData1 = 0;//BC CONFIG_PORT,DIN
- 43 1 //Configuration initial end
- 44 1
- 45 1 sbitRfCS1 = 1;//BS CONFIG_PORT,CS //entry configuration mode ce==0
- 46 1 //CALL Delay_5us //Tcs2data min. 5us
- 47 1 for (i = 0; i < 20; i++); // Wait 5us
- 48 1
- 49 1 Channel1Write8bitData(RF_CONFIG_DATA14);
- 50 1 Channel1Write8bitData(RF_CONFIG_DATA13);
- 51 1 Channel1Write8bitData(RF_CONFIG_DATA12);
- 52 1 Channel1Write8bitData(RF_CONFIG_DATA11);
- 53 1 Channel1Write8bitData(RF_CONFIG_DATA10);
- 54 1 Channel1Write8bitData(RF_CONFIG_DATA9);
- 55 1 Channel1Write8bitData(RF_CONFIG_DATA8);
- C51 COMPILER V7.02b NRF2401RX 11/30/2007 14:07:15 PAGE 2
- 56 1 Channel1Write8bitData(RF_CONFIG_DATA7);
- 57 1 Channel1Write8bitData(RF_CONFIG_DATA6);
- 58 1 Channel1Write8bitData(RF_CONFIG_DATA5);
- 59 1 Channel1Write8bitData(RF_CONFIG_DATA4);
- 60 1 Channel1Write8bitData(RF_CONFIG_DATA3);
- 61 1 Channel1Write8bitData(RF_CONFIG_DATA2);
- 62 1 Channel1Write8bitData(RF_CONFIG_DATA1);
- 63 1 Channel1Write8bitData(gaucRfConfigData0[0]);//(RF_CONFIG_DATA00);
- 64 1
- 65 1 for (i = 0; i < 20; i++); // Wait 5us
- 66 1
- 67 1 sbitRfCS1 = 0; //BC CONFIG_PORT,CS //After finish configuration mode,Entry stanby mode
- 68 1 sbitRfData1 = 0; //BC CONFIG_PORT,DIN //Remain low
- 69 1
- 70 1 sbitRfCE1 = 1; //BS CONFIG_PORT,CE
- 71 1
- 72 1
- 73 1 for (i = 0; i < 200; i++); // Wait 5us
- 74 1
- 75 1 /*==================================================*/
- 76 1 //config channeal 2
- 77 1 /*==================================================*/
- 78 1
- 79 1
- 80 1 //Configuration initial
- 81 1 //BS CONFIG_PORT,PWR_UP //
- 82 1 sbitRfCE2 = 0;
- 83 1 sbitRfCS2 = 0;//BC CONFIG_PORT,CS //CE==1
- 84 1 sbitRfCLK2 = 0;//BC CONFIG_PORT,CLK
- 85 1 sbitRfData2 = 0;//BC CONFIG_PORT,DIN
- 86 1 //Configuration initial end
- 87 1
- 88 1
- 89 1 sbitRfCS2 = 1;//BS CONFIG_PORT,CS //entry configuration mode ce==0
- 90 1 //CALL Delay_5us //Tcs2data min. 5us
- 91 1 for (i = 0; i < 20; i++); // Wait 5us
- 92 1
- 93 1 Channel2Write8bitData(RF_CONFIG_DATA14);
- 94 1 Channel2Write8bitData(RF_CONFIG_DATA13);
- 95 1 Channel2Write8bitData(RF_CONFIG_DATA12);
- 96 1 Channel2Write8bitData(RF_CONFIG_DATA11);
- 97 1 Channel2Write8bitData(RF_CONFIG_DATA10);
- 98 1 Channel2Write8bitData(RF_CONFIG_DATA9);
- 99 1 Channel2Write8bitData(RF_CONFIG_DATA8);
- 100 1 Channel2Write8bitData(RF_CONFIG_DATA7);
- 101 1 Channel2Write8bitData(RF_CONFIG_DATA6);
- 102 1 Channel2Write8bitData(RF_CONFIG_DATA5);
- 103 1 Channel2Write8bitData(RF_CONFIG_DATA4);
- 104 1 Channel2Write8bitData(RF_CONFIG_DATA3);
- 105 1 Channel2Write8bitData(RF_CONFIG_DATA2);
- 106 1 Channel2Write8bitData(RF_CONFIG_DATA1);
- 107 1 Channel2Write8bitData(gaucRfConfigData0[1]);//(RF_CONFIG_DATA00);
- 108 1
- 109 1 for (i = 0; i < 20; i++); // Wait 5us
- 110 1
- 111 1 sbitRfCS2 = 0; //BC CONFIG_PORT,CS //After finish configuration mode,Entry stanby mode
- 112 1 sbitRfData2 = 0; //BC CONFIG_PORT,DIN //Remain low
- 113 1
- 114 1 sbitRfCE2 = 1; //BS CONFIG_PORT,CE
- 115 1
- 116 1 //***********************************************************
- 117 1
- C51 COMPILER V7.02b NRF2401RX 11/30/2007 14:07:15 PAGE 3
- 118 1 for (i = 0; i < 200; i++); // Wait 5us
- 119 1
- 120 1 /*==================================================*/
- 121 1 //config channeal 3
- 122 1 /*==================================================*/
- 123 1 //Configuration initial
- 124 1 //BS CONFIG_PORT,PWR_UP //
- 125 1 sbitRfCE3 = 0;
- 126 1 sbitRfCS3 = 0;//BC CONFIG_PORT,CS //CE==1
- 127 1 sbitRfCLK3 = 0;//BC CONFIG_PORT,CLK
- 128 1 sbitRfData3 = 0;//BC CONFIG_PORT,DIN
- 129 1 //Configuration initial end
- 130 1
- 131 1
- 132 1 sbitRfCS3 = 1;//BS CONFIG_PORT,CS //entry configuration mode ce==0
- 133 1 //CALL Delay_5us //Tcs2data min. 5us
- 134 1 for (i = 0; i < 20; i++); // Wait 5us
- 135 1
- 136 1 Channel3Write8bitData(RF_CONFIG_DATA14);
- 137 1 Channel3Write8bitData(RF_CONFIG_DATA13);
- 138 1 Channel3Write8bitData(RF_CONFIG_DATA12);
- 139 1 Channel3Write8bitData(RF_CONFIG_DATA11);
- 140 1 Channel3Write8bitData(RF_CONFIG_DATA10);
- 141 1 Channel3Write8bitData(RF_CONFIG_DATA9);
- 142 1 Channel3Write8bitData(RF_CONFIG_DATA8);
- 143 1 Channel3Write8bitData(RF_CONFIG_DATA7);
- 144 1 Channel3Write8bitData(RF_CONFIG_DATA6);
- 145 1 Channel3Write8bitData(RF_CONFIG_DATA5);
- 146 1 Channel3Write8bitData(RF_CONFIG_DATA4);
- 147 1 Channel3Write8bitData(RF_CONFIG_DATA3);
- 148 1 Channel3Write8bitData(RF_CONFIG_DATA2);
- 149 1 Channel3Write8bitData(RF_CONFIG_DATA1);
- 150 1 Channel3Write8bitData(gaucRfConfigData0[2]);//(RF_CONFIG_DATA00);
- 151 1
- 152 1 for (i = 0; i < 20; i++); // Wait 5us
- 153 1
- 154 1 sbitRfCS3 = 0; //BC CONFIG_PORT,CS //After finish configuration mode,Entry stanby mode
- 155 1 sbitRfData3 = 0; //BC CONFIG_PORT,DIN //Remain low
- 156 1
- 157 1 sbitRfCE3 = 1; //BS CONFIG_PORT,CE
- 158 1
- 159 1 //***********************************************************
- 160 1
- 161 1 for (i = 0; i < 200; i++); // Wait 5us
- 162 1
- 163 1
- 164 1 /*==================================================*/
- 165 1 //config channeal 4
- 166 1 /*==================================================*/
- 167 1 //Configuration initial
- 168 1 //BS CONFIG_PORT,PWR_UP //
- 169 1 sbitRfCE4 = 0;
- 170 1 sbitRfCS4 = 0;//BC CONFIG_PORT,CS //CE==1
- 171 1 sbitRfCLK4 = 0;//BC CONFIG_PORT,CLK
- 172 1 sbitRfData4 = 0;//BC CONFIG_PORT,DIN
- 173 1 //Configuration initial end
- 174 1
- 175 1
- 176 1 sbitRfCS4 = 1;//BS CONFIG_PORT,CS //entry configuration mode ce==0
- 177 1 //CALL Delay_5us //Tcs2data min. 5us
- 178 1 for (i = 0; i < 20; i++); // Wait 5us
- 179 1
- C51 COMPILER V7.02b NRF2401RX 11/30/2007 14:07:15 PAGE 4
- 180 1 Channel4Write8bitData(RF_CONFIG_DATA14);
- 181 1 Channel4Write8bitData(RF_CONFIG_DATA13);
- 182 1 Channel4Write8bitData(RF_CONFIG_DATA12);
- 183 1 Channel4Write8bitData(RF_CONFIG_DATA11);
- 184 1 Channel4Write8bitData(RF_CONFIG_DATA10);
- 185 1 Channel4Write8bitData(RF_CONFIG_DATA9);
- 186 1 Channel4Write8bitData(RF_CONFIG_DATA8);
- 187 1 Channel4Write8bitData(RF_CONFIG_DATA7);
- 188 1 Channel4Write8bitData(RF_CONFIG_DATA6);
- 189 1 Channel4Write8bitData(RF_CONFIG_DATA5);
- 190 1 Channel4Write8bitData(RF_CONFIG_DATA4);
- 191 1 Channel4Write8bitData(RF_CONFIG_DATA3);
- 192 1 Channel4Write8bitData(RF_CONFIG_DATA2);
- 193 1 Channel4Write8bitData(RF_CONFIG_DATA1);
- 194 1 Channel4Write8bitData(gaucRfConfigData0[3]);//(RF_CONFIG_DATA00);
- 195 1
- 196 1 for (i = 0; i < 20; i++); // Wait 5us
- 197 1
- 198 1 sbitRfCS4 = 0; //BC CONFIG_PORT,CS //After finish configuration mode,Entry stanby mode
- 199 1 sbitRfData4 = 0; //BC CONFIG_PORT,DIN //Remain low
- 200 1
- 201 1 sbitRfCE4 = 1; //BS CONFIG_PORT,CE
- 202 1
- 203 1 //***********************************************************
- 204 1 }
- 205
- 206 //====================================================
- 207 //====================================================
- 208 //Low for ready Data High for Write Data
- 209 //时序 Low 8 LowHigh Low
- 210 void Channel1Write8bitData(unsigned char ucWriteData)
- 211 {
- 212 1 unsigned char ucGeneralCount=0;
- 213 1 unsigned char i;
- 214 1 //__disable_interrupt();
- 215 1
- 216 1 for (ucGeneralCount=0;ucGeneralCount<8;ucGeneralCount++)
- 217 1 {
- 218 2
- 219 2 sbitRfCLK1 = 0;
- 220 2 for (i = 0; i < 1; i++); // Wait 0.5us
- 221 2 if ((ucWriteData & BIT7) == BIT7)
- 222 2 {sbitRfData1 = 1;} //set DATA bit
- 223 2 else
- 224 2 {sbitRfData1 = 0;} //reset DATA bit
- 225 2 for (i = 0; i < 1; i++); // Wait 0.5us
- 226 2 sbitRfCLK1 = 1;
- 227 2 for (i = 0; i < 2; i++); // Wait 1us
- 228 2 ucWriteData=ucWriteData<<1; //MSB
- 229 2 }
- 230 1
- 231 1 sbitRfCLK1 = 0;// for last low
- 232 1 //sbitRfData1 = 0;
- 233 1 //_EINT(); //enable interrupt
- 234 1 }
- 235
- 236 //====================================================
- 237 //====================================================
- 238 //Low for ready Data High for Write Data
- 239 //时序 Low 8 LowHigh Low
- 240 void Channel2Write8bitData(unsigned char ucWriteData)
- 241 {
- C51 COMPILER V7.02b NRF2401RX 11/30/2007 14:07:15 PAGE 5
- 242 1 unsigned char ucGeneralCount=0;
- 243 1 unsigned char i;
- 244 1 //__disable_interrupt();
- 245 1
- 246 1 for (ucGeneralCount=0;ucGeneralCount<8;ucGeneralCount++)
- 247 1 {
- 248 2
- 249 2 sbitRfCLK2 = 0;
- 250 2 for (i = 0; i < 1; i++); // Wait 0.5us
- 251 2 if ((ucWriteData & BIT7) == BIT7)
- 252 2 {sbitRfData2 = 1;} //set DATA bit
- 253 2 else
- 254 2 {sbitRfData2 = 0;} //reset DATA bit
- 255 2 for (i = 0; i < 1; i++); // Wait 0.5us
- 256 2 sbitRfCLK2 = 1;
- 257 2 for (i = 0; i < 2; i++); // Wait 1us
- 258 2 ucWriteData=ucWriteData<<1; //MSB
- 259 2 }
- 260 1
- 261 1 sbitRfCLK2 = 0;// for last low
- 262 1 //sbitRfData2 = 0;
- 263 1 //_EINT(); //enable interrupt
- 264 1 }
- 265
- 266 //====================================================
- 267 //====================================================
- 268 //Low for ready Data High for Write Data
- 269 //时序 Low 8 LowHigh Low
- 270 void Channel3Write8bitData(unsigned char ucWriteData)
- 271 {
- 272 1 unsigned char ucGeneralCount=0;
- 273 1 unsigned char i;
- 274 1 //__disable_interrupt();
- 275 1
- 276 1 for (ucGeneralCount=0;ucGeneralCount<8;ucGeneralCount++)
- 277 1 {
- 278 2
- 279 2 sbitRfCLK3 = 0;
- 280 2 for (i = 0; i < 1; i++); // Wait 0.5us
- 281 2 if ((ucWriteData & BIT7) == BIT7)
- 282 2 {sbitRfData3 = 1;} //set DATA bit
- 283 2 else
- 284 2 {sbitRfData3 = 0;} //reset DATA bit
- 285 2 for (i = 0; i < 1; i++); // Wait 0.5us
- 286 2 sbitRfCLK3 = 1;
- 287 2 for (i = 0; i < 2; i++); // Wait 1us
- 288 2 ucWriteData=ucWriteData<<1; //MSB
- 289 2 }
- 290 1
- 291 1 sbitRfCLK3 = 0;// for last low
- 292 1 //sbitRfData3 = 0;
- 293 1 //_EINT(); //enable interrupt
- 294 1 }
- 295
- 296 //====================================================
- 297 //====================================================
- 298 //Low for ready Data High for Write Data
- 299 //时序 Low 8 LowHigh Low
- 300 void Channel4Write8bitData(unsigned char ucWriteData)
- 301 {
- 302 1 unsigned char ucGeneralCount=0;
- 303 1 unsigned char i;
- C51 COMPILER V7.02b NRF2401RX 11/30/2007 14:07:15 PAGE 6
- 304 1 //__disable_interrupt();
- 305 1
- 306 1 for (ucGeneralCount=0;ucGeneralCount<8;ucGeneralCount++)
- 307 1 {
- 308 2
- 309 2 sbitRfCLK4 = 0;
- 310 2 for (i = 0; i < 1; i++); // Wait 0.5us
- 311 2 if ((ucWriteData & BIT7) == BIT7)
- 312 2 {sbitRfData4 = 1;} //set DATA bit
- 313 2 else
- 314 2 {sbitRfData4 = 0;} //reset DATA bit
- 315 2 for (i = 0; i < 1; i++); // Wait 0.5us
- 316 2 sbitRfCLK4 = 1;
- 317 2 for (i = 0; i < 2; i++); // Wait 1us
- 318 2 ucWriteData=ucWriteData<<1; //MSB
- 319 2 }
- 320 1
- 321 1 sbitRfCLK4 = 0;// for last low
- 322 1 //sbitRfData4 = 0;
- 323 1 //_EINT(); //enable interrupt
- 324 1 }
- 325
- 326
- 327
- 328
- 329 //============================================================================================
- 330 //
- 331 //============================================================================================
- 332 bit nRF2401RxData(void)
- 333 {
- 334 1 unsigned char i;
- 335 1 // unsigned int j;
- 336 1 bit bitReceivedDataFlag = 0;
- 337 1 //ShockBurst TX initial
- 338 1 //sbitRfCE1 = 1;
- 339 1 //sbitRfCS1 = 0;//BC CONFIG_PORT,CS
- 340 1 //sbitRfCLK1 = 0;//BC CONFIG_PORT,CLK
- 341 1 //sbitRfData1 = 0;//BC CONFIG_PORT,DIN
- 342 1 //ShockBurst TX initial end
- 343 1
- 344 1
- 345 1 //for (i = 0; i < 20; i++); // Wait 5us //Tce2data min. 5us
- 346 1
- 347 1 for (i = 0; i < 1; i++)
- 348 1 {
- 349 2 //==================================================================
- 350 2 //Channel 1
- 351 2 //==================================================================
- 352 2 // for (i = 0; i < 1; i++)
- 353 2 // {
- 354 2 //if ( (sbitRfDR1 == 1) | (sbitRfDR2 == 1) | (sbitRfDR3 == 1) | (sbitRfDR4 == 1) )
- 355 2 if (sbitRfDR1 == 1)//(bitReceivedDataFlag == 0)//(sbitRfDR1 == 1)
- 356 2 {
- 357 3
- 358 3 sbitLED = 0;
- 359 3 //Receive_data_start:
- 360 3
- 361 3 //DelayMs(5);
- 362 3
- 363 3 /*
- 364 3 for (j = 0; j < 20000; j++) // Wait 5us
- 365 3 {
- C51 COMPILER V7.02b NRF2401RX 11/30/2007 14:07:15 PAGE 7
- 366 3 for (i = 0; i < 200; i++)
- 367 3 {;}
- 368 3 }
- 369 3 */
- 370 3
- 371 3 //StartTimer2(10); //200ms //收到数据,启动计时200ms
- 372 3 //StartTimer2(20); //200ms //收到数据,启动计时200ms //modify at 2007.11.19
- 373 3 StartTimer2(40); //200ms //收到数据,启动计时200ms //modify at 2007.11.30
- 374 3
- 375 3
- 376 3 gaucRxDataFromRfBuffer[COUNT_BASE + (COUNT_BASE + RF_PADLOAD)*0 + 0] = Channel1Read8bitData();
- 377 3
- 378 3 gaucRxDataFromRfBuffer[COUNT_BASE + (COUNT_BASE + RF_PADLOAD)*0 + 1] = Channel1Read8bitData();
- 379 3
- 380 3 gaucRxDataFromRfBuffer[COUNT_BASE + (COUNT_BASE + RF_PADLOAD)*0 + 2] = Channel1Read8bitData();
- 381 3
- 382 3 gaucRxDataFromRfBuffer[COUNT_BASE + (COUNT_BASE + RF_PADLOAD)*0 + 3] = Channel1Read8bitData();
- 383 3
- 384 3 gaucRxDataFromRfBuffer[COUNT_BASE + (COUNT_BASE + RF_PADLOAD)*0 + 4] = Channel1Read8bitData();
- 385 3
- 386 3 gaucRxDataFromRfBuffer[COUNT_BASE + (COUNT_BASE + RF_PADLOAD)*0 + 5] = Channel1Read8bitData();
- 387 3
- 388 3 gaucRxDataFromRfBuffer[COUNT_BASE + (COUNT_BASE + RF_PADLOAD)*0 + 6] = Channel1Read8bitData();
- 389 3
- 390 3 #ifndef _RF_PADLOAD_TEST_
- //#define _RF_PADLOAD_TEST_
-
- gaucRxDataFromRfBuffer[COUNT_BASE + (COUNT_BASE + RF_PADLOAD)*0 + 7] = Channel1Read8bitData();
-
- gaucRxDataFromRfBuffer[COUNT_BASE + (COUNT_BASE + RF_PADLOAD)*0 + 8] = Channel1Read8bitData();
-
- #endif
- 398 3
- 399 3 //#ifndef _USB_REQUEST_H
- 400 3 //Channel1Read8bitData();
- 401 3
- 402 3
- 403 3
- 404 3
- 405 3 while( sbitRfDR1 == 1 )
- 406 3 {
- 407 4 ;
- 408 4 }
- 409 3
- 410 3 sbitLED = 1;
- 411 3
- 412 3 //DelayMs(100);
- 413 3 bitReceivedDataFlag = 1; //Set flag for quit the Check Circle
- 414 3
- 415 3
- 416 3 }//if
- 417 2
- 418 2 if (bitReceivedDataFlag == 1)
- 419 2 break;
- 420 2
- 421 2 //}//for
- 422 2
- 423 2 /*
- 424 2
- 425 2 //==================================================================
- 426 2 //Channel 2
- 427 2 //==================================================================
- C51 COMPILER V7.02b NRF2401RX 11/30/2007 14:07:15 PAGE 8
- 428 2
- 429 2 //for (i = 0; i < 1; i++)
- 430 2 //{
- 431 2 if (sbitRfDR2 == 1)
- 432 2 {
- 433 2 sbitLED = 0;
- 434 2 //Receive_data_start:
- 435 2
- 436 2 DelayMs(5);
- 437 2
- 438 2 gaucRxDataFromRfBuffer[COUNT_BASE + (COUNT_BASE + RF_PADLOAD)*0 + 0] = Channel2Read8bitData();
- 439 2
- 440 2 gaucRxDataFromRfBuffer[COUNT_BASE + (COUNT_BASE + RF_PADLOAD)*0 + 1] = Channel2Read8bitData();
- 441 2
- 442 2 gaucRxDataFromRfBuffer[COUNT_BASE + (COUNT_BASE + RF_PADLOAD)*0 + 2] = Channel2Read8bitData();
- 443 2
- 444 2 gaucRxDataFromRfBuffer[COUNT_BASE + (COUNT_BASE + RF_PADLOAD)*0 + 3] = Channel2Read8bitData();
- 445 2
- 446 2 gaucRxDataFromRfBuffer[COUNT_BASE + (COUNT_BASE + RF_PADLOAD)*0 + 4] = Channel2Read8bitData();
- 447 2
- 448 2 gaucRxDataFromRfBuffer[COUNT_BASE + (COUNT_BASE + RF_PADLOAD)*0 + 5] = Channel2Read8bitData();
- 449 2
- 450 2 gaucRxDataFromRfBuffer[COUNT_BASE + (COUNT_BASE + RF_PADLOAD)*0 + 6] = Channel2Read8bitData();
- 451 2
- 452 2 #ifndef _RF_PADLOAD_TEST_
- 453 2
- 454 2 gaucRxDataFromRfBuffer[COUNT_BASE + (COUNT_BASE + RF_PADLOAD)*0 + 7] = Channel2Read8bitData();
- 455 2
- 456 2 gaucRxDataFromRfBuffer[COUNT_BASE + (COUNT_BASE + RF_PADLOAD)*0 + 8] = Channel2Read8bitData();
- 457 2
- 458 2 #endif
- 459 2
- 460 2
- 461 2
- 462 2 while( sbitRfDR2 == 1 )
- 463 2 {
- 464 2 ;
- 465 2 }
- 466 2
- 467 2 sbitLED = 1;
- 468 2
- 469 2 //DelayMs(100);
- 470 2 bitReceivedDataFlag = 1; //Set flag for quit the Check Circle
- 471 2
- 472 2
- 473 2 }//if
- 474 2
- 475 2 if (bitReceivedDataFlag == 1)
- 476 2 break;
- 477 2
- 478 2 //}//for
- 479 2
- 480 2 //DelayMs(1);
- 481 2
- 482 2
- 483 2
- 484 2
- 485 2 //=========================================================================
- 486 2 //Channel 3
- 487 2 //=========================================================================
- 488 2
- 489 2 // for (i = 0; i < 1; i++)
- C51 COMPILER V7.02b NRF2401RX 11/30/2007 14:07:15 PAGE 9
- 490 2 // {
- 491 2 if (sbitRfDR3 == 1)//(bitReceivedDataFlag == 0)//
- 492 2 {
- 493 2 sbitLED = 0;
- 494 2 //Receive_data_start:
- 495 2
- 496 2 DelayMs(5);
- 497 2
- 498 2 gaucRxDataFromRfBuffer[COUNT_BASE + (COUNT_BASE + RF_PADLOAD)*0 + 0] = Channel3Read8bitData();
- 499 2
- 500 2 gaucRxDataFromRfBuffer[COUNT_BASE + (COUNT_BASE + RF_PADLOAD)*0 + 1] = Channel3Read8bitData();
- 501 2
- 502 2 gaucRxDataFromRfBuffer[COUNT_BASE + (COUNT_BASE + RF_PADLOAD)*0 + 2] = Channel3Read8bitData();
- 503 2
- 504 2 gaucRxDataFromRfBuffer[COUNT_BASE + (COUNT_BASE + RF_PADLOAD)*0 + 3] = Channel3Read8bitData();
- 505 2
- 506 2 gaucRxDataFromRfBuffer[COUNT_BASE + (COUNT_BASE + RF_PADLOAD)*0 + 4] = Channel3Read8bitData();
- 507 2
- 508 2 gaucRxDataFromRfBuffer[COUNT_BASE + (COUNT_BASE + RF_PADLOAD)*0 + 5] = Channel3Read8bitData();
- 509 2
- 510 2 gaucRxDataFromRfBuffer[COUNT_BASE + (COUNT_BASE + RF_PADLOAD)*0 + 6] = Channel3Read8bitData();
- 511 2
- 512 2 #ifndef _RF_PADLOAD_TEST_
- 513 2
- 514 2 gaucRxDataFromRfBuffer[COUNT_BASE + (COUNT_BASE + RF_PADLOAD)*0 + 7] = Channel3Read8bitData();
- 515 2
- 516 2 gaucRxDataFromRfBuffer[COUNT_BASE + (COUNT_BASE + RF_PADLOAD)*0 + 8] = Channel3Read8bitData();
- 517 2
- 518 2 #endif
- 519 2
- 520 2
- 521 2
- 522 2 while( sbitRfDR3 == 1 )
- 523 2 {
- 524 2 ;
- 525 2 }
- 526 2
- 527 2 sbitLED = 1;
- 528 2
- 529 2 //DelayMs(100);
- 530 2 bitReceivedDataFlag = 1; //Set flag for quit the Check Circle
- 531 2
- 532 2
- 533 2 }//if
- 534 2 if (bitReceivedDataFlag == 1)
- 535 2 break;
- 536 2
- 537 2 // }//for
- 538 2
- 539 2
- 540 2
- 541 2
- 542 2 //=========================================================================
- 543 2 //Channel 4
- 544 2 //=========================================================================
- 545 2 // for (i = 0; i < 1; i++)
- 546 2 // {
- 547 2 if (sbitRfDR4 == 1)
- 548 2 {
- 549 2 sbitLED = 0;
- 550 2 //Receive_data_start:
- 551 2
- C51 COMPILER V7.02b NRF2401RX 11/30/2007 14:07:15 PAGE 10
- 552 2 DelayMs(5);
- 553 2
- 554 2 gaucRxDataFromRfBuffer[COUNT_BASE + (COUNT_BASE + RF_PADLOAD)*0 + 0] = Channel4Read8bitData();
- 555 2
- 556 2 gaucRxDataFromRfBuffer[COUNT_BASE + (COUNT_BASE + RF_PADLOAD)*0 + 1] = Channel4Read8bitData();
- 557 2
- 558 2 gaucRxDataFromRfBuffer[COUNT_BASE + (COUNT_BASE + RF_PADLOAD)*0 + 2] = Channel4Read8bitData();
- 559 2
- 560 2 gaucRxDataFromRfBuffer[COUNT_BASE + (COUNT_BASE + RF_PADLOAD)*0 + 3] = Channel4Read8bitData();
- 561 2
- 562 2 gaucRxDataFromRfBuffer[COUNT_BASE + (COUNT_BASE + RF_PADLOAD)*0 + 4] = Channel4Read8bitData();
- 563 2
- 564 2 gaucRxDataFromRfBuffer[COUNT_BASE + (COUNT_BASE + RF_PADLOAD)*0 + 5] = Channel4Read8bitData();
- 565 2
- 566 2 gaucRxDataFromRfBuffer[COUNT_BASE + (COUNT_BASE + RF_PADLOAD)*0 + 6] = Channel4Read8bitData();
- 567 2
- 568 2 #ifndef _RF_PADLOAD_TEST_
- 569 2
- 570 2 gaucRxDataFromRfBuffer[COUNT_BASE + (COUNT_BASE + RF_PADLOAD)*0 + 7] = Channel4Read8bitData();
- 571 2
- 572 2 gaucRxDataFromRfBuffer[COUNT_BASE + (COUNT_BASE + RF_PADLOAD)*0 + 8] = Channel4Read8bitData();
- 573 2
- 574 2 #endif
- 575 2
- 576 2
- 577 2
- 578 2 while( sbitRfDR4 == 1 )
- 579 2 {
- 580 2 ;
- 581 2 }
- 582 2
- 583 2 sbitLED = 1;
- 584 2
- 585 2 //DelayMs(100);
- 586 2 bitReceivedDataFlag = 1; //Set flag for quit the Check Circle
- 587 2
- 588 2
- 589 2 }//if
- 590 2
- 591 2
- 592 2
- 593 2
- 594 2 if (bitReceivedDataFlag == 1)
- 595 2 break;
- 596 2
- 597 2 //}//for
- 598 2
- 599 2 */
- 600 2
- 601 2 }//for
- 602 1 //=============================================================================================
- 603 1
- 604 1 if (bitReceivedDataFlag == 1)
- 605 1 {
- 606 2 //数据格式:地址2,地址1,地址0,数据3,数据2,数据1,数据0 地址2最高位bit7--0:学生机 1:教师机
- 607 2 if ((gaucRxDataFromRfBuffer[COUNT_BASE + (COUNT_BASE + RF_PADLOAD)*0 + 0] & BIT7) == BIT7)
- 608 2 {
- 609 3 //1:教师机
- 610 3 if ((gaucRxDataFromRfBuffer[COUNT_BASE + (COUNT_BASE + RF_PADLOAD)*0 + 3] & BIT7) == BIT7)
- 611 3 M_State = TX_TEACHER_KEY_DATA_TO_HOST_STATUS;
- 612 3 else
- 613 3 M_State = TX_TOUCHPAD_DATA_TO_HOST_STATUS;
- C51 COMPILER V7.02b NRF2401RX 11/30/2007 14:07:15 PAGE 11
- 614 3 }
- 615 2 else
- 616 2 {
- 617 3 //0:学生机
- 618 3
- 619 3 //数据3 bit7--1:有后续包 0:最后一包 bit6--1:考试数据 0:按键数据
- 620 3 if ( (gaucRxDataFromRfBuffer[5] & BIT6) == BIT6 )
- 621 3 {
- 622 4 M_State = TX_STUDENT_EXAM_DATA_TO_HOST_STATUS;
- 623 4 }
- 624 3 else
- 625 3 {
- 626 4 M_State = TX_STUDENT_KEY_DATA_TO_HOST_STATUS;
- 627 4 }
- 628 3
- 629 3 }
- 630 2 }
- 631 1 return bitReceivedDataFlag;
- 632 1
- 633 1 }
- 634
- 635
- 636 //nRF2401 ready Data when CLK is Low; Mcu read data when CLK is high
- 637 //CLK时序: Low 8个HighLow Low
- 638 unsigned char Channel1Read8bitData(void)
- 639 {
- 640 1 unsigned char ucGeneralCount=0;
- 641 1 unsigned char ucReadData=0;
- 642 1 unsigned char i;
- 643 1 //unsigned char j=0;
- 644 1 //__disable_interrupt();
- 645 1 sbitRfCLK1 = 0;
- 646 1 //j = P2MDOUT;
- 647 1 //j = P2;
- 648 1 //j = P0;
- 649 1 for (ucGeneralCount=0;ucGeneralCount<8;ucGeneralCount++)
- 650 1 {
- 651 2
- 652 2
- 653 2 ucReadData = ucReadData<<1;//MSB
- 654 2
- 655 2
- 656 2 sbitRfCLK1 = 1;//BS CONFIG_PORT,CLK ;Time Hold min.500ns
- 657 2 for (i = 0; i < 1; i++); // Wait 2.5us
- 658 2 if (sbitRfData1 == 1)
- 659 2 {ucReadData |= BIT0;} //bit 1
- 660 2 else
- 661 2 {ucReadData &= ~BIT0;} // bit is 0
- 662 2 //for (i = 0; i < 1; i++); // Wait 2.5us
- 663 2 for (i = 0; i < 1; i++); // Wait 2.5us
- 664 2
- 665 2 sbitRfCLK1 = 0;
- 666 2 for (i = 0; i < 2; i++); // Wait 2.5us
- 667 2
- 668 2
- 669 2 }
- 670 1 return ucReadData;
- 671 1 }
- 672
- 673
- 674 /*
- 675
- C51 COMPILER V7.02b NRF2401RX 11/30/2007 14:07:15 PAGE 12
- 676 //nRF2401 ready Data when CLK is Low; Mcu read data when CLK is high
- 677 //CLK时序: Low 8个HighLow Low
- 678 unsigned char Channel2Read8bitData(void)
- 679 {
- 680 unsigned char ucGeneralCount=0;
- 681 unsigned char ucReadData=0;
- 682 unsigned char i;
- 683 //unsigned char j=0;
- 684 //__disable_interrupt();
- 685 sbitRfCLK2 = 0;
- 686 //j = P2MDOUT;
- 687 //j = P2;
- 688 //j = P0;
- 689 for (ucGeneralCount=0;ucGeneralCount<8;ucGeneralCount++)
- 690 {
- 691
- 692
- 693 ucReadData=ucReadData<<1;//MSB
- 694
- 695
- 696 sbitRfCLK2 = 1;//BS CONFIG_PORT,CLK ;Time Hold min.500ns
- 697 for (i = 0; i < 1; i++); // Wait 2.5us
- 698 if (sbitRfData2 == 1)
- 699 {ucReadData |= BIT0;} //bit 1
- 700 else
- 701 {ucReadData &= ~BIT0;} // bit is 0
- 702 //for (i = 0; i < 1; i++); // Wait 2.5us
- 703 for (i = 0; i < 1; i++); // Wait 2.5us
- 704
- 705 sbitRfCLK2 = 0;
- 706 for (i = 0; i < 2; i++); // Wait 2.5us
- 707
- 708
- 709 }
- 710 return ucReadData;
- 711 }
- 712
- 713 //nRF2401 ready Data when CLK is Low; Mcu read data when CLK is high
- 714 //CLK时序: Low 8个HighLow Low
- 715 unsigned char Channel3Read8bitData(void)
- 716 {
- 717 unsigned char ucGeneralCount=0;
- 718 unsigned char ucReadData=0;
- 719 unsigned char i;
- 720 //unsigned char j=0;
- 721 //__disable_interrupt();
- 722 sbitRfCLK3 = 0;
- 723 //j = P2MDOUT;
- 724 //j = P2;
- 725 //j = P0;
- 726 for (ucGeneralCount=0;ucGeneralCount<8;ucGeneralCount++)
- 727 {
- 728
- 729
- 730 ucReadData=ucReadData<<1;//MSB
- 731
- 732
- 733 sbitRfCLK3 = 1;//BS CONFIG_PORT,CLK ;Time Hold min.500ns
- 734 for (i = 0; i < 1; i++); // Wait 2.5us
- 735 if (sbitRfData3 == 1)
- 736 {ucReadData |= BIT0;} //bit 1
- 737 else
- C51 COMPILER V7.02b NRF2401RX 11/30/2007 14:07:15 PAGE 13
- 738 {ucReadData &= ~BIT0;} // bit is 0
- 739 //for (i = 0; i < 1; i++); // Wait 2.5us
- 740 for (i = 0; i < 1; i++); // Wait 2.5us
- 741
- 742 sbitRfCLK3 = 0;
- 743 for (i = 0; i < 2; i++); // Wait 2.5us
- 744
- 745
- 746 }
- 747 return ucReadData;
- 748 }
- 749
- 750
- 751 //nRF2401 ready Data when CLK is Low; Mcu read data when CLK is high
- 752 //CLK时序: Low 8个HighLow Low
- 753 unsigned char Channel4Read8bitData(void)
- 754 {
- 755 unsigned char ucGeneralCount=0;
- 756 unsigned char ucReadData=0;
- 757 unsigned char i;
- 758 //unsigned char j=0;
- 759 //__disable_interrupt();
- 760 sbitRfCLK4 = 0;
- 761 //j = P2MDOUT;
- 762 //j = P2;
- 763 //j = P0;
- 764 for (ucGeneralCount=0;ucGeneralCount<8;ucGeneralCount++)
- 765 {
- 766
- 767
- 768 ucReadData=ucReadData<<1;//MSB
- 769
- 770
- 771 sbitRfCLK4 = 1;// ;Time Hold min.500ns
- 772 for (i = 0; i < 1; i++); // Wait 2.5us
- 773 if (sbitRfData4 == 1)
- 774 {ucReadData |= BIT0;} //bit 1
- 775 else
- 776 {ucReadData &= ~BIT0;} // bit is 0
- 777 //for (i = 0; i < 1; i++); // Wait 2.5us
- 778 for (i = 0; i < 1; i++); // Wait 2.5us
- 779
- 780 sbitRfCLK4 = 0;
- 781 for (i = 0; i < 2; i++); // Wait 2.5us
- 782
- 783
- 784 }
- 785 return ucReadData;
- 786 }
- 787
- 788
- 789 */
- 790
- 791 //-----------------------------------------------------------------------------
- 792 // End Of File
- 793 //-----------------------------------------------------------------------------
- MODULE INFORMATION: STATIC OVERLAYABLE
- CODE SIZE = 795 ----
- CONSTANT SIZE = ---- ----
- XDATA SIZE = ---- ----
- C51 COMPILER V7.02b NRF2401RX 11/30/2007 14:07:15 PAGE 14
- PDATA SIZE = ---- ----
- DATA SIZE = ---- 1
- IDATA SIZE = ---- ----
- BIT SIZE = ---- 1
- END OF MODULE INFORMATION.
- C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)