CVS: examples/timerA_uart main.c, 1.4, 1.5 makefile, 1.8, 1.9 swuart.s, 1.5, 1.6
Chris Liechti <[email protected]> Mon, 30 Oct 2006 11:36:45 -0800
| Newsgroups | gmane.comp.hardware.texas-instruments.msp430.gcc.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/mspgcc/examples/timerA_uart
In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv6791/examples/timerA_uart
Modified Files:
main.c makefile swuart.s
Log Message:
- improve the example, using a custom interrupt handler
Index: main.c
===================================================================
RCS file: /cvsroot/mspgcc/examples/timerA_uart/main.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -w -d -r1.4 -r1.5
--- main.c 10 Oct 2003 03:13:52 -0000 1.4
+++ main.c 30 Oct 2006 19:36:41 -0000 1.5
@@ -19,14 +19,45 @@
}
}
+volatile int reading = 0;
+int pos = 0;
+char buf[40];
+
+wakeup interrupt(NOVECTOR) timer_uart_rx_interrupt(void) {
+ switch (rxdata) {
+ //process RETURN key, ingnore CR
+ case '\r':
+ break;
+ case '\n':
+ printf("\r\n"); //finish line
+ buf[pos++] = 0; //to use printf...
+ reading = 0; //exit read loop
+ break;
+ //backspace
+ case '\b':
+ if (pos > 0) { //is there a char to delete?
+ pos--; //remove it in buffer
+ putchar('\b'); //go back
+ putchar(' '); //erase on screen
+ putchar('\b'); //go back
+ }
+ break;
+ //other characters
+ default:
+ //only store characters if buffer has space
+ if (pos < sizeof(buf)) {
+ putchar(rxdata); //echo
+ buf[pos++] = rxdata; //store
+ }
+ }
+}
+
+
/**
Main function with init an an endless loop that is synced with the
interrupts trough the lowpower mode.
*/
int main(void) {
- int reading = 0;
- int pos = 0;
- char buf[40];
WDTCTL = WDTCTL_INIT; //Init watchdog timer
@@ -63,34 +94,9 @@
reading = 1;
while (reading) { //loop and read characters
LPM0; //sync, wakeup by irq
- switch (rxdata) {
- //process RETURN key
- case '\r':
- //case '\n':
- printf("\r\n"); //finish line
- buf[pos++] = 0; //to use printf...
+ }
printf(":%s\r\n", buf);
- reading = 0; //exit read loop
pos = 0; //reset buffer
- break;
- //backspace
- case '\b':
- if (pos > 0) { //is there a char to delete?
- pos--; //remove it in buffer
- putchar('\b'); //go back
- putchar(' '); //erase on screen
- putchar('\b'); //go back
- }
- break;
- //other characters
- default:
- //only store characters if buffer has space
- if (pos < sizeof(buf)) {
- putchar(rxdata); //echo
- buf[pos++] = rxdata; //store
- }
- }
- }
}
}
Index: makefile
===================================================================
RCS file: /cvsroot/mspgcc/examples/timerA_uart/makefile,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -w -d -r1.8 -r1.9
--- makefile 8 Jun 2004 07:05:29 -0000 1.8
+++ makefile 30 Oct 2006 19:36:41 -0000 1.9
@@ -16,8 +16,8 @@
all: ${NAME}.elf ${NAME}.a43 ${NAME}.lst
#confgigure the next line if you want to use the serial download
-download: download-jtag
-#download: download-bsl
+#~ download: download-jtag
+download: download-bsl
#additional rules for files
${NAME}.elf: ${OBJECTS}
Index: swuart.s
===================================================================
RCS file: /cvsroot/mspgcc/examples/timerA_uart/swuart.s,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -w -d -r1.5 -r1.6
--- swuart.s 10 Oct 2003 03:13:52 -0000 1.5
+++ swuart.s 30 Oct 2006 19:36:41 -0000 1.6
@@ -29,12 +29,7 @@
clr rxbit ;reset state
mov #CCIE|CAP|CM_2|CCIS_1|SCS, &CCTL0 ;restore capture mode
mov.b rxshift, rxdata ;copy received data
- bic #CPUOFF|OSCOFF|SCG0|SCG1, 0(r1) ;exit all lowpower modes
- ;here you might do other things too, like setting a flag
- ;that the wakeup comes from the Timer_A UART. however
- ;it should not take longer than one bit time, otherwise
- ;charcetrs will be lost.
- reti
+ br #timer_uart_rx_interrupt
.Lrxstart: ;startbit, init
clr rxshift ;clear input buffer
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642