comparison src/external_flash.asm @ 561:9c54849b8d3b

Remove routine to fix corrupt dives made with v1.80
author heinrichsweikamp
date Sat, 03 Feb 2018 13:36:02 +0100
parents ccaaac45b61a
children b455b31ce022
comparison
equal deleted inserted replaced
560:b7eb98dbd800 561:9c54849b8d3b
339 btfss SSP2STAT, BF ; Buffer full? 339 btfss SSP2STAT, BF ; Buffer full?
340 bra write_spi2 ; No, wait. 340 bra write_spi2 ; No, wait.
341 movf SSP2BUF,W 341 movf SSP2BUF,W
342 return ; Returns RX data in WREG and SSP2BUF 342 return ; Returns RX data in WREG and SSP2BUF
343 343
344 global fix_180_dives
345 fix_180_dives: ; fix dives made with the 1.80
346 clrf divesecs ; Here: # of dive (0-255) in TOC
347 fix_180_dives2:
348 rcall fix_load_dive_into_buffer ; Load header #divesecs into buffer:256
349 rcall fix_check_buffer ; Check the buffered dive
350 tstfsz WREG ; Dive needs fix?
351 rcall fix_buffered_dive ; Yes, fix and save it
352 decfsz divesecs,F ; All done?
353 bra fix_180_dives2 ; No, continue
354 return ; All done.
355
356 fix_buffered_dive: ; Yes, fix and save it
357 rcall ext_flash_disable_protection ; Disable write protection for external flash
358 banksel buffer
359 ; Set to 1.81
360 movlw .81
361 movwf buffer+.49
362 ; Fix wrong profile length
363 movlw .3
364 subwf buffer+.9,F
365 movlw d'0'
366 subwfb buffer+.10,F
367 subwfb buffer+.11,F
368 banksel common
369 ; save result into external flash again
370 rcall fix_set_to_toc_start
371 clrf lo
372 lfsr FSR0,buffer+0
373 fix_buffered_dive2:
374 movf POSTINC0,W
375 rcall write_byte_ext_flash_plus_header; Write from WREG and increase address after write
376 decfsz lo,F ; All done?
377 bra fix_buffered_dive2 ; No, continue
378 return
379
380 fix_check_buffer: ; Check the buffered dive
381 movff buffer+.48,temp1
382 movlw .1
383 cpfseq temp1 ; buffer+.48 = .1 ?
384 retlw .0 ; No, abort
385 movff buffer+.49,temp1
386 movlw .80
387 cpfseq temp1 ; buffer+.49 = .80 ?
388 retlw .0 ; No, abort
389 retlw .1 ; Yes, fix this dive
390
391 fix_load_dive_into_buffer: ; Load header #divesecs into buffer:256
392 rcall fix_set_to_toc_start
393 clrf lo
394 lfsr FSR0,buffer+0
395 fix_load_dive_into_buffer2:
396 rcall ext_flash_byte_read_plus ; increase address after read
397 movff temp1,POSTINC0 ; copy into buffer
398 decfsz lo,F ; All done?
399 bra fix_load_dive_into_buffer2 ; No, continue
400
401 fix_set_to_toc_start:
402 clrf ext_flash_address+0
403 clrf ext_flash_address+1
404 movlw 0x20
405 movwf ext_flash_address+2
406 movlw .16
407 mulwf divesecs; divesecs*16 = offset to 0x2000 (up:hi)
408 movf PRODL,W
409 addwf ext_flash_address+1,F
410 movf PRODH,W
411 addwfc ext_flash_address+2,F
412 ; pointer at the first 0xFA of header
413 return
414
415
416 END 344 END