Skip to content

Commit c2ea624

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 4b7fdcc + 80c110e commit c2ea624

File tree

5 files changed

+82
-17
lines changed

5 files changed

+82
-17
lines changed

cores/esp32/Esp.cpp

+40-1
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,48 @@ void EspClass::restart(void)
112112
esp_restart();
113113
}
114114

115+
uint32_t EspClass::getHeapSize(void)
116+
{
117+
multi_heap_info_t info;
118+
heap_caps_get_info(&info, MALLOC_CAP_INTERNAL);
119+
return info.total_free_bytes + info.total_allocated_bytes;
120+
}
121+
115122
uint32_t EspClass::getFreeHeap(void)
116123
{
117-
return esp_get_free_heap_size();
124+
return heap_caps_get_free_size(MALLOC_CAP_INTERNAL);
125+
}
126+
127+
uint32_t EspClass::getMinFreeHeap(void)
128+
{
129+
return heap_caps_get_minimum_free_size(MALLOC_CAP_INTERNAL);
130+
}
131+
132+
uint32_t EspClass::getMaxAllocHeap(void)
133+
{
134+
return heap_caps_get_largest_free_block(MALLOC_CAP_INTERNAL);
135+
}
136+
137+
uint32_t EspClass::getPsramSize(void)
138+
{
139+
multi_heap_info_t info;
140+
heap_caps_get_info(&info, MALLOC_CAP_SPIRAM);
141+
return info.total_free_bytes + info.total_allocated_bytes;
142+
}
143+
144+
uint32_t EspClass::getFreePsram(void)
145+
{
146+
return heap_caps_get_free_size(MALLOC_CAP_SPIRAM);
147+
}
148+
149+
uint32_t EspClass::getMinFreePsram(void)
150+
{
151+
return heap_caps_get_minimum_free_size(MALLOC_CAP_SPIRAM);
152+
}
153+
154+
uint32_t EspClass::getMaxAllocPsram(void)
155+
{
156+
return heap_caps_get_largest_free_block(MALLOC_CAP_SPIRAM);
118157
}
119158

120159
uint8_t EspClass::getChipRevision(void)

cores/esp32/Esp.h

+13-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,19 @@ class EspClass
5656
EspClass() {}
5757
~EspClass() {}
5858
void restart();
59-
uint32_t getFreeHeap();
59+
60+
//Internal RAM
61+
uint32_t getHeapSize(); //total heap size
62+
uint32_t getFreeHeap(); //available heap
63+
uint32_t getMinFreeHeap(); //lowest level of free heap since boot
64+
uint32_t getMaxAllocHeap(); //largest block of heap that can be allocated at once
65+
66+
//SPI RAM
67+
uint32_t getPsramSize();
68+
uint32_t getFreePsram();
69+
uint32_t getMinFreePsram();
70+
uint32_t getMaxAllocPsram();
71+
6072
uint8_t getChipRevision();
6173
uint8_t getCpuFreqMHz(){ return CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ; }
6274
uint32_t getCycleCount();

cores/esp32/esp32-hal-i2c.c

+11-12
Original file line numberDiff line numberDiff line change
@@ -1350,33 +1350,32 @@ static void i2cReleaseISR(i2c_t * i2c)
13501350
}
13511351

13521352
static bool i2cCheckLineState(int8_t sda, int8_t scl){
1353-
if(sda < 0 || scl < 0){
1354-
return true;//return true since there is nothing to do
1353+
if(sda < 0 || scl < 0){
1354+
return false;//return false since there is nothing to do
13551355
}
1356-
// if the bus is not 'clear' try the recommended recovery sequence, START, 9 Clocks, STOP
1356+
// if the bus is not 'clear' try the cycling SCL until SDA goes High or 9 cycles
13571357
digitalWrite(sda, HIGH);
13581358
digitalWrite(scl, HIGH);
1359-
pinMode(sda, PULLUP|OPEN_DRAIN|OUTPUT|INPUT);
1360-
pinMode(scl, PULLUP|OPEN_DRAIN|OUTPUT|INPUT);
1359+
pinMode(sda, PULLUP|OPEN_DRAIN|INPUT);
1360+
pinMode(scl, PULLUP|OPEN_DRAIN|OUTPUT);
13611361

13621362
if(!digitalRead(sda) || !digitalRead(scl)) { // bus in busy state
1363-
log_w("invalid state sda=%d, scl=%d\n", digitalRead(sda), digitalRead(scl));
1364-
digitalWrite(sda, HIGH);
1363+
log_w("invalid state sda(%d)=%d, scl(%d)=%d", sda, digitalRead(sda), scl, digitalRead(scl));
13651364
digitalWrite(scl, HIGH);
1366-
delayMicroseconds(5);
1367-
digitalWrite(sda, LOW);
13681365
for(uint8_t a=0; a<9; a++) {
13691366
delayMicroseconds(5);
13701367
digitalWrite(scl, LOW);
13711368
delayMicroseconds(5);
13721369
digitalWrite(scl, HIGH);
1370+
if(digitalRead(sda)){ // bus recovered
1371+
log_d("Recovered after %d Cycles",a+1);
1372+
break;
1373+
}
13731374
}
1374-
delayMicroseconds(5);
1375-
digitalWrite(sda, HIGH);
13761375
}
13771376

13781377
if(!digitalRead(sda) || !digitalRead(scl)) { // bus in busy state
1379-
log_e("Bus Invalid State, TwoWire() Can't init");
1378+
log_e("Bus Invalid State, TwoWire() Can't init sda=%d, scl=%d",digitalRead(sda),digitalRead(scl));
13801379
return false; // bus is busy
13811380
}
13821381
return true;

docs/arduino-ide/mac.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Installation instructions for Mac OS
1111
cd esp32 && \
1212
git submodule update --init --recursive && \
1313
cd tools && \
14-
python get.py
14+
python get.py
1515
```
1616
Where `~/Documents/Arduino` represents your sketch book location as per "Arduino" > "Preferences" > "Sketchbook location" (in the IDE once started). Adjust the command above accordingly if necessary!
1717

@@ -20,6 +20,8 @@ Installation instructions for Mac OS
2020
```xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun```
2121

2222
```xcode-select --install```
23+
24+
- Try `python3` instead of `python` if you get the error: `IOError: [Errno socket error] [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:590)` when running `python get.py`
2325

2426
- Restart Arduino IDE
2527

variants/heltec_wifi_lora_32/pins_arduino.h

+15-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ static const uint8_t KEY_BUILTIN = 0;
1919
static const uint8_t TX = 1;
2020
static const uint8_t RX = 3;
2121

22-
static const uint8_t SDA = 21;
23-
static const uint8_t SCL = 22;
22+
static const uint8_t SDA = 4;
23+
static const uint8_t SCL = 15;
2424

2525
static const uint8_t SS = 18;
2626
static const uint8_t MOSI = 27;
@@ -61,4 +61,17 @@ static const uint8_t T9 = 33;
6161
static const uint8_t DAC1 = 26;
6262
static const uint8_t DAC2 = 25;
6363

64+
// OLed
65+
static const uint8_t OLED_SCL = 15;
66+
static const uint8_t OLED_SDA = 4;
67+
static const uint8_t OLED_RST = 16;
68+
69+
// LoRA
70+
static const uint8_t LORA_SCK = 5;
71+
static const uint8_t LORA_MOSI = 27;
72+
static const uint8_t LORA_MISO = 19;
73+
static const uint8_t LORA_CS = 18;
74+
static const uint8_t LORA_RST = 14;
75+
static const uint8_t LORA_IRQ = 26;
76+
6477
#endif /* Pins_Arduino_h */

0 commit comments

Comments
 (0)