Skip to content

Commit b674be7

Browse files
committed
Merge branch 'master' into core-ble
2 parents 9c67510 + 6516289 commit b674be7

File tree

10 files changed

+323
-6
lines changed

10 files changed

+323
-6
lines changed

cores/arduino/ard_sup/Arduino.h

+2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ extern "C"
4141
#include "am_util.h"
4242
// #include "am_bsp.h"
4343

44+
#include "hooks.h"
45+
4446
#include <math.h> //Gets us pow()
4547

4648
#ifdef ARDUINO_REDEFINE_OVERFLOW
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
/*
2+
IPAddress.cpp - Base class that provides IPAddress
3+
Copyright (c) 2011 Adrian McEwen. 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+
#include <Arduino.h>
21+
#include <IPAddress.h>
22+
23+
IPAddress::IPAddress()
24+
{
25+
_address.dword = 0;
26+
}
27+
28+
IPAddress::IPAddress(uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet)
29+
{
30+
_address.bytes[0] = first_octet;
31+
_address.bytes[1] = second_octet;
32+
_address.bytes[2] = third_octet;
33+
_address.bytes[3] = fourth_octet;
34+
}
35+
36+
IPAddress::IPAddress(uint32_t address)
37+
{
38+
_address.dword = address;
39+
}
40+
41+
IPAddress::IPAddress(const uint8_t *address)
42+
{
43+
memcpy(_address.bytes, address, sizeof(_address.bytes));
44+
}
45+
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+
88+
IPAddress& IPAddress::operator=(const uint8_t *address)
89+
{
90+
memcpy(_address.bytes, address, sizeof(_address.bytes));
91+
return *this;
92+
}
93+
94+
IPAddress& IPAddress::operator=(uint32_t address)
95+
{
96+
_address.dword = address;
97+
return *this;
98+
}
99+
100+
bool IPAddress::operator==(const uint8_t* addr) const
101+
{
102+
return memcmp(addr, _address.bytes, sizeof(_address.bytes)) == 0;
103+
}
104+
105+
size_t IPAddress::printTo(Print& p) const
106+
{
107+
size_t n = 0;
108+
for (int i =0; i < 3; i++)
109+
{
110+
n += p.print(_address.bytes[i], DEC);
111+
n += p.print('.');
112+
}
113+
n += p.print(_address.bytes[3], DEC);
114+
return n;
115+
}
116+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/*
2+
IPAddress.h - Base class that provides IPAddress
3+
Copyright (c) 2011 Adrian McEwen. 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 IPAddress_h
21+
#define IPAddress_h
22+
23+
#include <stdint.h>
24+
#include "Printable.h"
25+
#include "WString.h"
26+
27+
// A class to make it easier to handle and pass around IP addresses
28+
29+
class IPAddress : public Printable {
30+
private:
31+
union {
32+
uint8_t bytes[4]; // IPv4 address
33+
uint32_t dword;
34+
} _address;
35+
36+
// Access the raw byte array containing the address. Because this returns a pointer
37+
// to the internal structure rather than a copy of the address this function should only
38+
// be used when you know that the usage of the returned uint8_t* will be transient and not
39+
// stored.
40+
uint8_t* raw_address() { return _address.bytes; };
41+
42+
public:
43+
// Constructors
44+
IPAddress();
45+
IPAddress(uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet);
46+
IPAddress(uint32_t address);
47+
IPAddress(const uint8_t *address);
48+
49+
bool fromString(const char *address);
50+
bool fromString(const String &address) { return fromString(address.c_str()); }
51+
52+
// Overloaded cast operator to allow IPAddress objects to be used where a pointer
53+
// to a four-byte uint8_t array is expected
54+
operator uint32_t() const { return _address.dword; };
55+
bool operator==(const IPAddress& addr) const { return _address.dword == addr._address.dword; };
56+
bool operator==(const uint8_t* addr) const;
57+
58+
// Overloaded index operator to allow getting and setting individual octets of the address
59+
uint8_t operator[](int index) const { return _address.bytes[index]; };
60+
uint8_t& operator[](int index) { return _address.bytes[index]; };
61+
62+
// Overloaded copy operators to allow initialisation of IPAddress objects from other types
63+
IPAddress& operator=(const uint8_t *address);
64+
IPAddress& operator=(uint32_t address);
65+
66+
virtual size_t printTo(Print& p) const;
67+
68+
friend class EthernetClass;
69+
friend class UDP;
70+
friend class Client;
71+
friend class Server;
72+
friend class DhcpClass;
73+
friend class DNSClient;
74+
};
75+
76+
const IPAddress INADDR_NONE(0,0,0,0);
77+
78+
#endif
+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
Copyright (c) 2019 SparkFun Electronics
3+
4+
Permission is hereby granted, free of charge, to any person obtaining a copy
5+
of this software and associated documentation files (the "Software"), to deal
6+
in the Software without restriction, including without limitation the rights
7+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
copies of the Software, and to permit persons to whom the Software is
9+
furnished to do so, subject to the following conditions:
10+
11+
The above copyright notice and this permission notice shall be included in all
12+
copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
SOFTWARE.
21+
*/
22+
23+
#include "hooks.h"
24+
25+
/**
26+
* Empty yield() hook.
27+
*
28+
* This function is intended to be used by library writers to build
29+
* libraries or sketches that supports cooperative threads.
30+
*
31+
* Its defined as a weak symbol and it can be redefined to implement a
32+
* real cooperative scheduler.
33+
*/
34+
static void __empty() {
35+
// Empty
36+
}
37+
void yield(void) __attribute__ ((weak, alias("__empty")));
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
Copyright (c) 2019 SparkFun Electronics
3+
4+
Permission is hereby granted, free of charge, to any person obtaining a copy
5+
of this software and associated documentation files (the "Software"), to deal
6+
in the Software without restriction, including without limitation the rights
7+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
copies of the Software, and to permit persons to whom the Software is
9+
furnished to do so, subject to the following conditions:
10+
11+
The above copyright notice and this permission notice shall be included in all
12+
copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
SOFTWARE.
21+
*/
22+
#ifndef _HOOKS_H_
23+
#define _HOOKS_H_
24+
25+
void yield( void ) ;
26+
27+
#endif // _HOOKS_H_
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
Copyright (c) 2019 SparkFun Electronics
3+
4+
Permission is hereby granted, free of charge, to any person obtaining a copy
5+
of this software and associated documentation files (the "Software"), to deal
6+
in the Software without restriction, including without limitation the rights
7+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
copies of the Software, and to permit persons to whom the Software is
9+
furnished to do so, subject to the following conditions:
10+
11+
The above copyright notice and this permission notice shall be included in all
12+
copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
SOFTWARE.
21+
*/
22+
#ifndef _PINS_ARDUINO_H_
23+
#define _PINS_ARDUINO_H_
24+
25+
// This file exists solely for compilation compatibility with legacy libraries
26+
27+
#endif // _PINS_ARDUINO_H_
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
Copyright (c) 2019 SparkFun Electronics
3+
4+
Permission is hereby granted, free of charge, to any person obtaining a copy
5+
of this software and associated documentation files (the "Software"), to deal
6+
in the Software without restriction, including without limitation the rights
7+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
copies of the Software, and to permit persons to whom the Software is
9+
furnished to do so, subject to the following conditions:
10+
11+
The above copyright notice and this permission notice shall be included in all
12+
copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
SOFTWARE.
21+
*/
22+
#ifndef _WIRING_PRIVATE_H_
23+
#define _WIRING_PRIVATE_H_
24+
25+
// This file exists solely for compilation compatibility with legacy libraries
26+
27+
#endif // _WIRING_PRIVATE_H_

docs/CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ This is a record of the major changes between versions of the SparkFun Arduino A
55

66
Each log entry will use the version number of the release that contains the changes listed. Newest version at the top of the file (just below this line)
77

8+
1.0.12
9+
===================
10+
- fixed redefinition of ADC symbols in redboard_artemis_nano
11+
- added empty pins_arduino.h for compile-compatibility iwht older libraries
12+
- added standard IPAddress library
13+
- changed SoftwareSerial to inherit from Stream instead of Print
14+
815
1.0.8
916
===================
1017
- Wire library requestFrom address bug fix (previously required address to be set with 'beginTransmission')

libraries/SoftwareSerial/src/SoftwareSerial.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,13 @@
3838
#ifndef _SoftwareSerial_H
3939
#define _SoftwareSerial_H
4040
#include "Arduino.h"
41+
#include <Stream.h>
4142

4243
#define AP3_SS_BUFFER_SIZE 128 //Limit to 8 bits
4344

4445
#define TIMER_FREQ 3000000L
4546

46-
class SoftwareSerial : public Print
47+
class SoftwareSerial : public Stream
4748
{
4849
public:
4950
SoftwareSerial(uint8_t rxPin, uint8_t txPin, bool invertLogic = false);

variants/SparkFun_RedBoard_Artemis_Nano/config/variant.h

-5
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,6 @@ extern Uart Serial1;
5555
#define A14 14
5656
#define A15 15
5757
#define A16 16
58-
#define ADC_DIFF0 32 //Not legal pins. Used for pad lookup
59-
#define ADC_DIFF1 33
60-
#define ADC_TEMP 34
61-
#define ADC_DIV3 35
62-
#define ADC_VSS 36
6358

6459
#define LED_BUILTIN 19
6560

0 commit comments

Comments
 (0)