Skip to content

Commit e2de88c

Browse files
author
Federico Fissore
committed
Merge branch 'ide-1.5.x' into ide-1.5.x-avr-toolchain-gcc-4.8.1
2 parents fd0793e + f864cdc commit e2de88c

File tree

19 files changed

+123
-82
lines changed

19 files changed

+123
-82
lines changed

Diff for: hardware/arduino/avr/cores/arduino/Arduino.h

+1-3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#define Arduino_h
2222

2323
#include <stdlib.h>
24+
#include <stdbool.h>
2425
#include <string.h>
2526
#include <math.h>
2627

@@ -43,9 +44,6 @@ void yield(void);
4344
#define OUTPUT 0x1
4445
#define INPUT_PULLUP 0x2
4546

46-
#define true 0x1
47-
#define false 0x0
48-
4947
#define PI 3.1415926535897932384626433832795
5048
#define HALF_PI 1.5707963267948966192313216916398
5149
#define TWO_PI 6.283185307179586476925286766559

Diff for: hardware/arduino/avr/cores/arduino/CDC.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,11 @@ bool WEAK CDC_Setup(Setup& setup)
115115

116116

117117
int _serialPeek = -1;
118-
void Serial_::begin(unsigned long baud_count)
118+
void Serial_::begin(unsigned long /* baud_count */)
119119
{
120120
}
121121

122-
void Serial_::begin(unsigned long baud_count, byte config)
122+
void Serial_::begin(unsigned long /* baud_count */, byte /* config */)
123123
{
124124
}
125125

Diff for: hardware/arduino/avr/cores/arduino/HID.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ int WEAK HID_GetInterface(u8* interfaceNum)
151151
return USB_SendControl(TRANSFER_PGM,&_hidInterface,sizeof(_hidInterface));
152152
}
153153

154-
int WEAK HID_GetDescriptor(int i)
154+
int WEAK HID_GetDescriptor(int /* i */)
155155
{
156156
return USB_SendControl(TRANSFER_PGM,_hidReportDescriptor,sizeof(_hidReportDescriptor));
157157
}
@@ -510,11 +510,11 @@ void Keyboard_::releaseAll(void)
510510

511511
size_t Keyboard_::write(uint8_t c)
512512
{
513-
uint8_t p = press(c); // Keydown
514-
uint8_t r = release(c); // Keyup
515-
return (p); // just return the result of press() since release() almost always returns 1
513+
uint8_t p = press(c); // Keydown
514+
release(c); // Keyup
515+
return p; // just return the result of press() since release() almost always returns 1
516516
}
517517

518518
#endif
519519

520-
#endif /* if defined(USBCON) */
520+
#endif /* if defined(USBCON) */

Diff for: hardware/arduino/avr/cores/arduino/IPAddress.cpp

+12-12
Original file line numberDiff line numberDiff line change
@@ -22,53 +22,53 @@
2222

2323
IPAddress::IPAddress()
2424
{
25-
memset(_address, 0, sizeof(_address));
25+
_address.dword = 0;
2626
}
2727

2828
IPAddress::IPAddress(uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet)
2929
{
30-
_address[0] = first_octet;
31-
_address[1] = second_octet;
32-
_address[2] = third_octet;
33-
_address[3] = fourth_octet;
30+
_address.bytes[0] = first_octet;
31+
_address.bytes[1] = second_octet;
32+
_address.bytes[2] = third_octet;
33+
_address.bytes[3] = fourth_octet;
3434
}
3535

3636
IPAddress::IPAddress(uint32_t address)
3737
{
38-
memcpy(_address, &address, sizeof(_address));
38+
_address.dword = address;
3939
}
4040

4141
IPAddress::IPAddress(const uint8_t *address)
4242
{
43-
memcpy(_address, address, sizeof(_address));
43+
memcpy(_address.bytes, address, sizeof(_address.bytes));
4444
}
4545

4646
IPAddress& IPAddress::operator=(const uint8_t *address)
4747
{
48-
memcpy(_address, address, sizeof(_address));
48+
memcpy(_address.bytes, address, sizeof(_address.bytes));
4949
return *this;
5050
}
5151

5252
IPAddress& IPAddress::operator=(uint32_t address)
5353
{
54-
memcpy(_address, (const uint8_t *)&address, sizeof(_address));
54+
_address.dword = address;
5555
return *this;
5656
}
5757

5858
bool IPAddress::operator==(const uint8_t* addr) const
5959
{
60-
return memcmp(addr, _address, sizeof(_address)) == 0;
60+
return memcmp(addr, _address.bytes, sizeof(_address.bytes)) == 0;
6161
}
6262

6363
size_t IPAddress::printTo(Print& p) const
6464
{
6565
size_t n = 0;
6666
for (int i =0; i < 3; i++)
6767
{
68-
n += p.print(_address[i], DEC);
68+
n += p.print(_address.bytes[i], DEC);
6969
n += p.print('.');
7070
}
71-
n += p.print(_address[3], DEC);
71+
n += p.print(_address.bytes[3], DEC);
7272
return n;
7373
}
7474

Diff for: hardware/arduino/avr/cores/arduino/IPAddress.h

+10-6
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,16 @@
2727

2828
class IPAddress : public Printable {
2929
private:
30-
uint8_t _address[4]; // IPv4 address
30+
union {
31+
uint8_t bytes[4]; // IPv4 address
32+
uint32_t dword;
33+
} _address;
34+
3135
// Access the raw byte array containing the address. Because this returns a pointer
3236
// to the internal structure rather than a copy of the address this function should only
3337
// be used when you know that the usage of the returned uint8_t* will be transient and not
3438
// stored.
35-
uint8_t* raw_address() { return _address; };
39+
uint8_t* raw_address() { return _address.bytes; };
3640

3741
public:
3842
// Constructors
@@ -43,13 +47,13 @@ class IPAddress : public Printable {
4347

4448
// Overloaded cast operator to allow IPAddress objects to be used where a pointer
4549
// to a four-byte uint8_t array is expected
46-
operator uint32_t() const { return *((uint32_t*)_address); };
47-
bool operator==(const IPAddress& addr) const { return (*((uint32_t*)_address)) == (*((uint32_t*)addr._address)); };
50+
operator uint32_t() const { return _address.dword; };
51+
bool operator==(const IPAddress& addr) const { return _address.dword == addr._address.dword; };
4852
bool operator==(const uint8_t* addr) const;
4953

5054
// Overloaded index operator to allow getting and setting individual octets of the address
51-
uint8_t operator[](int index) const { return _address[index]; };
52-
uint8_t& operator[](int index) { return _address[index]; };
55+
uint8_t operator[](int index) const { return _address.bytes[index]; };
56+
uint8_t& operator[](int index) { return _address.bytes[index]; };
5357

5458
// Overloaded copy operators to allow initialisation of IPAddress objects from other types
5559
IPAddress& operator=(const uint8_t *address);

Diff for: hardware/arduino/avr/cores/arduino/Stream.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ float Stream::parseFloat(char skipChar){
176176
boolean isNegative = false;
177177
boolean isFraction = false;
178178
long value = 0;
179-
char c;
179+
int c;
180180
float fraction = 1.0;
181181

182182
c = peekNextDigit();

Diff for: hardware/arduino/avr/cores/arduino/USBCore.cpp

+11-5
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,18 @@ const u16 STRING_LANGUAGE[2] = {
5757
const u8 STRING_PRODUCT[] PROGMEM = USB_PRODUCT;
5858

5959
#if USB_VID == 0x2341
60-
#define USB_MANUFACTURER "Arduino LLC"
60+
# if defined(USB_MANUFACTURER)
61+
# undef USB_MANUFACTURER
62+
# endif
63+
# define USB_MANUFACTURER "Arduino LLC"
6164
#elif USB_VID == 0x1b4f
62-
#define USB_MANUFACTURER "SparkFun"
65+
# if defined(USB_MANUFACTURER)
66+
# undef USB_MANUFACTURER
67+
# endif
68+
# define USB_MANUFACTURER "SparkFun"
6369
#elif !defined(USB_MANUFACTURER)
6470
// Fall through to unknown if no manufacturer name was provided in a macro
65-
#define USB_MANUFACTURER "Unknown"
71+
# define USB_MANUFACTURER "Unknown"
6672
#endif
6773

6874
const u8 STRING_MANUFACTURER[] PROGMEM = USB_MANUFACTURER;
@@ -88,7 +94,8 @@ volatile u8 _usbConfiguration = 0;
8894

8995
static inline void WaitIN(void)
9096
{
91-
while (!(UEINTX & (1<<TXINI)));
97+
while (!(UEINTX & (1<<TXINI)))
98+
;
9299
}
93100

94101
static inline void ClearIN(void)
@@ -268,7 +275,6 @@ int USB_Send(u8 ep, const void* d, int len)
268275

269276
int r = len;
270277
const u8* data = (const u8*)d;
271-
u8 zero = ep & TRANSFER_ZERO;
272278
u8 timeout = 250; // 250ms timeout on send? TODO
273279
while (len)
274280
{

Diff for: hardware/arduino/sam/cores/arduino/IPAddress.cpp

+12-12
Original file line numberDiff line numberDiff line change
@@ -22,53 +22,53 @@
2222

2323
IPAddress::IPAddress()
2424
{
25-
memset(_address, 0, sizeof(_address));
25+
_address.dword = 0;
2626
}
2727

2828
IPAddress::IPAddress(uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet)
2929
{
30-
_address[0] = first_octet;
31-
_address[1] = second_octet;
32-
_address[2] = third_octet;
33-
_address[3] = fourth_octet;
30+
_address.bytes[0] = first_octet;
31+
_address.bytes[1] = second_octet;
32+
_address.bytes[2] = third_octet;
33+
_address.bytes[3] = fourth_octet;
3434
}
3535

3636
IPAddress::IPAddress(uint32_t address)
3737
{
38-
memcpy(_address, &address, sizeof(_address));
38+
_address.dword = address;
3939
}
4040

4141
IPAddress::IPAddress(const uint8_t *address)
4242
{
43-
memcpy(_address, address, sizeof(_address));
43+
memcpy(_address.bytes, address, sizeof(_address.bytes));
4444
}
4545

4646
IPAddress& IPAddress::operator=(const uint8_t *address)
4747
{
48-
memcpy(_address, address, sizeof(_address));
48+
memcpy(_address.bytes, address, sizeof(_address.bytes));
4949
return *this;
5050
}
5151

5252
IPAddress& IPAddress::operator=(uint32_t address)
5353
{
54-
memcpy(_address, (const uint8_t *)&address, sizeof(_address));
54+
_address.dword = address;
5555
return *this;
5656
}
5757

5858
bool IPAddress::operator==(const uint8_t* addr) const
5959
{
60-
return memcmp(addr, _address, sizeof(_address)) == 0;
60+
return memcmp(addr, _address.bytes, sizeof(_address.bytes)) == 0;
6161
}
6262

6363
size_t IPAddress::printTo(Print& p) const
6464
{
6565
size_t n = 0;
6666
for (int i =0; i < 3; i++)
6767
{
68-
n += p.print(_address[i], DEC);
68+
n += p.print(_address.bytes[i], DEC);
6969
n += p.print('.');
7070
}
71-
n += p.print(_address[3], DEC);
71+
n += p.print(_address.bytes[3], DEC);
7272
return n;
7373
}
7474

Diff for: hardware/arduino/sam/cores/arduino/IPAddress.h

+11-6
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,23 @@
2020
#ifndef IPAddress_h
2121
#define IPAddress_h
2222

23+
#include <stdint.h>
2324
#include <Printable.h>
2425

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

2728
class IPAddress : public Printable {
2829
private:
29-
uint8_t _address[4]; // IPv4 address
30+
union {
31+
uint8_t bytes[4]; // IPv4 address
32+
uint32_t dword;
33+
} _address;
34+
3035
// Access the raw byte array containing the address. Because this returns a pointer
3136
// to the internal structure rather than a copy of the address this function should only
3237
// be used when you know that the usage of the returned uint8_t* will be transient and not
3338
// stored.
34-
uint8_t* raw_address() { return _address; };
39+
uint8_t* raw_address() { return _address.bytes; };
3540

3641
public:
3742
// Constructors
@@ -42,13 +47,13 @@ class IPAddress : public Printable {
4247

4348
// Overloaded cast operator to allow IPAddress objects to be used where a pointer
4449
// to a four-byte uint8_t array is expected
45-
operator uint32_t() const { return *((uint32_t*)_address); };
46-
bool operator==(const IPAddress& addr) const { return (*((uint32_t*)_address)) == (*((uint32_t*)addr._address)); };
50+
operator uint32_t() const { return _address.dword; };
51+
bool operator==(const IPAddress& addr) const { return _address.dword == addr._address.dword; };
4752
bool operator==(const uint8_t* addr) const;
4853

4954
// Overloaded index operator to allow getting and setting individual octets of the address
50-
uint8_t operator[](int index) const { return _address[index]; };
51-
uint8_t& operator[](int index) { return _address[index]; };
55+
uint8_t operator[](int index) const { return _address.bytes[index]; };
56+
uint8_t& operator[](int index) { return _address.bytes[index]; };
5257

5358
// Overloaded copy operators to allow initialisation of IPAddress objects from other types
5459
IPAddress& operator=(const uint8_t *address);

Diff for: hardware/arduino/sam/cores/arduino/Stream.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ float Stream::parseFloat(char skipChar){
176176
boolean isNegative = false;
177177
boolean isFraction = false;
178178
long value = 0;
179-
char c;
179+
int c;
180180
float fraction = 1.0;
181181

182182
c = peekNextDigit();

Diff for: hardware/arduino/sam/cores/arduino/USB/CDC.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,15 @@ bool WEAK CDC_Setup(Setup& setup)
147147
int _serialPeek = -1;
148148
void Serial_::begin(uint32_t baud_count)
149149
{
150+
// suppress "unused parameter" warning
151+
(void)baud_count;
150152
}
151153

152154
void Serial_::begin(uint32_t baud_count, uint8_t config)
153155
{
156+
// suppress "unused parameter" warning
157+
(void)baud_count;
158+
(void)config;
154159
}
155160

156161
void Serial_::end(void)

Diff for: hardware/arduino/sam/cores/arduino/USB/USBCore.cpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,13 @@ const uint16_t STRING_LANGUAGE[2] = {
6969
const uint8_t STRING_PRODUCT[] = USB_PRODUCT;
7070

7171
#if USB_VID == 0x2341
72-
#define USB_MANUFACTURER "Arduino LLC"
72+
# if defined(USB_MANUFACTURER)
73+
# undef USB_MANUFACTURER
74+
# endif
75+
# define USB_MANUFACTURER "Arduino LLC"
7376
#elif !defined(USB_MANUFACTURER)
7477
// Fall through to unknown if no manufacturer name was provided in a macro
75-
#define USB_MANUFACTURER "Unknown"
78+
# define USB_MANUFACTURER "Unknown"
7679
#endif
7780

7881
const uint8_t STRING_MANUFACTURER[12] = USB_MANUFACTURER;
@@ -139,7 +142,7 @@ uint32_t USBD_Available(uint32_t ep)
139142
// Return number of bytes read
140143
uint32_t USBD_Recv(uint32_t ep, void* d, uint32_t len)
141144
{
142-
if (!_usbConfiguration || len < 0)
145+
if (!_usbConfiguration)
143146
return -1;
144147

145148
LockEP lock(ep);

Diff for: hardware/arduino/sam/cores/arduino/avr/dtostrf.c

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1919
*/
2020

21+
#include <stdio.h>
22+
2123
char *dtostrf (double val, signed char width, unsigned char prec, char *sout) {
2224
char fmt[20];
2325
sprintf(fmt, "%%%d.%df", width, prec);

0 commit comments

Comments
 (0)