Skip to content

Commit ce5dbda

Browse files
committed
Move time macro conversions to Ticker.h
1 parent 4b1cee3 commit ce5dbda

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

drivers/Ticker.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,21 @@
2323
#include "platform/NonCopyable.h"
2424
#include "hal/lp_ticker_api.h"
2525

26+
/**
27+
* Number of microseconds in a second
28+
*/
29+
#define MICROSECONDS_IN_SECOND (us_timestamp_t)1000000
30+
31+
/**
32+
* Converts seconds to microseconds
33+
*/
34+
#define SECONDS_TO_MICROSECONDS(SECONDS) (us_timestamp_t)(MICROSECONDS_IN_SECOND * SECONDS)
35+
36+
/**
37+
* Converts microseconds to seconds
38+
*/
39+
#define MICROSECONDS_TO_SECONDS(MICROSECONDS) (s_timestamp_t)(MICROSECONDS / MICROSECONDS_IN_SECOND)
40+
2641
namespace mbed {
2742
/**
2843
* \addtogroup drivers_Ticker Ticker class

hal/ticker_api.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,6 @@
2424
#include <stdbool.h>
2525
#include "device.h"
2626

27-
/**
28-
* Number of microseconds in a second
29-
*/
30-
#define MICROSECONDS_IN_SECOND (us_timestamp_t)1000000
31-
32-
/**
33-
* Converts seconds to microseconds
34-
*/
35-
#define SECONDS_TO_MICROSECONDS(SECONDS) (us_timestamp_t)(MICROSECONDS_IN_SECOND * SECONDS)
36-
37-
/**
38-
* Converts microseconds to seconds
39-
*/
40-
#define MICROSECONDS_TO_SECONDS(MICROSECONDS) (s_timestamp_t)(MICROSECONDS / MICROSECONDS_IN_SECOND)
41-
4227
/**
4328
* Legacy format representing a timestamp in us.
4429
* Given it is modeled as a 32 bit integer, this type can represent timestamp

0 commit comments

Comments
 (0)