Skip to content

Commit 25f5307

Browse files
committed
Make entry points into sequential cont scheduler weak functions
Move Schedule to libraries
1 parent cd00eb0 commit 25f5307

File tree

9 files changed

+55
-27
lines changed

9 files changed

+55
-27
lines changed

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ set(CORE_SRCS
2929
cores/esp32/MD5Builder.cpp
3030
cores/esp32/Print.cpp
3131
cores/esp32/stdlib_noniso.c
32-
cores/esp32/Schedule.cpp
3332
cores/esp32/Stream.cpp
3433
cores/esp32/StreamString.cpp
3534
cores/esp32/wiring_pulse.c
@@ -52,6 +51,7 @@ set(LIBRARY_SRCS
5251
libraries/HTTPUpdate/src/HTTPUpdate.cpp
5352
libraries/NetBIOS/src/NetBIOS.cpp
5453
libraries/Preferences/src/Preferences.cpp
54+
libraries/Schedule/src/Schedule.cpp
5555
libraries/SD_MMC/src/SD_MMC.cpp
5656
libraries/SD/src/SD.cpp
5757
libraries/SD/src/sd_diskio.cpp
@@ -191,6 +191,7 @@ set(COMPONENT_ADD_INCLUDEDIRS
191191
libraries/HTTPUpdate/src
192192
libraries/NetBIOS/src
193193
libraries/Preferences/src
194+
libraries/Schedule/src
194195
libraries/SD_MMC/src
195196
libraries/SD/src
196197
libraries/SimpleBLE/src

cores/esp32/Arduino.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ void init(void);
130130
void initVariant(void);
131131
void initArduino(void);
132132

133+
void yield_completed(void);
134+
void loop_completed(void);
135+
133136
unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout);
134137
unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout);
135138

@@ -153,7 +156,6 @@ void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val);
153156
#include "Udp.h"
154157
#include "HardwareSerial.h"
155158
#include "Esp.h"
156-
#include "Schedule.h"
157159

158160
using std::abs;
159161
using std::isinf;

cores/esp32/esp32-hal-misc.c

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
#include "rom/rtc.h"
3535
#include "esp_task_wdt.h"
3636
#include "esp32-hal.h"
37-
#include "Schedule.h"
3837

3938
//Undocumented!!! Get chip temperature in Farenheit
4039
//Source: https://github.com/pcbreflux/espressif/blob/master/esp32/arduino/sketchbook/ESP32_int_temp_sensor/ESP32_int_temp_sensor.ino
@@ -45,12 +44,6 @@ float temperatureRead()
4544
return (temprature_sens_read() - 32) / 1.8;
4645
}
4746

48-
void yield()
49-
{
50-
vPortYield();
51-
run_scheduled_functions(SCHEDULE_FUNCTION_WITHOUT_YIELDELAYCALLS);
52-
}
53-
5447
#if CONFIG_AUTOSTART_ARDUINO
5548

5649
extern TaskHandle_t loopTaskHandle;
@@ -141,9 +134,34 @@ unsigned long IRAM_ATTR millis()
141134
return (unsigned long) (esp_timer_get_time() / 1000ULL);
142135
}
143136

137+
void initVariant() __attribute__((weak));
138+
void initVariant() {}
139+
140+
void init() __attribute__((weak));
141+
void init() {}
142+
143+
void yield_completed() __attribute__((weak));
144+
void yield_completed() {}
145+
146+
bool verifyOta() __attribute__((weak));
147+
bool verifyOta() { return true; }
148+
149+
#ifdef CONFIG_BT_ENABLED
150+
//overwritten in esp32-hal-bt.c
151+
bool btInUse() __attribute__((weak));
152+
bool btInUse() { return false; }
153+
#endif
154+
155+
void yield()
156+
{
157+
vPortYield();
158+
yield_completed();
159+
}
160+
144161
void delay(uint32_t ms)
145162
{
146163
vTaskDelay(ms / portTICK_PERIOD_MS);
164+
yield_completed();
147165
}
148166

149167
void IRAM_ATTR delayMicroseconds(uint32_t us)
@@ -162,21 +180,6 @@ void IRAM_ATTR delayMicroseconds(uint32_t us)
162180
}
163181
}
164182

165-
void initVariant() __attribute__((weak));
166-
void initVariant() {}
167-
168-
void init() __attribute__((weak));
169-
void init() {}
170-
171-
bool verifyOta() __attribute__((weak));
172-
bool verifyOta() { return true; }
173-
174-
#ifdef CONFIG_BT_ENABLED
175-
//overwritten in esp32-hal-bt.c
176-
bool btInUse() __attribute__((weak));
177-
bool btInUse(){ return false; }
178-
#endif
179-
180183
void initArduino()
181184
{
182185
#ifdef CONFIG_APP_ROLLBACK_ENABLE

cores/esp32/main.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ void loopTask(void *pvParameters)
1717
esp_task_wdt_reset();
1818
}
1919
loop();
20-
run_scheduled_functions(SCHEDULE_FUNCTION_FROM_LOOP);
20+
loop_completed();
2121
}
2222
}
2323

@@ -28,4 +28,7 @@ extern "C" void app_main()
2828
xTaskCreateUniversal(loopTask, "loopTask", 8192, NULL, 1, &loopTaskHandle, CONFIG_ARDUINO_RUNNING_CORE);
2929
}
3030

31+
extern "C" void loop_completed() __attribute__((weak));
32+
extern "C" void loop_completed() {}
33+
3134
#endif

libraries/Schedule/library.properties

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name=Schedule
2+
version=1.0
3+
author=
4+
maintainer=
5+
sentence=
6+
paragraph=
7+
category=Other
8+
url=
9+
architectures=esp32

cores/esp32/Schedule.cpp renamed to libraries/Schedule/src/Schedule.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
11
#include "Schedule.h"
2-
#include "PolledTimeout.h"
2+
#include "PolledTimeout/PolledTimeout.h"
33
#include "Ticker.h"
44
#ifdef ESP8266
55
#include "interrupts.h"
66
#include "coredecls.h"
77
#else
88
#include <mutex>
99
#endif
10-
#include "circular_queue.h"
10+
#include "circular_queue/circular_queue.h"
11+
12+
void loop_completed()
13+
{
14+
run_scheduled_functions(SCHEDULE_FUNCTION_FROM_LOOP);
15+
}
16+
17+
void yield_completed()
18+
{
19+
run_scheduled_functions(SCHEDULE_FUNCTION_WITHOUT_YIELDELAYCALLS);
20+
}
1121

1222
typedef std::function<bool(void)> mFuncT;
1323

File renamed without changes.

0 commit comments

Comments
 (0)