changeset 235:ade0848c8b8b

New runtime asserts when compiled in DEBUG more. When __DEBUG is defined, the assert() calls are checked, and PLED_resetdebugger is called when the condition fails.
author JeanDo
date Sat, 19 Mar 2011 11:34:32 +0100
parents bb8940caebe1
children 3dbeacf42e9e
files code_part1/OSTC_code_asm_part1/definitions.asm code_part1/OSTC_code_asm_part1/pled_outputs.asm code_part1/OSTC_code_asm_part1/start.asm code_part1/OSTC_code_c_part2/p2_deco.c code_part1/OSTC_code_c_part2/p2_definitions.h
diffstat 5 files changed, 99 insertions(+), 62 deletions(-) [+]
line wrap: on
line diff
--- a/code_part1/OSTC_code_asm_part1/definitions.asm	Thu Mar 17 18:32:16 2011 +0100
+++ b/code_part1/OSTC_code_asm_part1/definitions.asm	Sat Mar 19 11:34:32 2011 +0100
@@ -314,7 +314,7 @@
 customfunction_temp2    res 1   ; used in GETCUSTOM8 and GETCUSTOM15
 
 decoplan_page           res 1   ; used in PLED_MultiGF,...
-temp10                  res 1   ; used in customview
+temp10                  res 2   ; used in customview
 
 fatal_error_code        res 1   ; holds error code value 
 
--- a/code_part1/OSTC_code_asm_part1/pled_outputs.asm	Thu Mar 17 18:32:16 2011 +0100
+++ b/code_part1/OSTC_code_asm_part1/pled_outputs.asm	Sat Mar 19 11:34:32 2011 +0100
@@ -283,10 +283,17 @@
 	STRCAT_PRINT " "
 	return
 
-
+;=============================================================================
+; BlueScreen function.
+;
 PLED_resetdebugger:
+    global PLED_resetdebugger
+    global temp10
+
+    movlb   1                       ; For C-code calls
 	call	PLED_boot				; PLED boot
 	call	PLED_ClearScreen		; clean up OLED
+
 	call	PLED_standard_color
 	WIN_INVERT	.0					; Init new Wordprocessor
 
@@ -297,12 +304,11 @@
 	
 	WIN_TOP		.100
 	WIN_LEFT	.10
-	WIN_FONT 	FT_SMALL
-	WIN_INVERT	.0					; Init new Wordprocessor
-	call	PLED_standard_color
+
 	lfsr	FSR2,letter
-	movff	temp10,lo
-	output_8		
+	movff	temp10+0,lo             ; Code-stack point at crash time.
+	movff	temp10+1,hi             ; Code-stack point at crash time.
+	output_16
 	movlw	' '
 	movwf	POSTINC2
 	movf	debug_char+0,W
@@ -326,10 +332,6 @@
 	call	word_processor
 
 	WIN_TOP		.125
-	WIN_LEFT	.10
-	WIN_FONT 	FT_SMALL
-	WIN_INVERT	.0					; Init new Wordprocessor
-	call	PLED_standard_color
 
 	lfsr	FSR2,letter
 	movff	flag3,lo
@@ -349,10 +351,6 @@
 	call	word_processor
 
 	WIN_TOP		.150
-	WIN_LEFT	.10
-	WIN_FONT 	FT_SMALL
-	WIN_INVERT	.0					; Init new Wordprocessor
-	call	PLED_standard_color
 
 	lfsr	FSR2,letter
 	movff	flag8,lo
@@ -373,8 +371,15 @@
 
 	bcf		switch_left	
 PLED_resetdebugger_loop:
+    bcf     LED_blue            ; Blink blue led every seconds..
+    btfss   secs,0
+    bsf     LED_blue
+
 	btfss	switch_left
 	bra		PLED_resetdebugger_loop		; Loop
+
+    bcf     LED_blue
+    bcf     LED_red
 	return
 
 PLED_divemode_mask:					; Displays mask in Dive-Mode
@@ -2215,28 +2220,36 @@
 	STRCAT_PRINT "m"
 	return
 
-
-PLED_serial:			; Writes OSTC #Serial and Firmware version in surfacemode
+;=============================================================================
+; Writes OSTC #Serial and Firmware version in surfacemode
+;
+PLED_serial:			
 	ostc_debug	'a'		; Sends debug-information to screen if debugmode active
 	WIN_TOP		.0
 	WIN_LEFT	.1
 	WIN_FONT 	FT_SMALL
-	WIN_INVERT	.0					; Init new Wordprocessor
+	WIN_INVERT	.0                      ; Init new Wordprocessor
+	
+  ifdef __DEBUG
+    movlw   color_grey                  ; Write header in blue when
+    call    PLED_set_color              ; compiled in DEBUG mode...
+  else
 	call	PLED_standard_color
+  endif
 
 	lfsr	FSR2,letter
-	OUTPUTTEXTH		d'262'			; "OSTC "
+	OUTPUTTEXTH		d'262'              ; "OSTC "
 	clrf	EEADRH
-	clrf	EEADR				; Get Serial number LOW
-	call	read_eeprom			; read byte
+	clrf	EEADR                       ; Get Serial number LOW
+	call	read_eeprom                 ; read byte
 	movff	EEDATA,lo
-	incf	EEADR,F				; Get Serial number HIGH
-	call	read_eeprom			; read byte
+	incf	EEADR,F                     ; Get Serial number HIGH
+	call	read_eeprom                 ; read byte
 	movff	EEDATA,hi
 
 	bsf		leftbind
 	output_16
-	STRCAT  " \x90\x91 V"		; Scribble logo...
+	STRCAT  " \x90\x91 V"               ; Scribble logo...
 	movlw	softwareversion_x
 	movwf	lo
 	bsf		leftbind
@@ -2247,17 +2260,25 @@
 	bsf		leftbind
 	output_99x
 	bcf		leftbind
+
+  ifdef __DEBUG
+    STRCAT_PRINT "-Dbg"    
+  else
 	call	word_processor
 
-	movlw	softwareversion_beta			; =1: Beta, =0: Release
+	movlw	softwareversion_beta        ; =1: Beta, =0: Release
 	decfsz	WREG,F
-	return									; Release version -> Return
+	return                              ; Release version -> Return
 
 	call	PLED_warnings_color
-	DISPLAYTEXT		d'243'			; beta
+	DISPLAYTEXT		d'243'              ; beta
 	call	PLED_standard_color
+  endif
+
 	return
 
+;=============================================================================
+
 PLED_divemode_menu_mask_first:			; Write Divemode menu1 mask
 	ostc_debug	'o'		; Sends debug-information to screen if debugmode active
 	call	PLED_menu_clear			; clear "Menu?"
--- a/code_part1/OSTC_code_asm_part1/start.asm	Thu Mar 17 18:32:16 2011 +0100
+++ b/code_part1/OSTC_code_asm_part1/start.asm	Sat Mar 19 11:34:32 2011 +0100
@@ -25,6 +25,8 @@
 start:
 	movlb	b'00000001'				; ram bank 1 selected
 	movff	STKPTR,temp10
+	clrf    temp10+1
+
 	call	init
 	btfsc	divemode				; Reset from Divemode?
 	call	PLED_resetdebugger		; Yes! Something went wrong, show reset informations
--- a/code_part1/OSTC_code_c_part2/p2_deco.c	Thu Mar 17 18:32:16 2011 +0100
+++ b/code_part1/OSTC_code_c_part2/p2_deco.c	Sat Mar 19 11:34:32 2011 +0100
@@ -467,6 +467,50 @@
 //////////////////////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////////////////////
 
+//////////////////////////////////////////////////////////////////////////////
+#ifdef __DEBUG
+void assert_failed(PARAMETER short int line)
+{
+    extern void PLED_resetdebugger(void);
+    extern unsigned short temp10;
+
+    temp10 = line;
+    PLED_resetdebugger();
+}
+#endif
+//////////////////////////////////////////////////////////////////////////////
+// When calling C code from ASM context, the data stack pointer and
+// frames should be reset. Bank8 is used by stack, when not doing hashing.
+
+#ifdef CROSS_COMPILE
+#       define RESET_C_STACK
+#else
+#   ifdef __DEBUG
+#       define RESET_C_STACK fillDataStack();
+        void fillDataStack(void)
+        {
+            _asm
+                LFSR    1,C_STACK
+                MOVLW   0xCC
+        loop:   MOVWF   POSTINC1,0
+                TSTFSZ  FSR1L,0
+                BRA     loop
+        
+                LFSR    1,C_STACK
+                LFSR    2,C_STACK
+            _endasm
+        }
+#   else
+#       define RESET_C_STACK    \
+        _asm                    \
+            LFSR    1, C_STACK  \
+            LFSR    2, C_STACK  \
+        _endasm
+#   endif
+#endif
+
+//////////////////////////////////////////////////////////////////////////////
+
 static short read_custom_function(PARAMETER unsigned char cf)
 {
 #ifdef CROSS_COMPILE
@@ -777,40 +821,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////////////////////
 
-void fillDataStack(void)
-{
-#ifndef CROSS_COMPILE
-    _asm
-        LFSR    1,C_STACK
-        MOVLW   0xCC
-loop:   MOVWF   POSTINC1,0
-        TSTFSZ  FSR1L,0
-        BRA     loop
-
-        LFSR    1,C_STACK
-        LFSR    2,C_STACK
-    _endasm
-#endif
-}
-
-//////////////////////////////////////////////////////////////////////////////
-// When calling C code from ASM context, the data stack pointer and
-// frames should be reset. Bank3 is dedicated to the stack (see the
-// .lkr script).
-#ifdef CROSS_COMPILE
-#       define RESET_C_STACK
-#else
-#   ifdef __DEBUG
-#       define RESET_C_STACK fillDataStack();
-#   else
-#       define RESET_C_STACK    \
-        _asm                    \
-            LFSR    1, C_STACK  \
-            LFSR    2, C_STACK  \
-        _endasm
-#   endif
-#endif
-
 //////////////////////////////////////////////////////////////////////////////
 // Called every 2 seconds during diving.
 // update tissues every time.
--- a/code_part1/OSTC_code_c_part2/p2_definitions.h	Thu Mar 17 18:32:16 2011 +0100
+++ b/code_part1/OSTC_code_c_part2/p2_definitions.h	Sat Mar 19 11:34:32 2011 +0100
@@ -112,7 +112,11 @@
 #   pragma warning(disable: 4244 4068 4305)
 #else
 #   define PARAMETER static
-#   define assert(predicate)
+#   ifdef __DEBUG
+#       define assert(predicate) if( !(predicate) ) assert_failed(__LINE__)
+#   else
+#       define assert(predicate)
+#   endif
 #endif
 
 //////////////////////////////////////////////////////////////////////////////