Browse Source

Teensylu support.

Erik van der Zalm 13 years ago
parent
commit
9173a5713b

+ 1
- 1
Marlin/Configuration.h View File

171
 
171
 
172
 //LCD and SD support
172
 //LCD and SD support
173
 //#define ULTRA_LCD  //general lcd support, also 16x2
173
 //#define ULTRA_LCD  //general lcd support, also 16x2
174
-//#define SDSUPPORT // Enable SD Card Support in Hardware Console
174
+#define SDSUPPORT // Enable SD Card Support in Hardware Console
175
 
175
 
176
 //#define ULTIPANEL
176
 //#define ULTIPANEL
177
 #ifdef ULTIPANEL
177
 #ifdef ULTIPANEL

+ 9
- 5
Marlin/Marlin.h View File

46
 
46
 
47
 #include "WString.h"
47
 #include "WString.h"
48
 
48
 
49
-
49
+#if MOTHERBOARD == 8  // Teensylu
50
+  #define SERIAL Serial
51
+#else
52
+  #define SERIAL MSerial
53
+#endif
50
 
54
 
51
 //this is a unfinsihed attemp to removes a lot of warning messages, see:
55
 //this is a unfinsihed attemp to removes a lot of warning messages, see:
52
 // http://www.avrfreaks.net/index.php?name=PNphpBB2&file=printview&t=57011
56
 // http://www.avrfreaks.net/index.php?name=PNphpBB2&file=printview&t=57011
59
 //#define MYPGM(s)  (__extension__({static prog_char __c[]  = (s); &__c[0];})) //this does not work but hides the warnings
63
 //#define MYPGM(s)  (__extension__({static prog_char __c[]  = (s); &__c[0];})) //this does not work but hides the warnings
60
 
64
 
61
 
65
 
62
-#define SERIAL_PROTOCOL(x) MSerial.print(x);
66
+#define SERIAL_PROTOCOL(x) SERIAL.print(x);
63
 #define SERIAL_PROTOCOLPGM(x) serialprintPGM(MYPGM(x));
67
 #define SERIAL_PROTOCOLPGM(x) serialprintPGM(MYPGM(x));
64
-#define SERIAL_PROTOCOLLN(x) {MSerial.print(x);MSerial.write('\n');}
65
-#define SERIAL_PROTOCOLLNPGM(x) {serialprintPGM(MYPGM(x));MSerial.write('\n');}
68
+#define SERIAL_PROTOCOLLN(x) {SERIAL.print(x);SERIAL.write('\n');}
69
+#define SERIAL_PROTOCOLLNPGM(x) {serialprintPGM(MYPGM(x));SERIAL.write('\n');}
66
 
70
 
67
 
71
 
68
 const prog_char errormagic[] PROGMEM ="Error:";
72
 const prog_char errormagic[] PROGMEM ="Error:";
89
   char ch=pgm_read_byte(str);
93
   char ch=pgm_read_byte(str);
90
   while(ch)
94
   while(ch)
91
   {
95
   {
92
-    MSerial.write(ch);
96
+    SERIAL.write(ch);
93
     ch=pgm_read_byte(++str);
97
     ch=pgm_read_byte(++str);
94
   }
98
   }
95
 }
99
 }

+ 4
- 4
Marlin/Marlin.pde View File

247
 void setup()
247
 void setup()
248
 { 
248
 { 
249
   setup_powerhold();
249
   setup_powerhold();
250
-  MSerial.begin(BAUDRATE);
250
+  SERIAL.begin(BAUDRATE);
251
   SERIAL_ECHO_START;
251
   SERIAL_ECHO_START;
252
   SERIAL_ECHOLNPGM(VERSION_STRING);
252
   SERIAL_ECHOLNPGM(VERSION_STRING);
253
   SERIAL_PROTOCOLLNPGM("start");
253
   SERIAL_PROTOCOLLNPGM("start");
318
 
318
 
319
 void get_command() 
319
 void get_command() 
320
 { 
320
 { 
321
-  while( MSerial.available() > 0  && buflen < BUFSIZE) {
322
-    serial_char = MSerial.read();
321
+  while( SERIAL.available() > 0  && buflen < BUFSIZE) {
322
+    serial_char = SERIAL.read();
323
     if(serial_char == '\n' || serial_char == '\r' || serial_char == ':' || serial_count >= (MAX_CMD_SIZE - 1) ) 
323
     if(serial_char == '\n' || serial_char == '\r' || serial_char == ':' || serial_count >= (MAX_CMD_SIZE - 1) ) 
324
     {
324
     {
325
       if(!serial_count) return; //if empty line
325
       if(!serial_count) return; //if empty line
1209
 void FlushSerialRequestResend()
1209
 void FlushSerialRequestResend()
1210
 {
1210
 {
1211
   //char cmdbuffer[bufindr][100]="Resend:";
1211
   //char cmdbuffer[bufindr][100]="Resend:";
1212
-  MSerial.flush();
1212
+  SERIAL.flush();
1213
   SERIAL_PROTOCOLPGM("Resend:");
1213
   SERIAL_PROTOCOLPGM("Resend:");
1214
   SERIAL_PROTOCOLLN(gcode_LastN + 1);
1214
   SERIAL_PROTOCOLLN(gcode_LastN + 1);
1215
   ClearToSend();
1215
   ClearToSend();

+ 3
- 8
Marlin/MarlinSerial.cpp View File

23
 #include "Marlin.h"
23
 #include "Marlin.h"
24
 #include "MarlinSerial.h"
24
 #include "MarlinSerial.h"
25
 
25
 
26
+#if MOTHERBOARD != 8 // !teensylu
26
 // this next line disables the entire HardwareSerial.cpp, 
27
 // this next line disables the entire HardwareSerial.cpp, 
27
 // this is so I can support Attiny series and any other chip without a uart
28
 // this is so I can support Attiny series and any other chip without a uart
28
 #if defined(UBRRH) || defined(UBRR0H) || defined(UBRR1H) || defined(UBRR2H) || defined(UBRR3H)
29
 #if defined(UBRRH) || defined(UBRR0H) || defined(UBRR1H) || defined(UBRR2H) || defined(UBRR3H)
29
 
30
 
30
-
31
-
32
-
33
-
34
-
35
 #if defined(UBRRH) || defined(UBRR0H)
31
 #if defined(UBRRH) || defined(UBRR0H)
36
   ring_buffer rx_buffer  =  { { 0 }, 0, 0 };
32
   ring_buffer rx_buffer  =  { { 0 }, 0, 0 };
37
 #endif
33
 #endif
38
 
34
 
39
-
40
 FORCE_INLINE void store_char(unsigned char c)
35
 FORCE_INLINE void store_char(unsigned char c)
41
 {
36
 {
42
   int i = (unsigned int)(rx_buffer.head + 1) % RX_BUFFER_SIZE;
37
   int i = (unsigned int)(rx_buffer.head + 1) % RX_BUFFER_SIZE;
324
     remainder -= toPrint; 
319
     remainder -= toPrint; 
325
   } 
320
   } 
326
 }
321
 }
327
-
328
 // Preinstantiate Objects //////////////////////////////////////////////////////
322
 // Preinstantiate Objects //////////////////////////////////////////////////////
329
 
323
 
330
-MarlinSerial MSerial;
331
 
324
 
325
+MarlinSerial MSerial;
332
 
326
 
333
 #endif // whole file
327
 #endif // whole file
328
+#endif //teensylu
334
 
329
 

+ 3
- 4
Marlin/MarlinSerial.h View File

31
 #define BYTE 0
31
 #define BYTE 0
32
 
32
 
33
 
33
 
34
-
34
+#if MOTHERBOARD != 8 // ! teensylu
35
 // Define constants and variables for buffering incoming serial data.  We're
35
 // Define constants and variables for buffering incoming serial data.  We're
36
 // using a ring buffer (I think), in which rx_buffer_head is the index of the
36
 // using a ring buffer (I think), in which rx_buffer_head is the index of the
37
 // location to which to write the next incoming character and rx_buffer_tail
37
 // location to which to write the next incoming character and rx_buffer_tail
144
     void println(void);
144
     void println(void);
145
 };
145
 };
146
 
146
 
147
-#if defined(UBRRH) || defined(UBRR0H)
148
-  extern MarlinSerial MSerial;
149
-#endif
147
+extern MarlinSerial MSerial;
148
+#endif // ! teensylu
150
 
149
 
151
 #endif
150
 #endif

+ 23
- 25
Marlin/SdBaseFile.cpp View File

18
  * <http://www.gnu.org/licenses/>.
18
  * <http://www.gnu.org/licenses/>.
19
  */
19
  */
20
 
20
 
21
-#define SERIAL MSerial
22
-
23
 #include "Marlin.h"
21
 #include "Marlin.h"
24
 #ifdef SDSUPPORT
22
 #ifdef SDSUPPORT
25
 
23
 
345
       && DIR_IS_FILE_OR_SUBDIR(&dir)) break;
343
       && DIR_IS_FILE_OR_SUBDIR(&dir)) break;
346
   }
344
   }
347
   // indent for dir level
345
   // indent for dir level
348
-  for (uint8_t i = 0; i < indent; i++) MSerial.write(' ');
346
+  for (uint8_t i = 0; i < indent; i++) SERIAL.write(' ');
349
 
347
 
350
   // print name
348
   // print name
351
   for (uint8_t i = 0; i < 11; i++) {
349
   for (uint8_t i = 0; i < 11; i++) {
352
     if (dir.name[i] == ' ')continue;
350
     if (dir.name[i] == ' ')continue;
353
     if (i == 8) {
351
     if (i == 8) {
354
-      MSerial.write('.');
352
+      SERIAL.write('.');
355
       w++;
353
       w++;
356
     }
354
     }
357
-    MSerial.write(dir.name[i]);
355
+    SERIAL.write(dir.name[i]);
358
     w++;
356
     w++;
359
   }
357
   }
360
   if (DIR_IS_SUBDIR(&dir)) {
358
   if (DIR_IS_SUBDIR(&dir)) {
361
-    MSerial.write('/');
359
+    SERIAL.write('/');
362
     w++;
360
     w++;
363
   }
361
   }
364
   if (flags & (LS_DATE | LS_SIZE)) {
362
   if (flags & (LS_DATE | LS_SIZE)) {
365
-    while (w++ < 14) MSerial.write(' ');
363
+    while (w++ < 14) SERIAL.write(' ');
366
   }
364
   }
367
   // print modify date/time if requested
365
   // print modify date/time if requested
368
   if (flags & LS_DATE) {
366
   if (flags & LS_DATE) {
369
-    MSerial.write(' ');
367
+    SERIAL.write(' ');
370
     printFatDate( dir.lastWriteDate);
368
     printFatDate( dir.lastWriteDate);
371
-    MSerial.write(' ');
369
+    SERIAL.write(' ');
372
     printFatTime( dir.lastWriteTime);
370
     printFatTime( dir.lastWriteTime);
373
   }
371
   }
374
   // print size if requested
372
   // print size if requested
375
   if (!DIR_IS_SUBDIR(&dir) && (flags & LS_SIZE)) {
373
   if (!DIR_IS_SUBDIR(&dir) && (flags & LS_SIZE)) {
376
-    MSerial.write(' ');
377
-    MSerial.print(dir.fileSize);
374
+    SERIAL.write(' ');
375
+    SERIAL.print(dir.fileSize);
378
   }
376
   }
379
-  MSerial.println();
377
+  SERIAL.println();
380
   return DIR_IS_FILE(&dir) ? 1 : 2;
378
   return DIR_IS_FILE(&dir) ? 1 : 2;
381
 }
379
 }
382
 //------------------------------------------------------------------------------
380
 //------------------------------------------------------------------------------
947
   for (uint8_t i = 0; i < 11; i++) {
945
   for (uint8_t i = 0; i < 11; i++) {
948
     if (dir.name[i] == ' ')continue;
946
     if (dir.name[i] == ' ')continue;
949
     if (i == 8) {
947
     if (i == 8) {
950
-      MSerial.write('.');
948
+      SERIAL.write('.');
951
       w++;
949
       w++;
952
     }
950
     }
953
-    MSerial.write(dir.name[i]);
951
+    SERIAL.write(dir.name[i]);
954
     w++;
952
     w++;
955
   }
953
   }
956
   if (DIR_IS_SUBDIR(&dir) && printSlash) {
954
   if (DIR_IS_SUBDIR(&dir) && printSlash) {
957
-    MSerial.write('/');
955
+    SERIAL.write('/');
958
     w++;
956
     w++;
959
   }
957
   }
960
   while (w < width) {
958
   while (w < width) {
961
-    MSerial.write(' ');
959
+    SERIAL.write(' ');
962
     w++;
960
     w++;
963
   }
961
   }
964
 }
962
 }
965
 //------------------------------------------------------------------------------
963
 //------------------------------------------------------------------------------
966
 // print uint8_t with width 2
964
 // print uint8_t with width 2
967
 static void print2u( uint8_t v) {
965
 static void print2u( uint8_t v) {
968
-  if (v < 10) MSerial.write('0');
969
-  MSerial.print(v, DEC);
966
+  if (v < 10) SERIAL.write('0');
967
+  SERIAL.print(v, DEC);
970
 }
968
 }
971
 //------------------------------------------------------------------------------
969
 //------------------------------------------------------------------------------
972
 /** %Print a directory date field to Serial.
970
 /** %Print a directory date field to Serial.
985
  * \param[in] fatDate The date field from a directory entry.
983
  * \param[in] fatDate The date field from a directory entry.
986
  */
984
  */
987
 void SdBaseFile::printFatDate(uint16_t fatDate) {
985
 void SdBaseFile::printFatDate(uint16_t fatDate) {
988
-  MSerial.print(FAT_YEAR(fatDate));
989
-  MSerial.write('-');
986
+  SERIAL.print(FAT_YEAR(fatDate));
987
+  SERIAL.write('-');
990
   print2u( FAT_MONTH(fatDate));
988
   print2u( FAT_MONTH(fatDate));
991
-  MSerial.write('-');
989
+  SERIAL.write('-');
992
   print2u( FAT_DAY(fatDate));
990
   print2u( FAT_DAY(fatDate));
993
 }
991
 }
994
 
992
 
1002
  */
1000
  */
1003
 void SdBaseFile::printFatTime( uint16_t fatTime) {
1001
 void SdBaseFile::printFatTime( uint16_t fatTime) {
1004
   print2u( FAT_HOUR(fatTime));
1002
   print2u( FAT_HOUR(fatTime));
1005
-  MSerial.write(':');
1003
+  SERIAL.write(':');
1006
   print2u( FAT_MINUTE(fatTime));
1004
   print2u( FAT_MINUTE(fatTime));
1007
-  MSerial.write(':');
1005
+  SERIAL.write(':');
1008
   print2u( FAT_SECOND(fatTime));
1006
   print2u( FAT_SECOND(fatTime));
1009
 }
1007
 }
1010
 //------------------------------------------------------------------------------
1008
 //------------------------------------------------------------------------------
1016
 bool SdBaseFile::printName() {
1014
 bool SdBaseFile::printName() {
1017
   char name[13];
1015
   char name[13];
1018
   if (!getFilename(name)) return false;
1016
   if (!getFilename(name)) return false;
1019
-  MSerial.print(name);
1017
+  SERIAL.print(name);
1020
   return true;
1018
   return true;
1021
 }
1019
 }
1022
 //------------------------------------------------------------------------------
1020
 //------------------------------------------------------------------------------
1790
 #endif  // ALLOW_DEPRECATED_FUNCTIONS
1788
 #endif  // ALLOW_DEPRECATED_FUNCTIONS
1791
 
1789
 
1792
 
1790
 
1793
-#endif
1791
+#endif

+ 2
- 2
Marlin/SdFatUtil.cpp View File

48
  * \param[in] str Pointer to string stored in flash memory.
48
  * \param[in] str Pointer to string stored in flash memory.
49
  */
49
  */
50
 void SdFatUtil::print_P( PGM_P str) {
50
 void SdFatUtil::print_P( PGM_P str) {
51
-  for (uint8_t c; (c = pgm_read_byte(str)); str++) MSerial.write(c);
51
+  for (uint8_t c; (c = pgm_read_byte(str)); str++) SERIAL.write(c);
52
 }
52
 }
53
 //------------------------------------------------------------------------------
53
 //------------------------------------------------------------------------------
54
 /** %Print a string in flash memory followed by a CR/LF.
54
 /** %Print a string in flash memory followed by a CR/LF.
58
  */
58
  */
59
 void SdFatUtil::println_P( PGM_P str) {
59
 void SdFatUtil::println_P( PGM_P str) {
60
   print_P( str);
60
   print_P( str);
61
-  MSerial.println();
61
+  SERIAL.println();
62
 }
62
 }
63
 //------------------------------------------------------------------------------
63
 //------------------------------------------------------------------------------
64
 /** %Print a string in flash memory to Serial.
64
 /** %Print a string in flash memory to Serial.

+ 1
- 1
Marlin/fastio.h View File

1928
 
1928
 
1929
 #endif
1929
 #endif
1930
 
1930
 
1931
-#if defined (__AVR_AT90USB1287__)
1931
+#if defined (__AVR_AT90USB1287__) || defined (__AVR_AT90USB1286__)
1932
 // SPI
1932
 // SPI
1933
 #define	SCK					DIO9
1933
 #define	SCK					DIO9
1934
 #define	MISO				DIO11
1934
 #define	MISO				DIO11

+ 4
- 2
Marlin/stepper.cpp View File

254
     timer = (unsigned short)pgm_read_word_near(table_address);
254
     timer = (unsigned short)pgm_read_word_near(table_address);
255
     timer -= (((unsigned short)pgm_read_word_near(table_address+2) * (unsigned char)(step_rate & 0x0007))>>3);
255
     timer -= (((unsigned short)pgm_read_word_near(table_address+2) * (unsigned char)(step_rate & 0x0007))>>3);
256
   }
256
   }
257
-  if(timer < 100) { timer = 100; MSerial.print("Steprate to high : "); MSerial.println(step_rate); }//(20kHz this should never happen)
257
+  if(timer < 100) { timer = 100; SERIAL.print("Steprate to high : "); SERIAL.println(step_rate); }//(20kHz this should never happen)
258
   return timer;
258
   return timer;
259
 }
259
 }
260
 
260
 
439
 
439
 
440
     
440
     
441
     for(int8_t i=0; i < step_loops; i++) { // Take multiple steps per interrupt (For high speed moves) 
441
     for(int8_t i=0; i < step_loops; i++) { // Take multiple steps per interrupt (For high speed moves) 
442
-      MSerial.checkRx(); // Check for serial chars. 
442
+      #if MOTHERBOARD != 8 // !teensylu
443
+      MSerial.checkRx(); // Check for serial chars.
444
+      #endif 
443
       
445
       
444
       #ifdef ADVANCE
446
       #ifdef ADVANCE
445
       counter_e += current_block->steps_e;
447
       counter_e += current_block->steps_e;

Loading…
Cancel
Save