File tree 1 file changed +33
-0
lines changed
1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,39 @@ extern "C" {
32
32
/* guard file in case no RTT device was specified */
33
33
#if RTT_NUMOF
34
34
35
+ #ifndef RTT_FREQUENCY
36
+ #warning "RTT_FREQUENCY undefined. Set RTT_FREQUENCY to the number of ticks" \
37
+ "per second for the current architecture."
38
+ #endif
39
+
40
+ /**
41
+ * @brief Convert microseconds to rtt ticks
42
+ * @param[in] us number of microseconds
43
+ * @return rtt ticks
44
+ */
45
+ #define RTT_US_TO_TICKS (us ) ((uint32_t)((uint64_t)(us) * RTT_FREQUENCY / 1000000UL))
46
+
47
+ /**
48
+ * @brief Convert milliseconds to rtt ticks
49
+ * @param[in] ms number of milliseconds
50
+ * @return rtt ticks
51
+ */
52
+ #define RTT_MS_TO_TICKS (ms ) ( RTT_US_TO_TICKS((ms) * 1000) )
53
+
54
+ /**
55
+ * @brief Convert seconds to rtt ticks
56
+ * @param[in] sec number of seconds
57
+ * @return rtt ticks
58
+ */
59
+ #define RTT_SEC_TO_TICKS (sec ) ( RTT_MS_TO_TICKS((sec) * 1000) )
60
+
61
+ /**
62
+ * @brief Convert minutes to rtt ticks
63
+ * @param[in] min number of minutes
64
+ * @return rtt ticks
65
+ */
66
+ #define RTT_MIN_TO_TICKS (min ) ( RTT_SEC_TO_TICKS((min) * 60) )
67
+
35
68
/**
36
69
* @brief Signature for the alarm callback
37
70
*
You can’t perform that action at this time.
0 commit comments