comparison src/i2c.asm @ 574:b8f45b57302d

language, compass and color update
author heinrichsweikamp
date Wed, 14 Feb 2018 16:27:54 +0100
parents 0ba88db66492
children b455b31ce022
comparison
equal deleted inserted replaced
573:cf4395595d9b 574:b8f45b57302d
589 movlw b'00000000' ; CTRL4 589 movlw b'00000000' ; CTRL4
590 rcall I2C_TX 590 rcall I2C_TX
591 movlw b'01100100' ; CTRL5 HIGH res, 6,25Hz 591 movlw b'01100100' ; CTRL5 HIGH res, 6,25Hz
592 rcall I2C_TX 592 rcall I2C_TX
593 init_compass1_common: 593 init_compass1_common:
594 movff opt_compass_gain,i2c_temp ; 0-7 (230LSB/Gauss to 1370LSB/Gauss)
594 movlw b'01100000' ; CTRL6 Full scale (+/-12 Gauss -> 2730LSB/Gauss) 595 movlw b'01100000' ; CTRL6 Full scale (+/-12 Gauss -> 2730LSB/Gauss)
595 ;movlw b'00000000' ; CTRL6 (+/-2 Gauss) 596 dcfsnz i2c_temp,F ; = 1?
596 ;movlw b'00100000' ; CTRL6 (+/-4 Gauss) 597 movlw b'01100000' ; Yes, CTRL6 Full scale (+/-12 Gauss -> 2730LSB/Gauss)
598 dcfsnz i2c_temp,F ; = 2?
599 movlw b'01000000' ; Yes, CTRL6 (+/-8 Gauss)
600 dcfsnz i2c_temp,F ; = 3?
601 movlw b'01000000' ; Yes, CTRL6 (+/-8 Gauss)
602 dcfsnz i2c_temp,F ; = 4?
603 movlw b'00100000' ; Yes, CTRL6 (+/-4 Gauss)
604 dcfsnz i2c_temp,F ; = 5?
605 movlw b'00100000' ; Yes, CTRL6 (+/-4 Gauss)
606 dcfsnz i2c_temp,F ; = 6?
607 movlw b'00000000' ; Yes, CTRL6 (+/-2 Gauss)
608 dcfsnz i2c_temp,F ; = 7?
609 movlw b'00000000' ; Yes, CTRL6 (+/-2 Gauss)
597 rcall I2C_TX 610 rcall I2C_TX
598 movlw b'00000000' ; CTRL7 Continuous Mode 611 movlw b'00000000' ; CTRL7 Continuous Mode
599 rcall I2C_TX 612 rcall I2C_TX
600 bsf SSP1CON2,PEN ; Stop condition 613 bsf SSP1CON2,PEN ; Stop condition
601 bra WaitMSSP ; (And return) 614 bra WaitMSSP ; (And return)
749 rcall I2C_TX 762 rcall I2C_TX
750 movlw b'01010111' ; CTRL_REG1_A (100Hz, x,y,z = ON) 763 movlw b'01010111' ; CTRL_REG1_A (100Hz, x,y,z = ON)
751 rcall I2C_TX 764 rcall I2C_TX
752 movlw b'00000000' ; CTRL_REG2_A 765 movlw b'00000000' ; CTRL_REG2_A
753 rcall I2C_TX 766 rcall I2C_TX
754 movlw b'00000000' ; CTRL_REG3_A 767 ; movlw b'00000000' ; CTRL_REG3_A
755 rcall I2C_TX 768 ; rcall I2C_TX
756 movlw b'00000000' ; CTRL_REG4_A (BDU=0, +/-2g, 769 ; movlw b'00000000' ; CTRL_REG4_A (BDU=0, +/-2g,
757 rcall I2C_TX 770 ; rcall I2C_TX
758 movlw b'00000000' ; CTRL_REG5_A 771 ; movlw b'00000000' ; CTRL_REG5_A
759 rcall I2C_TX 772 ; rcall I2C_TX
760 bsf SSP1CON2,PEN ; Stop condition 773 bsf SSP1CON2,PEN ; Stop condition
761 bra WaitMSSP ; (And return) 774 bra WaitMSSP ; (And return)
762 775
763 global I2C_sleep_accelerometer 776 global I2C_sleep_accelerometer
764 I2C_sleep_accelerometer: 777 I2C_sleep_accelerometer:
999 rcall WaitMSSP 1012 rcall WaitMSSP
1000 movlw b'11001000' ; Address byte + Write bit 1013 movlw b'11001000' ; Address byte + Write bit
1001 movwf SSP1BUF ; control byte 1014 movwf SSP1BUF ; control byte
1002 rcall WaitMSSP 1015 rcall WaitMSSP
1003 rcall I2C_WaitforACK 1016 rcall I2C_WaitforACK
1004 movff i2c_temp+1, SSP1BUF ; Data Byte 1017 movf i2c_temp+1,W
1005 rcall WaitMSSP 1018 bra I2C_TX ; (and return)
1006 bra I2C_WaitforACK ; (and return) 1019
1007
1008 I2C_RX_GAUGE: 1020 I2C_RX_GAUGE:
1009 bsf SSP1CON2,SEN ; Start condition 1021 bsf SSP1CON2,SEN ; Start condition
1010 rcall WaitMSSP 1022 rcall WaitMSSP
1011 movlw b'11001001' ; Address byte + Read bit 1023 movlw b'11001001' ; Address byte + Read bit
1012 movwf SSP1BUF ; control byte 1024 movwf SSP1BUF ; control byte