コード例 #1
0
ファイル: temp.c プロジェクト: nodish/openthread
void nrf5TempProcess(void)
{
    int32_t  prevTemperature = sTemperature;
    uint64_t now;

#if SOFTDEVICE_PRESENT
    now = nrf5AlarmGetCurrentTime();

    if (now - sLastReadTimestamp > (TEMP_MEASUREMENT_INTERVAL * US_PER_S))
    {
        (void)sd_temp_get(&sTemperature);
        sLastReadTimestamp = now;
    }
#else
    if (NRF_TEMP->EVENTS_DATARDY)
    {
        dataReadyEventClear();

        sTemperature = nrf_temp_read();
    }

    now = nrf5AlarmGetCurrentTime();

    if (now - sLastReadTimestamp > (TEMP_MEASUREMENT_INTERVAL * US_PER_S))
    {
        NRF_TEMP->TASKS_START = 1;
        sLastReadTimestamp    = now;
    }
#endif

    if (prevTemperature != sTemperature)
    {
        nrf_802154_temperature_changed();
    }
}
コード例 #2
0
ファイル: alarm.c プロジェクト: aeliot/openthread
static void HandleCompareMatch(AlarmIndex aIndex, bool aSkipCheck)
{
    nrf_rtc_event_clear(RTC_INSTANCE, sChannelData[aIndex].mCompareEvent);

    uint64_t usecTime = nrf5AlarmGetCurrentTime();
    uint32_t now;

    if (aIndex == kMsTimer)
    {
        now = (uint32_t)(usecTime / US_PER_MS);
    }
    else
    {
        now = (uint32_t)usecTime;
    }

    // In case the target time was larger than single overflow,
    // we should only strike the timer on final compare event.
    if (aSkipCheck || AlarmShallStrike(now, aIndex))
    {
        nrf_rtc_event_disable(RTC_INSTANCE, sChannelData[aIndex].mCompareEventMask);
        nrf_rtc_int_disable(RTC_INSTANCE, sChannelData[aIndex].mCompareInt);

        sTimerData[aIndex].mFireAlarm = true;
        PlatformEventSignalPending();
    }
}
コード例 #3
0
ファイル: alarm.c プロジェクト: aeliot/openthread
static inline uint32_t AlarmGetCurrentTimeRtcProtected(AlarmIndex aIndex)
{
    uint64_t usecTime = nrf5AlarmGetCurrentTime() + 2 * US_PER_TICK;
    uint32_t currentTime;

    if (aIndex == kMsTimer)
    {
        currentTime = (uint32_t)(usecTime / US_PER_MS);
    }
    else
    {
        currentTime = (uint32_t)usecTime;
    }

    return currentTime;
}
コード例 #4
0
ファイル: radio.c プロジェクト: spark/firmware
void nrf_802154_received_raw(uint8_t *p_data, int8_t power, uint8_t lqi)
#endif
{
    otRadioFrame *receivedFrame = NULL;

    for (uint32_t i = 0; i < NRF_802154_RX_BUFFERS; i++)
    {
        if (sReceivedFrames[i].mPsdu == NULL)
        {
            receivedFrame = &sReceivedFrames[i];

            memset(receivedFrame, 0, sizeof(*receivedFrame));
#if OPENTHREAD_CONFIG_HEADER_IE_SUPPORT
            receivedFrame->mIeInfo = &sReceivedIeInfos[i];
#endif
            break;
        }
    }

    assert(receivedFrame != NULL);

    receivedFrame->mPsdu               = &p_data[1];
    receivedFrame->mLength             = p_data[0];
    receivedFrame->mInfo.mRxInfo.mRssi = power;
    receivedFrame->mInfo.mRxInfo.mLqi  = lqi;
    receivedFrame->mChannel            = nrf_802154_channel_get();
    if (otPlatRadioGetPromiscuous(sInstance))
    {
        uint64_t timestamp                 = nrf5AlarmGetCurrentTime();
        receivedFrame->mInfo.mRxInfo.mMsec = timestamp / US_PER_MS;
        receivedFrame->mInfo.mRxInfo.mUsec = timestamp - receivedFrame->mInfo.mRxInfo.mMsec * US_PER_MS;
    }
#if OPENTHREAD_CONFIG_ENABLE_TIME_SYNC
    // Get the timestamp when the SFD was received.
    uint32_t offset =
        (int32_t)otPlatAlarmMicroGetNow() - (int32_t)nrf_802154_first_symbol_timestamp_get(time, p_data[0]);
    receivedFrame->mIeInfo->mTimestamp = otPlatTimeGet() - offset;
#endif

    otSysEventSignalPending();
}
コード例 #5
0
ファイル: alarm.c プロジェクト: aeliot/openthread
uint32_t otPlatAlarmMicroGetNow(void)
{
    return (uint32_t)nrf5AlarmGetCurrentTime();
}
コード例 #6
0
ファイル: alarm.c プロジェクト: aeliot/openthread
uint32_t otPlatAlarmMilliGetNow(void)
{
    return (uint32_t)(nrf5AlarmGetCurrentTime() / US_PER_MS);
}