-
-
Notifications
You must be signed in to change notification settings - Fork 175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement HAL_Time_TicksToTimeMilliSec #145
Changes from 1 commit
324aa34
5f5385a
3a7be06
9881e21
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,6 @@ | |
// See LICENSE file in the project root for full license information. | ||
// | ||
|
||
//#include <stdint.h> | ||
//#include <cmsis_os.h> | ||
#include <nanoHAL_Time.h> | ||
|
||
////////////////////////////////////////// | ||
|
@@ -13,8 +11,8 @@ typedef unsigned int UINT32; | |
typedef signed int INT32; | ||
////////////////////////////////////////// | ||
|
||
// Converts ticks (CMSIS sysTicks) in miliseconds | ||
// Converts ticks (CMSIS sysTicks) to microseconds | ||
INT32 HAL_Time_TicksToTimeMicroSec(UINT32 ticks) { | ||
// T[s] = 1 / f[Hz] | ||
return (ticks / (osKernelSysTickFrequency * NANOHAL_TIME_CONVERSION_MILISECONDS)); | ||
return (ticks / (osKernelSysTickFrequency * NANOHAL_TIME_CONVERSION_MICROSECONDS)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was this tested? For STM32F4-Discovery
the multiplication overflows. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Glad you spot this... This made me realize that we don't need micro seconds calculation for timeouts because the sys clock is... milliseconds! |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use a named constant or conversion macro instead of a magic value (*1000). Much easier to track down next time, when the time unit changes :)