mirror of https://github.com/ARMmbed/mbed-os.git
mbedtls: Use LowPowerTimeout for mbedtls_set_alarm() if available
The function `mbedtls_set_alarm()` is only precise to seconds, so `LowPowerTimeout` is enough and saves power.pull/14772/head
parent
e16f59a2ee
commit
ca719a96a8
|
@ -29,6 +29,7 @@
|
||||||
|
|
||||||
#include "mbedtls/timing.h"
|
#include "mbedtls/timing.h"
|
||||||
#include "drivers/Timeout.h"
|
#include "drivers/Timeout.h"
|
||||||
|
#include "drivers/LowPowerTimeout.h"
|
||||||
#include "drivers/Timer.h"
|
#include "drivers/Timer.h"
|
||||||
#include "drivers/LowPowerTimer.h"
|
#include "drivers/LowPowerTimer.h"
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
@ -44,7 +45,14 @@ static void handle_alarm(void)
|
||||||
|
|
||||||
extern "C" void mbedtls_set_alarm(int seconds)
|
extern "C" void mbedtls_set_alarm(int seconds)
|
||||||
{
|
{
|
||||||
|
#if DEVICE_LPTICKER
|
||||||
|
static mbed::LowPowerTimeout t;
|
||||||
|
#elif DEVICE_USTICKER
|
||||||
static mbed::Timeout t;
|
static mbed::Timeout t;
|
||||||
|
#else
|
||||||
|
#error "MBEDTLS_TIMING_C requires either LPTICKER or USTICKER"
|
||||||
|
#endif
|
||||||
|
|
||||||
mbedtls_timing_alarmed = 0;
|
mbedtls_timing_alarmed = 0;
|
||||||
|
|
||||||
t.attach(handle_alarm, std::chrono::seconds(seconds));
|
t.attach(handle_alarm, std::chrono::seconds(seconds));
|
||||||
|
|
Loading…
Reference in New Issue