Mercurial > public > hwos_code
comparison src/i2c.asm @ 618:7b3903536213
work on new battery menu
author | heinrichsweikamp |
---|---|
date | Mon, 04 Feb 2019 22:57:24 +0100 |
parents | 935e20e16dff |
children | cd986267a5ca |
comparison
equal
deleted
inserted
replaced
617:08b28118c46b | 618:7b3903536213 |
---|---|
870 movwf xB+0 | 870 movwf xB+0 |
871 movlw HIGH .6000 | 871 movlw HIGH .6000 |
872 movwf xB+1 | 872 movwf xB+1 |
873 call mult16x16 ; xA*xB=xC | 873 call mult16x16 ; xA*xB=xC |
874 | 874 |
875 ; divide xC (32bit)/65535 for result in mV (16bit) | 875 ; xC+3:xC+2 -> Result in mV |
876 movlw .16 | |
877 movwf i2c_temp1 | |
878 lt2942_get_voltage2: | |
879 bcf STATUS,C | |
880 rrcf xC+3,F | |
881 rrcf xC+2,F | |
882 rrcf xC+1,F | |
883 rrcf xC+0,F | |
884 decfsz i2c_temp1,F | |
885 bra lt2942_get_voltage2 | |
886 | 876 |
887 ; Update battery voltage in mV | 877 ; Update battery voltage in mV |
888 movff xC+1,batt_voltage+1 | 878 movff xC+3,batt_voltage+1 |
889 movff xC+0,batt_voltage+0 | 879 movff xC+2,batt_voltage+0 |
890 | 880 |
891 tstfsz batt_voltage+1 ; <256mV? | 881 tstfsz batt_voltage+1 ; <256mV? |
892 return ; No, done. | 882 return ; No, done. |
893 bra lt2942_init ;(and return) | 883 bra lt2942_init ;(and return) |
894 | 884 |
913 movwf xB+0 | 903 movwf xB+0 |
914 movlw HIGH .6000 | 904 movlw HIGH .6000 |
915 movwf xB+1 | 905 movwf xB+1 |
916 call mult16x16 ;xA*xB=xC | 906 call mult16x16 ;xA*xB=xC |
917 | 907 |
918 ; devide xC (32bit)/65535 for result in 0.1K (16bit) | 908 ; xC+3:xC+2 -> Result in 0.1K |
919 movlw .16 | |
920 movwf i2c_temp1 | |
921 lt2942_get_temperature2: | |
922 bcf STATUS,C | |
923 rrcf xC+3,F | |
924 rrcf xC+2,F | |
925 rrcf xC+1,F ; Result in 0.1K | |
926 rrcf xC+0,F ; Result in 0.1K | |
927 decfsz i2c_temp1,F | |
928 bra lt2942_get_temperature2 | |
929 | 909 |
930 movlw LOW max_allowed_battery_temp ; in 0.1K | 910 movlw LOW max_allowed_battery_temp ; in 0.1K |
931 movwf sub_a+0 | 911 movwf sub_a+0 |
932 movlw HIGH max_allowed_battery_temp | 912 movlw HIGH max_allowed_battery_temp |
933 movwf sub_a+1 | 913 movwf sub_a+1 |
934 movff xC+1,sub_b+1 | 914 movff xC+3,sub_b+1 |
935 movff xC+0,sub_b+0 | 915 movff xC+2,sub_b+0 |
936 call subU16 ; sub_c = sub_a - sub_b (with UNSIGNED values) | 916 call subU16 ; sub_c = sub_a - sub_b (with UNSIGNED values) |
937 btfss neg_flag | 917 btfss neg_flag |
938 return ; temp ok, return | 918 return ; temp ok, return |
939 ; too hot, disable charge if currently charging | 919 ; too hot, disable charge if currently charging |
940 btfss cc_active | 920 btfss cc_active |