Skip to content

Commit feca2d4

Browse files
committed
updated Arduino core to 1.6.6
1 parent 1773333 commit feca2d4

23 files changed

+756
-764
lines changed

1.0.2/cores/arduino/Arduino.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,8 @@ extern const PinDescription g_APinDescription[] ;
194194
#include "wiring_shift.h"
195195
#include "WInterrupts.h"
196196

197+
#include "watchdog.h"
198+
197199
// USB Device
198200
#define USB_VID 0x2341 // arduino LLC vid
199201
#define USB_PID_LEONARDO 0x0034

1.0.2/cores/arduino/IPAddress.cpp

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,48 @@ IPAddress::IPAddress(const uint8_t *address)
4343
memcpy(_address.bytes, address, sizeof(_address.bytes));
4444
}
4545

46+
bool IPAddress::fromString(const char *address)
47+
{
48+
// TODO: add support for "a", "a.b", "a.b.c" formats
49+
50+
uint16_t acc = 0; // Accumulator
51+
uint8_t dots = 0;
52+
53+
while (*address)
54+
{
55+
char c = *address++;
56+
if (c >= '0' && c <= '9')
57+
{
58+
acc = acc * 10 + (c - '0');
59+
if (acc > 255) {
60+
// Value out of [0..255] range
61+
return false;
62+
}
63+
}
64+
else if (c == '.')
65+
{
66+
if (dots == 3) {
67+
// Too much dots (there must be 3 dots)
68+
return false;
69+
}
70+
_address.bytes[dots++] = acc;
71+
acc = 0;
72+
}
73+
else
74+
{
75+
// Invalid char
76+
return false;
77+
}
78+
}
79+
80+
if (dots != 3) {
81+
// Too few dots (there must be 3 dots)
82+
return false;
83+
}
84+
_address.bytes[3] = acc;
85+
return true;
86+
}
87+
4688
IPAddress& IPAddress::operator=(const uint8_t *address)
4789
{
4890
memcpy(_address.bytes, address, sizeof(_address.bytes));

1.0.2/cores/arduino/IPAddress.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
#define IPAddress_h
2222

2323
#include <stdint.h>
24-
#include <Printable.h>
24+
#include "Printable.h"
25+
#include "WString.h"
2526

2627
// A class to make it easier to handle and pass around IP addresses
2728

@@ -45,6 +46,9 @@ class IPAddress : public Printable {
4546
IPAddress(uint32_t address);
4647
IPAddress(const uint8_t *address);
4748

49+
bool fromString(const char *address);
50+
bool fromString(const String &address) { return fromString(address.c_str()); }
51+
4852
// Overloaded cast operator to allow IPAddress objects to be used where a pointer
4953
// to a four-byte uint8_t array is expected
5054
operator uint32_t() const { return _address.dword; };
@@ -71,5 +75,4 @@ class IPAddress : public Printable {
7175

7276
const IPAddress INADDR_NONE(0,0,0,0);
7377

74-
7578
#endif

1.0.2/cores/arduino/Print.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1818
1919
Modified 23 November 2006 by David A. Mellis
20+
Modified 03 August 2015 by Chuck Todd
2021
*/
2122

2223
#include <stdlib.h>
@@ -34,7 +35,8 @@ size_t Print::write(const uint8_t *buffer, size_t size)
3435
{
3536
size_t n = 0;
3637
while (size--) {
37-
n += write(*buffer++);
38+
if (write(*buffer++)) n++;
39+
else break;
3840
}
3941
return n;
4042
}
@@ -115,9 +117,7 @@ size_t Print::print(const Printable& x)
115117

116118
size_t Print::println(void)
117119
{
118-
size_t n = print('\r');
119-
n += print('\n');
120-
return n;
120+
return write("\r\n");
121121
}
122122

123123
size_t Print::println(const String &s)

1.0.2/cores/arduino/USB/CDC.cpp

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "Arduino.h"
1818
#include "USBAPI.h"
1919
#include "Reset.h"
20+
#include "Print.h"
2021

2122
#ifdef CDC_ENABLED
2223

@@ -103,7 +104,7 @@ int WEAK CDC_GetOtherInterface(uint8_t* interfaceNum)
103104
return USBD_SendControl(0,&_cdcOtherInterface,sizeof(_cdcOtherInterface));
104105
}
105106

106-
bool WEAK CDC_Setup(Setup& setup)
107+
bool WEAK CDC_Setup(USBSetup& setup)
107108
{
108109
uint8_t r = setup.bRequest;
109110
uint8_t requestType = setup.bmRequestType;
@@ -299,6 +300,30 @@ Serial_::operator bool()
299300
return result;
300301
}
301302

303+
unsigned long Serial_::baud() {
304+
return _usbLineInfo.dwDTERate;
305+
}
306+
307+
uint8_t Serial_::stopbits() {
308+
return _usbLineInfo.bCharFormat;
309+
}
310+
311+
uint8_t Serial_::paritytype() {
312+
return _usbLineInfo.bParityType;
313+
}
314+
315+
uint8_t Serial_::numbits() {
316+
return _usbLineInfo.bDataBits;
317+
}
318+
319+
bool Serial_::dtr() {
320+
return _usbLineInfo.lineState & 0x1;
321+
}
322+
323+
bool Serial_::rts() {
324+
return _usbLineInfo.lineState & 0x2;
325+
}
326+
302327
Serial_ SerialUSB;
303328

304329
#endif

0 commit comments

Comments
 (0)