2 see README.txt for details.
4 chris <cliechti@gmx.net>
15 void delay(unsigned int d) {
23 Main function with init an an endless loop that is synced with the
24 interrupts trough the lowpower mode.
32 WDTCTL = WDTCTL_INIT; //Init watchdog timer
34 P1OUT = P1OUT_INIT; //Init output data of port1
35 P1SEL = P1SEL_INIT; //Select port or module -function on port1
36 P1DIR = P1DIR_INIT; //Init port direction register of port1
37 P1IES = P1IES_INIT; //init port interrupts
40 P2OUT = P2OUT_INIT; //Init output data of port2
41 P2SEL = P2SEL_INIT; //Select port or module -function on port2
42 P2DIR = P2DIR_INIT; //Init port direction register of port2
43 P2IES = P2IES_INIT; //init port interrupts
47 P3OUT = 0xff; //light LED during init
48 delay(65535); //Wait for watch crystal startup
50 // fllInit(); //Init FLL to desired frequency using the 32k768 cystal as reference.
51 P3OUT = 0x00; //switch off LED
53 TACTL = TACTL_AFTER_FLL; //setup timer (still stopped)
54 CCTL0 = CCIE|CAP|CM_2|CCIS_1|SCS; //select P2.2 with UART signal
57 TACTL |= MC1; //start timer
59 eint(); //enable interrupts
61 printf("\r\n====== openMSP430 in action ======\r\n"); //say hello
62 printf("\r\nSimple Line Editor Ready\r\n"); //say hello
64 while (1) { //main loop, never ends...
65 printf("> "); //show prompt
67 while (reading) { //loop and read characters
68 LPM0; //sync, wakeup by irq
70 led++; // Some lighting...
74 P3OUT = (0x01 << led);
80 printf("\r\n"); //finish line
81 buf[pos++] = 0; //to use printf...
82 printf(":%s\r\n", buf);
83 reading = 0; //exit read loop
84 pos = 0; //reset buffer
88 if (pos > 0) { //is there a char to delete?
89 pos--; //remove it in buffer
90 putchar('\b'); //go back
91 putchar(' '); //erase on screen
92 putchar('\b'); //go back
97 //only store characters if buffer has space
98 if (pos < sizeof(buf)) {
99 putchar(rxdata); //echo
100 buf[pos++] = rxdata; //store