comparison src/start.asm @ 643:7d8a4c60ec1a

3.15 release
author heinrichsweikamp
date Mon, 24 May 2021 18:40:53 +0200
parents 8c1f1f334275
children aeca5717d9eb
comparison
equal deleted inserted replaced
642:a9a0188091e4 643:7d8a4c60ec1a
112 112
113 ; initialize averaging for analog buttons before IRQ gets enabled 113 ; initialize averaging for analog buttons before IRQ gets enabled
114 movlw .16 ; set averaging span 114 movlw .16 ; set averaging span
115 movff WREG,analog_counter ; write to counter (in bank isr_backup) 115 movff WREG,analog_counter ; write to counter (in bank isr_backup)
116 116
117 ; initialize 1/4 second counting register
118 movlw .4 ; 62,5ms * 4 = 1/4 second
119 movff WREG,isr_tmr7_helper
120
117 ; initialize hardware (ports, timers) and start interrupts 121 ; initialize hardware (ports, timers) and start interrupts
118 call init_ostc ; also selects bank common and sets CPU to normal speed 122 call init_ostc ; also selects bank common and sets CPU to normal speed
119 123
120 ; flag that later restart origins from a cold start 124 ; flag that later restart origins from a cold start
121 bsf cold_start 125 bsf cold_start
152 156
153 ; get button polarity from configuration data (EEPROM) 157 ; get button polarity from configuration data (EEPROM)
154 EEPROM_CC_READ eeprom_button_polarity,button_polarity 158 EEPROM_CC_READ eeprom_button_polarity,button_polarity
155 159
156 ; initialize pressure sensor calibration 160 ; initialize pressure sensor calibration
161 call I2C_probe_pressure_sensor ; Probe the type of sensor, set/clear press_sensor_type
157 call get_calibration_data ; get calibration data from pressure sensor 162 call get_calibration_data ; get calibration data from pressure sensor
158 163
159 call TFT_DisplayOff ; turn off display 164 call TFT_DisplayOff ; turn off display
160 bsf LEDr ; turn on red LED 165 bsf LEDr ; turn on red LED
161 166
162 ; wait for valid temperature and pressure 167 ; wait for valid temperature and pressure
163 WAITS .3 ; wait 3 seconds 168 btfsc press_sensor_type ; New sensor found?
169 call I2C_get_temp_val_MS5837 ; (Will set ms5837_state)
170 WAITMS .250
171 btfsc press_sensor_type ; New sensor found?
172 call I2C_get_press_val_MS5837 ; (Will clear ms5837_state)
173 WAITMS .250
174 btfsc press_sensor_type ; New sensor found?
175 call I2C_get_temp_val_MS5837 ; (Will set ms5837_state)
176 WAITMS .250
177 btfsc press_sensor_type ; New sensor found?
178 call I2C_get_press_val_MS5837 ; (Will clear ms5837_state)
179 WAITMS .250
164 180
165 ; sensor calibration completed, first valid pressure value is available 181 ; sensor calibration completed, first valid pressure value is available
166 bcf LEDr ; turn off red LED 182 bcf LEDr ; turn off red LED
167 183
168 ; initial loading of the surface pressure into the ISR 184 ; initial loading of the surface pressure into the ISR
323 339
324 ; clear flag groups 340 ; clear flag groups
325 clrf HW_descriptor ; hardware - OSTC model descriptor 341 clrf HW_descriptor ; hardware - OSTC model descriptor
326 clrf HW_flags_state1 ; hardware - states 342 clrf HW_flags_state1 ; hardware - states
327 ; ; DO NOT clear HW_flags_state2 ! 343 ; ; DO NOT clear HW_flags_state2 !
344 ; ; DO NOT clear HW_flags_state3 !
328 clrf DM_flags_sensor ; hardware - O2 sensors 345 clrf DM_flags_sensor ; hardware - O2 sensors
329 clrf OS_flags_ISR1 ; operating system - ISR control 1 346 clrf OS_flags_ISR1 ; operating system - ISR control 1
330 clrf OS_flags_ISR2 ; operating system - ISR control 2 347 clrf OS_flags_ISR2 ; operating system - ISR control 2
331 clrf eventbase ; event triggers generated by ISR 348 clrf eventbase ; event triggers generated by ISR
332 clrf DM_flags_deco ; dive deco modes 349 clrf DM_flags_deco ; dive deco modes
382 399
383 restart4: 400 restart4:
384 ; Do the check for BLE-cR 401 ; Do the check for BLE-cR
385 IFDEF _external_sensor 402 IFDEF _external_sensor
386 bsf mcp_power ; power-up instrumentation amp (used by S8 and analog input) 403 bsf mcp_power ; power-up instrumentation amp (used by S8 and analog input)
404 btfss mcp_power ; power-up completed?
405 bra $-4 ; NO - loop
406 WAITMS .1
387 banksel BAUDCON2 ; select bank for IO register access 407 banksel BAUDCON2 ; select bank for IO register access
388 movlw b'00000000' ; speed generator configuration: BRG16=0, normal for S8 408 movlw b'00000000' ; speed generator configuration: BRG16=0, normal for S8
389 movwf BAUDCON2 ; ... 409 movwf BAUDCON2 ; ...
390 movlw b'00100000' ; TX configuration: BRGH=0, SYNC=0 410 movlw b'00100000' ; TX configuration: BRGH=0, SYNC=0
391 movwf TXSTA2 ; ... 411 movwf TXSTA2 ; ...
392 movlw .25 ; speed configuration: SPBRGH:SPBRG = .25 : 9615 BAUD @ 16 MHz 412 movlw .25 ; speed configuration: SPBRGH:SPBRG = .25 : 9615 BAUD @ 16 MHz
393 movwf SPBRG2 ; ... 413 movwf SPBRG2 ; ...
394 movlw b'10010000' ; RX configuration 414 movlw b'10010000' ; RX configuration
395 movwf RCSTA2 ; ... 415 movwf RCSTA2 ; ...
396 banksel common ; back to bank common 416 banksel common ; back to bank common
397 call get_analog_inputs 417 WAITMS .1
398 movff sensor1_mv+1,lo 418 ; Check sensor 1 input with no limits
399 movlw .58 ; ~ >1,500V 419 movlw b'00000000' ; AVDD Vref+
400 cpfslt lo ; >58 on the high byte -> confident that there is cR circuity 420 movwf ADCON1 ; ...
421 ; set to read Sensor 1
422 extern wait_adc
423 movlw b'00100001' ; power on ADC, select AN8
424 call wait_adc ; wait for ADC
425 movlw .10 ; ~ >1,900V
426 cpfslt ADRESH ; >10 on the high byte -> confident that there is cR circuity
401 bsf ext_input_s8_ana ; YES - it's a cR, S8/analog sensor input available 427 bsf ext_input_s8_ana ; YES - it's a cR, S8/analog sensor input available
402 call disable_ir_s8_analog ; power-down circuity again 428 call disable_ir_s8_analog ; power-down circuity again
403 ENDIF 429 ENDIF
430
431
404 bsf lv_core ; default to low voltage core 432 bsf lv_core ; default to low voltage core
405 movlw 0x80 ; point to 0x1F780 433 movlw 0x80 ; point to 0x1F780
406 movwf TBLPTRL ; ... 434 movwf TBLPTRL ; ...
407 movlw 0xF7 ; ... 435 movlw 0xF7 ; ...
408 movwf TBLPTRH ; ... 436 movwf TBLPTRH ; ...
500 528
501 529
502 restart5: 530 restart5:
503 ; configure button_hold_down_allowed flag 531 ; configure button_hold_down_allowed flag
504 btfsc lv_core 532 btfsc lv_core
505 bsf button_hold_down_allowed,A ; OSTC sport mod. 2019 533 bsf button_hold_down_allowed ; OSTC sport mod. 2019
506 btfsc ext_input_optical 534 btfsc ext_input_optical
507 bsf button_hold_down_allowed,A ; OSTC3/old sport 535 bsf button_hold_down_allowed ; OSTC3/old sport
508 536
509 ; manage hardware 537 ; manage hardware
510 btfss ext_input_s8_ana ; OSTC with S8/analog input? 538 btfss ext_input_s8_ana ; OSTC with S8/analog input?
511 bsf TRISB,3 ; NO - shut down power supply for S8 bulkhead 539 bsf TRISB,3 ; NO - shut down power supply for S8 bulkhead
512 540