comparison src/hwos.inc @ 646:5b7fe7777425

3.16 release
author heinrichs weikamp
date Thu, 14 Oct 2021 12:03:24 +0200
parents 8c1f1f334275
children 357341239438
comparison
equal deleted inserted replaced
642:a9a0188091e4 646:5b7fe7777425
10 ; 2011-05-24 : [jDG] Cleanups from initial Matthias code 10 ; 2011-05-24 : [jDG] Cleanups from initial Matthias code
11 ;============================================================================= 11 ;=============================================================================
12 12
13 13
14 ; ---- Hardware Configuration 14 ; ---- Hardware Configuration
15 LIST P=18F87K22 ; compiler settings, if changed change also: Configure -> SelectDevice in MPLAB 15 LIST P=18F87K22 ; compiler settings, if changed change also: Configure -> SelectDevice in MPLAB
16 #include "p18f87k22.inc" ; processor definitions 16 #include "p18f87k22.inc" ; processor definitions
17 #include "ports.inc" ; port map definitions 17 #include "ports.inc" ; port map definitions
18 18
19 19
20 ; ---- Software Configuration 20 ; ---- Software Configuration
68 68
69 #DEFINE speed_is_eco cpu_speed_state,0 ; =1: CPU is running at eco speed 69 #DEFINE speed_is_eco cpu_speed_state,0 ; =1: CPU is running at eco speed
70 #DEFINE speed_is_normal cpu_speed_state,1 ; =1: CPU is running at normal speed 70 #DEFINE speed_is_normal cpu_speed_state,1 ; =1: CPU is running at normal speed
71 #DEFINE speed_is_fastest cpu_speed_state,2 ; =1: CPU is running at fastest speed 71 #DEFINE speed_is_fastest cpu_speed_state,2 ; =1: CPU is running at fastest speed
72 72
73 ; ---- I2C speed
74 #DEFINE i2c_speed_value 0x27 ;0x9C = 100kHz @ 64MHz Fosc, 0x27 = 100kHz @ 16MHz Fosc
73 75
74 ; ---- Divemode Custom View Indexes - Attention: these numbers need to be in line with the jump tables in customview.asm! 76 ; ---- Divemode Custom View Indexes - Attention: these numbers need to be in line with the jump tables in customview.asm!
75 #DEFINE index_blank .0 ; blank view 77 #DEFINE index_blank .0 ; blank view
76 #DEFINE index_avr_stopwatch .1 ; average depth and stopwatch 78 #DEFINE index_avr_stopwatch .1 ; average depth and stopwatch
77 #DEFINE index_compass_dm .2 ; compass 79 #DEFINE index_compass_dm .2 ; compass
442 ;----------------------------------------------------------------------------- 444 ;-----------------------------------------------------------------------------
443 445
444 #DEFINE timebase_0sec timebase,0 ; counting timebase, 1/2 sec bit 446 #DEFINE timebase_0sec timebase,0 ; counting timebase, 1/2 sec bit
445 #DEFINE timebase_1sec timebase,1 ; counting timebase, 1 sec bit 447 #DEFINE timebase_1sec timebase,1 ; counting timebase, 1 sec bit
446 #DEFINE timebase_2sec timebase,2 ; counting timebase, 2 sec bit 448 #DEFINE timebase_2sec timebase,2 ; counting timebase, 2 sec bit
447 #DEFINE trigger_quarter_second timebase,3 ; =1: a new 1/4 second has begun (not synced with the other time flags, not generated while block_sensor_interrupt is set) 449 #DEFINE trigger_quarter_second timebase,3 ; =1: a new 1/4 second has begun (not synced with the other time flags)
448 #DEFINE trigger_half_second timebase,4 ; =1: a new 1/2 second has begun 450 #DEFINE trigger_half_second timebase,4 ; =1: a new 1/2 second has begun
449 #DEFINE trigger_full_second timebase,5 ; =1: a new 1/1 second has begun 451 #DEFINE trigger_full_second timebase,5 ; =1: a new 1/1 second has begun
450 #DEFINE trigger_full_minute timebase,6 ; =1: a new minute has begun 452 #DEFINE trigger_full_minute timebase,6 ; =1: a new minute has begun
451 #DEFINE trigger_full_hour timebase,7 ; =1: a new hour has begun 453 #DEFINE trigger_full_hour timebase,7 ; =1: a new hour has begun
452 454
482 #DEFINE compass_type2 HW_variants,4 ; =1: compass type 2, =0: compass type 0 or 1 484 #DEFINE compass_type2 HW_variants,4 ; =1: compass type 2, =0: compass type 0 or 1
483 #DEFINE compass_type3 HW_variants,5 ; =1: compass type 3, =0: compass type 0 or 1 or 2 485 #DEFINE compass_type3 HW_variants,5 ; =1: compass type 3, =0: compass type 0 or 1 or 2
484 #DEFINE analog_switches HW_variants,6 ; =1: analog switches available 486 #DEFINE analog_switches HW_variants,6 ; =1: analog switches available
485 #DEFINE battery_is_36v HW_variants,7 ; =1: a 3.6 Volt battery is detected 487 #DEFINE battery_is_36v HW_variants,7 ; =1: a 3.6 Volt battery is detected
486 488
489 ;---- Hardware - OSTC Model Variants2 (stored in access RAM, NOT cleared in restart)
490 #DEFINE press_sensor_type HW_variants2,0 ; =1: pressure sensor MS5837, =0: Pressure sensor MS5541
491 ; HW_variants2,1 ; --- unused
492 ; HW_variants2,2 ; --- unused
493 ; HW_variants2,3 ; --- unused
494 ; HW_variants2,4 ; --- unused
495 ; HW_variants2,5 ; --- unused
496 ; HW_variants2,6 ; --- unused
497 ; HW_variants2,7 ; --- unused
487 498
488 ;---- Hardware - States 1 (stored in access RAM, cleared on restart) 499 ;---- Hardware - States 1 (stored in access RAM, cleared on restart)
489 #DEFINE analog_sw1_pressed HW_flags_state1,0 ; =1: analog switch 1 pressed 500 #DEFINE analog_sw1_pressed HW_flags_state1,0 ; =1: analog switch 1 pressed
490 #DEFINE analog_sw2_pressed HW_flags_state1,1 ; =1: analog switch 2 pressed 501 #DEFINE analog_sw2_pressed HW_flags_state1,1 ; =1: analog switch 2 pressed
491 #DEFINE switch_left HW_flags_state1,2 ; =1: left button was pressed 502 #DEFINE switch_left HW_flags_state1,2 ; =1: left button was pressed
501 #DEFINE i2c_error_flag HW_flags_state2,2 ; =1: an I2C error occurred 512 #DEFINE i2c_error_flag HW_flags_state2,2 ; =1: an I2C error occurred
502 #DEFINE rs232_rx_timeout HW_flags_state2,3 ; =1: RS232 receive timeout occurred 513 #DEFINE rs232_rx_timeout HW_flags_state2,3 ; =1: RS232 receive timeout occurred
503 #DEFINE battery_low_condition HW_flags_state2,4 ; =1: low battery condition detected 514 #DEFINE battery_low_condition HW_flags_state2,4 ; =1: low battery condition detected
504 #DEFINE flash_wrap_around HW_flags_state2,5 ; =1: address wrap-around control / signalling 515 #DEFINE flash_wrap_around HW_flags_state2,5 ; =1: address wrap-around control / signalling
505 #DEFINE flash_wait HW_flags_state2,6 ; =1: wait for flash write operation to complete 516 #DEFINE flash_wait HW_flags_state2,6 ; =1: wait for flash write operation to complete
506 ; HW_flags_state2,7 ; --- unused 517 #DEFINE i2c_busy_temperature HW_flags_state2,7 ; =1: Currently updating temperature from MS5837
507 518
508 519 ;---- Hardware - States 3 (stored in access RAM, NOT cleared on restart)
520 #DEFINE ms5837_state HW_flags_state3,0 ; =1: result of pressure is in the ADC
521 #DEFINE i2c_busy_pressure HW_flags_state3,1 ; =1: Currently updating pressure from MS5837
522 ; HW_flags_state3,2 ; --- unused
523 ; HW_flags_state3,3 ; --- unused
524 ; HW_flags_state3,4 ; --- unused
525 ; HW_flags_state3,5 ; --- unused
526 ; HW_flags_state3,6 ; --- unused
527 ; HW_flags_state3,7 ; --- unused
528
509 ;---- Operating System - persistent Settings (stored in access RAM, NOT cleared in restart) 529 ;---- Operating System - persistent Settings (stored in access RAM, NOT cleared in restart)
510 #DEFINE sensor1_calibrated_ok OS_flags_persist,0 ; =1: sensor 1 calibration ok 530 #DEFINE sensor1_calibrated_ok OS_flags_persist,0 ; =1: sensor 1 calibration ok
511 #DEFINE sensor2_calibrated_ok OS_flags_persist,1 ; =1: sensor 2 calibration ok 531 #DEFINE sensor2_calibrated_ok OS_flags_persist,1 ; =1: sensor 2 calibration ok
512 #DEFINE sensor3_calibrated_ok OS_flags_persist,2 ; =1: sensor 3 calibration ok 532 #DEFINE sensor3_calibrated_ok OS_flags_persist,2 ; =1: sensor 3 calibration ok
513 #DEFINE compass_bearing_set OS_flags_persist,3 ; =1: compass bearing is set 533 #DEFINE compass_bearing_set OS_flags_persist,3 ; =1: compass bearing is set
838 858
839 ; ---- options checking 859 ; ---- options checking
840 860
841 TSTOSS macro opt_reg ; TeST Option Skip next instruction if Set (not zero) 861 TSTOSS macro opt_reg ; TeST Option Skip next instruction if Set (not zero)
842 movff opt_reg,EEDATA ; Attention: destroys EEDATA! 862 movff opt_reg,EEDATA ; Attention: destroys EEDATA!
843 tstfsz EEDATA,A ; Attention: must be followed by a plain machine 863 tstfsz EEDATA ; Attention: must be followed by a plain machine
844 bra $+4 ; command, do not let follow a macro! 864 bra $+4 ; command, do not let follow a macro!
845 endm ; 865 endm ;
846 866
847 TSTOSC macro opt_reg ; TeST Option Skip next instruction if Clear (zero) 867 TSTOSC macro opt_reg ; TeST Option Skip next instruction if Clear (zero)
848 movff opt_reg,EEDATA ; Attention: destroys EEDATA! 868 movff opt_reg,EEDATA ; Attention: destroys EEDATA!
849 tstfsz EEDATA,A ; Attention: must be followed by a plain machine 869 tstfsz EEDATA ; Attention: must be followed by a plain machine
850 endm ; command, do not let follow a macro! 870 endm ; command, do not let follow a macro!
851 871
852 872
853 ; ---- literal operations 873 ; ---- literal operations
854 874
1011 1031
1012 ifndef INSIDE_HWOS_ASM 1032 ifndef INSIDE_HWOS_ASM
1013 1033
1014 extern HW_descriptor 1034 extern HW_descriptor
1015 extern HW_variants 1035 extern HW_variants
1036 extern HW_variants2
1016 1037
1017 extern HW_flags_state1 1038 extern HW_flags_state1
1018 extern HW_flags_state2 1039 extern HW_flags_state2
1040 extern HW_flags_state3
1019 1041
1020 extern OS_flags_persist 1042 extern OS_flags_persist
1021 extern OS_flags_ISR1 1043 extern OS_flags_ISR1
1022 extern OS_flags_ISR2 1044 extern OS_flags_ISR2
1023 1045
1114 sensor_state_counter res 1 ; counter for pressure sensor state machine 1136 sensor_state_counter res 1 ; counter for pressure sensor state machine
1115 dLSB res 1 ; pressure sensor interface, LSB 1137 dLSB res 1 ; pressure sensor interface, LSB
1116 dMSB res 1 ; pressure sensor interface, MSB 1138 dMSB res 1 ; pressure sensor interface, MSB
1117 dbuffer res 1 ; pressure sensor interface, RX/TX buffer 1139 dbuffer res 1 ; pressure sensor interface, RX/TX buffer
1118 1140
1119 C1 res 2 ; decoded calibration data 1141 C1 res 2 ; decoded calibration data
1120 C2 res 2 ; decoded calibration data 1142 C2 res 2 ; decoded calibration data
1121 C3 res 2 ; decoded calibration data 1143 C3 res 2 ; decoded calibration data
1122 C4 res 2 ; decoded calibration data, here C4-250 1144 C4 res 2 ; decoded calibration data, here C4-250
1123 C5 res 2 ; decoded calibration data, here reference temperature UT1 = 8*C5 + 10000 (u16 range 10.000 .. +42.760) 1145 C5 res 2 ; decoded calibration data, here reference temperature UT1 = 8*C5 + 10000 (u16 range 10.000 .. +42.760)
1124 C6 res 2 ; decoded calibration data 1146 C6 res 2 ; decoded calibration data
1125 D1 res 2 ; raw pressure 1147 D1 res 3 ; raw pressure
1126 D2 res 2 ; raw temperature 1148 D2 res 3 ; raw temperature
1127 xdT res 2 1149 xdT res 3
1128 xdT2 res 2 1150 xdT2 res 2
1129 OFF res 2 1151 OFF res 4
1130 SENS res 2 1152 SENS res 4
1131 1153
1132 temperature_cur res 2 ; current temperature 1154 temperature_cur res 2 ; current temperature
1133 temperature_min res 2 ; minimum temperature (operated by divemode.asm) 1155 temperature_min res 2 ; minimum temperature (operated by divemode.asm)
1134 temperature_avg res 2 ; internal register used for averaging 1156 temperature_avg res 2 ; internal register used for averaging
1135 temperature_last res 2 ; internal register used for detecting changes 1157 temperature_last res 2 ; internal register used for detecting changes
1136 1158
1137 pressure_abs res 2 ; current absolute pressure 1159 pressure_abs res 2 ; current absolute pressure
1138 pressure_abs_avg res 2 ; internal register used for averaging 1160 pressure_abs_avg res 3 ; internal register used for averaging
1139 pressure_abs_last res 2 ; internal register used for detecting pressure changes 1161 pressure_abs_last res 2 ; internal register used for detecting pressure changes
1140 1162
1141 pressure_abs_sampled res 2 ; sampled surface pressure, sampled in sleep mode every 15 minutes 1163 pressure_abs_sampled res 2 ; sampled surface pressure, sampled in sleep mode every 15 minutes
1142 pressure_abs_ref res 2 ; reference surface pressure, surface pressure sampled 15 minutes ago 1164 pressure_abs_ref res 2 ; reference surface pressure, surface pressure sampled 15 minutes ago
1143 pressure_surf res 2 ; surface pressure used by ISR to calculate relative pressures 1165 pressure_surf res 2 ; surface pressure used by ISR to calculate relative pressures
1145 pressure_rel_cur res 2 ; current relative pressure 1167 pressure_rel_cur res 2 ; current relative pressure
1146 pressure_rel_max res 2 ; maximum relative pressure 1168 pressure_rel_max res 2 ; maximum relative pressure
1147 pressure_rel_sim res 2 ; simulated relative pressure (simulator mode) 1169 pressure_rel_sim res 2 ; simulated relative pressure (simulator mode)
1148 1170
1149 ;---- Data for ISR Math Subroutines 1171 ;---- Data for ISR Math Subroutines
1150 isr_xA res 2 ; multiplicand 1 1172 isr_xA res 4 ; multiplicand 1
1151 isr_xB res 2 ; multiplicand 2 1173 isr_xB res 3 ; multiplicand 2
1152 isr_xC res 4 ; resulting product 1174 isr_xC res 7 ; resulting product
1175 isr_math_loop res 1 ; loop counter
1153 1176
1154 ;---- Display Brightness 1177 ;---- Display Brightness
1155 ambient_light res 2 ; ambient light level 1178 ambient_light res 2 ; ambient light level
1156 max_CCPR1L res 1 ; max. brightness value for CCPR1L 1179 max_CCPR1L res 1 ; max. brightness value for CCPR1L
1157 1180
1188 pressure_rel_min_trip res 2 ; resettable minimum relative pressure 1211 pressure_rel_min_trip res 2 ; resettable minimum relative pressure
1189 pressure_rel_max_trip res 2 ; resettable maximum relative pressure 1212 pressure_rel_max_trip res 2 ; resettable maximum relative pressure
1190 ENDIF 1213 ENDIF
1191 1214
1192 debounce_counter res 1 ; multiples of 16ms 1215 debounce_counter res 1 ; multiples of 16ms
1193 1216 isr_tmr7_helper res 1 ; used for 1/4 second trigger
1194 ; 144 byte used, 16 byte free 1217
1218 ; 158 byte used, 2 byte free
1195 1219
1196 1220
1197 ;----------------------------------------------------------------------------- 1221 ;-----------------------------------------------------------------------------
1198 ; Common DATA 1222 ; Common DATA
1199 ;----------------------------------------------------------------------------- 1223 ;-----------------------------------------------------------------------------
1294 dive_timeout_timer res 2 ; timeout timer for leaving dive mode after surfacing 1318 dive_timeout_timer res 2 ; timeout timer for leaving dive mode after surfacing
1295 gaslist_gas res 1 ; used for transfer between gaslist.asm and menu_tree.asm 1319 gaslist_gas res 1 ; used for transfer between gaslist.asm and menu_tree.asm
1296 best_gas_number res 1 ; number of the "best gas": 0= none found, 1-5= gases 1-5, 255= not computed 1320 best_gas_number res 1 ; number of the "best gas": 0= none found, 1-5= gases 1-5, 255= not computed
1297 active_gas res 1 ; the currently used OC/bailout gas (1-5) 1321 active_gas res 1 ; the currently used OC/bailout gas (1-5)
1298 dive_ccr_mode res 1 ; working copy of opt_ccr_mode while the dive 1322 dive_ccr_mode res 1 ; working copy of opt_ccr_mode while the dive
1299 1323 dive_threshold_debounce res 1 ; Countdown for entering dive mode
1324
1300 IFDEF _ccr_pscr 1325 IFDEF _ccr_pscr
1301 best_dil_number res 1 ; number of the "best dil": 0= none found, 1-5= dils 1-5, 255= not computed 1326 best_dil_number res 1 ; number of the "best dil": 0= none found, 1-5= dils 1-5, 255= not computed
1302 active_dil res 1 ; the currently used diluent (1-5) 1327 active_dil res 1 ; the currently used diluent (1-5)
1303 ENDIF 1328 ENDIF
1304 1329
1565 pres_last_2nd res 2 ; last pressure reading pressure in 1/160 bar | other! 1590 pres_last_2nd res 2 ; last pressure reading pressure in 1/160 bar | other!
1566 time_last_1st res 2 ; last pressure reading time in seconds | 1591 time_last_1st res 2 ; last pressure reading time in seconds |
1567 time_last_2nd res 2 ; last pressure reading time in seconds | 1592 time_last_2nd res 2 ; last pressure reading time in seconds |
1568 ENDIF 1593 ENDIF
1569 1594
1570 ; 156 byte used, 100 byte free 1595 i2c_error_vault res 2 ; Store last used device ID and data byte
1596 D1_buffer res 3 ; Buffer of D1 (Sensor raw data)
1597 D2_buffer res 3 ; Buffer of D2 (Sensor raw data)
1598
1599 brightness res 1 ; =0: Eco, =1:Medium, =2:Full
1600 ; 157 byte used, 92 byte free
1571 1601
1572 1602
1573 ;----------------------------------------------------------------------------- 1603 ;-----------------------------------------------------------------------------
1574 ; Bank 2 General Purpose Buffer 1 1604 ; Bank 2 General Purpose Buffer 1
1575 ;----------------------------------------------------------------------------- 1605 ;-----------------------------------------------------------------------------
1631 ;---- various other Settings 1661 ;---- various other Settings
1632 opt_fw_version_major res 1 ; firmware version, major | use read-only! 1662 opt_fw_version_major res 1 ; firmware version, major | use read-only!
1633 opt_fw_version_minor res 1 ; firmware version, minor | 1663 opt_fw_version_minor res 1 ; firmware version, minor |
1634 opt_fw_version_beta res 1 ; firmware version, beta | 1664 opt_fw_version_beta res 1 ; firmware version, beta |
1635 opt_surface_interval res 1 ; surface interval, used by deco calculator 1665 opt_surface_interval res 1 ; surface interval, used by deco calculator
1636 opt_brightness res 1 ; =0: Eco, =1:Medium, =2:Full 1666 opt_brightness_divemode res 1 ; =0: Eco, =1:Medium, =2:Full
1667 opt_brightness_surface res 1 ; =0: Eco, =1:Medium, =2:Full
1637 opt_salinity res 1 ; 0-5% 1668 opt_salinity res 1 ; 0-5%
1638 opt_language res 1 ; current language: 0=EN, 1=DE, 2=FR, 3=SP 1669 opt_language res 1 ; current language: 0=EN, 1=DE, 2=FR, 3=SP
1639 opt_units res 1 ; 0:m/°C, 1:ft/°F 1670 opt_units res 1 ; 0:m/°C, 1:ft/°F
1640 opt_dateformat res 1 ; =0:MMDDYY, =1:DDMMYY, =2:YYMMDD 1671 opt_dateformat res 1 ; =0:MMDDYY, =1:DDMMYY, =2:YYMMDD
1641 opt_dive_color_scheme res 1 ; dive mode color scheme selection 1672 opt_dive_color_scheme res 1 ; dive mode color scheme selection