This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

z-stack系统时钟问题

在z-stack-2.5.1a中系统时钟所用的定时器四在哪个地方启的

  • 用的是Timer2

    void osalTimeUpdate( void )
    {
    halIntState_t intState;
    uint32 tmp;
    uint32 ticks320us;
    uint16 elapsedMSec = 0;

    HAL_ENTER_CRITICAL_SECTION(intState);
    // Get the free-running count of 320us timer ticks
    tmp = macMcuPrecisionCount();
    HAL_EXIT_CRITICAL_SECTION(intState);

    if ( tmp != previousMacTimerTick )
    {
    // Calculate the elapsed ticks of the free-running timer.
    ticks320us = (tmp - previousMacTimerTick) & 0xffffffffu;

    // Store the MAC Timer tick count for the next time through this function.
    previousMacTimerTick = tmp;

    // update converted number with remaining ticks from loop and the
    // accumulated remainder from loop
    tmp = (ticks320us * 8) + remUsTicks;

    // Convert the 320 us ticks into milliseconds and a remainder
    CONVERT_320US_TO_MS_ELAPSED_REMAINDER( tmp, elapsedMSec, remUsTicks );

    // Update OSAL Clock and Timers
    if ( elapsedMSec )
    {
    osalClockUpdate( elapsedMSec );
    osalTimerUpdate( elapsedMSec );
    }
    }
    }

    /*********************************************************************
    * @fn osalClockUpdate
    *
    * @brief Updates the OSAL Clock time with elapsed milliseconds.
    *
    * @param elapsedMSec - elapsed milliseconds
    *
    * @return none
    */
    static void osalClockUpdate( uint16 elapsedMSec )
    {
    // Add elapsed milliseconds to the saved millisecond portion of time
    timeMSec += elapsedMSec;

    // Roll up milliseconds to the number of seconds
    if ( timeMSec >= 1000 )
    {
    OSAL_timeSeconds += timeMSec / 1000;
    timeMSec = timeMSec % 1000;
    }
    }