annotate src/eeprom_rs232.inc @ 633:690c48db7b5b

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