Mercurial > public > hwos_code
comparison src/adc_lightsensor.asm @ 629:237931377539
3.07 stable release
author | heinrichsweikamp |
---|---|
date | Fri, 29 Nov 2019 18:48:11 +0100 |
parents | cd58f7fc86db |
children | 185ba2f91f59 |
comparison
equal
deleted
inserted
replaced
628:cd58f7fc86db | 629:237931377539 |
---|---|
1 ;============================================================================= | 1 ;============================================================================= |
2 ; | 2 ; |
3 ; File adc_lightsensor.asm combined next generation V3.03.5 | 3 ; File adc_lightsensor.asm combined next generation V3.06.1 |
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 |
239 movwf max_CCPR1L ; - store value for dimming in TMR7 interrupt | 239 movwf max_CCPR1L ; - store value for dimming in TMR7 interrupt |
240 return ; - done | 240 return ; - done |
241 | 241 |
242 get_ambient_level1: ; using ambient sensor | 242 get_ambient_level1: ; using ambient sensor |
243 banksel isr_backup ; back to ISR default bank | 243 banksel isr_backup ; back to ISR default bank |
244 movlw b'00000000' ; Vref+ = Vdd | 244 clrf ADCON1 ; Vref+ = Vdd |
245 movwf ADCON1 | |
246 movlw b'00011101' ; power on ADC, select AN7 | 245 movlw b'00011101' ; power on ADC, select AN7 |
247 rcall wait_adc | 246 rcall wait_adc |
248 MOVII ADRESL,ambient_light | 247 MOVII ADRESL,ambient_light |
249 bcf ADCON0,0 ; power off ADC | 248 bcf ADCON0,0 ; power off ADC |
250 | 249 |
484 global get_analog_switches ; called from ISR and from sleep mode, returns in bank common | 483 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 | 484 get_analog_switches: ; start ADC and wait until finished |
486 banksel HW_variants ; switch to bank where OSTC model variant is stored | 485 banksel HW_variants ; switch to bank where OSTC model variant is stored |
487 btfsc analog_switches ; does the OSTC have analog switches? | 486 btfsc analog_switches ; does the OSTC have analog switches? |
488 bra get_analog_switches_1 ; YES | 487 bra get_analog_switches_1 ; YES |
489 get_analog_switches0: | 488 get_analog_switches0: |
490 banksel common ; NO - back to bank common | 489 banksel common ; NO - back to bank common |
491 bcf analog_sw1_pressed ; - clear flag for analog switch 1 | 490 bcf analog_sw1_pressed ; - clear flag for analog switch 1 |
492 bcf analog_sw2_pressed ; - clear flag for analog switch 2 | 491 bcf analog_sw2_pressed ; - clear flag for analog switch 2 |
493 return ; - done | 492 return ; - done |
494 | 493 |
500 bra get_analog_switches0 ; YES - abort (And clear both flags) | 499 bra get_analog_switches0 ; YES - abort (And clear both flags) |
501 ;bra get_analog_switches_2 ; NO - read switches | 500 ;bra get_analog_switches_2 ; NO - read switches |
502 | 501 |
503 get_analog_switches_2: | 502 get_analog_switches_2: |
504 bsf adc_is_running | 503 bsf adc_is_running |
505 movlw b'00001010' ; left justified | 504 bcf ADCON2,ADFM ; left justified |
506 movwf ADCON2 | |
507 ; movlw b'00000000' ; Vref+ = Vdd | |
508 clrf ADCON1 | 505 clrf ADCON1 |
509 movlw b'00100101' ; power on ADC, select AN9 | 506 movlw b'00100101' ; power on ADC, select AN9 |
510 rcall wait_adc | 507 rcall wait_adc |
511 | 508 |
512 banksel isr_backup ; select bank ISR data | 509 banksel isr_backup ; select bank ISR data |
612 | 609 |
613 get_analog_switches_sw1_pressed: | 610 get_analog_switches_sw1_pressed: |
614 bsf analog_sw1_pressed ; set right button as pressed | 611 bsf analog_sw1_pressed ; set right button as pressed |
615 | 612 |
616 get_analog_switches_4: | 613 get_analog_switches_4: |
617 movlw b'10001010' ; restore to right justified | 614 bsf ADCON2,ADFM ; restore to right justified |
618 movwf ADCON2 | |
619 bcf adc_is_running | 615 bcf adc_is_running |
620 banksel common ; back to bank common | 616 banksel common ; back to bank common |
621 btfsc analog_sw1_pressed ; right button pressed? | 617 btfsc analog_sw1_pressed ; right button pressed? |
622 return ; YES - done | 618 return ; YES - done |
623 btfsc analog_sw2_pressed ; left button pressed? | 619 btfsc analog_sw2_pressed ; left button pressed? |