comparison src/i2c.asm @ 628:cd58f7fc86db

3.05 stable work
author heinrichsweikamp
date Thu, 19 Sep 2019 12:01:29 +0200
parents bf5fee575701
children 185ba2f91f59
comparison
equal deleted inserted replaced
627:bf5fee575701 628:cd58f7fc86db
1 ;============================================================================= 1 ;=============================================================================
2 ; 2 ;
3 ; File i2c.asm combined next generation V3.03.2 3 ; File i2c.asm combined next generation V3.03.5
4 ; 4 ;
5 ; I2C Interface 5 ; I2C Interface
6 ; 6 ;
7 ; Copyright (c) 2012, JD Gascuel, HeinrichsWeikamp, all right reserved. 7 ; Copyright (c) 2012, JD Gascuel, HeinrichsWeikamp, all right reserved.
8 ;============================================================================= 8 ;=============================================================================
26 ; LSM303AGR's Acceleration read address (8-Bit): 0x33 26 ; LSM303AGR's Acceleration read address (8-Bit): 0x33
27 ; LSM303AGR's Acceleration write address (8-Bit): 0x32 27 ; LSM303AGR's Acceleration write address (8-Bit): 0x32
28 ; 28 ;
29 ; Compass3 29 ; Compass3
30 ; -------- 30 ; --------
31 ; LSM303C's Compass read address (8-Bit): 0x3D 31 ; LSM303C's Compass read address (8-Bit): 0x3D
32 ; LSM303C's Compass write address (8-Bit): 0x3C 32 ; LSM303C's Compass write address (8-Bit): 0x3C
33 ; LSM303C's Acceleration read address (8-Bit): 0x3B 33 ; LSM303C's Acceleration read address (8-Bit): 0x3B
34 ; LSM303C's Acceleration write address (8-Bit): 0x3A 34 ; LSM303C's Acceleration write address (8-Bit): 0x3A
35 ; 35 ;
36 ; RX Circuity 36 ; RX Circuity
37 ; ----------- 37 ; -----------
89 rrcf lo 89 rrcf lo
90 return 90 return
91 91
92 global I2C_RX_accelerometer 92 global I2C_RX_accelerometer
93 I2C_RX_accelerometer: 93 I2C_RX_accelerometer:
94 btfsc compass_type3 ; compass3 94 btfsc compass_type3 ; compass3 ?
95 bra I2C_RX_accelerometer_compass3 ; yes 95 bra I2C_RX_accelerometer_compass3 ; YES
96 btfsc compass_type2 ; compass2 ? 96 btfsc compass_type2 ; compass2 ?
97 bra I2C_RX_accelerometer_compass2 ; YES 97 bra I2C_RX_accelerometer_compass2 ; YES
98 btfsc compass_type ; compass1 ? 98 btfsc compass_type1 ; compass1 ?
99 bra I2C_RX_accelerometer_compass1 ; YES 99 bra I2C_RX_accelerometer_compass1 ; YES
100 ;bra I2C_RX_accelerometer_compass0 ; NO - compass0 then
101
100 I2C_RX_accelerometer_compass0: 102 I2C_RX_accelerometer_compass0:
101 bsf SSP1CON2,SEN ; start condition 103 bsf SSP1CON2,SEN ; start condition
102 rcall WaitMSSP 104 rcall WaitMSSP
103 movlw 0x38 ; address 105 movlw 0x38 ; address
104 rcall I2C_TX 106 rcall I2C_TX
168 movlw b'10101000' ; 0x28 with auto-increment (MSB=1) 170 movlw b'10101000' ; 0x28 with auto-increment (MSB=1)
169 rcall I2C_TX 171 rcall I2C_TX
170 bsf SSP1CON2,RSEN ; repeated start condition (!) 172 bsf SSP1CON2,RSEN ; repeated start condition (!)
171 rcall WaitMSSP 173 rcall WaitMSSP
172 movlw 0x3D ; address 174 movlw 0x3D ; address
173 I2C_RX_accelerometer_compass1_xx: ; compass2 and 3 continue here... 175 I2C_RX_accelerometer_compass1_xx: ; compass 2 and 3 continue here...
174 rcall I2C_TX 176 rcall I2C_TX
175 177
176 ; Non-flipped screen: 178 ; Non-flipped screen:
177 ; Chip orientation on the PCB requires 179 ; Chip orientation on the PCB requires
178 ; Original = Corrected 180 ; Original = Corrected
256 movlw b'10101000' ; 0x28 with auto-increment (MSB=1) 258 movlw b'10101000' ; 0x28 with auto-increment (MSB=1)
257 rcall I2C_TX 259 rcall I2C_TX
258 bsf SSP1CON2,RSEN ; repeated start condition (!) 260 bsf SSP1CON2,RSEN ; repeated start condition (!)
259 rcall WaitMSSP 261 rcall WaitMSSP
260 movlw 0x33 ; address 262 movlw 0x33 ; address
261 bra I2C_RX_accelerometer_compass1_xx 263 bra I2C_RX_accelerometer_compass1_xx
262 264
263 I2C_RX_accelerometer_compass3: 265 I2C_RX_accelerometer_compass3:
264 bsf SSP1CON2,SEN ; Start condition 266 bsf SSP1CON2,SEN ; start condition
265 rcall WaitMSSP 267 rcall WaitMSSP
266 movlw 0x3A ; address 268 movlw 0x3A ; address
267 rcall I2C_TX 269 rcall I2C_TX
268 movlw 0x28 ; 0x28 (OUT_X_L_A) 270 movlw 0x28 ; 0x28 (OUT_X_L_A)
269 rcall I2C_TX 271 rcall I2C_TX
270 bsf SSP1CON2,RSEN ; Repeated start condition (!) 272 bsf SSP1CON2,RSEN ; repeated start condition (!)
271 rcall WaitMSSP 273 rcall WaitMSSP
272 movlw 0x3B ; address 274 movlw 0x3B ; address
273 bra I2C_RX_accelerometer_compass1_xx 275 bra I2C_RX_accelerometer_compass1_xx
274 276
275 I2C_OneByteRX: 277 I2C_OneByteRX:
276 bsf SSP1CON2,RCEN ; enable receive mode 278 bsf SSP1CON2,RCEN ; enable receive mode
277 rcall WaitMSSP 279 rcall WaitMSSP
278 bsf SSP1CON2,ACKEN ; master acknowledge 280 bsf SSP1CON2,ACKEN ; master acknowledge
282 ;----------------------------------------------------------------------------- 284 ;-----------------------------------------------------------------------------
283 IFDEF _compass 285 IFDEF _compass
284 286
285 global I2C_RX_compass 287 global I2C_RX_compass
286 I2C_RX_compass: 288 I2C_RX_compass:
287 btfsc compass_type3 ; compass3 289 btfsc compass_type3 ; compass 3 ?
288 bra I2C_RX_compass3 ; YES 290 bra I2C_RX_compass3 ; YES
289 btfsc compass_type2 ; compass2 ? 291 btfsc compass_type2 ; compass 2 ?
290 bra I2C_RX_compass2 ; YES 292 bra I2C_RX_compass2 ; YES
291 btfsc compass_type ; compass1 ? 293 btfsc compass_type1 ; compass 1 ?
292 bra I2C_RX_compass1 ; YES 294 bra I2C_RX_compass1 ; YES
295 ;bra I2C_RX_compass0 ; NO - compass 0 then
296
293 I2C_RX_compass0: 297 I2C_RX_compass0:
294 bsf SSP1CON2,SEN ; start condition 298 bsf SSP1CON2,SEN ; start condition
295 rcall WaitMSSP 299 rcall WaitMSSP
296 movlw 0x3C ; address 300 movlw 0x3C ; address
297 rcall I2C_TX 301 rcall I2C_TX
345 movff SSP1BUF,compass_DZ+1 ; data byte 349 movff SSP1BUF,compass_DZ+1 ; data byte
346 rcall I2C_OneByteRX ; get one byte 350 rcall I2C_OneByteRX ; get one byte
347 movff SSP1BUF,compass_DZ+0 ; data byte 351 movff SSP1BUF,compass_DZ+0 ; data byte
348 rcall I2C_OneByteRX ; get one byte 352 rcall I2C_OneByteRX ; get one byte
349 movff SSP1BUF,compass_DX+1 ; data byte 353 movff SSP1BUF,compass_DX+1 ; data byte
350 bsf SSP1CON2, RCEN ; Enable receive mode 354 bsf SSP1CON2,RCEN ; enable receive mode
351 rcall WaitMSSP 355 rcall WaitMSSP
352 movff SSP1BUF,compass_DX+0 ; data byte 356 movff SSP1BUF,compass_DX+0 ; data byte
353 bsf SSP1CON2,PEN ; stop condition 357 bsf SSP1CON2,PEN ; stop condition
354 rcall WaitMSSP 358 rcall WaitMSSP
355 btfss flip_screen ; 180° rotation? 359 btfss flip_screen ; 180° rotation?
360 btfsc STATUS,C ; - carry to propagate? 364 btfsc STATUS,C ; - carry to propagate?
361 incf compass_DX+1,F ; YES - do it 365 incf compass_DX+1,F ; YES - do it
362 banksel common 366 banksel common
363 return 367 return
364 368
365 I2C_RX_compass1: ; new compass 369 I2C_RX_compass1: ; compass type 1
366 bsf SSP1CON2,SEN ; start condition 370 bsf SSP1CON2,SEN ; start condition
367 rcall WaitMSSP 371 rcall WaitMSSP
368 movlw 0x3C ; address 372 movlw 0x3C ; address
369 rcall I2C_TX 373 rcall I2C_TX
370 movlw b'10001000' ; 0x08 with auto-increment (MSB=1) 374 movlw b'10001000' ; 0x08 with auto-increment (MSB=1)
412 rcall I2C_TwoBytesRX_div8_2 416 rcall I2C_TwoBytesRX_div8_2
413 MOVII mpr,compass_DZ 417 MOVII mpr,compass_DZ
414 bsf SSP1CON2,PEN ; stop condition 418 bsf SSP1CON2,PEN ; stop condition
415 bra WaitMSSP ; ... and return 419 bra WaitMSSP ; ... and return
416 420
417 I2C_RX_compass2: ; newest compass 421 I2C_RX_compass2: ; compass type 2
418 bsf SSP1CON2,SEN ; start condition 422 bsf SSP1CON2,SEN ; start condition
419 rcall WaitMSSP 423 rcall WaitMSSP
420 movlw 0x3C ; address 424 movlw 0x3C ; address
421 rcall I2C_TX 425 rcall I2C_TX
422 movlw 0xE8 ; 0x68 with auto-increment (MSB=1) 426 movlw 0xE8 ; 0x68 with auto-increment (MSB=1)
423 rcall I2C_TX 427 rcall I2C_TX
424 bsf SSP1CON2,RSEN ; repeated start condition (!) 428 bsf SSP1CON2,RSEN ; repeated start condition (!)
425 rcall WaitMSSP 429 rcall WaitMSSP
426 movlw 0x3D ; address 430 movlw 0x3D ; address
427 rcall I2C_TX 431 rcall I2C_TX
428 I2C_RX_compass2_xx: ; compass 3 enters here 432 I2C_RX_compass2_xx: ; compass 3 joins in here
429 ; rcall WaitMSSP 433 ; rcall WaitMSSP
430 rcall I2C_OneByteRX ; get one byte 434 rcall I2C_OneByteRX ; get one byte
431 movff SSP1BUF,lo ; data byte 435 movff SSP1BUF,lo ; data byte
432 rcall I2C_OneByteRX ; get one byte 436 rcall I2C_OneByteRX ; get one byte
433 movff SSP1BUF,hi ; data byte 437 movff SSP1BUF,hi ; data byte
460 rcall I2C_OneByteRX ; get one byte 464 rcall I2C_OneByteRX ; get one byte
461 movff SSP1BUF,hi ; data byte 465 movff SSP1BUF,hi ; data byte
462 ; rcall I2C_TwoBytesRX_div8_2 466 ; rcall I2C_TwoBytesRX_div8_2
463 MOVII mpr,compass_DZ 467 MOVII mpr,compass_DZ
464 bsf SSP1CON2,PEN ; stop condition 468 bsf SSP1CON2,PEN ; stop condition
465 bra WaitMSSP ;(And return) 469 bra WaitMSSP ; ...and return
466 470
467 I2C_RX_compass3: 471 I2C_RX_compass3: ; compass type 3
468 bsf SSP1CON2,SEN ; Start condition 472 bsf SSP1CON2,SEN ; start condition
469 rcall WaitMSSP 473 rcall WaitMSSP
470 movlw 0x3C ; address 474 movlw 0x3C ; address
471 rcall I2C_TX 475 rcall I2C_TX
472 movlw 0xA8 ; 0x28 with auto-increment (MSB=1) 476 movlw 0xA8 ; 0x28 with auto-increment (MSB=1)
473 rcall I2C_TX 477 rcall I2C_TX
474 bsf SSP1CON2,RSEN ; Repeated start condition (!) 478 bsf SSP1CON2,RSEN ; repeated start condition (!)
475 rcall WaitMSSP 479 rcall WaitMSSP
476 movlw 0x3D ; address 480 movlw 0x3D ; address
477 rcall I2C_TX 481 rcall I2C_TX
478 bra I2C_RX_compass2_xx 482 bra I2C_RX_compass2_xx ; join with compass 2 code
479 483
480 ENDIF ; _compass 484 ENDIF ; _compass
481 485
482 ;----------------------------------------------------------------------------- 486 ;-----------------------------------------------------------------------------
483 487
484 global I2C_init_compass 488 global I2C_init_compass
485 I2C_init_compass: 489 I2C_init_compass:
486 bsf compass_enabled 490 bsf compass_enabled
487 bcf compass_type2 491 bcf compass_type2
488 bcf compass_type3 492 bcf compass_type3
489 493
490 ; probe compass 3 494 ; probe for compass 3
491 bsf SSP1CON2,SEN ; Start condition 495 bsf SSP1CON2,SEN ; start condition
492 rcall WaitMSSP 496 rcall WaitMSSP
493 movlw 0x3A ; Address byte + Write bit 497 movlw 0x3A ; address byte + write bit
494 movwf SSP1BUF ; control byte
495 rcall WaitMSSP
496 btfss SSP1CON2,ACKSTAT ; ACK?
497 bsf compass_type3 ; ACK send. compass2 present
498 bsf SSP1CON2,PEN ; Stop condition
499 rcall WaitMSSP
500
501 btfsc compass_type3
502 bra I2C_init_compass3 ; Compass3
503
504 ; check for compass2
505 bsf SSP1CON2,SEN ; start condition
506 rcall WaitMSSP
507 movlw 0x32 ; address byte + Write bit
508 movwf SSP1BUF ; control byte 498 movwf SSP1BUF ; control byte
509 rcall WaitMSSP 499 rcall WaitMSSP
510 btfss SSP1CON2,ACKSTAT ; ACK? 500 btfss SSP1CON2,ACKSTAT ; ACK?
511 bsf compass_type2 ; YES - ACK send, compass2 present 501 bsf compass_type3 ; YES - ACK was send, compass 3 present
512 bsf SSP1CON2,PEN ; NO - stop condition 502 bsf SSP1CON2,PEN ; stop condition
513 rcall WaitMSSP 503 rcall WaitMSSP
514 btfsc compass_type2 504
515 bra I2C_init_compass2 ; compass2 505 btfsc compass_type3 ; compass 3 found?
516 506 bra I2C_init_compass3 ; YES - initialize compass 3
517 ; check for compass0 or compass1... 507
518 bsf compass_type ; set flag 508 ; probe for compass 2
509 bsf SSP1CON2,SEN ; start condition
510 rcall WaitMSSP
511 movlw 0x32 ; address byte + write bit
512 movwf SSP1BUF ; control byte
513 rcall WaitMSSP
514 btfss SSP1CON2,ACKSTAT ; ACK?
515 bsf compass_type2 ; YES - ACK send, compass 2 present
516 bsf SSP1CON2,PEN ; stop condition
517 rcall WaitMSSP
518
519 btfsc compass_type2 ; compass 2 found?
520 bra I2C_init_compass2 ; YES - initialize compass 2
521
522 ; probe for compass 0 or 1
523 bsf compass_type1 ; set flag
519 bsf SSP1CON2,SEN ; start condition 524 bsf SSP1CON2,SEN ; start condition
520 rcall WaitMSSP 525 rcall WaitMSSP
521 movlw 0x3C ; address 526 movlw 0x3C ; address
522 rcall I2C_TX 527 rcall I2C_TX
523 movlw 0x0F 528 movlw 0x0F
528 bsf SSP1CON2,SEN ; start condition 533 bsf SSP1CON2,SEN ; start condition
529 rcall WaitMSSP 534 rcall WaitMSSP
530 movlw 0x3D ; address 535 movlw 0x3D ; address
531 rcall I2C_TX 536 rcall I2C_TX
532 rcall I2C_OneByteRX ; get one byte 537 rcall I2C_OneByteRX ; get one byte
533 movlw 0x49 ; 0x49 = Compass1 538 movlw 0x49 ; 0x49 = compass 1
534 cpfseq SSP1BUF 539 cpfseq SSP1BUF
535 bcf compass_type ; clear flag 540 bcf compass_type1 ; clear flag
536 bsf SSP1CON2,PEN ; stop condition 541 bsf SSP1CON2,PEN ; stop condition
537 rcall WaitMSSP 542 rcall WaitMSSP
538 btfsc compass_type ; compass1 ? 543
539 bra I2C_init_compass1 ; YES 544 btfsc compass_type1 ; compass 1 found?
540 545 bra I2C_init_compass1 ; YES - initialize compass 1
541 ; init compass0 546 ;bra I2C_init_compass0 ; NO - must be compass 0 then
547
548 I2C_init_compass0:
549 ; magnetic
542 bsf SSP1CON2,SEN ; start condition 550 bsf SSP1CON2,SEN ; start condition
543 rcall WaitMSSP 551 rcall WaitMSSP
544 movlw 0x3C ; address 552 movlw 0x3C ; address
545 rcall I2C_TX 553 rcall I2C_TX
546 movlw 0x00 554 movlw 0x00
547 rcall I2C_TX 555 rcall I2C_TX
548 ; movlw b'01101001' ; ConfigA: 3 Hz, 8 samples averaged, test mode (positive bias)
549 movlw b'01101000' ; ConfigA: 3 Hz, 8 samples averaged 556 movlw b'01101000' ; ConfigA: 3 Hz, 8 samples averaged
550 rcall I2C_TX 557 rcall I2C_TX
551 I2C_init_compass_common:
552 movff opt_compass_gain,i2c_temp1 ; 0-7 (230 LSB/Gauss to 1370 LSB/Gauss) 558 movff opt_compass_gain,i2c_temp1 ; 0-7 (230 LSB/Gauss to 1370 LSB/Gauss)
553 swapf i2c_temp1,F 559 swapf i2c_temp1,F
554 comf i2c_temp1,F 560 comf i2c_temp1,F
555 bcf STATUS,C 561 bcf STATUS,C
556 rlcf i2c_temp1 562 rlcf i2c_temp1
558 clrf i2c_temp1 564 clrf i2c_temp1
559 rcall I2C_TX 565 rcall I2C_TX
560 movlw b'00000000' ; continuous mode 566 movlw b'00000000' ; continuous mode
561 rcall I2C_TX 567 rcall I2C_TX
562 bsf SSP1CON2,PEN ; stop condition 568 bsf SSP1CON2,PEN ; stop condition
569 rcall WaitMSSP
570
571 ; accelerometer
572 rcall I2C_sleep_accelerometer0 ; registers can only be changed in standby mode
573
574 bsf SSP1CON2,SEN ; start condition
575 rcall WaitMSSP
576 movlw 0x38 ; address
577 rcall I2C_TX
578 movlw 0x0E ; XYZ_DATA_CFG
579 rcall I2C_TX
580 movlw b'00000000' ; high pass filter = 0, +/- 2 g range
581 rcall I2C_TX
582 bsf SSP1CON2,PEN ; stop condition
583 rcall WaitMSSP
584 bsf SSP1CON2,SEN ; start condition
585 rcall WaitMSSP
586 movlw 0x38 ; address
587 rcall I2C_TX
588 movlw 0x2A ; CTRL_REG1
589 rcall I2C_TX
590 ; movlw b'00110000' ; CTRL_REG1: 160 ms data rate, standby mode
591 movlw b'00110100' ; CTRL_REG1: 160 ms data rate, standby mode, reduced noise mode
592 rcall I2C_TX
593 movlw b'00000010' ; CTRL_REG2: high-res in active mode
594 rcall I2C_TX
595 bsf SSP1CON2,PEN ; stop condition
596 rcall WaitMSSP
597
598 bsf SSP1CON2,SEN ; start condition
599 rcall WaitMSSP
600 movlw 0x38 ; address
601 rcall I2C_TX
602 movlw 0x2A ; CTRL_REG1
603 rcall I2C_TX
604 ; movlw b'00110001' ; CTRL_REG1: 160 ms data rate, active mode
605 movlw b'00110101' ; CTRL_REG1: 160 ms data rate, standby mode, reduced noise mode, active Mode
606 rcall I2C_TX
607 bsf SSP1CON2,PEN ; stop condition
563 bra WaitMSSP ; ... and return 608 bra WaitMSSP ; ... and return
564 609
610
565 I2C_init_compass1: 611 I2C_init_compass1:
566 bsf SSP1CON2,SEN ; start condition 612 bsf SSP1CON2,SEN ; start condition
567 rcall WaitMSSP 613 rcall WaitMSSP
568 movlw 0x3C ; address 614 movlw 0x3C ; address
569 rcall I2C_TX 615 rcall I2C_TX
579 rcall I2C_TX 625 rcall I2C_TX
580 movlw b'00000000' ; CTRL4 626 movlw b'00000000' ; CTRL4
581 rcall I2C_TX 627 rcall I2C_TX
582 movlw b'01100100' ; CTRL5 HIGH res, 6.25 Hz 628 movlw b'01100100' ; CTRL5 HIGH res, 6.25 Hz
583 rcall I2C_TX 629 rcall I2C_TX
584 init_compass1_common:
585 movff opt_compass_gain,i2c_temp1 ; 0-7 (230 LSB/Gauss to 1370 LSB/Gauss) 630 movff opt_compass_gain,i2c_temp1 ; 0-7 (230 LSB/Gauss to 1370 LSB/Gauss)
586 movlw b'01100000' ; CTRL6 Full scale (+/-12 Gauss -> 2730 LSB/Gauss) 631 movlw b'01100000' ; CTRL6 Full scale (+/-12 Gauss -> 2730 LSB/Gauss)
587 dcfsnz i2c_temp1,F ; = 1? 632 dcfsnz i2c_temp1,F ; = 1?
588 movlw b'01100000' ; YES - CTRL6 Full scale (+/-12 Gauss -> 2730 LSB/Gauss) 633 movlw b'01100000' ; YES - CTRL6 Full scale (+/-12 Gauss -> 2730 LSB/Gauss)
589 dcfsnz i2c_temp1,F ; = 2? 634 dcfsnz i2c_temp1,F ; = 2?
600 movlw b'00000000' ; YES - CTRL6 (+/-2 Gauss) 645 movlw b'00000000' ; YES - CTRL6 (+/-2 Gauss)
601 rcall I2C_TX 646 rcall I2C_TX
602 movlw b'00000000' ; CTRL7 Continuous Mode 647 movlw b'00000000' ; CTRL7 Continuous Mode
603 rcall I2C_TX 648 rcall I2C_TX
604 bsf SSP1CON2,PEN ; stop condition 649 bsf SSP1CON2,PEN ; stop condition
650 bra WaitMSSP ; (and return), no I2C_init_accelerometer1 needed (inits with magnetic sensor)
651
652 I2C_init_compass2:
653 ; magnetic
654 bsf SSP1CON2,SEN ; Start condition
655 rcall WaitMSSP
656 movlw 0x3C ; address
657 rcall I2C_TX
658 movlw 0xE0 ; 0x60 with auto-increment (MSB=1)
659 rcall I2C_TX
660 movlw b'10000000' ; CFG_REG_A_M (10Hz, Continuous) 0x60 0x00
661 rcall I2C_TX
662 movlw b'00000011' ; CFG_REG_B_M (low-pass filter enabled) 0x61 (set pulse is released every 63 ODR)
663 rcall I2C_TX
664 movlw b'00010000' ; CFG_REG_C_M BDU=1 0x62 0x57
665 rcall I2C_TX
666 bsf SSP1CON2,PEN ; Stop condition
667 rcall WaitMSSP
668
669 ; accelerometer
670 bsf SSP1CON2,SEN ; start condition
671 rcall WaitMSSP
672 movlw 0x32 ; address
673 rcall I2C_TX
674 movlw 0x9F ; 1F with auto-increment (MSB=1)
675 rcall I2C_TX
676 movlw b'00000000' ; TEMP_CFG_REG_A (Temp sensor off)
677 rcall I2C_TX
678 movlw b'00100111' ; CTRL_REG1_A (10Hz, x,y,z = ON)
679 rcall I2C_TX
680 movlw b'00000000' ; CTRL_REG2_A
681 rcall I2C_TX
682 movlw b'00000000' ; CTRL_REG3_A
683 rcall I2C_TX
684 movlw b'00001000' ; CTRL_REG4_A (BDU=0, +/-2g, HR=1)
685 rcall I2C_TX
686 ; movlw b'00000000' ; CTRL_REG5_A
687 ; rcall I2C_TX
688 bsf SSP1CON2,PEN ; stop condition
605 bra WaitMSSP ; ... and return 689 bra WaitMSSP ; ... and return
606 690
607 I2C_init_compass2:
608 bsf SSP1CON2,SEN ; start condition
609 rcall WaitMSSP
610 movlw 0x3C ; address
611 rcall I2C_TX
612 movlw 0xE0 ; 0x60 with auto-increment (MSB=1)
613 rcall I2C_TX
614 movlw b'00000000' ; CFG_REG_A_M 0x60 (10 Hz, continuous)
615 rcall I2C_TX
616 movlw b'00000000' ; CFG_REG_B_M 0x61 (low-pass filter off, set pulse is released every 63 ODR)
617 rcall I2C_TX
618 movlw b'00000000' ; CFG_REG_C_M BDU=0 0x62
619 rcall I2C_TX
620 bsf SSP1CON2,PEN ; stop condition
621 bra WaitMSSP ; ... and return
622 691
623 I2C_init_compass3: 692 I2C_init_compass3:
624 bsf SSP1CON2,SEN ; Start condition 693 ; magnetic
694 bsf SSP1CON2,SEN ; Start condition
625 rcall WaitMSSP 695 rcall WaitMSSP
626 movlw 0x3C ; address 696 movlw 0x3C ; address
697 rcall I2C_TX
698 movlw 0xA0 ; 0x20 with auto-increment (MSB=1)
699 rcall I2C_TX
700 movlw b'01110000' ; CTRL_REG1_M (10Hz) 0x20
701 rcall I2C_TX
702 movlw b'01100000' ; CTRL_REG2_M (Full-scale: +/- 16gauss) 0x21
703 rcall I2C_TX
704 movlw b'01000000' ; CTRL_REG3_M (Continuous) 0x22
705 rcall I2C_TX
706 movlw b'00000000' ; CTRL_REG4_M (Z in Low-power mode) 0x23
707 rcall I2C_TX
708 movlw b'00000000' ; CTRL_REG5_M 0x24
709 rcall I2C_TX
710 movlw b'00000000' ; CTRL_REG5_M 0x24
711 rcall I2C_TX
712 bsf SSP1CON2,PEN ; Stop condition
713 rcall WaitMSSP
714
715 ;accelerometer
716 bsf SSP1CON2,SEN ; Start condition
717 rcall WaitMSSP
718 movlw 0x3A ; address
719 rcall I2C_TX
720 movlw 0x20
627 rcall I2C_TX 721 rcall I2C_TX
628 movlw 0xA0 ; 0x20 with auto-increment (MSB=1) 722 movlw b'10010111' ; CTRL_REG1_A (100Hz, x,y,z = ON, BDU=OFF) 0x20
629 rcall I2C_TX 723 rcall I2C_TX
630 movlw b'00010000' ; CTRL_REG1_M (10Hz) 0x20 724 movlw b'00000000' ; CTRL_REG2_A 0x21
631 rcall I2C_TX 725 rcall I2C_TX
632 movlw b'01100000' ; CTRL_REG2_M (Full-scale: +/- 16gauss) 0x21 726 movlw b'00000000' ; CTRL_REG3_A 0x22
633 rcall I2C_TX 727 rcall I2C_TX
634 movlw b'01000000' ; CTRL_REG3_M (Continuous) 0x22 728 movlw b'11001100' ; CTRL_REG4_A 0x23
635 rcall I2C_TX 729 rcall I2C_TX
636 movlw b'00000000' ; CTRL_REG4_M (Z in Low-power mode) 0x23 730 bsf SSP1CON2,PEN ; Stop condition
637 rcall I2C_TX 731 bra WaitMSSP ; (And return)
638 movlw b'00000000' ; CTRL_REG5_M 0x24 732
639 rcall I2C_TX
640 movlw b'00000000' ; CTRL_REG5_M 0x24
641 rcall I2C_TX
642 bsf SSP1CON2,PEN ; Stop condition
643 bra WaitMSSP ;(And return)
644
645 733
646 global I2C_sleep_compass 734 global I2C_sleep_compass
647 I2C_sleep_compass: 735 I2C_sleep_compass:
736 btfss compass_enabled ; compass active?
737 return ; NO - return
648 bcf compass_enabled 738 bcf compass_enabled
649 btfsc compass_type3 ; compass3? 739 btfsc compass_type3 ; compass 3 ?
650 bra I2C_sleep_compass3 ; YES 740 bra I2C_sleep_compass3 ; YES
651 btfsc compass_type2 ; compass2 ? 741 btfsc compass_type2 ; compass 2 ?
652 bra I2C_sleep_compass2 ; YES 742 bra I2C_sleep_compass2 ; YES
653 btfsc compass_type ; compass1 ? 743 btfsc compass_type1 ; compass 1 ?
654 bra I2C_sleep_compass1 ; YES 744 bra I2C_sleep_compass1 ; YES
745 ;bra I2C_sleep_compass0 ; NO - must be compass 0 then
746
655 I2C_sleep_compass0: 747 I2C_sleep_compass0:
748 ; magnetic
656 bsf SSP1CON2,SEN ; start condition 749 bsf SSP1CON2,SEN ; start condition
657 rcall WaitMSSP 750 rcall WaitMSSP
658 movlw 0x3C ; address 751 movlw 0x3C ; address
659 rcall I2C_TX 752 rcall I2C_TX
660 movlw 0x00 753 movlw 0x00
664 movlw b'00100000' ; ConfigB 757 movlw b'00100000' ; ConfigB
665 rcall I2C_TX 758 rcall I2C_TX
666 movlw b'00000010' ; idle mode 759 movlw b'00000010' ; idle mode
667 rcall I2C_TX 760 rcall I2C_TX
668 bsf SSP1CON2,PEN ; stop condition 761 bsf SSP1CON2,PEN ; stop condition
762 rcall WaitMSSP
763
764 I2C_sleep_accelerometer0: ;(needed)
765 ; accelerometer
766 bsf SSP1CON2,SEN ; start condition
767 rcall WaitMSSP
768 movlw 0x38 ; address
769 rcall I2C_TX
770 movlw 0x2A ; CTRL_REG1
771 rcall I2C_TX
772 movlw b'00000000' ; standby mode
773 rcall I2C_TX
774 bsf SSP1CON2,PEN ; stop condition
669 bra WaitMSSP ; ... and return 775 bra WaitMSSP ; ... and return
670 776
671 I2C_sleep_compass1: 777 I2C_sleep_compass1:
672 bsf SSP1CON2,SEN ; start condition 778 bsf SSP1CON2,SEN ; start condition
673 rcall WaitMSSP 779 rcall WaitMSSP
686 movlw 0x26 ; CTRL_REG7 792 movlw 0x26 ; CTRL_REG7
687 rcall I2C_TX 793 rcall I2C_TX
688 movlw b'00000010' ; data for CTRL_REG7: magnetic sensor power-down mode 794 movlw b'00000010' ; data for CTRL_REG7: magnetic sensor power-down mode
689 rcall I2C_TX 795 rcall I2C_TX
690 bsf SSP1CON2,PEN ; stop condition 796 bsf SSP1CON2,PEN ; stop condition
691 bra WaitMSSP ; and return 797 bra WaitMSSP ; (And return) - no I2C_sleep_accelerometer1 required (sleeps with magnetic sensor)
798
692 799
693 I2C_sleep_compass2: 800 I2C_sleep_compass2:
694 ; magnetic 801 ; magnetic
695 bsf SSP1CON2,SEN ; start condition 802 bsf SSP1CON2,SEN ; start condition
696 rcall WaitMSSP 803 rcall WaitMSSP
705 movlw b'01010001' ; CFG_REG_C_M 0x62 812 movlw b'01010001' ; CFG_REG_C_M 0x62
706 rcall I2C_TX 813 rcall I2C_TX
707 movlw b'00000000' ; INT_CTRL_REG_M 0x63 814 movlw b'00000000' ; INT_CTRL_REG_M 0x63
708 rcall I2C_TX 815 rcall I2C_TX
709 bsf SSP1CON2,PEN ; stop condition 816 bsf SSP1CON2,PEN ; stop condition
817 rcall WaitMSSP
818
819 ; accelerometer
820 bsf SSP1CON2,SEN ; start condition
821 rcall WaitMSSP
822 movlw 0x32 ; address
823 rcall I2C_TX
824 movlw 0x9F ; 1F with auto-increment (MSB=1)
825 rcall I2C_TX
826 movlw b'00000000' ; TEMP_CFG_REG_A 0x1F (temp sensor off)
827 rcall I2C_TX
828 movlw b'00000000' ; CTRL_REG1_A 0x20 (all off)
829 rcall I2C_TX
830 bsf SSP1CON2,PEN ; stop condition
710 bra WaitMSSP ; ... and return 831 bra WaitMSSP ; ... and return
711 832
712 I2C_sleep_compass3: 833 I2C_sleep_compass3:
713 ; magnetic 834 ; magnetic
714 bsf SSP1CON2,SEN ; Start condition 835 bsf SSP1CON2,SEN ; start condition
715 rcall WaitMSSP 836 rcall WaitMSSP
716 movlw 0x3C ; address 837 movlw 0x3C ; address
717 rcall I2C_TX 838 rcall I2C_TX
718 movlw 0xA2 ; 0x22 with auto-increment (MSB=1) 839 movlw 0xA2 ; 0x22 with auto-increment (MSB=1)
719 movlw b'01000010' ; CTRL_REG3_M (Power-down) 0x22 840 rcall I2C_TX
720 rcall I2C_TX 841 movlw b'01000010' ; CTRL_REG3_M (power-down) 0x22
721 bsf SSP1CON2,PEN ; Stop condition 842 rcall I2C_TX
722 bra WaitMSSP ;(And return) 843 bsf SSP1CON2,PEN ; stop condition
723 844 rcall WaitMSSP
724 I2C_sleep_accelerometer2: 845
725 ; accelerometer 846 ; accelerometer
726 bsf SSP1CON2,SEN ; start condition 847 bsf SSP1CON2,SEN ; start condition
727 rcall WaitMSSP 848 rcall WaitMSSP
728 movlw 0x32 ; address 849 movlw 0x3A ; address
729 rcall I2C_TX 850 rcall I2C_TX
730 movlw 0x9F ; 1F with auto-increment (MSB=1)
731 rcall I2C_TX
732 movlw b'00000000' ; TEMP_CFG_REG_A 0x1F (temp sensor off)
733 rcall I2C_TX
734 movlw b'00000000' ; CTRL_REG1_A 0x20 (all off)
735 rcall I2C_TX
736 bsf SSP1CON2,PEN ; stop condition
737 bra WaitMSSP ; ... and return
738
739 I2C_sleep_accelerometer3:
740 ; accelerometer
741 bsf SSP1CON2,SEN ; Start condition
742 rcall WaitMSSP
743 movlw 0x3A ; address
744 rcall I2C_TX
745 movlw 0x20 851 movlw 0x20
746 rcall I2C_TX 852 rcall I2C_TX
747 movlw b'00000000' ; CTRL_REG1_A (100Hz, x,y,z = ON) 0x20 853 movlw b'00000000' ; CTRL_REG1_A (100Hz, x,y,z = OFF) 0x20
748 rcall I2C_TX 854 rcall I2C_TX
749 bsf SSP1CON2,PEN ; Stop condition 855 bsf SSP1CON2,PEN ; stop condition
750 bra WaitMSSP ; (And return) 856 bra WaitMSSP ; ... and return
751
752 857
753 WaitMSSP: 858 WaitMSSP:
754 decfsz i2c_temp1,F ; check for timeout during I2C action 859 decfsz i2c_temp1,F ; check for timeout during I2C action
755 bra WaitMSSP2 860 bra WaitMSSP2
756 bra I2CFail ; timeout occurred 861 bra I2CFail ; timeout occurred
760 clrf i2c_temp1 865 clrf i2c_temp1
761 bcf PIR1,SSP1IF 866 bcf PIR1,SSP1IF
762 return 867 return
763 868
764 I2C_WaitforACK: 869 I2C_WaitforACK:
765 btfss SSP1CON2,ACKSTAT ; checks for ACK bit from slave 870 btfss SSP1CON2,ACKSTAT ; ACK received from slave?
766 return 871 return ; YES
767 I2CFail: 872 I2CFail: ; NO
768 bsf active_reset_ostc_rx ; RESET RX circuitry (Which may be the cause for the hang up) 873 bsf active_reset_ostc_rx ; - reset RX circuitry (which may be the cause for the hang up)
769 rcall I2CReset ; I2C Reset 874 rcall I2CReset ; - reset I2C
770 bcf PIR1,SSP1IF 875 bcf PIR1,SSP1IF ; -
771 clrf i2c_temp1 876 clrf i2c_temp1 ; -
772 bsf i2c_error_flag ; set error flag 877 bsf i2c_error_flag ; - set error flag
773 bcf active_reset_ostc_rx ; release RESET from RX circuitry 878 bcf active_reset_ostc_rx ; - release reset from RX circuitry
774 return 879 return ; - done
775 880
776 I2CReset: ; something went wrong (slave holds SDA low?) 881 I2CReset: ; something went wrong (slave holds SDA low?)
777 clrf SSP1CON1 ; wake-up slave and reset entire module 882 clrf SSP1CON1 ; wake-up slave and reset entire module
778 clrf SSP1CON2 883 clrf SSP1CON2
779 clrf SSP1STAT 884 clrf SSP1STAT
806 movwf SSP1STAT 911 movwf SSP1STAT
807 movlw b'00101000' 912 movlw b'00101000'
808 movwf SSP1CON1 913 movwf SSP1CON1
809 movlw b'00000000' 914 movlw b'00000000'
810 movwf SSP1CON2 915 movwf SSP1CON2
811 movlw 0x27 916 movlw 0x9C
812 movwf SSP1ADD 917 movwf SSP1ADD
813 return 918 return
814 919
815
816 global I2C_init_accelerometer
817 I2C_init_accelerometer:
818 btfsc compass_type3 ; compass3?
819 bra I2C_init_accelerometer3 ; YES
820
821 btfsc compass_type2 ; compass2 ?
822 bra I2C_init_accelerometer2 ; YES
823
824 btfsc compass_type ; compass1 ?
825 return ; YES - ignore
826
827 rcall I2C_sleep_accelerometer ; registers can only be changed in standby mode
828
829 bsf SSP1CON2,SEN ; start condition
830 rcall WaitMSSP
831 movlw 0x38 ; address
832 rcall I2C_TX
833 movlw 0x0E ; XYZ_DATA_CFG
834 rcall I2C_TX
835 movlw b'00000000' ; high pass filter = 0, +/- 2g range
836 rcall I2C_TX
837 bsf SSP1CON2,PEN ; stop condition
838 rcall WaitMSSP
839
840 bsf SSP1CON2,SEN ; start condition
841 rcall WaitMSSP
842 movlw 0x38 ; address
843 rcall I2C_TX
844 movlw 0x2A ; CTRL_REG1
845 rcall I2C_TX
846 ; movlw b'00110000' ; CTRL_REG1: 160 ms data rate, standby mode
847 movlw b'00110100' ; CTRL_REG1: 160 ms data rate, standby mode, reduced noise mode
848 rcall I2C_TX
849 movlw b'00000010' ; CTRL_REG2: high-res in active mode
850 rcall I2C_TX
851 bsf SSP1CON2,PEN ; stop condition
852 rcall WaitMSSP
853
854 bsf SSP1CON2,SEN ; start condition
855 rcall WaitMSSP
856 movlw 0x38 ; address
857 rcall I2C_TX
858 movlw 0x2A ; CTRL_REG1
859 rcall I2C_TX
860 ; movlw b'00110001' ; CTRL_REG1: 160 ms data rate, active mode
861 movlw b'00110101' ; CTRL_REG1: 160 ms data rate, standby mode, reduced noise mode, active Mode
862 rcall I2C_TX
863 bsf SSP1CON2,PEN ; stop condition
864 bra WaitMSSP ; ... and return
865
866 I2C_init_accelerometer2:
867 bsf SSP1CON2,SEN ; start condition
868 rcall WaitMSSP
869 movlw 0x32 ; address
870 rcall I2C_TX
871 movlw 0x9F ; 1F with auto-increment (MSB=1)
872 rcall I2C_TX
873 movlw b'00000000' ; TEMP_CFG_REG_A (Temp sensor off)
874 rcall I2C_TX
875 movlw b'01010111' ; CTRL_REG1_A (100Hz, x,y,z = ON)
876 rcall I2C_TX
877 movlw b'00000000' ; CTRL_REG2_A
878 rcall I2C_TX
879 ; movlw b'00000000' ; CTRL_REG3_A
880 ; rcall I2C_TX
881 ; movlw b'00000000' ; CTRL_REG4_A (BDU=0, +/-2g,
882 ; rcall I2C_TX
883 ; movlw b'00000000' ; CTRL_REG5_A
884 ; rcall I2C_TX
885 bsf SSP1CON2,PEN ; stop condition
886 bra WaitMSSP ; ... and return
887
888 I2C_init_accelerometer3:
889 bsf SSP1CON2,SEN ; Start condition
890 rcall WaitMSSP
891 movlw 0x3A ; address
892 rcall I2C_TX
893 movlw 0x20
894 rcall I2C_TX
895 movlw b'00110111' ; CTRL_REG1_A (100Hz, x,y,z = ON) 0x20
896 rcall I2C_TX
897 movlw b'00000000' ; CTRL_REG2_A 0x21
898 rcall I2C_TX
899 movlw b'00000000' ; CTRL_REG3_A 0x22
900 rcall I2C_TX
901 bsf SSP1CON2,PEN ; Stop condition
902 bra WaitMSSP ; (And return)
903
904
905 global I2C_sleep_accelerometer
906 I2C_sleep_accelerometer:
907 btfsc compass_type3 ; Compass3
908 bra I2C_sleep_accelerometer3 ; YES
909 btfsc compass_type2 ; Compass2
910 bra I2C_sleep_accelerometer2 ; YES
911 btfsc compass_type ; compass1?
912 return ; YES - ignore
913
914 bsf SSP1CON2,SEN ; start condition
915 rcall WaitMSSP
916 movlw 0x38 ; address
917 rcall I2C_TX
918 movlw 0x2A ; CTRL_REG1
919 rcall I2C_TX
920 movlw b'00000000' ; standby mode
921 rcall I2C_TX
922 bsf SSP1CON2,PEN ; stop condition
923 bra WaitMSSP ; ... and return
924 920
925 lt2942_init_again: 921 lt2942_init_again:
926 clrf i2c_temp1 922 clrf i2c_temp1
927 movlw 0x02 ; point to accumulated charge registers 923 movlw 0x02 ; point to accumulated charge registers
928 rcall I2C_TX_GAUGE 924 rcall I2C_TX_GAUGE
934 rcall I2C_WaitforACK 930 rcall I2C_WaitforACK
935 bsf SSP1CON2,PEN ; stop condition 931 bsf SSP1CON2,PEN ; stop condition
936 rcall WaitMSSP 932 rcall WaitMSSP
937 MOVII battery_accumulated_charge,sub_a 933 MOVII battery_accumulated_charge,sub_a
938 ; and init again... 934 ; and init again...
935
939 936
940 global lt2942_init 937 global lt2942_init
941 lt2942_init: ; setup control register B 938 lt2942_init: ; setup control register B
942 clrf i2c_temp1 939 clrf i2c_temp1
943 movlw 0x01 ; point to control reg B 940 movlw 0x01 ; point to control reg B
946 movff WREG, SSP1BUF ; data byte 943 movff WREG, SSP1BUF ; data byte
947 rcall WaitMSSP 944 rcall WaitMSSP
948 rcall I2C_WaitforACK 945 rcall I2C_WaitforACK
949 bsf SSP1CON2,PEN ; stop condition 946 bsf SSP1CON2,PEN ; stop condition
950 bra WaitMSSP ; ... and return 947 bra WaitMSSP ; ... and return
948
951 949
952 global lt2942_get_status 950 global lt2942_get_status
953 lt2942_get_status: ; read status register 951 lt2942_get_status: ; read status register
954 bcf battery_gauge_available ; clear flag 952 bcf battery_gauge_available ; clear flag
955 clrf i2c_temp1 953 clrf i2c_temp1
997 call I2C_TX_GAUGE 995 call I2C_TX_GAUGE
998 call I2C_RX_GAUGE 996 call I2C_RX_GAUGE
999 bsf SSP1CON2,ACKEN ; master acknowledge 997 bsf SSP1CON2,ACKEN ; master acknowledge
1000 rcall WaitMSSP 998 rcall WaitMSSP
1001 movff SSP1BUF,xA+1 ; store raw temperature, high byte 999 movff SSP1BUF,xA+1 ; store raw temperature, high byte
1002 bsf SSP1CON2, RCEN ; enable receive mode 1000 bsf SSP1CON2,RCEN ; enable receive mode
1003 rcall WaitMSSP 1001 rcall WaitMSSP
1004 movff SSP1BUF,xA+0 ; store raw temperature, low byte 1002 movff SSP1BUF,xA+0 ; store raw temperature, low byte
1005 bsf SSP1CON2,PEN ; stop condition 1003 bsf SSP1CON2,PEN ; stop condition
1006 rcall WaitMSSP 1004 rcall WaitMSSP
1007 1005
1073 ; > zero, set batt_percent properly 1071 ; > zero, set batt_percent properly
1074 MOVII sub_c,xA 1072 MOVII sub_c,xA
1075 MOVII battery_capacity,xB 1073 MOVII battery_capacity,xB
1076 call div16x16 ; xC = xA / xB with xA as remainder 1074 call div16x16 ; xC = xA / xB with xA as remainder
1077 movff xC+0,batt_percent 1075 movff xC+0,batt_percent
1076 movlw .100 ; max. value is 100 %
1077 cpfslt batt_percent ; batt_percent < 100 % ?
1078 movwf batt_percent ; NO - limit to 100 %
1078 return 1079 return
1079 1080
1080 lt2942_set_to_zero_percent: 1081 lt2942_set_to_zero_percent:
1081 clrf i2c_temp1 1082 clrf i2c_temp1
1082 movlw 0x02 ; point to accumulated charge registers 1083 movlw 0x02 ; point to accumulated charge registers
1087 movff battery_offset+0,SSP1BUF 1088 movff battery_offset+0,SSP1BUF
1088 rcall WaitMSSP 1089 rcall WaitMSSP
1089 rcall I2C_WaitforACK 1090 rcall I2C_WaitforACK
1090 bsf SSP1CON2,PEN ; stop condition 1091 bsf SSP1CON2,PEN ; stop condition
1091 bra WaitMSSP ; ... and return 1092 bra WaitMSSP ; ... and return
1093
1092 1094
1093 global lt2942_charge_done 1095 global lt2942_charge_done
1094 lt2942_charge_done: ; reset accumulating registers to 0xFFFF 1096 lt2942_charge_done: ; reset accumulating registers to 0xFFFF
1095 clrf i2c_temp1 1097 clrf i2c_temp1
1096 movlw 0x02 ; point to accumulated charge registers 1098 movlw 0x02 ; point to accumulated charge registers
1120 rcall WaitMSSP 1122 rcall WaitMSSP
1121 movlw b'11001001' ; address byte + Read bit 1123 movlw b'11001001' ; address byte + Read bit
1122 movwf SSP1BUF ; control byte 1124 movwf SSP1BUF ; control byte
1123 rcall WaitMSSP 1125 rcall WaitMSSP
1124 rcall I2C_WaitforACK 1126 rcall I2C_WaitforACK
1125 bsf SSP1CON2, RCEN ; enable receive mode 1127 bsf SSP1CON2,RCEN ; enable receive mode
1126 bra WaitMSSP ; ... and return 1128 bra WaitMSSP ; ... and return
1127 1129
1128 1130
1129 ;============================================================================= 1131 ;=============================================================================
1130 ; Transmitter Functions 1132 ; Transmitter Functions
1254 bcf SSP1CON2,ACKDT ; reset ACKDT flag 1256 bcf SSP1CON2,ACKDT ; reset ACKDT flag
1255 bsf SSP1CON2,PEN ; stop condition 1257 bsf SSP1CON2,PEN ; stop condition
1256 bra WaitMSSP ; ... and return 1258 bra WaitMSSP ; ... and return
1257 1259
1258 1260
1261 IFDEF _rx_update
1262
1259 global I2C_update_OSTC_rx 1263 global I2C_update_OSTC_rx
1260 I2C_update_OSTC_rx: ; transfer 64 byte to RX co-processor 1264 I2C_update_OSTC_rx: ; transfer 64 byte to RX co-processor
1261 ; setup for write 1265 ; setup for write
1262 bcf i2c_error_flag ; clear error flag 1266 bcf i2c_error_flag ; clear error flag
1263 lfsr FSR2,buffer ; initialize pointer to send buffer used for verify 1267 lfsr FSR2,buffer ; initialize pointer to send buffer used for verify
1336 ; error check 1340 ; error check
1337 btfss i2c_error_flag ; did an error occur? 1341 btfss i2c_error_flag ; did an error occur?
1338 retlw .0 ; NO - data transfered successfully 1342 retlw .0 ; NO - data transfered successfully
1339 retlw .255 ; YES - error in data transfer occurred 1343 retlw .255 ; YES - error in data transfer occurred
1340 1344
1341 ENDIF 1345 ENDIF ; _rx_update
1346
1347 ENDIF ; _rx_functions
1342 1348
1343 ;============================================================================= 1349 ;=============================================================================
1344 1350
1345 END 1351 END