-// SilentTimer Action Figure software, v2.1
+// SilentTimer Action Figure software, v2.2
// main.c
// The main c file.
//
-// 27.06.2020
+// 14.12.2020
// Copyright (C) 2014-2017, 2020 Balthasar SzczepaĆski
//
// This program is free software: you can redistribute it and/or modify
P2IFG=0;
if(event)
- _BIC_SR_IRQ(OSCOFF|CPUOFF|SCG1|SCG0); //escaoe low power mode
+ _BIC_SR_IRQ(OSCOFF|CPUOFF|SCG1|SCG0); //escape low power mode
return;
}
{
calcdata[2]=settime[0];
calcdata[3]=settime[1];
- if ((settime[1] & 0xF0)==0xA0) //minus sign encoded as 0xA
+ calcdata[6] &= ~0x0c; //clear old flags
+ if ((settime[1] & 0xf0)==0xa0) //minus sign encoded as 0xA
{
calcdata[6] |= 0x04;
calcdata[3] &= 0x0f;
{
settime[0] = calcdata[2];
settime[1] = calcdata[3];
- settime[2] = (calcdata[6]>>2)&0x03;
+ if (calcdata[6]&0x04)
+ settime[1] |= 0xA0; //restore minus sign
+ settime[2] = (calcdata[6]&0x08)>>3; //restore decimal point
}
else
{
break;
case MODE_VER:
dispvalue[4] = SYMB_NUL;
- dispvalue[5] = SYMB_1;
+ dispvalue[5] = SYMB_2;
dispvalue[6] = SYMB_2;
dispvalue[7] = SYMB_NUL;
dot |= 0x02; //.
P1OUT =0xff; //display data on p1
P1DIR =0xff;
- P3OUT &=0x0f; //display control on p3.4-7
- P3DIR |=0xf0;
+ P3OUT =0x01;
+ P3DIR |=0xf1; //display control on p3.4-7, RTC CS on p3.0
+ P3SEL =0x0e; // SPI on p3.1, 3.2, 3.3
dispvalue[0]=SYMB_NUL;
dispvalue[1]=SYMB_o;
//init SPI
- P3SEL =0x0e; // SPI on p3.1, 3.2, 3.3
- P3OUT |=0x01;
- P3DIR |=0x01; //RTC CS on p3.0
-
U0CTL =
SWRST| //reset
MM| //master
for (i=0; i<8; ++i)
{
if (i != 4)
- sendhex(time[i]); //hs
+ sendhex(time[i]);
}
- sendhex(lastyear[4]); //yL
+ sendhex(lastyear[4]); //yH
break;
case 'H': //get state
sendhex(mode);
sendhex(run);
break;
case 'M': //get version
- sendhex(1);
- sendhex(2);
+ sendhex(2); //vL
+ sendhex(2); //vH
break;
case 'N': //get pinout
sendhex(PIN_AB);
case 'Q': //get diit
sendhex(digit);
break;
- case 'R': //set memory
+ case 'R': //read memory
p = (unsigned char*)(*((unsigned short*)rxdata));
sendhex(*p);
break;