Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store tag count in one place #120

Merged
merged 1 commit into from
Jun 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 19 additions & 14 deletions src/Modules/Eeprom.asm
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
;
;**** **** **** **** **** **** **** **** **** **** **** **** ****

ESC_LAYOUT_SIZE EQU 48
MELODY_SIZE EQU 140


;**** **** **** **** **** **** **** **** **** **** **** **** ****
;
; Read all eeprom parameters
Expand Down Expand Up @@ -88,7 +92,7 @@ read_eeprom_exit:
;**** **** **** **** **** **** **** **** **** **** **** **** ****
erase_and_store_all_in_eeprom:
clr IE_EA ; Disable interrupts
call read_tags
call read_esc_layout
call read_melody
call erase_flash ; Erase flash

Expand Down Expand Up @@ -127,7 +131,7 @@ write_eeprom_block2:
djnz Temp4, write_eeprom_block2

; Now write tags, melogy and signature
call write_tags
call write_esc_layout
call write_melody
call write_eeprom_signature
mov DPTR, #Eep_Dummy ; Set pointer to uncritical area
Expand Down Expand Up @@ -205,42 +209,43 @@ write_eeprom_signature:
ret

;**** **** **** **** **** **** **** **** **** **** **** **** ****
; Read all tags from flash and store in temporary storage
; Read esc layout bytes from flash and store in temporary storage
;**** **** **** **** **** **** **** **** **** **** **** **** ****
read_tags:
mov Temp3, #48 ; Number of tags
read_esc_layout:
mov Temp3, #ESC_LAYOUT_SIZE ; Number of esc layout bytes
mov Temp2, #Temp_Storage ; Set RAM address
mov Temp1, #Bit_Access
mov DPTR, #Eep_ESC_Layout ; Set flash address
read_tag:
read_esc_layout_byte:
call read_eeprom_byte
mov A, Bit_Access
mov @Temp2, A ; Write to RAM
inc Temp2
inc DPTR
djnz Temp3, read_tag
djnz Temp3, read_esc_layout_byte
ret

;**** **** **** **** **** **** **** **** **** **** **** **** ****
; Write all tags from temporary storage and store in flash
; Write all esc layout bytes from temporary storage and
; store them in flash
;**** **** **** **** **** **** **** **** **** **** **** **** ****
write_tags:
mov Temp3, #48 ; Number of tags
write_esc_layout:
mov Temp3, #ESC_LAYOUT_SIZE ; Number of esc layout bytes
mov Temp2, #Temp_Storage ; Set RAM address
mov DPTR, #Eep_ESC_Layout ; Set flash address
write_tag:
write_esc_layout_byte:
mov A, @Temp2 ; Read from RAM
call write_eeprom_byte_from_acc
inc Temp2
inc DPTR
djnz Temp3, write_tag
djnz Temp3, write_esc_layout_byte
ret

;**** **** **** **** **** **** **** **** **** **** **** **** ****
; Read bytes from flash and store in external memory
;**** **** **** **** **** **** **** **** **** **** **** **** ****
read_melody:
mov Temp3, #140 ; Number of bytes
mov Temp3, #MELODY_SIZE ; Number of bytes
mov Temp2, #0 ; Set XRAM address
mov Temp1, #Bit_Access
mov DPTR, #Eep_Pgm_Beep_Melody ; Set flash address
Expand All @@ -257,7 +262,7 @@ read_melody_byte:
; Write bytes from external memory and store in flash
;**** **** **** **** **** **** **** **** **** **** **** **** ****
write_melody:
mov Temp3, #140 ; Number of bytes
mov Temp3, #MELODY_SIZE ; Number of bytes
mov Temp2, #0 ; Set XRAM address
mov DPTR, #Eep_Pgm_Beep_Melody ; Set flash address
write_melody_byte:
Expand Down