-
-
Notifications
You must be signed in to change notification settings - Fork 65
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
[beken-72xx] Fix deep_sleep time parameter overflow #232
Conversation
@@ -21,12 +21,12 @@ void lt_deep_sleep_unset_gpio(uint32_t gpio_index_map) { | |||
|
|||
void lt_deep_sleep_config_timer(uint32_t sleep_duration) { | |||
deep_sleep_param.wake_up_way |= PS_DEEP_WAKEUP_RTC; | |||
uint64_t duration_math = 32768 * sleep_duration; | |||
if (duration_math / 1000 > 0xFFFFFFFF) { | |||
uint32_t duration_math = (32768 * ((float) sleep_duration)/1000.0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To avoid unnecessary casting, could you try 32.768 * sleep_duration
? This way the division is avoided, and casting is implicit because the first operand is a float.
uint64_t duration_math = 32768 * sleep_duration; | ||
if (duration_math / 1000 > 0xFFFFFFFF) { | ||
uint32_t duration_math = (32768 * ((float) sleep_duration)/1000.0); | ||
if (duration_math > 0xFFFFFFFF) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can never be larger than 0xFFFFFFFF now. Is that even needed?
This reverts commit 0518e21.
This reverts commit 0518e21.
This can probably be closed as duplicate of the now-completed #253 |
Fix for #230