changeset 245:dee88c962653

Some clean up and minor I2C speed improvements
author heinrichsweikamp
date Thu, 24 Mar 2011 21:51:36 +0100
parents 976260083540
children 90af80e57b49
files code_part1/OSTC_code_asm_part1/changelog.txt code_part1/OSTC_code_asm_part1/i2c_eeprom.asm code_part1/OSTC_code_asm_part1/isr.asm code_part1/OSTC_code_asm_part1/menu_logbook.asm
diffstat 4 files changed, 50 insertions(+), 56 deletions(-) [+]
line wrap: on
line diff
--- a/code_part1/OSTC_code_asm_part1/changelog.txt	Wed Mar 23 23:23:06 2011 +0100
+++ b/code_part1/OSTC_code_asm_part1/changelog.txt	Thu Mar 24 21:51:36 2011 +0100
@@ -4,6 +4,7 @@
 NEW: High altitude (Plane/Fly) mode added
 NEW: Gaslist, Salinity, Gradient Factors and Average depth displayed in Logbook
 
+
 New in 1.83 beta:
 BETA Version - Do NOT use for diving!
 BUGFIX: gas switch
--- a/code_part1/OSTC_code_asm_part1/i2c_eeprom.asm	Wed Mar 23 23:23:06 2011 +0100
+++ b/code_part1/OSTC_code_asm_part1/i2c_eeprom.asm	Thu Mar 24 21:51:36 2011 +0100
@@ -220,6 +220,43 @@
 	
 	
 I2CREAD:
+	rcall		I2CREAD_COMMON
+	bsf			SSPCON2, PEN	; Stop
+	rcall		WaitMSSP	
+	return
+
+I2CREAD2:						; same as I2CREAD but with automatic address increase 
+	rcall		I2CREAD
+I2CREAD2_2:
+	movlw		d'1'
+	addwf		eeprom_address+0,F
+	movlw		d'0'
+	addwfc		eeprom_address+1,F
+	bcf			eeprom_overflow		
+	btfss		eeprom_address+1,7	; at 0x8000?
+	return		; no, return
+	
+	clrf		eeprom_address+0	; Yes, clear address
+	clrf		eeprom_address+1
+	bsf			eeprom_overflow		; and set overflow bit
+	return
+
+I2CREAD3:						; block read start with automatic address increase 
+	rcall		I2CREAD_COMMON
+	; no Stop condition here
+	bra			I2CREAD2_2
+
+I2CREAD4:						; block read with automatic address increase 
+	bsf			SSPCON2,ACKEN	; Master acknowlegde
+	rcall		WaitMSSP	
+	bsf			SSPCON2, RCEN	; Enable recieve mode
+	rcall		WaitMSSP	
+	movf		SSPBUF,W		; copy read byte into WREG
+	; no Stop condition here
+	bra			I2CREAD2_2
+
+
+I2CREAD_COMMON:
 	bsf			SSPCON2, PEN	; Stop
 	rcall		WaitMSSP	
 	bsf			SSPCON2,SEN		; Start condition
@@ -246,25 +283,9 @@
 	bsf			SSPCON2, RCEN	; Enable recieve mode
 	rcall		WaitMSSP	
 	movf		SSPBUF,W		; copy read byte into WREG
-	bsf			SSPCON2, PEN	; Stop
-	rcall		WaitMSSP	
 	return
 
-I2CREAD2:						; same as I2CREAD but with automatic address increase 
-	rcall		I2CREAD
-	movlw		d'1'
-	addwf		eeprom_address+0,F
-	movlw		d'0'
-	addwfc		eeprom_address+1,F
-	bcf			eeprom_overflow		
-	btfss		eeprom_address+1,7	; at 0x8000?
-	return		; no, return
-	
-	clrf		eeprom_address+0	; Yes, clear address
-	clrf		eeprom_address+1
-	bsf			eeprom_overflow		; and set overflow bit
-	return
-	
+
 I2CWRITE:
 	movwf		ext_ee_temp1				; Data byte
 	bsf			SSPCON2,SEN			; Start condition
@@ -284,7 +305,7 @@
 	rcall		I2C_WaitforACK
 	bsf			SSPCON2,PEN			; Stop condition
 	rcall		WaitMSSP	
-	WAITMS		d'6'				; Write delay
+	WAITMS		d'5'				; Write delay
 	return
 
 I2C_WaitforACK:
--- a/code_part1/OSTC_code_asm_part1/isr.asm	Wed Mar 23 23:23:06 2011 +0100
+++ b/code_part1/OSTC_code_asm_part1/isr.asm	Thu Mar 24 21:51:36 2011 +0100
@@ -119,34 +119,6 @@
 		clrf	TMR0L
 		return
 		
-timer0int_left_reset:
-		bcf		INTCON2, INTEDG0			; Interrupt on faling edge again
-		bcf		switch_left_isr				; Clear flag, button press is done
-
-		movlw	T0CON_debounce				; Timer0
-		movwf	T0CON
-
-		bsf		T0CON,TMR0ON				; Start Timer 0
-		return
-
-timer0int_left:
-		bsf		INTCON2, INTEDG0			; Interrupt on rising edge again
-		return
-
-timer0int_right_reset:
-		bcf		INTCON2, INTEDG1			; Interrupt on faling edge again
-		bcf		switch_right_isr			; Clear flag, button press is done
-
-		movlw	T0CON_debounce				; Timer0
-		movwf	T0CON
-
-		bsf		T0CON,TMR0ON				; Start Timer 0
-		return
-
-timer0int_right:
-		bsf		INTCON2, INTEDG1			; Interrupt on rising edge again
-		return
-
 timer1int:
 		bcf		PIR1,TMR1IF					; Clear flag
 
--- a/code_part1/OSTC_code_asm_part1/menu_logbook.asm	Wed Mar 23 23:23:06 2011 +0100
+++ b/code_part1/OSTC_code_asm_part1/menu_logbook.asm	Thu Mar 24 21:51:36 2011 +0100
@@ -79,7 +79,7 @@
 	btfsc		divemins+1,7            ; At 0x8000?
 	bra			menu_logbook_reset      ; yes, restart (if not empty)
 
-	decf_eeprom_address	d'2'			; +2 to eeprom address.
+	decf_eeprom_address	d'2'			; -2 to eeprom address.
 
 	call		I2CREAD					; reads one byte (Slow! Better use Blockread!)
 
@@ -137,7 +137,7 @@
 	movf		divesecs,W					; divenumber that is searched
 	cpfseq		divenumber					; current divenumber
 	goto		next_logbook				; No match, continue search
-	bra			display_profile2
+	bra			display_profile2			; Match: Show header and profile
 	
 
 menu_logbook_display_loop:
@@ -1038,20 +1038,20 @@
 	movff		divenumber,lo
 	output_99x								; # of dive
 	PUTC		' '
-	call		I2CREAD2					; logbook_profile_version (1st. byte of Header after the 0xFA, 0xFA)
+	call		I2CREAD3					; logbook_profile_version (1st. byte of Header after the 0xFA, 0xFA)  (Block read start)
 	movff		SSPBUF,lo
 	movlw		d'13'
 	cpfsgt		lo							; Skip if lo>13
 	bra			display_listdive2			; use old format
 
-	call		I2CREAD2					; Skip Profile version
+	call		I2CREAD4					; Skip Profile version (Block read)
 	movff		SSPBUF,lo					; in new format, read month
 
 display_listdive2:
 	movff		lo,convert_value_temp+0		; Month (in lo, see above)
-	call		I2CREAD2					; Day
+	call		I2CREAD4					; Day (Block read)
 	movff		SSPBUF,convert_value_temp+1
-	call		I2CREAD2					; Year
+	call		I2CREAD4					; Year (Block read)
 	movff		SSPBUF,convert_value_temp+2
 	call		PLED_convert_date_short		; converts into "DD/MM" or "MM/DD" or "MM/DD" in s
 
@@ -1061,17 +1061,17 @@
 ;	call		I2CREAD2					; minutes (skip)
 
 	PUTC		' '
-	call		I2CREAD2					; Depth
+	call		I2CREAD3					; Depth (Block read start)
 	movff		SSPBUF,lo
-	call		I2CREAD2	
+	call		I2CREAD4					; Block read
 	movff		SSPBUF,hi
 	bsf			leftbind
 	bsf			ignore_digit5				; Do not display 1cm figure
 	output_16dp	d'3'						; max. depth
 	STRCAT      "m "
-	call		I2CREAD2	
+	call		I2CREAD4					; Block read
 	movff		SSPBUF,lo					; read divetime in minutes
-	call		I2CREAD2	
+	call		I2CREAD4					; Block read
 	movff		SSPBUF,hi					; read divetime in minutes
 	bsf			leftbind
 	output_16								; Divetime minutes