1
0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2024-11-23 12:04:19 +00:00

Teensylu support.

This commit is contained in:
Erik van der Zalm 2012-02-09 19:27:45 +01:00
parent da040fd393
commit 9173a5713b
9 changed files with 50 additions and 52 deletions

View 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

View File

@ -46,7 +46,11 @@
#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
@ -59,10 +63,10 @@
//#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);
}
}

View 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();

View File

@ -23,20 +23,15 @@
#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;
#endif // whole file
#endif //teensylu

View 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

View 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
#endif

View 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.

View 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

View 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;