comparison src/i2c.asm @ 621:1ad0531e9078

3.01 release
author heinrichsweikamp
date Sat, 23 Feb 2019 16:51:14 +0100
parents cd986267a5ca
children c40025d8e750 be8787f2034d
comparison
equal deleted inserted replaced
620:cd986267a5ca 621:1ad0531e9078
82 rrcf lo 82 rrcf lo
83 return 83 return
84 84
85 global I2C_RX_accelerometer 85 global I2C_RX_accelerometer
86 I2C_RX_accelerometer: 86 I2C_RX_accelerometer:
87 btfss compass_enabled ; Compass enabled?
88 return ; No, return
89 btfsc compass_type2 ; compass2 ? 87 btfsc compass_type2 ; compass2 ?
90 bra I2C_RX_accelerometer_compass2 ; YES 88 bra I2C_RX_accelerometer_compass2 ; YES
91 btfsc compass_type ; compass1 ? 89 btfsc compass_type ; compass1 ?
92 bra I2C_RX_accelerometer_compass1 ; YES 90 bra I2C_RX_accelerometer_compass1 ; YES
93 I2C_RX_accelerometer_compass0: 91 I2C_RX_accelerometer_compass0:
269 bsf SSP1CON2,ACKEN ; Master acknowledge 267 bsf SSP1CON2,ACKEN ; Master acknowledge
270 bra WaitMSSP ; And return! 268 bra WaitMSSP ; And return!
271 269
272 global I2C_RX_compass 270 global I2C_RX_compass
273 I2C_RX_compass: 271 I2C_RX_compass:
274 btfss compass_enabled ; Compass enabled?
275 return ; No, return
276
277 btfsc compass_type2 ; compass2 272 btfsc compass_type2 ; compass2
278 bra I2C_RX_compass2 ; yes 273 bra I2C_RX_compass2 ; yes
279 btfsc compass_type ; compass1? 274 btfsc compass_type ; compass1?
280 bra I2C_RX_compass1 ; yes 275 bra I2C_RX_compass1 ; yes
281 I2C_RX_compass0: 276 I2C_RX_compass0:
500 bsf SSP1CON2,PEN ; Stop condition 495 bsf SSP1CON2,PEN ; Stop condition
501 rcall WaitMSSP 496 rcall WaitMSSP
502 497
503 btfsc compass_type ; compass1? 498 btfsc compass_type ; compass1?
504 bra I2C_init_compass1 ; yes 499 bra I2C_init_compass1 ; yes
505
506 ; Check for compass0
507 bsf SSP1CON2,SEN ; Start condition
508 rcall WaitMSSP
509 movlw 0x3C ; address
510 rcall I2C_TX
511 movlw 0x10
512 rcall I2C_TX
513 bsf SSP1CON2,PEN ; Stop condition
514 rcall WaitMSSP
515 bcf PIR1,SSP1IF
516 bsf SSP1CON2,SEN ; Start condition
517 rcall WaitMSSP
518 movlw 0x3D ; address
519 rcall I2C_TX
520 rcall I2C_OneByteRX ; Get one byte
521 movlw "H" ; ASCI "H" = Compass0
522 cpfseq SSP1BUF
523 bcf compass_enabled ; clear enable flag, neither Compass2, 1 or 0 was found properly
524 bsf SSP1CON2,PEN ; Stop condition
525 rcall WaitMSSP
526
527
528 ; init compass0 500 ; init compass0
529 btfss compass_enabled ; Compass enabled?
530 return ; No, return
531 bsf SSP1CON2,SEN ; Start condition 501 bsf SSP1CON2,SEN ; Start condition
532 rcall WaitMSSP 502 rcall WaitMSSP
533 movlw 0x3C ; address 503 movlw 0x3C ; address
534 rcall I2C_TX 504 rcall I2C_TX
535 movlw 0x00 505 movlw 0x00
610 bra WaitMSSP ;(And return) 580 bra WaitMSSP ;(And return)
611 581
612 582
613 global I2C_sleep_compass 583 global I2C_sleep_compass
614 I2C_sleep_compass: 584 I2C_sleep_compass:
615 btfss compass_enabled ; Compass enabled?
616 return ; No, return
617 bcf compass_enabled 585 bcf compass_enabled
618 btfsc compass_type2 ; compass2? 586 btfsc compass_type2 ; compass2?
619 bra I2C_sleep_compass2 ; yes 587 bra I2C_sleep_compass2 ; yes
620 btfsc compass_type ; compass1? 588 btfsc compass_type ; compass1?
621 bra I2C_sleep_compass1 ; yes 589 bra I2C_sleep_compass1 ; yes
752 movwf SSP1ADD 720 movwf SSP1ADD
753 return 721 return
754 722
755 global I2C_init_accelerometer 723 global I2C_init_accelerometer
756 I2C_init_accelerometer: 724 I2C_init_accelerometer:
757 btfss compass_enabled ; Compass enabled?
758 return ; No, return
759
760 btfsc compass_type2 ; compass2? 725 btfsc compass_type2 ; compass2?
761 bra I2C_init_accelerometer2 ; Yes. 726 bra I2C_init_accelerometer2 ; Yes.
762 727
763 btfsc compass_type ; compass1? 728 btfsc compass_type ; compass1?
764 return ; yes, ignore 729 return ; yes, ignore