comparison code_part1/OSTC_code_asm_part1/menu_logbook.asm @ 362:64da813d4726 64kByte Logbook

Logbook converter (Needs ~8Minutes and is called one time). Backup your dives before use!!
author Heinrichsweikamp
date Wed, 08 Jun 2011 19:47:18 +0200
parents 5c186a72cb5d
children ca3d15e6240e
comparison
equal deleted inserted replaced
361:88660a400338 362:64da813d4726
1162 incf_eeprom_address d'37' ; 12 Bytes read from header, skip 37 Bytes in EEPROM (Remaining Header) 1162 incf_eeprom_address d'37' ; 12 Bytes read from header, skip 37 Bytes in EEPROM (Remaining Header)
1163 btfss logbook_format_0x21 ; 10byte extra? 1163 btfss logbook_format_0x21 ; 10byte extra?
1164 return ; No, Done. 1164 return ; No, Done.
1165 incf_eeprom_address d'10' ; Skip another 10 byte from the header for 0x21 format 1165 incf_eeprom_address d'10' ; Skip another 10 byte from the header for 0x21 format
1166 return 1166 return
1167
1168 logbook_convert_64k:
1169 call PLED_boot
1170 call PLED_ClearScreen ; Clear screen
1171 movlw color_red
1172 call PLED_set_color ; Set to Red
1173 DISPLAYTEXTH d'303' ; Please wait!
1174 movlw LOW 0x100
1175 movwf EEADR
1176 movlw HIGH 0x100
1177 movwf EEADRH
1178 movlw 0xAA
1179 movwf EEDATA
1180 call write_eeprom ; write 0xAA to indicate the logbook is already converted
1181 ; convert logbook:
1182 ; Step 1: Copy 32k from 0xFE + 1 with bank switching to bank1
1183 ; Step 2: Copy 32k from bank1 to bank0
1184 ; Step 3: delete bank1
1185 call get_free_EEPROM_location ; Searches 0xFD, 0xFD, 0xFE and sets Pointer to 0xFE
1186 rcall incf_eeprom_bank0 ; eeprom_address:2 now at 0xFE+1
1187 ; Do Step 1:
1188 ;logbook_temp5 and logbook_temp6 hold address in bank1
1189 ;logbook_temp1 and logbook_temp2 hold address in bank0
1190 movlw HIGH 0x8000
1191 movwf logbook_temp6
1192 movlw LOW 0x8000
1193 movwf logbook_temp5 ; load address for bank1
1194 movff eeprom_address+0,logbook_temp1
1195 movff eeprom_address+1,logbook_temp2 ; load address for bank0
1196 movlw 0x80
1197 movwf uart2_temp
1198 logbook_convert2:
1199 clrf uart1_temp ; counter for copy operation
1200 logbook_convert3:
1201 ; read source
1202 movff logbook_temp1,eeprom_address+0
1203 movff logbook_temp2,eeprom_address+1
1204 call I2CREAD
1205 movff SSPBUF,lo ; hold read value
1206 rcall incf_eeprom_bank0 ; eeprom_address:2 +1 with bank switching
1207 movff eeprom_address+0,logbook_temp1
1208 movff eeprom_address+1,logbook_temp2 ; write source address
1209 ; write target
1210 movff logbook_temp5,eeprom_address+0
1211 movff logbook_temp6,eeprom_address+1
1212 movf lo,W
1213 call I2CWRITE ; writes WREG into EEPROM@eeprom_address
1214 movlw d'1'
1215 addwf logbook_temp5,F
1216 movlw d'0'
1217 addwfc logbook_temp6,F ; increase target address
1218 decfsz uart1_temp,F
1219 bra logbook_convert3
1220 btg LED_blue
1221 decfsz uart2_temp,F ; 32kByte done?
1222 bra logbook_convert2 ; No, continue
1223 ; Step 1 done.
1224 bcf LED_blue
1225 ; Do Step 2:
1226 movlw HIGH 0x0000
1227 movwf logbook_temp6
1228 movlw LOW 0x0000
1229 movwf logbook_temp5 ; load address for bank0
1230 movlw HIGH 0x8000
1231 movwf logbook_temp2
1232 movlw LOW 0x8000
1233 movwf logbook_temp1 ; load address for bank1
1234 movlw 0x80
1235 movwf uart2_temp
1236 logbook_convert4:
1237 clrf uart1_temp ; counter for copy operation
1238 logbook_convert5:
1239 ; read source
1240 movff logbook_temp1,eeprom_address+0
1241 movff logbook_temp2,eeprom_address+1
1242 call I2CREAD
1243 movff SSPBUF,lo ; hold read value
1244 incf_eeprom_address d'1'
1245 movff eeprom_address+0,logbook_temp1
1246 movff eeprom_address+1,logbook_temp2 ; write source address
1247 ; write target
1248 movff logbook_temp5,eeprom_address+0
1249 movff logbook_temp6,eeprom_address+1
1250 movf lo,W
1251 call I2CWRITE ; writes WREG into EEPROM@eeprom_address
1252 incf_eeprom_address d'1'
1253 movff eeprom_address+0,logbook_temp5
1254 movff eeprom_address+1,logbook_temp6 ; write target address
1255 decfsz uart1_temp,F
1256 bra logbook_convert5
1257 btg LED_red
1258 decfsz uart2_temp,F ; 32kByte done?
1259 bra logbook_convert4 ; No, continue
1260 ; Step 2 done.
1261 bcf LED_red
1262 movlw HIGH 0x8000
1263 movwf logbook_temp2
1264 movlw LOW 0x8000
1265 movwf logbook_temp1 ; load address for bank1
1266 movlw 0x80
1267 movwf uart2_temp
1268 logbook_convert6:
1269 clrf uart1_temp ; counter for copy operation
1270 logbook_convert7:
1271 ; write target
1272 movff logbook_temp1,eeprom_address+0
1273 movff logbook_temp2,eeprom_address+1
1274 movlw 0xFF
1275 call I2CWRITE ; writes WREG into EEPROM@eeprom_address
1276 incf_eeprom_address d'1'
1277 movff eeprom_address+0,logbook_temp1
1278 movff eeprom_address+1,logbook_temp2 ; write target address
1279 decfsz uart1_temp,F
1280 bra logbook_convert7
1281 btg LED_red
1282 btg LED_blue
1283 decfsz uart2_temp,F ; 32kByte done?
1284 bra logbook_convert6 ; No, continue
1285 ; Step 3 done.
1286 bcf LED_red
1287 bcf LED_blue
1288 return
1289
1290 incf_eeprom_bank0:
1291 movlw d'1' ; increase address
1292 addwf eeprom_address+0,F
1293 movlw d'0'
1294 addwfc eeprom_address+1,F
1295 btfss eeprom_address+1,7 ; at address 8000?
1296 return ; no, skip
1297 clrf eeprom_address+0 ; Clear eeprom address
1298 clrf eeprom_address+1
1299 return