changeset 351:5c186a72cb5d 64kByte Logbook

Debugging the new logbook format, 64kB download routine
author heinrichsweikamp
date Tue, 31 May 2011 22:09:17 +0200
parents 7250ca7c8d24
children 544a96faa9f3
files code_part1/OSTC_code_asm_part1/definitions.asm code_part1/OSTC_code_asm_part1/divemode.asm code_part1/OSTC_code_asm_part1/interface.asm code_part1/OSTC_code_asm_part1/menu_logbook.asm
diffstat 4 files changed, 69 insertions(+), 107 deletions(-) [+]
line wrap: on
line diff
--- a/code_part1/OSTC_code_asm_part1/definitions.asm	Tue May 31 19:43:29 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/definitions.asm	Tue May 31 22:09:17 2011 +0200
@@ -34,9 +34,9 @@
 ;#DEFINE	GERMAN							; Use german_text.asm
 ;#DEFINE	SPANISH							; Use spanish_text.asm
 
-;#DEFINE	__DEBUG	; 
+#DEFINE	__DEBUG	; 
 
-#DEFINE	logbook_profile_version	0x20        ; Do not touch!
+#DEFINE	logbook_profile_version	0x21        ; Do not touch!
 #DEFINE	T0CON_debounce	b'00000000'         ; Timer0 Switch Debounce
 
 #DEFINE		FT_SMALL		.0
--- a/code_part1/OSTC_code_asm_part1/divemode.asm	Tue May 31 19:43:29 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/divemode.asm	Tue May 31 22:09:17 2011 +0200
@@ -589,7 +589,7 @@
 
 ; shift address for header
 ; the header will be stored after the dive
-	incf_eeprom_address	d'47'				; Macro, that adds 8Bit to eeprom_address:2 with banking at 0x8000
+	incf_eeprom_address	d'57'				; Macro, that adds 8Bit to eeprom_address:2 with banking at 0x8000
 
 store_dive_data2:
     SAFE_2BYTE_COPY rel_pressure, lo
@@ -1333,7 +1333,27 @@
 	movff	char_O_CNS_fraction,WREG	; copy into bank1
 	call	write_external_eeprom		; Stores CNS%
 
-; Add additional 10bytes here.... mH
+	movff	avr_rel_pressure_total+0,WREG	; Average Depth
+	call	write_external_eeprom
+	movff	avr_rel_pressure_total+1,WREG	; Average Depth
+	call	write_external_eeprom
+	
+	clrf	WREG
+	call	write_external_eeprom			; Spare8
+	clrf	WREG
+	call	write_external_eeprom			; Spare7
+	clrf	WREG
+	call	write_external_eeprom			; Spare6
+	clrf	WREG
+	call	write_external_eeprom			; Spare5
+	clrf	WREG
+	call	write_external_eeprom			; Spare4
+	clrf	WREG
+	call	write_external_eeprom			; Spare3
+	clrf	WREG
+	call	write_external_eeprom			; Spare2
+	clrf	WREG
+	call	write_external_eeprom			; Spare1
 
 	movlw	0xFB						; Header stop
 	call	write_external_eeprom
--- a/code_part1/OSTC_code_asm_part1/interface.asm	Tue May 31 19:43:29 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/interface.asm	Tue May 31 22:09:17 2011 +0200
@@ -167,14 +167,16 @@
 
 	DISPLAYTEXT .18						; "Header"
 
-	clrf		uart1_temp					; low address counter
-	clrf		uart2_temp					; high address counter
+	setf		uart1_temp					; low address counter
+	setf		uart2_temp					; high address counter
 
 menu_interface3:
 	bsf		SSPCON2,SEN					; Start condition
 	call		WaitMSSP
 
-	movlw		b'10100110'					; Bit0=0: WRITE, Bit0=1: READ
+	movlw		b'10101110'			; Bit0=0: WRITE, Bit0=1: READ, BLOCK2
+	btfss		eeprom_address+1,7	; Access Block2?
+	movlw		b'10100110'			; No, -> Bit0=0: WRITE, Bit0=1: READ, BLOCK1
 	movwf		SSPBUF					; control byte
 	call		WaitMSSP	
 	btfsc		SSPCON2,ACKSTAT
@@ -189,7 +191,10 @@
 	bsf		SSPCON2,RSEN				; Start condition
 	call		WaitMSSP
 
-	movlw		b'10100111'					; Bit0=0: WRITE, Bit0=1: READ
+	movlw		b'10101111'			; Bit0=0: WRITE, Bit0=1: READ, BLOCK2
+	btfss		eeprom_address+1,7	; Access Block2?
+	movlw		b'10100111'			; No, -> Bit0=0: WRITE, Bit0=1: READ, BLOCK1
+
 	movwf		SSPBUF					; control byte
 	call		WaitMSSP	
 	call		I2C_WaitforACK
@@ -199,78 +204,20 @@
 menu_interface2:
 	call		rs232_wait_tx				; wait for UART
 
-	bsf			SSPCON2, RCEN				; Enable recieve mode
-	call		WaitMSSP	
-
-	movff		SSPBUF, TXREG
-
 	movlw		d'1'
 	addwf		uart1_temp,F
 	movlw		d'0'
 	addwfc		uart2_temp,F
 
-	btfsc		uart2_temp,7				; 32KB done?
-	bra			menu_interface4				; Yes
-	
-	bsf			SSPCON2, ACKEN				; Ack
-	call		WaitMSSP	
-	bra			menu_interface2				; go on
-
-menu_interface4:
-	bsf			SSPCON2, PEN				; Stop
-	call		WaitMSSP	
-
-
-	clrf		uart1_temp					; low address counter
-	clrf		uart2_temp					; high address counter
-
-menu_interface5:		;Send another 32kB from Block2....
-	bsf		SSPCON2,SEN					; Start condition
-	call		WaitMSSP
-
-	movlw		b'10101110'					; Bit0=0: WRITE, Bit0=1: READ
-	movwf		SSPBUF					; control byte
-	call		WaitMSSP	
-	btfsc		SSPCON2,ACKSTAT
-	bra		menu_interface5				; No Ack, try again!
-	
-	movff		eeprom_address+1,SSPBUF			; High Address byte
-	call		WaitMSSP	
-	call		I2C_WaitforACK
-	movff		eeprom_address+0,SSPBUF			; Low Address byte
-	call		WaitMSSP	
-	call		I2C_WaitforACK
-	bsf		SSPCON2,RSEN				; Start condition
-	call		WaitMSSP
-
-	movlw		b'10101111'					; Bit0=0: WRITE, Bit0=1: READ
-	movwf		SSPBUF					; control byte
-	call		WaitMSSP	
-	call		I2C_WaitforACK
-
-menu_interface6:
-	call		rs232_wait_tx				; wait for UART
-
-	bsf			SSPCON2, RCEN				; Enable recieve mode
-	call		WaitMSSP	
-
+; Slow but safe...
+	call		I2CREAD2					; same as I2CREAD but with automatic address increase 
 	movff		SSPBUF, TXREG
 
-	movlw		d'1'
-	addwf		uart1_temp,F
-	movlw		d'0'
-	addwfc		uart2_temp,F
-
-	btfsc		uart2_temp,7				; 32KB done?
-	bra			menu_interface7				; Yes
-	
-	bsf			SSPCON2, ACKEN				; Ack
-	call		WaitMSSP	
-	bra			menu_interface6				; go on
-
-menu_interface7:
-	bsf			SSPCON2, PEN				; Stop
-	call		WaitMSSP	
+	movlw		0xFF
+	cpfseq		uart2_temp					;=0xFFFF?
+	bra			menu_interface2				; No, continue
+	cpfseq		uart1_temp					;=0xFFFF?
+	bra			menu_interface2				; No, continue
 
 	DISPLAYTEXT	.20						; Done.
 
--- a/code_part1/OSTC_code_asm_part1/menu_logbook.asm	Tue May 31 19:43:29 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/menu_logbook.asm	Tue May 31 22:09:17 2011 +0200
@@ -71,21 +71,27 @@
 
     ;---- fast loop: check every other byte ----------------------------------
 menu_logbook2:
-    infsnz      divemins+0,F            ; increase 16Bit value
-	incf        divemins+1,F
-    infsnz      divemins+0,F            ; increase 16Bit value, twice
-	incf        divemins+1,F
+	movlw		d'2'
+	addwf		divemins+0,F
+	movlw		d'0'
+	addwfc		divemins+1,F			; increase 16Bit value, twice
 
-	movlw		0xFF					
+	movlw		0xFF
+	cpfseq		divemins+1				; =0xFFFF ?
+	bra			menu_logbook2a			; No
 	cpfseq		divemins+0				; =0xFFFF ?
 	bra			menu_logbook2a			; No
-
-	cpfseq		divemins+1				; =0xFFFF ?
-	bra			menu_logbook2a			; No
-
 	bra			menu_logbook_reset      ; yes, restart (if not empty)
 
 menu_logbook2a:
+	movlw		0x00
+	cpfseq		divemins+1				; =0x0000 ?
+	bra			menu_logbook2b			; No
+	cpfseq		divemins+0				; =0x0000 ?
+	bra			menu_logbook2b			; No
+	bra			menu_logbook_reset      ; yes, restart (if not empty)
+
+menu_logbook2b:
 	decf_eeprom_address	d'2'			; -2 to eeprom address.
 
 	call		I2CREAD					; reads one byte (Slow! Better use Blockread!)
@@ -131,6 +137,7 @@
 	bra			menu_logbook3b				; No, Nothing to do
 
 	bsf			all_dives_shown				; Yes
+	bsf			logbook_page_not_empty
 	bra			menu_logbook_display_loop2	; rcall of get_free_eeprom_location not required here (faster)
 
 
@@ -456,9 +463,6 @@
 	call		I2CREAD2				; read Air pressure
 	movff		SSPBUF,hi
 
-;	movff		lo,average_depth_hold+2
-;	movff		hi,average_depth_hold+3		; Store here for correct average
-
 	bsf			leftbind
 	output_16							; Air pressure before dive
 	STRCAT      "mbar "
@@ -514,17 +518,13 @@
 	movff		SSPBUF,divisor_nuy2			; Store divisor
 	incf_eeprom_address	d'2'				; Skip 2Bytes in EEPROM (faster)
 	; 2 bytes salinity, GF
+	btfss	logbook_format_0x21				; 10byte extra?
+	bra		display_profile2d				; No
+	incf_eeprom_address	d'10'				; Skip another 10 byte from the header for 0x21 format
+	; Average Depth, spare bytes
 
 display_profile2d:
 	; Start Profile display
-
-;	clrf		average_divesecs+0
-;	clrf		average_divesecs+1			; Counts x-pixels for average
-;	clrf		average_depth_hold_total+0
-;	clrf		average_depth_hold_total+1
-;	clrf		average_depth_hold_total+2
-;	clrf		average_depth_hold_total+3	; Track average depth here...
-;
 ; Write 0m X-Line..
 	movlw		color_grey	
 	call		PLED_set_color				; Make this configurable?
@@ -969,18 +969,6 @@
 	return
 
 profile_view_get_depth_new1:
-;	incf		average_divesecs+0,F			
-;	movlw		d'0'
-;	addwfc		average_divesecs+1,F			; counter for average depth
-;	; add depth to average registers
-;	movf		lo,W
-;	addwf		average_depth_hold_total+0,F
-;	movf		hi,W
-;	addwfc		average_depth_hold_total+1,F
-;	movlw		d'0'
-;	addwfc		average_depth_hold_total+2,F
-;	addwfc		average_depth_hold_total+3,F 	; Will work up to 9999mBar*60*60*24=863913600mBar
-;
 	btfsc		event_occured				; Was there an event attached to this sample?
 	rcall		profile_view_get_depth_new2	; Yes, get information about this event
 
@@ -1025,7 +1013,6 @@
 	call		PLED_set_color				; Set Color...
 	return		;(The two bytes indicating the manual gas change will be ignored in the standard "ignore loop" above...)
 
-
 ;Keep comments for future temperature graph
 ;	call		I2CREAD2					; ignore byte
 ;	decfsz		timeout_counter2,F			; reduce counter
@@ -1135,6 +1122,11 @@
 	cpfsgt		lo							; Skip if lo>13
 	bra			display_listdive2			; use old (Pre 0x20) format
 
+	bsf			logbook_format_0x21		; Set flag for new 0x21 Format
+	movlw		0x21
+	cpfseq		lo						; Skip if 0x21
+	bcf			logbook_format_0x21		; Clear flag for new 0x21 Format
+
 	call		I2CREAD4					; Skip Profile version (Block read)
 	movff		SSPBUF,lo					; in new format, read month
 
@@ -1168,4 +1160,7 @@
 	output_16								; Divetime minutes
 	STRCAT_PRINT "'"                    	; Display header-row in list
 	incf_eeprom_address	d'37'				; 12 Bytes read from header, skip 37 Bytes in EEPROM (Remaining Header)
-	return
+	btfss	logbook_format_0x21				; 10byte extra?
+	return									; No, Done.
+	incf_eeprom_address	d'10'				; Skip another 10 byte from the header for 0x21 format
+	return
\ No newline at end of file