diff src/eeprom_rs232.inc @ 634:4050675965ea

3.10 stable release
author heinrichsweikamp
date Tue, 28 Apr 2020 17:34:31 +0200
parents 185ba2f91f59
children aeca5717d9eb
line wrap: on
line diff
--- a/src/eeprom_rs232.inc	Thu Mar 05 15:06:14 2020 +0100
+++ b/src/eeprom_rs232.inc	Tue Apr 28 17:34:31 2020 +0200
@@ -1,6 +1,6 @@
 ;=============================================================================
 ;
-;   File eeprom_rs232.inc                     combined next generation V3.08.8
+;   File eeprom_rs232.inc                   * combined next generation V3.09.4n
 ;
 ;
 ;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
@@ -9,150 +9,6 @@
 ;  2011-08-03 : [mH] moving from OSTC code
 
 
-; --------------------------------------------------------------------------------------------
-;           EEPROM read & write Macros
-; --------------------------------------------------------------------------------------------
-
-
-; read 1 byte from EEPROM to memory
-;
-; eeprom_address: address:2 containing source address in EEPROM
-; memory_address: address:2 containing target address in memory
-;
-EEPROM_CC_READ		macro	eeprom_address, memory_address
-	movlw	HIGH(eeprom_address)	; extract bank in EEPROM
-	movwf	EEADRH					; set     bank in EEPROM
-	movlw	LOW (eeprom_address)	; extract start address in EEPROM
-	movwf	EEADR					; set     start address in EEPROM
-	call	read_eeprom				; read from EEPROM
-	movff	EEDATA,memory_address	; store to memory
-	endm
-
-
-; read 2 bytes from EEPROM to memory, both bytes must be in same EEPROM bank
-;
-; eeprom_address: address:2 containing start address in EEPROM
-; memory_address: address:2 containing start address in memory
-;
-EEPROM_II_READ		macro	eeprom_address, memory_address
-	movlw	HIGH(eeprom_address)	; extract bank in EEPROM
-	movwf	EEADRH					; set     bank in EEPROM
-	movlw	LOW (eeprom_address)	; extract start address in EEPROM
-	movwf	EEADR					; set     start address in EEPROM
-	lfsr	FSR1,memory_address		; set start address in memory
-	movlw	.2						; read  2 bytes
-	call	eeprom_read_common		; execute read
-	endm
-
-
-; read 3 bytes from EEPROM to memory, all bytes must be in same EEPROM bank
-;
-; eeprom_address: address:2 containing start address in EEPROM
-; memory_address: address:2 containing start address in memory
-;
-EEPROM_TT_READ		macro	eeprom_address, memory_address
-	movlw	HIGH(eeprom_address)	; extract bank in EEPROM
-	movwf	EEADRH					; set     bank in EEPROM
-	movlw	LOW (eeprom_address)	; extract start address in EEPROM
-	movwf	EEADR					; set     start address in EEPROM
-	lfsr	FSR1,memory_address		; set start address in memory
-	movlw	.3						; read  3 bytes
-	call	eeprom_read_common		; execute read
-	endm
-
-
-; read a range of bytes from EEPROM to memory, all bytes must be in same EEPROM bank
-;
-; eeprom_address: address:2 containing start address in EEPROM
-; memory_address: address:2 containing start address in memory (bank safe)
-; range         : number of bytes to read (1-256), will wrap-around staying in same EEPROM bank!
-;
-EEPROM_RR_READ		macro	eeprom_address, memory_address, range
-	movlw	HIGH(eeprom_address)	; extract bank in EEPROM
-	movwf	EEADRH					; set     bank in EEPROM
-	movlw	LOW (eeprom_address)	; extract start address in EEPROM
-	movwf	EEADR					; set     start address in EEPROM
-	lfsr	FSR1,memory_address		; set start address in memory
-	movlw	low(range)				; set size of range to read
-	call	eeprom_read_common		; execute read
-	endm
-
-
-; write 1 byte from memory to EEPROM
-;
-; memory_address: address:2 containing source      address in memory (bank safe)
-; eeprom_address: address:2 containing destination address in EEPROM
-;
-EEPROM_CC_WRITE		macro	memory_address, eeprom_address
-	movlw	HIGH(eeprom_address)	; extract bank in EEPROM
-	movwf	EEADRH					; set     bank in EEPROM
-	movlw	LOW (eeprom_address)	; extract start address in EEPROM
-	movwf	EEADR					; set     start address in EEPROM
-	movff	memory_address,EEDATA	; copy byte to EEPROM data register
-	call	write_eeprom			; execute write
-	endm
-
-
-; write 2 bytes from memory to EEPROM, both bytes must go into the same EEPROM bank
-;
-; memory_address: address:2 containing start address in memory (bank safe)
-; eeprom_address: address:2 containing start address in EEPROM
-;
-EEPROM_II_WRITE		macro	memory_address, eeprom_address
-	movlw	HIGH(eeprom_address)	; extract bank in EEPROM
-	movwf	EEADRH					; set     bank in EEPROM
-	movlw	LOW (eeprom_address)	; extract start address in EEPROM
-	movwf	EEADR					; set     start address in EEPROM
-	lfsr	FSR1,memory_address		; set start address in memory
-	movlw	.2						; write 2 bytes
-	call	eeprom_write_common		; execute write
-	endm
-
-
-; write 3 bytes from memory to EEPROM, all bytes must go into the same EEPROM bank
-;
-; memory_address: address:2 containing start address in memory (bank safe)
-; eeprom_address: address:2 containing start address in EEPROM
-;
-EEPROM_TT_WRITE		macro	memory_address, eeprom_address
-	movlw	HIGH(eeprom_address)	; extract bank in EEPROM
-	movwf	EEADRH					; set     bank in EEPROM
-	movlw	LOW (eeprom_address)	; extract start address in EEPROM
-	movwf	EEADR					; set     start address in EEPROM
-	lfsr	FSR1,memory_address		; set start address in memory
-	movlw	.3						; write 3 bytes
-	call	eeprom_write_common		; execute write
-	endm
-
-
-; write a range of bytes from memory to EEPROM, all bytes must go into the same EEPROM bank
-;
-; memory_address: address:2 containing start address in memory (bank safe)
-; eeprom_address: address:2 containing start address in EEPROM
-; range         : number of bytes to write (1-256), will wrap-around staying in same EEPROM bank!
-;
-EEPROM_RR_WRITE		macro	memory_address, eeprom_address, range
-	movlw	HIGH(eeprom_address)	; extract bank in EEPROM
-	movwf	EEADRH					; set     bank in EEPROM
-	movlw	LOW (eeprom_address)	; extract start address in EEPROM
-	movwf	EEADR					; set     start address in EEPROM
-	lfsr	FSR1,memory_address		; set start address in memory
-	movlw	low(range)				; set size of range to write
-	call	eeprom_write_common		; execute write
-	endm
-
-
-; set up EEPROM address register for subsequent read/write operations
-;
-; eeprom_address: address:2 containing the EEPROM address to set up
-;
-EEPROM_SET_ADDRESS	macro	eeprom_address							; Set EEPROM address
-	movlw	HIGH(eeprom_address)	; extract bank in EEPROM		; for subsequent calls to
-	movwf	EEADRH					; set     EEPROM bank			; write_eeprom / read_eeprom
-	movlw	LOW (eeprom_address)	; extract start address in EEPROM
-	movwf	EEADR					; set     EEPROM cell
-	endm
-
 
 ; --------------------------------------------------------------------------------------------
 ;       EEPROM Defines
@@ -177,7 +33,8 @@
 #DEFINE eeprom_log_offset				0x00D		; | 2  offset between OSTC dive counting and user's counting
 #DEFINE eeprom_battery_type				0x00F		; | 1  battery type inside the OSTC
 #DEFINE eeprom_options_version			0x010		;   2  options version identifier
-;										0x012		;   8  unused
+#DEFINE eeprom_fw_chksum_current		0x012		;   6  checksum of the current firmware *)
+;										0x018		;   2  unused
 #DEFINE eeprom_options_storage			0x01A		; 486  backup storage for the options
 
 
@@ -201,37 +58,208 @@
 #DEFINE eeprom_prog_page0_backup		0x300		; 128  backup storage for the first program memory page
 ;										0x380		;   1  unused
 #DEFINE eeprom_button_polarity			0x381		;   1  button polarity (factory use only, do not change position!)
-;										0x382		; 126  unused
+#DEFINE eeprom_fw_chksum_recovry		0x382		;   6  checksum of stored recovery firmware *)
+;										0x388		; 121  unused
+
+
+; *) 4 byte code checksum, 1 byte checksum of the checksum, 1 byte firmware ID
 
 
 
 ; --------------------------------------------------------------------------------------------
-;           Serial read & write Macros
+;
+;           EEPROM read & write Macros
+;
 ; --------------------------------------------------------------------------------------------
 
-; receive 1 byte and write to memory, in case of timeout the flag 'rs232_rx_timeout' will be set
+
+;-----------------------------------------------------------------------------
+; read 1 byte from EEPROM to memory
+;
+; eeprom_address: address:2 containing source address in EEPROM
+; memory_address: address:2 containing target address in memory
+;
+EEPROM_CC_READ		macro	eeprom_address, memory_address
+	movlw	HIGH(eeprom_address)	; extract bank in EEPROM
+	movwf	EEADRH					; set     bank in EEPROM
+	movlw	LOW (eeprom_address)	; extract start address in EEPROM
+	movwf	EEADR					; set     start address in EEPROM
+	call	read_eeprom				; read from EEPROM
+	movff	EEDATA,memory_address	; store to memory
+	endm
+
+
+;-----------------------------------------------------------------------------
+; read 2 bytes from EEPROM to memory, both bytes need to be in same EEPROM bank
+;
+; eeprom_address: address:2 containing start address in EEPROM
+; memory_address: address:2 containing start address in memory
+;
+EEPROM_II_READ		macro	eeprom_address, memory_address
+	movlw	HIGH(eeprom_address)	; extract bank in EEPROM
+	movwf	EEADRH					; set     bank in EEPROM
+	movlw	LOW (eeprom_address)	; extract start address in EEPROM
+	movwf	EEADR					; set     start address in EEPROM
+	lfsr	FSR1,memory_address		; set start address in memory
+	movlw	.2						; read  2 bytes
+	call	eeprom_read_common		; execute read
+	endm
+
+
+;-----------------------------------------------------------------------------
+; read 3 bytes from EEPROM to memory, all bytes need to be in same EEPROM bank
+;
+; eeprom_address: address:2 containing start address in EEPROM
+; memory_address: address:2 containing start address in memory
+;
+EEPROM_TT_READ		macro	eeprom_address, memory_address
+	movlw	HIGH(eeprom_address)	; extract bank in EEPROM
+	movwf	EEADRH					; set     bank in EEPROM
+	movlw	LOW (eeprom_address)	; extract start address in EEPROM
+	movwf	EEADR					; set     start address in EEPROM
+	lfsr	FSR1,memory_address		; set start address in memory
+	movlw	.3						; read  3 bytes
+	call	eeprom_read_common		; execute read
+	endm
+
+
+;-----------------------------------------------------------------------------
+; read a range of bytes from EEPROM to memory, all bytes need to be in same EEPROM bank
+;
+; eeprom_address: address:2 containing start address in EEPROM
+; memory_address: address:2 containing start address in memory (bank safe)
+; range         : number of bytes to read (1-256), will wrap-around staying in same EEPROM bank!
+;
+EEPROM_RR_READ		macro	eeprom_address, memory_address, range
+	movlw	HIGH(eeprom_address)	; extract bank in EEPROM
+	movwf	EEADRH					; set     bank in EEPROM
+	movlw	LOW (eeprom_address)	; extract start address in EEPROM
+	movwf	EEADR					; set     start address in EEPROM
+	lfsr	FSR1,memory_address		; set start address in memory
+	movlw	low(range)				; set size of range to read
+	call	eeprom_read_common		; execute read
+	endm
+
+
+;-----------------------------------------------------------------------------
+; write 1 byte from memory to EEPROM
+;
+; memory_address: address:2 containing source      address in memory (bank safe)
+; eeprom_address: address:2 containing destination address in EEPROM
+;
+EEPROM_CC_WRITE		macro	memory_address, eeprom_address
+	movlw	HIGH(eeprom_address)	; extract bank in EEPROM
+	movwf	EEADRH					; set     bank in EEPROM
+	movlw	LOW (eeprom_address)	; extract start address in EEPROM
+	movwf	EEADR					; set     start address in EEPROM
+	movff	memory_address,EEDATA	; copy byte to EEPROM data register
+	call	write_eeprom			; execute write
+	endm
+
+
+;-----------------------------------------------------------------------------
+; write 2 bytes from memory to EEPROM, both bytes need to go into the same EEPROM bank
+;
+; memory_address: address:2 containing start address in memory (bank safe)
+; eeprom_address: address:2 containing start address in EEPROM
+;
+EEPROM_II_WRITE		macro	memory_address, eeprom_address
+	movlw	HIGH(eeprom_address)	; extract bank in EEPROM
+	movwf	EEADRH					; set     bank in EEPROM
+	movlw	LOW (eeprom_address)	; extract start address in EEPROM
+	movwf	EEADR					; set     start address in EEPROM
+	lfsr	FSR1,memory_address		; set start address in memory
+	movlw	.2						; write 2 bytes
+	call	eeprom_write_common		; execute write
+	endm
+
+
+;-----------------------------------------------------------------------------
+; write 3 bytes from memory to EEPROM, all bytes need to go into the same EEPROM bank
+;
+; memory_address: address:2 containing start address in memory (bank safe)
+; eeprom_address: address:2 containing start address in EEPROM
+;
+EEPROM_TT_WRITE		macro	memory_address, eeprom_address
+	movlw	HIGH(eeprom_address)	; extract bank in EEPROM
+	movwf	EEADRH					; set     bank in EEPROM
+	movlw	LOW (eeprom_address)	; extract start address in EEPROM
+	movwf	EEADR					; set     start address in EEPROM
+	lfsr	FSR1,memory_address		; set start address in memory
+	movlw	.3						; write 3 bytes
+	call	eeprom_write_common		; execute write
+	endm
+
+
+;-----------------------------------------------------------------------------
+; write a range of bytes from memory to EEPROM, all bytes need to go into the same EEPROM bank
+;
+; memory_address: address:2 containing start address in memory (bank safe)
+; eeprom_address: address:2 containing start address in EEPROM
+; range         : number of bytes to write (1-256), will wrap-around staying in same EEPROM bank!
+;
+EEPROM_RR_WRITE		macro	memory_address, eeprom_address, range
+	movlw	HIGH(eeprom_address)	; extract bank in EEPROM
+	movwf	EEADRH					; set     bank in EEPROM
+	movlw	LOW (eeprom_address)	; extract start address in EEPROM
+	movwf	EEADR					; set     start address in EEPROM
+	lfsr	FSR1,memory_address		; set start address in memory
+	movlw	low(range)				; set size of range to write
+	call	eeprom_write_common		; execute write
+	endm
+
+
+;-----------------------------------------------------------------------------
+; set up EEPROM address register for subsequent read/write operations
+;
+; eeprom_address: address:2 containing the EEPROM address to set up
+;
+EEPROM_SET_ADDRESS	macro	eeprom_address							; Set EEPROM address
+	movlw	HIGH(eeprom_address)	; extract bank in EEPROM		; for subsequent calls to
+	movwf	EEADRH					; set     EEPROM bank			; write_eeprom / read_eeprom
+	movlw	LOW (eeprom_address)	; extract start address in EEPROM
+	movwf	EEADR					; set     EEPROM cell
+	endm
+
+
+
+; --------------------------------------------------------------------------------------------
+;
+;           Serial Read & Write Macros
+;
+; --------------------------------------------------------------------------------------------
+
+
+;-----------------------------------------------------------------------------
+; Receive 1 Byte and write to Memory
+;
+; in case of a Timeout the Flag 'rs232_rx_timeout' will be set
 ;
 SERIAL_CC_RECEIVE	macro	mem_address
-	call	rs232_get_byte				; (try to) receive one byte
+	extern	serial_rx_single
+	call	serial_rx_single			; (try to) receive one byte
 	movff	RCREG1,mem_address			; copy received byte to memory
 	endm
 
 
-; stream a range of bytes to memory, in case of timeout the flag 'rs232_rx_timeout' will be set
+;-----------------------------------------------------------------------------
+; Stream a Range of Bytes to Memory
+;
+; in case of a Timeout the Flag 'rs232_rx_timeout' will be set
 ;
 ; mem_address: address:2 containing the start address in memory (bank safe)
 ; range      : number of bytes to receive (1-256)
 ;
-SERIAL_RR_RECEIVE_RAM	macro	mem_address, range
+SERIAL_RR_RECEIVE	macro	mem_address, range
 	lfsr	FSR2,mem_address			; set start address in memory
 	movlw	low(range)					; set number of bytes to receive
-	extern	serial_rx_stream_ram
-	call	serial_rx_stream_ram
+	extern	serial_rx_stream
+	call	serial_rx_stream
 	endm
 
 
-
-; send 1 byte literal
+;-----------------------------------------------------------------------------
+; Send 1 Byte Literal
 ;
 SERIAL_LC_SEND	macro	literal
 	call	rs232_wait_tx				; wait for completion of last transmit
@@ -240,7 +268,8 @@
 	endm
 
 
-; send 1 byte from memory
+;-----------------------------------------------------------------------------
+; Send 1 Byte from Memory
 ;
 ; mem_address: address:2 containing the source address in memory (bank safe)
 ;
@@ -250,16 +279,17 @@
 	endm
 
 
-; send a range of bytes from memory
+;-----------------------------------------------------------------------------
+; Send a Range of Bytes from Memory
 ;
 ; mem_address: address:2 containing the start address in memory (bank safe)
 ; range      : number of bytes to send (1-256)
 ;
-SERIAL_RR_SEND_RAM	macro	mem_address, range
+SERIAL_RR_SEND	macro	mem_address, range
 	lfsr	FSR2,mem_address			; set start address in memory
 	movlw	low(range)					; set number of bytes to send
-	extern	serial_tx_ram
-	call	serial_tx_ram
+	extern	serial_tx_steam
+	call	serial_tx_steam
 	endm
 
 
@@ -297,16 +327,15 @@
 
 ; Serial - IR / S8
 
-	extern	enable_ir_s8
-	extern	disable_ir_s8
-	extern	ir_s8_wait_tx
+	extern	enable_ir_s8_analog
+	extern	disable_ir_s8_analog
+	extern	ir_s8_tx_single
 
 
 ; Serial - RS232 (USB / BT)
 
 	extern	enable_rs232
 	extern	disable_rs232
-	extern	rs232_get_byte
 	extern	rs232_wait_tx