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

Fix implementation of ESP32 sleep implementation #1852

Merged
merged 2 commits into from
Mar 8, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,5 @@ const CLR_RT_NativeAssemblyData g_CLR_AssemblyNative_nanoFramework_Hardware_Esp3
"nanoFramework.Hardware.Esp32",
0x1B75B894,
method_lookup,
{ 100, 0, 7, 1 }
{ 100, 0, 7, 2 }
};
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,28 @@ HRESULT Library_nanoFramework_hardware_esp32_native_nanoFramework_Hardware_Esp32
{
NANOCLR_HEADER();
{
gpio_num_t gpio_num = (gpio_num_t)stack.Arg0().NumericByRef().s4;
uint64_t mask = (uint64_t)stack.Arg0().NumericByRef().s8;
int level = stack.Arg1().NumericByRef().s4;

esp_err_t err = esp_sleep_enable_ext0_wakeup( gpio_num, level);

// Extract pin number from mask value
gpio_num_t gpio_num = GPIO_NUM_0;
esp_err_t err = 0;
if (mask) // Only enable pin if other than Pin.None
{
for (size_t i = 0; i < GPIO_NUM_MAX; i++)
{
if (mask & 0x01)
{
gpio_num = (gpio_num_t) i;
}
mask >>= 1;
}
err = esp_sleep_enable_ext0_wakeup( gpio_num, level);
}

// Return err to the managed application
stack.SetResult_I4( (int)err ) ;
}
}
NANOCLR_NOCLEANUP_NOLABEL();
}

Expand Down