annotate src/eeprom_rs232.asm @ 628:cd58f7fc86db

3.05 stable work
author heinrichsweikamp
date Thu, 19 Sep 2019 12:01:29 +0200
parents c40025d8e750
children 237931377539
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
heinrichsweikamp
parents:
diff changeset
1 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
2 ;
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
3 ; File eeprom_rs232.asm combined next generation V3.04.3
0
heinrichsweikamp
parents:
diff changeset
4 ;
heinrichsweikamp
parents:
diff changeset
5 ; Internal EEPROM, RS232
heinrichsweikamp
parents:
diff changeset
6 ;
heinrichsweikamp
parents:
diff changeset
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
heinrichsweikamp
parents:
diff changeset
8 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
9 ; HISTORY
heinrichsweikamp
parents:
diff changeset
10 ; 2011-08-06 : [mH] moving from OSTC code
heinrichsweikamp
parents:
diff changeset
11
275
653a3ab08062 rename into hwOS
heinrichsweikamp
parents: 236
diff changeset
12 #include "hwos.inc"
0
heinrichsweikamp
parents:
diff changeset
13 #include "wait.inc"
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
14 #include "shared_definitions.h"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
15 #include "rtc.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
16
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
17 extern lt2942_charge_done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
18
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
19 ;-----------------------------------------------------------------------------
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
20 ; Macros
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
21
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
22 write_int_eeprom macro eeprom_address
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
23 movlw eeprom_address
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
24 call write_int_eeprom_1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
25 endm
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
26
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
27 read_int_eeprom macro eeprom_address
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
28 movlw eeprom_address
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
29 call read_int_eeprom_1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
30 endm
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
31
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
32 ;-----------------------------------------------------------------------------
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
33 ; Reserved memory locations in EEPROM
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
34
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
35 eeprom code 0xF00000+0x10 ; skip SERIAL number - it should not be overwritten
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
36
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
37 global eeprom_serial_save
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
38 global eeprom_opt_backup
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
39
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
40 eeprom_serial_save res 2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
41 eeprom_opt_backup res 0x3E
0
heinrichsweikamp
parents:
diff changeset
42
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
43 ;-----------------------------------------------------------------------------
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
44
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
45 ee_rs232 CODE
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
46
0
heinrichsweikamp
parents:
diff changeset
47 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
48
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
49 global write_int_eeprom_1
0
heinrichsweikamp
parents:
diff changeset
50 write_int_eeprom_1:
heinrichsweikamp
parents:
diff changeset
51 movwf EEADR
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
52 bra write_eeprom ; writes and "returns" after write
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
53
0
heinrichsweikamp
parents:
diff changeset
54
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
55 global read_int_eeprom_1
0
heinrichsweikamp
parents:
diff changeset
56 read_int_eeprom_1:
heinrichsweikamp
parents:
diff changeset
57 movwf EEADR
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
58 bra read_eeprom ; reads and "returns" after write
0
heinrichsweikamp
parents:
diff changeset
59
heinrichsweikamp
parents:
diff changeset
60 ;=============================================================================
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
61 ; read from internal EEPROM
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
62 ;
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
63 ; Input: EEADRH:EEADR = EEPROM address
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
64 ; Output: EEDATA
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
65 ; Trashed: NONE
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
66 ;
0
heinrichsweikamp
parents:
diff changeset
67 global read_eeprom
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
68 read_eeprom:
0
heinrichsweikamp
parents:
diff changeset
69 bcf EECON1,EEPGD
heinrichsweikamp
parents:
diff changeset
70 bcf EECON1,CFGS
heinrichsweikamp
parents:
diff changeset
71 bsf EECON1,RD
heinrichsweikamp
parents:
diff changeset
72 return
heinrichsweikamp
parents:
diff changeset
73
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
74 ;=============================================================================
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
75 ; write into internal EEPROM
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
76 ;
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
77 ; Input: EEADRH:EEADR = EEPROM address
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
78 ; EEDATA = byte to write
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
79 ; Trashed: WREG
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
80 ;
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
81 global write_eeprom
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
82 write_eeprom:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
83 bcf EECON1,EEPGD
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
84 bcf EECON1,CFGS
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
85 bsf EECON1,WREN
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
86
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
87 bcf INTCON,GIE ; disable interrupts for the next 5 instructions
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
88 movlw 0x55
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
89 movwf EECON2
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
90 movlw 0xAA
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
91 movwf EECON2
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
92 bsf EECON1,WR
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
93
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
94 write_eep2:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
95 btfsc EECON1,WR
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
96 bra write_eep2 ; wait about 4ms...
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
97 bcf EECON1,WREN
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
98 bsf INTCON,GIE ; ...but the flag for the ISR routines were still set, so they will interrupt now!
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
99 return
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
100
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
101 ;=============================================================================
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
102
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
103 IFDEF _external_sensor
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
104
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
105 global disable_ir_s8
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
106 disable_ir_s8:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
107 banksel TXSTA2 ; select bank for IO register access
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
108 clrf TXSTA2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
109 clrf RCSTA2
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
110 banksel common ; back to bank common
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
111 bcf ir_power ; IR off
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
112 bcf mcp_power ; power-down instrumentation amp
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
113 bsf s8_npower ; power-down S8 digital interface
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
114 bcf s8_digital_avail ; digital S8 interface not available
0
heinrichsweikamp
parents:
diff changeset
115 return
heinrichsweikamp
parents:
diff changeset
116
heinrichsweikamp
parents:
diff changeset
117
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
118 global enable_ir_s8
187
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 151
diff changeset
119 enable_ir_s8:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
120 ;initialize serial port2 (TRISG2)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
121 btfsc analog_o2_input ; do we have an analog input?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
122 bra enable_s8 ; YES - search for S8 digital input
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
123 ; NO - start IR digital input
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
124 banksel BAUDCON2 ; - select bank for IO register access
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
125 movlw b'00100000' ; - BRG16=0, inverted for IR
113
heinrichsweikamp
parents: 0
diff changeset
126 movwf BAUDCON2
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
127 movlw b'00100000' ; - BRGH=0, SYNC=0
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
128 movwf TXSTA2
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
129 movlw .102 ; - SPBRGH:SPBRG = .102 : 2403 BAUD @ 16 MHz
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
130 movwf SPBRG2
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
131 clrf SPBRGH2
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
132 movlw b'10010000'
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
133 movwf RCSTA2
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
134 banksel common ; - back to bank common
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
135 bsf ir_power ; - power-up IR
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
136 btfss ir_power
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
137 bra $-6
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
138 return
0
heinrichsweikamp
parents:
diff changeset
139
113
heinrichsweikamp
parents: 0
diff changeset
140 enable_s8:
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
141 banksel TXSTA2 ; select bank for IO register access
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
142 clrf TXSTA2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
143 clrf RCSTA2
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
144 banksel common ; back to bank common
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
145 ; Check for Digital/Analog
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
146 bsf s8_npower ; power-down S8 HUD
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
147 WAITMS d'2' ; very short delay
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
148 bsf mcp_power ; power-up instrumentation amp
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
149 btfss mcp_power
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
150 bra $-4
113
heinrichsweikamp
parents: 0
diff changeset
151
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
152 ; It may be digital, check for voltage when isolator is powered
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
153 bcf s8_npower ; power S8 HUD
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
154 WAITMS d'1' ; wait 1 ms
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
155 btfsc PORTG,2 ; RX2=1?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
156 bra enable_s8_2 ; YES - digital
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
157 WAITMS d'30' ; NO - wait 30 ms
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
158 btfsc PORTG,2 ; - RX2=1?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
159 bra enable_s8_2 ; YES - digital
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
160 ;bra enable_s8_analog ; NO - not found, set to analog (fail-safe)
113
heinrichsweikamp
parents: 0
diff changeset
161
heinrichsweikamp
parents: 0
diff changeset
162 enable_s8_analog:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
163 ; S8 analog interface
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
164 bsf s8_npower ; power-down S8 HUD
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
165 bcf s8_digital_avail ; digital S8 interface not available
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
166 return
113
heinrichsweikamp
parents: 0
diff changeset
167
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
168 enable_s8_2: ; configure S8 digital interface
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
169 banksel BAUDCON2 ; select bank for IO register access
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
170 movlw b'00000000' ; BRG16=0, normal for S8
113
heinrichsweikamp
parents: 0
diff changeset
171 movwf BAUDCON2
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
172 movlw b'00100000' ; BRGH=0, SYNC=0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
173 movwf TXSTA2
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
174 movlw .25 ; SPBRGH:SPBRG = .25 : 9615 BAUD @ 16 MHz
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
175 movwf SPBRG2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
176 movlw b'10010000'
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
177 movwf RCSTA2
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
178 banksel common ; back to bank common
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
179 bsf s8_digital_avail ; digital S8 interface available
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
180 return
113
heinrichsweikamp
parents: 0
diff changeset
181
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
182 ENDIF ; _external_sensor
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
183
0
heinrichsweikamp
parents:
diff changeset
184 ;=============================================================================
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
185
0
heinrichsweikamp
parents:
diff changeset
186 global enable_rs232
heinrichsweikamp
parents:
diff changeset
187 enable_rs232:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
188 call request_speed_normal ; request CPU speed change to normal speed
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
189 enable_rs232_1:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
190 btfss speed_is_normal ; speed = normal?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
191 bra enable_rs232_1 ; NO - wait for ISR to adjust speed
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
192 bcf PORTE,0 ; start comm
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
193 bsf PORTJ,2 ; /Reset (for very old OSTC sport)
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
194 ;initialize serial port1 (TRISC6/7)
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
195 movlw b'00100100' ; BRGH=1, SYNC=0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
196 movwf TXSTA1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
197 movlw b'10010000'
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
198 movwf RCSTA1
0
heinrichsweikamp
parents:
diff changeset
199 return
heinrichsweikamp
parents:
diff changeset
200
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
201
0
heinrichsweikamp
parents:
diff changeset
202 global disable_rs232
heinrichsweikamp
parents:
diff changeset
203 disable_rs232:
heinrichsweikamp
parents:
diff changeset
204 clrf RCSTA1
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
205 clrf TXSTA1 ; UART disable
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
206 bcf PORTC,6 ; TX hard to GND
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
207 bsf PORTE,0 ; stop comm
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
208 bcf PORTJ,2 ; /Reset (for very old OSTC sport)
0
heinrichsweikamp
parents:
diff changeset
209 return
heinrichsweikamp
parents:
diff changeset
210
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
211
0
heinrichsweikamp
parents:
diff changeset
212 global rs232_wait_tx
heinrichsweikamp
parents:
diff changeset
213 rs232_wait_tx:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
214 btfss TXSTA1,TRMT ; RS232 busy?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
215 bra rs232_wait_tx ; YES - wait...
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
216
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
217 btfss ble_available ; ble available?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
218 return ; NO - done
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
219
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
220 btfsc NRTS ; wait for Bluetooth module
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
221 bra rs232_wait_tx ; YES - wait...
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
222 return ; done
344
1e342e433839 CHANGE: GF and aGF high range increased to 45-110%
heinrichsweikamp
parents: 276
diff changeset
223
0
heinrichsweikamp
parents:
diff changeset
224
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
225 global rs232_wait_tx2
113
heinrichsweikamp
parents: 0
diff changeset
226 rs232_wait_tx2:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
227 banksel TXSTA2 ; select bank for IO register access
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
228 rs232_wait_tx2_loop:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
229 btfss TXSTA2,TRMT ; RS232 busy?
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
230 bra rs232_wait_tx2_loop ; YES - wait...
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
231 banksel common ; back to bank common
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
232 return ; done
113
heinrichsweikamp
parents: 0
diff changeset
233
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
234
0
heinrichsweikamp
parents:
diff changeset
235 global rs232_get_byte
heinrichsweikamp
parents:
diff changeset
236 rs232_get_byte:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
237 bcf rs232_rx_timeout ; clear timeout flag
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
238 ; set timeout timer to approx. 400 ms:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
239 clrf uart_timeout_timer+0 ; set low byte of timeout timer to 0
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
240 clrf uart_timeout_timer+1 ; set high byte of timeout timer to 0
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
241 ; set upper byte of timeout timer to 10 without using WREG:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
242 clrf uart_timeout_timer+2 ; first clear to 0, then...
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
243 bsf uart_timeout_timer+2,1 ; set bit 1 (value 2),
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
244 bsf uart_timeout_timer+2,3 ; and bit 3 (value 8).
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
245
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
246 rs232_get_byte_loop:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
247 btfsc PIR1,RCIF ; received a data byte?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
248 return ; YES - done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
249 decfsz uart_timeout_timer+0,F ; NO - decrement low byte of timer, became zero?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
250 bra rs232_get_byte_loop ; NO - loop
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
251 decfsz uart_timeout_timer+1,F ; YES - decrement high byte of timer, became zero?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
252 bra rs232_get_byte_loop ; NO - loop
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
253 decfsz uart_timeout_timer+2,F ; YES - decrement upper byte of timer, became zero?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
254 bra rs232_get_byte_loop ; NO - loop
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
255 bsf rs232_rx_timeout ; YES - set timeout flag
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
256 bcf RCSTA1,CREN ; - clear receiver status
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
257 bsf RCSTA1,CREN ; - ...
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
258 return ; - and return anyway
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
259
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
260 ;=============================================================================
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
261
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
262 global do_logoffset_common_write
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
263 do_logoffset_common_write:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
264 movff lo,EEDATA
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
265 write_int_eeprom 0x0D
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
266 movff hi,EEDATA
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
267 write_int_eeprom 0x0E
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
268 return
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
269
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
270 global do_logoffset_common_read
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
271 do_logoffset_common_read:
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
272 clrf EEADRH
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
273 read_int_eeprom 0x0D
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
274 movff EEDATA,lo
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
275 read_int_eeprom 0x0E
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
276 movff EEDATA,hi
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
277 return
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
278
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
279 ;=============================================================================
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
280
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
281 global update_battery_registers
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
282 update_battery_registers:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
283 ; save battery gauge to EEPROM 0x07-0x0C
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
284 bsf block_battery_gauge ; suspend ISR from accessing the battery gauge
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
285 clrf EEADRH
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
286 movff battery_gauge+0,EEDATA
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
287 write_int_eeprom 0x07
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
288 movff battery_gauge+1,EEDATA
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
289 write_int_eeprom 0x08
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
290 movff battery_gauge+2,EEDATA
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
291 write_int_eeprom 0x09
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
292 movff battery_gauge+3,EEDATA
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
293 write_int_eeprom 0x0A
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
294 movff battery_gauge+4,EEDATA
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
295 write_int_eeprom 0x0B
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
296 movff battery_gauge+5,EEDATA
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
297 write_int_eeprom 0x0C
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
298 movff battery_type,EEDATA ; =0:1.5V, =1:3.6V Saft, =2:LiIon 3.7V/0.8Ah, =3:LiIon 3.7V/3.1Ah, =4: LiIon 3.7V/2.3Ah
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
299 write_int_eeprom 0x0F
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
300 bcf block_battery_gauge ; allow ISR to access the battery gauge again
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
301 return
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
302
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
303
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
304 global retrieve_battery_registers
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
305 retrieve_battery_registers:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
306 ; retrieve battery gauge from EEPROM 0x07-0x0C
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
307 bsf block_battery_gauge ; suspend ISR from accessing the battery gauge
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
308 clrf EEADRH
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
309 read_int_eeprom 0x07
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
310 movff EEDATA,battery_gauge+0
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
311 read_int_eeprom 0x08
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
312 movff EEDATA,battery_gauge+1
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
313 read_int_eeprom 0x09
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
314 movff EEDATA,battery_gauge+2
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
315 read_int_eeprom 0x0A
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
316 movff EEDATA,battery_gauge+3
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
317 read_int_eeprom 0x0B
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
318 movff EEDATA,battery_gauge+4
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
319 read_int_eeprom 0x0C
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
320 movff EEDATA,battery_gauge+5
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
321 read_int_eeprom 0x0F
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
322 movff EEDATA,battery_type ; =0:1.5V, =1:3,6V Saft, =2:LiIon 3,7V/0.8Ah, =3:LiIon 3,7V/3.1Ah, =4: LiIon 3,7V/2.3Ah
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
323 bcf block_battery_gauge ; allow ISR to access the battery gauge again
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
324 return
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
325
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
326 ;=============================================================================
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
327
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
328 global vault_decodata_into_eeprom
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
329 vault_decodata_into_eeprom:
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
330 ; Vault in EEPROM 512...1023
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
331 ; Write 0xAA at 512 to indicate valid data in vault
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
332 ; Store last time/date
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
333 ; Store 0x700 to 0x780 (pres_tissue_N2 and pres_tissue_He)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
334 movlw HIGH .512 ; =2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
335 movwf EEADRH
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
336
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
337 ; indicate valid data in vault
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
338 movlw 0xAA
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
339 movwf EEDATA
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
340 write_int_eeprom .0
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
341
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
342 ; store date/time
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
343 SMOVSS rtc_year,rtc_latched_year ; ISR-safe 6 byte copy of date and time
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
344 movff rtc_latched_year+0,EEDATA
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
345 write_int_eeprom .1
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
346 movff rtc_latched_year+1,EEDATA
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
347 write_int_eeprom .2
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
348 movff rtc_latched_year+2,EEDATA
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
349 write_int_eeprom .3
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
350 movff rtc_latched_year+3,EEDATA
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
351 write_int_eeprom .4
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
352 movff rtc_latched_year+4,EEDATA
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
353 write_int_eeprom .5
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
354 movff rtc_latched_year+5,EEDATA
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
355 write_int_eeprom .6
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
356
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
357 movff int_O_CNS_current+0,EEDATA ; get current CNS, low byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
358 write_int_eeprom .7 ; store value
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
359 movff int_O_CNS_current+1,EEDATA ; get current CNS, high byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
360 write_int_eeprom .8 ; store value
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
361
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
362 movff int_O_desaturation_time+0,EEDATA; get desaturation time, low byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
363 write_int_eeprom .9 ; store value
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
364 movff int_O_desaturation_time+1,EEDATA; get desaturation time, high byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
365 write_int_eeprom .10 ; store value
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
366
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
367 SMOVII surface_interval,mpr ; ISR-safe copy of surface interval
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
368 movff mpr+0,EEDATA ; get surface interval, low byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
369 write_int_eeprom .11 ; store value
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
370 movff mpr+1,EEDATA ; get surface interval, high byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
371 write_int_eeprom .12 ; store value
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
372
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
373 movff int_O_lead_supersat+0,EEDATA ; get leading tissue's supersaturation, value is limited to 255 so only the lower byte is used for the value
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
374 write_int_eeprom .13
0
heinrichsweikamp
parents:
diff changeset
375
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
376 movff int_O_nofly_time+0,EEDATA ; get time, low byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
377 write_int_eeprom .14 ; store value
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
378 movff int_O_nofly_time+1,EEDATA ; get time, high byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
379 write_int_eeprom .15 ; store value
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
380
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
381 ; tissue data from 16 to 144
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
382 movlw .16
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
383 movwf EEADR
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
384 movlw .128 ; 2 * 16 floats = 2*16*4 byte = 128 byte
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
385 movwf lo
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
386 lfsr FSR1,0x700 ; pres_tissue_N2+0
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
387 vault_decodata_into_eeprom2:
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
388 movff POSTINC1,EEDATA
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
389 call write_eeprom ; EEDATA into EEPROM@EEADR
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
390 incf EEADR,F
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
391 decfsz lo,F ; all done?
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
392 bra vault_decodata_into_eeprom2 ; NO - loop
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
393 clrf EEADRH ; YES - reset EEPROM pointer
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
394 return ; - done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
395
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
396
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
397 global restore_decodata_from_eeprom
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
398 restore_decodata_from_eeprom:
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
399 movlw LOW .512 ; =0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
400 movwf EEADR
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
401 movlw HIGH .512 ; =2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
402 movwf EEADRH
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
403
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
404 ; restore date and time
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
405 read_int_eeprom .1
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
406 movff EEDATA,rtc_latched_year
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
407 read_int_eeprom .2
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
408 movff EEDATA,rtc_latched_month
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
409 read_int_eeprom .3
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
410 movff EEDATA,rtc_latched_day
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
411 read_int_eeprom .4
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
412 movff EEDATA,rtc_latched_hour
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
413 read_int_eeprom .5
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
414 movff EEDATA,rtc_latched_mins
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
415 read_int_eeprom .6
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
416 movff EEDATA,rtc_latched_secs
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
417 call rtc_set_rtc ; write time and date to RTC module
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
418
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
419 read_int_eeprom .7 ; read CNS%, low byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
420 movff EEDATA,int_O_CNS_current+0 ; restore value
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
421 read_int_eeprom .8 ; read CNS%, high byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
422 movff EEDATA,int_O_CNS_current+1 ; restore value
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
423
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
424 read_int_eeprom .9 ; read desaturation time, low byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
425 movff EEDATA,int_O_desaturation_time+0; restore value
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
426 read_int_eeprom .10 ; read desaturation time, high byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
427 movff EEDATA,int_O_desaturation_time+1; restore value
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
428
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
429 read_int_eeprom .11 ; read surface interval, low byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
430 movff EEDATA,mpr+0 ; cache value in mpr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
431 read_int_eeprom .12 ; read surface interval, high byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
432 movff EEDATA,mpr+1 ; cache value in mpr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
433 SMOVII mpr,surface_interval ; ISR-safe copy-back of surface interval
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
434
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
435 read_int_eeprom .13 ; read leading tissue's supersaturation
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
436 movff EEDATA,int_O_lead_supersat+0 ; restore value
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
437
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
438 read_int_eeprom .14 ; read no-fly/no-altitude time, low byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
439 movff EEDATA,int_O_nofly_time+0 ; restore value
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
440 read_int_eeprom .15 ; read no-fly/no-altitude time, high byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
441 movff EEDATA,int_O_nofly_time+1 ; restore value
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
442
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
443 ; tissue data from 16 to 144
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
444 movlw .16
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
445 movwf EEADR
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
446 movlw .128 ; 2 * 16 floats = 2*16*4 byte = 128 byte
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
447 movwf lo
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
448 lfsr FSR1,0x700 ; pres_tissue_N2+0
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
449 restore_decodata_from_eeprom2:
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
450 call read_eeprom ; EEPROM@EEADR into EEDATA
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
451 movff EEDATA,POSTINC1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
452 incf EEADR,F
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
453 decfsz lo,F ; all done?
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
454 bra restore_decodata_from_eeprom2 ; NO - loop
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
455 clrf EEADRH ; YES
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
456 return
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
457
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
458 ;=============================================================================
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
459
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
460 global reset_battery_pointer ; called from comm and menu tree
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
461 global reset_battery_internal_only
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
462 reset_battery_pointer: ; reset battery pointer 0x07-0x0C and battery gauge
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
463 btfsc battery_gauge_available ; something to reset?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
464 call lt2942_charge_done ; YES - reset accumulating registers to 0xFFFF
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
465 reset_battery_internal_only:
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
466 clrf EEADRH
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
467 clrf EEDATA ; delete to zero
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
468 write_int_eeprom 0x07
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
469 write_int_eeprom 0x08
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
470 write_int_eeprom 0x09
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
471 write_int_eeprom 0x0A
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
472 write_int_eeprom 0x0B
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
473 write_int_eeprom 0x0C
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
474
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
475 bsf block_battery_gauge ; suspend ISR from accessing the battery gauge
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
476 banksel battery_gauge ; select bank ISR data
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
477 clrf battery_gauge+0 ; null the battery gauge
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
478 clrf battery_gauge+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
479 clrf battery_gauge+2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
480 clrf battery_gauge+3
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
481 clrf battery_gauge+4
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
482 clrf battery_gauge+5
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
483 banksel common ; back to bank common
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
484 bcf block_battery_gauge ; allow ISR to access the battery gauge again
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
485
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
486 movlw .100
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
487 movwf batt_percent ; set battery level to 100%
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
488 return
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
489
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
490 ;=============================================================================
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
491
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
492 global eeprom_reset_logbook_pointers
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
493 eeprom_reset_logbook_pointers:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
494 clrf EEADRH ; make sure to select EEPROM bank 0
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
495 clrf EEDATA
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
496 write_int_eeprom .4
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
497 write_int_eeprom .5
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
498 write_int_eeprom .6
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
499 write_int_eeprom .2 ; also delete total dive counter
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
500 write_int_eeprom .3
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
501 write_int_eeprom .16
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
502 write_int_eeprom .17 ; ...and the backup counter, too
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
503 return
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
504
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
505 ;=============================================================================
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
506
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
507 END