Mercurial > public > hwos_code
comparison src/adc_lightsensor.asm @ 628:cd58f7fc86db
3.05 stable work
author | heinrichsweikamp |
---|---|
date | Thu, 19 Sep 2019 12:01:29 +0200 |
parents | c40025d8e750 |
children | 237931377539 |
comparison
equal
deleted
inserted
replaced
627:bf5fee575701 | 628:cd58f7fc86db |
---|---|
1 ;============================================================================= | 1 ;============================================================================= |
2 ; | 2 ; |
3 ; File adc_lightsensor.asm combined next generation V3.03.2 | 3 ; File adc_lightsensor.asm combined next generation V3.03.5 |
4 ; | 4 ; |
5 ; | 5 ; |
6 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. | 6 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. |
7 ;============================================================================= | 7 ;============================================================================= |
8 ; HISTORY | 8 ; HISTORY |
217 movff sub_c+0,lo ; store result | 217 movff sub_c+0,lo ; store result |
218 bra get_battery_voltage_8 ; check limits and return | 218 bra get_battery_voltage_8 ; check limits and return |
219 | 219 |
220 | 220 |
221 global get_ambient_level ; called from ISR only, in context bank isr_backup | 221 global get_ambient_level ; called from ISR only, in context bank isr_backup |
222 get_ambient_level: ; starts ADC and waits until finished | 222 get_ambient_level: |
223 btfsc sleepmode ; in sleep mode? | 223 btfsc sleepmode ; in sleep mode? |
224 return ; YES - done | 224 return ; YES - done |
225 btfsc adc_is_running ; NO - ADC in use? | 225 btfsc adc_is_running ; NO - ADC in use? |
226 return ; YES - return | 226 return ; YES - return |
227 banksel HW_descriptor ; NO - select bank where hardware descriptor is stored | 227 banksel HW_descriptor ; NO - select bank where hardware descriptor is stored |
484 global get_analog_switches ; called from ISR and from sleep mode, returns in bank common | 484 global get_analog_switches ; called from ISR and from sleep mode, returns in bank common |
485 get_analog_switches: ; start ADC and wait until finished | 485 get_analog_switches: ; start ADC and wait until finished |
486 banksel HW_variants ; switch to bank where OSTC model variant is stored | 486 banksel HW_variants ; switch to bank where OSTC model variant is stored |
487 btfsc analog_switches ; does the OSTC have analog switches? | 487 btfsc analog_switches ; does the OSTC have analog switches? |
488 bra get_analog_switches_1 ; YES | 488 bra get_analog_switches_1 ; YES |
489 get_analog_switches0: | |
489 banksel common ; NO - back to bank common | 490 banksel common ; NO - back to bank common |
490 bcf analog_sw1_pressed ; - clear flag for analog switch 1 | 491 bcf analog_sw1_pressed ; - clear flag for analog switch 1 |
491 bcf analog_sw2_pressed ; - clear flag for analog switch 2 | 492 bcf analog_sw2_pressed ; - clear flag for analog switch 2 |
492 return ; - done | 493 return ; - done |
493 | 494 |
494 get_analog_switches_1: | 495 get_analog_switches_1: |
495 banksel common ; back to bank common | 496 banksel common ; back to bank common |
496 btfsc adc_is_running ; ADC in use? | 497 btfsc adc_is_running ; ADC in use? |
497 return ; YES - abort | 498 return ; YES - abort |
498 ;bra get_analog_switches_2 ; NO - read switches | 499 btfsc cc_active ; NO - charging? |
500 bra get_analog_switches0 ; YES - abort (And clear both flags) | |
501 ;bra get_analog_switches_2 ; NO - read switches | |
499 | 502 |
500 get_analog_switches_2: | 503 get_analog_switches_2: |
501 movlw b'00001001' ; left justified | 504 bsf adc_is_running |
505 movlw b'00001010' ; left justified | |
502 movwf ADCON2 | 506 movwf ADCON2 |
503 ; movlw b'00000000' ; Vref+ = Vdd | 507 ; movlw b'00000000' ; Vref+ = Vdd |
504 clrf ADCON1 | 508 clrf ADCON1 |
505 movlw b'00100101' ; power on ADC, select AN9 | 509 movlw b'00100101' ; power on ADC, select AN9 |
506 rcall wait_adc | 510 rcall wait_adc |
608 | 612 |
609 get_analog_switches_sw1_pressed: | 613 get_analog_switches_sw1_pressed: |
610 bsf analog_sw1_pressed ; set right button as pressed | 614 bsf analog_sw1_pressed ; set right button as pressed |
611 | 615 |
612 get_analog_switches_4: | 616 get_analog_switches_4: |
613 movlw b'10001101' ; restore to right justified | 617 movlw b'10001010' ; restore to right justified |
614 movwf ADCON2 | 618 movwf ADCON2 |
615 | 619 bcf adc_is_running |
616 banksel common ; back to bank common | 620 banksel common ; back to bank common |
617 btfsc analog_sw1_pressed ; right button pressed? | 621 btfsc analog_sw1_pressed ; right button pressed? |
618 return ; YES - done | 622 return ; YES - done |
619 btfsc analog_sw2_pressed ; left button pressed? | 623 btfsc analog_sw2_pressed ; left button pressed? |
620 return ; YES - done | 624 return ; YES - done |