📄 accept.lst
字号:
276 1 {
277 2 if(SDIO)
278 2 tmp = (tmp << 1) | 0x01;
279 2 else
280 2 tmp = tmp << 1;
281 2
282 2 SCK = 1;
283 2 _nop_();
284 2 SCK = 0;
285 2 }
286 1 SCS = 1;
287 1 return tmp;
288 1 }
289
290
291 /*********************************************************************
292 ** Strobe Command
293 *********************************************************************/
294 void StrobeCmd(Uint8 src)
295 {
296 1 Uint8 i;
297 1
298 1 SCS = 0;
299 1 for(i = 0; i < 8; i++)
300 1 {
301 2 if(src & 0x80)
302 2 SDIO = 1;
303 2 else
C51 COMPILER V9.01 ACCEPT 02/25/2011 21:04:32 PAGE 6
304 2 SDIO = 0;
305 2
306 2 _nop_();
307 2 SCK = 1;
308 2 _nop_();
309 2 SCK = 0;
310 2 src = src << 1;
311 2 }
312 1 SCS = 1;
313 1 }
314
315 /************************************************************************
316 ** ByteSend
317 ************************************************************************/
318 void ByteSend(Uint8 src)
319 {
320 1 Uint8 i;
321 1
322 1 for(i = 0; i < 8; i++)
323 1 {
324 2 if(src & 0x80)
325 2 SDIO = 1;
326 2 else
327 2 SDIO = 0;
328 2
329 2 _nop_();
330 2 SCK = 1;
331 2 _nop_();
332 2 SCK = 0;
333 2 src = src << 1;
334 2 }
335 1 }
336
337 /************************************************************************
338 ** WriteID
339 ************************************************************************/
340 void A7125_WriteID(void)
341 {
342 1 Uint8 i;
343 1 Uint8 addr;
344 1
345 1 addr = IDCODE_REG; //send address 0x06, bit cmd=0, r/w=0
346 1 SCS = 0;
347 1 ByteSend(addr);
348 1 for (i=0; i < 4; i++)
349 1 ByteSend(ID_Tab[i]);
350 1 SCS = 1;
351 1 }
352
353 /************************************************************************
354 ** Reset_RF
355 ************************************************************************/
356 void A7125_Reset(void)
357 {
358 1 A7125_WriteReg(MODE_REG, 0x00); //reset RF chip
359 1 }
360 /*********************************************************************
361 ** CHGroupCal
362 *********************************************************************/
363 void CHGroupCal(Uint8 ch)
364 {
365 1 Uint8 tmp;
C51 COMPILER V9.01 ACCEPT 02/25/2011 21:04:32 PAGE 7
366 1 Uint8 vb,vbcf;
367 1 Uint8 vcb,vccf;
368 1
369 1 A7125_WriteReg(PLL1_REG, ch);
370 1 A7125_WriteReg(CALIBRATION_REG, 0x1C);
371 1 do
372 1 {
373 2 tmp = A7125_ReadReg(CALIBRATION_REG);
374 2 tmp &= 0x1C;
375 2 }
376 1 while (tmp);
377 1
378 1 //for check
379 1 tmp = A7125_ReadReg(VCOCAL1_REG);
380 1 vb = tmp & 0x07;
381 1 vbcf = (tmp >>3) & 0x01;
382 1
383 1 tmp = A7125_ReadReg(VCOCCAL_REG);
384 1 vcb = tmp & 0x0F;
385 1 vccf= (tmp >> 4) & 0x01;
386 1
387 1 if (vbcf || vccf)
388 1 Err_State();//error
389 1 }
390
391 /*********************************************************************
392 ** calibration
393 *********************************************************************/
394 void A7125_Cal(void)
395 {
396 1 Uint8 tmp;
397 1 Uint8 fb,fbcf,fcd;
398 1 Uint8 dvt;
399 1
400 1 //calibration RSSI,IF procedure
401 1 StrobeCmd(CMD_PLL);
402 1 A7125_WriteReg(CALIBRATION_REG, 0x03);
403 1 do
404 1 {
405 2 tmp = A7125_ReadReg(CALIBRATION_REG);
406 2 tmp &= 0x03;
407 2 }
408 1 while (tmp);
409 1
410 1 //calibration VCO dev,VBC,VCC procedure
411 1
412 1 CHGroupCal(30); //calibrate channel group Bank I
413 1 CHGroupCal(90); //calibrate channel group Bank II
414 1 CHGroupCal(150); //calibrate channel group Bank III
415 1 StrobeCmd(CMD_STBY); //return to STBY state
416 1
417 1 //for check
418 1 tmp = A7125_ReadReg(IFCAL1_REG);
419 1 fb = tmp & 0x0F;
420 1 fbcf = (tmp >>4) & 0x01;
421 1
422 1 tmp = A7125_ReadReg(IFCAL2_REG);
423 1 fcd = tmp & 0x1F;
424 1
425 1 tmp = A7125_ReadReg(VCOCAL2_REG);
426 1 dvt = tmp;
427 1
C51 COMPILER V9.01 ACCEPT 02/25/2011 21:04:32 PAGE 8
428 1 if (fbcf)
429 1 Err_State(); //error
430 1 }
431
432 /*********************************************************************
433 ** A7125_Config
434 *********************************************************************/
435 void A7125_Config(void)
436 {
437 1 Uint8 i;
438 1
439 1 //0x00 mode register, for reset
440 1 //0x05 fifo data register
441 1 //0x06 id code register
442 1 //0x24 IF calibration II, only read
443 1
444 1 for ( i=0x01; i<=0x38; i++ )
445 1 {
446 2 if ( (i==0x05) || (i==0x06) || (i==0x24) )
447 2 continue;
448 2
449 2 A7125_WriteReg( i, A7125Config[i] );
450 2 }
451 1 }
452
453 /*********************************************************************
454 ** initRF
455 *********************************************************************/
456 void initRF(void)
457 {
458 1 //init io pin
459 1 SCS = 1;
460 1 SCK = 0;
461 1 SDIO = 1;
462 1 GIO1 = 1;
463 1 GIO2 = 1;
464 1
465 1 A7125_Reset(); //reset A7125 RF chip
466 1 A7125_WriteID(); //write ID code
467 1 A7125_Config(); //config A7125 chip
468 1 A7125_Cal(); //calibration IF,vco, vcoc
469 1 }
470
471 //**********************************************************************
472 // ByteRead
473 //**********************************************************************
474 Uint8 ByteRead(void)
475 {
476 1 Uint8 i,tmp;
477 1
478 1 SDIO = 1; //sdio pull high
479 1 for(i = 0; i < 8; i++)
480 1 {
481 2 if(SDIO)
482 2 tmp = (tmp << 1) | 0x01;
483 2 else
484 2 tmp = tmp << 1;
485 2 SCK = 1;
486 2 _nop_();
487 2 SCK = 0;
488 2 }
489 1 return tmp;
C51 COMPILER V9.01 ACCEPT 02/25/2011 21:04:32 PAGE 9
490 1 }
491
492 //**********************************************************************
493 // ReadFIFO
494 //**********************************************************************
495 void ReadFIFO(Uint8 length)
496 {
497 1 Uint8 i;
498 1
499 1 SCS = 0;
500 1 ByteSend(FIFO_REG | 0x40);
501 1 for(i = 0; i <length; i++)
502 1 RfBuf[i] = ByteRead();
503 1 SCS=1;
504 1 }
505 //**********************************************************************
506 // WriteFIFO
507 //**********************************************************************
508 void WriteFIFO(Uint8 length)
509 {
510 1 Uint8 i;
511 1 A7125_WriteReg( FIFO1_REG, length-1); // set FIFO length
512 1 StrobeCmd(CMD_TFR); // Reset TX FIFO point
513 1
514 1 SCS=0;
515 1 ByteSend(FIFO_REG);
516 1 for(i=0; i <length; i++)
517 1 ByteSend(PN9_Tab[i]);
518 1 SCS=1;
519 1 }
520 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
521 // DELAY 1MS FUNCTION //
522 // USER NEED CHANGE THIS FUNCTION TO FIT SYSTEM. //
523 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
524 void Delay1ms(Uint8 n)
525 {
526 1 Uint8 i, j;
527 1 while(n--)
528 1 {
529 2 for(j = 0; j < 6; j ++)
530 2 {
531 3 for(i = 0; i < 235; i ++)
532 3 {
533 4 _nop_();
534 4 _nop_();
535 4 _nop_();
536 4 _nop_();
537 4 }
538 3 }
539 2 }
540 1 }
541
542
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 675 ----
CONSTANT SIZE = 182 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- 6
IDATA SIZE = 65 ----
C51 COMPILER V9.01 ACCEPT 02/25/2011 21:04:32 PAGE 10
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -