annotate src/eeprom_rs232.asm @ 630:4cd81bdbf15c

3.08 stable release
author heinrichsweikamp
date Fri, 21 Feb 2020 10:51:36 +0100
parents 237931377539
children 185ba2f91f59
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
heinrichsweikamp
parents:
diff changeset
1 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
2 ;
629
237931377539 3.07 stable release
heinrichsweikamp
parents: 628
diff changeset
3 ; File eeprom_rs232.asm combined next generation V3.06.2
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
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
103 global disable_ir_s8
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
104 disable_ir_s8:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
105 banksel TXSTA2 ; select bank for IO register access
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
106 clrf TXSTA2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
107 clrf RCSTA2
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
108 banksel common ; back to bank common
629
237931377539 3.07 stable release
heinrichsweikamp
parents: 628
diff changeset
109 bcf PIE3,RC2IE ; disable RC2 INT
237931377539 3.07 stable release
heinrichsweikamp
parents: 628
diff changeset
110 bcf ir_power ; IR off
237931377539 3.07 stable release
heinrichsweikamp
parents: 628
diff changeset
111 bcf mcp_power ; power-down instrumentation amp
237931377539 3.07 stable release
heinrichsweikamp
parents: 628
diff changeset
112 bsf s8_npower ; power-down S8 digital interface
237931377539 3.07 stable release
heinrichsweikamp
parents: 628
diff changeset
113 bcf s8_digital_avail ; digital S8 interface not available
0
heinrichsweikamp
parents:
diff changeset
114 return
heinrichsweikamp
parents:
diff changeset
115
heinrichsweikamp
parents:
diff changeset
116
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
117 global enable_ir_s8
187
669b5d00706d CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents: 151
diff changeset
118 enable_ir_s8:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
119 ;initialize serial port2 (TRISG2)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
120 btfsc analog_o2_input ; do we have an analog input?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
121 bra enable_s8 ; YES - search for S8 digital input
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
122 ; NO - start IR digital input
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
123 banksel BAUDCON2 ; - select bank for IO register access
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
124 movlw b'00100000' ; - BRG16=0, inverted for IR
113
heinrichsweikamp
parents: 0
diff changeset
125 movwf BAUDCON2
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
126 movlw b'00100000' ; - BRGH=0, SYNC=0
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
127 movwf TXSTA2
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
128 movlw .102 ; - SPBRGH:SPBRG = .102 : 2403 BAUD @ 16 MHz
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
129 movwf SPBRG2
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
130 clrf SPBRGH2
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
131 movlw b'10010000'
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
132 movwf RCSTA2
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
133 banksel common ; - back to bank common
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
134 bsf ir_power ; - power-up IR
629
237931377539 3.07 stable release
heinrichsweikamp
parents: 628
diff changeset
135 btfss ir_power ; - power-up confirmed?
237931377539 3.07 stable release
heinrichsweikamp
parents: 628
diff changeset
136 bra $-6 ; NO - loop and wait
237931377539 3.07 stable release
heinrichsweikamp
parents: 628
diff changeset
137 bsf PIE3,RC2IE ; - enable RC2 INT
237931377539 3.07 stable release
heinrichsweikamp
parents: 628
diff changeset
138 return ; - done
0
heinrichsweikamp
parents:
diff changeset
139
113
heinrichsweikamp
parents: 0
diff changeset
140 enable_s8:
629
237931377539 3.07 stable release
heinrichsweikamp
parents: 628
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
0
heinrichsweikamp
parents:
diff changeset
182 ;=============================================================================
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
183
0
heinrichsweikamp
parents:
diff changeset
184 global enable_rs232
heinrichsweikamp
parents:
diff changeset
185 enable_rs232:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
186 call request_speed_normal ; request CPU speed change to normal speed
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
187 enable_rs232_1:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
188 btfss speed_is_normal ; speed = normal?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
189 bra enable_rs232_1 ; NO - wait for ISR to adjust speed
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
190 bcf PORTE,0 ; start comm
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
191 bsf PORTJ,2 ; /Reset (for very old OSTC sport)
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
192 ;initialize serial port1 (TRISC6/7)
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
193 movlw b'00100100' ; BRGH=1, SYNC=0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
194 movwf TXSTA1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
195 movlw b'10010000'
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
196 movwf RCSTA1
0
heinrichsweikamp
parents:
diff changeset
197 return
heinrichsweikamp
parents:
diff changeset
198
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
199
0
heinrichsweikamp
parents:
diff changeset
200 global disable_rs232
heinrichsweikamp
parents:
diff changeset
201 disable_rs232:
heinrichsweikamp
parents:
diff changeset
202 clrf RCSTA1
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
203 clrf TXSTA1 ; UART disable
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
204 bcf PORTC,6 ; TX hard to GND
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
205 bsf PORTE,0 ; stop comm
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
206 bcf PORTJ,2 ; /Reset (for very old OSTC sport)
0
heinrichsweikamp
parents:
diff changeset
207 return
heinrichsweikamp
parents:
diff changeset
208
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
209
0
heinrichsweikamp
parents:
diff changeset
210 global rs232_wait_tx
heinrichsweikamp
parents:
diff changeset
211 rs232_wait_tx:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
212 btfss TXSTA1,TRMT ; RS232 busy?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
213 bra rs232_wait_tx ; YES - wait...
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
214
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
215 btfss ble_available ; ble available?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
216 return ; NO - done
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
217
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
218 btfsc NRTS ; wait for Bluetooth module
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
219 bra rs232_wait_tx ; YES - wait...
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
220 return ; done
344
1e342e433839 CHANGE: GF and aGF high range increased to 45-110%
heinrichsweikamp
parents: 276
diff changeset
221
0
heinrichsweikamp
parents:
diff changeset
222
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
223 global rs232_wait_tx2
113
heinrichsweikamp
parents: 0
diff changeset
224 rs232_wait_tx2:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
225 banksel TXSTA2 ; select bank for IO register access
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
226 rs232_wait_tx2_loop:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
227 btfss TXSTA2,TRMT ; RS232 busy?
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
228 bra rs232_wait_tx2_loop ; YES - wait...
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
229 banksel common ; back to bank common
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
230 return ; done
113
heinrichsweikamp
parents: 0
diff changeset
231
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
232
0
heinrichsweikamp
parents:
diff changeset
233 global rs232_get_byte
heinrichsweikamp
parents:
diff changeset
234 rs232_get_byte:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
235 bcf rs232_rx_timeout ; clear timeout flag
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
236 ; set timeout timer to approx. 400 ms:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
237 clrf uart_timeout_timer+0 ; set low byte of timeout timer to 0
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
238 clrf uart_timeout_timer+1 ; set high byte of timeout timer to 0
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
239 ; set upper byte of timeout timer to 10 without using WREG:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
240 clrf uart_timeout_timer+2 ; first clear to 0, then...
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
241 bsf uart_timeout_timer+2,1 ; set bit 1 (value 2),
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
242 bsf uart_timeout_timer+2,3 ; and bit 3 (value 8).
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
243
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
244 rs232_get_byte_loop:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
245 btfsc PIR1,RCIF ; received a data byte?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
246 return ; YES - done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
247 decfsz uart_timeout_timer+0,F ; NO - decrement low byte of timer, became zero?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
248 bra rs232_get_byte_loop ; NO - loop
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
249 decfsz uart_timeout_timer+1,F ; YES - decrement high 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+2,F ; YES - decrement upper 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 bsf rs232_rx_timeout ; YES - set timeout flag
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
254 bcf RCSTA1,CREN ; - clear receiver status
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
255 bsf RCSTA1,CREN ; - ...
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
256 return ; - and return anyway
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
257
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
258 ;=============================================================================
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
259
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
260 global do_logoffset_common_write
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
261 do_logoffset_common_write:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
262 movff lo,EEDATA
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
263 write_int_eeprom 0x0D
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
264 movff hi,EEDATA
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
265 write_int_eeprom 0x0E
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
266 return
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
267
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
268 global do_logoffset_common_read
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
269 do_logoffset_common_read:
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
270 clrf EEADRH
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
271 read_int_eeprom 0x0D
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
272 movff EEDATA,lo
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
273 read_int_eeprom 0x0E
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
274 movff EEDATA,hi
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
275 return
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
276
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
277 ;=============================================================================
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
278
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
279 global update_battery_registers
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
280 update_battery_registers:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
281 ; save battery gauge to EEPROM 0x07-0x0C
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
282 bsf block_battery_gauge ; suspend ISR from accessing the battery gauge
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
283 clrf EEADRH
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
284 movff battery_gauge+0,EEDATA
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
285 write_int_eeprom 0x07
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
286 movff battery_gauge+1,EEDATA
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
287 write_int_eeprom 0x08
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
288 movff battery_gauge+2,EEDATA
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
289 write_int_eeprom 0x09
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
290 movff battery_gauge+3,EEDATA
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
291 write_int_eeprom 0x0A
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
292 movff battery_gauge+4,EEDATA
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
293 write_int_eeprom 0x0B
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
294 movff battery_gauge+5,EEDATA
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
295 write_int_eeprom 0x0C
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
296 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
297 write_int_eeprom 0x0F
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
298 bcf block_battery_gauge ; allow ISR to access the battery gauge again
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
299 return
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
300
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
301
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
302 global retrieve_battery_registers
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
303 retrieve_battery_registers:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
304 ; retrieve battery gauge from EEPROM 0x07-0x0C
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
305 bsf block_battery_gauge ; suspend ISR from accessing the battery gauge
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
306 clrf EEADRH
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
307 read_int_eeprom 0x07
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
308 movff EEDATA,battery_gauge+0
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
309 read_int_eeprom 0x08
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
310 movff EEDATA,battery_gauge+1
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
311 read_int_eeprom 0x09
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
312 movff EEDATA,battery_gauge+2
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
313 read_int_eeprom 0x0A
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
314 movff EEDATA,battery_gauge+3
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
315 read_int_eeprom 0x0B
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
316 movff EEDATA,battery_gauge+4
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
317 read_int_eeprom 0x0C
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
318 movff EEDATA,battery_gauge+5
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
319 read_int_eeprom 0x0F
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
320 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
321 bcf block_battery_gauge ; allow ISR to access the battery gauge again
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
322 return
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
323
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
324 ;=============================================================================
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
325
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
326 global vault_decodata_into_eeprom
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
327 vault_decodata_into_eeprom:
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
328 ; Vault in EEPROM 512...1023
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
329 ; Write 0xAA at 512 to indicate valid data in vault
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
330 ; Store last time/date
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
331 ; Store 0x700 to 0x780 (pres_tissue_N2 and pres_tissue_He)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
332 movlw HIGH .512 ; =2
629
237931377539 3.07 stable release
heinrichsweikamp
parents: 628
diff changeset
333 movwf EEADRH ; set EEPROM address, high byte
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
334
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
335 ; indicate valid data in vault
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
336 movlw 0xAA
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
337 movwf EEDATA
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
338 write_int_eeprom .0
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
339
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
340 ; store date/time
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
341 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
342 movff rtc_latched_year+0,EEDATA
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
343 write_int_eeprom .1
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
344 movff rtc_latched_year+1,EEDATA
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
345 write_int_eeprom .2
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
346 movff rtc_latched_year+2,EEDATA
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
347 write_int_eeprom .3
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
348 movff rtc_latched_year+3,EEDATA
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
349 write_int_eeprom .4
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
350 movff rtc_latched_year+4,EEDATA
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
351 write_int_eeprom .5
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
352 movff rtc_latched_year+5,EEDATA
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
353 write_int_eeprom .6
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
354
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
355 movff int_O_CNS_current+0,EEDATA ; get current CNS, low byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
356 write_int_eeprom .7 ; store value
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
357 movff int_O_CNS_current+1,EEDATA ; get current CNS, high byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
358 write_int_eeprom .8 ; store value
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
359
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
360 movff int_O_desaturation_time+0,EEDATA; get desaturation time, low byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
361 write_int_eeprom .9 ; store value
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
362 movff int_O_desaturation_time+1,EEDATA; get desaturation time, high byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
363 write_int_eeprom .10 ; store value
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
364
629
237931377539 3.07 stable release
heinrichsweikamp
parents: 628
diff changeset
365 SMOVII surface_interval_mins,mpr ; ISR-safe copy of surface interval
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
366 movff mpr+0,EEDATA ; get surface interval, low byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
367 write_int_eeprom .11 ; store value
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
368 movff mpr+1,EEDATA ; get surface interval, high byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
369 write_int_eeprom .12 ; store value
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
370
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
371 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
372 write_int_eeprom .13
0
heinrichsweikamp
parents:
diff changeset
373
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
374 movff int_O_nofly_time+0,EEDATA ; get time, low byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
375 write_int_eeprom .14 ; store value
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
376 movff int_O_nofly_time+1,EEDATA ; get time, high byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
377 write_int_eeprom .15 ; store value
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
378
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
379 ; tissue data from 16 to 144
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
380 movlw .16
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
381 movwf EEADR
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
382 movlw .128 ; 2 * 16 floats = 2*16*4 byte = 128 byte
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
383 movwf lo
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
384 lfsr FSR1,0x700 ; pres_tissue_N2+0
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
385 vault_decodata_into_eeprom2:
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
386 movff POSTINC1,EEDATA
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
387 call write_eeprom ; EEDATA into EEPROM@EEADR
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
388 incf EEADR,F
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
389 decfsz lo,F ; all done?
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
390 bra vault_decodata_into_eeprom2 ; NO - loop
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
391 clrf EEADRH ; YES - reset EEPROM pointer
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
392 return ; - done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
393
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
394
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
395 global restore_decodata_from_eeprom
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
396 restore_decodata_from_eeprom:
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
397 movlw LOW .512 ; =0
629
237931377539 3.07 stable release
heinrichsweikamp
parents: 628
diff changeset
398 movwf EEADR ; set EEPROM address, low byte
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
399 movlw HIGH .512 ; =2
629
237931377539 3.07 stable release
heinrichsweikamp
parents: 628
diff changeset
400 movwf EEADRH ; set EEPROM address, high byte
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
401
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
402 ; restore date and time
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
403 read_int_eeprom .1
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
404 movff EEDATA,rtc_latched_year
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
405 read_int_eeprom .2
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
406 movff EEDATA,rtc_latched_month
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
407 read_int_eeprom .3
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
408 movff EEDATA,rtc_latched_day
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
409 read_int_eeprom .4
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
410 movff EEDATA,rtc_latched_hour
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
411 read_int_eeprom .5
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
412 movff EEDATA,rtc_latched_mins
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
413 read_int_eeprom .6
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
414 movff EEDATA,rtc_latched_secs
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
415 call rtc_set_rtc ; write time and date to RTC module
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
416
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
417 read_int_eeprom .7 ; read CNS%, low byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
418 movff EEDATA,int_O_CNS_current+0 ; restore value
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
419 read_int_eeprom .8 ; read CNS%, high byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
420 movff EEDATA,int_O_CNS_current+1 ; restore value
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
421
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
422 read_int_eeprom .9 ; read desaturation time, low byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
423 movff EEDATA,int_O_desaturation_time+0; restore value
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
424 read_int_eeprom .10 ; read desaturation time, high byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
425 movff EEDATA,int_O_desaturation_time+1; restore value
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
426
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
427 read_int_eeprom .11 ; read surface interval, low byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
428 movff EEDATA,mpr+0 ; cache value in mpr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
429 read_int_eeprom .12 ; read surface interval, high byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
430 movff EEDATA,mpr+1 ; cache value in mpr
629
237931377539 3.07 stable release
heinrichsweikamp
parents: 628
diff changeset
431 SMOVII mpr,surface_interval_mins ; ISR-safe copy-back of surface interval
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
432
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
433 read_int_eeprom .13 ; read leading tissue's supersaturation
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
434 movff EEDATA,int_O_lead_supersat+0 ; restore value
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
435
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
436 read_int_eeprom .14 ; read no-fly/no-altitude time, low byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
437 movff EEDATA,int_O_nofly_time+0 ; restore value
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
438 read_int_eeprom .15 ; read no-fly/no-altitude time, high byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
439 movff EEDATA,int_O_nofly_time+1 ; restore value
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
440
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
441 ; tissue data from 16 to 144
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
442 movlw .16
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
443 movwf EEADR
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
444 movlw .128 ; 2 * 16 floats = 2*16*4 byte = 128 byte
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
445 movwf lo
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
446 lfsr FSR1,0x700 ; pres_tissue_N2+0
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
447 restore_decodata_from_eeprom2:
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
448 call read_eeprom ; EEPROM@EEADR into EEDATA
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
449 movff EEDATA,POSTINC1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
450 incf EEADR,F
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
451 decfsz lo,F ; all done?
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
452 bra restore_decodata_from_eeprom2 ; NO - loop
629
237931377539 3.07 stable release
heinrichsweikamp
parents: 628
diff changeset
453 clrf EEADRH ; YES - revert EEPROM high address pointer to default
237931377539 3.07 stable release
heinrichsweikamp
parents: 628
diff changeset
454 return ; - done
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
455
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
456 ;=============================================================================
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
457
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
458 global reset_battery_pointer ; called from comm and menu tree
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
459 global reset_battery_internal_only
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
460 reset_battery_pointer: ; reset battery pointer 0x07-0x0C and battery gauge
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
461 btfsc battery_gauge_available ; something to reset?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
462 call lt2942_charge_done ; YES - reset accumulating registers to 0xFFFF
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
463 reset_battery_internal_only:
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
464 clrf EEADRH
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
465 clrf EEDATA ; delete to zero
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
466 write_int_eeprom 0x07
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
467 write_int_eeprom 0x08
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
468 write_int_eeprom 0x09
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
469 write_int_eeprom 0x0A
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
470 write_int_eeprom 0x0B
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
471 write_int_eeprom 0x0C
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
472
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
473 bsf block_battery_gauge ; suspend ISR from accessing the battery gauge
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
474 banksel battery_gauge ; select bank ISR data
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
475 clrf battery_gauge+0 ; null the battery gauge
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
476 clrf battery_gauge+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
477 clrf battery_gauge+2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
478 clrf battery_gauge+3
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
479 clrf battery_gauge+4
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
480 clrf battery_gauge+5
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
481 banksel common ; back to bank common
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
482 bcf block_battery_gauge ; allow ISR to access the battery gauge again
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
483
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
484 movlw .100
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
485 movwf batt_percent ; set battery level to 100%
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
486 return
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
487
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
488 ;=============================================================================
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
489
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
490 global eeprom_reset_logbook_pointers
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
491 eeprom_reset_logbook_pointers:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
492 clrf EEADRH ; make sure to select EEPROM bank 0
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
493 clrf EEDATA
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
494 write_int_eeprom .4
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
495 write_int_eeprom .5
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
496 write_int_eeprom .6
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
497 write_int_eeprom .2 ; also delete total dive counter
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
498 write_int_eeprom .3
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
499 write_int_eeprom .16
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
500 write_int_eeprom .17 ; ...and the backup counter, too
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
501 return
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
502
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
503 ;=============================================================================
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
504
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 386
diff changeset
505 END