Workaround unused-but-set-variable warning.
authorDan White <dan@whiteaudio.com>
Sun, 1 Feb 2015 19:27:55 +0000 (13:27 -0600)
committerDan White <dan@whiteaudio.com>
Sun, 1 Feb 2015 19:27:55 +0000 (13:27 -0600)
The UART status register must be read to clear the flags and enable operation.
Previously, it was read into a dummy variable which triggered the warning.
Attempts to suppress the warning didn't work for some reason, but the
statement "UART0_SR;" is sufficient to emit assembly to read the register.

I don't trust this to always work, so there is a comment with the purpose
of the line.

msp4th/main.c

index e14e849c3667538dac1ac5e44c18dbd913fe8b01..c389cbd54d6ff42bfbb8b40fd9fb2cdc4a1c84b2 100644 (file)
@@ -89,7 +89,6 @@ static void __inline__ eint(void){
 
 static __inline__ void init_uart(void)
 {
-    int16_t tmp;
     // chip setup for UART0 use
     PAPER = 0x0030;
     PAOUT = 0x0000;
@@ -99,7 +98,9 @@ static __inline__ void init_uart(void)
     UART0_CR = UARTEn;
 
     // a read clears the register -- ready for TX/RX
-    tmp = UART0_SR;
+    // NOTE: make sure the ASM actually reads this register
+    //       and isn't "optimized" out.  So far, no problems...
+    UART0_SR;
 }