forked from Makuna/NeoPixelBus
Use DWT if exposed and present
This commit is contained in:
@@ -169,23 +169,32 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
static inline uint32_t getCycleCount(void)
|
static inline uint32_t getCycleCount(void)
|
||||||
{
|
{
|
||||||
|
#ifdef DWT
|
||||||
|
// use the general exposed access object
|
||||||
|
return DWT->CYCCNT;
|
||||||
|
#else
|
||||||
return *((volatile uint32_t*)0xE0001004);
|
return *((volatile uint32_t*)0xE0001004);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void startCycleCount()
|
static inline void startCycleCount()
|
||||||
{
|
{
|
||||||
// init DWT feature
|
#ifndef DWT
|
||||||
|
// init DWT feature since not exposed for general use
|
||||||
(*((volatile uint32_t*)0xE000EDFC)) |= 0x01000000;
|
(*((volatile uint32_t*)0xE000EDFC)) |= 0x01000000;
|
||||||
// init DWT Count to zero
|
// init DWT Count to zero
|
||||||
*((volatile uint32_t*)0xE0001004) = 0;
|
*((volatile uint32_t*)0xE0001004) = 0;
|
||||||
// start DWT
|
// start DWT
|
||||||
(*(volatile uint32_t*)0xe0001000) |= 0x40000001;
|
(*(volatile uint32_t*)0xe0001000) |= 0x40000001;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void stopCycleCount()
|
static inline void stopCycleCount()
|
||||||
{
|
{
|
||||||
// stop DWT
|
#ifndef DWT
|
||||||
|
// stop DWT since not exposed generally
|
||||||
(*(volatile uint32_t*)0xe0001000) &= ~0x00000001;
|
(*(volatile uint32_t*)0xe0001000) &= ~0x00000001;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user