Add lss file for cpp_obj program
[avr_serial_lcd.git] / serial_lcd.c
index 899e945bcbef5eb56803e48875bcf9d5eb76aaa1..bef0e8c463f004adf5e54eed0adaaca9be901741 100644 (file)
 #include "serial_lcd.h"\r
 \r
 #if defined(__GNUC__)\r
-FUSES = {\r
-  .low = SUT1, \r
-  .high = (unsigned char) (DWEN & WDTON & RSTDISBL & BODLEVEL1 & BODLEVEL2),\r
-  .extended = EFUSE_DEFAULT,\r
-};\r
+//FUSES = {\r
+// .low = SUT1,\r
+    //  .high = (unsigned char) (DWEN & WDTON & RSTDISBL & BODLEVEL1 & BODLEVEL2),\r
+    //  .extended = EFUSE_DEFAULT,\r
+    //};\r
 #endif\r
-  \r
+\r
 // Number of PWM brightness levels supported\r
 #define LED_BRIGHTNESS_LEVELS 8\r
 \r
@@ -40,20 +40,20 @@ FUSES = {
 #define        LCD_ON  0x0C\r
 // Clear display command\r
 #define LCD_CLR 0x01\r
-// Set 4 data bits \r
-#define LCD_4_Bit 0x20 \r
-// Set 8 data bits \r
-#define LCD_8_Bit 0x30 \r
-// Set number of lines \r
-#define LCD_4_Line 0x08 \r
+// Set 4 data bits\r
+#define LCD_4_Bit 0x20\r
+// Set 8 data bits\r
+#define LCD_8_Bit 0x30\r
+// Set number of lines\r
+#define LCD_4_Line 0x08\r
 // Set 8 data bits\r
 #define        DATA_8  0x30\r
-// Set character font \r
-#define LCD_Font 0x04 \r
-// Turn the cursor on \r
-#define LCD_CURSOR_ON 0x02 \r
-// Turn on cursor blink \r
-#define LCD_CURSOR_BLINK 0x01 \r
+// Set character font\r
+#define LCD_Font 0x04\r
+// Turn the cursor on\r
+#define LCD_CURSOR_ON 0x02\r
+// Turn on cursor blink\r
+#define LCD_CURSOR_BLINK 0x01\r
 \r
 ////// Serial command codes ///////\r
 // ASCII control code to set brightness level\r
@@ -419,14 +419,9 @@ unsigned char LcdBusyWait (void) {
   return (LCDStatus);\r
 }\r
 \r
-#if defined(__IMAGECRAFT__)\r
-#pragma interrupt_handler usart_rx_handler:iv_USART0_RXC\r
-void usart_rx_handler(void)\r
-#else\r
-ISR(USART_RX_vect)\r
-#endif\r
-{\r
-  unsigned char rx, tmphead;\r
+INLINE_FUNC_DECLARE(static void UartStoreRx (uint8_t rx));\r
+static inline void UartStoreRx (uint8_t rx) {\r
+  unsigned char tmphead;\r
 \r
   if (UCSRA & (1<<FE)) {\r
     // framing error. Currrently, this is silently ignored\r
@@ -434,13 +429,12 @@ ISR(USART_RX_vect)
     // erroroneous byte received\r
     return;\r
   }\r
-#if HANDLE_DATA_OVER_RUN_ERROR\r
+#ifdef HANDLE_DATA_OVER_RUN_ERROR\r
   if (UCSRA & (1<<DOR)) {\r
     // some applications may benefit from addind error notification for serial port data overruns\r
   }\r
 #endif\r
-  \r
-  rx = UDR;\r
+\r
   // Calculate next buffer position.\r
   tmphead = sUartRxHead;\r
   if (tmphead == UART_RX_BUFFER_SIZE-1)\r
@@ -468,6 +462,16 @@ ISR(USART_RX_vect)
 #endif\r
 }\r
 \r
+#if defined(__IMAGECRAFT__)\r
+#pragma interrupt_handler usart_rx_handler:iv_USART0_RXC\r
+void usart_rx_handler(void)\r
+#else\r
+ISR(USART_RX_vect)\r
+#endif\r
+{\r
+  UartStoreRx(UDR);\r
+}\r
+\r
 static unsigned char WaitRxChar (void) {\r
   // waits for next RX character, then return it\r
   unsigned char tail;\r