@@ -545,49 +545,32 @@ void OS_TimeBase_CallbackThread(osal_id_t timebase_id)
545545 }
546546} /* end OS_TimeBase_CallbackThread */
547547
548- /****************************************************************************************
549- Other Time-Related API Implementation
550- ***************************************************************************************/
551-
552- /*
553- * This is the OSAL-defined interface to the OS Timer tick -
554- * Not sure what it is really useful for since none of the user API timer calls deal with
555- * OS ticks directly.
556- */
557-
558-
559- /*----------------------------------------------------------------
560- *
561- * Function: OS_Tick2Micros
562- *
563- * Purpose: Implemented per public OSAL API
564- * See description in API and header file for detail
565- *
566- *-----------------------------------------------------------------*/
567- int32 OS_Tick2Micros (void )
568- {
569- return (OS_SharedGlobalVars .MicroSecPerTick );
570- } /* end OS_Tick2Micros */
571-
572-
573548/*----------------------------------------------------------------
574549 *
575550 * Function: OS_Milli2Ticks
576551 *
577- * Purpose: Implemented per public OSAL API
578- * See description in API and header file for detail
552+ * Purpose: Internal helper to convert milliseconds to ticks
553+ *
554+ * Returns: OS_SUCCESS on success, OS_ERROR on failure (rollover)
579555 *
580556 *-----------------------------------------------------------------*/
581- int32 OS_Milli2Ticks (uint32 milli_seconds )
557+ int32 OS_Milli2Ticks (uint32 milli_seconds , int * ticks )
582558{
583- unsigned long num_of_ticks ;
584-
585- num_of_ticks = (unsigned long )milli_seconds ;
586- num_of_ticks *= OS_SharedGlobalVars .TicksPerSecond ;
587- num_of_ticks = (num_of_ticks + 999 ) / 1000 ;
588-
589- return ((uint32 )num_of_ticks );
590- } /* end OS_Milli2Ticks */
559+ uint64 num_of_ticks ;
560+ int32 return_code = OS_SUCCESS ;
591561
562+ num_of_ticks = (((uint64 )milli_seconds * OS_SharedGlobalVars .TicksPerSecond ) + 999 ) / 1000 ;
592563
564+ /* Check against maximum int32 (limit from some OS's) */
565+ if (num_of_ticks <= INT_MAX )
566+ {
567+ * ticks = (int )num_of_ticks ;
568+ }
569+ else
570+ {
571+ return_code = OS_ERROR ;
572+ * ticks = 0 ;
573+ }
593574
575+ return return_code ;
576+ } /* end OS_Milli2Ticks */
0 commit comments