From d66d06934313cfc2373c167bac557f32d2efb203 Mon Sep 17 00:00:00 2001 From: Michael Moon Date: Thu, 25 Aug 2011 14:36:01 +1000 Subject: [PATCH 1/3] remove wiring.c and wiring_serial.c so we can compile in arduino 22 --- Marlin/wiring.c | 176 ----------------------------------------- Marlin/wiring_serial.c | 139 -------------------------------- 2 files changed, 315 deletions(-) delete mode 100644 Marlin/wiring.c delete mode 100644 Marlin/wiring_serial.c diff --git a/Marlin/wiring.c b/Marlin/wiring.c deleted file mode 100644 index adee6cbe44af..000000000000 --- a/Marlin/wiring.c +++ /dev/null @@ -1,176 +0,0 @@ -/* - wiring.c - Partial implementation of the Wiring API for the ATmega8. - Part of Arduino - http://www.arduino.cc/ - - Copyright (c) 2005-2006 David A. Mellis - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General - Public License along with this library; if not, write to the - Free Software Foundation, Inc., 59 Temple Place, Suite 330, - Boston, MA 02111-1307 USA - - $Id: wiring.c 388 2008-03-08 22:05:23Z mellis $ -*/ - -#include "wiring_private.h" - -volatile unsigned long timer0_millis = 0; - -SIGNAL(TIMER0_OVF_vect) -{ - // timer 0 prescale factor is 64 and the timer overflows at 256 - timer0_millis++; -} - -unsigned long millis() -{ - unsigned long m; - uint8_t oldSREG = SREG; - - // disable interrupts while we read timer0_millis or we might get an - // inconsistent value (e.g. in the middle of the timer0_millis++) - cli(); - m = timer0_millis; - SREG = oldSREG; - - return m; -} - -void delay(unsigned long ms) -{ - unsigned long start = millis(); - - while (millis() - start <= ms) - ; -} - -/* Delay for the given number of microseconds. Assumes a 8 or 16 MHz clock. - * Disables interrupts, which will disrupt the millis() function if used - * too frequently. */ -void delayMicroseconds(unsigned int us) -{ - uint8_t oldSREG; - - // calling avrlib's delay_us() function with low values (e.g. 1 or - // 2 microseconds) gives delays longer than desired. - //delay_us(us); - -#if F_CPU >= 16000000L - // for the 16 MHz clock on most Arduino boards - - // for a one-microsecond delay, simply return. the overhead - // of the function call yields a delay of approximately 1 1/8 us. - if (--us == 0) - return; - - // the following loop takes a quarter of a microsecond (4 cycles) - // per iteration, so execute it four times for each microsecond of - // delay requested. - us <<= 2; - - // account for the time taken in the preceeding commands. - us -= 2; -#else - // for the 8 MHz internal clock on the ATmega168 - - // for a one- or two-microsecond delay, simply return. the overhead of - // the function calls takes more than two microseconds. can't just - // subtract two, since us is unsigned; we'd overflow. - if (--us == 0) - return; - if (--us == 0) - return; - - // the following loop takes half of a microsecond (4 cycles) - // per iteration, so execute it twice for each microsecond of - // delay requested. - us <<= 1; - - // partially compensate for the time taken by the preceeding commands. - // we can't subtract any more than this or we'd overflow w/ small delays. - us--; -#endif - - // disable interrupts, otherwise the timer 0 overflow interrupt that - // tracks milliseconds will make us delay longer than we want. - oldSREG = SREG; - cli(); - - // busy wait - __asm__ __volatile__ ( - "1: sbiw %0,1" "\n\t" // 2 cycles - "brne 1b" : "=w" (us) : "0" (us) // 2 cycles - ); - - // reenable interrupts. - SREG = oldSREG; -} - -void init() -{ - // this needs to be called before setup() or some functions won't - // work there - sei(); - - // on the ATmega168, timer 0 is also used for fast hardware pwm - // (using phase-correct PWM would mean that timer 0 overflowed half as often - // resulting in different millis() behavior on the ATmega8 and ATmega168) - sbi(TCCR0A, WGM01); - sbi(TCCR0A, WGM00); - - // set timer 0 prescale factor to 64 - sbi(TCCR0B, CS01); - sbi(TCCR0B, CS00); - - // enable timer 0 overflow interrupt - sbi(TIMSK0, TOIE0); - - // timers 1 and 2 are used for phase-correct hardware pwm - // this is better for motors as it ensures an even waveform - // note, however, that fast pwm mode can achieve a frequency of up - // 8 MHz (with a 16 MHz clock) at 50% duty cycle -#if 0 - // set timer 1 prescale factor to 64 - sbi(TCCR1B, CS11); - sbi(TCCR1B, CS10); - - // put timer 1 in 8-bit phase correct pwm mode - sbi(TCCR1A, WGM10); - - // set timer 2 prescale factor to 64 - sbi(TCCR2B, CS22); - - // configure timer 2 for phase correct pwm (8-bit) - sbi(TCCR2A, WGM20); - - // set a2d prescale factor to 128 - // 16 MHz / 128 = 125 KHz, inside the desired 50-200 KHz range. - // XXX: this will not work properly for other clock speeds, and - // this code should use F_CPU to determine the prescale factor. - sbi(ADCSRA, ADPS2); - sbi(ADCSRA, ADPS1); - sbi(ADCSRA, ADPS0); - - // enable a2d conversions - sbi(ADCSRA, ADEN); - - // the bootloader connects pins 0 and 1 to the USART; disconnect them - // here so they can be used as normal digital i/o; they will be - // reconnected in Serial.begin() - UCSR0B = 0; - #if defined(__AVR_ATmega644P__) - //TODO: test to see if disabling this helps? - //UCSR1B = 0; - #endif -#endif -} diff --git a/Marlin/wiring_serial.c b/Marlin/wiring_serial.c deleted file mode 100644 index c027944c9030..000000000000 --- a/Marlin/wiring_serial.c +++ /dev/null @@ -1,139 +0,0 @@ -/* - wiring_serial.c - serial functions. - Part of Arduino - http://www.arduino.cc/ - - Copyright (c) 2005-2006 David A. Mellis - Modified 29 January 2009, Marius Kintel for Sanguino - http://www.sanguino.cc/ - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General - Public License along with this library; if not, write to the - Free Software Foundation, Inc., 59 Temple Place, Suite 330, - Boston, MA 02111-1307 USA - - $Id: wiring.c 248 2007-02-03 15:36:30Z mellis $ -*/ - - -#include "wiring_private.h" - -// 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 -// is the index of the location from which to read. -#define RX_BUFFER_SIZE 128 -#define RX_BUFFER_MASK 0x7f - -#if defined(__AVR_ATmega644P__) -unsigned char rx_buffer[2][RX_BUFFER_SIZE]; -int rx_buffer_head[2] = {0, 0}; -int rx_buffer_tail[2] = {0, 0}; -#else -unsigned char rx_buffer[1][RX_BUFFER_SIZE]; -int rx_buffer_head[1] = {0}; -int rx_buffer_tail[1] = {0}; -#endif - - -#define BEGIN_SERIAL(uart_, baud_) \ -{ \ - UBRR##uart_##H = ((F_CPU / 16 + baud / 2) / baud - 1) >> 8; \ - UBRR##uart_##L = ((F_CPU / 16 + baud / 2) / baud - 1); \ - \ - /* reset config for UART */ \ - UCSR##uart_##A = 0; \ - UCSR##uart_##B = 0; \ - UCSR##uart_##C = 0; \ - \ - /* enable rx and tx */ \ - sbi(UCSR##uart_##B, RXEN##uart_);\ - sbi(UCSR##uart_##B, TXEN##uart_);\ - \ - /* enable interrupt on complete reception of a byte */ \ - sbi(UCSR##uart_##B, RXCIE##uart_); \ - UCSR##uart_##C = _BV(UCSZ##uart_##1)|_BV(UCSZ##uart_##0); \ - /* defaults to 8-bit, no parity, 1 stop bit */ \ -} - -void beginSerial(uint8_t uart, long baud) -{ - if (uart == 0) BEGIN_SERIAL(0, baud) -#if defined(__AVR_ATmega644P__) - else BEGIN_SERIAL(1, baud) -#endif -} - -#define SERIAL_WRITE(uart_, c_) \ - while (!(UCSR##uart_##A & (1 << UDRE##uart_))) \ - ; \ - UDR##uart_ = c - -void serialWrite(uint8_t uart, unsigned char c) -{ - if (uart == 0) { - SERIAL_WRITE(0, c); - } -#if defined(__AVR_ATmega644P__) - else { - SERIAL_WRITE(1, c); - } -#endif -} - -int serialAvailable(uint8_t uart) -{ - return (RX_BUFFER_SIZE + rx_buffer_head[uart] - rx_buffer_tail[uart]) & RX_BUFFER_MASK; -} - -int serialRead(uint8_t uart) -{ - // if the head isn't ahead of the tail, we don't have any characters - if (rx_buffer_head[uart] == rx_buffer_tail[uart]) { - return -1; - } else { - unsigned char c = rx_buffer[uart][rx_buffer_tail[uart]]; - rx_buffer_tail[uart] = (rx_buffer_tail[uart] + 1) & RX_BUFFER_MASK; - return c; - } -} - -void serialFlush(uint8_t uart) -{ - // don't reverse this or there may be problems if the RX interrupt - // occurs after reading the value of rx_buffer_head but before writing - // the value to rx_buffer_tail; the previous value of rx_buffer_head - // may be written to rx_buffer_tail, making it appear as if the buffer - // were full, not empty. - rx_buffer_head[uart] = rx_buffer_tail[uart]; -} - -#define UART_ISR(uart_) \ -ISR(USART##uart_##_RX_vect) \ -{ \ - unsigned char c = UDR##uart_; \ - \ - int i = (rx_buffer_head[uart_] + 1) & RX_BUFFER_MASK; \ - \ - /* if we should be storing the received character into the location \ - just before the tail (meaning that the head would advance to the \ - current location of the tail), we're about to overflow the buffer \ - and so we don't write the character or advance the head. */ \ - if (i != rx_buffer_tail[uart_]) { \ - rx_buffer[uart_][rx_buffer_head[uart_]] = c; \ - rx_buffer_head[uart_] = i; \ - } \ -} - -UART_ISR(0) -#if defined(__AVR_ATmega644P__) -UART_ISR(1) -#endif From 4163341690672ca982a8279b798073c23bdb21f8 Mon Sep 17 00:00:00 2001 From: Michael Moon Date: Thu, 25 Aug 2011 14:36:18 +1000 Subject: [PATCH 2/3] add support for M80/M81 listed in supported gcodes --- Marlin/Marlin.pde | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Marlin/Marlin.pde b/Marlin/Marlin.pde index d1a98565edf5..bf79148f505e 100644 --- a/Marlin/Marlin.pde +++ b/Marlin/Marlin.pde @@ -811,6 +811,14 @@ inline void process_commands() break; case 190: break; + #if (PS_ON_PIN > -1) + case 80: // M81 - ATX Power On + SET_OUTPUT(PS_ON_PIN); //GND + break; + case 81: // M81 - ATX Power Off + SET_INPUT(PS_ON_PIN); //Floating + break; + #endif case 82: axis_relative_modes[3] = false; break; @@ -2039,4 +2047,4 @@ ISR(TIMER2_OVF_vect) } } - + From 1f90c6ea54f17bbd739f2eccb788dd74c3a9f69c Mon Sep 17 00:00:00 2001 From: Michael Moon Date: Thu, 25 Aug 2011 15:07:06 +1000 Subject: [PATCH 3/3] no bed support, remove M140/M190 from supported gcodes --- Marlin/Marlin.pde | 2 -- 1 file changed, 2 deletions(-) diff --git a/Marlin/Marlin.pde b/Marlin/Marlin.pde index bf79148f505e..be96b3d1d33f 100644 --- a/Marlin/Marlin.pde +++ b/Marlin/Marlin.pde @@ -85,8 +85,6 @@ char version_string[] = "0.9.3"; // M85 - Set inactivity shutdown timer with parameter S. To disable set zero (default) // M92 - Set axis_steps_per_unit - same syntax as G92 // M115 - Capabilities string -// M140 - Set bed target temp -// M190 - Wait for bed current temp to reach target temp. // M201 - Set max acceleration in units/s^2 for print moves (M201 X1000 Y1000) // M202 - Set max acceleration in units/s^2 for travel moves (M202 X1000 Y1000) // M301 - Set PID parameters P I and D