Skip to content

Commit 9c649ea

Browse files
Dazza0aggargkar-rahul-aws
authored
Add time conversion macros (#866)
This commit updates the following time conversion macros: - pdMS_TO_TICKS: Added cast to "uint64_t" to prevent overflow - pdTICKS_TO_MS: Added macro to convert ticks to milliseconds Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com> Co-authored-by: Rahul Kar <118818625+kar-rahul-aws@users.noreply.github.com>
1 parent 0640b2e commit 9c649ea

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

include/projdefs.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,14 @@ typedef void (* TaskFunction_t)( void * );
3939
* overridden by a macro of the same name defined in FreeRTOSConfig.h in case the
4040
* definition here is not suitable for your application. */
4141
#ifndef pdMS_TO_TICKS
42-
#define pdMS_TO_TICKS( xTimeInMs ) ( ( TickType_t ) ( ( ( TickType_t ) ( xTimeInMs ) * ( TickType_t ) configTICK_RATE_HZ ) / ( TickType_t ) 1000U ) )
42+
#define pdMS_TO_TICKS( xTimeInMs ) ( ( TickType_t ) ( ( ( uint64_t ) ( xTimeInMs ) * ( uint64_t ) configTICK_RATE_HZ ) / ( uint64_t ) 1000U ) )
43+
#endif
44+
45+
/* Converts a time in ticks to a time in milliseconds. This macro can be
46+
* overridden by a macro of the same name defined in FreeRTOSConfig.h in case the
47+
* definition here is not suitable for your application. */
48+
#ifndef pdTICKS_TO_MS
49+
#define pdTICKS_TO_MS( xTimeInTicks ) ( ( TickType_t ) ( ( ( uint64_t ) ( xTimeInTicks ) * ( uint64_t ) 1000U ) / ( uint64_t ) configTICK_RATE_HZ ) )
4350
#endif
4451

4552
#define pdFALSE ( ( BaseType_t ) 0 )

0 commit comments

Comments
 (0)