Pārlūkot izejas kodu

Teensylu support.

Erik van der Zalm 12 gadus atpakaļ
vecāks
revīzija
9173a5713b

+ 1
- 1
Marlin/Configuration.h Parādīt failu

@@ -171,7 +171,7 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
171 171
 
172 172
 //LCD and SD support
173 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 176
 //#define ULTIPANEL
177 177
 #ifdef ULTIPANEL

+ 9
- 5
Marlin/Marlin.h Parādīt failu

@@ -46,7 +46,11 @@
46 46
 
47 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 55
 //this is a unfinsihed attemp to removes a lot of warning messages, see:
52 56
 // http://www.avrfreaks.net/index.php?name=PNphpBB2&file=printview&t=57011
@@ -59,10 +63,10 @@
59 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 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 72
 const prog_char errormagic[] PROGMEM ="Error:";
@@ -89,7 +93,7 @@ FORCE_INLINE void serialprintPGM(const char *str)
89 93
   char ch=pgm_read_byte(str);
90 94
   while(ch)
91 95
   {
92
-    MSerial.write(ch);
96
+    SERIAL.write(ch);
93 97
     ch=pgm_read_byte(++str);
94 98
   }
95 99
 }

+ 4
- 4
Marlin/Marlin.pde Parādīt failu

@@ -247,7 +247,7 @@ void suicide()
247 247
 void setup()
248 248
 { 
249 249
   setup_powerhold();
250
-  MSerial.begin(BAUDRATE);
250
+  SERIAL.begin(BAUDRATE);
251 251
   SERIAL_ECHO_START;
252 252
   SERIAL_ECHOLNPGM(VERSION_STRING);
253 253
   SERIAL_PROTOCOLLNPGM("start");
@@ -318,8 +318,8 @@ void loop()
318 318
 
319 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 323
     if(serial_char == '\n' || serial_char == '\r' || serial_char == ':' || serial_count >= (MAX_CMD_SIZE - 1) ) 
324 324
     {
325 325
       if(!serial_count) return; //if empty line
@@ -1209,7 +1209,7 @@ void process_commands()
1209 1209
 void FlushSerialRequestResend()
1210 1210
 {
1211 1211
   //char cmdbuffer[bufindr][100]="Resend:";
1212
-  MSerial.flush();
1212
+  SERIAL.flush();
1213 1213
   SERIAL_PROTOCOLPGM("Resend:");
1214 1214
   SERIAL_PROTOCOLLN(gcode_LastN + 1);
1215 1215
   ClearToSend();

+ 3
- 8
Marlin/MarlinSerial.cpp Parādīt failu

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

+ 3
- 4
Marlin/MarlinSerial.h Parādīt failu

@@ -31,7 +31,7 @@
31 31
 #define BYTE 0
32 32
 
33 33
 
34
-
34
+#if MOTHERBOARD != 8 // ! teensylu
35 35
 // Define constants and variables for buffering incoming serial data.  We're
36 36
 // using a ring buffer (I think), in which rx_buffer_head is the index of the
37 37
 // location to which to write the next incoming character and rx_buffer_tail
@@ -144,8 +144,7 @@ class MarlinSerial //: public Stream
144 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 150
 #endif

+ 23
- 25
Marlin/SdBaseFile.cpp Parādīt failu

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

+ 2
- 2
Marlin/SdFatUtil.cpp Parādīt failu

@@ -48,7 +48,7 @@ int SdFatUtil::FreeRam() {
48 48
  * \param[in] str Pointer to string stored in flash memory.
49 49
  */
50 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 54
 /** %Print a string in flash memory followed by a CR/LF.
@@ -58,7 +58,7 @@ void SdFatUtil::print_P( PGM_P str) {
58 58
  */
59 59
 void SdFatUtil::println_P( PGM_P str) {
60 60
   print_P( str);
61
-  MSerial.println();
61
+  SERIAL.println();
62 62
 }
63 63
 //------------------------------------------------------------------------------
64 64
 /** %Print a string in flash memory to Serial.

+ 1
- 1
Marlin/fastio.h Parādīt failu

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

+ 4
- 2
Marlin/stepper.cpp Parādīt failu

@@ -254,7 +254,7 @@ FORCE_INLINE unsigned short calc_timer(unsigned short step_rate) {
254 254
     timer = (unsigned short)pgm_read_word_near(table_address);
255 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 258
   return timer;
259 259
 }
260 260
 
@@ -439,7 +439,9 @@ ISR(TIMER1_COMPA_vect)
439 439
 
440 440
     
441 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 446
       #ifdef ADVANCE
445 447
       counter_e += current_block->steps_e;

Notiek ielāde…
Atcelt
Saglabāt