chiark / gitweb /
Teensylu support.
authorErik van der Zalm <erik@vdzalm.eu>
Thu, 9 Feb 2012 18:27:45 +0000 (19:27 +0100)
committerErik van der Zalm <erik@vdzalm.eu>
Thu, 9 Feb 2012 18:27:45 +0000 (19:27 +0100)
Marlin/Configuration.h
Marlin/Marlin.h
Marlin/Marlin.pde
Marlin/MarlinSerial.cpp
Marlin/MarlinSerial.h
Marlin/SdBaseFile.cpp
Marlin/SdFatUtil.cpp
Marlin/fastio.h
Marlin/stepper.cpp

index fe79a9c396b1ba68003740f9faed110eee19c6b5..9e14a47fc3087f63ecc9792fc6d29020b86accb2 100644 (file)
@@ -171,7 +171,7 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
 
 //LCD and SD support
 //#define ULTRA_LCD  //general lcd support, also 16x2
-//#define SDSUPPORT // Enable SD Card Support in Hardware Console
+#define SDSUPPORT // Enable SD Card Support in Hardware Console
 
 //#define ULTIPANEL
 #ifdef ULTIPANEL
index 78739af246512831bd858d63f51d6590c7b02470..818c6ffe6cd9b4de5e6059f99cae405a00aa2f25 100644 (file)
 
 #include "WString.h"
 
-
+#if MOTHERBOARD == 8  // Teensylu
+  #define SERIAL Serial
+#else
+  #define SERIAL MSerial
+#endif
 
 //this is a unfinsihed attemp to removes a lot of warning messages, see:
 // http://www.avrfreaks.net/index.php?name=PNphpBB2&file=printview&t=57011
 //#define MYPGM(s)  (__extension__({static prog_char __c[]  = (s); &__c[0];})) //this does not work but hides the warnings
 
 
-#define SERIAL_PROTOCOL(x) MSerial.print(x);
+#define SERIAL_PROTOCOL(x) SERIAL.print(x);
 #define SERIAL_PROTOCOLPGM(x) serialprintPGM(MYPGM(x));
-#define SERIAL_PROTOCOLLN(x) {MSerial.print(x);MSerial.write('\n');}
-#define SERIAL_PROTOCOLLNPGM(x) {serialprintPGM(MYPGM(x));MSerial.write('\n');}
+#define SERIAL_PROTOCOLLN(x) {SERIAL.print(x);SERIAL.write('\n');}
+#define SERIAL_PROTOCOLLNPGM(x) {serialprintPGM(MYPGM(x));SERIAL.write('\n');}
 
 
 const prog_char errormagic[] PROGMEM ="Error:";
@@ -89,7 +93,7 @@ FORCE_INLINE void serialprintPGM(const char *str)
   char ch=pgm_read_byte(str);
   while(ch)
   {
-    MSerial.write(ch);
+    SERIAL.write(ch);
     ch=pgm_read_byte(++str);
   }
 }
index 57ededa2ef1c8e1270a549fb12ae00bd0d8df9a5..5c20bd657dd06a4815ade092c6704c01798e9e05 100644 (file)
@@ -247,7 +247,7 @@ void suicide()
 void setup()
 { 
   setup_powerhold();
-  MSerial.begin(BAUDRATE);
+  SERIAL.begin(BAUDRATE);
   SERIAL_ECHO_START;
   SERIAL_ECHOLNPGM(VERSION_STRING);
   SERIAL_PROTOCOLLNPGM("start");
@@ -318,8 +318,8 @@ void loop()
 
 void get_command() 
 { 
-  while( MSerial.available() > 0  && buflen < BUFSIZE) {
-    serial_char = MSerial.read();
+  while( SERIAL.available() > 0  && buflen < BUFSIZE) {
+    serial_char = SERIAL.read();
     if(serial_char == '\n' || serial_char == '\r' || serial_char == ':' || serial_count >= (MAX_CMD_SIZE - 1) ) 
     {
       if(!serial_count) return; //if empty line
@@ -1209,7 +1209,7 @@ void process_commands()
 void FlushSerialRequestResend()
 {
   //char cmdbuffer[bufindr][100]="Resend:";
-  MSerial.flush();
+  SERIAL.flush();
   SERIAL_PROTOCOLPGM("Resend:");
   SERIAL_PROTOCOLLN(gcode_LastN + 1);
   ClearToSend();
index 7175561e23adfed38b9c2bf5dc7fdf86f3616bca..e369800b893b31412cde34b559acc3da0141cdd9 100644 (file)
 #include "Marlin.h"
 #include "MarlinSerial.h"
 
+#if MOTHERBOARD != 8 // !teensylu
 // this next line disables the entire HardwareSerial.cpp, 
 // this is so I can support Attiny series and any other chip without a uart
 #if defined(UBRRH) || defined(UBRR0H) || defined(UBRR1H) || defined(UBRR2H) || defined(UBRR3H)
 
-
-
-
-
-
 #if defined(UBRRH) || defined(UBRR0H)
   ring_buffer rx_buffer  =  { { 0 }, 0, 0 };
 #endif
 
-
 FORCE_INLINE void store_char(unsigned char c)
 {
   int i = (unsigned int)(rx_buffer.head + 1) % RX_BUFFER_SIZE;
@@ -324,11 +319,11 @@ void MarlinSerial::printFloat(double number, uint8_t digits)
     remainder -= toPrint; 
   } 
 }
-
 // Preinstantiate Objects //////////////////////////////////////////////////////
 
-MarlinSerial MSerial;
 
+MarlinSerial MSerial;
 
 #endif // whole file
+#endif //teensylu
 
index 71823de8f1f59051980d59b268f882065184d1fd..8525cba288d396ed893174489cb7ccafc0e98391 100644 (file)
@@ -31,7 +31,7 @@
 #define BYTE 0
 
 
-
+#if MOTHERBOARD != 8 // ! teensylu
 // Define constants and variables for buffering incoming serial data.  We're
 // using a ring buffer (I think), in which rx_buffer_head is the index of the
 // location to which to write the next incoming character and rx_buffer_tail
@@ -144,8 +144,7 @@ class MarlinSerial //: public Stream
     void println(void);
 };
 
-#if defined(UBRRH) || defined(UBRR0H)
-  extern MarlinSerial MSerial;
-#endif
+extern MarlinSerial MSerial;
+#endif // ! teensylu
 
 #endif
index f8dc83adeb9edd14b83df4a0b0410f6062281a10..450c9f327f563101998add8f892d6bd64518ebf8 100644 (file)
@@ -18,8 +18,6 @@
  * <http://www.gnu.org/licenses/>.
  */
 
-#define SERIAL MSerial
-
 #include "Marlin.h"
 #ifdef SDSUPPORT
 
@@ -345,38 +343,38 @@ int8_t SdBaseFile::lsPrintNext( uint8_t flags, uint8_t indent) {
       && DIR_IS_FILE_OR_SUBDIR(&dir)) break;
   }
   // indent for dir level
-  for (uint8_t i = 0; i < indent; i++) MSerial.write(' ');
+  for (uint8_t i = 0; i < indent; i++) SERIAL.write(' ');
 
   // print name
   for (uint8_t i = 0; i < 11; i++) {
     if (dir.name[i] == ' ')continue;
     if (i == 8) {
-      MSerial.write('.');
+      SERIAL.write('.');
       w++;
     }
-    MSerial.write(dir.name[i]);
+    SERIAL.write(dir.name[i]);
     w++;
   }
   if (DIR_IS_SUBDIR(&dir)) {
-    MSerial.write('/');
+    SERIAL.write('/');
     w++;
   }
   if (flags & (LS_DATE | LS_SIZE)) {
-    while (w++ < 14) MSerial.write(' ');
+    while (w++ < 14) SERIAL.write(' ');
   }
   // print modify date/time if requested
   if (flags & LS_DATE) {
-    MSerial.write(' ');
+    SERIAL.write(' ');
     printFatDate( dir.lastWriteDate);
-    MSerial.write(' ');
+    SERIAL.write(' ');
     printFatTime( dir.lastWriteTime);
   }
   // print size if requested
   if (!DIR_IS_SUBDIR(&dir) && (flags & LS_SIZE)) {
-    MSerial.write(' ');
-    MSerial.print(dir.fileSize);
+    SERIAL.write(' ');
+    SERIAL.print(dir.fileSize);
   }
-  MSerial.println();
+  SERIAL.println();
   return DIR_IS_FILE(&dir) ? 1 : 2;
 }
 //------------------------------------------------------------------------------
@@ -947,26 +945,26 @@ void SdBaseFile::printDirName(const dir_t& dir,
   for (uint8_t i = 0; i < 11; i++) {
     if (dir.name[i] == ' ')continue;
     if (i == 8) {
-      MSerial.write('.');
+      SERIAL.write('.');
       w++;
     }
-    MSerial.write(dir.name[i]);
+    SERIAL.write(dir.name[i]);
     w++;
   }
   if (DIR_IS_SUBDIR(&dir) && printSlash) {
-    MSerial.write('/');
+    SERIAL.write('/');
     w++;
   }
   while (w < width) {
-    MSerial.write(' ');
+    SERIAL.write(' ');
     w++;
   }
 }
 //------------------------------------------------------------------------------
 // print uint8_t with width 2
 static void print2u( uint8_t v) {
-  if (v < 10) MSerial.write('0');
-  MSerial.print(v, DEC);
+  if (v < 10) SERIAL.write('0');
+  SERIAL.print(v, DEC);
 }
 //------------------------------------------------------------------------------
 /** %Print a directory date field to Serial.
@@ -985,10 +983,10 @@ static void print2u( uint8_t v) {
  * \param[in] fatDate The date field from a directory entry.
  */
 void SdBaseFile::printFatDate(uint16_t fatDate) {
-  MSerial.print(FAT_YEAR(fatDate));
-  MSerial.write('-');
+  SERIAL.print(FAT_YEAR(fatDate));
+  SERIAL.write('-');
   print2u( FAT_MONTH(fatDate));
-  MSerial.write('-');
+  SERIAL.write('-');
   print2u( FAT_DAY(fatDate));
 }
 
@@ -1002,9 +1000,9 @@ void SdBaseFile::printFatDate(uint16_t fatDate) {
  */
 void SdBaseFile::printFatTime( uint16_t fatTime) {
   print2u( FAT_HOUR(fatTime));
-  MSerial.write(':');
+  SERIAL.write(':');
   print2u( FAT_MINUTE(fatTime));
-  MSerial.write(':');
+  SERIAL.write(':');
   print2u( FAT_SECOND(fatTime));
 }
 //------------------------------------------------------------------------------
@@ -1016,7 +1014,7 @@ void SdBaseFile::printFatTime( uint16_t fatTime) {
 bool SdBaseFile::printName() {
   char name[13];
   if (!getFilename(name)) return false;
-  MSerial.print(name);
+  SERIAL.print(name);
   return true;
 }
 //------------------------------------------------------------------------------
@@ -1790,4 +1788,4 @@ void (*SdBaseFile::oldDateTime_)(uint16_t& date, uint16_t& time) = 0;  // NOLINT
 #endif  // ALLOW_DEPRECATED_FUNCTIONS
 
 
-#endif
\ No newline at end of file
+#endif
index ffbcba0c695d78865b2213f48f049e43b6154148..965f6ec21856dc453ca0458260f5b2f638b9f254 100644 (file)
@@ -48,7 +48,7 @@ int SdFatUtil::FreeRam() {
  * \param[in] str Pointer to string stored in flash memory.
  */
 void SdFatUtil::print_P( PGM_P str) {
-  for (uint8_t c; (c = pgm_read_byte(str)); str++) MSerial.write(c);
+  for (uint8_t c; (c = pgm_read_byte(str)); str++) SERIAL.write(c);
 }
 //------------------------------------------------------------------------------
 /** %Print a string in flash memory followed by a CR/LF.
@@ -58,7 +58,7 @@ void SdFatUtil::print_P( PGM_P str) {
  */
 void SdFatUtil::println_P( PGM_P str) {
   print_P( str);
-  MSerial.println();
+  SERIAL.println();
 }
 //------------------------------------------------------------------------------
 /** %Print a string in flash memory to Serial.
index 5188a0681a2fd3beeeecb30f5abc1cf1badd8a27..42f4ebb4f74ce76ce44830de5a58aa0f9631eb85 100644 (file)
@@ -1928,7 +1928,7 @@ pins
 
 #endif
 
-#if defined (__AVR_AT90USB1287__)
+#if defined (__AVR_AT90USB1287__) || defined (__AVR_AT90USB1286__)
 // SPI
 #define        SCK                                     DIO9
 #define        MISO                            DIO11
index 26c265e53200eb44db1230f01ac4869d021da9b3..994683f5d135dac30b066af7d179d8ed6cf755ee 100644 (file)
@@ -254,7 +254,7 @@ FORCE_INLINE unsigned short calc_timer(unsigned short step_rate) {
     timer = (unsigned short)pgm_read_word_near(table_address);
     timer -= (((unsigned short)pgm_read_word_near(table_address+2) * (unsigned char)(step_rate & 0x0007))>>3);
   }
-  if(timer < 100) { timer = 100; MSerial.print("Steprate to high : "); MSerial.println(step_rate); }//(20kHz this should never happen)
+  if(timer < 100) { timer = 100; SERIAL.print("Steprate to high : "); SERIAL.println(step_rate); }//(20kHz this should never happen)
   return timer;
 }
 
@@ -439,7 +439,9 @@ ISR(TIMER1_COMPA_vect)
 
     
     for(int8_t i=0; i < step_loops; i++) { // Take multiple steps per interrupt (For high speed moves) 
-      MSerial.checkRx(); // Check for serial chars. 
+      #if MOTHERBOARD != 8 // !teensylu
+      MSerial.checkRx(); // Check for serial chars.
+      #endif 
       
       #ifdef ADVANCE
       counter_e += current_block->steps_e;