chiark / gitweb /
inlineing of small functions in serial
authorBernhard <bkubicek@x201.(none)>
Mon, 28 Nov 2011 18:34:42 +0000 (19:34 +0100)
committerBernhard <bkubicek@x201.(none)>
Mon, 28 Nov 2011 18:34:42 +0000 (19:34 +0100)
Marlin/MarlinSerial.cpp
Marlin/MarlinSerial.h

index fb34ab19bb8ba56d80463da12949dcba647d7ed4..6cf47eafe337f530fe9e30b295b1c659481bb07b 100644 (file)
@@ -161,31 +161,9 @@ void MarlinSerial::flush()
 
 
 /// imports from print.h
-/* default implementation: may be overridden */
-void MarlinSerial::write(const char *str)
-{
-  while (*str)
-    write(*str++);
-}
 
-/* default implementation: may be overridden */
-void MarlinSerial::write(const uint8_t *buffer, size_t size)
-{
-  while (size--)
-    write(*buffer++);
-}
 
-void MarlinSerial::print(const String &s)
-{
-  for (int i = 0; i < s.length(); i++) {
-    write(s[i]);
-  }
-}
 
-void MarlinSerial::print(const char str[])
-{
-  write(str);
-}
 
 void MarlinSerial::print(char c, int base)
 {
@@ -353,11 +331,7 @@ void MarlinSerial::printFloat(double number, uint8_t digits)
 
 // Preinstantiate Objects //////////////////////////////////////////////////////
 
-#if defined(UBRR0H) && defined(UBRR0L)
-  MarlinSerial MSerial;
-#else
-  #error no serial port defined  (port 0)
-#endif
+MarlinSerial MSerial;
 
 
 #endif // whole file
index 30c0f5a344855aba30f2f42ae23ab0bc9a77ee32..9ff07912b9305650541ac54b8496c5edbc30bcce 100644 (file)
@@ -51,13 +51,15 @@ class MarlinSerial //: public Stream
     MarlinSerial();
     void begin(long);
     void end();
+    int peek(void);
+    int read(void);
+    void flush(void);
+    
     inline int available(void)
     {
       return (unsigned int)(RX_BUFFER_SIZE + rx_buffer.head - rx_buffer.tail) % RX_BUFFER_SIZE;
     }
-    int peek(void);
-    int read(void);
-    void flush(void);
+    
     inline void write(uint8_t c)
     {
       while (!((UCSR0A) & (1 << UDRE0)))
@@ -91,11 +93,31 @@ class MarlinSerial //: public Stream
     
     
   public:
-    void write(const char *str);
-    void write( const uint8_t *buffer, size_t size);
     
-    void print(const String &);
-    void print(const char[]);
+    inline void write(const char *str)
+    {
+      while (*str)
+        write(*str++);
+    }
+
+
+    inline void write(const uint8_t *buffer, size_t size)
+    {
+      while (size--)
+        write(*buffer++);
+    }
+
+    inline void print(const String &s)
+    {
+      for (int i = 0; i < s.length(); i++) {
+        write(s[i]);
+      }
+    }
+    
+    inline void print(const char *str)
+    {
+      write(str);
+    }
     void print(char, int = BYTE);
     void print(unsigned char, int = BYTE);
     void print(int, int = DEC);