File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change 2121#define _WIRING_TIME_H_
2222
2323#include "clock.h"
24+ #include "dwt.h"
2425
2526#ifdef __cplusplus
2627extern "C" {
@@ -57,14 +58,20 @@ extern void delay(uint32_t dwMs) ;
5758/**
5859 * \brief Pauses the program for the amount of time (in microseconds) specified as parameter.
5960 *
60- * \param dwUs the number of microseconds to pause (uint32_t)
61+ * \param us the number of microseconds to pause (uint32_t)
6162 */
6263static 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 )
6465{
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 );
6669
70+ while ((int32_t )dwt_getCycles () - start < cycles );
71+ #else
72+ uint32_t start = GetCurrentMicro ();
6773 while ((start + usec ) > GetCurrentMicro ());
74+ #endif
6875}
6976
7077#ifdef __cplusplus
You can’t perform that action at this time.
0 commit comments