Mercurial > public > hwos_code
comparison src/start.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 start.asm combined next generation V3.03.2 | 3 ; File start.asm combined next generation V3.04.3 |
| 4 ; | 4 ; |
| 5 ; Startup subroutines | 5 ; Startup subroutines |
| 6 ; | 6 ; |
| 7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. | 7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. |
| 8 ;============================================================================= | 8 ;============================================================================= |
| 48 ENDIF | 48 ENDIF |
| 49 | 49 |
| 50 IFDEF _rx_functions | 50 IFDEF _rx_functions |
| 51 extern option_cleanup_oTrMode_CCR | 51 extern option_cleanup_oTrMode_CCR |
| 52 extern option_cleanup_oTrMode_no_CCR | 52 extern option_cleanup_oTrMode_no_CCR |
| 53 ENDIF | |
| 54 | |
| 55 IFDEF _rx_update | |
| 53 extern rx_firmware_new_major | 56 extern rx_firmware_new_major |
| 54 extern rx_firmware_new_minor | 57 extern rx_firmware_new_minor |
| 55 ENDIF | 58 ENDIF |
| 56 | 59 |
| 57 ;----------------------------------------------------------------------------- | 60 ;----------------------------------------------------------------------------- |
| 106 cpfseq TABLAT ; equal? | 109 cpfseq TABLAT ; equal? |
| 107 bcf analog_switches ; NO - no analog buttons | 110 bcf analog_switches ; NO - no analog buttons |
| 108 | 111 |
| 109 ; get screen type (2) from bootloader info | 112 ; get screen type (2) from bootloader info |
| 110 bsf screen_type2 | 113 bsf screen_type2 |
| 114 bsf screen_type3 | |
| 111 movlw 0x80 | 115 movlw 0x80 |
| 112 movwf TBLPTRL ; only low byte adjustment needed, high and upper are still at 0x01F7xx | 116 movwf TBLPTRL ; only low byte adjustment needed, high and upper are still at 0x01F7xx |
| 113 TBLRD*+ ; read configuration byte | 117 TBLRD*+ ; read configuration byte |
| 114 movlw 0x83 ; coding for screen type 2 | 118 movlw 0x83 ; coding for screen type 2 |
| 115 cpfseq TABLAT ; equal? | 119 cpfseq TABLAT ; equal? |
| 116 bcf screen_type2 ; NO - not screen type 2 | 120 bcf screen_type2 ; NO - not screen type 2 |
| 121 movlw 0x84 ; coding for screen type 3 | |
| 122 cpfseq TABLAT ; equal? | |
| 123 bcf screen_type3 ; NO - not screen type 3 | |
| 117 | 124 |
| 118 ; get button polarity from configuration data (EEPROM) | 125 ; get button polarity from configuration data (EEPROM) |
| 119 movlw LOW .897 | 126 movlw LOW .897 |
| 120 movwf EEADR | 127 movwf EEADR |
| 121 movlw HIGH .897 | 128 movlw HIGH .897 |
| 130 | 137 |
| 131 ; wait for calibration data to take effect | 138 ; wait for calibration data to take effect |
| 132 bsf LEDr ; turn on red LED | 139 bsf LEDr ; turn on red LED |
| 133 | 140 |
| 134 ; first pass, will not have valid temperature yet | 141 ; first pass, will not have valid temperature yet |
| 135 bcf trigger_pres_update ; make sure ISR pressure update confirmation is not older than from now on | 142 call wait_1s |
| 136 btfss trigger_pres_update ; has the ISR confirmed a pressure update? | 143 call wait_1s |
| 137 bra $-2 ; NO - not yet, loop waiting for the ISR to kick in | 144 ; bcf trigger_pres_update ; make sure ISR pressure update confirmation is not older than from now on |
| 145 ; btfss trigger_pres_update ; has the ISR confirmed a pressure update? | |
| 146 ; bra $-2 ; NO - not yet, loop waiting for the ISR to kick in | |
| 138 | 147 |
| 139 ; second pass - complete sensor initialization | 148 ; second pass - complete sensor initialization |
| 140 bcf trigger_pres_update ; make sure ISR pressure update confirmation is not older than from now on | 149 call wait_1s |
| 141 btfss trigger_pres_update ; has the ISR confirmed a pressure update? | 150 call wait_1s |
| 142 bra $-2 ; NO - not yet, loop waiting for the ISR to kick in | 151 ; bcf trigger_pres_update ; make sure ISR pressure update confirmation is not older than from now on |
| 152 ; btfss trigger_pres_update ; has the ISR confirmed a pressure update? | |
| 153 ; bra $-2 ; NO - not yet, loop waiting for the ISR to kick in | |
| 143 | 154 |
| 144 ; sensor calibration completed, first valid pressure value is available | 155 ; sensor calibration completed, first valid pressure value is available |
| 145 bcf LEDr ; turn off red LED again | 156 bcf LEDr ; turn off red LED again |
| 146 | 157 |
| 147 ; load surface pressure into ISR | 158 ; load surface pressure into ISR |
| 283 btfsc option_repaired ; errors found & repaired during options check? | 294 btfsc option_repaired ; errors found & repaired during options check? |
| 284 call option_save_all ; YES - save corrected settings into EEPROM | 295 call option_save_all ; YES - save corrected settings into EEPROM |
| 285 | 296 |
| 286 ; clear flag groups | 297 ; clear flag groups |
| 287 clrf HW_descriptor ; hardware - OSTC model descriptor | 298 clrf HW_descriptor ; hardware - OSTC model descriptor |
| 288 clrf HW_flags_state ; hardware - status | 299 clrf HW_flags_state1 ; hardware - states |
| 300 ; ; do not clear HW_flags_state2 ! | |
| 289 clrf DM_flags_sensor ; hardware - O2 sensors | 301 clrf DM_flags_sensor ; hardware - O2 sensors |
| 290 | 302 |
| 291 clrf OS_flags_ISR1 ; operating system - ISR control 1 | 303 clrf OS_flags_ISR1 ; operating system - ISR control 1 |
| 292 clrf OS_flags_ISR2 ; operating system - ISR control 2 | 304 clrf OS_flags_ISR2 ; operating system - ISR control 2 |
| 293 | 305 |
| 329 bsf ANCON0,7 ; AN7 analog again | 341 bsf ANCON0,7 ; AN7 analog again |
| 330 banksel common ; back to bank common | 342 banksel common ; back to bank common |
| 331 bsf lightsen_power ; power-up ambient light sensor again | 343 bsf lightsen_power ; power-up ambient light sensor again |
| 332 | 344 |
| 333 restart2: | 345 restart2: |
| 346 IFNDEF _hwos_sport | |
| 334 btfsc vusb_in ; USB power detected? | 347 btfsc vusb_in ; USB power detected? |
| 335 bra restart3 ; YES | 348 bra restart3 ; YES |
| 336 bcf PORTE,0 ; start comm | 349 bcf PORTE,0 ; start comm |
| 337 WAITMS d'5' ; wait 5 ms | 350 WAITMS d'5' ; wait 5 ms |
| 338 btfss vusb_in ; USB power detected? | 351 btfss vusb_in ; USB power detected? |
| 339 bra restart3 ; NO | 352 bra restart3 ; NO |
| 353 ENDIF | |
| 340 bsf ble_available ; YES - BLE available | 354 bsf ble_available ; YES - BLE available |
| 341 | 355 |
| 342 restart3: | 356 restart3: |
| 343 bsf PORTE,0 ; stop comm | 357 bsf PORTE,0 ; stop comm |
| 344 btfsc ble_available ; BLE available? | 358 btfsc ble_available ; BLE available? |
| 377 WAITMS .200 ; wait 200 ms while RX module boots up | 391 WAITMS .200 ; wait 200 ms while RX module boots up |
| 378 call I2C_probe_OSTC_rx ; check for RX module and set ostc_rx_present flag if found | 392 call I2C_probe_OSTC_rx ; check for RX module and set ostc_rx_present flag if found |
| 379 btfss ostc_rx_present ; RX module detected? | 393 btfss ostc_rx_present ; RX module detected? |
| 380 bra restart5 ; NO | 394 bra restart5 ; NO |
| 381 | 395 |
| 396 IFDEF _rx_update | |
| 397 | |
| 382 ; check if TR module firmware is up to date | 398 ; check if TR module firmware is up to date |
| 383 movff rx_firmware_cur_major,hi ; copy current firmware on RX module to bank common, major | 399 movff rx_firmware_cur_major,hi ; copy current firmware on RX module to bank common, major |
| 384 movff rx_firmware_cur_minor,lo ; copy current firmware on RX module to bank common, minor | 400 movff rx_firmware_cur_minor,lo ; copy current firmware on RX module to bank common, minor |
| 385 call rx_firmware_new_major ; get latest firmware version into WREG, major | 401 call rx_firmware_new_major ; get latest firmware version into WREG, major |
| 386 cpfseq hi ; equal to current firmware on RX module, major ? | 402 cpfseq hi ; equal to current firmware on RX module, major ? |
| 401 call TFT_Display_FadeIn ; display screen | 417 call TFT_Display_FadeIn ; display screen |
| 402 WIN_SMALL .10,.160 | 418 WIN_SMALL .10,.160 |
| 403 STRCAT "TR Update " ; prepare result message | 419 STRCAT "TR Update " ; prepare result message |
| 404 | 420 |
| 405 ; update firmware in RX module | 421 ; update firmware in RX module |
| 406 call I2C_sleep_accelerometer ; stop accelerometer | |
| 407 call I2C_sleep_compass ; stop compass | 422 call I2C_sleep_compass ; stop compass |
| 408 call update_tr_module ; update TR module | 423 call update_tr_module ; update TR module |
| 409 | 424 |
| 410 WIN_SMALL .10,.160 ; set next output position | 425 WIN_SMALL .10,.160 ; set next output position |
| 411 STRCAT "Update " ; common part of result message | 426 STRCAT "Update " ; common part of result message |
| 422 restart4d: | 437 restart4d: |
| 423 call wait_1s ; wait (up to) 1 second | 438 call wait_1s ; wait (up to) 1 second |
| 424 call wait_1s ; wait (another full) 1 second | 439 call wait_1s ; wait (another full) 1 second |
| 425 call wait_1s ; wait (another full) 1 second | 440 call wait_1s ; wait (another full) 1 second |
| 426 | 441 |
| 442 ENDIF ; _rx_update | |
| 443 | |
| 427 restart4e: | 444 restart4e: |
| 428 btfss ostc_rx_present ; TR module up & running? | 445 btfss ostc_rx_present ; TR module up & running? |
| 429 bra restart5 ; NO | 446 bra restart5 ; NO |
| 430 movff opt_TR_mode,WREG ; YES - get TR mode | 447 movff opt_TR_mode,WREG ; YES - get TR mode |
| 431 tstfsz WREG ; - TR mode <> off ? | 448 tstfsz WREG ; - TR mode <> off ? |
| 488 restart_set_modes_and_flags: | 505 restart_set_modes_and_flags: |
| 489 call option_restore_all ; restore all options settings from EEPROM | 506 call option_restore_all ; restore all options settings from EEPROM |
| 490 | 507 |
| 491 IFDEF _external_sensor | 508 IFDEF _external_sensor |
| 492 call disable_ir_s8 ; switch off IR/S8 digital interface by default | 509 call disable_ir_s8 ; switch off IR/S8 digital interface by default |
| 493 ENDIF | 510 WAITMS d'100' ; Some delay to power down S8-HUD properly |
| 494 | 511 ENDIF |
| 495 ; setup sampling rate | 512 ; setup sampling rate |
| 496 movlw .2 ; default to 2 seconds | 513 movlw .2 ; default to 2 seconds |
| 497 movwf sampling_rate ; write setting | 514 movwf sampling_rate ; write setting |
| 498 TSTOSS opt_sampling_rate ; check option: 1= 10s, 0= 2s | 515 TSTOSS opt_sampling_rate ; check option: 1= 10s, 0= 2s |
| 499 bra restart_set_modes_and_flags1 ; 0 - 2 seconds selected, done | 516 bra restart_set_modes_and_flags1 ; 0 - 2 seconds selected, done |
