# 'make clean' deletes everything except source files and Makefile
# You need to set TARGET, MCU and SOURCES for your project.
# TARGET is the name of the executable file to be produced
-# $(TARGET).elf $(TARGET).hex and $(TARGET).txt nad $(TARGET).map are all generated.
+# $(TARGET).elf $(TARGET).hex and $(TARGET).txt and $(TARGET).map are all generated.
# The TXT file is used for BSL loading, the ELF can be used for JTAG use
#
TARGET = main
MCU = msp2
# List all the source files here
# eg if you have a source file foo.c then list it here
-SOURCES = main.c ns430-uart.c
+SOURCES = main.c ns430-uart.c msp4th.c
# Include are located in the Include directory
#INCLUDES = -IInclude
INCLUDES = -I.
.PHONY: clean
clean:
-$(RM) $(OBJECTS)
- -$(RM) $(TARGET).*
+ -$(RM) $(TARGET).{,elf,hex,txt,map}
-$(RM) $(SOURCES:.c=.lst)
-$(RM) $(DEPEND)
+#include <signal.h>
+#include <stdio.h>
+
#include "ns430-atoi.h"
#include "ns430-uart.h"
#include "msp4th.h"
// The order is important .... don't insert anything!
// the order matches the execN function
-const uint8_t cmdListBi[] =
+const char cmdListBi[] =
{"exit + - * / " // 1 -> 5
". dup drop swap < " // 6 -> 10
"> = .hb gw dfn " // 11 -> 15
// these commands are interps
-const uint8_t cmdListBi2[] = {"[ : var "};
+const char cmdListBi2[] = {"[ : var "};
// these values point to where in progBi[] these routines start
int16_t progPtr; // next open space for user opcodes
int16_t progOps[USR_OPCODE_SIZE];
int16_t progOpsPtr;
-uint8_t cmdList[CMD_LIST_SIZE]; // just a string of user defined names
+char cmdList[CMD_LIST_SIZE]; // just a string of user defined names
int16_t cmdListPtr;
int16_t subSecondClock;
int16_t i;
lineBufferPtr = 0;
- emit(0x0D);
- emit(0x0A);
- emit('>'); // this is our prompt
+ putchar(0x0D);
+ putchar(0x0A);
+ putchar('>'); // this is our prompt
i = 1;
while(i){ // just hang in loop until we get CR
- i = getKey();
+ i = getchar();
if(i == 0x08){
if(lineBufferPtr > 0){
- emit(0x08);
- emit(' ');
- emit(0x08);
+ putchar(0x08);
+ putchar(' ');
+ putchar(0x08);
lineBufferPtr--;
}
} else {
- emit(i);
+ putchar(i);
if(i == 0x0D){
// hit cr
lineBuffer[lineBufferPtr] = 0;
}
}
}
- emit(0x0A);
+ putchar(0x0A);
lineBufferPtr = 0;
}
}
void inline listFunction(){
- printString(cmdListBi);
- printString(cmdListBi2);
- printString(cmdList);
+ puts(cmdListBi);
+ puts(cmdListBi2);
+ puts(cmdList);
}
int16_t popMathStack(){
void numFunc(){ // the word to test is in wordBuffer
int16_t i,j,n;
- printString((const uint8_t *)"in numFunc()\r\n");
- printString(wordBuffer);
+ puts((const uint8_t *)"in numFunc()\r\n");
+ puts(wordBuffer);
// first check for neg sign
i = 0;
if(wordBuffer[0] == '-'){
}
/*printNumber(n);*/
/*printNumber(j);*/
- /*printString("\r\n");*/
+ /*puts("\r\n");*/
pushMathStack(n);
pushMathStack(j);
}
i--;
if(n < 0){
- emit('-');
+ putchar('-');
}
do{
- emit(x[i--]);
+ putchar(x[i--]);
}while(i >= 0);
- emit(' ');
+ putchar(' ');
}
void printHexChar(int16_t n){
n += 7;
}
n += '0';
- emit(n);
+ putchar(n);
}
void printHexByte(int16_t n){
void execN(int16_t n){
int16_t i,j,k,m;
int32_t x,y,z;
- printString((const uint8_t *)"execN: ");
+ puts((const uint8_t *)"execN: ");
printNumber(n);
- printString((const uint8_t *)"\r\n");
+ puts((const uint8_t *)"\r\n");
switch(n){
case 1:
// xit = 1;
case 17: // allot
prog[progPtr++] = popMathStack();
if(progPtr >= PROG_SPACE){
- printString((uint8_t *)"prog mem");
+ puts((uint8_t *)"prog mem");
}
break;
case 30: // num
- printString((const uint8_t *)"in case 30\r\n");
+ puts((const uint8_t *)"in case 30\r\n");
numFunc();
break;
break;
case 38: // pwrd
- printString(wordBuffer);
+ puts(wordBuffer);
break;
case 39: // emit
- emit(popMathStack());
+ putchar(popMathStack());
break;
case 40: // ;
break;
case 52: // key get a key from input .... (wait for it)
- pushMathStack(getKey());
+ pushMathStack(getchar());
break;
case 53: // cr
- emit(0x0D);
- emit(0x0A);
+ putchar(0x0D);
+ putchar(0x0A);
break;
case 54: // hist
case 58: // hstat
for(i=256;i<260;i++){
printHexWord(buckets[i]);
- emit(' ');
+ putchar(' ');
}
break;
for(i=0;i<256;i++){
if(buckets[i]){
printHexByte(i);
- emit(' ');
+ putchar(' ');
printHexWord(buckets[i]);
- emit(0x0D);
- emit(0x0A);
+ putchar(0x0D);
+ putchar(0x0A);
}
}
break;
case 60: // fec
printHexWord(fecShadow[2]);
- emit(' ');
+ putchar(' ');
printHexWord(fecShadow[1]);
- emit(' ');
+ putchar(' ');
printHexWord(fecShadow[0]);
break;
break;
default:
- printString((uint8_t *)"opcode ");
+ puts((uint8_t *)"opcode ");
break;
}
}
int16_t opcode;
while(1){
- printString((const uint8_t *)"processLoop()\r\n");
+ puts((const uint8_t *)"processLoop()\r\n");
if(progCounter > 9999){
opcode = progBi[progCounter - 10000];
} else {
-#endif