From: b Date: Wed, 29 Apr 2020 18:28:43 +0000 (+0200) Subject: reset after debug, no sleep in debug X-Git-Tag: v1.6 X-Git-Url: http://bicyclesonthemoon.info/git-projects/?a=commitdiff_plain;h=66f6690ac2ea6ab653e183a3bb2bcf3ab8ce1a23;p=staf%2Fstaf reset after debug, no sleep in debug --- diff --git a/definitions.h b/definitions.h index d671397..aee5ebc 100644 --- a/definitions.h +++ b/definitions.h @@ -2,8 +2,8 @@ // definitions.h // Definitions used by the code. // -// 21.03.2016 -// Copyright (C) 2014-2016 Balthasar Szczepański +// 17.07.2017 +// Copyright (C) 2014-2017 Balthasar Szczepański // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -108,10 +108,11 @@ #define MODE_DEBUG 12 #define MODE_DEBUGADDR 13 #define MODE_DEBUGVAL 14 +#define MODE_RESET 15 -#define MODE_CALC 15 -#define MODE_CALCSETNUM 16 -#define MODE_CALCSETOPER 17 +#define MODE_CALC 16 +#define MODE_CALCSETNUM 17 +#define MODE_CALCSETOPER 18 #define ALARMVALUE 0xa5 diff --git a/main.c b/main.c index fd0828d..aead80a 100644 --- a/main.c +++ b/main.c @@ -2,8 +2,8 @@ // main.c // The main c file. // -// 15.07.2016 -// Copyright (C) 2014-2016 Balthasar Szczepański +// 17.07.2017 +// Copyright (C) 2014-2017 Balthasar Szczepański // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -23,20 +23,20 @@ #include "msp430.h" #include "definitions.h" - unsigned char inbuf[8]; - unsigned char outbuf[8] __attribute__ ((aligned (2))); - unsigned char dispvalue[4]; - unsigned char time[8]; - unsigned char leap; - unsigned char settime[3]; - unsigned char mode; - unsigned char alarm[3]; - unsigned char lastcdn[2]; - unsigned char lastyear[5]; - unsigned char digit; - unsigned char changed; - unsigned char run; - unsigned char symbol[16] ={ + unsigned char inbuf[8]; + unsigned char outbuf[8] __attribute__ ((aligned (2))); + unsigned char dispvalue[4]; + volatile unsigned char time[8]; + unsigned char leap; + unsigned char settime[3]; + volatile unsigned char mode; + unsigned char alarm[3]; + unsigned char lastcdn[2]; + unsigned char lastyear[5]; + unsigned char digit; + unsigned char changed; + unsigned char run; + const unsigned char symbol[16] ={ SYMB_0, SYMB_1, SYMB_2, @@ -264,6 +264,10 @@ if(mode==MODE_DEBUG && changed) spi(RTC_READ,settime[1],settime,outbuf,1); + + if(mode==MODE_RESET && P2IN&0x02 && P2IN&0x01 && P2IN&0x20) { + WDTCTL = ALARMVALUE; + } } else if(P2IFG&0x02) // button A { @@ -315,9 +319,15 @@ } break; case MODE_DEBUGADDR: + settime[1]=settime[2]; case MODE_DEBUGVAL: + spi(RTC_READ,settime[1],settime,outbuf,1); mode=MODE_DEBUG; break; + case MODE_DEBUG: + case MODE_RESET: + mode=MODE_RESET; + break; case MODE_SETCOUNTDOWN: case MODE_COUNTDOWN: if(changed || mode==MODE_COUNTDOWN) @@ -608,6 +618,7 @@ case MODE_DEBUG: //changed=1; digit=1; + settime[2]=settime[1]; mode=MODE_DEBUGADDR; break; default: @@ -883,6 +894,12 @@ dispvalue[2]=symbol[settime[2]&0x0f]; dispvalue[3]=((settime[2]&0xf0)?symbol[(settime[2]&0xf0)>>4]:SYMB_NUL)&(alarm[0]?SYMB_DOT:SYMB_NUL); break; + case MODE_RESET: + dispvalue[0]=SYMB_NUL; + dispvalue[1]=SYMB_NUL; + dispvalue[2]=SYMB_NUL; + dispvalue[3]=SYMB_NUL; + break; case MODE_DEBUG: if(changed) { @@ -894,7 +911,7 @@ else { dispvalue[0]=SYMB_NUL; - dispvalue[1]=SYMB_5&SYMB_DOT; + dispvalue[1]=SYMB_6&SYMB_DOT; dispvalue[2]=SYMB_1; dispvalue[3]=SYMB_NUL&(alarm[0]?SYMB_DOT:SYMB_NUL); } @@ -1132,6 +1149,16 @@ while(1) { - lpm3(); + switch(mode) + { + case MODE_DEBUG: + P2IFG|=0x08; + case MODE_DEBUGADDR: + case MODE_DEBUGVAL: + break; + default: + lpm3(); + break; + } } }