Browse Source

Changed max/min temp init. Removed second uart from sabguino core

Erik van der Zalm 13 years ago
parent
commit
ff69e0a772
25 changed files with 68 additions and 3862 deletions
  1. 0
    303
      Marlin/Sanguino/cores/Copy of arduino/HardwareSerial.cpp
  2. 0
    76
      Marlin/Sanguino/cores/Copy of arduino/HardwareSerial.h
  3. 0
    220
      Marlin/Sanguino/cores/Copy of arduino/Print.cpp
  4. 0
    66
      Marlin/Sanguino/cores/Copy of arduino/Print.h
  5. 0
    515
      Marlin/Sanguino/cores/Copy of arduino/Tone.cpp
  6. 0
    168
      Marlin/Sanguino/cores/Copy of arduino/WCharacter.h
  7. 0
    1
      Marlin/Sanguino/cores/Copy of arduino/WConstants.h
  8. 0
    87
      Marlin/Sanguino/cores/Copy of arduino/WInterrupts.c
  9. 0
    60
      Marlin/Sanguino/cores/Copy of arduino/WMath.cpp
  10. 0
    63
      Marlin/Sanguino/cores/Copy of arduino/WProgram.h
  11. 0
    443
      Marlin/Sanguino/cores/Copy of arduino/WString.cpp
  12. 0
    112
      Marlin/Sanguino/cores/Copy of arduino/WString.h
  13. 0
    515
      Marlin/Sanguino/cores/Copy of arduino/binary.h
  14. 0
    14
      Marlin/Sanguino/cores/Copy of arduino/main.cpp
  15. 0
    200
      Marlin/Sanguino/cores/Copy of arduino/pins_arduino.c
  16. 0
    65
      Marlin/Sanguino/cores/Copy of arduino/pins_arduino.h
  17. 0
    289
      Marlin/Sanguino/cores/Copy of arduino/wiring.c
  18. 0
    135
      Marlin/Sanguino/cores/Copy of arduino/wiring.h
  19. 0
    116
      Marlin/Sanguino/cores/Copy of arduino/wiring_analog.c
  20. 0
    95
      Marlin/Sanguino/cores/Copy of arduino/wiring_digital.c
  21. 0
    60
      Marlin/Sanguino/cores/Copy of arduino/wiring_private.h
  22. 0
    69
      Marlin/Sanguino/cores/Copy of arduino/wiring_pulse.c
  23. 0
    55
      Marlin/Sanguino/cores/Copy of arduino/wiring_shift.c
  24. 13
    129
      Marlin/Sanguino/cores/arduino/HardwareSerial.cpp
  25. 55
    6
      Marlin/temperature.cpp

+ 0
- 303
Marlin/Sanguino/cores/Copy of arduino/HardwareSerial.cpp View File

@@ -1,303 +0,0 @@
1
-/*
2
-  HardwareSerial.cpp - Hardware serial library for Wiring
3
-  Copyright (c) 2006 Nicholas Zambetti.  All right reserved.
4
-
5
-  This library is free software; you can redistribute it and/or
6
-  modify it under the terms of the GNU Lesser General Public
7
-  License as published by the Free Software Foundation; either
8
-  version 2.1 of the License, or (at your option) any later version.
9
-
10
-  This library is distributed in the hope that it will be useful,
11
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
-  Lesser General Public License for more details.
14
-
15
-  You should have received a copy of the GNU Lesser General Public
16
-  License along with this library; if not, write to the Free Software
17
-  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
-  
19
-  Modified 23 November 2006 by David A. Mellis
20
-  Modified 28 September 2010 by Mark Sproul
21
-*/
22
-
23
-#include <stdlib.h>
24
-#include <stdio.h>
25
-#include <string.h>
26
-#include <inttypes.h>
27
-#include "wiring.h"
28
-#include "wiring_private.h"
29
-
30
-// this next line disables the entire HardwareSerial.cpp, 
31
-// this is so I can support Attiny series and any other chip without a uart
32
-#if defined(UBRRH) || defined(UBRR0H) || defined(UBRR1H) || defined(UBRR2H) || defined(UBRR3H)
33
-
34
-#include "HardwareSerial.h"
35
-
36
-// Define constants and variables for buffering incoming serial data.  We're
37
-// using a ring buffer (I think), in which rx_buffer_head is the index of the
38
-// location to which to write the next incoming character and rx_buffer_tail
39
-// is the index of the location from which to read.
40
-#if (RAMEND < 1000)
41
-  #define RX_BUFFER_SIZE 32
42
-#else
43
-  #define RX_BUFFER_SIZE 128
44
-#endif
45
-
46
-struct ring_buffer
47
-{
48
-  unsigned char buffer[RX_BUFFER_SIZE];
49
-  int head;
50
-  int tail;
51
-};
52
-
53
-#if defined(UBRRH) || defined(UBRR0H)
54
-  ring_buffer rx_buffer  =  { { 0 }, 0, 0 };
55
-#endif
56
-#if defined(UBRR1H)
57
-  ring_buffer rx_buffer1  =  { { 0 }, 0, 0 };
58
-#endif
59
-#if defined(UBRR2H)
60
-  ring_buffer rx_buffer2  =  { { 0 }, 0, 0 };
61
-#endif
62
-#if defined(UBRR3H)
63
-  ring_buffer rx_buffer3  =  { { 0 }, 0, 0 };
64
-#endif
65
-
66
-inline void store_char(unsigned char c, ring_buffer *rx_buffer)
67
-{
68
-  int i = (unsigned int)(rx_buffer->head + 1) % RX_BUFFER_SIZE;
69
-
70
-  // if we should be storing the received character into the location
71
-  // just before the tail (meaning that the head would advance to the
72
-  // current location of the tail), we're about to overflow the buffer
73
-  // and so we don't write the character or advance the head.
74
-  if (i != rx_buffer->tail) {
75
-    rx_buffer->buffer[rx_buffer->head] = c;
76
-    rx_buffer->head = i;
77
-  }
78
-}
79
-
80
-#if defined(USART_RX_vect)
81
-  SIGNAL(USART_RX_vect)
82
-  {
83
-  #if defined(UDR0)
84
-    unsigned char c  =  UDR0;
85
-  #elif defined(UDR)
86
-    unsigned char c  =  UDR;  //  atmega8535
87
-  #else
88
-    #error UDR not defined
89
-  #endif
90
-    store_char(c, &rx_buffer);
91
-  }
92
-#elif defined(SIG_USART0_RECV) && defined(UDR0)
93
-  SIGNAL(SIG_USART0_RECV)
94
-  {
95
-    unsigned char c  =  UDR0;
96
-    store_char(c, &rx_buffer);
97
-  }
98
-#elif defined(SIG_UART0_RECV) && defined(UDR0)
99
-  SIGNAL(SIG_UART0_RECV)
100
-  {
101
-    unsigned char c  =  UDR0;
102
-    store_char(c, &rx_buffer);
103
-  }
104
-//#elif defined(SIG_USART_RECV)
105
-#elif defined(USART0_RX_vect)
106
-  // fixed by Mark Sproul this is on the 644/644p
107
-  //SIGNAL(SIG_USART_RECV)
108
-  SIGNAL(USART0_RX_vect)
109
-  {
110
-  #if defined(UDR0)
111
-    unsigned char c  =  UDR0;
112
-  #elif defined(UDR)
113
-    unsigned char c  =  UDR;  //  atmega8, atmega32
114
-  #else
115
-    #error UDR not defined
116
-  #endif
117
-    store_char(c, &rx_buffer);
118
-  }
119
-#elif defined(SIG_UART_RECV)
120
-  // this is for atmega8
121
-  SIGNAL(SIG_UART_RECV)
122
-  {
123
-  #if defined(UDR0)
124
-    unsigned char c  =  UDR0;  //  atmega645
125
-  #elif defined(UDR)
126
-    unsigned char c  =  UDR;  //  atmega8
127
-  #endif
128
-    store_char(c, &rx_buffer);
129
-  }
130
-#elif defined(USBCON)
131
-  #warning No interrupt handler for usart 0
132
-  #warning Serial(0) is on USB interface
133
-#else
134
-  #error No interrupt handler for usart 0
135
-#endif
136
-
137
-//#if defined(SIG_USART1_RECV)
138
-#if defined(USART1_RX_vect)
139
-  //SIGNAL(SIG_USART1_RECV)
140
-  SIGNAL(USART1_RX_vect)
141
-  {
142
-    unsigned char c = UDR1;
143
-    store_char(c, &rx_buffer1);
144
-  }
145
-#elif defined(SIG_USART1_RECV)
146
-  #error SIG_USART1_RECV
147
-#endif
148
-
149
-#if defined(USART2_RX_vect) && defined(UDR2)
150
-  SIGNAL(USART2_RX_vect)
151
-  {
152
-    unsigned char c = UDR2;
153
-    store_char(c, &rx_buffer2);
154
-  }
155
-#elif defined(SIG_USART2_RECV)
156
-  #error SIG_USART2_RECV
157
-#endif
158
-
159
-#if defined(USART3_RX_vect) && defined(UDR3)
160
-  SIGNAL(USART3_RX_vect)
161
-  {
162
-    unsigned char c = UDR3;
163
-    store_char(c, &rx_buffer3);
164
-  }
165
-#elif defined(SIG_USART3_RECV)
166
-  #error SIG_USART3_RECV
167
-#endif
168
-
169
-
170
-
171
-// Constructors ////////////////////////////////////////////////////////////////
172
-
173
-HardwareSerial::HardwareSerial(ring_buffer *rx_buffer,
174
-  volatile uint8_t *ubrrh, volatile uint8_t *ubrrl,
175
-  volatile uint8_t *ucsra, volatile uint8_t *ucsrb,
176
-  volatile uint8_t *udr,
177
-  uint8_t rxen, uint8_t txen, uint8_t rxcie, uint8_t udre, uint8_t u2x)
178
-{
179
-  _rx_buffer = rx_buffer;
180
-  _ubrrh = ubrrh;
181
-  _ubrrl = ubrrl;
182
-  _ucsra = ucsra;
183
-  _ucsrb = ucsrb;
184
-  _udr = udr;
185
-  _rxen = rxen;
186
-  _txen = txen;
187
-  _rxcie = rxcie;
188
-  _udre = udre;
189
-  _u2x = u2x;
190
-}
191
-
192
-// Public Methods //////////////////////////////////////////////////////////////
193
-
194
-void HardwareSerial::begin(long baud)
195
-{
196
-  uint16_t baud_setting;
197
-  bool use_u2x = true;
198
-
199
-#if F_CPU == 16000000UL
200
-  // hardcoded exception for compatibility with the bootloader shipped
201
-  // with the Duemilanove and previous boards and the firmware on the 8U2
202
-  // on the Uno and Mega 2560.
203
-  if (baud == 57600) {
204
-    use_u2x = false;
205
-  }
206
-#endif
207
-  
208
-  if (use_u2x) {
209
-    *_ucsra = 1 << _u2x;
210
-    baud_setting = (F_CPU / 4 / baud - 1) / 2;
211
-  } else {
212
-    *_ucsra = 0;
213
-    baud_setting = (F_CPU / 8 / baud - 1) / 2;
214
-  }
215
-
216
-  // assign the baud_setting, a.k.a. ubbr (USART Baud Rate Register)
217
-  *_ubrrh = baud_setting >> 8;
218
-  *_ubrrl = baud_setting;
219
-
220
-  sbi(*_ucsrb, _rxen);
221
-  sbi(*_ucsrb, _txen);
222
-  sbi(*_ucsrb, _rxcie);
223
-}
224
-
225
-void HardwareSerial::end()
226
-{
227
-  cbi(*_ucsrb, _rxen);
228
-  cbi(*_ucsrb, _txen);
229
-  cbi(*_ucsrb, _rxcie);  
230
-}
231
-
232
-int HardwareSerial::available(void)
233
-{
234
-  return (unsigned int)(RX_BUFFER_SIZE + _rx_buffer->head - _rx_buffer->tail) % RX_BUFFER_SIZE;
235
-}
236
-
237
-int HardwareSerial::peek(void)
238
-{
239
-  if (_rx_buffer->head == _rx_buffer->tail) {
240
-    return -1;
241
-  } else {
242
-    return _rx_buffer->buffer[_rx_buffer->tail];
243
-  }
244
-}
245
-
246
-int HardwareSerial::read(void)
247
-{
248
-  // if the head isn't ahead of the tail, we don't have any characters
249
-  if (_rx_buffer->head == _rx_buffer->tail) {
250
-    return -1;
251
-  } else {
252
-    unsigned char c = _rx_buffer->buffer[_rx_buffer->tail];
253
-    _rx_buffer->tail = (unsigned int)(_rx_buffer->tail + 1) % RX_BUFFER_SIZE;
254
-    return c;
255
-  }
256
-}
257
-
258
-void HardwareSerial::flush()
259
-{
260
-  // don't reverse this or there may be problems if the RX interrupt
261
-  // occurs after reading the value of rx_buffer_head but before writing
262
-  // the value to rx_buffer_tail; the previous value of rx_buffer_head
263
-  // may be written to rx_buffer_tail, making it appear as if the buffer
264
-  // don't reverse this or there may be problems if the RX interrupt
265
-  // occurs after reading the value of rx_buffer_head but before writing
266
-  // the value to rx_buffer_tail; the previous value of rx_buffer_head
267
-  // may be written to rx_buffer_tail, making it appear as if the buffer
268
-  // were full, not empty.
269
-  _rx_buffer->head = _rx_buffer->tail;
270
-}
271
-
272
-void HardwareSerial::write(uint8_t c)
273
-{
274
-  while (!((*_ucsra) & (1 << _udre)))
275
-    ;
276
-
277
-  *_udr = c;
278
-}
279
-
280
-// Preinstantiate Objects //////////////////////////////////////////////////////
281
-
282
-#if defined(UBRRH) && defined(UBRRL)
283
-  HardwareSerial Serial(&rx_buffer, &UBRRH, &UBRRL, &UCSRA, &UCSRB, &UDR, RXEN, TXEN, RXCIE, UDRE, U2X);
284
-#elif defined(UBRR0H) && defined(UBRR0L)
285
-  HardwareSerial Serial(&rx_buffer, &UBRR0H, &UBRR0L, &UCSR0A, &UCSR0B, &UDR0, RXEN0, TXEN0, RXCIE0, UDRE0, U2X0);
286
-#elif defined(USBCON)
287
-  #warning no serial port defined  (port 0)
288
-#else
289
-  #error no serial port defined  (port 0)
290
-#endif
291
-
292
-#if defined(UBRR1H)
293
-  HardwareSerial Serial1(&rx_buffer1, &UBRR1H, &UBRR1L, &UCSR1A, &UCSR1B, &UDR1, RXEN1, TXEN1, RXCIE1, UDRE1, U2X1);
294
-#endif
295
-#if defined(UBRR2H)
296
-  HardwareSerial Serial2(&rx_buffer2, &UBRR2H, &UBRR2L, &UCSR2A, &UCSR2B, &UDR2, RXEN2, TXEN2, RXCIE2, UDRE2, U2X2);
297
-#endif
298
-#if defined(UBRR3H)
299
-  HardwareSerial Serial3(&rx_buffer3, &UBRR3H, &UBRR3L, &UCSR3A, &UCSR3B, &UDR3, RXEN3, TXEN3, RXCIE3, UDRE3, U2X3);
300
-#endif
301
-
302
-#endif // whole file
303
-

+ 0
- 76
Marlin/Sanguino/cores/Copy of arduino/HardwareSerial.h View File

@@ -1,76 +0,0 @@
1
-/*
2
-  HardwareSerial.h - Hardware serial library for Wiring
3
-  Copyright (c) 2006 Nicholas Zambetti.  All right reserved.
4
-
5
-  This library is free software; you can redistribute it and/or
6
-  modify it under the terms of the GNU Lesser General Public
7
-  License as published by the Free Software Foundation; either
8
-  version 2.1 of the License, or (at your option) any later version.
9
-
10
-  This library is distributed in the hope that it will be useful,
11
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
-  Lesser General Public License for more details.
14
-
15
-  You should have received a copy of the GNU Lesser General Public
16
-  License along with this library; if not, write to the Free Software
17
-  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
-
19
-  Modified 28 September 2010 by Mark Sproul
20
-*/
21
-
22
-#ifndef HardwareSerial_h
23
-#define HardwareSerial_h
24
-
25
-#include <inttypes.h>
26
-
27
-#include "Stream.h"
28
-
29
-struct ring_buffer;
30
-
31
-class HardwareSerial : public Stream
32
-{
33
-  private:
34
-    ring_buffer *_rx_buffer;
35
-    volatile uint8_t *_ubrrh;
36
-    volatile uint8_t *_ubrrl;
37
-    volatile uint8_t *_ucsra;
38
-    volatile uint8_t *_ucsrb;
39
-    volatile uint8_t *_udr;
40
-    uint8_t _rxen;
41
-    uint8_t _txen;
42
-    uint8_t _rxcie;
43
-    uint8_t _udre;
44
-    uint8_t _u2x;
45
-  public:
46
-    HardwareSerial(ring_buffer *rx_buffer,
47
-      volatile uint8_t *ubrrh, volatile uint8_t *ubrrl,
48
-      volatile uint8_t *ucsra, volatile uint8_t *ucsrb,
49
-      volatile uint8_t *udr,
50
-      uint8_t rxen, uint8_t txen, uint8_t rxcie, uint8_t udre, uint8_t u2x);
51
-    void begin(long);
52
-    void end();
53
-    virtual int available(void);
54
-    virtual int peek(void);
55
-    virtual int read(void);
56
-    virtual void flush(void);
57
-    virtual void write(uint8_t);
58
-    using Print::write; // pull in write(str) and write(buf, size) from Print
59
-};
60
-
61
-#if defined(UBRRH) || defined(UBRR0H)
62
-  extern HardwareSerial Serial;
63
-#elif defined(USBCON)
64
-  #include "usb_api.h"
65
-#endif
66
-#if defined(UBRR1H)
67
-  extern HardwareSerial Serial1;
68
-#endif
69
-#if defined(UBRR2H)
70
-  extern HardwareSerial Serial2;
71
-#endif
72
-#if defined(UBRR3H)
73
-  extern HardwareSerial Serial3;
74
-#endif
75
-
76
-#endif

+ 0
- 220
Marlin/Sanguino/cores/Copy of arduino/Print.cpp View File

@@ -1,220 +0,0 @@
1
-/*
2
- Print.cpp - Base class that provides print() and println()
3
- Copyright (c) 2008 David A. Mellis.  All right reserved.
4
- 
5
- This library is free software; you can redistribute it and/or
6
- modify it under the terms of the GNU Lesser General Public
7
- License as published by the Free Software Foundation; either
8
- version 2.1 of the License, or (at your option) any later version.
9
- 
10
- This library is distributed in the hope that it will be useful,
11
- but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
- Lesser General Public License for more details.
14
- 
15
- You should have received a copy of the GNU Lesser General Public
16
- License along with this library; if not, write to the Free Software
17
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
- 
19
- Modified 23 November 2006 by David A. Mellis
20
- */
21
-
22
-#include <stdlib.h>
23
-#include <stdio.h>
24
-#include <string.h>
25
-#include <math.h>
26
-#include "wiring.h"
27
-
28
-#include "Print.h"
29
-
30
-// Public Methods //////////////////////////////////////////////////////////////
31
-
32
-/* default implementation: may be overridden */
33
-void Print::write(const char *str)
34
-{
35
-  while (*str)
36
-    write(*str++);
37
-}
38
-
39
-/* default implementation: may be overridden */
40
-void Print::write(const uint8_t *buffer, size_t size)
41
-{
42
-  while (size--)
43
-    write(*buffer++);
44
-}
45
-
46
-void Print::print(const String &s)
47
-{
48
-  for (int i = 0; i < s.length(); i++) {
49
-    write(s[i]);
50
-  }
51
-}
52
-
53
-void Print::print(const char str[])
54
-{
55
-  write(str);
56
-}
57
-
58
-void Print::print(char c, int base)
59
-{
60
-  print((long) c, base);
61
-}
62
-
63
-void Print::print(unsigned char b, int base)
64
-{
65
-  print((unsigned long) b, base);
66
-}
67
-
68
-void Print::print(int n, int base)
69
-{
70
-  print((long) n, base);
71
-}
72
-
73
-void Print::print(unsigned int n, int base)
74
-{
75
-  print((unsigned long) n, base);
76
-}
77
-
78
-void Print::print(long n, int base)
79
-{
80
-  if (base == 0) {
81
-    write(n);
82
-  } else if (base == 10) {
83
-    if (n < 0) {
84
-      print('-');
85
-      n = -n;
86
-    }
87
-    printNumber(n, 10);
88
-  } else {
89
-    printNumber(n, base);
90
-  }
91
-}
92
-
93
-void Print::print(unsigned long n, int base)
94
-{
95
-  if (base == 0) write(n);
96
-  else printNumber(n, base);
97
-}
98
-
99
-void Print::print(double n, int digits)
100
-{
101
-  printFloat(n, digits);
102
-}
103
-
104
-void Print::println(void)
105
-{
106
-  print('\r');
107
-  print('\n');  
108
-}
109
-
110
-void Print::println(const String &s)
111
-{
112
-  print(s);
113
-  println();
114
-}
115
-
116
-void Print::println(const char c[])
117
-{
118
-  print(c);
119
-  println();
120
-}
121
-
122
-void Print::println(char c, int base)
123
-{
124
-  print(c, base);
125
-  println();
126
-}
127
-
128
-void Print::println(unsigned char b, int base)
129
-{
130
-  print(b, base);
131
-  println();
132
-}
133
-
134
-void Print::println(int n, int base)
135
-{
136
-  print(n, base);
137
-  println();
138
-}
139
-
140
-void Print::println(unsigned int n, int base)
141
-{
142
-  print(n, base);
143
-  println();
144
-}
145
-
146
-void Print::println(long n, int base)
147
-{
148
-  print(n, base);
149
-  println();
150
-}
151
-
152
-void Print::println(unsigned long n, int base)
153
-{
154
-  print(n, base);
155
-  println();
156
-}
157
-
158
-void Print::println(double n, int digits)
159
-{
160
-  print(n, digits);
161
-  println();
162
-}
163
-
164
-// Private Methods /////////////////////////////////////////////////////////////
165
-
166
-void Print::printNumber(unsigned long n, uint8_t base)
167
-{
168
-  unsigned char buf[8 * sizeof(long)]; // Assumes 8-bit chars. 
169
-  unsigned long i = 0;
170
-
171
-  if (n == 0) {
172
-    print('0');
173
-    return;
174
-  } 
175
-
176
-  while (n > 0) {
177
-    buf[i++] = n % base;
178
-    n /= base;
179
-  }
180
-
181
-  for (; i > 0; i--)
182
-    print((char) (buf[i - 1] < 10 ?
183
-      '0' + buf[i - 1] :
184
-      'A' + buf[i - 1] - 10));
185
-}
186
-
187
-void Print::printFloat(double number, uint8_t digits) 
188
-{ 
189
-  // Handle negative numbers
190
-  if (number < 0.0)
191
-  {
192
-     print('-');
193
-     number = -number;
194
-  }
195
-
196
-  // Round correctly so that print(1.999, 2) prints as "2.00"
197
-  double rounding = 0.5;
198
-  for (uint8_t i=0; i<digits; ++i)
199
-    rounding /= 10.0;
200
-  
201
-  number += rounding;
202
-
203
-  // Extract the integer part of the number and print it
204
-  unsigned long int_part = (unsigned long)number;
205
-  double remainder = number - (double)int_part;
206
-  print(int_part);
207
-
208
-  // Print the decimal point, but only if there are digits beyond
209
-  if (digits > 0)
210
-    print("."); 
211
-
212
-  // Extract digits from the remainder one at a time
213
-  while (digits-- > 0)
214
-  {
215
-    remainder *= 10.0;
216
-    int toPrint = int(remainder);
217
-    print(toPrint);
218
-    remainder -= toPrint; 
219
-  } 
220
-}

+ 0
- 66
Marlin/Sanguino/cores/Copy of arduino/Print.h View File

@@ -1,66 +0,0 @@
1
-/*
2
-  Print.h - Base class that provides print() and println()
3
-  Copyright (c) 2008 David A. Mellis.  All right reserved.
4
-
5
-  This library is free software; you can redistribute it and/or
6
-  modify it under the terms of the GNU Lesser General Public
7
-  License as published by the Free Software Foundation; either
8
-  version 2.1 of the License, or (at your option) any later version.
9
-
10
-  This library is distributed in the hope that it will be useful,
11
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
-  Lesser General Public License for more details.
14
-
15
-  You should have received a copy of the GNU Lesser General Public
16
-  License along with this library; if not, write to the Free Software
17
-  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
-*/
19
-
20
-#ifndef Print_h
21
-#define Print_h
22
-
23
-#include <inttypes.h>
24
-#include <stdio.h> // for size_t
25
-
26
-#include "WString.h"
27
-
28
-#define DEC 10
29
-#define HEX 16
30
-#define OCT 8
31
-#define BIN 2
32
-#define BYTE 0
33
-
34
-class Print
35
-{
36
-  private:
37
-    void printNumber(unsigned long, uint8_t);
38
-    void printFloat(double, uint8_t);
39
-  public:
40
-    virtual void write(uint8_t) = 0;
41
-    virtual void write(const char *str);
42
-    virtual void write(const uint8_t *buffer, size_t size);
43
-    
44
-    void print(const String &);
45
-    void print(const char[]);
46
-    void print(char, int = BYTE);
47
-    void print(unsigned char, int = BYTE);
48
-    void print(int, int = DEC);
49
-    void print(unsigned int, int = DEC);
50
-    void print(long, int = DEC);
51
-    void print(unsigned long, int = DEC);
52
-    void print(double, int = 2);
53
-
54
-    void println(const String &s);
55
-    void println(const char[]);
56
-    void println(char, int = BYTE);
57
-    void println(unsigned char, int = BYTE);
58
-    void println(int, int = DEC);
59
-    void println(unsigned int, int = DEC);
60
-    void println(long, int = DEC);
61
-    void println(unsigned long, int = DEC);
62
-    void println(double, int = 2);
63
-    void println(void);
64
-};
65
-
66
-#endif

+ 0
- 515
Marlin/Sanguino/cores/Copy of arduino/Tone.cpp View File

@@ -1,515 +0,0 @@
1
-/* Tone.cpp
2
-
3
-  A Tone Generator Library
4
-
5
-  Written by Brett Hagman
6
-
7
-  This library is free software; you can redistribute it and/or
8
-  modify it under the terms of the GNU Lesser General Public
9
-  License as published by the Free Software Foundation; either
10
-  version 2.1 of the License, or (at your option) any later version.
11
-
12
-  This library is distributed in the hope that it will be useful,
13
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
-  Lesser General Public License for more details.
16
-
17
-  You should have received a copy of the GNU Lesser General Public
18
-  License along with this library; if not, write to the Free Software
19
-  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20
-
21
-Version Modified By Date     Comments
22
-------- ----------- -------- --------
23
-0001    B Hagman    09/08/02 Initial coding
24
-0002    B Hagman    09/08/18 Multiple pins
25
-0003    B Hagman    09/08/18 Moved initialization from constructor to begin()
26
-0004    B Hagman    09/09/26 Fixed problems with ATmega8
27
-0005    B Hagman    09/11/23 Scanned prescalars for best fit on 8 bit timers
28
-                    09/11/25 Changed pin toggle method to XOR
29
-                    09/11/25 Fixed timer0 from being excluded
30
-0006    D Mellis    09/12/29 Replaced objects with functions
31
-
32
-*************************************************/
33
-
34
-#include <avr/interrupt.h>
35
-#include <avr/pgmspace.h>
36
-#include <wiring.h>
37
-#include <pins_arduino.h>
38
-
39
-#if defined(__AVR_ATmega8__)
40
-#define TCCR2A TCCR2
41
-#define TCCR2B TCCR2
42
-#define COM2A1 COM21
43
-#define COM2A0 COM20
44
-#define OCR2A OCR2
45
-#define TIMSK2 TIMSK
46
-#define OCIE2A OCIE2
47
-#define TIMER2_COMPA_vect TIMER2_COMP_vect
48
-#define TIMSK1 TIMSK
49
-#endif
50
-
51
-// timerx_toggle_count:
52
-//  > 0 - duration specified
53
-//  = 0 - stopped
54
-//  < 0 - infinitely (until stop() method called, or new play() called)
55
-
56
-#if !defined(__AVR_ATmega8__)
57
-volatile long timer0_toggle_count;
58
-volatile uint8_t *timer0_pin_port;
59
-volatile uint8_t timer0_pin_mask;
60
-#endif
61
-
62
-volatile long timer1_toggle_count;
63
-volatile uint8_t *timer1_pin_port;
64
-volatile uint8_t timer1_pin_mask;
65
-volatile long timer2_toggle_count;
66
-volatile uint8_t *timer2_pin_port;
67
-volatile uint8_t timer2_pin_mask;
68
-
69
-#if defined(__AVR_ATmega1280__)
70
-volatile long timer3_toggle_count;
71
-volatile uint8_t *timer3_pin_port;
72
-volatile uint8_t timer3_pin_mask;
73
-volatile long timer4_toggle_count;
74
-volatile uint8_t *timer4_pin_port;
75
-volatile uint8_t timer4_pin_mask;
76
-volatile long timer5_toggle_count;
77
-volatile uint8_t *timer5_pin_port;
78
-volatile uint8_t timer5_pin_mask;
79
-#endif
80
-
81
-
82
-#if defined(__AVR_ATmega1280__)
83
-
84
-#define AVAILABLE_TONE_PINS 1
85
-
86
-const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 2 /*, 3, 4, 5, 1, 0 */ };
87
-static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255, 255, 255, 255, 255 */ };
88
-
89
-#elif defined(__AVR_ATmega8__)
90
-
91
-#define AVAILABLE_TONE_PINS 1
92
-
93
-const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 2 /*, 1 */ };
94
-static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255 */ };
95
-
96
-#else
97
-
98
-#define AVAILABLE_TONE_PINS 1
99
-
100
-// Leave timer 0 to last.
101
-const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 2 /*, 1, 0 */ };
102
-static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255, 255 */ };
103
-
104
-#endif
105
-
106
-
107
-
108
-static int8_t toneBegin(uint8_t _pin)
109
-{
110
-  int8_t _timer = -1;
111
-
112
-  // if we're already using the pin, the timer should be configured.  
113
-  for (int i = 0; i < AVAILABLE_TONE_PINS; i++) {
114
-    if (tone_pins[i] == _pin) {
115
-      return pgm_read_byte(tone_pin_to_timer_PGM + i);
116
-    }
117
-  }
118
-  
119
-  // search for an unused timer.
120
-  for (int i = 0; i < AVAILABLE_TONE_PINS; i++) {
121
-    if (tone_pins[i] == 255) {
122
-      tone_pins[i] = _pin;
123
-      _timer = pgm_read_byte(tone_pin_to_timer_PGM + i);
124
-      break;
125
-    }
126
-  }
127
-  
128
-  if (_timer != -1)
129
-  {
130
-    // Set timer specific stuff
131
-    // All timers in CTC mode
132
-    // 8 bit timers will require changing prescalar values,
133
-    // whereas 16 bit timers are set to either ck/1 or ck/64 prescalar
134
-    switch (_timer)
135
-    {
136
-#if !defined(__AVR_ATmega8__)
137
-      case 0:
138
-        // 8 bit timer
139
-        TCCR0A = 0;
140
-        TCCR0B = 0;
141
-        bitWrite(TCCR0A, WGM01, 1);
142
-        bitWrite(TCCR0B, CS00, 1);
143
-        timer0_pin_port = portOutputRegister(digitalPinToPort(_pin));
144
-        timer0_pin_mask = digitalPinToBitMask(_pin);
145
-        break;
146
-#endif
147
-
148
-      case 1:
149
-        // 16 bit timer
150
-        TCCR1A = 0;
151
-        TCCR1B = 0;
152
-        bitWrite(TCCR1B, WGM12, 1);
153
-        bitWrite(TCCR1B, CS10, 1);
154
-        timer1_pin_port = portOutputRegister(digitalPinToPort(_pin));
155
-        timer1_pin_mask = digitalPinToBitMask(_pin);
156
-        break;
157
-      case 2:
158
-        // 8 bit timer
159
-        TCCR2A = 0;
160
-        TCCR2B = 0;
161
-        bitWrite(TCCR2A, WGM21, 1);
162
-        bitWrite(TCCR2B, CS20, 1);
163
-        timer2_pin_port = portOutputRegister(digitalPinToPort(_pin));
164
-        timer2_pin_mask = digitalPinToBitMask(_pin);
165
-        break;
166
-
167
-#if defined(__AVR_ATmega1280__)
168
-      case 3:
169
-        // 16 bit timer
170
-        TCCR3A = 0;
171
-        TCCR3B = 0;
172
-        bitWrite(TCCR3B, WGM32, 1);
173
-        bitWrite(TCCR3B, CS30, 1);
174
-        timer3_pin_port = portOutputRegister(digitalPinToPort(_pin));
175
-        timer3_pin_mask = digitalPinToBitMask(_pin);
176
-        break;
177
-      case 4:
178
-        // 16 bit timer
179
-        TCCR4A = 0;
180
-        TCCR4B = 0;
181
-        bitWrite(TCCR4B, WGM42, 1);
182
-        bitWrite(TCCR4B, CS40, 1);
183
-        timer4_pin_port = portOutputRegister(digitalPinToPort(_pin));
184
-        timer4_pin_mask = digitalPinToBitMask(_pin);
185
-        break;
186
-      case 5:
187
-        // 16 bit timer
188
-        TCCR5A = 0;
189
-        TCCR5B = 0;
190
-        bitWrite(TCCR5B, WGM52, 1);
191
-        bitWrite(TCCR5B, CS50, 1);
192
-        timer5_pin_port = portOutputRegister(digitalPinToPort(_pin));
193
-        timer5_pin_mask = digitalPinToBitMask(_pin);
194
-        break;
195
-#endif
196
-    }
197
-  }
198
-
199
-  return _timer;
200
-}
201
-
202
-
203
-
204
-// frequency (in hertz) and duration (in milliseconds).
205
-
206
-void tone(uint8_t _pin, unsigned int frequency, unsigned long duration)
207
-{
208
-  uint8_t prescalarbits = 0b001;
209
-  long toggle_count = 0;
210
-  uint32_t ocr = 0;
211
-  int8_t _timer;
212
-
213
-  _timer = toneBegin(_pin);
214
-
215
-  if (_timer >= 0)
216
-  {
217
-    // Set the pinMode as OUTPUT
218
-    pinMode(_pin, OUTPUT);
219
-    
220
-    // if we are using an 8 bit timer, scan through prescalars to find the best fit
221
-    if (_timer == 0 || _timer == 2)
222
-    {
223
-      ocr = F_CPU / frequency / 2 - 1;
224
-      prescalarbits = 0b001;  // ck/1: same for both timers
225
-      if (ocr > 255)
226
-      {
227
-        ocr = F_CPU / frequency / 2 / 8 - 1;
228
-        prescalarbits = 0b010;  // ck/8: same for both timers
229
-
230
-        if (_timer == 2 && ocr > 255)
231
-        {
232
-          ocr = F_CPU / frequency / 2 / 32 - 1;
233
-          prescalarbits = 0b011;
234
-        }
235
-
236
-        if (ocr > 255)
237
-        {
238
-          ocr = F_CPU / frequency / 2 / 64 - 1;
239
-          prescalarbits = _timer == 0 ? 0b011 : 0b100;
240
-
241
-          if (_timer == 2 && ocr > 255)
242
-          {
243
-            ocr = F_CPU / frequency / 2 / 128 - 1;
244
-            prescalarbits = 0b101;
245
-          }
246
-
247
-          if (ocr > 255)
248
-          {
249
-            ocr = F_CPU / frequency / 2 / 256 - 1;
250
-            prescalarbits = _timer == 0 ? 0b100 : 0b110;
251
-            if (ocr > 255)
252
-            {
253
-              // can't do any better than /1024
254
-              ocr = F_CPU / frequency / 2 / 1024 - 1;
255
-              prescalarbits = _timer == 0 ? 0b101 : 0b111;
256
-            }
257
-          }
258
-        }
259
-      }
260
-
261
-#if !defined(__AVR_ATmega8__)
262
-      if (_timer == 0)
263
-        TCCR0B = prescalarbits;
264
-      else
265
-#endif
266
-        TCCR2B = prescalarbits;
267
-    }
268
-    else
269
-    {
270
-      // two choices for the 16 bit timers: ck/1 or ck/64
271
-      ocr = F_CPU / frequency / 2 - 1;
272
-
273
-      prescalarbits = 0b001;
274
-      if (ocr > 0xffff)
275
-      {
276
-        ocr = F_CPU / frequency / 2 / 64 - 1;
277
-        prescalarbits = 0b011;
278
-      }
279
-
280
-      if (_timer == 1)
281
-        TCCR1B = (TCCR1B & 0b11111000) | prescalarbits;
282
-#if defined(__AVR_ATmega1280__)
283
-      else if (_timer == 3)
284
-        TCCR3B = (TCCR3B & 0b11111000) | prescalarbits;
285
-      else if (_timer == 4)
286
-        TCCR4B = (TCCR4B & 0b11111000) | prescalarbits;
287
-      else if (_timer == 5)
288
-        TCCR5B = (TCCR5B & 0b11111000) | prescalarbits;
289
-#endif
290
-
291
-    }
292
-    
293
-
294
-    // Calculate the toggle count
295
-    if (duration > 0)
296
-    {
297
-      toggle_count = 2 * frequency * duration / 1000;
298
-    }
299
-    else
300
-    {
301
-      toggle_count = -1;
302
-    }
303
-
304
-    // Set the OCR for the given timer,
305
-    // set the toggle count,
306
-    // then turn on the interrupts
307
-    switch (_timer)
308
-    {
309
-
310
-#if !defined(__AVR_ATmega8__)
311
-      case 0:
312
-        OCR0A = ocr;
313
-        timer0_toggle_count = toggle_count;
314
-        bitWrite(TIMSK0, OCIE0A, 1);
315
-        break;
316
-#endif
317
-
318
-      case 1:
319
-        OCR1A = ocr;
320
-        timer1_toggle_count = toggle_count;
321
-        bitWrite(TIMSK1, OCIE1A, 1);
322
-        break;
323
-      case 2:
324
-        OCR2A = ocr;
325
-        timer2_toggle_count = toggle_count;
326
-        bitWrite(TIMSK2, OCIE2A, 1);
327
-        break;
328
-
329
-#if defined(__AVR_ATmega1280__)
330
-      case 3:
331
-        OCR3A = ocr;
332
-        timer3_toggle_count = toggle_count;
333
-        bitWrite(TIMSK3, OCIE3A, 1);
334
-        break;
335
-      case 4:
336
-        OCR4A = ocr;
337
-        timer4_toggle_count = toggle_count;
338
-        bitWrite(TIMSK4, OCIE4A, 1);
339
-        break;
340
-      case 5:
341
-        OCR5A = ocr;
342
-        timer5_toggle_count = toggle_count;
343
-        bitWrite(TIMSK5, OCIE5A, 1);
344
-        break;
345
-#endif
346
-
347
-    }
348
-  }
349
-}
350
-
351
-
352
-void noTone(uint8_t _pin)
353
-{
354
-  int8_t _timer = -1;
355
-  
356
-  for (int i = 0; i < AVAILABLE_TONE_PINS; i++) {
357
-    if (tone_pins[i] == _pin) {
358
-      _timer = pgm_read_byte(tone_pin_to_timer_PGM + i);
359
-      tone_pins[i] = 255;
360
-    }
361
-  }
362
-  
363
-  switch (_timer)
364
-  {
365
-#if defined(__AVR_ATmega8__)
366
-    case 1:
367
-      bitWrite(TIMSK1, OCIE1A, 0);
368
-      break;
369
-    case 2:
370
-      bitWrite(TIMSK2, OCIE2A, 0);
371
-      break;
372
-
373
-#else
374
-    case 0:
375
-      TIMSK0 = 0;
376
-      break;
377
-    case 1:
378
-      TIMSK1 = 0;
379
-      break;
380
-    case 2:
381
-      TIMSK2 = 0;
382
-      break;
383
-#endif
384
-
385
-#if defined(__AVR_ATmega1280__)
386
-    case 3:
387
-      TIMSK3 = 0;
388
-      break;
389
-    case 4:
390
-      TIMSK4 = 0;
391
-      break;
392
-    case 5:
393
-      TIMSK5 = 0;
394
-      break;
395
-#endif
396
-  }
397
-
398
-  digitalWrite(_pin, 0);
399
-}
400
-
401
-#if 0
402
-#if !defined(__AVR_ATmega8__)
403
-ISR(TIMER0_COMPA_vect)
404
-{
405
-  if (timer0_toggle_count != 0)
406
-  {
407
-    // toggle the pin
408
-    *timer0_pin_port ^= timer0_pin_mask;
409
-
410
-    if (timer0_toggle_count > 0)
411
-      timer0_toggle_count--;
412
-  }
413
-  else
414
-  {
415
-    TIMSK0 = 0;   // disable the interrupt
416
-    *timer0_pin_port &= ~(timer0_pin_mask);  // keep pin low after stop
417
-  }
418
-}
419
-#endif
420
-
421
-
422
-ISR(TIMER1_COMPA_vect)
423
-{
424
-  if (timer1_toggle_count != 0)
425
-  {
426
-    // toggle the pin
427
-    *timer1_pin_port ^= timer1_pin_mask;
428
-
429
-    if (timer1_toggle_count > 0)
430
-      timer1_toggle_count--;
431
-  }
432
-  else
433
-  {
434
-    TIMSK1 = 0;   // disable the interrupt
435
-    *timer1_pin_port &= ~(timer1_pin_mask);  // keep pin low after stop
436
-  }
437
-}
438
-#endif
439
-
440
-
441
-ISR(TIMER2_COMPA_vect)
442
-{
443
-
444
-  if (timer2_toggle_count != 0)
445
-  {
446
-    // toggle the pin
447
-    *timer2_pin_port ^= timer2_pin_mask;
448
-
449
-    if (timer2_toggle_count > 0)
450
-      timer2_toggle_count--;
451
-  }
452
-  else
453
-  {
454
-    TIMSK2 = 0;   // disable the interrupt
455
-    *timer2_pin_port &= ~(timer2_pin_mask);  // keep pin low after stop
456
-  }
457
-}
458
-
459
-
460
-
461
-//#if defined(__AVR_ATmega1280__)
462
-#if 0
463
-
464
-ISR(TIMER3_COMPA_vect)
465
-{
466
-  if (timer3_toggle_count != 0)
467
-  {
468
-    // toggle the pin
469
-    *timer3_pin_port ^= timer3_pin_mask;
470
-
471
-    if (timer3_toggle_count > 0)
472
-      timer3_toggle_count--;
473
-  }
474
-  else
475
-  {
476
-    TIMSK3 = 0;   // disable the interrupt
477
-    *timer3_pin_port &= ~(timer3_pin_mask);  // keep pin low after stop
478
-  }
479
-}
480
-
481
-ISR(TIMER4_COMPA_vect)
482
-{
483
-  if (timer4_toggle_count != 0)
484
-  {
485
-    // toggle the pin
486
-    *timer4_pin_port ^= timer4_pin_mask;
487
-
488
-    if (timer4_toggle_count > 0)
489
-      timer4_toggle_count--;
490
-  }
491
-  else
492
-  {
493
-    TIMSK4 = 0;   // disable the interrupt
494
-    *timer4_pin_port &= ~(timer4_pin_mask);  // keep pin low after stop
495
-  }
496
-}
497
-
498
-ISR(TIMER5_COMPA_vect)
499
-{
500
-  if (timer5_toggle_count != 0)
501
-  {
502
-    // toggle the pin
503
-    *timer5_pin_port ^= timer5_pin_mask;
504
-
505
-    if (timer5_toggle_count > 0)
506
-      timer5_toggle_count--;
507
-  }
508
-  else
509
-  {
510
-    TIMSK5 = 0;   // disable the interrupt
511
-    *timer5_pin_port &= ~(timer5_pin_mask);  // keep pin low after stop
512
-  }
513
-}
514
-
515
-#endif

+ 0
- 168
Marlin/Sanguino/cores/Copy of arduino/WCharacter.h View File

@@ -1,168 +0,0 @@
1
-/*
2
- WCharacter.h - Character utility functions for Wiring & Arduino
3
- Copyright (c) 2010 Hernando Barragan.  All right reserved.
4
- 
5
- This library is free software; you can redistribute it and/or
6
- modify it under the terms of the GNU Lesser General Public
7
- License as published by the Free Software Foundation; either
8
- version 2.1 of the License, or (at your option) any later version.
9
- 
10
- This library is distributed in the hope that it will be useful,
11
- but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
- Lesser General Public License for more details.
14
- 
15
- You should have received a copy of the GNU Lesser General Public
16
- License along with this library; if not, write to the Free Software
17
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
- */
19
-
20
-#ifndef Character_h
21
-#define Character_h
22
-
23
-#include <ctype.h>
24
-
25
-// WCharacter.h prototypes
26
-inline boolean isAlphaNumeric(int c) __attribute__((always_inline));
27
-inline boolean isAlpha(int c) __attribute__((always_inline));
28
-inline boolean isAscii(int c) __attribute__((always_inline));
29
-inline boolean isWhitespace(int c) __attribute__((always_inline));
30
-inline boolean isControl(int c) __attribute__((always_inline));
31
-inline boolean isDigit(int c) __attribute__((always_inline));
32
-inline boolean isGraph(int c) __attribute__((always_inline));
33
-inline boolean isLowerCase(int c) __attribute__((always_inline));
34
-inline boolean isPrintable(int c) __attribute__((always_inline));
35
-inline boolean isPunct(int c) __attribute__((always_inline));
36
-inline boolean isSpace(int c) __attribute__((always_inline));
37
-inline boolean isUpperCase(int c) __attribute__((always_inline));
38
-inline boolean isHexadecimalDigit(int c) __attribute__((always_inline));
39
-inline int toAscii(int c) __attribute__((always_inline));
40
-inline int toLowerCase(int c) __attribute__((always_inline));
41
-inline int toUpperCase(int c)__attribute__((always_inline));
42
-
43
-
44
-// Checks for an alphanumeric character. 
45
-// It is equivalent to (isalpha(c) || isdigit(c)).
46
-inline boolean isAlphaNumeric(int c) 
47
-{
48
-  return ( isalnum(c) == 0 ? false : true);
49
-}
50
-
51
-
52
-// Checks for an alphabetic character. 
53
-// It is equivalent to (isupper(c) || islower(c)).
54
-inline boolean isAlpha(int c)
55
-{
56
-  return ( isalpha(c) == 0 ? false : true);
57
-}
58
-
59
-
60
-// Checks whether c is a 7-bit unsigned char value 
61
-// that fits into the ASCII character set.
62
-inline boolean isAscii(int c)
63
-{
64
-  return ( isascii (c) == 0 ? false : true);
65
-}
66
-
67
-
68
-// Checks for a blank character, that is, a space or a tab.
69
-inline boolean isWhitespace(int c)
70
-{
71
-  return ( isblank (c) == 0 ? false : true);
72
-}
73
-
74
-
75
-// Checks for a control character.
76
-inline boolean isControl(int c)
77
-{
78
-  return ( iscntrl (c) == 0 ? false : true);
79
-}
80
-
81
-
82
-// Checks for a digit (0 through 9).
83
-inline boolean isDigit(int c)
84
-{
85
-  return ( isdigit (c) == 0 ? false : true);
86
-}
87
-
88
-
89
-// Checks for any printable character except space.
90
-inline boolean isGraph(int c)
91
-{
92
-  return ( isgraph (c) == 0 ? false : true);
93
-}
94
-
95
-
96
-// Checks for a lower-case character.
97
-inline boolean isLowerCase(int c)
98
-{
99
-  return (islower (c) == 0 ? false : true);
100
-}
101
-
102
-
103
-// Checks for any printable character including space.
104
-inline boolean isPrintable(int c)
105
-{
106
-  return ( isprint (c) == 0 ? false : true);
107
-}
108
-
109
-
110
-// Checks for any printable character which is not a space 
111
-// or an alphanumeric character.
112
-inline boolean isPunct(int c)
113
-{
114
-  return ( ispunct (c) == 0 ? false : true);
115
-}
116
-
117
-
118
-// Checks for white-space characters. For the avr-libc library, 
119
-// these are: space, formfeed ('\f'), newline ('\n'), carriage 
120
-// return ('\r'), horizontal tab ('\t'), and vertical tab ('\v').
121
-inline boolean isSpace(int c)
122
-{
123
-  return ( isspace (c) == 0 ? false : true);
124
-}
125
-
126
-
127
-// Checks for an uppercase letter.
128
-inline boolean isUpperCase(int c)
129
-{
130
-  return ( isupper (c) == 0 ? false : true);
131
-}
132
-
133
-
134
-// Checks for a hexadecimal digits, i.e. one of 0 1 2 3 4 5 6 7 
135
-// 8 9 a b c d e f A B C D E F.
136
-inline boolean isHexadecimalDigit(int c)
137
-{
138
-  return ( isxdigit (c) == 0 ? false : true);
139
-}
140
-
141
-
142
-// Converts c to a 7-bit unsigned char value that fits into the 
143
-// ASCII character set, by clearing the high-order bits.
144
-inline int toAscii(int c)
145
-{
146
-  return toascii (c);
147
-}
148
-
149
-
150
-// Warning:
151
-// Many people will be unhappy if you use this function. 
152
-// This function will convert accented letters into random 
153
-// characters.
154
-
155
-// Converts the letter c to lower case, if possible.
156
-inline int toLowerCase(int c)
157
-{
158
-  return tolower (c);
159
-}
160
-
161
-
162
-// Converts the letter c to upper case, if possible.
163
-inline int toUpperCase(int c)
164
-{
165
-  return toupper (c);
166
-}
167
-
168
-#endif

+ 0
- 1
Marlin/Sanguino/cores/Copy of arduino/WConstants.h View File

@@ -1 +0,0 @@
1
-#include "wiring.h"

+ 0
- 87
Marlin/Sanguino/cores/Copy of arduino/WInterrupts.c View File

@@ -1,87 +0,0 @@
1
-/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2
-
3
-/*
4
-  Part of the Wiring project - http://wiring.uniandes.edu.co
5
-
6
-  Copyright (c) 2004-05 Hernando Barragan
7
-
8
-  This library is free software; you can redistribute it and/or
9
-  modify it under the terms of the GNU Lesser General Public
10
-  License as published by the Free Software Foundation; either
11
-  version 2.1 of the License, or (at your option) any later version.
12
-
13
-  This library is distributed in the hope that it will be useful,
14
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
15
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16
-  Lesser General Public License for more details.
17
-
18
-  You should have received a copy of the GNU Lesser General
19
-  Public License along with this library; if not, write to the
20
-  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
21
-  Boston, MA  02111-1307  USA
22
-  
23
-  Modified 24 November 2006 by David A. Mellis
24
-*/
25
-
26
-#include <inttypes.h>
27
-#include <avr/io.h>
28
-#include <avr/interrupt.h>
29
-#include <avr/pgmspace.h>
30
-#include <stdio.h>
31
-
32
-#include "WConstants.h"
33
-#include "wiring_private.h"
34
-
35
-volatile static voidFuncPtr intFunc[EXTERNAL_NUM_INTERRUPTS];
36
-// volatile static voidFuncPtr twiIntFunc;
37
-
38
-void attachInterrupt(uint8_t interruptNum, void (*userFunc)(void), int mode)
39
-{
40
-	if(interruptNum < EXTERNAL_NUM_INTERRUPTS)
41
-	{
42
-		intFunc[interruptNum] = userFunc;
43
-
44
-		//clear the config for the change settings
45
-		EICRA &= ~(B00000011 << (interruptNum * 2));
46
-
47
-		//set our mode.
48
-		EICRA |= (mode << (interruptNum * 2));
49
-
50
-		// Enable the interrupt.
51
-		EIMSK |= (1 << interruptNum);
52
-	}
53
-}
54
-
55
-void detachInterrupt(uint8_t interruptNum)
56
-{
57
-	if(interruptNum < EXTERNAL_NUM_INTERRUPTS)
58
-	{
59
-		// Disable the interrupt.
60
-		EIMSK &= ~(1 << interruptNum);
61
-
62
-		intFunc[interruptNum] = 0;
63
-	}
64
-}
65
-
66
-ISR(INT0_vect) {
67
-  if(intFunc[EXTERNAL_INT_0])
68
-    intFunc[EXTERNAL_INT_0]();
69
-}
70
-
71
-ISR(INT1_vect) {
72
-  if(intFunc[EXTERNAL_INT_1])
73
-    intFunc[EXTERNAL_INT_1]();
74
-}
75
-
76
-ISR(INT2_vect) {
77
-  if(intFunc[EXTERNAL_INT_2])
78
-    intFunc[EXTERNAL_INT_2]();
79
-}
80
-
81
-/*
82
-SIGNAL(SIG_2WIRE_SERIAL) {
83
-  if(twiIntFunc)
84
-    twiIntFunc();
85
-}
86
-*/
87
-

+ 0
- 60
Marlin/Sanguino/cores/Copy of arduino/WMath.cpp View File

@@ -1,60 +0,0 @@
1
-/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2
-
3
-/*
4
-  Part of the Wiring project - http://wiring.org.co
5
-  Copyright (c) 2004-06 Hernando Barragan
6
-  Modified 13 August 2006, David A. Mellis for Arduino - http://www.arduino.cc/
7
-  
8
-  This library is free software; you can redistribute it and/or
9
-  modify it under the terms of the GNU Lesser General Public
10
-  License as published by the Free Software Foundation; either
11
-  version 2.1 of the License, or (at your option) any later version.
12
-
13
-  This library is distributed in the hope that it will be useful,
14
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
15
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16
-  Lesser General Public License for more details.
17
-
18
-  You should have received a copy of the GNU Lesser General
19
-  Public License along with this library; if not, write to the
20
-  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
21
-  Boston, MA  02111-1307  USA
22
-  
23
-  $Id$
24
-*/
25
-
26
-extern "C" {
27
-  #include "stdlib.h"
28
-}
29
-
30
-void randomSeed(unsigned int seed)
31
-{
32
-  if (seed != 0) {
33
-    srandom(seed);
34
-  }
35
-}
36
-
37
-long random(long howbig)
38
-{
39
-  if (howbig == 0) {
40
-    return 0;
41
-  }
42
-  return random() % howbig;
43
-}
44
-
45
-long random(long howsmall, long howbig)
46
-{
47
-  if (howsmall >= howbig) {
48
-    return howsmall;
49
-  }
50
-  long diff = howbig - howsmall;
51
-  return random(diff) + howsmall;
52
-}
53
-
54
-long map(long x, long in_min, long in_max, long out_min, long out_max)
55
-{
56
-  return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
57
-}
58
-
59
-unsigned int makeWord(unsigned int w) { return w; }
60
-unsigned int makeWord(unsigned char h, unsigned char l) { return (h << 8) | l; }

+ 0
- 63
Marlin/Sanguino/cores/Copy of arduino/WProgram.h View File

@@ -1,63 +0,0 @@
1
-#ifndef WProgram_h
2
-#define WProgram_h
3
-
4
-#include <stdlib.h>
5
-#include <string.h>
6
-#include <math.h>
7
-
8
-#include <avr/interrupt.h>
9
-
10
-#include "wiring.h"
11
-
12
-#ifdef __cplusplus
13
-#include "WCharacter.h"
14
-#include "WString.h"
15
-#include "HardwareSerial.h"
16
-
17
-uint16_t makeWord(uint16_t w);
18
-uint16_t makeWord(byte h, byte l);
19
-
20
-#define word(...) makeWord(__VA_ARGS__)
21
-
22
-unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L);
23
-
24
-void tone(uint8_t _pin, unsigned int frequency, unsigned long duration = 0);
25
-void noTone(uint8_t _pin);
26
-
27
-// WMath prototypes
28
-long random(long);
29
-long random(long, long);
30
-void randomSeed(unsigned int);
31
-long map(long, long, long, long, long);
32
-
33
-#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
34
-const static uint8_t A0 = 54;
35
-const static uint8_t A1 = 55;
36
-const static uint8_t A2 = 56;
37
-const static uint8_t A3 = 57;
38
-const static uint8_t A4 = 58;
39
-const static uint8_t A5 = 59;
40
-const static uint8_t A6 = 60;
41
-const static uint8_t A7 = 61;
42
-const static uint8_t A8 = 62;
43
-const static uint8_t A9 = 63;
44
-const static uint8_t A10 = 64;
45
-const static uint8_t A11 = 65;
46
-const static uint8_t A12 = 66;
47
-const static uint8_t A13 = 67;
48
-const static uint8_t A14 = 68;
49
-const static uint8_t A15 = 69;
50
-#else
51
-const static uint8_t A0 = 14;
52
-const static uint8_t A1 = 15;
53
-const static uint8_t A2 = 16;
54
-const static uint8_t A3 = 17;
55
-const static uint8_t A4 = 18;
56
-const static uint8_t A5 = 19;
57
-const static uint8_t A6 = 20;
58
-const static uint8_t A7 = 21;
59
-#endif
60
-
61
-#endif
62
-
63
-#endif

+ 0
- 443
Marlin/Sanguino/cores/Copy of arduino/WString.cpp View File

@@ -1,443 +0,0 @@
1
-/*
2
-  WString.cpp - String library for Wiring & Arduino
3
-  Copyright (c) 2009-10 Hernando Barragan.  All rights reserved.
4
-
5
-  This library is free software; you can redistribute it and/or
6
-  modify it under the terms of the GNU Lesser General Public
7
-  License as published by the Free Software Foundation; either
8
-  version 2.1 of the License, or (at your option) any later version.
9
-
10
-  This library is distributed in the hope that it will be useful,
11
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
-  Lesser General Public License for more details.
14
-
15
-  You should have received a copy of the GNU Lesser General Public
16
-  License along with this library; if not, write to the Free Software
17
-  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
-*/
19
-
20
-#include <stdlib.h>
21
-#include "WProgram.h"
22
-#include "WString.h"
23
-
24
-
25
-String::String( const char *value )
26
-{
27
-  if ( value == NULL )
28
-    value = "";
29
-  getBuffer( _length = strlen( value ) );
30
-  if ( _buffer != NULL )
31
-    strcpy( _buffer, value );
32
-}
33
-
34
-String::String( const String &value )
35
-{
36
-  getBuffer( _length = value._length );
37
-  if ( _buffer != NULL )
38
-    strcpy( _buffer, value._buffer );
39
-}
40
-
41
-String::String( const char value )
42
-{
43
-  _length = 1;
44
-  getBuffer(1);
45
-  if ( _buffer != NULL ) {
46
-    _buffer[0] = value;
47
-    _buffer[1] = 0;
48
-  }
49
-}
50
-
51
-String::String( const unsigned char value )
52
-{
53
-  _length = 1;
54
-  getBuffer(1);
55
-  if ( _buffer != NULL) {
56
-    _buffer[0] = value;
57
-    _buffer[1] = 0;
58
-  }
59
-}
60
-
61
-String::String( const int value, const int base )
62
-{
63
-  char buf[33];   
64
-  itoa((signed long)value, buf, base);
65
-  getBuffer( _length = strlen(buf) );
66
-  if ( _buffer != NULL )
67
-    strcpy( _buffer, buf );
68
-}
69
-
70
-String::String( const unsigned int value, const int base )
71
-{
72
-  char buf[33];   
73
-  ultoa((unsigned long)value, buf, base);
74
-  getBuffer( _length = strlen(buf) );
75
-  if ( _buffer != NULL )
76
-    strcpy( _buffer, buf );
77
-}
78
-
79
-String::String( const long value, const int base )
80
-{
81
-  char buf[33];   
82
-  ltoa(value, buf, base);
83
-  getBuffer( _length = strlen(buf) );
84
-  if ( _buffer != NULL )
85
-    strcpy( _buffer, buf );
86
-}
87
-
88
-String::String( const unsigned long value, const int base )
89
-{
90
-  char buf[33];   
91
-  ultoa(value, buf, 10);
92
-  getBuffer( _length = strlen(buf) );
93
-  if ( _buffer != NULL )
94
-    strcpy( _buffer, buf );
95
-}
96
-
97
-char String::charAt( unsigned int loc ) const
98
-{
99
-  return operator[]( loc );
100
-}
101
-
102
-void String::setCharAt( unsigned int loc, const char aChar ) 
103
-{
104
-  if(_buffer == NULL) return;
105
-  if(_length > loc) {
106
-    _buffer[loc] = aChar;
107
-  }
108
-}
109
-
110
-int String::compareTo( const String &s2 ) const
111
-{
112
-  return strcmp( _buffer, s2._buffer );
113
-}
114
-
115
-const String & String::concat( const String &s2 )
116
-{
117
-  return (*this) += s2;
118
-}
119
-
120
-const String & String::operator=( const String &rhs )
121
-{
122
-  if ( this == &rhs )
123
-    return *this;
124
-
125
-  if ( rhs._length > _length )
126
-  {
127
-    free(_buffer);
128
-    getBuffer( rhs._length );
129
-  }
130
-  
131
-  if ( _buffer != NULL ) {
132
-    _length = rhs._length;
133
-    strcpy( _buffer, rhs._buffer );
134
-  }
135
-  return *this;
136
-}
137
-
138
-//const String & String::operator+=( const char aChar )
139
-//{
140
-//  if ( _length == _capacity )
141
-//    doubleBuffer();
142
-//
143
-//  _buffer[ _length++ ] = aChar;
144
-//  _buffer[ _length ] = '\0';
145
-//  return *this;
146
-//}
147
-
148
-const String & String::operator+=( const String &other )
149
-{
150
-  _length += other._length;
151
-  if ( _length > _capacity )
152
-  {
153
-    char *temp = (char *)realloc(_buffer, _length + 1);
154
-    if ( temp != NULL ) {
155
-      _buffer = temp;
156
-      _capacity = _length;
157
-    } else {
158
-      _length -= other._length;
159
-      return *this;
160
-    }
161
-  }
162
-  strcat( _buffer, other._buffer );
163
-  return *this;
164
-}
165
-
166
-
167
-int String::operator==( const String &rhs ) const
168
-{
169
-  return ( _length == rhs._length && strcmp( _buffer, rhs._buffer ) == 0 );
170
-}
171
-
172
-int String::operator!=( const String &rhs ) const
173
-{
174
-  return ( _length != rhs.length() || strcmp( _buffer, rhs._buffer ) != 0 );
175
-}
176
-
177
-int String::operator<( const String &rhs ) const
178
-{
179
-  return strcmp( _buffer, rhs._buffer ) < 0;
180
-}
181
-
182
-int String::operator>( const String &rhs ) const
183
-{
184
-  return strcmp( _buffer, rhs._buffer ) > 0;
185
-}
186
-
187
-int String::operator<=( const String &rhs ) const
188
-{
189
-  return strcmp( _buffer, rhs._buffer ) <= 0;
190
-}
191
-
192
-int String::operator>=( const String & rhs ) const
193
-{
194
-  return strcmp( _buffer, rhs._buffer ) >= 0;
195
-}
196
-
197
-char & String::operator[]( unsigned int index )
198
-{
199
-  static char dummy_writable_char;
200
-  if (index >= _length || !_buffer) {
201
-    dummy_writable_char = 0;
202
-    return dummy_writable_char;
203
-  }
204
-  return _buffer[ index ];
205
-}
206
-
207
-char String::operator[]( unsigned int index ) const
208
-{
209
-  // need to check for valid index, to do later
210
-  return _buffer[ index ];
211
-}
212
-
213
-boolean String::endsWith( const String &s2 ) const
214
-{
215
-  if ( _length < s2._length )
216
-    return 0;
217
-
218
-  return strcmp( &_buffer[ _length - s2._length], s2._buffer ) == 0;
219
-}
220
-
221
-boolean String::equals( const String &s2 ) const
222
-{
223
-  return ( _length == s2._length && strcmp( _buffer,s2._buffer ) == 0 );
224
-}
225
-
226
-boolean String::equalsIgnoreCase( const String &s2 ) const
227
-{
228
-  if ( this == &s2 )
229
-    return true; //1;
230
-  else if ( _length != s2._length )
231
-    return false; //0;
232
-
233
-  return strcmp(toLowerCase()._buffer, s2.toLowerCase()._buffer) == 0;
234
-}
235
-
236
-String String::replace( char findChar, char replaceChar )
237
-{
238
-  if ( _buffer == NULL ) return *this;
239
-  String theReturn = _buffer;
240
-  char* temp = theReturn._buffer;
241
-  while( (temp = strchr( temp, findChar )) != 0 )
242
-    *temp = replaceChar;
243
-
244
-  return theReturn;
245
-}
246
-
247
-String String::replace( const String& match, const String& replace )
248
-{
249
-  if ( _buffer == NULL ) return *this;
250
-  String temp = _buffer, newString;
251
-
252
-  int loc;
253
-  while ( (loc = temp.indexOf( match )) != -1 )
254
-  {
255
-    newString += temp.substring( 0, loc );
256
-    newString += replace;
257
-    temp = temp.substring( loc + match._length );
258
-  }
259
-  newString += temp;  
260
-  return newString;
261
-}
262
-
263
-int String::indexOf( char temp ) const
264
-{
265
-  return indexOf( temp, 0 );
266
-}
267
-
268
-int String::indexOf( char ch, unsigned int fromIndex ) const
269
-{
270
-  if ( fromIndex >= _length )
271
-    return -1;
272
-
273
-  const char* temp = strchr( &_buffer[fromIndex], ch );
274
-  if ( temp == NULL )
275
-    return -1;
276
-
277
-  return temp - _buffer;
278
-}
279
-
280
-int String::indexOf( const String &s2 ) const
281
-{
282
-  return indexOf( s2, 0 );
283
-}
284
-
285
-int String::indexOf( const String &s2, unsigned int fromIndex ) const
286
-{
287
-  if ( fromIndex >= _length )
288
-    return -1;
289
-
290
-  const char *theFind = strstr( &_buffer[ fromIndex ], s2._buffer );
291
-
292
-  if ( theFind == NULL )
293
-    return -1;
294
-
295
-  return theFind - _buffer; // pointer subtraction
296
-}
297
-
298
-int String::lastIndexOf( char theChar ) const
299
-{
300
-  return lastIndexOf( theChar, _length - 1 );
301
-}
302
-
303
-int String::lastIndexOf( char ch, unsigned int fromIndex ) const
304
-{
305
-  if ( fromIndex >= _length )
306
-    return -1;
307
-
308
-  char tempchar = _buffer[fromIndex + 1];
309
-  _buffer[fromIndex + 1] = '\0';
310
-  char* temp = strrchr( _buffer, ch );
311
-  _buffer[fromIndex + 1] = tempchar;
312
-
313
-  if ( temp == NULL )
314
-    return -1;
315
-
316
-  return temp - _buffer;
317
-}
318
-
319
-int String::lastIndexOf( const String &s2 ) const
320
-{
321
-  return lastIndexOf( s2, _length - s2._length );
322
-}
323
-
324
-int String::lastIndexOf( const String &s2, unsigned int fromIndex ) const
325
-{
326
-  // check for empty strings
327
-  if ( s2._length == 0 || s2._length - 1 > fromIndex || fromIndex >= _length )
328
-    return -1;
329
-
330
-  // matching first character
331
-  char temp = s2[ 0 ];
332
-
333
-  for ( int i = fromIndex; i >= 0; i-- )
334
-  {
335
-    if ( _buffer[ i ] == temp && (*this).substring( i, i + s2._length ).equals( s2 ) )
336
-    return i;
337
-  }
338
-  return -1;
339
-}
340
-
341
-boolean String::startsWith( const String &s2 ) const
342
-{
343
-  if ( _length < s2._length )
344
-    return 0;
345
-
346
-  return startsWith( s2, 0 );
347
-}
348
-
349
-boolean String::startsWith( const String &s2, unsigned int offset ) const
350
-{
351
-  if ( offset > _length - s2._length )
352
-    return 0;
353
-
354
-  return strncmp( &_buffer[offset], s2._buffer, s2._length ) == 0;
355
-}
356
-
357
-String String::substring( unsigned int left ) const
358
-{
359
-  return substring( left, _length );
360
-}
361
-
362
-String String::substring( unsigned int left, unsigned int right ) const
363
-{
364
-  if ( left > right )
365
-  {
366
-    int temp = right;
367
-    right = left;
368
-    left = temp;
369
-  }
370
-
371
-  if ( right > _length )
372
-  {
373
-    right = _length;
374
-  } 
375
-
376
-  char temp = _buffer[ right ];  // save the replaced character
377
-  _buffer[ right ] = '\0';	
378
-  String outPut = ( _buffer + left );  // pointer arithmetic
379
-  _buffer[ right ] = temp;  //restore character
380
-  return outPut;
381
-}
382
-
383
-String String::toLowerCase() const
384
-{
385
-  String temp = _buffer;
386
-
387
-  for ( unsigned int i = 0; i < _length; i++ )
388
-    temp._buffer[ i ] = (char)tolower( temp._buffer[ i ] );
389
-  return temp;
390
-}
391
-
392
-String String::toUpperCase() const
393
-{
394
-  String temp = _buffer;
395
-
396
-  for ( unsigned int i = 0; i < _length; i++ )
397
-    temp._buffer[ i ] = (char)toupper( temp._buffer[ i ] );
398
-  return temp;
399
-}
400
-
401
-String String::trim() const
402
-{
403
-  if ( _buffer == NULL ) return *this;
404
-  String temp = _buffer;
405
-  unsigned int i,j;
406
-
407
-  for ( i = 0; i < _length; i++ )
408
-  {
409
-    if ( !isspace(_buffer[i]) )
410
-      break;
411
-  }
412
-
413
-  for ( j = temp._length - 1; j > i; j-- )
414
-  {
415
-    if ( !isspace(_buffer[j]) )
416
-      break;
417
-  }
418
-
419
-  return temp.substring( i, j + 1);
420
-}
421
-
422
-void String::getBytes(unsigned char *buf, unsigned int bufsize)
423
-{
424
-  if (!bufsize || !buf) return;
425
-  unsigned int len = bufsize - 1;
426
-  if (len > _length) len = _length;
427
-  strncpy((char *)buf, _buffer, len);
428
-  buf[len] = 0;
429
-}
430
-
431
-void String::toCharArray(char *buf, unsigned int bufsize)
432
-{
433
-  if (!bufsize || !buf) return;
434
-  unsigned int len = bufsize - 1;
435
-  if (len > _length) len = _length;
436
-  strncpy(buf, _buffer, len);
437
-  buf[len] = 0;
438
-}
439
-
440
-
441
-long String::toInt() {
442
-  return atol(_buffer);
443
-}

+ 0
- 112
Marlin/Sanguino/cores/Copy of arduino/WString.h View File

@@ -1,112 +0,0 @@
1
-/*
2
-  WString.h - String library for Wiring & Arduino
3
-  Copyright (c) 2009-10 Hernando Barragan.  All right reserved.
4
-
5
-  This library is free software; you can redistribute it and/or
6
-  modify it under the terms of the GNU Lesser General Public
7
-  License as published by the Free Software Foundation; either
8
-  version 2.1 of the License, or (at your option) any later version.
9
-
10
-  This library is distributed in the hope that it will be useful,
11
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
-  Lesser General Public License for more details.
14
-
15
-  You should have received a copy of the GNU Lesser General Public
16
-  License along with this library; if not, write to the Free Software
17
-  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
-*/
19
-
20
-#ifndef String_h
21
-#define String_h
22
-
23
-//#include "WProgram.h"
24
-#include <stdlib.h>
25
-#include <string.h>
26
-#include <ctype.h>
27
-
28
-class String
29
-{
30
-  public:
31
-    // constructors
32
-    String( const char *value = "" );
33
-    String( const String &value );
34
-    String( const char );
35
-    String( const unsigned char );
36
-    String( const int, const int base=10);
37
-    String( const unsigned int, const int base=10 );
38
-    String( const long, const int base=10 );
39
-    String( const unsigned long, const int base=10 );
40
-    ~String() { free(_buffer); _length = _capacity = 0;}     //added _length = _capacity = 0;
41
-
42
-    // operators
43
-    const String & operator = ( const String &rhs );
44
-    const String & operator +=( const String &rhs );
45
-    //const String & operator +=( const char );
46
-    int operator ==( const String &rhs ) const;
47
-    int	operator !=( const String &rhs ) const;
48
-    int	operator < ( const String &rhs ) const;
49
-    int	operator > ( const String &rhs ) const;
50
-    int	operator <=( const String &rhs ) const;
51
-    int	operator >=( const String &rhs ) const;
52
-    char operator []( unsigned int index ) const;
53
-    char& operator []( unsigned int index );
54
-    //operator const char *() const { return _buffer; }
55
-    
56
-    // general methods
57
-    char charAt( unsigned int index ) const;
58
-    int	compareTo( const String &anotherString ) const;
59
-    unsigned char endsWith( const String &suffix ) const;
60
-    unsigned char equals( const String &anObject ) const;
61
-    unsigned char equalsIgnoreCase( const String &anotherString ) const;
62
-    int	indexOf( char ch ) const;
63
-    int	indexOf( char ch, unsigned int fromIndex ) const;
64
-    int	indexOf( const String &str ) const;
65
-    int	indexOf( const String &str, unsigned int fromIndex ) const;
66
-    int	lastIndexOf( char ch ) const;
67
-    int	lastIndexOf( char ch, unsigned int fromIndex ) const;
68
-    int	lastIndexOf( const String &str ) const;
69
-    int	lastIndexOf( const String &str, unsigned int fromIndex ) const;
70
-    const unsigned int length( ) const { return _length; }
71
-    void setCharAt(unsigned int index, const char ch);
72
-    unsigned char startsWith( const String &prefix ) const;
73
-    unsigned char startsWith( const String &prefix, unsigned int toffset ) const;
74
-    String substring( unsigned int beginIndex ) const;
75
-    String substring( unsigned int beginIndex, unsigned int endIndex ) const;
76
-    String toLowerCase( ) const;
77
-    String toUpperCase( ) const;
78
-    String trim( ) const;
79
-    void getBytes(unsigned char *buf, unsigned int bufsize);
80
-    void toCharArray(char *buf, unsigned int bufsize);
81
-    long toInt( );
82
-    const String& concat( const String &str );
83
-    String replace( char oldChar, char newChar );
84
-    String replace( const String& match, const String& replace );
85
-    friend String operator + ( String lhs, const String &rhs );
86
-
87
-  protected:
88
-    char *_buffer;	     // the actual char array
89
-    unsigned int _capacity;  // the array length minus one (for the '\0')
90
-    unsigned int _length;    // the String length (not counting the '\0')
91
-
92
-    void getBuffer(unsigned int maxStrLen);
93
-
94
-  private:
95
-
96
-};
97
-
98
-// allocate buffer space
99
-inline void String::getBuffer(unsigned int maxStrLen)
100
-{
101
-  _capacity = maxStrLen;
102
-  _buffer = (char *) malloc(_capacity + 1);
103
-  if (_buffer == NULL) _length = _capacity = 0;
104
-}
105
-
106
-inline String operator+( String lhs, const String &rhs )
107
-{
108
-  return lhs += rhs;
109
-}
110
-
111
-
112
-#endif

+ 0
- 515
Marlin/Sanguino/cores/Copy of arduino/binary.h View File

@@ -1,515 +0,0 @@
1
-#ifndef Binary_h
2
-#define Binary_h
3
-
4
-#define B0 0
5
-#define B00 0
6
-#define B000 0
7
-#define B0000 0
8
-#define B00000 0
9
-#define B000000 0
10
-#define B0000000 0
11
-#define B00000000 0
12
-#define B1 1
13
-#define B01 1
14
-#define B001 1
15
-#define B0001 1
16
-#define B00001 1
17
-#define B000001 1
18
-#define B0000001 1
19
-#define B00000001 1
20
-#define B10 2
21
-#define B010 2
22
-#define B0010 2
23
-#define B00010 2
24
-#define B000010 2
25
-#define B0000010 2
26
-#define B00000010 2
27
-#define B11 3
28
-#define B011 3
29
-#define B0011 3
30
-#define B00011 3
31
-#define B000011 3
32
-#define B0000011 3
33
-#define B00000011 3
34
-#define B100 4
35
-#define B0100 4
36
-#define B00100 4
37
-#define B000100 4
38
-#define B0000100 4
39
-#define B00000100 4
40
-#define B101 5
41
-#define B0101 5
42
-#define B00101 5
43
-#define B000101 5
44
-#define B0000101 5
45
-#define B00000101 5
46
-#define B110 6
47
-#define B0110 6
48
-#define B00110 6
49
-#define B000110 6
50
-#define B0000110 6
51
-#define B00000110 6
52
-#define B111 7
53
-#define B0111 7
54
-#define B00111 7
55
-#define B000111 7
56
-#define B0000111 7
57
-#define B00000111 7
58
-#define B1000 8
59
-#define B01000 8
60
-#define B001000 8
61
-#define B0001000 8
62
-#define B00001000 8
63
-#define B1001 9
64
-#define B01001 9
65
-#define B001001 9
66
-#define B0001001 9
67
-#define B00001001 9
68
-#define B1010 10
69
-#define B01010 10
70
-#define B001010 10
71
-#define B0001010 10
72
-#define B00001010 10
73
-#define B1011 11
74
-#define B01011 11
75
-#define B001011 11
76
-#define B0001011 11
77
-#define B00001011 11
78
-#define B1100 12
79
-#define B01100 12
80
-#define B001100 12
81
-#define B0001100 12
82
-#define B00001100 12
83
-#define B1101 13
84
-#define B01101 13
85
-#define B001101 13
86
-#define B0001101 13
87
-#define B00001101 13
88
-#define B1110 14
89
-#define B01110 14
90
-#define B001110 14
91
-#define B0001110 14
92
-#define B00001110 14
93
-#define B1111 15
94
-#define B01111 15
95
-#define B001111 15
96
-#define B0001111 15
97
-#define B00001111 15
98
-#define B10000 16
99
-#define B010000 16
100
-#define B0010000 16
101
-#define B00010000 16
102
-#define B10001 17
103
-#define B010001 17
104
-#define B0010001 17
105
-#define B00010001 17
106
-#define B10010 18
107
-#define B010010 18
108
-#define B0010010 18
109
-#define B00010010 18
110
-#define B10011 19
111
-#define B010011 19
112
-#define B0010011 19
113
-#define B00010011 19
114
-#define B10100 20
115
-#define B010100 20
116
-#define B0010100 20
117
-#define B00010100 20
118
-#define B10101 21
119
-#define B010101 21
120
-#define B0010101 21
121
-#define B00010101 21
122
-#define B10110 22
123
-#define B010110 22
124
-#define B0010110 22
125
-#define B00010110 22
126
-#define B10111 23
127
-#define B010111 23
128
-#define B0010111 23
129
-#define B00010111 23
130
-#define B11000 24
131
-#define B011000 24
132
-#define B0011000 24
133
-#define B00011000 24
134
-#define B11001 25
135
-#define B011001 25
136
-#define B0011001 25
137
-#define B00011001 25
138
-#define B11010 26
139
-#define B011010 26
140
-#define B0011010 26
141
-#define B00011010 26
142
-#define B11011 27
143
-#define B011011 27
144
-#define B0011011 27
145
-#define B00011011 27
146
-#define B11100 28
147
-#define B011100 28
148
-#define B0011100 28
149
-#define B00011100 28
150
-#define B11101 29
151
-#define B011101 29
152
-#define B0011101 29
153
-#define B00011101 29
154
-#define B11110 30
155
-#define B011110 30
156
-#define B0011110 30
157
-#define B00011110 30
158
-#define B11111 31
159
-#define B011111 31
160
-#define B0011111 31
161
-#define B00011111 31
162
-#define B100000 32
163
-#define B0100000 32
164
-#define B00100000 32
165
-#define B100001 33
166
-#define B0100001 33
167
-#define B00100001 33
168
-#define B100010 34
169
-#define B0100010 34
170
-#define B00100010 34
171
-#define B100011 35
172
-#define B0100011 35
173
-#define B00100011 35
174
-#define B100100 36
175
-#define B0100100 36
176
-#define B00100100 36
177
-#define B100101 37
178
-#define B0100101 37
179
-#define B00100101 37
180
-#define B100110 38
181
-#define B0100110 38
182
-#define B00100110 38
183
-#define B100111 39
184
-#define B0100111 39
185
-#define B00100111 39
186
-#define B101000 40
187
-#define B0101000 40
188
-#define B00101000 40
189
-#define B101001 41
190
-#define B0101001 41
191
-#define B00101001 41
192
-#define B101010 42
193
-#define B0101010 42
194
-#define B00101010 42
195
-#define B101011 43
196
-#define B0101011 43
197
-#define B00101011 43
198
-#define B101100 44
199
-#define B0101100 44
200
-#define B00101100 44
201
-#define B101101 45
202
-#define B0101101 45
203
-#define B00101101 45
204
-#define B101110 46
205
-#define B0101110 46
206
-#define B00101110 46
207
-#define B101111 47
208
-#define B0101111 47
209
-#define B00101111 47
210
-#define B110000 48
211
-#define B0110000 48
212
-#define B00110000 48
213
-#define B110001 49
214
-#define B0110001 49
215
-#define B00110001 49
216
-#define B110010 50
217
-#define B0110010 50
218
-#define B00110010 50
219
-#define B110011 51
220
-#define B0110011 51
221
-#define B00110011 51
222
-#define B110100 52
223
-#define B0110100 52
224
-#define B00110100 52
225
-#define B110101 53
226
-#define B0110101 53
227
-#define B00110101 53
228
-#define B110110 54
229
-#define B0110110 54
230
-#define B00110110 54
231
-#define B110111 55
232
-#define B0110111 55
233
-#define B00110111 55
234
-#define B111000 56
235
-#define B0111000 56
236
-#define B00111000 56
237
-#define B111001 57
238
-#define B0111001 57
239
-#define B00111001 57
240
-#define B111010 58
241
-#define B0111010 58
242
-#define B00111010 58
243
-#define B111011 59
244
-#define B0111011 59
245
-#define B00111011 59
246
-#define B111100 60
247
-#define B0111100 60
248
-#define B00111100 60
249
-#define B111101 61
250
-#define B0111101 61
251
-#define B00111101 61
252
-#define B111110 62
253
-#define B0111110 62
254
-#define B00111110 62
255
-#define B111111 63
256
-#define B0111111 63
257
-#define B00111111 63
258
-#define B1000000 64
259
-#define B01000000 64
260
-#define B1000001 65
261
-#define B01000001 65
262
-#define B1000010 66
263
-#define B01000010 66
264
-#define B1000011 67
265
-#define B01000011 67
266
-#define B1000100 68
267
-#define B01000100 68
268
-#define B1000101 69
269
-#define B01000101 69
270
-#define B1000110 70
271
-#define B01000110 70
272
-#define B1000111 71
273
-#define B01000111 71
274
-#define B1001000 72
275
-#define B01001000 72
276
-#define B1001001 73
277
-#define B01001001 73
278
-#define B1001010 74
279
-#define B01001010 74
280
-#define B1001011 75
281
-#define B01001011 75
282
-#define B1001100 76
283
-#define B01001100 76
284
-#define B1001101 77
285
-#define B01001101 77
286
-#define B1001110 78
287
-#define B01001110 78
288
-#define B1001111 79
289
-#define B01001111 79
290
-#define B1010000 80
291
-#define B01010000 80
292
-#define B1010001 81
293
-#define B01010001 81
294
-#define B1010010 82
295
-#define B01010010 82
296
-#define B1010011 83
297
-#define B01010011 83
298
-#define B1010100 84
299
-#define B01010100 84
300
-#define B1010101 85
301
-#define B01010101 85
302
-#define B1010110 86
303
-#define B01010110 86
304
-#define B1010111 87
305
-#define B01010111 87
306
-#define B1011000 88
307
-#define B01011000 88
308
-#define B1011001 89
309
-#define B01011001 89
310
-#define B1011010 90
311
-#define B01011010 90
312
-#define B1011011 91
313
-#define B01011011 91
314
-#define B1011100 92
315
-#define B01011100 92
316
-#define B1011101 93
317
-#define B01011101 93
318
-#define B1011110 94
319
-#define B01011110 94
320
-#define B1011111 95
321
-#define B01011111 95
322
-#define B1100000 96
323
-#define B01100000 96
324
-#define B1100001 97
325
-#define B01100001 97
326
-#define B1100010 98
327
-#define B01100010 98
328
-#define B1100011 99
329
-#define B01100011 99
330
-#define B1100100 100
331
-#define B01100100 100
332
-#define B1100101 101
333
-#define B01100101 101
334
-#define B1100110 102
335
-#define B01100110 102
336
-#define B1100111 103
337
-#define B01100111 103
338
-#define B1101000 104
339
-#define B01101000 104
340
-#define B1101001 105
341
-#define B01101001 105
342
-#define B1101010 106
343
-#define B01101010 106
344
-#define B1101011 107
345
-#define B01101011 107
346
-#define B1101100 108
347
-#define B01101100 108
348
-#define B1101101 109
349
-#define B01101101 109
350
-#define B1101110 110
351
-#define B01101110 110
352
-#define B1101111 111
353
-#define B01101111 111
354
-#define B1110000 112
355
-#define B01110000 112
356
-#define B1110001 113
357
-#define B01110001 113
358
-#define B1110010 114
359
-#define B01110010 114
360
-#define B1110011 115
361
-#define B01110011 115
362
-#define B1110100 116
363
-#define B01110100 116
364
-#define B1110101 117
365
-#define B01110101 117
366
-#define B1110110 118
367
-#define B01110110 118
368
-#define B1110111 119
369
-#define B01110111 119
370
-#define B1111000 120
371
-#define B01111000 120
372
-#define B1111001 121
373
-#define B01111001 121
374
-#define B1111010 122
375
-#define B01111010 122
376
-#define B1111011 123
377
-#define B01111011 123
378
-#define B1111100 124
379
-#define B01111100 124
380
-#define B1111101 125
381
-#define B01111101 125
382
-#define B1111110 126
383
-#define B01111110 126
384
-#define B1111111 127
385
-#define B01111111 127
386
-#define B10000000 128
387
-#define B10000001 129
388
-#define B10000010 130
389
-#define B10000011 131
390
-#define B10000100 132
391
-#define B10000101 133
392
-#define B10000110 134
393
-#define B10000111 135
394
-#define B10001000 136
395
-#define B10001001 137
396
-#define B10001010 138
397
-#define B10001011 139
398
-#define B10001100 140
399
-#define B10001101 141
400
-#define B10001110 142
401
-#define B10001111 143
402
-#define B10010000 144
403
-#define B10010001 145
404
-#define B10010010 146
405
-#define B10010011 147
406
-#define B10010100 148
407
-#define B10010101 149
408
-#define B10010110 150
409
-#define B10010111 151
410
-#define B10011000 152
411
-#define B10011001 153
412
-#define B10011010 154
413
-#define B10011011 155
414
-#define B10011100 156
415
-#define B10011101 157
416
-#define B10011110 158
417
-#define B10011111 159
418
-#define B10100000 160
419
-#define B10100001 161
420
-#define B10100010 162
421
-#define B10100011 163
422
-#define B10100100 164
423
-#define B10100101 165
424
-#define B10100110 166
425
-#define B10100111 167
426
-#define B10101000 168
427
-#define B10101001 169
428
-#define B10101010 170
429
-#define B10101011 171
430
-#define B10101100 172
431
-#define B10101101 173
432
-#define B10101110 174
433
-#define B10101111 175
434
-#define B10110000 176
435
-#define B10110001 177
436
-#define B10110010 178
437
-#define B10110011 179
438
-#define B10110100 180
439
-#define B10110101 181
440
-#define B10110110 182
441
-#define B10110111 183
442
-#define B10111000 184
443
-#define B10111001 185
444
-#define B10111010 186
445
-#define B10111011 187
446
-#define B10111100 188
447
-#define B10111101 189
448
-#define B10111110 190
449
-#define B10111111 191
450
-#define B11000000 192
451
-#define B11000001 193
452
-#define B11000010 194
453
-#define B11000011 195
454
-#define B11000100 196
455
-#define B11000101 197
456
-#define B11000110 198
457
-#define B11000111 199
458
-#define B11001000 200
459
-#define B11001001 201
460
-#define B11001010 202
461
-#define B11001011 203
462
-#define B11001100 204
463
-#define B11001101 205
464
-#define B11001110 206
465
-#define B11001111 207
466
-#define B11010000 208
467
-#define B11010001 209
468
-#define B11010010 210
469
-#define B11010011 211
470
-#define B11010100 212
471
-#define B11010101 213
472
-#define B11010110 214
473
-#define B11010111 215
474
-#define B11011000 216
475
-#define B11011001 217
476
-#define B11011010 218
477
-#define B11011011 219
478
-#define B11011100 220
479
-#define B11011101 221
480
-#define B11011110 222
481
-#define B11011111 223
482
-#define B11100000 224
483
-#define B11100001 225
484
-#define B11100010 226
485
-#define B11100011 227
486
-#define B11100100 228
487
-#define B11100101 229
488
-#define B11100110 230
489
-#define B11100111 231
490
-#define B11101000 232
491
-#define B11101001 233
492
-#define B11101010 234
493
-#define B11101011 235
494
-#define B11101100 236
495
-#define B11101101 237
496
-#define B11101110 238
497
-#define B11101111 239
498
-#define B11110000 240
499
-#define B11110001 241
500
-#define B11110010 242
501
-#define B11110011 243
502
-#define B11110100 244
503
-#define B11110101 245
504
-#define B11110110 246
505
-#define B11110111 247
506
-#define B11111000 248
507
-#define B11111001 249
508
-#define B11111010 250
509
-#define B11111011 251
510
-#define B11111100 252
511
-#define B11111101 253
512
-#define B11111110 254
513
-#define B11111111 255
514
-
515
-#endif

+ 0
- 14
Marlin/Sanguino/cores/Copy of arduino/main.cpp View File

@@ -1,14 +0,0 @@
1
-#include <WProgram.h>
2
-
3
-int main(void)
4
-{
5
-	init();
6
-
7
-	setup();
8
-    
9
-	for (;;)
10
-		loop();
11
-        
12
-	return 0;
13
-}
14
-

+ 0
- 200
Marlin/Sanguino/cores/Copy of arduino/pins_arduino.c View File

@@ -1,200 +0,0 @@
1
-/*
2
-  pins_arduino.c - pin definitions for the Arduino board
3
-  Part of Arduino / Wiring Lite
4
-
5
-  Copyright (c) 2005 David A. Mellis
6
-
7
-  This library is free software; you can redistribute it and/or
8
-  modify it under the terms of the GNU Lesser General Public
9
-  License as published by the Free Software Foundation; either
10
-  version 2.1 of the License, or (at your option) any later version.
11
-
12
-  This library is distributed in the hope that it will be useful,
13
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
-  Lesser General Public License for more details.
16
-
17
-  You should have received a copy of the GNU Lesser General
18
-  Public License along with this library; if not, write to the
19
-  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20
-  Boston, MA  02111-1307  USA
21
-
22
-  $Id: pins_arduino.c 254 2007-04-20 23:17:38Z mellis $
23
-*/
24
-
25
-#include <avr/io.h>
26
-#include "wiring_private.h"
27
-#include "pins_arduino.h"
28
-
29
-// On the Sanguino board, digital pins are also used
30
-// for the analog output (software PWM).  Analog input
31
-// pins are a separate set.
32
-
33
-// ATMEL ATMEGA644P / SANGUINO
34
-//
35
-//                   +---\/---+
36
-//  INT0 (D 0) PB0  1|        |40  PA0 (AI 0 / D31)
37
-//  INT1 (D 1) PB1  2|        |39  PA1 (AI 1 / D30)
38
-//  INT2 (D 2) PB2  3|        |38  PA2 (AI 2 / D29)
39
-//   PWM (D 3) PB3  4|        |37  PA3 (AI 3 / D28)
40
-//   PWM (D 4) PB4  5|        |36  PA4 (AI 4 / D27)
41
-//  MOSI (D 5) PB5  6|        |35  PA5 (AI 5 / D26)
42
-//  MISO (D 6) PB6  7|        |34  PA6 (AI 6 / D25)
43
-//   SCK (D 7) PB7  8|        |33  PA7 (AI 7 / D24)
44
-//             RST  9|        |32  AREF
45
-//             VCC 10|        |31  GND 
46
-//             GND 11|        |30  AVCC
47
-//           XTAL2 12|        |29  PC7 (D 23)
48
-//           XTAL1 13|        |28  PC6 (D 22)
49
-//  RX0 (D 8)  PD0 14|        |27  PC5 (D 21) TDI
50
-//  TX0 (D 9)  PD1 15|        |26  PC4 (D 20) TDO
51
-//  RX1 (D 10) PD2 16|        |25  PC3 (D 19) TMS
52
-//  TX1 (D 11) PD3 17|        |24  PC2 (D 18) TCK
53
-//  PWM (D 12) PD4 18|        |23  PC1 (D 17) SDA
54
-//  PWM (D 13) PD5 19|        |22  PC0 (D 16) SCL
55
-//  PWM (D 14) PD6 20|        |21  PD7 (D 15) PWM
56
-//                   +--------+
57
-//
58
-
59
-#define PA 1
60
-#define PB 2
61
-#define PC 3
62
-#define PD 4
63
-
64
-// these arrays map port names (e.g. port B) to the
65
-// appropriate addresses for various functions (e.g. reading
66
-// and writing)
67
-const uint8_t PROGMEM port_to_mode_PGM[] =
68
-{
69
-	NOT_A_PORT,
70
-    &DDRA,
71
-	&DDRB,
72
-	&DDRC,
73
-	&DDRD,
74
-};
75
-
76
-const uint8_t PROGMEM port_to_output_PGM[] =
77
-{
78
-	NOT_A_PORT,
79
-	&PORTA,
80
-	&PORTB,
81
-	&PORTC,
82
-	&PORTD,
83
-};
84
-
85
-const uint8_t PROGMEM port_to_input_PGM[] =
86
-{
87
-	NOT_A_PORT,
88
-	&PINA,
89
-	&PINB,
90
-	&PINC,
91
-	&PIND,
92
-};
93
-
94
-const uint8_t PROGMEM digital_pin_to_port_PGM[] =
95
-{
96
-	PB, /* 0 */
97
-	PB,
98
-	PB,
99
-	PB,
100
-	PB,
101
-	PB,
102
-	PB,
103
-	PB,
104
-	PD, /* 8 */
105
-	PD,
106
-	PD,
107
-	PD,
108
-	PD,
109
-	PD,
110
-	PD,
111
-	PD,
112
-	PC, /* 16 */
113
-	PC,
114
-	PC,
115
-	PC,
116
-	PC,
117
-	PC,
118
-   	PC,
119
-	PC,
120
-	PA, /* 24 */
121
-	PA,
122
-	PA,
123
-	PA,
124
-	PA,
125
-	PA,
126
-	PA,
127
-	PA  /* 31 */
128
-};
129
-
130
-const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] =
131
-{
132
-	_BV(0), /* 0, port B */
133
-	_BV(1),
134
-	_BV(2),
135
-	_BV(3),
136
-	_BV(4),
137
-	_BV(5),
138
-	_BV(6),
139
-	_BV(7),
140
-	_BV(0), /* 8, port D */
141
-	_BV(1),
142
-	_BV(2),
143
-	_BV(3),
144
-	_BV(4),
145
-	_BV(5),
146
-	_BV(6),
147
-	_BV(7),
148
-	_BV(0), /* 16, port C */
149
-	_BV(1),
150
-	_BV(2),
151
-	_BV(3),
152
-	_BV(4),
153
-	_BV(5),
154
-	_BV(6),
155
-	_BV(7),
156
-	_BV(7), /* 24, port A */
157
-	_BV(6),
158
-	_BV(5),
159
-	_BV(4),
160
-	_BV(3),
161
-	_BV(2),
162
-	_BV(1),
163
-	_BV(0)
164
-};
165
-
166
-const uint8_t PROGMEM digital_pin_to_timer_PGM[] =
167
-{
168
-	NOT_ON_TIMER, 	/* 0  - PB0 */
169
-	NOT_ON_TIMER, 	/* 1  - PB1 */
170
-	NOT_ON_TIMER, 	/* 2  - PB2 */
171
-	TIMER0A,     	/* 3  - PB3 */
172
-	TIMER0B, 		/* 4  - PB4 */
173
-	NOT_ON_TIMER, 	/* 5  - PB5 */
174
-	NOT_ON_TIMER, 	/* 6  - PB6 */
175
-	NOT_ON_TIMER,	/* 7  - PB7 */
176
-	NOT_ON_TIMER, 	/* 8  - PD0 */
177
-	NOT_ON_TIMER, 	/* 9  - PD1 */
178
-	NOT_ON_TIMER, 	/* 10 - PD2 */
179
-	NOT_ON_TIMER, 	/* 11 - PD3 */
180
-	TIMER1B,     	/* 12 - PD4 */
181
-	TIMER1A,     	/* 13 - PD5 */
182
-	TIMER2B,     	/* 14 - PD6 */
183
-	TIMER2A,     	/* 15 - PD7 */
184
-	NOT_ON_TIMER, 	/* 16 - PC0 */
185
-	NOT_ON_TIMER,   /* 17 - PC1 */
186
-	NOT_ON_TIMER,   /* 18 - PC2 */
187
-	NOT_ON_TIMER,   /* 19 - PC3 */
188
-	NOT_ON_TIMER,   /* 20 - PC4 */
189
-	NOT_ON_TIMER,   /* 21 - PC5 */
190
-	NOT_ON_TIMER,   /* 22 - PC6 */
191
-	NOT_ON_TIMER,   /* 23 - PC7 */
192
-	NOT_ON_TIMER,   /* 24 - PA0 */
193
-	NOT_ON_TIMER,   /* 25 - PA1 */
194
-	NOT_ON_TIMER,   /* 26 - PA2 */
195
-	NOT_ON_TIMER,   /* 27 - PA3 */
196
-	NOT_ON_TIMER,   /* 28 - PA4 */
197
-	NOT_ON_TIMER,   /* 29 - PA5 */
198
-	NOT_ON_TIMER,   /* 30 - PA6 */
199
-	NOT_ON_TIMER   /* 31 - PA7 */
200
-};

+ 0
- 65
Marlin/Sanguino/cores/Copy of arduino/pins_arduino.h View File

@@ -1,65 +0,0 @@
1
-/*
2
-  pins_arduino.h - Pin definition functions for Arduino
3
-  Part of Arduino - http://www.arduino.cc/
4
-
5
-  Copyright (c) 2007 David A. Mellis
6
-
7
-  This library is free software; you can redistribute it and/or
8
-  modify it under the terms of the GNU Lesser General Public
9
-  License as published by the Free Software Foundation; either
10
-  version 2.1 of the License, or (at your option) any later version.
11
-
12
-  This library is distributed in the hope that it will be useful,
13
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
-  Lesser General Public License for more details.
16
-
17
-  You should have received a copy of the GNU Lesser General
18
-  Public License along with this library; if not, write to the
19
-  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20
-  Boston, MA  02111-1307  USA
21
-
22
-  $Id: wiring.h 249 2007-02-03 16:52:51Z mellis $
23
-*/
24
-
25
-#ifndef Pins_Arduino_h
26
-#define Pins_Arduino_h
27
-
28
-#include <avr/pgmspace.h>
29
-
30
-#define NOT_A_PIN 0
31
-#define NOT_A_PORT 0
32
-
33
-#define NOT_ON_TIMER 0
34
-#define TIMER0A 1
35
-#define TIMER0B 2
36
-#define TIMER1A 3
37
-#define TIMER1B 4
38
-#define TIMER2  5
39
-#define TIMER2A 6
40
-#define TIMER2B 7
41
-
42
-extern const uint8_t PROGMEM port_to_mode_PGM[];
43
-extern const uint8_t PROGMEM port_to_input_PGM[];
44
-extern const uint8_t PROGMEM port_to_output_PGM[];
45
-
46
-extern const uint8_t PROGMEM digital_pin_to_port_PGM[];
47
-extern const uint8_t PROGMEM digital_pin_to_bit_PGM[];
48
-extern const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[];
49
-
50
-extern const uint8_t PROGMEM digital_pin_to_timer_PGM[];
51
-
52
-// Get the bit location within the hardware port of the given virtual pin.
53
-// This comes from the pins_*.c file for the active board configuration.
54
-// 
55
-// These perform slightly better as macros compared to inline functions
56
-//
57
-#define digitalPinToPort(P) ( pgm_read_byte( digital_pin_to_port_PGM + (P) ) )
58
-#define digitalPinToBitMask(P) ( pgm_read_byte( digital_pin_to_bit_mask_PGM + (P) ) )
59
-#define digitalPinToTimer(P) ( pgm_read_byte( digital_pin_to_timer_PGM + (P) ) )
60
-#define analogInPinToBit(P) (P)
61
-#define portOutputRegister(P) ( (volatile uint8_t *)( pgm_read_byte( port_to_output_PGM + (P))) )
62
-#define portInputRegister(P) ( (volatile uint8_t *)( pgm_read_byte( port_to_input_PGM + (P))) )
63
-#define portModeRegister(P) ( (volatile uint8_t *)( pgm_read_byte( port_to_mode_PGM + (P))) )
64
-
65
-#endif

+ 0
- 289
Marlin/Sanguino/cores/Copy of arduino/wiring.c View File

@@ -1,289 +0,0 @@
1
-/*
2
-  wiring.c - Partial implementation of the Wiring API for the ATmega8.
3
-  Part of Arduino - http://www.arduino.cc/
4
-
5
-  Copyright (c) 2005-2006 David A. Mellis
6
-
7
-  This library is free software; you can redistribute it and/or
8
-  modify it under the terms of the GNU Lesser General Public
9
-  License as published by the Free Software Foundation; either
10
-  version 2.1 of the License, or (at your option) any later version.
11
-
12
-  This library is distributed in the hope that it will be useful,
13
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
-  Lesser General Public License for more details.
16
-
17
-  You should have received a copy of the GNU Lesser General
18
-  Public License along with this library; if not, write to the
19
-  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20
-  Boston, MA  02111-1307  USA
21
-
22
-  $Id$
23
-*/
24
-
25
-#include "wiring_private.h"
26
-
27
-// the prescaler is set so that timer0 ticks every 64 clock cycles, and the
28
-// the overflow handler is called every 256 ticks.
29
-#define MICROSECONDS_PER_TIMER0_OVERFLOW (clockCyclesToMicroseconds(64 * 256))
30
-
31
-// the whole number of milliseconds per timer0 overflow
32
-#define MILLIS_INC (MICROSECONDS_PER_TIMER0_OVERFLOW / 1000)
33
-
34
-// the fractional number of milliseconds per timer0 overflow. we shift right
35
-// by three to fit these numbers into a byte. (for the clock speeds we care
36
-// about - 8 and 16 MHz - this doesn't lose precision.)
37
-#define FRACT_INC ((MICROSECONDS_PER_TIMER0_OVERFLOW % 1000) >> 3)
38
-#define FRACT_MAX (1000 >> 3)
39
-
40
-volatile unsigned long timer0_overflow_count = 0;
41
-volatile unsigned long timer0_millis = 0;
42
-static unsigned char timer0_fract = 0;
43
-
44
-SIGNAL(TIMER0_OVF_vect)
45
-{
46
-	// copy these to local variables so they can be stored in registers
47
-	// (volatile variables must be read from memory on every access)
48
-	unsigned long m = timer0_millis;
49
-	unsigned char f = timer0_fract;
50
-
51
-	m += MILLIS_INC;
52
-	f += FRACT_INC;
53
-	if (f >= FRACT_MAX) {
54
-		f -= FRACT_MAX;
55
-		m += 1;
56
-	}
57
-
58
-	timer0_fract = f;
59
-	timer0_millis = m;
60
-	timer0_overflow_count++;
61
-}
62
-
63
-unsigned long millis()
64
-{
65
-	unsigned long m;
66
-	uint8_t oldSREG = SREG;
67
-
68
-	// disable interrupts while we read timer0_millis or we might get an
69
-	// inconsistent value (e.g. in the middle of a write to timer0_millis)
70
-	cli();
71
-	m = timer0_millis;
72
-	SREG = oldSREG;
73
-
74
-	return m;
75
-}
76
-
77
-unsigned long micros() {
78
-	unsigned long m;
79
-	uint8_t oldSREG = SREG, t;
80
-	
81
-	cli();
82
-	m = timer0_overflow_count;
83
-#if defined(TCNT0)
84
-	t = TCNT0;
85
-#elif defined(TCNT0L)
86
-	t = TCNT0L;
87
-#else
88
-	#error TIMER 0 not defined
89
-#endif
90
-
91
-  
92
-#ifdef TIFR0
93
-	if ((TIFR0 & _BV(TOV0)) && (t < 255))
94
-		m++;
95
-#else
96
-	if ((TIFR & _BV(TOV0)) && (t < 255))
97
-		m++;
98
-#endif
99
-
100
-	SREG = oldSREG;
101
-	
102
-	return ((m << 8) + t) * (64 / clockCyclesPerMicrosecond());
103
-}
104
-
105
-void delay(unsigned long ms)
106
-{
107
-	uint16_t start = (uint16_t)micros();
108
-
109
-	while (ms > 0) {
110
-		if (((uint16_t)micros() - start) >= 1000) {
111
-			ms--;
112
-			start += 1000;
113
-		}
114
-	}
115
-}
116
-
117
-/* Delay for the given number of microseconds.  Assumes a 8 or 16 MHz clock. */
118
-void delayMicroseconds(unsigned int us)
119
-{
120
-	// calling avrlib's delay_us() function with low values (e.g. 1 or
121
-	// 2 microseconds) gives delays longer than desired.
122
-	//delay_us(us);
123
-
124
-#if F_CPU >= 16000000L
125
-	// for the 16 MHz clock on most Arduino boards
126
-
127
-	// for a one-microsecond delay, simply return.  the overhead
128
-	// of the function call yields a delay of approximately 1 1/8 us.
129
-	if (--us == 0)
130
-		return;
131
-
132
-	// the following loop takes a quarter of a microsecond (4 cycles)
133
-	// per iteration, so execute it four times for each microsecond of
134
-	// delay requested.
135
-	us <<= 2;
136
-
137
-	// account for the time taken in the preceeding commands.
138
-	us -= 2;
139
-#else
140
-	// for the 8 MHz internal clock on the ATmega168
141
-
142
-	// for a one- or two-microsecond delay, simply return.  the overhead of
143
-	// the function calls takes more than two microseconds.  can't just
144
-	// subtract two, since us is unsigned; we'd overflow.
145
-	if (--us == 0)
146
-		return;
147
-	if (--us == 0)
148
-		return;
149
-
150
-	// the following loop takes half of a microsecond (4 cycles)
151
-	// per iteration, so execute it twice for each microsecond of
152
-	// delay requested.
153
-	us <<= 1;
154
-    
155
-	// partially compensate for the time taken by the preceeding commands.
156
-	// we can't subtract any more than this or we'd overflow w/ small delays.
157
-	us--;
158
-#endif
159
-
160
-	// busy wait
161
-	__asm__ __volatile__ (
162
-		"1: sbiw %0,1" "\n\t" // 2 cycles
163
-		"brne 1b" : "=w" (us) : "0" (us) // 2 cycles
164
-	);
165
-}
166
-
167
-void init()
168
-{
169
-	// this needs to be called before setup() or some functions won't
170
-	// work there
171
-	sei();
172
-	
173
-	// on the ATmega168, timer 0 is also used for fast hardware pwm
174
-	// (using phase-correct PWM would mean that timer 0 overflowed half as often
175
-	// resulting in different millis() behavior on the ATmega8 and ATmega168)
176
-#if defined(TCCR0A) && defined(WGM01)
177
-	sbi(TCCR0A, WGM01);
178
-	sbi(TCCR0A, WGM00);
179
-#endif  
180
-
181
-	// set timer 0 prescale factor to 64
182
-#if defined(__AVR_ATmega128__)
183
-	// CPU specific: different values for the ATmega128
184
-	sbi(TCCR0, CS02);
185
-#elif defined(TCCR0) && defined(CS01) && defined(CS00)
186
-	// this combination is for the standard atmega8
187
-	sbi(TCCR0, CS01);
188
-	sbi(TCCR0, CS00);
189
-#elif defined(TCCR0B) && defined(CS01) && defined(CS00)
190
-	// this combination is for the standard 168/328/1280/2560
191
-	sbi(TCCR0B, CS01);
192
-	sbi(TCCR0B, CS00);
193
-#elif defined(TCCR0A) && defined(CS01) && defined(CS00)
194
-	// this combination is for the __AVR_ATmega645__ series
195
-	sbi(TCCR0A, CS01);
196
-	sbi(TCCR0A, CS00);
197
-#else
198
-	#error Timer 0 prescale factor 64 not set correctly
199
-#endif
200
-
201
-	// enable timer 0 overflow interrupt
202
-#if defined(TIMSK) && defined(TOIE0)
203
-	sbi(TIMSK, TOIE0);
204
-#elif defined(TIMSK0) && defined(TOIE0)
205
-	sbi(TIMSK0, TOIE0);
206
-#else
207
-	#error	Timer 0 overflow interrupt not set correctly
208
-#endif
209
-
210
-	// timers 1 and 2 are used for phase-correct hardware pwm
211
-	// this is better for motors as it ensures an even waveform
212
-	// note, however, that fast pwm mode can achieve a frequency of up
213
-	// 8 MHz (with a 16 MHz clock) at 50% duty cycle
214
-
215
-	TCCR1B = 0;
216
-
217
-	// set timer 1 prescale factor to 64
218
-#if defined(TCCR1B) && defined(CS11) && defined(CS10)
219
-	sbi(TCCR1B, CS11);
220
-	sbi(TCCR1B, CS10);
221
-#elif defined(TCCR1) && defined(CS11) && defined(CS10)
222
-	sbi(TCCR1, CS11);
223
-	sbi(TCCR1, CS10);
224
-#endif
225
-	// put timer 1 in 8-bit phase correct pwm mode
226
-#if defined(TCCR1A) && defined(WGM10)
227
-	sbi(TCCR1A, WGM10);
228
-#elif defined(TCCR1)
229
-	#warning this needs to be finished
230
-#endif
231
-
232
-	// set timer 2 prescale factor to 64
233
-#if defined(TCCR2) && defined(CS22)
234
-	sbi(TCCR2, CS22);
235
-#elif defined(TCCR2B) && defined(CS22)
236
-	sbi(TCCR2B, CS22);
237
-#else
238
-	#warning Timer 2 not finished (may not be present on this CPU)
239
-#endif
240
-
241
-	// configure timer 2 for phase correct pwm (8-bit)
242
-#if defined(TCCR2) && defined(WGM20)
243
-	sbi(TCCR2, WGM20);
244
-#elif defined(TCCR2A) && defined(WGM20)
245
-	sbi(TCCR2A, WGM20);
246
-#else
247
-	#warning Timer 2 not finished (may not be present on this CPU)
248
-#endif
249
-
250
-#if defined(TCCR3B) && defined(CS31) && defined(WGM30)
251
-	sbi(TCCR3B, CS31);		// set timer 3 prescale factor to 64
252
-	sbi(TCCR3B, CS30);
253
-	sbi(TCCR3A, WGM30);		// put timer 3 in 8-bit phase correct pwm mode
254
-#endif
255
-	
256
-#if defined(TCCR4B) && defined(CS41) && defined(WGM40)
257
-	sbi(TCCR4B, CS41);		// set timer 4 prescale factor to 64
258
-	sbi(TCCR4B, CS40);
259
-	sbi(TCCR4A, WGM40);		// put timer 4 in 8-bit phase correct pwm mode
260
-#endif
261
-
262
-#if defined(TCCR5B) && defined(CS51) && defined(WGM50)
263
-	sbi(TCCR5B, CS51);		// set timer 5 prescale factor to 64
264
-	sbi(TCCR5B, CS50);
265
-	sbi(TCCR5A, WGM50);		// put timer 5 in 8-bit phase correct pwm mode
266
-#endif
267
-
268
-#if defined(ADCSRA)
269
-	// set a2d prescale factor to 128
270
-	// 16 MHz / 128 = 125 KHz, inside the desired 50-200 KHz range.
271
-	// XXX: this will not work properly for other clock speeds, and
272
-	// this code should use F_CPU to determine the prescale factor.
273
-	sbi(ADCSRA, ADPS2);
274
-	sbi(ADCSRA, ADPS1);
275
-	sbi(ADCSRA, ADPS0);
276
-
277
-	// enable a2d conversions
278
-	sbi(ADCSRA, ADEN);
279
-#endif
280
-
281
-	// the bootloader connects pins 0 and 1 to the USART; disconnect them
282
-	// here so they can be used as normal digital i/o; they will be
283
-	// reconnected in Serial.begin()
284
-#if defined(UCSRB)
285
-	UCSRB = 0;
286
-#elif defined(UCSR0B)
287
-	UCSR0B = 0;
288
-#endif
289
-}

+ 0
- 135
Marlin/Sanguino/cores/Copy of arduino/wiring.h View File

@@ -1,135 +0,0 @@
1
-/*
2
-  wiring.h - Partial implementation of the Wiring API for the ATmega8.
3
-  Part of Arduino - http://www.arduino.cc/
4
-
5
-  Copyright (c) 2005-2006 David A. Mellis
6
-
7
-  This library is free software; you can redistribute it and/or
8
-  modify it under the terms of the GNU Lesser General Public
9
-  License as published by the Free Software Foundation; either
10
-  version 2.1 of the License, or (at your option) any later version.
11
-
12
-  This library is distributed in the hope that it will be useful,
13
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
-  Lesser General Public License for more details.
16
-
17
-  You should have received a copy of the GNU Lesser General
18
-  Public License along with this library; if not, write to the
19
-  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20
-  Boston, MA  02111-1307  USA
21
-
22
-  $Id$
23
-*/
24
-
25
-#ifndef Wiring_h
26
-#define Wiring_h
27
-
28
-#include <avr/io.h>
29
-#include <stdlib.h>
30
-#include "binary.h"
31
-
32
-#ifdef __cplusplus
33
-extern "C"{
34
-#endif
35
-
36
-#define HIGH 0x1
37
-#define LOW  0x0
38
-
39
-#define INPUT 0x0
40
-#define OUTPUT 0x1
41
-
42
-#define true 0x1
43
-#define false 0x0
44
-
45
-#define PI 3.1415926535897932384626433832795
46
-#define HALF_PI 1.5707963267948966192313216916398
47
-#define TWO_PI 6.283185307179586476925286766559
48
-#define DEG_TO_RAD 0.017453292519943295769236907684886
49
-#define RAD_TO_DEG 57.295779513082320876798154814105
50
-
51
-#define SERIAL  0x0
52
-#define DISPLAY 0x1
53
-
54
-#define LSBFIRST 0
55
-#define MSBFIRST 1
56
-
57
-#define CHANGE 1
58
-#define FALLING 2
59
-#define RISING 3
60
-
61
-#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
62
-#define INTERNAL1V1 2
63
-#define INTERNAL2V56 3
64
-#else
65
-#define INTERNAL 3
66
-#endif
67
-#define DEFAULT 1
68
-#define EXTERNAL 0
69
-
70
-// undefine stdlib's abs if encountered
71
-#ifdef abs
72
-#undef abs
73
-#endif
74
-
75
-#define min(a,b) ((a)<(b)?(a):(b))
76
-#define max(a,b) ((a)>(b)?(a):(b))
77
-#define abs(x) ((x)>0?(x):-(x))
78
-#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
79
-#define round(x)     ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
80
-#define radians(deg) ((deg)*DEG_TO_RAD)
81
-#define degrees(rad) ((rad)*RAD_TO_DEG)
82
-#define sq(x) ((x)*(x))
83
-
84
-#define interrupts() sei()
85
-#define noInterrupts() cli()
86
-
87
-#define clockCyclesPerMicrosecond() ( F_CPU / 1000000L )
88
-#define clockCyclesToMicroseconds(a) ( ((a) * 1000L) / (F_CPU / 1000L) )
89
-#define microsecondsToClockCycles(a) ( ((a) * (F_CPU / 1000L)) / 1000L )
90
-
91
-#define lowByte(w) ((uint8_t) ((w) & 0xff))
92
-#define highByte(w) ((uint8_t) ((w) >> 8))
93
-
94
-#define bitRead(value, bit) (((value) >> (bit)) & 0x01)
95
-#define bitSet(value, bit) ((value) |= (1UL << (bit)))
96
-#define bitClear(value, bit) ((value) &= ~(1UL << (bit)))
97
-#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit))
98
-
99
-
100
-typedef unsigned int word;
101
-
102
-#define bit(b) (1UL << (b))
103
-
104
-typedef uint8_t boolean;
105
-typedef uint8_t byte;
106
-
107
-void init(void);
108
-
109
-void pinMode(uint8_t, uint8_t);
110
-void digitalWrite(uint8_t, uint8_t);
111
-int digitalRead(uint8_t);
112
-int analogRead(uint8_t);
113
-void analogReference(uint8_t mode);
114
-void analogWrite(uint8_t, int);
115
-
116
-unsigned long millis(void);
117
-unsigned long micros(void);
118
-void delay(unsigned long);
119
-void delayMicroseconds(unsigned int us);
120
-unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout);
121
-
122
-void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val);
123
-uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder);
124
-
125
-void attachInterrupt(uint8_t, void (*)(void), int mode);
126
-void detachInterrupt(uint8_t);
127
-
128
-void setup(void);
129
-void loop(void);
130
-
131
-#ifdef __cplusplus
132
-} // extern "C"
133
-#endif
134
-
135
-#endif

+ 0
- 116
Marlin/Sanguino/cores/Copy of arduino/wiring_analog.c View File

@@ -1,116 +0,0 @@
1
-/*
2
-  wiring_analog.c - analog input and output
3
-  Part of Arduino - http://www.arduino.cc/
4
-
5
-  Copyright (c) 2005-2006 David A. Mellis
6
-
7
-  This library is free software; you can redistribute it and/or
8
-  modify it under the terms of the GNU Lesser General Public
9
-  License as published by the Free Software Foundation; either
10
-  version 2.1 of the License, or (at your option) any later version.
11
-
12
-  This library is distributed in the hope that it will be useful,
13
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
-  Lesser General Public License for more details.
16
-
17
-  You should have received a copy of the GNU Lesser General
18
-  Public License along with this library; if not, write to the
19
-  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20
-  Boston, MA  02111-1307  USA
21
-
22
-  $Id: wiring.c 248 2007-02-03 15:36:30Z mellis $
23
-*/
24
-
25
-#include "wiring_private.h"
26
-#include "pins_arduino.h"
27
-
28
-uint8_t analog_reference = DEFAULT;
29
-
30
-void analogReference(uint8_t mode)
31
-{
32
-	// can't actually set the register here because the default setting
33
-	// will connect AVCC and the AREF pin, which would cause a short if
34
-	// there's something connected to AREF.
35
-	analog_reference = mode;
36
-}
37
-
38
-int analogRead(uint8_t pin)
39
-{
40
-	uint8_t low, high, ch = analogInPinToBit(pin);
41
-
42
-	// set the analog reference (high two bits of ADMUX) and select the
43
-	// channel (low 4 bits).  this also sets ADLAR (left-adjust result)
44
-	// to 0 (the default).
45
-	// the final AND is to clear the pos/neg reference bits
46
-	ADMUX = ((analog_reference << 6) | (pin & 0x0f)) & B11000111;
47
-
48
-	// without a delay, we seem to read from the wrong channel
49
-	//delay(1);
50
-
51
-	// start the conversion
52
-	sbi(ADCSRA, ADSC);
53
-
54
-	// ADSC is cleared when the conversion finishes
55
-	while (bit_is_set(ADCSRA, ADSC));
56
-
57
-	// we have to read ADCL first; doing so locks both ADCL
58
-	// and ADCH until ADCH is read.  reading ADCL second would
59
-	// cause the results of each conversion to be discarded,
60
-	// as ADCL and ADCH would be locked when it completed.
61
-	low = ADCL;
62
-	high = ADCH;
63
-
64
-	// combine the two bytes
65
-	return (high << 8) | low;
66
-}
67
-
68
-// Right now, PWM output only works on the pins with
69
-// hardware support.  These are defined in the appropriate
70
-// pins_*.c file.  For the rest of the pins, we default
71
-// to digital output.
72
-void analogWrite(uint8_t pin, int val)
73
-{
74
-	// We need to make sure the PWM output is enabled for those pins
75
-	// that support it, as we turn it off when digitally reading or
76
-	// writing with them.  Also, make sure the pin is in output mode
77
-	// for consistenty with Wiring, which doesn't require a pinMode
78
-	// call for the analog output pins.
79
-	pinMode(pin, OUTPUT);
80
-	
81
-	if (digitalPinToTimer(pin) == TIMER1A) {
82
-		// connect pwm to pin on timer 1, channel A
83
-		sbi(TCCR1A, COM1A1);
84
-		// set pwm duty
85
-		OCR1A = val;
86
-	} else if (digitalPinToTimer(pin) == TIMER1B) {
87
-		// connect pwm to pin on timer 1, channel B
88
-		sbi(TCCR1A, COM1B1);
89
-		// set pwm duty
90
-		OCR1B = val;
91
-	} else if (digitalPinToTimer(pin) == TIMER0A) {
92
-		// connect pwm to pin on timer 0, channel A
93
-		sbi(TCCR0A, COM0A1);
94
-		// set pwm duty
95
-		OCR0A = val;	
96
-	} else if (digitalPinToTimer(pin) == TIMER0B) {
97
-		// connect pwm to pin on timer 0, channel B
98
-		sbi(TCCR0A, COM0B1);
99
-		// set pwm duty
100
-		OCR0B = val;
101
-	} else if (digitalPinToTimer(pin) == TIMER2A) {
102
-		// connect pwm to pin on timer 2, channel A
103
-		sbi(TCCR2A, COM2A1);
104
-		// set pwm duty
105
-		OCR2A = val;	
106
-	} else if (digitalPinToTimer(pin) == TIMER2B) {
107
-		// connect pwm to pin on timer 2, channel B
108
-		sbi(TCCR2A, COM2B1);
109
-		// set pwm duty
110
-		OCR2B = val;
111
-	} else if (val < 128)
112
-	//fail semi-intelligently
113
-		digitalWrite(pin, LOW);
114
-	else
115
-		digitalWrite(pin, HIGH);
116
-}

+ 0
- 95
Marlin/Sanguino/cores/Copy of arduino/wiring_digital.c View File

@@ -1,95 +0,0 @@
1
-/*
2
-  wiring_digital.c - digital input and output functions
3
-  Part of Arduino - http://www.arduino.cc/
4
-
5
-  Copyright (c) 2005-2006 David A. Mellis
6
-
7
-  This library is free software; you can redistribute it and/or
8
-  modify it under the terms of the GNU Lesser General Public
9
-  License as published by the Free Software Foundation; either
10
-  version 2.1 of the License, or (at your option) any later version.
11
-
12
-  This library is distributed in the hope that it will be useful,
13
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
-  Lesser General Public License for more details.
16
-
17
-  You should have received a copy of the GNU Lesser General
18
-  Public License along with this library; if not, write to the
19
-  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20
-  Boston, MA  02111-1307  USA
21
-
22
-  $Id: wiring.c 248 2007-02-03 15:36:30Z mellis $
23
-*/
24
-
25
-#include "wiring_private.h"
26
-#include "pins_arduino.h"
27
-
28
-void pinMode(uint8_t pin, uint8_t mode)
29
-{
30
-	uint8_t bit = digitalPinToBitMask(pin);
31
-	uint8_t port = digitalPinToPort(pin);
32
-	volatile uint8_t *reg;
33
-
34
-	if (port == NOT_A_PIN) return;
35
-
36
-	// JWS: can I let the optimizer do this?
37
-	reg = portModeRegister(port);
38
-
39
-	if (mode == INPUT) *reg &= ~bit;
40
-	else *reg |= bit;
41
-}
42
-
43
-// Forcing this inline keeps the callers from having to push their own stuff
44
-// on the stack. It is a good performance win and only takes 1 more byte per
45
-// user than calling. (It will take more bytes on the 168.)
46
-//
47
-// But shouldn't this be moved into pinMode? Seems silly to check and do on
48
-// each digitalread or write.
49
-//
50
-static inline void turnOffPWM(uint8_t timer) __attribute__ ((always_inline));
51
-static inline void turnOffPWM(uint8_t timer)
52
-{
53
-	if (timer == TIMER0A) cbi(TCCR0A, COM0A1);
54
-	if (timer == TIMER0B) cbi(TCCR0A, COM0B1);
55
-	if (timer == TIMER1A) cbi(TCCR1A, COM1A1);
56
-	if (timer == TIMER1B) cbi(TCCR1A, COM1B1);
57
-	if (timer == TIMER2A) cbi(TCCR2A, COM2A1);
58
-	if (timer == TIMER2B) cbi(TCCR2A, COM2B1);
59
-}
60
-
61
-void digitalWrite(uint8_t pin, uint8_t val)
62
-{
63
-	uint8_t timer = digitalPinToTimer(pin);
64
-	uint8_t bit = digitalPinToBitMask(pin);
65
-	uint8_t port = digitalPinToPort(pin);
66
-	volatile uint8_t *out;
67
-
68
-	if (port == NOT_A_PIN) return;
69
-
70
-	// If the pin that support PWM output, we need to turn it off
71
-	// before doing a digital write.
72
-	if (timer != NOT_ON_TIMER) turnOffPWM(timer);
73
-
74
-	out = portOutputRegister(port);
75
-
76
-	if (val == LOW) *out &= ~bit;
77
-	else *out |= bit;
78
-}
79
-
80
-int digitalRead(uint8_t pin)
81
-{
82
-	uint8_t timer = digitalPinToTimer(pin);
83
-	uint8_t bit = digitalPinToBitMask(pin);
84
-	uint8_t port = digitalPinToPort(pin);
85
-
86
-	if (port == NOT_A_PIN) return LOW;
87
-
88
-	// If the pin that support PWM output, we need to turn it off
89
-	// before getting a digital reading.
90
-	if (timer != NOT_ON_TIMER) turnOffPWM(timer);
91
-
92
-	if (*portInputRegister(port) & bit) return HIGH;
93
-	
94
-	return LOW;
95
-}

+ 0
- 60
Marlin/Sanguino/cores/Copy of arduino/wiring_private.h View File

@@ -1,60 +0,0 @@
1
-/*
2
-  wiring_private.h - Internal header file.
3
-  Part of Arduino - http://www.arduino.cc/
4
-
5
-  Copyright (c) 2005-2006 David A. Mellis
6
-
7
-  This library is free software; you can redistribute it and/or
8
-  modify it under the terms of the GNU Lesser General Public
9
-  License as published by the Free Software Foundation; either
10
-  version 2.1 of the License, or (at your option) any later version.
11
-
12
-  This library is distributed in the hope that it will be useful,
13
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
-  Lesser General Public License for more details.
16
-
17
-  You should have received a copy of the GNU Lesser General
18
-  Public License along with this library; if not, write to the
19
-  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20
-  Boston, MA  02111-1307  USA
21
-
22
-  $Id: wiring.h 239 2007-01-12 17:58:39Z mellis $
23
-*/
24
-
25
-#ifndef WiringPrivate_h
26
-#define WiringPrivate_h
27
-
28
-#include <avr/io.h>
29
-#include <avr/interrupt.h>
30
-#include <avr/signal.h>
31
-#include <avr/delay.h>
32
-#include <stdio.h>
33
-#include <stdarg.h>
34
-
35
-#include "wiring.h"
36
-
37
-#ifdef __cplusplus
38
-extern "C"{
39
-#endif
40
-
41
-#ifndef cbi
42
-#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
43
-#endif
44
-#ifndef sbi
45
-#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
46
-#endif
47
-
48
-#define EXTERNAL_INT_0 0
49
-#define EXTERNAL_INT_1 1
50
-#define EXTERNAL_INT_2 2
51
-
52
-#define EXTERNAL_NUM_INTERRUPTS 3
53
-
54
-typedef void (*voidFuncPtr)(void);
55
-
56
-#ifdef __cplusplus
57
-} // extern "C"
58
-#endif
59
-
60
-#endif

+ 0
- 69
Marlin/Sanguino/cores/Copy of arduino/wiring_pulse.c View File

@@ -1,69 +0,0 @@
1
-/*
2
-  wiring_pulse.c - pulseIn() function
3
-  Part of Arduino - http://www.arduino.cc/
4
-
5
-  Copyright (c) 2005-2006 David A. Mellis
6
-
7
-  This library is free software; you can redistribute it and/or
8
-  modify it under the terms of the GNU Lesser General Public
9
-  License as published by the Free Software Foundation; either
10
-  version 2.1 of the License, or (at your option) any later version.
11
-
12
-  This library is distributed in the hope that it will be useful,
13
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
-  Lesser General Public License for more details.
16
-
17
-  You should have received a copy of the GNU Lesser General
18
-  Public License along with this library; if not, write to the
19
-  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20
-  Boston, MA  02111-1307  USA
21
-
22
-  $Id: wiring.c 248 2007-02-03 15:36:30Z mellis $
23
-*/
24
-
25
-#include "wiring_private.h"
26
-#include "pins_arduino.h"
27
-
28
-/* Measures the length (in microseconds) of a pulse on the pin; state is HIGH
29
- * or LOW, the type of pulse to measure.  Works on pulses from 2-3 microseconds
30
- * to 3 minutes in length, but must be called at least a few dozen microseconds
31
- * before the start of the pulse. */
32
-unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout)
33
-{
34
-	// cache the port and bit of the pin in order to speed up the
35
-	// pulse width measuring loop and achieve finer resolution.  calling
36
-	// digitalRead() instead yields much coarser resolution.
37
-	uint8_t bit = digitalPinToBitMask(pin);
38
-	uint8_t port = digitalPinToPort(pin);
39
-	uint8_t stateMask = (state ? bit : 0);
40
-	unsigned long width = 0; // keep initialization out of time critical area
41
-	
42
-	// convert the timeout from microseconds to a number of times through
43
-	// the initial loop; it takes 16 clock cycles per iteration.
44
-	unsigned long numloops = 0;
45
-	unsigned long maxloops = microsecondsToClockCycles(timeout) / 16;
46
-	
47
-	// wait for any previous pulse to end
48
-	while ((*portInputRegister(port) & bit) == stateMask)
49
-		if (numloops++ == maxloops)
50
-			return 0;
51
-	
52
-	// wait for the pulse to start
53
-	while ((*portInputRegister(port) & bit) != stateMask)
54
-		if (numloops++ == maxloops)
55
-			return 0;
56
-	
57
-	// wait for the pulse to stop
58
-	while ((*portInputRegister(port) & bit) == stateMask) {
59
-		if (numloops++ == maxloops)
60
-			return 0;
61
-		width++;
62
-	}
63
-
64
-	// convert the reading to microseconds. The loop has been determined
65
-	// to be 20 clock cycles long and have about 16 clocks between the edge
66
-	// and the start of the loop. There will be some error introduced by
67
-	// the interrupt handlers.
68
-	return clockCyclesToMicroseconds(width * 21 + 16); 
69
-}

+ 0
- 55
Marlin/Sanguino/cores/Copy of arduino/wiring_shift.c View File

@@ -1,55 +0,0 @@
1
-/*
2
-  wiring_shift.c - shiftOut() function
3
-  Part of Arduino - http://www.arduino.cc/
4
-
5
-  Copyright (c) 2005-2006 David A. Mellis
6
-
7
-  This library is free software; you can redistribute it and/or
8
-  modify it under the terms of the GNU Lesser General Public
9
-  License as published by the Free Software Foundation; either
10
-  version 2.1 of the License, or (at your option) any later version.
11
-
12
-  This library is distributed in the hope that it will be useful,
13
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
-  Lesser General Public License for more details.
16
-
17
-  You should have received a copy of the GNU Lesser General
18
-  Public License along with this library; if not, write to the
19
-  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20
-  Boston, MA  02111-1307  USA
21
-
22
-  $Id: wiring.c 248 2007-02-03 15:36:30Z mellis $
23
-*/
24
-
25
-#include "wiring_private.h"
26
-
27
-uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder) {
28
-	uint8_t value = 0;
29
-	uint8_t i;
30
-
31
-	for (i = 0; i < 8; ++i) {
32
-		digitalWrite(clockPin, HIGH);
33
-		if (bitOrder == LSBFIRST)
34
-			value |= digitalRead(dataPin) << i;
35
-		else
36
-			value |= digitalRead(dataPin) << (7 - i);
37
-		digitalWrite(clockPin, LOW);
38
-	}
39
-	return value;
40
-}
41
-
42
-void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val)
43
-{
44
-	uint8_t i;
45
-
46
-	for (i = 0; i < 8; i++)  {
47
-		if (bitOrder == LSBFIRST)
48
-			digitalWrite(dataPin, !!(val & (1 << i)));
49
-		else	
50
-			digitalWrite(dataPin, !!(val & (1 << (7 - i))));
51
-			
52
-		digitalWrite(clockPin, HIGH);
53
-		digitalWrite(clockPin, LOW);		
54
-	}
55
-}

+ 13
- 129
Marlin/Sanguino/cores/arduino/HardwareSerial.cpp View File

@@ -37,11 +37,7 @@
37 37
 // using a ring buffer (I think), in which rx_buffer_head is the index of the
38 38
 // location to which to write the next incoming character and rx_buffer_tail
39 39
 // is the index of the location from which to read.
40
-#if (RAMEND < 1000)
41
-  #define RX_BUFFER_SIZE 32
42
-#else
43
-  #define RX_BUFFER_SIZE 128
44
-#endif
40
+#define RX_BUFFER_SIZE 128
45 41
 
46 42
 struct ring_buffer
47 43
 {
@@ -50,22 +46,11 @@ struct ring_buffer
50 46
   int tail;
51 47
 };
52 48
 
53
-#if defined(UBRRH) || defined(UBRR0H)
54
-  ring_buffer rx_buffer  =  { { 0 }, 0, 0 };
55
-#endif
56
-#if defined(UBRR1H)
57
-  ring_buffer rx_buffer1  =  { { 0 }, 0, 0 };
58
-#endif
59
-#if defined(UBRR2H)
60
-  ring_buffer rx_buffer2  =  { { 0 }, 0, 0 };
61
-#endif
62
-#if defined(UBRR3H)
63
-  ring_buffer rx_buffer3  =  { { 0 }, 0, 0 };
64
-#endif
49
+ring_buffer rx_buffer  =  { { 0 }, 0, 0 };
65 50
 
66 51
 inline void store_char(unsigned char c, ring_buffer *rx_buffer)
67 52
 {
68
-  int i = (unsigned int)(rx_buffer->head + 1) % RX_BUFFER_SIZE;
53
+  int i = (unsigned int)(rx_buffer->head + 1) & (RX_BUFFER_SIZE -1);
69 54
 
70 55
   // if we should be storing the received character into the location
71 56
   // just before the tail (meaning that the head would advance to the
@@ -77,95 +62,13 @@ inline void store_char(unsigned char c, ring_buffer *rx_buffer)
77 62
   }
78 63
 }
79 64
 
80
-#if defined(USART_RX_vect)
81
-  SIGNAL(USART_RX_vect)
82
-  {
83
-  #if defined(UDR0)
84
-    unsigned char c  =  UDR0;
85
-  #elif defined(UDR)
86
-    unsigned char c  =  UDR;  //  atmega8535
87
-  #else
88
-    #error UDR not defined
89
-  #endif
90
-    store_char(c, &rx_buffer);
91
-  }
92
-#elif defined(SIG_USART0_RECV) && defined(UDR0)
93
-  SIGNAL(SIG_USART0_RECV)
94
-  {
95
-    unsigned char c  =  UDR0;
96
-    store_char(c, &rx_buffer);
97
-  }
98
-#elif defined(SIG_UART0_RECV) && defined(UDR0)
99
-  SIGNAL(SIG_UART0_RECV)
100
-  {
101
-    unsigned char c  =  UDR0;
102
-    store_char(c, &rx_buffer);
103
-  }
104
-//#elif defined(SIG_USART_RECV)
105
-#elif defined(USART0_RX_vect)
106
-  // fixed by Mark Sproul this is on the 644/644p
107
-  //SIGNAL(SIG_USART_RECV)
108
-  SIGNAL(USART0_RX_vect)
109
-  {
110
-  #if defined(UDR0)
111
-    unsigned char c  =  UDR0;
112
-  #elif defined(UDR)
113
-    unsigned char c  =  UDR;  //  atmega8, atmega32
114
-  #else
115
-    #error UDR not defined
116
-  #endif
117
-    store_char(c, &rx_buffer);
118
-  }
119
-#elif defined(SIG_UART_RECV)
120
-  // this is for atmega8
121
-  SIGNAL(SIG_UART_RECV)
122
-  {
123
-  #if defined(UDR0)
124
-    unsigned char c  =  UDR0;  //  atmega645
125
-  #elif defined(UDR)
126
-    unsigned char c  =  UDR;  //  atmega8
127
-  #endif
128
-    store_char(c, &rx_buffer);
129
-  }
130
-#elif defined(USBCON)
131
-  #warning No interrupt handler for usart 0
132
-  #warning Serial(0) is on USB interface
133
-#else
134
-  #error No interrupt handler for usart 0
135
-#endif
136
-
137
-//#if defined(SIG_USART1_RECV)
138
-#if defined(USART1_RX_vect)
139
-  //SIGNAL(SIG_USART1_RECV)
140
-  SIGNAL(USART1_RX_vect)
141
-  {
142
-    unsigned char c = UDR1;
143
-    store_char(c, &rx_buffer1);
144
-  }
145
-#elif defined(SIG_USART1_RECV)
146
-  #error SIG_USART1_RECV
147
-#endif
148
-
149
-#if defined(USART2_RX_vect) && defined(UDR2)
150
-  SIGNAL(USART2_RX_vect)
151
-  {
152
-    unsigned char c = UDR2;
153
-    store_char(c, &rx_buffer2);
154
-  }
155
-#elif defined(SIG_USART2_RECV)
156
-  #error SIG_USART2_RECV
157
-#endif
158
-
159
-#if defined(USART3_RX_vect) && defined(UDR3)
160
-  SIGNAL(USART3_RX_vect)
161
-  {
162
-    unsigned char c = UDR3;
163
-    store_char(c, &rx_buffer3);
164
-  }
165
-#elif defined(SIG_USART3_RECV)
166
-  #error SIG_USART3_RECV
167
-#endif
168
-
65
+// fixed by Mark Sproul this is on the 644/644p
66
+//SIGNAL(SIG_USART_RECV)
67
+SIGNAL(USART0_RX_vect)
68
+{
69
+  unsigned char c  =  UDR0;
70
+  store_char(c, &rx_buffer);
71
+}
169 72
 
170 73
 
171 74
 // Constructors ////////////////////////////////////////////////////////////////
@@ -231,7 +134,7 @@ void HardwareSerial::end()
231 134
 
232 135
 int HardwareSerial::available(void)
233 136
 {
234
-  return (unsigned int)(RX_BUFFER_SIZE + _rx_buffer->head - _rx_buffer->tail) % RX_BUFFER_SIZE;
137
+  return (unsigned int)(RX_BUFFER_SIZE + _rx_buffer->head - _rx_buffer->tail) & (RX_BUFFER_SIZE-1);
235 138
 }
236 139
 
237 140
 int HardwareSerial::peek(void)
@@ -250,7 +153,7 @@ int HardwareSerial::read(void)
250 153
     return -1;
251 154
   } else {
252 155
     unsigned char c = _rx_buffer->buffer[_rx_buffer->tail];
253
-    _rx_buffer->tail = (unsigned int)(_rx_buffer->tail + 1) % RX_BUFFER_SIZE;
156
+    _rx_buffer->tail = (unsigned int)(_rx_buffer->tail + 1) & (RX_BUFFER_SIZE-1);
254 157
     return c;
255 158
   }
256 159
 }
@@ -278,26 +181,7 @@ void HardwareSerial::write(uint8_t c)
278 181
 }
279 182
 
280 183
 // Preinstantiate Objects //////////////////////////////////////////////////////
281
-
282
-#if defined(UBRRH) && defined(UBRRL)
283
-  HardwareSerial Serial(&rx_buffer, &UBRRH, &UBRRL, &UCSRA, &UCSRB, &UDR, RXEN, TXEN, RXCIE, UDRE, U2X);
284
-#elif defined(UBRR0H) && defined(UBRR0L)
285
-  HardwareSerial Serial(&rx_buffer, &UBRR0H, &UBRR0L, &UCSR0A, &UCSR0B, &UDR0, RXEN0, TXEN0, RXCIE0, UDRE0, U2X0);
286
-#elif defined(USBCON)
287
-  #warning no serial port defined  (port 0)
288
-#else
289
-  #error no serial port defined  (port 0)
290
-#endif
291
-
292
-#if defined(UBRR1H)
293
-  HardwareSerial Serial1(&rx_buffer1, &UBRR1H, &UBRR1L, &UCSR1A, &UCSR1B, &UDR1, RXEN1, TXEN1, RXCIE1, UDRE1, U2X1);
294
-#endif
295
-#if defined(UBRR2H)
296
-  HardwareSerial Serial2(&rx_buffer2, &UBRR2H, &UBRR2L, &UCSR2A, &UCSR2B, &UDR2, RXEN2, TXEN2, RXCIE2, UDRE2, U2X2);
297
-#endif
298
-#if defined(UBRR3H)
299
-  HardwareSerial Serial3(&rx_buffer3, &UBRR3H, &UBRR3L, &UCSR3A, &UCSR3B, &UDR3, RXEN3, TXEN3, RXCIE3, UDRE3, U2X3);
300
-#endif
184
+HardwareSerial Serial(&rx_buffer, &UBRR0H, &UBRR0L, &UCSR0A, &UCSR0B, &UDR0, RXEN0, TXEN0, RXCIE0, UDRE0, U2X0);
301 185
 
302 186
 #endif // whole file
303 187
 

+ 55
- 6
Marlin/temperature.cpp View File

@@ -89,25 +89,50 @@ static unsigned long previous_millis_heater, previous_millis_bed_heater;
89 89
   static unsigned long watchmillis = 0;
90 90
 #endif //WATCHPERIOD
91 91
 
92
+// Init min and max temp with extreme values to prevent false errors during startup
92 93
 #ifdef HEATER_0_MINTEMP
93
-  static int minttemp_0 = temp2analog(HEATER_0_MINTEMP);
94
+  #ifdef HEATER_0_USES_AD595
95
+    static int minttemp_0 = 0;
96
+  #else
97
+    static int minttemp_0 = 16383;
98
+  #endif
94 99
 #endif //MINTEMP
95 100
 #ifdef HEATER_0_MAXTEMP
96
-  static int maxttemp_0 = temp2analog(HEATER_0_MAXTEMP);
101
+  #ifdef HEATER_0_USES_AD595
102
+    static int maxttemp_0 = 0;
103
+  #else
104
+    static int maxttemp_0 = 16383;
105
+  #endif
97 106
 #endif //MAXTEMP
98 107
 
99 108
 #ifdef HEATER_1_MINTEMP
100
-  static int minttemp_1 = temp2analog(HEATER_1_MINTEMP);
109
+  #ifdef HEATER_1_USES_AD595
110
+    static int minttemp_1 = 0;
111
+  #else
112
+    static int minttemp_1 = 16383;
113
+  #endif
101 114
 #endif //MINTEMP
102 115
 #ifdef HEATER_1_MAXTEMP
103
-  static int maxttemp_1 = temp2analog(HEATER_1_MAXTEMP);
116
+  #ifdef HEATER_1_USES_AD595
117
+    static int maxttemp_1 = 0;
118
+  #else
119
+    static int maxttemp_1 = 16383;
120
+  #endif
104 121
 #endif //MAXTEMP
105 122
 
106 123
 #ifdef BED_MINTEMP
107
-  static int bed_minttemp = temp2analog(BED_MINTEMP);
124
+  #ifdef BED_USES_AD595
125
+    static int bed_minttemp = 0;
126
+  #else
127
+    static int bed_minttemp = 16383;
128
+  #endif
108 129
 #endif //BED_MINTEMP
109 130
 #ifdef BED_MAXTEMP
110
-  static int bed_maxttemp = temp2analog(BED_MAXTEMP);
131
+  #ifdef BED_USES_AD595
132
+    static int bed_maxttemp = 0;
133
+  #else
134
+    static int bed_maxttemp = 16383;
135
+  #endif
111 136
 #endif //BED_MAXTEMP
112 137
 
113 138
 //===========================================================================
@@ -350,6 +375,30 @@ void tp_init()
350 375
   // Interleave temperature interrupt with millies interrupt
351 376
   OCR0B = 128;
352 377
   TIMSK0 |= (1<<OCIE0B);  
378
+  
379
+  // Wait for temperature measurement to settle
380
+  delay(500);
381
+
382
+#ifdef HEATER_0_MINTEMP
383
+  minttemp_0 = temp2analog(HEATER_0_MINTEMP);
384
+#endif //MINTEMP
385
+#ifdef HEATER_0_MAXTEMP
386
+  maxttemp_0 = temp2analog(HEATER_0_MAXTEMP);
387
+#endif //MAXTEMP
388
+
389
+#ifdef HEATER_1_MINTEMP
390
+  minttemp_1 = temp2analog(HEATER_1_MINTEMP);
391
+#endif //MINTEMP
392
+#ifdef HEATER_1_MAXTEMP
393
+  maxttemp_1 = temp2analog(HEATER_1_MAXTEMP);
394
+#endif //MAXTEMP
395
+
396
+#ifdef BED_MINTEMP
397
+  bed_minttemp = temp2analog(BED_MINTEMP);
398
+#endif //BED_MINTEMP
399
+#ifdef BED_MAXTEMP
400
+  bed_maxttemp = temp2analog(BED_MAXTEMP);
401
+#endif //BED_MAXTEMP
353 402
 }
354 403
 
355 404
 

Loading…
Cancel
Save