Skip to content

Commit 034e1a1

Browse files
authored
Improvements in power mode API (#2567)
***NO_CI***
1 parent d3b1444 commit 034e1a1

File tree

18 files changed

+74
-40
lines changed

18 files changed

+74
-40
lines changed

src/CLR/Startup/CLRStartup.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ void ClrStartup(CLR_SETTINGS params)
444444

445445
s_ClrSettings.Cleanup();
446446

447-
nanoHAL_Uninitialize();
447+
nanoHAL_Uninitialize(false);
448448

449449
// re-init the hal for the reboot (initially it is called in bootentry)
450450
nanoHAL_Initialize();

src/HAL/Include/nanoHAL.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,7 @@ template <typename T> class HAL_RingBuffer
800800
// hal cleanup for CLR reboot
801801

802802
void nanoHAL_Initialize();
803-
void nanoHAL_Uninitialize();
803+
void nanoHAL_Uninitialize(bool isPoweringDown);
804804

805805
typedef void (*ON_SOFT_REBOOT_HANDLER)(void);
806806

src/HAL/Include/nanoHAL_v2.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ extern "C"
201201
#endif
202202

203203
void nanoHAL_Initialize_C();
204-
void nanoHAL_Uninitialize_C();
204+
void nanoHAL_Uninitialize_C(bool isPoweringDown);
205205
void HeapLocation_C(unsigned char **baseAddress, unsigned int *sizeInBytes);
206206

207207
// Call to the external memory configuration and initialization function
@@ -220,6 +220,10 @@ extern "C"
220220
void CPU_Reset();
221221
void CPU_Sleep(SLEEP_LEVEL_type level, uint64_t wakeEvents);
222222
void CPU_SetPowerMode(PowerLevel_type powerLevel);
223+
// platform specific handler for power mode changes (may be empty)
224+
void CPU_SetPowerModePlatform(PowerLevel_type powerLevel);
225+
// target specific handler for power mode changes (may be empty)
226+
void CPU_SetPowerModeTarget(PowerLevel_type powerLevel);
223227

224228
#ifdef __cplusplus
225229
}

targets/AzureRTOS/Maxim/_nanoCLR/targetHAL.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ extern "C"
4040
nanoHAL_Initialize();
4141
}
4242

43-
void nanoHAL_Uninitialize_C()
43+
void nanoHAL_Uninitialize_C(bool isPoweringDown)
4444
{
45-
nanoHAL_Uninitialize();
45+
nanoHAL_Uninitialize(isPoweringDown);
4646
}
4747
}
4848

@@ -161,8 +161,10 @@ void nanoHAL_Initialize()
161161
Network_Initialize();
162162
}
163163

164-
void nanoHAL_Uninitialize()
164+
void nanoHAL_Uninitialize(bool isPoweringDown)
165165
{
166+
(void)isPoweringDown;
167+
166168
// release the global mutex, just in case it's locked somewhere
167169
// chMtxUnlock(&interpreterGlobalMutex);
168170

targets/AzureRTOS/Maxim/_nanoCLR/targetHAL_Power.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ void CPU_SetPowerMode(PowerLevel_type powerLevel)
4646
// wdgStop(&WDGD1);
4747

4848
// gracefully shutdown everything
49-
nanoHAL_Uninitialize_C();
49+
nanoHAL_Uninitialize_C(true);
5050

5151
// chSysDisable();
5252
// disable interrupts

targets/AzureRTOS/ST/_nanoCLR/targetHAL.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ extern "C"
3838
nanoHAL_Initialize();
3939
}
4040

41-
void nanoHAL_Uninitialize_C()
41+
void nanoHAL_Uninitialize_C(bool isPoweringDown)
4242
{
43-
nanoHAL_Uninitialize();
43+
nanoHAL_Uninitialize(isPoweringDown);
4444
}
4545
}
4646

@@ -157,8 +157,10 @@ void nanoHAL_Initialize()
157157
Network_Initialize();
158158
}
159159

160-
void nanoHAL_Uninitialize()
160+
void nanoHAL_Uninitialize(bool isPoweringDown)
161161
{
162+
(void)isPoweringDown;
163+
162164
// release the global mutex, just in case it's locked somewhere
163165
// chMtxUnlock(&interpreterGlobalMutex);
164166

targets/AzureRTOS/ST/_nanoCLR/targetHAL_Power.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ void CPU_SetPowerMode(PowerLevel_type powerLevel)
7070
#endif
7171
#endif
7272
// gracefully shutdown everything
73-
nanoHAL_Uninitialize_C();
73+
nanoHAL_Uninitialize_C(true);
7474

7575
__disable_irq();
7676

targets/AzureRTOS/SiliconLabs/_nanoCLR/targetHAL.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ extern void DeInitPwm();
3737
#include <sys_dev_usbstream_native_target.h>
3838
#endif
3939

40-
4140
// global mutex protecting the internal state of the interpreter, including event flags
4241
// mutex_t interpreterGlobalMutex;
4342

@@ -51,9 +50,9 @@ extern "C"
5150
nanoHAL_Initialize();
5251
}
5352

54-
void nanoHAL_Uninitialize_C()
53+
void nanoHAL_Uninitialize_C(bool isPoweringDown)
5554
{
56-
nanoHAL_Uninitialize();
55+
nanoHAL_Uninitialize(isPoweringDown);
5756
}
5857
}
5958

@@ -138,10 +137,10 @@ void nanoHAL_Initialize()
138137
#endif
139138

140139
#if (GECKO_USE_ADC0 == TRUE) && defined(NANO_GG_ADC_NATIVE_TARGET_H)
141-
adc0Initialized = false;
140+
adc0Initialized = false;
142141
#endif
143142
#if (GECKO_USE_ADC1 == TRUE) && defined(NANO_GG_ADC_NATIVE_TARGET_H)
144-
adc1Initialized = false;
143+
adc1Initialized = false;
145144
#endif
146145

147146
#if GECKO_FEATURE_USBD_WINUSB == TRUE
@@ -205,8 +204,10 @@ adc1Initialized = false;
205204
Network_Initialize();
206205
}
207206

208-
void nanoHAL_Uninitialize()
207+
void nanoHAL_Uninitialize(bool isPoweringDown)
209208
{
209+
(void)isPoweringDown;
210+
210211
// release the global mutex, just in case it's locked somewhere
211212
// chMtxUnlock(&interpreterGlobalMutex);
212213

@@ -283,16 +284,16 @@ void nanoHAL_Uninitialize()
283284
#endif
284285

285286
#if (GECKO_USE_ADC0 == TRUE) && defined(NANO_GG_ADC_NATIVE_TARGET_H)
286-
ADC_Reset(ADC0);
287-
adc0Initialized = false;
287+
ADC_Reset(ADC0);
288+
adc0Initialized = false;
288289
#endif
289290
#if (GECKO_USE_ADC1 == TRUE) && defined(NANO_GG_ADC_NATIVE_TARGET_H)
290-
ADC_Reset(ADC1);
291-
adc1Initialized = false;
291+
ADC_Reset(ADC1);
292+
adc1Initialized = false;
292293
#endif
293294

294295
#if GECKO_FEATURE_USBD_WINUSB == TRUE
295-
296+
296297
// abort any transfer in progress, just in case
297298
sl_usbd_vendor_abort_write_bulk(sl_usbd_vendor_winusb_number);
298299
sl_usbd_vendor_abort_read_bulk(sl_usbd_vendor_winusb_number);

targets/AzureRTOS/SiliconLabs/_nanoCLR/targetHAL_Power.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ void CPU_SetPowerMode(PowerLevel_type powerLevel)
4444
// wdgStop(&WDGD1);
4545

4646
// gracefully shutdown everything
47-
nanoHAL_Uninitialize_C();
47+
nanoHAL_Uninitialize_C(true);
4848

4949
__disable_irq();
5050

targets/ChibiOS/_nanoCLR/targetHAL.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ extern "C"
4040
nanoHAL_Initialize();
4141
}
4242

43-
void nanoHAL_Uninitialize_C()
43+
void nanoHAL_Uninitialize_C(bool isPoweringDown)
4444
{
45-
nanoHAL_Uninitialize();
45+
nanoHAL_Uninitialize(isPoweringDown);
4646
}
4747
}
4848

@@ -155,8 +155,10 @@ void nanoHAL_Initialize()
155155
Network_Initialize();
156156
}
157157

158-
void nanoHAL_Uninitialize()
158+
void nanoHAL_Uninitialize(bool isPoweringDown)
159159
{
160+
(void)isPoweringDown;
161+
160162
// release the global mutex, just in case it's locked somewhere
161163
// chMtxUnlock(&interpreterGlobalMutex);
162164

0 commit comments

Comments
 (0)