Skip to content

Commit

Permalink
Merge pull request #169 from mikeodr/pluggable-delay-method
Browse files Browse the repository at this point in the history
Make MillisecondTimer::delay weak
  • Loading branch information
andysworkshop committed Mar 24, 2016
2 parents 20d12f9 + 56f17cc commit 4e58f87
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
16 changes: 1 addition & 15 deletions lib/include/timing/MillisecondTimer.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace stm32plus {

public:
static void initialise();
static void delay(uint32_t millis_);
static void __attribute__ ((weak)) delay(uint32_t millis_);
static uint32_t millis();
static void reset();
static bool hasTimedOut(uint32_t start,uint32_t timeout);
Expand All @@ -42,20 +42,6 @@ namespace stm32plus {
}


/**
* Delay for given time. Waits for the current value of the systick counter to reach a target.
* @param millis The amount of time to wait.
*/

inline void MillisecondTimer::delay(uint32_t millis) {

uint32_t target;

target=_counter+millis;
while(_counter<target);
}


/**
* Reset the counter to zero
*/
Expand Down
14 changes: 14 additions & 0 deletions lib/src/timing/MillisecondTimer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,20 @@ namespace stm32plus {
_counter=0;
SysTick_Config(SystemCoreClock / 1000);
}


/**
* Delay for given time. Waits for the current value of the systick counter to reach a target.
* @param millis The amount of time to wait.
*/

inline void MillisecondTimer::delay(uint32_t millis) {

uint32_t target;

target=_counter+millis;
while(_counter<target);
}
}


Expand Down

0 comments on commit 4e58f87

Please sign in to comment.