Mercurial > public > hwos_code
comparison src/i2c.asm @ 608:d866684249bd
work on 2.99 stable
author | heinrichsweikamp |
---|---|
date | Mon, 07 Jan 2019 21:13:43 +0100 |
parents | ca4556fb60b9 |
children | b87f23fae743 |
comparison
equal
deleted
inserted
replaced
607:c5151a490d88 | 608:d866684249bd |
---|---|
622 rcall I2C_TX | 622 rcall I2C_TX |
623 bsf SSP1CON2,PEN ; Stop condition | 623 bsf SSP1CON2,PEN ; Stop condition |
624 bra WaitMSSP ; (And return) | 624 bra WaitMSSP ; (And return) |
625 | 625 |
626 I2C_init_compass2: | 626 I2C_init_compass2: |
627 bsf SSP1CON2,SEN ; Start condition | 627 bsf SSP1CON2,SEN ; Start condition |
628 rcall WaitMSSP | 628 rcall WaitMSSP |
629 movlw 0x3C ; address | 629 movlw 0x3C ; address |
630 rcall I2C_TX | 630 rcall I2C_TX |
631 movlw 0xE0 ; 0x60 with auto-increment (MSB=1) | 631 movlw 0xE0 ; 0x60 with auto-increment (MSB=1) |
632 rcall I2C_TX | 632 rcall I2C_TX |
633 movlw b'00000000' ; CFG_REG_A_M (10Hz, Continuous) | 633 movlw b'00000000' ; CFG_REG_A_M (10Hz, Continuous) 0x60 |
634 rcall I2C_TX | 634 rcall I2C_TX |
635 movlw b'00000000' ; CFG_REG_B_M (Low-Pass Filter off) | 635 movlw b'00000000' ; CFG_REG_B_M (Low-Pass Filter off) 0x61 (set pulse is released every 63 ODR) |
636 rcall I2C_TX | 636 rcall I2C_TX |
637 movlw b'00000000' ; CFG_REG_C_M BDU=0 | 637 movlw b'00000000' ; CFG_REG_C_M BDU=0 0x62 |
638 rcall I2C_TX | 638 rcall I2C_TX |
639 bsf SSP1CON2,PEN ; Stop condition | 639 bsf SSP1CON2,PEN ; Stop condition |
640 bra WaitMSSP ;(And return) | 640 bra WaitMSSP ;(And return) |
641 | 641 |
642 | 642 |
643 global I2C_sleep_compass | 643 global I2C_sleep_compass |
644 I2C_sleep_compass: | 644 I2C_sleep_compass: |
645 bcf compass_enabled | 645 bcf compass_enabled |
684 rcall I2C_TX | 684 rcall I2C_TX |
685 bsf SSP1CON2,PEN ; Stop condition | 685 bsf SSP1CON2,PEN ; Stop condition |
686 bra WaitMSSP ;(And return) | 686 bra WaitMSSP ;(And return) |
687 | 687 |
688 I2C_sleep_compass2: | 688 I2C_sleep_compass2: |
689 ; magnetic | 689 ; magnetic |
690 bsf SSP1CON2,SEN ; Start condition | 690 bsf SSP1CON2,SEN ; Start condition |
691 rcall WaitMSSP | 691 rcall WaitMSSP |
692 movlw 0x3C ; address | 692 movlw 0x3C ; address |
693 rcall I2C_TX | 693 rcall I2C_TX |
694 movlw 0xE0 ; 0x60 with auto-increment (MSB=1) | 694 movlw 0xE0 ; 0x60 with auto-increment (MSB=1) |
695 rcall I2C_TX | 695 rcall I2C_TX |
696 movlw b'00000010' ; CFG_REG_A_M (Idle mode) | 696 movlw b'00000011' ; CFG_REG_A_M (Idle mode) 0x60 |
697 rcall I2C_TX | 697 rcall I2C_TX |
698 bsf SSP1CON2,PEN ; Stop condition | 698 movlw b'00000100' ; CFG_REG_B_M 0x61 (set pulse is released only at power-on after PD condition) |
699 bra WaitMSSP ; (And return) | 699 rcall I2C_TX |
700 | 700 movlw b'01010001' ; CFG_REG_C_M 0x62 |
701 rcall I2C_TX | |
702 movlw b'00000000' ; INT_CTRL_REG_M 0x63 | |
703 rcall I2C_TX | |
704 | |
705 bsf SSP1CON2,PEN ; Stop condition | |
706 bra WaitMSSP ; (And return) | |
707 | |
701 I2C_sleep_accelerometer2: | 708 I2C_sleep_accelerometer2: |
702 ; accelerometer | 709 ; accelerometer |
703 bsf SSP1CON2,SEN ; Start condition | 710 bsf SSP1CON2,SEN ; Start condition |
704 rcall WaitMSSP | 711 rcall WaitMSSP |
705 movlw 0x32 ; address | 712 movlw 0x32 ; address |
706 rcall I2C_TX | 713 rcall I2C_TX |
707 movlw 0x9F ; 1F with auto-increment (MSB=1) | 714 movlw 0x9F ; 1F with auto-increment (MSB=1) |
708 rcall I2C_TX | 715 rcall I2C_TX |
709 movlw b'00000000' ; TEMP_CFG_REG_A (Temp sensor off) | 716 movlw b'00000000' ; TEMP_CFG_REG_A (Temp sensor off) 0x1F |
710 rcall I2C_TX | 717 rcall I2C_TX |
711 movlw b'00000000' ; CTRL_REG1_A (All off) | 718 movlw b'00000000' ; CTRL_REG1_A (All off) 0x20 |
712 rcall I2C_TX | 719 rcall I2C_TX |
713 bsf SSP1CON2,PEN ; Stop condition | 720 bsf SSP1CON2,PEN ; Stop condition |
714 bra WaitMSSP ; (And return) | 721 bra WaitMSSP ; (And return) |
715 | 722 |
716 global I2C_init_accelerometer | 723 global I2C_init_accelerometer |
717 I2C_init_accelerometer: | 724 I2C_init_accelerometer: |
718 btfsc compass_type2 ; compass2? | 725 btfsc compass_type2 ; compass2? |
719 bra I2C_init_accelerometer2 ; Yes. | 726 bra I2C_init_accelerometer2 ; Yes. |
1105 bsf active_reset_ostc_rx | 1112 bsf active_reset_ostc_rx |
1106 WAITMS .5 | 1113 WAITMS .5 |
1107 bcf active_reset_ostc_rx | 1114 bcf active_reset_ostc_rx |
1108 WAITMS .250 | 1115 WAITMS .250 |
1109 WAITMS .250 | 1116 WAITMS .250 |
1110 WAITMS .250 | |
1111 WAITMS .250 | |
1112 WAITMS .250 | |
1113 WAITMS .250 | |
1114 WAITMS .250 | |
1115 WAITMS .250 | |
1116 clrf i2c_temp1 | 1117 clrf i2c_temp1 |
1117 decfsz lo_temp,F ; try max. 5 times | 1118 decfsz lo_temp,F ; try max. 5 times |
1118 bra I2C_probe_OSTC_rx_1 | 1119 bra I2C_probe_OSTC_rx_1 |
1119 bcf ostc_rx_present ; Clear flag. Something is wrong | 1120 bcf ostc_rx_present ; Clear flag. Something is wrong |
1120 I2C_probe_OSTC_rx_2: | 1121 I2C_probe_OSTC_rx_2: |