]> bicyclesonthemoon.info Git - staf/staf/commitdiff
reset after debug, no sleep in debug v1.6
authorb <rowerynaksiezycu@gmail.com>
Wed, 29 Apr 2020 18:28:43 +0000 (20:28 +0200)
committerb <rowerynaksiezycu@gmail.com>
Wed, 29 Apr 2020 18:28:43 +0000 (20:28 +0200)
definitions.h
main.c

index d67139774d1926b864be219c09a7f5cdbd6a8e6c..aee5ebcfd185b14f01627bd5c914deca93c7e0eb 100644 (file)
@@ -2,8 +2,8 @@
 // definitions.h\r
 // Definitions used by the code.\r
 // \r
-// 21.03.2016\r
-// Copyright (C) 2014-2016  Balthasar Szczepański\r
+// 17.07.2017\r
+// Copyright (C) 2014-2017  Balthasar Szczepański\r
 //\r
 // This program is free software: you can redistribute it and/or modify\r
 // it under the terms of the GNU General Public License as published by\r
 #define MODE_DEBUG       12\r
 #define MODE_DEBUGADDR   13\r
 #define MODE_DEBUGVAL    14\r
+#define MODE_RESET       15\r
 \r
-#define MODE_CALC        15\r
-#define MODE_CALCSETNUM  16\r
-#define MODE_CALCSETOPER 17\r
+#define MODE_CALC        16\r
+#define MODE_CALCSETNUM  17\r
+#define MODE_CALCSETOPER 18\r
 \r
 #define ALARMVALUE 0xa5\r
 \r
diff --git a/main.c b/main.c
index fd0828d77be179f5e0f43f65a0b81d6416ae6074..aead80a6f25b8c8f7c91d0af4d162cb8ea68dc6d 100644 (file)
--- 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
        #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,
                        
                        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
                {
                                }
                                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)
                        case MODE_DEBUG:
                                //changed=1;
                                digit=1;
+                               settime[2]=settime[1];
                                mode=MODE_DEBUGADDR;
                                break;  
                        default:
                        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)
                        {
                        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);
                        }
                
                while(1)
                {
-                       lpm3();
+                       switch(mode)
+                       {
+                       case MODE_DEBUG:
+                               P2IFG|=0x08;
+                       case MODE_DEBUGADDR:
+                       case MODE_DEBUGVAL:
+                               break;
+                       default:
+                               lpm3();
+                               break;
+                       }
                }
        }