global: make sleep immediately return on 0 duration
This commit is contained in:
parent
9220dbeb50
commit
252363cf02
8
global.c
8
global.c
|
@ -101,6 +101,10 @@ void led_toggle(void)
|
|||
|
||||
void sleep_us(uint32_t duration)
|
||||
{
|
||||
if (0 == duration) {
|
||||
return;
|
||||
}
|
||||
|
||||
systick_counter_disable(); // disable SysTick to reconfigure it
|
||||
if (!systick_set_frequency(1000000, rcc_ahb_frequency)) { // set SysTick frequency to microseconds
|
||||
while (true); // unhandled error
|
||||
|
@ -116,6 +120,10 @@ void sleep_us(uint32_t duration)
|
|||
|
||||
void sleep_ms(uint32_t duration)
|
||||
{
|
||||
if (0 == duration) {
|
||||
return;
|
||||
}
|
||||
|
||||
systick_counter_disable(); // disable SysTick to reconfigure it
|
||||
if (!systick_set_frequency(1000, rcc_ahb_frequency)) { // set SysTick frequency to milliseconds
|
||||
while (true); // unhandled error
|
||||
|
|
Loading…
Reference in New Issue