You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.1 KiB
C

#include <msp430.h>
#include "foci.h"
static intptr_t dict[100];
int main()
{
WDTCTL = WDTPW | WDTHOLD;
DCOCTL = 0;
BCSCTL1 = CALBC1_8MHZ;
DCOCTL = CALDCO_8MHZ;
P1SEL = BIT1 | BIT2; // P1.1 = RXD, P1.2=TXD
P1SEL2 = BIT1 | BIT2; // P1.1 = RXD, P1.2=TXD
UCA0CTL1 |= UCSSEL_2; // SMCLK
UCA0BR0 = 208; // 8MHz 38400
UCA0BR1 = 0;
UCA0MCTL = UCBRS0; // Modulation UCBRSx = 1
UCA0CTL1 &= ~UCSWRST;
init(dict);
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)
{
do asm("nop");
while ((IFG2 & UCA0TXIFG) == 0 || (UCA0STAT & UCBUSY) == UCBUSY);
UCA0TXBUF = ch;
while ((UCA0STAT & UCBUSY) == UCBUSY);
}
int foci_getchar(void)
{
int ch;
do asm("nop");
while ((IFG2 & UCA0RXIFG) == 0 || (UCA0STAT & UCBUSY) == UCBUSY);
ch = UCA0RXBUF;
do asm("nop");
while ((UCA0STAT & UCBUSY) == UCBUSY);
foci_putchar(ch);
return ch;
}