Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inline getFreeStack and mention 2.5.0 helper method #1208

Merged
merged 1 commit into from
Sep 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions code/espurna/config/prototypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,25 @@ extern "C" {
void custom_crash_callback(struct rst_info*, uint32_t, uint32_t);
}

// Core version 2.4.2 and higher changed the cont_t structure to a pointer:
// https://github.com/esp8266/Arduino/commit/5d5ea92a4d004ab009d5f642629946a0cb8893dd#diff-3fa12668b289ccb95b7ab334833a4ba8L35
// Core version 2.5.0 introduced EspClass helper method:
// https://github.com/esp8266/Arduino/commit/0e0e34c614fe8a47544c9998201b1d9b3c24eb18
extern "C" {
#include <cont.h>
#if defined(ARDUINO_ESP8266_RELEASE_2_3_0) \
|| defined(ARDUINO_ESP8266_RELEASE_2_4_0) \
|| defined(ARDUINO_ESP8266_RELEASE_2_4_1)
extern cont_t g_cont;
#define getFreeStack() cont_get_free_stack(&g_cont)
#elif defined(ARDUINO_ESP8266_RELEASE_2_4_2)
extern cont_t* g_pcont;
#define getFreeStack() cont_get_free_stack(g_pcont)
#else
#define getFreeStack() ESP.getFreeContStack()
#endif
}

// -----------------------------------------------------------------------------
// Domoticz
// -----------------------------------------------------------------------------
Expand Down
25 changes: 0 additions & 25 deletions code/espurna/utils.ino
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,6 @@ Copyright (C) 2017-2018 by Xose Pérez <xose dot perez at gmail dot com>

*/

// Core version 2.4.2 and higher changed the cont_t structure to a pointer:
// https://github.com/esp8266/Arduino/commit/5d5ea92a4d004ab009d5f642629946a0cb8893dd#diff-3fa12668b289ccb95b7ab334833a4ba8L35
#if defined(ARDUINO_ESP8266_RELEASE_2_3_0) \
|| defined(ARDUINO_ESP8266_RELEASE_2_4_0) \
|| defined(ARDUINO_ESP8266_RELEASE_2_4_1)
extern "C" {
#include <cont.h>
extern cont_t g_cont;

}

unsigned int getFreeStack() {
return cont_get_free_stack(&g_cont);
}
#else
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add elif here just like in https://github.com/xoseperez/espurna/pull/1208/files#diff-52135e36de9de9ff791c1184a170b897R50, this way for 2.5.0 we won't have that extern "C" and rest.
Sorry if this is a bumb comment, I recently start learning Arduino and stuff.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

much less things on the screen was the main reason.
i am not an expert on c++, just felt like a better approach :) and as it turns out from #1205 all that multiline constructs inside .ino broke compilation when on Windows. moving to header also helped with that

extern "C" {
#include <cont.h>
extern cont_t* g_pcont;
}

unsigned int getFreeStack() {
return cont_get_free_stack(g_pcont);
}
#endif // defined(ARDUINO_ESP8266_RELEASE_2_3_0/2_4_0/2_4_1)

#include <Ticker.h>
Ticker _defer_reset;

Expand Down