Skip to content

Commit

Permalink
Corrected bug regarding interrupt
Browse files Browse the repository at this point in the history
  • Loading branch information
bsaxen committed Dec 3, 2011
1 parent 4f81d18 commit 58ba0e6
Show file tree
Hide file tree
Showing 5 changed files with 200 additions and 86 deletions.
4 changes: 2 additions & 2 deletions config.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Simuino Configuration Thu Dec 1 11:46:26 2011
# Simuino Configuration Sat Dec 3 10:21:06 2011
DELAY 30
LOG_LEVEL 3
LOG_FILE 0
SKETCH ../adcajo/heater_control.c
SKETCH ../adcajo/s1.c
SERVUINO servuino/data.su
56 changes: 18 additions & 38 deletions decode_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,6 @@
// Developed by Benny Saxen, ADCAJO
//================================================

#define A0 0
#define A1 1
#define A2 2
#define A3 3
#define A4 4
#define A5 5

#define byte int



// Math function min and max
#ifndef max
#define max( a, b ) ( ((a) > (b)) ? (a) : (b) )
#endif

#ifndef min
#define min( a, b ) ( ((a) < (b)) ? (a) : (b) )
#endif

char stemp[80];

//typedef std::string String;

//=====================================
// Functions
Expand All @@ -35,7 +12,7 @@ char stemp[80];

void pinMode(int pin,int mode)
{
char temp[80];
char temp[120];

//passTime();
if(mode == INPUT || mode == OUTPUT)
Expand All @@ -50,36 +27,34 @@ void pinMode(int pin,int mode)
strcpy(temp,textPinModeIn[pin]);
wprintw(uno,"In");
if(strstr(temp,"void"))
wLog("pinMode IN",pin,-1);
wLog1("pinMode IN",pin);
else
wLog(temp,pin,-1);
wLog1(temp,pin);
}

if(mode==OUTPUT)
{
strcpy(temp,textPinModeOut[pin]);
wprintw(uno,"Out");
if(strstr(temp,"void"))
wLog("pinMode OUT",pin,-1);
wLog1("pinMode OUT",pin);
else
wLog(temp,pin,-1);
wLog1(temp,pin);
}
show(uno);
}
else
{
showError("Unknown Pin Mode",mode);
wLog("pinMode ",pin,-1);
}
}

void digitalWrite(int pin,int value)
{
char temp[80];
char temp[120];
//passTime();
if(digitalMode[pin] == OUTPUT)
{
//s_digitalPin[nloop][pin] = value;

wmove(uno,DP,digPinPos[pin]);
if(value==HIGH)
Expand Down Expand Up @@ -124,7 +99,7 @@ void digitalWrite(int pin,int value)

int digitalRead(int pin)
{
char temp[80];
char temp[120];
int value;

//passTime();
Expand Down Expand Up @@ -173,7 +148,7 @@ int analogRead(int pin) // Values 0 to 1023
{

int value;
char temp[80];
char temp[120];

value = g_value;

Expand Down Expand Up @@ -215,7 +190,7 @@ int analogRead(int pin) // Values 0 to 1023
void analogWrite(int pin,int value)
// Values 0 to 255 PWM: only pin 3,5,6,9,10,11
{
char temp[80];
char temp[120];

//passTime();

Expand Down Expand Up @@ -291,12 +266,12 @@ void shiftOut(int dataPin, int clockPin, int bitOrder, int value)

unsigned long pulseIn(int pin, int value)
{
unimplemented("pulseIn()");
unimplemented("pulseIn(int,int)");
}

unsigned long pulseIn(int pin, int value, unsigned long timeout)
{
unimplemented("pulseIn()");
unimplemented("pulseIn(int,int,unsigned long)");
}

//------ Time ------------------------------
Expand All @@ -316,15 +291,15 @@ unsigned long micros()
void delay(int ms)
{
//passTime();
if(confLogLev > 1)wLog("delay",ms,-1);
wLog("delay",ms,-1);
//msleep(ms);

}

void delayMicroseconds(int us)
{
//passTime();
if(confLogLev > 1)wLog("delayMicroseconds",us,-1);
wLog("delayMicroseconds",us,-1);
//msleep(us);

}
Expand Down Expand Up @@ -436,6 +411,11 @@ unsigned char bit(unsigned char x)
//------ External Interrupts ---------------


void interrupt(char *m,int intrpt_no)
{
wLog(m,intrpt_no,-1);
}

void attachInterrupt(int interrupt,void(*func)(),int mode)
{

Expand Down
81 changes: 62 additions & 19 deletions simuino.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@
#include <sys/stat.h>
#include <form.h>

#define A0 0
#define A1 1
#define A2 2
#define A3 3
#define A4 4
#define A5 5


#define LOW 0
#define HIGH 1
#define INPUT 1
Expand Down Expand Up @@ -70,6 +78,11 @@
#define RUN 1
#define ADMIN 2

#define FREE 0
#define RX 3
#define TX 4


// Configuration
int currentStep = 0;
int currentLoop = 0;
Expand All @@ -84,14 +97,11 @@ void (*interrupt1)();
char simulation[MAX_STEP][SIZE_ROW];
int loopPos[MAX_LOOP];

#define FREE 0
#define RX 3
#define TX 4

int s_row,s_col;
int digPinPos[MAX_PIN_DIGITAL];
int anaPinPos[MAX_PIN_ANALOG];
char appName[80];
char appName[120];

int interruptMode[2];
int digitalMode[MAX_PIN_DIGITAL];
Expand All @@ -100,26 +110,22 @@ int baud = 0;
int error = 0;

// Log
int logging = YES;
char logBuffer[MAX_LOG][100];
int logSize = 1;
//int logging = YES;
char logBlankRow[500];

// Serial Interface
int serialSize = 1;
//int serialSize = 1;
int serialMode = OFF;
char serialBuffer[100][100];
int rememberNewLine = 0;
char prevSerial[SIZE_ROW];
char serBlankRow[500];

char textPinModeIn[MAX_PIN_DIGITAL][80];
char textPinModeOut[MAX_PIN_DIGITAL][80];
char textDigitalWriteLow[MAX_PIN_DIGITAL][80];
char textDigitalWriteHigh[MAX_PIN_DIGITAL][80];
char textAnalogWrite[MAX_PIN_DIGITAL][80];
char textAnalogRead[MAX_PIN_ANALOG][80];
char textDigitalRead[MAX_PIN_DIGITAL][80];
char textPinModeIn[MAX_PIN_DIGITAL][SIZE_ROW];
char textPinModeOut[MAX_PIN_DIGITAL][SIZE_ROW];
char textDigitalWriteLow[MAX_PIN_DIGITAL][SIZE_ROW];
char textDigitalWriteHigh[MAX_PIN_DIGITAL][SIZE_ROW];
char textAnalogWrite[MAX_PIN_DIGITAL][SIZE_ROW];
char textAnalogRead[MAX_PIN_ANALOG][SIZE_ROW];
char textDigitalRead[MAX_PIN_DIGITAL][SIZE_ROW];
int scenAnalog = 0;
int scenDigital = 0;
int scenInterrupt = 0;
Expand All @@ -139,6 +145,20 @@ int ser_h=0, ser_w=0;
WINDOW *uno,*ser,*slog,*msg;
static struct termios orig, nnew;


#define byte int

// Math function min and max
#ifndef max
#define max( a, b ) ( ((a) > (b)) ? (a) : (b) )
#endif

#ifndef min
#define min( a, b ) ( ((a) < (b)) ? (a) : (b) )
#endif

char stemp[80];

#include "simuino.h"
#include "simuino_lib.c"
#include "decode_lib.c"
Expand Down Expand Up @@ -210,7 +230,6 @@ void runStep(int dir)
}
else if (p=strstr(event,"Serial:print(char)"))
{
//sscanf(event,"%d %s %s",&step,temp,temp2);
getString(event,temp3);
Serial.print(temp3);
}
Expand All @@ -221,7 +240,6 @@ void runStep(int dir)
}
else if (p=strstr(event,"Serial:println(char)"))
{
//sscanf(event,"%d %s %s",&step,temp,temp2);
getString(event,temp3);
Serial.println(temp3);
}
Expand All @@ -240,6 +258,26 @@ void runStep(int dir)
sscanf(event,"%d %s %d",&step,temp,&x);
detachInterrupt(x);
}
else if (p=strstr(event,"interruptRISING"))
{
sscanf(event,"%d %s %d",&step,temp,&x);
interrupt(temp,x);
}
else if (p=strstr(event,"interruptFALLING"))
{
sscanf(event,"%d %s %d",&step,temp,&x);
interrupt(temp,x);
}
else if (p=strstr(event,"interruptCHANGE"))
{
sscanf(event,"%d %s %d",&step,temp,&x);
interrupt(temp,x);
}
else if (p=strstr(event,"interruptLOW"))
{
sscanf(event,"%d %s %d",&step,temp,&x);
interrupt(temp,x);
}
else
unimplemented(temp);

Expand Down Expand Up @@ -324,6 +362,10 @@ void openCommand()
{
showLoops();
}
if(p=strstr(str,"sim")) //status
{
readSimulation(confServuinoFile);
}
if(p=strstr(str,"scen")) // scenario
{
showScenario(confSketchFile);
Expand Down Expand Up @@ -475,6 +517,7 @@ int main(int argc, char *argv[])
readSimulation(confServuinoFile);
readSketchInfo();
unoInfo();
show(slog);

if(confLogFile == YES)resetFile("log.txt");

Expand Down
3 changes: 3 additions & 0 deletions simuino.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
void wLog0(const char *p);
void wLog1(const char *p, int value1);
void wLog2(const char *p, int value1, int value2);
void debug(char *msg);
void runMode();
void runStep(int dir);
Expand Down
Loading

0 comments on commit 58ba0e6

Please sign in to comment.