Skip to content

Commit

Permalink
Enabled Deep sleep for Esp32_H2 (nanoframework#2981)
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianSoundy authored and TerryFogg committed Dec 3, 2024
1 parent 663c911 commit 30613aa
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,27 @@ typedef enum __nfpack Sleep_WakeupGpioPin
{
Sleep_WakeupGpioPin_None = 0,
Sleep_WakeupGpioPin_Pin0 = 1,
Sleep_WakeupGpioPin_Pin1 = 2,
Sleep_WakeupGpioPin_Pin2 = 4,
Sleep_WakeupGpioPin_Pin3 = 8,
Sleep_WakeupGpioPin_Pin4 = 16,
Sleep_WakeupGpioPin_Pin5 = 32,
Sleep_WakeupGpioPin_Pin6 = 64,
Sleep_WakeupGpioPin_Pin7 = 128,
Sleep_WakeupGpioPin_Pin8 = 256,
Sleep_WakeupGpioPin_Pin9 = 512,
Sleep_WakeupGpioPin_Pin10 = 1024,
Sleep_WakeupGpioPin_Pin11 = 2048,
Sleep_WakeupGpioPin_Pin12 = 4096,
Sleep_WakeupGpioPin_Pin13 = 8192,
Sleep_WakeupGpioPin_Pin14 = 16384,
Sleep_WakeupGpioPin_Pin15 = 32768,
Sleep_WakeupGpioPin_Pin16 = 65536,
Sleep_WakeupGpioPin_Pin17 = 131072,
Sleep_WakeupGpioPin_Pin18 = 262144,
Sleep_WakeupGpioPin_Pin19 = 524288,
Sleep_WakeupGpioPin_Pin20 = 1048576,
Sleep_WakeupGpioPin_Pin21 = 2097152,
Sleep_WakeupGpioPin_Pin25 = 33554432,
Sleep_WakeupGpioPin_Pin26 = 67108864,
Sleep_WakeupGpioPin_Pin27 = 134217728,
Expand Down Expand Up @@ -226,12 +241,12 @@ typedef enum __nfpack ValueTypes
ValueTypes_DeviceType = 65536,
} ValueTypes;

typedef enum __nfpack GpioChangePolarity
typedef enum __nfpack GpioPulsePolarity
{
GpioChangePolarity_Both = 0,
GpioChangePolarity_Falling = 1,
GpioChangePolarity_Rising = 2,
} GpioChangePolarity;
GpioPulsePolarity_Both = 0,
GpioPulsePolarity_Falling = 1,
GpioPulsePolarity_Rising = 2,
} GpioPulsePolarity;

struct Library_nanoFramework_hardware_esp32_native_nanoFramework_Hardware_Esp32_Configuration
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ static pcnt_unit_handle_t InitialiseCounter(int counterIndex)
return (ec == ESP_OK) ? counter->unitHandle : NULL;
}

static pcnt_unit_handle_t InitialiseEdgeAndActions(int counterIndex, GpioChangePolarity polarity)
static pcnt_unit_handle_t InitialiseEdgeAndActions(int counterIndex, GpioPulsePolarity polarity)
{
esp_err_t ec = ESP_OK;
bool countRising = false;
Expand All @@ -169,17 +169,17 @@ static pcnt_unit_handle_t InitialiseEdgeAndActions(int counterIndex, GpioChangeP

switch (polarity)
{
case GpioChangePolarity_Both:
case GpioPulsePolarity_Both:
countRising = true;
countFalling = true;
break;

case GpioChangePolarity_Rising:
case GpioPulsePolarity_Rising:
countRising = true;
countFalling = false;
break;

case GpioChangePolarity_Falling:
case GpioPulsePolarity_Falling:
countRising = false;
countFalling = true;
break;
Expand Down Expand Up @@ -420,7 +420,7 @@ HRESULT Library_nanoFramework_hardware_esp32_native_System_Device_Gpio_GpioPulse
// must be disabled to change
pcnt_unit_disable(unitHandle);

GpioChangePolarity polarity = (GpioChangePolarity)pThis[FIELD___polarity].NumericByRefConst().s4;
GpioPulsePolarity polarity = (GpioPulsePolarity)pThis[FIELD___polarity].NumericByRefConst().s4;
InitialiseEdgeAndActions(counterIndex, polarity);

// Apply filter.
Expand Down
2 changes: 0 additions & 2 deletions targets/ESP32/_nanoCLR/targetHAL_Power.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ inline bool CPU_IsSoftRebootSupported()

void CPU_SetPowerMode(PowerLevel_type powerLevel)
{
#if !defined(CONFIG_IDF_TARGET_ESP32H2)
switch (powerLevel)
{
case PowerLevel__Off:
Expand All @@ -52,5 +51,4 @@ void CPU_SetPowerMode(PowerLevel_type powerLevel)
// all the other power modes are unsupported here
break;
}
#endif
}

0 comments on commit 30613aa

Please sign in to comment.