File tree 1 file changed +10
-3
lines changed
1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change 21
21
#define _WIRING_TIME_H_
22
22
23
23
#include "clock.h"
24
+ #include "dwt.h"
24
25
25
26
#ifdef __cplusplus
26
27
extern "C" {
@@ -57,14 +58,20 @@ extern void delay(uint32_t dwMs) ;
57
58
/**
58
59
* \brief Pauses the program for the amount of time (in microseconds) specified as parameter.
59
60
*
60
- * \param dwUs the number of microseconds to pause (uint32_t)
61
+ * \param us the number of microseconds to pause (uint32_t)
61
62
*/
62
63
static inline void delayMicroseconds (uint32_t ) __attribute__((always_inline , unused ));
63
- static inline void delayMicroseconds (uint32_t usec )
64
+ static inline void delayMicroseconds (uint32_t us )
64
65
{
65
- uint32_t start = GetCurrentMicro ();
66
+ #if defined(DWT_BASE ) && !defined(DWT_DELAY_DISABLED )
67
+ int32_t start = dwt_getCycles ();
68
+ int32_t cycles = us * (SystemCoreClock / 1000000 );
66
69
70
+ while ((int32_t )dwt_getCycles () - start < cycles );
71
+ #else
72
+ uint32_t start = GetCurrentMicro ();
67
73
while ((start + usec ) > GetCurrentMicro ());
74
+ #endif
68
75
}
69
76
70
77
#ifdef __cplusplus
You can’t perform that action at this time.
0 commit comments