Mercurial > public > hwos_code
comparison src/adc_lightsensor.asm @ 615:b87f23fae743
work on new battery menu
| author | heinrichsweikamp |
|---|---|
| date | Sat, 02 Feb 2019 17:39:44 +0100 |
| parents | d866684249bd |
| children | c40025d8e750 be8787f2034d |
comparison
equal
deleted
inserted
replaced
| 614:a32212cd5ea9 | 615:b87f23fae743 |
|---|---|
| 36 btfss battery_gauge_available | 36 btfss battery_gauge_available |
| 37 bra get_battery_voltage1 ; normal ostc3 hardware | 37 bra get_battery_voltage1 ; normal ostc3 hardware |
| 38 | 38 |
| 39 call lt2942_get_accumulated_charge | 39 call lt2942_get_accumulated_charge |
| 40 call lt2942_get_voltage | 40 call lt2942_get_voltage |
| 41 | 41 call lt2942_get_temperature |
| 42 | |
| 42 tstfsz batt_voltage+1 ; < 256 mV ? | 43 tstfsz batt_voltage+1 ; < 256 mV ? |
| 43 bra get_battery_voltage_noretry ; NO | 44 bra get_battery_voltage_noretry ; NO |
| 44 | 45 |
| 45 ; Retry | 46 ; Retry |
| 46 call lt2942_get_accumulated_charge | 47 call lt2942_get_accumulated_charge |
| 47 call lt2942_get_voltage | 48 call lt2942_get_voltage |
| 49 call lt2942_get_temperature | |
| 48 | 50 |
| 49 get_battery_voltage_noretry: | 51 get_battery_voltage_noretry: |
| 50 btfsc divemode | 52 btfsc divemode |
| 51 return ; not in divemode | 53 return ; not in divemode |
| 52 | 54 |
| 63 bsf TRISJ,2 ; Chrg-Out high impedance | 65 bsf TRISJ,2 ; Chrg-Out high impedance |
| 64 | 66 |
| 65 WAITMS d'1' | 67 WAITMS d'1' |
| 66 | 68 |
| 67 btfsc CHRG_IN | 69 btfsc CHRG_IN |
| 68 return | 70 return ; Not charging, done. |
| 69 charge_cv_active: | 71 charge_cv_active: |
| 70 decfsz get_bat_volt_counter,F | 72 decfsz get_bat_volt_counter,F |
| 71 return | 73 return |
| 72 movlw .15 | 74 movlw .15 |
| 73 cpfsgt batt_voltage+1 ; battery voltage >= 16*256mV (4,096V)? | 75 cpfsgt batt_voltage+1 ; battery voltage >= 16*256mV (4,096V)? |
| 96 movlw .10 | 98 movlw .10 |
| 97 movwf get_bat_volt_counter | 99 movwf get_bat_volt_counter |
| 98 return | 100 return |
| 99 | 101 |
| 100 get_battery_voltage1: | 102 get_battery_voltage1: |
| 101 bsf adc_running ; =1: The ADC is in use | 103 ; Additional disable in software |
| 104 bsf charge_disable | |
| 105 bcf TRISE,2 | |
| 106 bsf adc_running ; =1: The ADC is in use | |
| 107 | |
| 102 movlw b'00100000' ; 2.048V Vref+ -> 1LSB = 500µV | 108 movlw b'00100000' ; 2.048V Vref+ -> 1LSB = 500µV |
| 103 movwf ADCON1 | 109 movwf ADCON1 |
| 104 movlw b'00011001' ; power on ADC, select AN6 | 110 movlw b'00011001' ; power on ADC, select AN6 |
| 105 rcall wait_adc | 111 rcall wait_adc |
| 106 | 112 |
