Skip to content

Commit 01e1b81

Browse files
committed
Rename all millis as ms
During debug millis can be interpreted as the millis() function pointer Signed-off-by: Frederic Pillon <[email protected]>
1 parent 02af715 commit 01e1b81

File tree

3 files changed

+43
-43
lines changed

3 files changed

+43
-43
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ Arduino library to support STM32 Low Power.
88

99
* **`void begin()`**: configure the Low Power
1010

11-
* **`void idle(uint32_t millis)`**: enter in idle mode
12-
**param** millis (optional): number of milliseconds before to exit the mode. The RTC is used in alarm mode to wakeup the chip in millis milliseconds.
11+
* **`void idle(uint32_t ms)`**: enter in idle mode
12+
**param** ms (optional): number of milliseconds before to exit the mode. The RTC is used in alarm mode to wakeup the chip in ms milliseconds.
1313

14-
* **`void sleep(uint32_t millis)`**: enter in sleep mode
15-
**param** millis (optional): number of milliseconds before to exit the mode. he RTC is used in alarm mode to wakeup the chip in millis milliseconds.
14+
* **`void sleep(uint32_t ms)`**: enter in sleep mode
15+
**param** ms (optional): number of milliseconds before to exit the mode. he RTC is used in alarm mode to wakeup the chip in ms milliseconds.
1616

17-
* **`void deepSleep(uint32_t millis)`**: enter in deepSleep mode
18-
**param** millis (optional): number of milliseconds before to exit the mode. The RTC is used in alarm mode to wakeup the chip in millis milliseconds.
17+
* **`void deepSleep(uint32_t ms)`**: enter in deepSleep mode
18+
**param** ms (optional): number of milliseconds before to exit the mode. The RTC is used in alarm mode to wakeup the chip in ms milliseconds.
1919

20-
* **`void shutdown(uint32_t millis)`**: enter in shutdown mode
21-
**param** millis (optional): number of milliseconds before to exit the mode. The RTC is used in alarm mode to wakeup the board in millis milliseconds.
20+
* **`void shutdown(uint32_t ms)`**: enter in shutdown mode
21+
**param** ms (optional): number of milliseconds before to exit the mode. The RTC is used in alarm mode to wakeup the board in ms milliseconds.
2222

2323
**Note: With [STM32RTC](https://github.com/stm32duino/STM32RTC) version lower than 1.1.0, the minimum number of milliseconds is 1000 ms.**
2424

src/STM32LowPower.cpp

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -60,55 +60,55 @@ void STM32LowPower::begin(void)
6060
/**
6161
* @brief Enable the idle low power mode (STM32 sleep). Exit this mode on
6262
* interrupt or in n milliseconds.
63-
* @param millis: optional delay before leave the idle mode (default: 0).
63+
* @param ms: optional delay before leave the idle mode (default: 0).
6464
* @retval None
6565
*/
66-
void STM32LowPower::idle(uint32_t millis)
66+
void STM32LowPower::idle(uint32_t ms)
6767
{
68-
if ((millis > 0) || _rtc_wakeup) {
69-
programRtcWakeUp(millis, IDLE_MODE);
68+
if ((ms != 0) || _rtc_wakeup) {
69+
programRtcWakeUp(ms, IDLE_MODE);
7070
}
7171
LowPower_sleep(PWR_MAINREGULATOR_ON);
7272
}
7373

7474
/**
7575
* @brief Enable the sleep low power mode (STM32 sleep). Exit this mode on
7676
* interrupt or in n milliseconds.
77-
* @param millis: optional delay before leave the sleep mode (default: 0).
77+
* @param ms: optional delay before leave the sleep mode (default: 0).
7878
* @retval None
7979
*/
80-
void STM32LowPower::sleep(uint32_t millis)
80+
void STM32LowPower::sleep(uint32_t ms)
8181
{
82-
if ((millis > 0) || _rtc_wakeup) {
83-
programRtcWakeUp(millis, SLEEP_MODE);
82+
if ((ms != 0) || _rtc_wakeup) {
83+
programRtcWakeUp(ms, SLEEP_MODE);
8484
}
8585
LowPower_sleep(PWR_LOWPOWERREGULATOR_ON);
8686
}
8787

8888
/**
8989
* @brief Enable the deepsleep low power mode (STM32 stop). Exit this mode on
9090
* interrupt or in n milliseconds.
91-
* @param millis: optional delay before leave the deepSleep mode (default: 0).
91+
* @param ms: optional delay before leave the deepSleep mode (default: 0).
9292
* @retval None
9393
*/
94-
void STM32LowPower::deepSleep(uint32_t millis)
94+
void STM32LowPower::deepSleep(uint32_t ms)
9595
{
96-
if ((millis > 0) || _rtc_wakeup) {
97-
programRtcWakeUp(millis, DEEP_SLEEP_MODE);
96+
if ((ms != 0) || _rtc_wakeup) {
97+
programRtcWakeUp(ms, DEEP_SLEEP_MODE);
9898
}
9999
LowPower_stop(_serial);
100100
}
101101

102102
/**
103103
* @brief Enable the shutdown low power mode (STM32 shutdown or standby mode).
104104
* Exit this mode on interrupt or in n milliseconds.
105-
* @param millis: optional delay before leave the shutdown mode (default: 0).
105+
* @param ms: optional delay before leave the shutdown mode (default: 0).
106106
* @retval None
107107
*/
108-
void STM32LowPower::shutdown(uint32_t millis)
108+
void STM32LowPower::shutdown(uint32_t ms)
109109
{
110-
if ((millis > 0) || _rtc_wakeup) {
111-
programRtcWakeUp(millis, SHUTDOWN_MODE);
110+
if ((ms != 0) || _rtc_wakeup) {
111+
programRtcWakeUp(ms, SHUTDOWN_MODE);
112112
}
113113
LowPower_shutdown();
114114
}
@@ -167,11 +167,11 @@ void STM32LowPower::enableWakeupFrom(STM32RTC *rtc, voidFuncPtr callback, void *
167167

168168
/**
169169
* @brief Configure the RTC alarm
170-
* @param millis: time of the alarm in milliseconds.
170+
* @param ms: time of the alarm in milliseconds.
171171
* @param lp_mode: low power mode targeted.
172172
* @retval None
173173
*/
174-
void STM32LowPower::programRtcWakeUp(uint32_t millis, LP_Mode lp_mode)
174+
void STM32LowPower::programRtcWakeUp(uint32_t ms, LP_Mode lp_mode)
175175
{
176176
int epoc;
177177
uint32_t sec;
@@ -199,17 +199,17 @@ void STM32LowPower::programRtcWakeUp(uint32_t millis, LP_Mode lp_mode)
199199
}
200200
rtc.configForLowPower(clkSrc);
201201

202-
if (millis > 0) {
202+
if (ms != 0) {
203203
// Convert millisecond to second
204-
sec = millis / 1000;
204+
sec = ms / 1000;
205205

206206
#if defined(STM32_RTC_VERSION) && (STM32_RTC_VERSION >= 0x01010000)
207207
uint32_t epoc_ms;
208-
millis = millis % 1000;
208+
ms = ms % 1000;
209209
epoc = rtc.getEpoch(&epoc_ms);
210210

211211
//Update epoch_ms - might need to add a second to epoch
212-
epoc_ms += millis;
212+
epoc_ms += ms;
213213
if (epoc_ms >= 1000) {
214214
sec ++;
215215
epoc_ms -= 1000;

src/STM32LowPower.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -66,28 +66,28 @@ class STM32LowPower {
6666

6767
void begin(void);
6868

69-
void idle(uint32_t millis = 0);
70-
void idle(int millis)
69+
void idle(uint32_t ms = 0);
70+
void idle(int ms)
7171
{
72-
idle((uint32_t)millis);
72+
idle((uint32_t)ms);
7373
}
7474

75-
void sleep(uint32_t millis = 0);
76-
void sleep(int millis)
75+
void sleep(uint32_t ms = 0);
76+
void sleep(int ms)
7777
{
78-
sleep((uint32_t)millis);
78+
sleep((uint32_t)ms);
7979
}
8080

81-
void deepSleep(uint32_t millis = 0);
82-
void deepSleep(int millis)
81+
void deepSleep(uint32_t ms = 0);
82+
void deepSleep(int ms)
8383
{
84-
deepSleep((uint32_t)millis);
84+
deepSleep((uint32_t)ms);
8585
}
8686

87-
void shutdown(uint32_t millis = 0);
88-
void shutdown(int millis)
87+
void shutdown(uint32_t ms = 0);
88+
void shutdown(int ms)
8989
{
90-
shutdown((uint32_t)millis);
90+
shutdown((uint32_t)ms);
9191
}
9292

9393
void attachInterruptWakeup(uint32_t pin, voidFuncPtrVoid callback, uint32_t mode, LP_Mode LowPowerMode = SHUTDOWN_MODE);
@@ -99,7 +99,7 @@ class STM32LowPower {
9999
bool _configured; // Low Power mode initialization status
100100
serial_t *_serial; // Serial for wakeup from deep sleep
101101
bool _rtc_wakeup; // Is RTC wakeup?
102-
void programRtcWakeUp(uint32_t millis, LP_Mode lp_mode);
102+
void programRtcWakeUp(uint32_t ms, LP_Mode lp_mode);
103103
};
104104

105105
extern STM32LowPower LowPower;

0 commit comments

Comments
 (0)