-
-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement HAL_Time_TicksToTimeMilliSec (#145)
* Implement HAL_Time_TicksToTimeMicroSec - rename function to HAL_Time_TicksToTimeMicroSec to clarify output - changed the output from 'ticks' (100ns intervals) to miliseconds to follow CMSIS API and because having a time base granularity of 1 milisecond is more than enough (100ns intervals is really too much for an embedded system) this also allows an extra efficiency of using 32bits vars and math for this instead of 64bits - update code accordingly where required - add ChibiOS implementation Signed-off-by: José Simões <[email protected]> * Rework types and adjust code accordingly - adjust return type of HAL_Time_CurrentTicks to uint32_t - update code accordingly - uncomment timeout code in WireProtocol - minor reworks in code per reviewer request Signed-off-by: José Simões <[email protected]> * Rework code to use milliseconds calculations instead of microseconds - as the system clock is in milliseconds it doesn't make sense to be performing the calculations in microseconds - update code accordingly - adjust target ChibiOS config to use 1ms as sys time base - adjust target ChibiOS config to use classic periodic tick (was set to use tick-less) Signed-off-by: José Simões <[email protected]> * Replace code with ChibiOS macro rewrite and correct return type - ChibiOS macro STMS(n) will overflow when doing the math with uint32_t Signed-off-by: José Simões <[email protected]>
- Loading branch information
1 parent
5c0ce2e
commit 4884fe5
Showing
15 changed files
with
76 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// Copyright (c) 2017 The nanoFramework project contributors | ||
// See LICENSE file in the project root for full license information. | ||
// | ||
|
||
#include <nanoHAL_Time.h> | ||
|
||
////////////////////////////////////////// | ||
// TODO delete these when working on #130 | ||
typedef unsigned int UINT32; | ||
typedef signed int INT32; | ||
////////////////////////////////////////// | ||
|
||
// Converts ticks (CMSIS sysTicks) to milliseconds | ||
UINT64 HAL_Time_TicksToTimeMilliSec(UINT32 ticks) { | ||
|
||
// this is a rewrite of ChibiOS ST2MS(n) macro because it will overflow if doing the math using uint32_t | ||
return (((ticks) * 1000ULL + (uint64_t)CH_CFG_ST_FREQUENCY - 1ULL) / (uint64_t)CH_CFG_ST_FREQUENCY); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters