annotate src/eeprom_rs232.inc @ 634:4050675965ea

3.10 stable release
author heinrichsweikamp
date Tue, 28 Apr 2020 17:34:31 +0200 (2020-04-28)
parents 185ba2f91f59
children aeca5717d9eb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
heinrichsweikamp
parents:
diff changeset
1 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
2 ;
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
3 ; File eeprom_rs232.inc * combined next generation V3.09.4n
0
heinrichsweikamp
parents:
diff changeset
4 ;
heinrichsweikamp
parents:
diff changeset
5 ;
heinrichsweikamp
parents:
diff changeset
6 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
heinrichsweikamp
parents:
diff changeset
7 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
8 ; HISTORY
heinrichsweikamp
parents:
diff changeset
9 ; 2011-08-03 : [mH] moving from OSTC code
heinrichsweikamp
parents:
diff changeset
10
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 224
diff changeset
11
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
12
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
13 ; --------------------------------------------------------------------------------------------
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
14 ; EEPROM Defines
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
15 ; --------------------------------------------------------------------------------------------
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
16
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
17 #DEFINE DECO_DATA_VALID_TOKEN 0x55 ; deco data valid
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
18 #DEFINE DECO_DATA_INVALID_TOKEN 0xAA ; deco data invalid
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
19
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
20
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
21 ; --------------------------------------------------------------------------------------------
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
22 ; EEPROM Memory Map
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
23 ; --------------------------------------------------------------------------------------------
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
24
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
25 ; Label EEPROM Address Size Description
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
26
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
27 ; bank 1+2: settings & options
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
28 ; ---------------------------- +--- do not change the position of these data!
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
29 #DEFINE eeprom_ostc_serial 0x000 ; | 2 OSTC dive computer unique serial number
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
30 #DEFINE eeprom_num_dives 0x002 ; | 2 total number of dives
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
31 #DEFINE eeprom_log_pointer 0x004 ; | 3 pointer used for accessing log data in external flash
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
32 #DEFINE eeprom_battery_gauge 0x007 ; | 6 backup storage for the battery gauge meter
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
33 #DEFINE eeprom_log_offset 0x00D ; | 2 offset between OSTC dive counting and user's counting
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
34 #DEFINE eeprom_battery_type 0x00F ; | 1 battery type inside the OSTC
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
35 #DEFINE eeprom_options_version 0x010 ; 2 options version identifier
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
36 #DEFINE eeprom_fw_chksum_current 0x012 ; 6 checksum of the current firmware *)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
37 ; 0x018 ; 2 unused
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
38 #DEFINE eeprom_options_storage 0x01A ; 486 backup storage for the options
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
39
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
40
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
41 ; bank 2: deco data backup
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
42 ; ------------------------
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
43 #DEFINE eeprom_deco_data_validity 0x200 ; 1 deco data validity
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
44 #DEFINE eeprom_deco_data_version 0x201 ; 1 deco data format version
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
45 #DEFINE eeprom_deco_data_timestamp 0x202 ; 6 date/time of deco data
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
46 #DEFINE eeprom_deco_data_surfinterval 0x208 ; 2 surface interval
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
47 ; 0x20A ; 6 unused
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
48 #DEFINE eeprom_deco_data_bank3 0x210 ; 9 desaturation status
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
49 ; 0x219 ; 1 unused
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
50 #DEFINE eeprom_deco_data_bank5 0x21A ; 4 CNS
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
51 ; 0x21E ; 2 unused
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
52 #DEFINE eeprom_deco_data_bank7 0x220 ; 128 tissue pressures
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
53 ; 0x2A0 ; 96 unused
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
54
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
55
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
56 ; bank 3: flash backup & factory use
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
57 ; ----------------------------------
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
58 #DEFINE eeprom_prog_page0_backup 0x300 ; 128 backup storage for the first program memory page
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
59 ; 0x380 ; 1 unused
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
60 #DEFINE eeprom_button_polarity 0x381 ; 1 button polarity (factory use only, do not change position!)
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
61 #DEFINE eeprom_fw_chksum_recovry 0x382 ; 6 checksum of stored recovery firmware *)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
62 ; 0x388 ; 121 unused
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
63
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
64
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
65 ; *) 4 byte code checksum, 1 byte checksum of the checksum, 1 byte firmware ID
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
66
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
67
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
68
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
69 ; --------------------------------------------------------------------------------------------
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
70 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
71 ; EEPROM read & write Macros
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
72 ;
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
73 ; --------------------------------------------------------------------------------------------
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
74
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
75
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
76 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
77 ; read 1 byte from EEPROM to memory
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
78 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
79 ; eeprom_address: address:2 containing source address in EEPROM
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
80 ; memory_address: address:2 containing target address in memory
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
81 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
82 EEPROM_CC_READ macro eeprom_address, memory_address
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
83 movlw HIGH(eeprom_address) ; extract bank in EEPROM
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
84 movwf EEADRH ; set bank in EEPROM
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
85 movlw LOW (eeprom_address) ; extract start address in EEPROM
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
86 movwf EEADR ; set start address in EEPROM
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
87 call read_eeprom ; read from EEPROM
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
88 movff EEDATA,memory_address ; store to memory
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
89 endm
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
90
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
91
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
92 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
93 ; read 2 bytes from EEPROM to memory, both bytes need to be in same EEPROM bank
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
94 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
95 ; eeprom_address: address:2 containing start address in EEPROM
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
96 ; memory_address: address:2 containing start address in memory
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
97 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
98 EEPROM_II_READ macro eeprom_address, memory_address
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
99 movlw HIGH(eeprom_address) ; extract bank in EEPROM
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
100 movwf EEADRH ; set bank in EEPROM
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
101 movlw LOW (eeprom_address) ; extract start address in EEPROM
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
102 movwf EEADR ; set start address in EEPROM
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
103 lfsr FSR1,memory_address ; set start address in memory
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
104 movlw .2 ; read 2 bytes
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
105 call eeprom_read_common ; execute read
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
106 endm
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
107
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
108
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
109 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
110 ; read 3 bytes from EEPROM to memory, all bytes need to be in same EEPROM bank
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
111 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
112 ; eeprom_address: address:2 containing start address in EEPROM
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
113 ; memory_address: address:2 containing start address in memory
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
114 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
115 EEPROM_TT_READ macro eeprom_address, memory_address
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
116 movlw HIGH(eeprom_address) ; extract bank in EEPROM
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
117 movwf EEADRH ; set bank in EEPROM
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
118 movlw LOW (eeprom_address) ; extract start address in EEPROM
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
119 movwf EEADR ; set start address in EEPROM
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
120 lfsr FSR1,memory_address ; set start address in memory
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
121 movlw .3 ; read 3 bytes
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
122 call eeprom_read_common ; execute read
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
123 endm
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
124
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
125
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
126 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
127 ; read a range of bytes from EEPROM to memory, all bytes need to be in same EEPROM bank
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
128 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
129 ; eeprom_address: address:2 containing start address in EEPROM
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
130 ; memory_address: address:2 containing start address in memory (bank safe)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
131 ; range : number of bytes to read (1-256), will wrap-around staying in same EEPROM bank!
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
132 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
133 EEPROM_RR_READ macro eeprom_address, memory_address, range
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
134 movlw HIGH(eeprom_address) ; extract bank in EEPROM
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
135 movwf EEADRH ; set bank in EEPROM
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
136 movlw LOW (eeprom_address) ; extract start address in EEPROM
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
137 movwf EEADR ; set start address in EEPROM
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
138 lfsr FSR1,memory_address ; set start address in memory
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
139 movlw low(range) ; set size of range to read
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
140 call eeprom_read_common ; execute read
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
141 endm
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
142
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
143
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
144 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
145 ; write 1 byte from memory to EEPROM
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
146 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
147 ; memory_address: address:2 containing source address in memory (bank safe)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
148 ; eeprom_address: address:2 containing destination address in EEPROM
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
149 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
150 EEPROM_CC_WRITE macro memory_address, eeprom_address
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
151 movlw HIGH(eeprom_address) ; extract bank in EEPROM
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
152 movwf EEADRH ; set bank in EEPROM
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
153 movlw LOW (eeprom_address) ; extract start address in EEPROM
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
154 movwf EEADR ; set start address in EEPROM
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
155 movff memory_address,EEDATA ; copy byte to EEPROM data register
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
156 call write_eeprom ; execute write
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
157 endm
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
158
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
159
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
160 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
161 ; write 2 bytes from memory to EEPROM, both bytes need to go into the same EEPROM bank
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
162 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
163 ; memory_address: address:2 containing start address in memory (bank safe)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
164 ; eeprom_address: address:2 containing start address in EEPROM
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
165 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
166 EEPROM_II_WRITE macro memory_address, eeprom_address
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
167 movlw HIGH(eeprom_address) ; extract bank in EEPROM
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
168 movwf EEADRH ; set bank in EEPROM
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
169 movlw LOW (eeprom_address) ; extract start address in EEPROM
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
170 movwf EEADR ; set start address in EEPROM
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
171 lfsr FSR1,memory_address ; set start address in memory
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
172 movlw .2 ; write 2 bytes
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
173 call eeprom_write_common ; execute write
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
174 endm
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
175
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
176
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
177 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
178 ; write 3 bytes from memory to EEPROM, all bytes need to go into the same EEPROM bank
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
179 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
180 ; memory_address: address:2 containing start address in memory (bank safe)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
181 ; eeprom_address: address:2 containing start address in EEPROM
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
182 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
183 EEPROM_TT_WRITE macro memory_address, eeprom_address
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
184 movlw HIGH(eeprom_address) ; extract bank in EEPROM
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
185 movwf EEADRH ; set bank in EEPROM
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
186 movlw LOW (eeprom_address) ; extract start address in EEPROM
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
187 movwf EEADR ; set start address in EEPROM
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
188 lfsr FSR1,memory_address ; set start address in memory
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
189 movlw .3 ; write 3 bytes
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
190 call eeprom_write_common ; execute write
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
191 endm
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
192
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
193
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
194 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
195 ; write a range of bytes from memory to EEPROM, all bytes need to go into the same EEPROM bank
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
196 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
197 ; memory_address: address:2 containing start address in memory (bank safe)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
198 ; eeprom_address: address:2 containing start address in EEPROM
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
199 ; range : number of bytes to write (1-256), will wrap-around staying in same EEPROM bank!
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
200 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
201 EEPROM_RR_WRITE macro memory_address, eeprom_address, range
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
202 movlw HIGH(eeprom_address) ; extract bank in EEPROM
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
203 movwf EEADRH ; set bank in EEPROM
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
204 movlw LOW (eeprom_address) ; extract start address in EEPROM
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
205 movwf EEADR ; set start address in EEPROM
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
206 lfsr FSR1,memory_address ; set start address in memory
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
207 movlw low(range) ; set size of range to write
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
208 call eeprom_write_common ; execute write
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
209 endm
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
210
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
211
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
212 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
213 ; set up EEPROM address register for subsequent read/write operations
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
214 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
215 ; eeprom_address: address:2 containing the EEPROM address to set up
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
216 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
217 EEPROM_SET_ADDRESS macro eeprom_address ; Set EEPROM address
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
218 movlw HIGH(eeprom_address) ; extract bank in EEPROM ; for subsequent calls to
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
219 movwf EEADRH ; set EEPROM bank ; write_eeprom / read_eeprom
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
220 movlw LOW (eeprom_address) ; extract start address in EEPROM
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
221 movwf EEADR ; set EEPROM cell
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
222 endm
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
223
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
224
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
225
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
226 ; --------------------------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
227 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
228 ; Serial Read & Write Macros
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
229 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
230 ; --------------------------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
231
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
232
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
233 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
234 ; Receive 1 Byte and write to Memory
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
235 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
236 ; in case of a Timeout the Flag 'rs232_rx_timeout' will be set
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
237 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
238 SERIAL_CC_RECEIVE macro mem_address
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
239 extern serial_rx_single
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
240 call serial_rx_single ; (try to) receive one byte
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
241 movff RCREG1,mem_address ; copy received byte to memory
0
heinrichsweikamp
parents:
diff changeset
242 endm
heinrichsweikamp
parents:
diff changeset
243
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 224
diff changeset
244
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
245 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
246 ; Stream a Range of Bytes to Memory
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
247 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
248 ; in case of a Timeout the Flag 'rs232_rx_timeout' will be set
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
249 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
250 ; mem_address: address:2 containing the start address in memory (bank safe)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
251 ; range : number of bytes to receive (1-256)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
252 ;
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
253 SERIAL_RR_RECEIVE macro mem_address, range
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
254 lfsr FSR2,mem_address ; set start address in memory
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
255 movlw low(range) ; set number of bytes to receive
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
256 extern serial_rx_stream
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
257 call serial_rx_stream
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
258 endm
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
259
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
260
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
261 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
262 ; Send 1 Byte Literal
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
263 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
264 SERIAL_LC_SEND macro literal
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
265 call rs232_wait_tx ; wait for completion of last transmit
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
266 movlw literal ; load literal
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
267 movwf TXREG1 ; send literal to serial TX
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
268 endm
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
269
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
270
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
271 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
272 ; Send 1 Byte from Memory
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
273 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
274 ; mem_address: address:2 containing the source address in memory (bank safe)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
275 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
276 SERIAL_CC_SEND macro mem_address
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
277 call rs232_wait_tx ; wait for completion of last transmit
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
278 movff mem_address,TXREG1 ; send byte from memory to serial TX
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
279 endm
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
280
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
281
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
282 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
283 ; Send a Range of Bytes from Memory
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
284 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
285 ; mem_address: address:2 containing the start address in memory (bank safe)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
286 ; range : number of bytes to send (1-256)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
287 ;
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
288 SERIAL_RR_SEND macro mem_address, range
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
289 lfsr FSR2,mem_address ; set start address in memory
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
290 movlw low(range) ; set number of bytes to send
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
291 extern serial_tx_steam
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
292 call serial_tx_steam
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
293 endm
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
294
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
295
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
296 ; --------------------------------------------------------------------------------------------
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
297 ; EXTERN Directives
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
298 ; --------------------------------------------------------------------------------------------
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
299
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
300 IFNDEF INSIDE_EEPROM_RS232
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
301
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
302 ; EEPROM - basic read & write
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
303
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
304 extern eeprom_read_common
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
305 extern eeprom_write_common
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
306
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
307 extern read_eeprom
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
308 extern write_eeprom
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
309
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
310
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
311 ; EEPROM high-level access
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
312
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
313 extern eeprom_serial_number_read
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
314
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
315 extern eeprom_total_dives_read
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
316 extern eeprom_total_dives_write
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
317
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
318 extern eeprom_log_offset_read
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
319 extern eeprom_log_offset_write
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
320
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
321 extern eeprom_battery_gauge_read
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
322 extern eeprom_battery_gauge_write
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
323
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
324 extern eeprom_deco_data_read
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
325 extern eeprom_deco_data_write
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
326
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
327
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
328 ; Serial - IR / S8
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
329
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
330 extern enable_ir_s8_analog
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
331 extern disable_ir_s8_analog
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
332 extern ir_s8_tx_single
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
333
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
334
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
335 ; Serial - RS232 (USB / BT)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
336
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 224
diff changeset
337 extern enable_rs232
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 224
diff changeset
338 extern disable_rs232
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 224
diff changeset
339 extern rs232_wait_tx
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 582
diff changeset
340
629
237931377539 3.07 stable release
heinrichsweikamp
parents: 623
diff changeset
341
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 629
diff changeset
342 ENDIF ; INSIDE_EEPROM_RS232