Mercurial > public > hwos_code
comparison src/i2c.asm @ 620:cd986267a5ca
potential compass bug "fixed"
author | heinrichsweikamp |
---|---|
date | Fri, 22 Feb 2019 16:30:05 +0100 |
parents | 7b3903536213 |
children | 1ad0531e9078 |
comparison
equal
deleted
inserted
replaced
619:e76a87e087ef | 620:cd986267a5ca |
---|---|
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 | |
87 btfsc compass_type2 ; compass2 ? | 89 btfsc compass_type2 ; compass2 ? |
88 bra I2C_RX_accelerometer_compass2 ; YES | 90 bra I2C_RX_accelerometer_compass2 ; YES |
89 btfsc compass_type ; compass1 ? | 91 btfsc compass_type ; compass1 ? |
90 bra I2C_RX_accelerometer_compass1 ; YES | 92 bra I2C_RX_accelerometer_compass1 ; YES |
91 I2C_RX_accelerometer_compass0: | 93 I2C_RX_accelerometer_compass0: |
267 bsf SSP1CON2,ACKEN ; Master acknowledge | 269 bsf SSP1CON2,ACKEN ; Master acknowledge |
268 bra WaitMSSP ; And return! | 270 bra WaitMSSP ; And return! |
269 | 271 |
270 global I2C_RX_compass | 272 global I2C_RX_compass |
271 I2C_RX_compass: | 273 I2C_RX_compass: |
274 btfss compass_enabled ; Compass enabled? | |
275 return ; No, return | |
276 | |
272 btfsc compass_type2 ; compass2 | 277 btfsc compass_type2 ; compass2 |
273 bra I2C_RX_compass2 ; yes | 278 bra I2C_RX_compass2 ; yes |
274 btfsc compass_type ; compass1? | 279 btfsc compass_type ; compass1? |
275 bra I2C_RX_compass1 ; yes | 280 bra I2C_RX_compass1 ; yes |
276 I2C_RX_compass0: | 281 I2C_RX_compass0: |
495 bsf SSP1CON2,PEN ; Stop condition | 500 bsf SSP1CON2,PEN ; Stop condition |
496 rcall WaitMSSP | 501 rcall WaitMSSP |
497 | 502 |
498 btfsc compass_type ; compass1? | 503 btfsc compass_type ; compass1? |
499 bra I2C_init_compass1 ; yes | 504 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 | |
500 ; init compass0 | 528 ; init compass0 |
529 btfss compass_enabled ; Compass enabled? | |
530 return ; No, return | |
501 bsf SSP1CON2,SEN ; Start condition | 531 bsf SSP1CON2,SEN ; Start condition |
502 rcall WaitMSSP | 532 rcall WaitMSSP |
503 movlw 0x3C ; address | 533 movlw 0x3C ; address |
504 rcall I2C_TX | 534 rcall I2C_TX |
505 movlw 0x00 | 535 movlw 0x00 |
580 bra WaitMSSP ;(And return) | 610 bra WaitMSSP ;(And return) |
581 | 611 |
582 | 612 |
583 global I2C_sleep_compass | 613 global I2C_sleep_compass |
584 I2C_sleep_compass: | 614 I2C_sleep_compass: |
615 btfss compass_enabled ; Compass enabled? | |
616 return ; No, return | |
585 bcf compass_enabled | 617 bcf compass_enabled |
586 btfsc compass_type2 ; compass2? | 618 btfsc compass_type2 ; compass2? |
587 bra I2C_sleep_compass2 ; yes | 619 bra I2C_sleep_compass2 ; yes |
588 btfsc compass_type ; compass1? | 620 btfsc compass_type ; compass1? |
589 bra I2C_sleep_compass1 ; yes | 621 bra I2C_sleep_compass1 ; yes |
720 movwf SSP1ADD | 752 movwf SSP1ADD |
721 return | 753 return |
722 | 754 |
723 global I2C_init_accelerometer | 755 global I2C_init_accelerometer |
724 I2C_init_accelerometer: | 756 I2C_init_accelerometer: |
757 btfss compass_enabled ; Compass enabled? | |
758 return ; No, return | |
759 | |
725 btfsc compass_type2 ; compass2? | 760 btfsc compass_type2 ; compass2? |
726 bra I2C_init_accelerometer2 ; Yes. | 761 bra I2C_init_accelerometer2 ; Yes. |
727 | 762 |
728 btfsc compass_type ; compass1? | 763 btfsc compass_type ; compass1? |
729 return ; yes, ignore | 764 return ; yes, ignore |