Skip to content

Commit 7d45733

Browse files
committed
Merge branch 'master' of github.com:espressif/arduino-esp32
2 parents 5395e16 + 7d78247 commit 7d45733

File tree

157 files changed

+2275
-1971
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

157 files changed

+2275
-1971
lines changed

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,3 +209,8 @@ set(COMPONENT_REQUIRES spi_flash mbedtls mdns ethernet)
209209
set(COMPONENT_PRIV_REQUIRES fatfs nvs_flash app_update spiffs bootloader_support openssl bt)
210210

211211
register_component()
212+
213+
set_source_files_properties(libraries/AzureIoT/src/az_iot/iothub_client/src/iothubtransport_mqtt_common.c
214+
PROPERTIES COMPILE_FLAGS
215+
-Wno-maybe-uninitialized
216+
)

boards.txt

Lines changed: 492 additions & 4 deletions
Large diffs are not rendered by default.

cores/esp32/Arduino.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,6 @@
6868
#define __STRINGIFY(a) #a
6969
#endif
7070

71-
// undefine stdlib's abs if encountered
72-
#ifdef abs
73-
#undef abs
74-
#endif
75-
76-
#define abs(x) ((x)>0?(x):-(x))
7771
#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
7872
#define radians(deg) ((deg)*DEG_TO_RAD)
7973
#define degrees(rad) ((rad)*RAD_TO_DEG)
@@ -160,6 +154,7 @@ void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val);
160154
#include "HardwareSerial.h"
161155
#include "Esp.h"
162156

157+
using std::abs;
163158
using std::isinf;
164159
using std::isnan;
165160
using std::max;

cores/esp32/Stream.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ class Stream: public Print
9797

9898
float parseFloat(); // float version of parseInt
9999

100-
size_t readBytes(char *buffer, size_t length); // read chars from stream into buffer
101-
size_t readBytes(uint8_t *buffer, size_t length)
100+
virtual size_t readBytes(char *buffer, size_t length); // read chars from stream into buffer
101+
virtual size_t readBytes(uint8_t *buffer, size_t length)
102102
{
103103
return readBytes((char *) buffer, length);
104104
}
@@ -114,7 +114,7 @@ class Stream: public Print
114114
// returns the number of characters placed in the buffer (0 means no valid data found)
115115

116116
// Arduino String functions to be added here
117-
String readString();
117+
virtual String readString();
118118
String readStringUntil(char terminator);
119119

120120
protected:

cores/esp32/StreamString.cpp

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
StreamString.cpp
33
44
Copyright (c) 2015 Markus Sattler. All rights reserved.
5+
This file is part of the esp8266 core for Arduino environment.
56
67
This library is free software; you can redistribute it and/or
78
modify it under the terms of the GNU Lesser General Public
@@ -22,31 +23,28 @@
2223
#include <Arduino.h>
2324
#include "StreamString.h"
2425

25-
size_t StreamString::write(const uint8_t *data, size_t size)
26-
{
26+
size_t StreamString::write(const uint8_t *data, size_t size) {
2727
if(size && data) {
28-
if(reserve(length() + size + 1)) {
29-
memcpy((void *) (buffer + len), (const void *) data, size);
30-
len += size;
31-
*(buffer + len) = 0x00; // add null for string end
28+
const unsigned int newlen = length() + size;
29+
if(reserve(newlen + 1)) {
30+
memcpy((void *) (wbuffer() + len()), (const void *) data, size);
31+
setLen(newlen);
32+
*(wbuffer() + newlen) = 0x00; // add null for string end
3233
return size;
3334
}
3435
}
3536
return 0;
3637
}
3738

38-
size_t StreamString::write(uint8_t data)
39-
{
39+
size_t StreamString::write(uint8_t data) {
4040
return concat((char) data);
4141
}
4242

43-
int StreamString::available()
44-
{
43+
int StreamString::available() {
4544
return length();
4645
}
4746

48-
int StreamString::read()
49-
{
47+
int StreamString::read() {
5048
if(length()) {
5149
char c = charAt(0);
5250
remove(0, 1);
@@ -56,16 +54,14 @@ int StreamString::read()
5654
return -1;
5755
}
5856

59-
int StreamString::peek()
60-
{
57+
int StreamString::peek() {
6158
if(length()) {
6259
char c = charAt(0);
6360
return c;
6461
}
6562
return -1;
6663
}
6764

68-
void StreamString::flush()
69-
{
65+
void StreamString::flush() {
7066
}
7167

cores/esp32/WMath.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,12 @@ long random(long howsmall, long howbig)
6565
return random(diff) + howsmall;
6666
}
6767

68-
long map(long x, long in_min, long in_max, long out_min, long out_max)
69-
{
70-
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
68+
long map(long x, long in_min, long in_max, long out_min, long out_max) {
69+
long divisor = (in_max - in_min);
70+
if(divisor == 0){
71+
return -1; //AVR returns -1, SAM returns 0
72+
}
73+
return (x - in_min) * (out_max - out_min) / divisor + out_min;
7174
}
7275

7376
unsigned int makeWord(unsigned int w)

0 commit comments

Comments
 (0)