aboutsummaryrefslogtreecommitdiffstats
path: root/msp430/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'msp430/main.c')
-rw-r--r--msp430/main.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/msp430/main.c b/msp430/main.c
new file mode 100644
index 0000000..5c83c2e
--- /dev/null
+++ b/msp430/main.c
@@ -0,0 +1,52 @@
+#include <msp430.h>
+
+#define FOCI_MSP430
+#include "../foci.h"
+
+int main()
+{
+ WDTCTL = WDTPW | WDTHOLD;
+
+ DCOCTL = 0;
+ BCSCTL1 = CALBC1_1MHZ;
+ DCOCTL = CALDCO_1MHZ;
+
+ P1SEL = BIT1 | BIT2; // P1.1 = RXD, P1.2=TXD
+ P1SEL2 = BIT1 | BIT2; // P1.1 = RXD, P1.2=TXD
+ UCA0CTL1 |= UCSSEL_2; // SMCLK
+ UCA0BR0 = 104; // 1MHz 9600
+ UCA0BR1 = 0; // 1MHz 9600
+ UCA0MCTL = UCBRS0; // Modulation UCBRSx = 1
+ UCA0CTL1 &= ~UCSWRST;
+
+ init();
+
+ foci_putchar('o');
+ foci_putchar('k');
+ foci_putchar('\n');
+
+ for (;;) {
+ interpret();
+ foci_putchar('o');
+ foci_putchar('k');
+ foci_putchar('\n');
+ //printf(compiling() ? "compiled <%d>\n" : "ok <%d>\n", depth());
+ }
+}
+
+void foci_putchar(int ch)
+{
+ while (!(IFG2 & UCA0TXIFG));
+ UCA0TXBUF = ch;
+}
+
+int foci_getchar(void)
+{
+ int ch;
+
+ while (!(IFG2 & UCA0RXIFG));
+ ch = UCA0RXBUF;
+ foci_putchar(ch);
+ return ch;
+}
+