mirror of
https://github.com/espressif/openthread.git
synced 2026-08-02 00:57:47 +00:00
[code-style] apply clang-format
This commit is contained in:
@@ -26,9 +26,9 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <openthread/config.h>
|
||||
#include <openthread-core-config.h>
|
||||
#include <assert.h>
|
||||
#include <openthread-core-config.h>
|
||||
#include <openthread/config.h>
|
||||
|
||||
#include <openthread/cli.h>
|
||||
#include <openthread/diag.h>
|
||||
@@ -59,8 +59,8 @@ int main(int argc, char *argv[])
|
||||
otInstance *sInstance;
|
||||
|
||||
#if OPENTHREAD_ENABLE_MULTIPLE_INSTANCES
|
||||
size_t otInstanceBufferLength = 0;
|
||||
uint8_t *otInstanceBuffer = NULL;
|
||||
size_t otInstanceBufferLength = 0;
|
||||
uint8_t *otInstanceBuffer = NULL;
|
||||
#endif
|
||||
|
||||
PlatformInit(argc, argv);
|
||||
@@ -92,9 +92,9 @@ int main(int argc, char *argv[])
|
||||
PlatformProcessDrivers(sInstance);
|
||||
}
|
||||
|
||||
// otInstanceFinalize(sInstance);
|
||||
// otInstanceFinalize(sInstance);
|
||||
#if OPENTHREAD_ENABLE_MULTIPLE_INSTANCES
|
||||
// free(otInstanceBuffer);
|
||||
// free(otInstanceBuffer);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -26,9 +26,9 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <openthread/config.h>
|
||||
#include <openthread-core-config.h>
|
||||
#include <assert.h>
|
||||
#include <openthread-core-config.h>
|
||||
#include <openthread/config.h>
|
||||
|
||||
#include <openthread/diag.h>
|
||||
#include <openthread/ncp.h>
|
||||
@@ -58,8 +58,8 @@ int main(int argc, char *argv[])
|
||||
otInstance *sInstance;
|
||||
|
||||
#if OPENTHREAD_ENABLE_MULTIPLE_INSTANCES
|
||||
size_t otInstanceBufferLength = 0;
|
||||
uint8_t *otInstanceBuffer = NULL;
|
||||
size_t otInstanceBufferLength = 0;
|
||||
uint8_t *otInstanceBuffer = NULL;
|
||||
#endif
|
||||
|
||||
PlatformInit(argc, argv);
|
||||
@@ -91,18 +91,17 @@ int main(int argc, char *argv[])
|
||||
PlatformProcessDrivers(sInstance);
|
||||
}
|
||||
|
||||
// otInstanceFinalize(sInstance);
|
||||
// otInstanceFinalize(sInstance);
|
||||
#if OPENTHREAD_ENABLE_MULTIPLE_INSTANCES
|
||||
// free(otInstanceBuffer);
|
||||
// free(otInstanceBuffer);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Provide, if required an "otPlatLog()" function
|
||||
*/
|
||||
/*
|
||||
* Provide, if required an "otPlatLog()" function
|
||||
*/
|
||||
|
||||
#if (OPENTHREAD_CONFIG_LOG_OUTPUT == OPENTHREAD_CONFIG_LOG_OUTPUT_APP)
|
||||
void otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, ...)
|
||||
|
||||
@@ -44,19 +44,19 @@
|
||||
|
||||
enum
|
||||
{
|
||||
kSystemClock = 32000000, ///< MHz
|
||||
kTicksPerSec = 1000, ///< Ticks per second
|
||||
kSystemClock = 32000000, ///< MHz
|
||||
kTicksPerSec = 1000, ///< Ticks per second
|
||||
};
|
||||
|
||||
static uint32_t sCounter = 0;
|
||||
static uint32_t sAlarmT0 = 0;
|
||||
static uint32_t sAlarmDt = 0;
|
||||
static bool sIsRunning = false;
|
||||
static uint32_t sCounter = 0;
|
||||
static uint32_t sAlarmT0 = 0;
|
||||
static uint32_t sAlarmDt = 0;
|
||||
static bool sIsRunning = false;
|
||||
|
||||
void cc2538AlarmInit(void)
|
||||
{
|
||||
HWREG(NVIC_ST_RELOAD) = kSystemClock / kTicksPerSec;
|
||||
HWREG(NVIC_ST_CTRL) = NVIC_ST_CTRL_CLK_SRC | NVIC_ST_CTRL_INTEN | NVIC_ST_CTRL_ENABLE;
|
||||
HWREG(NVIC_ST_CTRL) = NVIC_ST_CTRL_CLK_SRC | NVIC_ST_CTRL_INTEN | NVIC_ST_CTRL_ENABLE;
|
||||
}
|
||||
|
||||
uint32_t otPlatAlarmMilliGetNow(void)
|
||||
@@ -67,8 +67,8 @@ uint32_t otPlatAlarmMilliGetNow(void)
|
||||
void otPlatAlarmMilliStartAt(otInstance *aInstance, uint32_t t0, uint32_t dt)
|
||||
{
|
||||
(void)aInstance;
|
||||
sAlarmT0 = t0;
|
||||
sAlarmDt = dt;
|
||||
sAlarmT0 = t0;
|
||||
sAlarmDt = dt;
|
||||
sIsRunning = true;
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ void otPlatAlarmMilliStop(otInstance *aInstance)
|
||||
void cc2538AlarmProcess(otInstance *aInstance)
|
||||
{
|
||||
uint32_t expires;
|
||||
bool fire = false;
|
||||
bool fire = false;
|
||||
|
||||
if (sIsRunning)
|
||||
{
|
||||
@@ -119,7 +119,6 @@ void cc2538AlarmProcess(otInstance *aInstance)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SysTick_Handler()
|
||||
|
||||
@@ -26,8 +26,8 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <openthread/config.h>
|
||||
#include <openthread-core-config.h>
|
||||
#include <openthread/config.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
@@ -42,7 +42,7 @@
|
||||
#include "utils/flash.h"
|
||||
#include "utils/wrap_string.h"
|
||||
|
||||
#define FLASH_CTRL_FCTL_BUSY 0x00000080
|
||||
#define FLASH_CTRL_FCTL_BUSY 0x00000080
|
||||
|
||||
#if SETTINGS_CONFIG_PAGE_SIZE != 2048
|
||||
#error FLASH page size is 2048 on this chip
|
||||
@@ -102,16 +102,16 @@ uint32_t utilsFlashGetSize(void)
|
||||
|
||||
otError utilsFlashErasePage(uint32_t aAddress)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
int32_t status;
|
||||
otError error = OT_ERROR_NONE;
|
||||
int32_t status;
|
||||
uint32_t address;
|
||||
|
||||
otEXPECT_ACTION(aAddress < utilsFlashGetSize(), error = OT_ERROR_INVALID_ARGS);
|
||||
|
||||
address = aAddress - (aAddress & (SETTINGS_CONFIG_PAGE_SIZE - 1));
|
||||
address = flashPhysAddr(address);
|
||||
status = ROM_PageErase(address, SETTINGS_CONFIG_PAGE_SIZE);
|
||||
error = romStatusToThread(status);
|
||||
status = ROM_PageErase(address, SETTINGS_CONFIG_PAGE_SIZE);
|
||||
error = romStatusToThread(status);
|
||||
|
||||
exit:
|
||||
return error;
|
||||
@@ -119,9 +119,9 @@ exit:
|
||||
|
||||
otError utilsFlashStatusWait(uint32_t aTimeout)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint32_t start = otPlatAlarmMilliGetNow();
|
||||
uint32_t busy = 1;
|
||||
uint32_t busy = 1;
|
||||
|
||||
while (busy && ((otPlatAlarmMilliGetNow() - start) < aTimeout))
|
||||
{
|
||||
@@ -136,13 +136,12 @@ exit:
|
||||
|
||||
uint32_t utilsFlashWrite(uint32_t aAddress, uint8_t *aData, uint32_t aSize)
|
||||
{
|
||||
int32_t status;
|
||||
uint32_t busy = 1;
|
||||
int32_t status;
|
||||
uint32_t busy = 1;
|
||||
uint32_t *data;
|
||||
uint32_t size = 0;
|
||||
uint32_t size = 0;
|
||||
|
||||
otEXPECT_ACTION(((aAddress + aSize) < utilsFlashGetSize()) &&
|
||||
(!(aAddress & 3)) && (!(aSize & 3)), aSize = 0);
|
||||
otEXPECT_ACTION(((aAddress + aSize) < utilsFlashGetSize()) && (!(aAddress & 3)) && (!(aSize & 3)), aSize = 0);
|
||||
|
||||
data = (uint32_t *)(aData);
|
||||
|
||||
@@ -173,8 +172,8 @@ uint32_t utilsFlashRead(uint32_t aAddress, uint8_t *aData, uint32_t aSize)
|
||||
|
||||
while (size < aSize)
|
||||
{
|
||||
uint8_t *byte = (uint8_t *)flashPhysAddr(aAddress);
|
||||
uint8_t maxIndex = 4;
|
||||
uint8_t *byte = (uint8_t *)flashPhysAddr(aAddress);
|
||||
uint8_t maxIndex = 4;
|
||||
|
||||
if (size == (aSize - aSize % 4))
|
||||
{
|
||||
|
||||
@@ -27,15 +27,15 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file logging.c
|
||||
* Platform abstraction for the logging
|
||||
*
|
||||
*/
|
||||
#include <openthread/config.h>
|
||||
* @file logging.c
|
||||
* Platform abstraction for the logging
|
||||
*
|
||||
*/
|
||||
#include <openthread-core-config.h>
|
||||
#include <openthread/config.h>
|
||||
#include <openthread/platform/logging.h>
|
||||
|
||||
#if (OPENTHREAD_CONFIG_LOG_OUTPUT == OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED)
|
||||
#if (OPENTHREAD_CONFIG_LOG_OUTPUT == OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED)
|
||||
void otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, ...)
|
||||
{
|
||||
(void)aLogLevel;
|
||||
@@ -43,4 +43,3 @@ void otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat
|
||||
(void)aFormat;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -35,9 +35,9 @@
|
||||
#ifndef PLATFORM_CC2538_H_
|
||||
#define PLATFORM_CC2538_H_
|
||||
|
||||
#include <openthread/config.h>
|
||||
#include <openthread-core-config.h>
|
||||
#include <stdint.h>
|
||||
#include <openthread/config.h>
|
||||
|
||||
#include <openthread/types.h>
|
||||
|
||||
@@ -91,4 +91,4 @@ void cc2538RandomInit(void);
|
||||
*/
|
||||
void cc2538UartProcess(void);
|
||||
|
||||
#endif // PLATFORM_CC2538_H_
|
||||
#endif // PLATFORM_CC2538_H_
|
||||
|
||||
@@ -31,8 +31,8 @@
|
||||
* @brief
|
||||
* This file includes the platform-specific initializers.
|
||||
*/
|
||||
#include <openthread/config.h>
|
||||
#include "platform-cc2538.h"
|
||||
#include <openthread/config.h>
|
||||
|
||||
otInstance *sInstance;
|
||||
|
||||
|
||||
@@ -44,19 +44,19 @@
|
||||
|
||||
enum
|
||||
{
|
||||
IEEE802154_MIN_LENGTH = 5,
|
||||
IEEE802154_MAX_LENGTH = 127,
|
||||
IEEE802154_ACK_LENGTH = 5,
|
||||
IEEE802154_MIN_LENGTH = 5,
|
||||
IEEE802154_MAX_LENGTH = 127,
|
||||
IEEE802154_ACK_LENGTH = 5,
|
||||
IEEE802154_FRAME_TYPE_MASK = 0x7,
|
||||
IEEE802154_FRAME_TYPE_ACK = 0x2,
|
||||
IEEE802154_FRAME_PENDING = 1 << 4,
|
||||
IEEE802154_ACK_REQUEST = 1 << 5,
|
||||
IEEE802154_DSN_OFFSET = 2,
|
||||
IEEE802154_FRAME_TYPE_ACK = 0x2,
|
||||
IEEE802154_FRAME_PENDING = 1 << 4,
|
||||
IEEE802154_ACK_REQUEST = 1 << 5,
|
||||
IEEE802154_DSN_OFFSET = 2,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CC2538_RSSI_OFFSET = 73,
|
||||
CC2538_RSSI_OFFSET = 73,
|
||||
CC2538_CRC_BIT_MASK = 0x80,
|
||||
CC2538_LQI_BIT_MASK = 0x7f,
|
||||
};
|
||||
@@ -73,36 +73,35 @@ typedef struct TxPowerTable
|
||||
} TxPowerTable;
|
||||
|
||||
// The transmit power table, the values are from SmartRF Studio 2.4.0
|
||||
static const TxPowerTable sTxPowerTable[] =
|
||||
{
|
||||
{ 7, 0xFF }, //
|
||||
{ 5, 0xED }, //
|
||||
{ 3, 0xD5 }, //
|
||||
{ 1, 0xC5 }, //
|
||||
{ 0, 0xB6 }, //
|
||||
{ -1, 0xB0 }, //
|
||||
{ -3, 0xA1 }, //
|
||||
{ -5, 0x91 }, //
|
||||
{ -7, 0x88 }, //
|
||||
{ -9, 0x72 }, //
|
||||
{ -11, 0x62 }, //
|
||||
{ -13, 0x58 }, //
|
||||
{ -15, 0x42 }, //
|
||||
{ -24, 0x00 }, //
|
||||
static const TxPowerTable sTxPowerTable[] = {
|
||||
{7, 0xFF}, //
|
||||
{5, 0xED}, //
|
||||
{3, 0xD5}, //
|
||||
{1, 0xC5}, //
|
||||
{0, 0xB6}, //
|
||||
{-1, 0xB0}, //
|
||||
{-3, 0xA1}, //
|
||||
{-5, 0x91}, //
|
||||
{-7, 0x88}, //
|
||||
{-9, 0x72}, //
|
||||
{-11, 0x62}, //
|
||||
{-13, 0x58}, //
|
||||
{-15, 0x42}, //
|
||||
{-24, 0x00}, //
|
||||
};
|
||||
|
||||
static otRadioFrame sTransmitFrame;
|
||||
static otRadioFrame sReceiveFrame;
|
||||
static otError sTransmitError;
|
||||
static otError sReceiveError;
|
||||
static otError sTransmitError;
|
||||
static otError sReceiveError;
|
||||
|
||||
static uint8_t sTransmitPsdu[IEEE802154_MAX_LENGTH];
|
||||
static uint8_t sReceivePsdu[IEEE802154_MAX_LENGTH];
|
||||
static uint8_t sChannel = 0;
|
||||
static int8_t sTxPower = 0;
|
||||
static int8_t sTxPower = 0;
|
||||
|
||||
static otRadioState sState = OT_RADIO_STATE_DISABLED;
|
||||
static bool sIsReceiverEnabled = false;
|
||||
static otRadioState sState = OT_RADIO_STATE_DISABLED;
|
||||
static bool sIsReceiverEnabled = false;
|
||||
|
||||
void enableReceiver(void)
|
||||
{
|
||||
@@ -116,7 +115,7 @@ void enableReceiver(void)
|
||||
|
||||
// enable receiver
|
||||
HWREG(RFCORE_SFR_RFST) = RFCORE_SFR_RFST_INSTR_RXON;
|
||||
sIsReceiverEnabled = true;
|
||||
sIsReceiverEnabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,7 +125,8 @@ void disableReceiver(void)
|
||||
{
|
||||
otLogInfoPlat(sInstance, "Disabling receiver", NULL);
|
||||
|
||||
while (HWREG(RFCORE_XREG_FSMSTAT1) & RFCORE_XREG_FSMSTAT1_TX_ACTIVE);
|
||||
while (HWREG(RFCORE_XREG_FSMSTAT1) & RFCORE_XREG_FSMSTAT1_TX_ACTIVE)
|
||||
;
|
||||
|
||||
// flush rxfifo
|
||||
HWREG(RFCORE_SFR_RFST) = RFCORE_SFR_RFST_INSTR_FLUSHRX;
|
||||
@@ -157,7 +157,7 @@ void setChannel(uint8_t aChannel)
|
||||
otLogInfoPlat(sInstance, "Channel=%d", aChannel);
|
||||
|
||||
HWREG(RFCORE_XREG_FREQCTRL) = 11 + (aChannel - 11) * 5;
|
||||
sChannel = aChannel;
|
||||
sChannel = aChannel;
|
||||
|
||||
if (enabled)
|
||||
{
|
||||
@@ -183,7 +183,7 @@ void setTxPower(int8_t aTxPower)
|
||||
}
|
||||
|
||||
HWREG(RFCORE_XREG_TXPOWER) = sTxPowerTable[i].mTxPowerReg;
|
||||
sTxPower = aTxPower;
|
||||
sTxPower = aTxPower;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -212,9 +212,8 @@ void otPlatRadioSetExtendedAddress(otInstance *aInstance, const otExtAddress *aA
|
||||
{
|
||||
(void)aInstance;
|
||||
|
||||
otLogInfoPlat(sInstance, "ExtAddr=%X%X%X%X%X%X%X%X",
|
||||
aAddress->m8[7], aAddress->m8[6], aAddress->m8[5], aAddress->m8[4],
|
||||
aAddress->m8[3], aAddress->m8[2], aAddress->m8[1], aAddress->m8[0]);
|
||||
otLogInfoPlat(sInstance, "ExtAddr=%X%X%X%X%X%X%X%X", aAddress->m8[7], aAddress->m8[6], aAddress->m8[5],
|
||||
aAddress->m8[4], aAddress->m8[3], aAddress->m8[2], aAddress->m8[1], aAddress->m8[0]);
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
@@ -235,9 +234,9 @@ void otPlatRadioSetShortAddress(otInstance *aInstance, uint16_t aAddress)
|
||||
void cc2538RadioInit(void)
|
||||
{
|
||||
sTransmitFrame.mLength = 0;
|
||||
sTransmitFrame.mPsdu = sTransmitPsdu;
|
||||
sReceiveFrame.mLength = 0;
|
||||
sReceiveFrame.mPsdu = sReceivePsdu;
|
||||
sTransmitFrame.mPsdu = sTransmitPsdu;
|
||||
sReceiveFrame.mLength = 0;
|
||||
sReceiveFrame.mPsdu = sReceivePsdu;
|
||||
|
||||
// enable clock
|
||||
HWREG(SYS_CTRL_RCGCRFC) = SYS_CTRL_RCGCRFC_RFC0;
|
||||
@@ -245,11 +244,11 @@ void cc2538RadioInit(void)
|
||||
HWREG(SYS_CTRL_DCGCRFC) = SYS_CTRL_DCGCRFC_RFC0;
|
||||
|
||||
// Table 23-7.
|
||||
HWREG(RFCORE_XREG_AGCCTRL1) = 0x15;
|
||||
HWREG(RFCORE_XREG_TXFILTCFG) = 0x09;
|
||||
HWREG(RFCORE_XREG_AGCCTRL1) = 0x15;
|
||||
HWREG(RFCORE_XREG_TXFILTCFG) = 0x09;
|
||||
HWREG(ANA_REGS_BASE + ANA_REGS_O_IVCTRL) = 0x0b;
|
||||
|
||||
HWREG(RFCORE_XREG_CCACTRL0) = 0xf8;
|
||||
HWREG(RFCORE_XREG_CCACTRL0) = 0xf8;
|
||||
HWREG(RFCORE_XREG_FIFOPCTRL) = IEEE802154_MAX_LENGTH;
|
||||
|
||||
HWREG(RFCORE_XREG_FRMCTRL0) = RFCORE_XREG_FRMCTRL0_AUTOCRC | RFCORE_XREG_FRMCTRL0_AUTOACK;
|
||||
@@ -258,7 +257,7 @@ void cc2538RadioInit(void)
|
||||
// SRCMATCH.PEND_DATAREQ_ONLY(1), RFCORE_XREG_FRMCTRL1_PENDING_OR(0)
|
||||
|
||||
HWREG(RFCORE_XREG_TXPOWER) = sTxPowerTable[0].mTxPowerReg;
|
||||
sTxPower = sTxPowerTable[0].mTxPowerVal;
|
||||
sTxPower = sTxPowerTable[0].mTxPowerVal;
|
||||
|
||||
otLogInfoPlat(sInstance, "Initialized", NULL);
|
||||
}
|
||||
@@ -299,7 +298,7 @@ otError otPlatRadioSleep(otInstance *aInstance)
|
||||
if (sState == OT_RADIO_STATE_SLEEP || sState == OT_RADIO_STATE_RECEIVE)
|
||||
{
|
||||
otLogDebgPlat(sInstance, "State=OT_RADIO_STATE_SLEEP", NULL);
|
||||
error = OT_ERROR_NONE;
|
||||
error = OT_ERROR_NONE;
|
||||
sState = OT_RADIO_STATE_SLEEP;
|
||||
disableReceiver();
|
||||
}
|
||||
@@ -316,7 +315,7 @@ otError otPlatRadioReceive(otInstance *aInstance, uint8_t aChannel)
|
||||
{
|
||||
otLogDebgPlat(sInstance, "State=OT_RADIO_STATE_RECEIVE", NULL);
|
||||
|
||||
error = OT_ERROR_NONE;
|
||||
error = OT_ERROR_NONE;
|
||||
sState = OT_RADIO_STATE_RECEIVE;
|
||||
setChannel(aChannel);
|
||||
sReceiveFrame.mChannel = aChannel;
|
||||
@@ -335,11 +334,12 @@ otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aFrame)
|
||||
{
|
||||
int i;
|
||||
|
||||
error = OT_ERROR_NONE;
|
||||
sState = OT_RADIO_STATE_TRANSMIT;
|
||||
error = OT_ERROR_NONE;
|
||||
sState = OT_RADIO_STATE_TRANSMIT;
|
||||
sTransmitError = OT_ERROR_NONE;
|
||||
|
||||
while (HWREG(RFCORE_XREG_FSMSTAT1) & RFCORE_XREG_FSMSTAT1_TX_ACTIVE);
|
||||
while (HWREG(RFCORE_XREG_FSMSTAT1) & RFCORE_XREG_FSMSTAT1_TX_ACTIVE)
|
||||
;
|
||||
|
||||
// flush txfifo
|
||||
HWREG(RFCORE_SFR_RFST) = RFCORE_SFR_RFST_INSTR_FLUSHTX;
|
||||
@@ -356,10 +356,12 @@ otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aFrame)
|
||||
|
||||
setChannel(aFrame->mChannel);
|
||||
|
||||
while ((HWREG(RFCORE_XREG_FSMSTAT1) & 1) == 0);
|
||||
while ((HWREG(RFCORE_XREG_FSMSTAT1) & 1) == 0)
|
||||
;
|
||||
|
||||
// wait for valid rssi
|
||||
while ((HWREG(RFCORE_XREG_RSSISTAT) & RFCORE_XREG_RSSISTAT_RSSI_VALID) == 0);
|
||||
while ((HWREG(RFCORE_XREG_RSSISTAT) & RFCORE_XREG_RSSISTAT_RSSI_VALID) == 0)
|
||||
;
|
||||
|
||||
otEXPECT_ACTION(((HWREG(RFCORE_XREG_FSMSTAT1) & RFCORE_XREG_FSMSTAT1_CCA) &&
|
||||
!((HWREG(RFCORE_XREG_FSMSTAT1) & RFCORE_XREG_FSMSTAT1_SFD))),
|
||||
@@ -370,7 +372,8 @@ otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aFrame)
|
||||
|
||||
otPlatRadioTxStarted(aInstance, aFrame);
|
||||
|
||||
while (HWREG(RFCORE_XREG_FSMSTAT1) & RFCORE_XREG_FSMSTAT1_TX_ACTIVE);
|
||||
while (HWREG(RFCORE_XREG_FSMSTAT1) & RFCORE_XREG_FSMSTAT1_TX_ACTIVE)
|
||||
;
|
||||
|
||||
otLogDebgPlat(sInstance, "Transmitted %d bytes", aFrame->mLength);
|
||||
}
|
||||
@@ -423,7 +426,7 @@ void readFrame(void)
|
||||
{
|
||||
uint8_t length;
|
||||
uint8_t crcCorr;
|
||||
int i;
|
||||
int i;
|
||||
|
||||
otEXPECT(sState == OT_RADIO_STATE_RECEIVE || sState == OT_RADIO_STATE_TRANSMIT);
|
||||
otEXPECT((HWREG(RFCORE_XREG_FSMSTAT1) & RFCORE_XREG_FSMSTAT1_FIFOP) != 0);
|
||||
@@ -435,7 +438,7 @@ void readFrame(void)
|
||||
#if OPENTHREAD_ENABLE_RAW_LINK_API
|
||||
// Timestamp
|
||||
sReceiveFrame.mMsec = otPlatAlarmMilliGetNow();
|
||||
sReceiveFrame.mUsec = 0; // Don't support microsecond timer for now.
|
||||
sReceiveFrame.mUsec = 0; // Don't support microsecond timer for now.
|
||||
#endif
|
||||
|
||||
// read psdu
|
||||
@@ -445,12 +448,12 @@ void readFrame(void)
|
||||
}
|
||||
|
||||
sReceiveFrame.mRssi = (int8_t)HWREG(RFCORE_SFR_RFDATA) - CC2538_RSSI_OFFSET;
|
||||
crcCorr = HWREG(RFCORE_SFR_RFDATA);
|
||||
crcCorr = HWREG(RFCORE_SFR_RFDATA);
|
||||
|
||||
if (crcCorr & CC2538_CRC_BIT_MASK)
|
||||
{
|
||||
sReceiveFrame.mLength = length;
|
||||
sReceiveFrame.mLqi = crcCorr & CC2538_LQI_BIT_MASK;
|
||||
sReceiveFrame.mLqi = crcCorr & CC2538_LQI_BIT_MASK;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -548,8 +551,8 @@ void RFCoreErrIntHandler(void)
|
||||
|
||||
uint32_t getSrcMatchEntriesEnableStatus(bool aShort)
|
||||
{
|
||||
uint32_t status = 0;
|
||||
uint32_t *addr = aShort ? (uint32_t *) RFCORE_XREG_SRCSHORTEN0 : (uint32_t *) RFCORE_XREG_SRCEXTEN0;
|
||||
uint32_t status = 0;
|
||||
uint32_t *addr = aShort ? (uint32_t *)RFCORE_XREG_SRCSHORTEN0 : (uint32_t *)RFCORE_XREG_SRCEXTEN0;
|
||||
|
||||
for (uint8_t i = 0; i < RFCORE_XREG_SRCMATCH_ENABLE_STATUS_SIZE; i++)
|
||||
{
|
||||
@@ -561,11 +564,11 @@ uint32_t getSrcMatchEntriesEnableStatus(bool aShort)
|
||||
|
||||
int8_t findSrcMatchShortEntry(const uint16_t aShortAddress)
|
||||
{
|
||||
int8_t entry = -1;
|
||||
uint16_t shortAddr;
|
||||
uint32_t bitMask;
|
||||
uint32_t *addr = NULL;
|
||||
uint32_t status = getSrcMatchEntriesEnableStatus(true);
|
||||
int8_t entry = -1;
|
||||
uint16_t shortAddr;
|
||||
uint32_t bitMask;
|
||||
uint32_t *addr = NULL;
|
||||
uint32_t status = getSrcMatchEntriesEnableStatus(true);
|
||||
|
||||
for (uint8_t i = 0; i < RFCORE_XREG_SRCMATCH_SHORT_ENTRIES; i++)
|
||||
{
|
||||
@@ -593,15 +596,15 @@ int8_t findSrcMatchShortEntry(const uint16_t aShortAddress)
|
||||
|
||||
int8_t findSrcMatchExtEntry(const otExtAddress *aExtAddress)
|
||||
{
|
||||
int8_t entry = -1;
|
||||
uint32_t bitMask;
|
||||
uint32_t *addr = NULL;
|
||||
uint32_t status = getSrcMatchEntriesEnableStatus(false);
|
||||
int8_t entry = -1;
|
||||
uint32_t bitMask;
|
||||
uint32_t *addr = NULL;
|
||||
uint32_t status = getSrcMatchEntriesEnableStatus(false);
|
||||
|
||||
for (uint8_t i = 0; i < RFCORE_XREG_SRCMATCH_EXT_ENTRIES; i++)
|
||||
{
|
||||
uint8_t j = 0;
|
||||
bitMask = 0x00000001 << 2 * i;
|
||||
bitMask = 0x00000001 << 2 * i;
|
||||
|
||||
if ((status & bitMask) == 0)
|
||||
{
|
||||
@@ -630,11 +633,11 @@ int8_t findSrcMatchExtEntry(const otExtAddress *aExtAddress)
|
||||
|
||||
void setSrcMatchEntryEnableStatus(bool aShort, uint8_t aEntry, bool aEnable)
|
||||
{
|
||||
uint8_t entry = aShort ? aEntry : (2 * aEntry);
|
||||
uint8_t index = entry / 8;
|
||||
uint32_t *addrEn = aShort ? (uint32_t *)RFCORE_XREG_SRCSHORTEN0 : (uint32_t *)RFCORE_XREG_SRCEXTEN0;
|
||||
uint8_t entry = aShort ? aEntry : (2 * aEntry);
|
||||
uint8_t index = entry / 8;
|
||||
uint32_t *addrEn = aShort ? (uint32_t *)RFCORE_XREG_SRCSHORTEN0 : (uint32_t *)RFCORE_XREG_SRCEXTEN0;
|
||||
uint32_t *addrAutoPendEn = aShort ? (uint32_t *)RFCORE_FFSM_SRCSHORTPENDEN0 : (uint32_t *)RFCORE_FFSM_SRCEXTPENDEN0;
|
||||
uint32_t bitMask = 0x00000001;
|
||||
uint32_t bitMask = 0x00000001;
|
||||
|
||||
if (aEnable)
|
||||
{
|
||||
@@ -650,10 +653,10 @@ void setSrcMatchEntryEnableStatus(bool aShort, uint8_t aEntry, bool aEnable)
|
||||
|
||||
int8_t findSrcMatchAvailEntry(bool aShort)
|
||||
{
|
||||
int8_t entry = -1;
|
||||
int8_t entry = -1;
|
||||
uint32_t bitMask;
|
||||
uint32_t shortEnableStatus = getSrcMatchEntriesEnableStatus(true);
|
||||
uint32_t extEnableStatus = getSrcMatchEntriesEnableStatus(false);
|
||||
uint32_t extEnableStatus = getSrcMatchEntriesEnableStatus(false);
|
||||
|
||||
otLogDebgPlat(sInstance, "Short enable status: 0x%x", shortEnableStatus);
|
||||
otLogDebgPlat(sInstance, "Ext enable status: 0x%x", extEnableStatus);
|
||||
@@ -693,7 +696,7 @@ int8_t findSrcMatchAvailEntry(bool aShort)
|
||||
break;
|
||||
}
|
||||
|
||||
extEnableStatus = extEnableStatus >> 2;
|
||||
extEnableStatus = extEnableStatus >> 2;
|
||||
shortEnableStatus = shortEnableStatus >> 2;
|
||||
}
|
||||
}
|
||||
@@ -722,9 +725,9 @@ void otPlatRadioEnableSrcMatch(otInstance *aInstance, bool aEnable)
|
||||
|
||||
otError otPlatRadioAddSrcMatchShortEntry(otInstance *aInstance, const uint16_t aShortAddress)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
int8_t entry = findSrcMatchAvailEntry(true);
|
||||
uint32_t *addr = (uint32_t *)RFCORE_FFSM_SRCADDRESS_TABLE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
int8_t entry = findSrcMatchAvailEntry(true);
|
||||
uint32_t *addr = (uint32_t *)RFCORE_FFSM_SRCADDRESS_TABLE;
|
||||
(void)aInstance;
|
||||
|
||||
otLogDebgPlat(sInstance, "Add ShortAddr entry: %d", entry);
|
||||
@@ -746,9 +749,9 @@ exit:
|
||||
|
||||
otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
int8_t entry = findSrcMatchAvailEntry(false);
|
||||
uint32_t *addr = (uint32_t *)RFCORE_FFSM_SRCADDRESS_TABLE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
int8_t entry = findSrcMatchAvailEntry(false);
|
||||
uint32_t *addr = (uint32_t *)RFCORE_FFSM_SRCADDRESS_TABLE;
|
||||
(void)aInstance;
|
||||
|
||||
otLogDebgPlat(sInstance, "Add ExtAddr entry: %d", entry);
|
||||
@@ -771,7 +774,7 @@ exit:
|
||||
otError otPlatRadioClearSrcMatchShortEntry(otInstance *aInstance, const uint16_t aShortAddress)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
int8_t entry = findSrcMatchShortEntry(aShortAddress);
|
||||
int8_t entry = findSrcMatchShortEntry(aShortAddress);
|
||||
(void)aInstance;
|
||||
|
||||
otLogDebgPlat(sInstance, "Clear ShortAddr entry: %d", entry);
|
||||
@@ -787,7 +790,7 @@ exit:
|
||||
otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
int8_t entry = findSrcMatchExtEntry(aExtAddress);
|
||||
int8_t entry = findSrcMatchExtEntry(aExtAddress);
|
||||
(void)aInstance;
|
||||
|
||||
otLogDebgPlat(sInstance, "Clear ExtAddr entry: %d", entry);
|
||||
@@ -802,7 +805,7 @@ exit:
|
||||
|
||||
void otPlatRadioClearSrcMatchShortEntries(otInstance *aInstance)
|
||||
{
|
||||
uint32_t *addrEn = (uint32_t *)RFCORE_XREG_SRCSHORTEN0;
|
||||
uint32_t *addrEn = (uint32_t *)RFCORE_XREG_SRCSHORTEN0;
|
||||
uint32_t *addrAutoPendEn = (uint32_t *)RFCORE_FFSM_SRCSHORTPENDEN0;
|
||||
(void)aInstance;
|
||||
|
||||
@@ -810,14 +813,14 @@ void otPlatRadioClearSrcMatchShortEntries(otInstance *aInstance)
|
||||
|
||||
for (uint8_t i = 0; i < RFCORE_XREG_SRCMATCH_ENABLE_STATUS_SIZE; i++)
|
||||
{
|
||||
HWREG(addrEn++) = 0;
|
||||
HWREG(addrEn++) = 0;
|
||||
HWREG(addrAutoPendEn++) = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void otPlatRadioClearSrcMatchExtEntries(otInstance *aInstance)
|
||||
{
|
||||
uint32_t *addrEn = (uint32_t *)RFCORE_XREG_SRCEXTEN0;
|
||||
uint32_t *addrEn = (uint32_t *)RFCORE_XREG_SRCEXTEN0;
|
||||
uint32_t *addrAutoPendEn = (uint32_t *)RFCORE_FFSM_SRCEXTPENDEN0;
|
||||
(void)aInstance;
|
||||
|
||||
@@ -825,7 +828,7 @@ void otPlatRadioClearSrcMatchExtEntries(otInstance *aInstance)
|
||||
|
||||
for (uint8_t i = 0; i < RFCORE_XREG_SRCMATCH_ENABLE_STATUS_SIZE; i++)
|
||||
{
|
||||
HWREG(addrEn++) = 0;
|
||||
HWREG(addrEn++) = 0;
|
||||
HWREG(addrAutoPendEn++) = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,12 +44,14 @@ static void generateRandom(uint8_t *aOutput, uint16_t aOutputLength)
|
||||
HWREG(SOC_ADC_ADCCON1) &= ~(SOC_ADC_ADCCON1_RCTRL1 | SOC_ADC_ADCCON1_RCTRL0);
|
||||
HWREG(SYS_CTRL_RCGCRFC) = SYS_CTRL_RCGCRFC_RFC0;
|
||||
|
||||
while (HWREG(SYS_CTRL_RCGCRFC) != SYS_CTRL_RCGCRFC_RFC0);
|
||||
while (HWREG(SYS_CTRL_RCGCRFC) != SYS_CTRL_RCGCRFC_RFC0)
|
||||
;
|
||||
|
||||
HWREG(RFCORE_XREG_FRMCTRL0) = RFCORE_XREG_FRMCTRL0_INFINITY_RX;
|
||||
HWREG(RFCORE_SFR_RFST) = RFCORE_SFR_RFST_INSTR_RXON;
|
||||
HWREG(RFCORE_SFR_RFST) = RFCORE_SFR_RFST_INSTR_RXON;
|
||||
|
||||
while (!HWREG(RFCORE_XREG_RSSISTAT) & RFCORE_XREG_RSSISTAT_RSSI_VALID);
|
||||
while (!HWREG(RFCORE_XREG_RSSISTAT) & RFCORE_XREG_RSSISTAT_RSSI_VALID)
|
||||
;
|
||||
|
||||
for (uint16_t index = 0; index < aOutputLength; index++)
|
||||
{
|
||||
@@ -93,7 +95,7 @@ uint32_t otPlatRandomGet(void)
|
||||
|
||||
otError otPlatRandomGetTrue(uint8_t *aOutput, uint16_t aOutputLength)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint8_t channel = 0;
|
||||
|
||||
otEXPECT_ACTION(aOutput, error = OT_ERROR_INVALID_ARGS);
|
||||
|
||||
@@ -31,29 +31,29 @@
|
||||
|
||||
#define ROM_API_TABLE_ADDR 0x00000048
|
||||
|
||||
typedef uint32_t (* volatile FPTR_CRC32_T)(uint8_t * /*pData*/, uint32_t /*byteCount*/);
|
||||
typedef uint32_t (* volatile FPTR_GETFLSIZE_T)(void);
|
||||
typedef uint32_t (* volatile FPTR_GETCHIPID_T)(void);
|
||||
typedef int32_t (* volatile FPTR_PAGEERASE_T)(uint32_t /*FlashAddr*/, uint32_t /*Size*/);
|
||||
typedef int32_t (* volatile FPTR_PROGFLASH_T)(uint32_t * /*pRamData*/, uint32_t /*FlashAdr*/, uint32_t /*ByteCount*/);
|
||||
typedef void (* volatile FPTR_RESETDEV_T)(void);
|
||||
typedef void *(* volatile FPTR_MEMSET_T)(void * /*s*/, int32_t /*c*/, uint32_t /*n*/);
|
||||
typedef void *(* volatile FPTR_MEMCPY_T)(void * /*s1*/, const void * /*s2*/, uint32_t /*n*/);
|
||||
typedef int32_t (* volatile FPTR_MEMCMP_T)(const void * /*s1*/, const void * /*s2*/, uint32_t /*n*/);
|
||||
typedef void *(* volatile FPTR_MEMMOVE_T)(void * /*s1*/, const void * /*s2*/, uint32_t /*n*/);
|
||||
typedef uint32_t (*volatile FPTR_CRC32_T)(uint8_t * /*pData*/, uint32_t /*byteCount*/);
|
||||
typedef uint32_t (*volatile FPTR_GETFLSIZE_T)(void);
|
||||
typedef uint32_t (*volatile FPTR_GETCHIPID_T)(void);
|
||||
typedef int32_t (*volatile FPTR_PAGEERASE_T)(uint32_t /*FlashAddr*/, uint32_t /*Size*/);
|
||||
typedef int32_t (*volatile FPTR_PROGFLASH_T)(uint32_t * /*pRamData*/, uint32_t /*FlashAdr*/, uint32_t /*ByteCount*/);
|
||||
typedef void (*volatile FPTR_RESETDEV_T)(void);
|
||||
typedef void *(*volatile FPTR_MEMSET_T)(void * /*s*/, int32_t /*c*/, uint32_t /*n*/);
|
||||
typedef void *(*volatile FPTR_MEMCPY_T)(void * /*s1*/, const void * /*s2*/, uint32_t /*n*/);
|
||||
typedef int32_t (*volatile FPTR_MEMCMP_T)(const void * /*s1*/, const void * /*s2*/, uint32_t /*n*/);
|
||||
typedef void *(*volatile FPTR_MEMMOVE_T)(void * /*s1*/, const void * /*s2*/, uint32_t /*n*/);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
FPTR_CRC32_T Crc32;
|
||||
FPTR_GETFLSIZE_T GetFlashSize;
|
||||
FPTR_GETCHIPID_T GetChipId;
|
||||
FPTR_PAGEERASE_T PageErase;
|
||||
FPTR_PROGFLASH_T ProgramFlash;
|
||||
FPTR_RESETDEV_T ResetDevice;
|
||||
FPTR_MEMSET_T memset;
|
||||
FPTR_MEMCPY_T memcpy;
|
||||
FPTR_MEMCMP_T memcmp;
|
||||
FPTR_MEMMOVE_T memmove;
|
||||
FPTR_CRC32_T Crc32;
|
||||
FPTR_GETFLSIZE_T GetFlashSize;
|
||||
FPTR_GETCHIPID_T GetChipId;
|
||||
FPTR_PAGEERASE_T PageErase;
|
||||
FPTR_PROGFLASH_T ProgramFlash;
|
||||
FPTR_RESETDEV_T ResetDevice;
|
||||
FPTR_MEMSET_T memset;
|
||||
FPTR_MEMCPY_T memcpy;
|
||||
FPTR_MEMCMP_T memcmp;
|
||||
FPTR_MEMMOVE_T memmove;
|
||||
} ROM_API_T;
|
||||
|
||||
// clang-format off
|
||||
@@ -73,4 +73,4 @@ typedef struct
|
||||
|
||||
// clang-format on
|
||||
|
||||
#endif // ROM_UTILITY_H_
|
||||
#endif // ROM_UTILITY_H_
|
||||
|
||||
@@ -46,13 +46,26 @@ extern uint8_t _einit_array;
|
||||
|
||||
__extension__ typedef int __guard __attribute__((mode(__DI__)));
|
||||
|
||||
int __cxa_guard_acquire(__guard *g) { return !*(char *)(g); }
|
||||
int __cxa_guard_acquire(__guard *g)
|
||||
{
|
||||
return !*(char *)(g);
|
||||
}
|
||||
|
||||
void __cxa_guard_release(__guard *g) { *(char *)g = 1; }
|
||||
void __cxa_guard_release(__guard *g)
|
||||
{
|
||||
*(char *)g = 1;
|
||||
}
|
||||
|
||||
void __cxa_guard_abort(__guard *g) { (void)g; }
|
||||
void __cxa_guard_abort(__guard *g)
|
||||
{
|
||||
(void)g;
|
||||
}
|
||||
|
||||
void __cxa_pure_virtual(void) { while (1); }
|
||||
void __cxa_pure_virtual(void)
|
||||
{
|
||||
while (1)
|
||||
;
|
||||
}
|
||||
|
||||
void IntDefaultHandler(void);
|
||||
void ResetHandler(void);
|
||||
@@ -65,81 +78,80 @@ extern void main(void);
|
||||
|
||||
static uint64_t stack[512] __attribute__((section(".stack")));
|
||||
|
||||
__attribute__((section(".vectors"), used))
|
||||
void (*const vectors[])(void) =
|
||||
{
|
||||
(void (*)(void))((unsigned long)stack + sizeof(stack)), // Initial Stack Pointer
|
||||
ResetHandler, // 1 The reset handler
|
||||
ResetHandler, // 2 The NMI handler
|
||||
IntDefaultHandler, // 3 The hard fault handler
|
||||
IntDefaultHandler, // 4 The MPU fault handler
|
||||
IntDefaultHandler, // 5 The bus fault handler
|
||||
IntDefaultHandler, // 6 The usage fault handler
|
||||
0, // 7 Reserved
|
||||
0, // 8 Reserved
|
||||
0, // 9 Reserved
|
||||
0, // 10 Reserved
|
||||
IntDefaultHandler, // 11 SVCall handler
|
||||
IntDefaultHandler, // 12 Debug monitor handler
|
||||
0, // 13 Reserved
|
||||
IntDefaultHandler, // 14 The PendSV handler
|
||||
SysTick_Handler, // 15 The SysTick handler
|
||||
IntDefaultHandler, // 16 GPIO Port A
|
||||
IntDefaultHandler, // 17 GPIO Port B
|
||||
IntDefaultHandler, // 18 GPIO Port C
|
||||
IntDefaultHandler, // 19 GPIO Port D
|
||||
0, // 20 none
|
||||
UART0IntHandler, // 21 UART0 Rx and Tx
|
||||
IntDefaultHandler, // 22 UART1 Rx and Tx
|
||||
IntDefaultHandler, // 23 SSI0 Rx and Tx
|
||||
IntDefaultHandler, // 24 I2C Master and Slave
|
||||
0, // 25 Reserved
|
||||
0, // 26 Reserved
|
||||
0, // 27 Reserved
|
||||
0, // 28 Reserved
|
||||
0, // 29 Reserved
|
||||
IntDefaultHandler, // 30 ADC Sequence 0
|
||||
0, // 31 Reserved
|
||||
0, // 32 Reserved
|
||||
0, // 33 Reserved
|
||||
IntDefaultHandler, // 34 Watchdog timer, timer 0
|
||||
IntDefaultHandler, // 35 Timer 0 subtimer A
|
||||
IntDefaultHandler, // 36 Timer 0 subtimer B
|
||||
IntDefaultHandler, // 37 Timer 1 subtimer A
|
||||
IntDefaultHandler, // 38 Timer 1 subtimer B
|
||||
IntDefaultHandler, // 39 Timer 2 subtimer A
|
||||
IntDefaultHandler, // 40 Timer 2 subtimer B
|
||||
IntDefaultHandler, // 41 Analog Comparator 0
|
||||
RFCoreRxTxIntHandler, // 42 RFCore Rx/Tx
|
||||
RFCoreErrIntHandler, // 43 RFCore Error
|
||||
IntDefaultHandler, // 44 IcePick
|
||||
IntDefaultHandler, // 45 FLASH Control
|
||||
IntDefaultHandler, // 46 AES
|
||||
IntDefaultHandler, // 47 PKA
|
||||
IntDefaultHandler, // 48 Sleep Timer
|
||||
IntDefaultHandler, // 49 MacTimer
|
||||
IntDefaultHandler, // 50 SSI1 Rx and Tx
|
||||
IntDefaultHandler, // 51 Timer 3 subtimer A
|
||||
IntDefaultHandler, // 52 Timer 3 subtimer B
|
||||
0, // 53 Reserved
|
||||
0, // 54 Reserved
|
||||
0, // 55 Reserved
|
||||
0, // 56 Reserved
|
||||
0, // 57 Reserved
|
||||
0, // 58 Reserved
|
||||
0, // 59 Reserved
|
||||
IntDefaultHandler, // 60 USB 2538
|
||||
0, // 61 Reserved
|
||||
IntDefaultHandler, // 62 uDMA
|
||||
IntDefaultHandler, // 63 uDMA Error
|
||||
__attribute__((section(".vectors"), used)) void (*const vectors[])(void) = {
|
||||
(void (*)(void))((unsigned long)stack + sizeof(stack)), // Initial Stack Pointer
|
||||
ResetHandler, // 1 The reset handler
|
||||
ResetHandler, // 2 The NMI handler
|
||||
IntDefaultHandler, // 3 The hard fault handler
|
||||
IntDefaultHandler, // 4 The MPU fault handler
|
||||
IntDefaultHandler, // 5 The bus fault handler
|
||||
IntDefaultHandler, // 6 The usage fault handler
|
||||
0, // 7 Reserved
|
||||
0, // 8 Reserved
|
||||
0, // 9 Reserved
|
||||
0, // 10 Reserved
|
||||
IntDefaultHandler, // 11 SVCall handler
|
||||
IntDefaultHandler, // 12 Debug monitor handler
|
||||
0, // 13 Reserved
|
||||
IntDefaultHandler, // 14 The PendSV handler
|
||||
SysTick_Handler, // 15 The SysTick handler
|
||||
IntDefaultHandler, // 16 GPIO Port A
|
||||
IntDefaultHandler, // 17 GPIO Port B
|
||||
IntDefaultHandler, // 18 GPIO Port C
|
||||
IntDefaultHandler, // 19 GPIO Port D
|
||||
0, // 20 none
|
||||
UART0IntHandler, // 21 UART0 Rx and Tx
|
||||
IntDefaultHandler, // 22 UART1 Rx and Tx
|
||||
IntDefaultHandler, // 23 SSI0 Rx and Tx
|
||||
IntDefaultHandler, // 24 I2C Master and Slave
|
||||
0, // 25 Reserved
|
||||
0, // 26 Reserved
|
||||
0, // 27 Reserved
|
||||
0, // 28 Reserved
|
||||
0, // 29 Reserved
|
||||
IntDefaultHandler, // 30 ADC Sequence 0
|
||||
0, // 31 Reserved
|
||||
0, // 32 Reserved
|
||||
0, // 33 Reserved
|
||||
IntDefaultHandler, // 34 Watchdog timer, timer 0
|
||||
IntDefaultHandler, // 35 Timer 0 subtimer A
|
||||
IntDefaultHandler, // 36 Timer 0 subtimer B
|
||||
IntDefaultHandler, // 37 Timer 1 subtimer A
|
||||
IntDefaultHandler, // 38 Timer 1 subtimer B
|
||||
IntDefaultHandler, // 39 Timer 2 subtimer A
|
||||
IntDefaultHandler, // 40 Timer 2 subtimer B
|
||||
IntDefaultHandler, // 41 Analog Comparator 0
|
||||
RFCoreRxTxIntHandler, // 42 RFCore Rx/Tx
|
||||
RFCoreErrIntHandler, // 43 RFCore Error
|
||||
IntDefaultHandler, // 44 IcePick
|
||||
IntDefaultHandler, // 45 FLASH Control
|
||||
IntDefaultHandler, // 46 AES
|
||||
IntDefaultHandler, // 47 PKA
|
||||
IntDefaultHandler, // 48 Sleep Timer
|
||||
IntDefaultHandler, // 49 MacTimer
|
||||
IntDefaultHandler, // 50 SSI1 Rx and Tx
|
||||
IntDefaultHandler, // 51 Timer 3 subtimer A
|
||||
IntDefaultHandler, // 52 Timer 3 subtimer B
|
||||
0, // 53 Reserved
|
||||
0, // 54 Reserved
|
||||
0, // 55 Reserved
|
||||
0, // 56 Reserved
|
||||
0, // 57 Reserved
|
||||
0, // 58 Reserved
|
||||
0, // 59 Reserved
|
||||
IntDefaultHandler, // 60 USB 2538
|
||||
0, // 61 Reserved
|
||||
IntDefaultHandler, // 62 uDMA
|
||||
IntDefaultHandler, // 63 uDMA Error
|
||||
};
|
||||
|
||||
void IntDefaultHandler(void)
|
||||
{
|
||||
while (1);
|
||||
while (1)
|
||||
;
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
// clang-format off
|
||||
|
||||
#define FLASH_CCA_BOOTLDR_CFG_DISABLE 0xEFFFFFFF ///< Disable backdoor function
|
||||
#define FLASH_CCA_BOOTLDR_CFG_ENABLE 0xF0FFFFFF ///< Enable backdoor function
|
||||
@@ -160,19 +172,12 @@ typedef struct
|
||||
uint8_t ui8lock[32];
|
||||
} flash_cca_lock_page_t;
|
||||
|
||||
__attribute__((__section__(".flashcca"), used))
|
||||
const flash_cca_lock_page_t flash_cca_lock_page =
|
||||
{
|
||||
__attribute__((__section__(".flashcca"), used)) const flash_cca_lock_page_t flash_cca_lock_page = {
|
||||
FLASH_CCA_BOOTLDR_CFG_ENABLE | (FLASH_CCA_CONF_BOOTLDR_BACKDOOR_PORT_A_PIN << FLASH_CCA_BOOTLDR_CFG_PORT_A_PIN_S),
|
||||
FLASH_CCA_IMAGE_VALID,
|
||||
(uint32_t) &vectors,
|
||||
{
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
|
||||
}
|
||||
};
|
||||
(uint32_t)&vectors,
|
||||
{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}};
|
||||
|
||||
typedef void (*init_fn_t)(void);
|
||||
|
||||
@@ -205,5 +210,6 @@ void ResetHandler(void)
|
||||
main();
|
||||
|
||||
// end here if main() returns
|
||||
while (1);
|
||||
while (1)
|
||||
;
|
||||
}
|
||||
|
||||
@@ -32,25 +32,25 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <openthread/config.h>
|
||||
#include <openthread-core-config.h>
|
||||
#include <openthread/config.h>
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <openthread/types.h>
|
||||
#include <openthread/platform/debug_uart.h>
|
||||
#include <openthread/platform/uart.h>
|
||||
#include <openthread/platform/logging.h>
|
||||
#include <openthread/platform/uart.h>
|
||||
|
||||
#include "platform-cc2538.h"
|
||||
#include "utils/code_utils.h"
|
||||
|
||||
enum
|
||||
{
|
||||
kPlatformClock = 32000000,
|
||||
kBaudRate = 115200,
|
||||
kPlatformClock = 32000000,
|
||||
kBaudRate = 115200,
|
||||
kReceiveBufferSize = 128,
|
||||
};
|
||||
|
||||
@@ -60,7 +60,7 @@ static void processReceive(void);
|
||||
static void processTransmit(void);
|
||||
|
||||
static const uint8_t *sTransmitBuffer = NULL;
|
||||
static uint16_t sTransmitLength = 0;
|
||||
static uint16_t sTransmitLength = 0;
|
||||
|
||||
typedef struct RecvBuffer
|
||||
{
|
||||
@@ -109,19 +109,19 @@ otError otPlatUartEnable(void)
|
||||
HWREG(UART0_BASE + UART_O_CC) = 0;
|
||||
|
||||
// tx pin
|
||||
HWREG(IOC_PA1_SEL) = IOC_MUX_OUT_SEL_UART0_TXD;
|
||||
HWREG(IOC_PA1_SEL) = IOC_MUX_OUT_SEL_UART0_TXD;
|
||||
HWREG(IOC_PA1_OVER) = IOC_OVERRIDE_OE;
|
||||
HWREG(GPIO_A_BASE + GPIO_O_AFSEL) |= GPIO_PIN_1;
|
||||
|
||||
// rx pin
|
||||
HWREG(IOC_PA0_SEL) = IOC_UARTRXD_UART0;
|
||||
HWREG(IOC_PA0_SEL) = IOC_UARTRXD_UART0;
|
||||
HWREG(IOC_PA0_OVER) = IOC_OVERRIDE_DIS;
|
||||
HWREG(GPIO_A_BASE + GPIO_O_AFSEL) |= GPIO_PIN_0;
|
||||
|
||||
HWREG(UART0_BASE + UART_O_CTL) = 0;
|
||||
|
||||
// baud rate
|
||||
div = (((kPlatformClock * 8) / kBaudRate) + 1) / 2;
|
||||
div = (((kPlatformClock * 8) / kBaudRate) + 1) / 2;
|
||||
HWREG(UART0_BASE + UART_O_IBRD) = div / 64;
|
||||
HWREG(UART0_BASE + UART_O_FBRD) = div % 64;
|
||||
HWREG(UART0_BASE + UART_O_LCRH) = UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE;
|
||||
@@ -186,7 +186,8 @@ void processTransmit(void)
|
||||
|
||||
for (; sTransmitLength > 0; sTransmitLength--)
|
||||
{
|
||||
while (HWREG(UART0_BASE + UART_O_FR) & UART_FR_TXFF);
|
||||
while (HWREG(UART0_BASE + UART_O_FR) & UART_FR_TXFF)
|
||||
;
|
||||
|
||||
HWREG(UART0_BASE + UART_O_DR) = *sTransmitBuffer++;
|
||||
}
|
||||
@@ -207,9 +208,9 @@ void cc2538UartProcess(void)
|
||||
void UART0IntHandler(void)
|
||||
{
|
||||
uint32_t mis;
|
||||
uint8_t byte;
|
||||
uint8_t byte;
|
||||
|
||||
mis = HWREG(UART0_BASE + UART_O_MIS);
|
||||
mis = HWREG(UART0_BASE + UART_O_MIS);
|
||||
HWREG(UART0_BASE + UART_O_ICR) = mis;
|
||||
|
||||
if (mis & (UART_IM_RXIM | UART_IM_RTIM))
|
||||
@@ -222,7 +223,7 @@ void UART0IntHandler(void)
|
||||
if (sReceive.mHead != (sReceive.mTail + 1) % kReceiveBufferSize)
|
||||
{
|
||||
sReceive.mBuffer[sReceive.mTail] = byte;
|
||||
sReceive.mTail = (sReceive.mTail + 1) % kReceiveBufferSize;
|
||||
sReceive.mTail = (sReceive.mTail + 1) % kReceiveBufferSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -260,13 +261,13 @@ int otPlatDebugUart_getc(void)
|
||||
void otPlatDebugUart_putchar_raw(int b)
|
||||
{
|
||||
/* wait till not busy */
|
||||
while (HWREG(UART1_BASE + UART_O_FR) & UART_FR_TXFF);
|
||||
while (HWREG(UART1_BASE + UART_O_FR) & UART_FR_TXFF)
|
||||
;
|
||||
|
||||
/* write byte */
|
||||
HWREG(UART1_BASE + UART_O_DR) = ((uint32_t)(b & 0x0ff));
|
||||
}
|
||||
|
||||
|
||||
void cc2538DebugUartInit(void)
|
||||
{
|
||||
int32_t a, b;
|
||||
@@ -281,13 +282,13 @@ void cc2538DebugUartInit(void)
|
||||
// http://www.ti.com/tool/cc2538dk
|
||||
// PA3 => is jumper position RF1.14
|
||||
// To use these, you will require a "flying-lead" UART adapter
|
||||
HWREG(IOC_PA3_SEL) = IOC_MUX_OUT_SEL_UART1_TXD;
|
||||
HWREG(IOC_PA3_SEL) = IOC_MUX_OUT_SEL_UART1_TXD;
|
||||
HWREG(IOC_PA3_OVER) = IOC_OVERRIDE_OE;
|
||||
HWREG(GPIO_A_BASE + GPIO_O_AFSEL) |= GPIO_PIN_3;
|
||||
|
||||
// UART1 - rx pin we don't really use but we setup anyway
|
||||
// PA2 => is jumper position RF1.16
|
||||
HWREG(IOC_PA2_SEL) = IOC_UARTRXD_UART1;
|
||||
HWREG(IOC_PA2_SEL) = IOC_UARTRXD_UART1;
|
||||
HWREG(IOC_PA2_OVER) = IOC_OVERRIDE_DIS;
|
||||
HWREG(GPIO_A_BASE + GPIO_O_AFSEL) |= GPIO_PIN_2;
|
||||
|
||||
|
||||
@@ -26,10 +26,10 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <driverlib/aon_rtc.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <openthread/types.h>
|
||||
#include <driverlib/aon_rtc.h>
|
||||
|
||||
#include <openthread/platform/alarm-milli.h>
|
||||
#include <openthread/platform/diag.h>
|
||||
@@ -75,7 +75,7 @@ uint32_t otPlatAlarmMilliGetNow(void)
|
||||
void otPlatAlarmMilliStartAt(otInstance *aInstance, uint32_t aT0, uint32_t aDt)
|
||||
{
|
||||
(void)aInstance;
|
||||
sTime0 = aT0;
|
||||
sTime0 = aT0;
|
||||
sAlarmTime = aDt;
|
||||
sIsRunning = true;
|
||||
}
|
||||
@@ -118,4 +118,3 @@ void cc2650AlarmProcess(otInstance *aInstance)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,4 +37,3 @@
|
||||
#else
|
||||
#error "Unknown compiler"
|
||||
#endif
|
||||
|
||||
|
||||
@@ -26,18 +26,18 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "mbedtls/aes.h"
|
||||
#include "aes_alt.h"
|
||||
#include "mbedtls/aes.h"
|
||||
|
||||
#ifdef MBEDTLS_AES_ALT
|
||||
|
||||
#include <string.h>
|
||||
#include <driverlib/crypto.h>
|
||||
#include <driverlib/prcm.h>
|
||||
#include <string.h>
|
||||
#include <utils/code_utils.h>
|
||||
|
||||
#define CC2650_AES_KEY_UNUSED (-1)
|
||||
#define CC2650_AES_CTX_MAGIC (0x7E)
|
||||
#define CC2650_AES_CTX_MAGIC (0x7E)
|
||||
|
||||
/**
|
||||
* bitmap of which key stores are currently used
|
||||
@@ -66,11 +66,11 @@ void mbedtls_aes_init(mbedtls_aes_context *ctx)
|
||||
PRCMPeripheralDeepSleepEnable(PRCM_PERIPH_CRYPTO);
|
||||
PRCMLoadSet();
|
||||
|
||||
while (!PRCMLoadGet());
|
||||
|
||||
while (!PRCMLoadGet())
|
||||
;
|
||||
}
|
||||
|
||||
ctx->magic = CC2650_AES_CTX_MAGIC;
|
||||
ctx->magic = CC2650_AES_CTX_MAGIC;
|
||||
ctx->key_idx = CC2650_AES_KEY_UNUSED;
|
||||
}
|
||||
|
||||
@@ -98,8 +98,8 @@ void mbedtls_aes_free(mbedtls_aes_context *ctx)
|
||||
PRCMPeripheralDeepSleepDisable(PRCM_PERIPH_CRYPTO);
|
||||
PRCMLoadSet();
|
||||
|
||||
while (!PRCMLoadGet());
|
||||
|
||||
while (!PRCMLoadGet())
|
||||
;
|
||||
}
|
||||
|
||||
memset((void *)ctx, 0x00, sizeof(ctx));
|
||||
@@ -111,7 +111,7 @@ exit:
|
||||
int mbedtls_aes_setkey_enc(mbedtls_aes_context *ctx, const unsigned char *key, unsigned int keybits)
|
||||
{
|
||||
unsigned char key_idx;
|
||||
int retval = 0;
|
||||
int retval = 0;
|
||||
|
||||
otEXPECT_ACTION(ctx->magic == CC2650_AES_CTX_MAGIC, retval = -1);
|
||||
|
||||
@@ -123,7 +123,8 @@ int mbedtls_aes_setkey_enc(mbedtls_aes_context *ctx, const unsigned char *key, u
|
||||
/* our hardware only supports 128 bit keys */
|
||||
otEXPECT_ACTION(keybits == 128u, retval = MBEDTLS_ERR_AES_INVALID_KEY_LENGTH);
|
||||
|
||||
for (key_idx = 0; ((sUsedKeys >> key_idx) & 0x01) != 0 && key_idx < 8; key_idx++);
|
||||
for (key_idx = 0; ((sUsedKeys >> key_idx) & 0x01) != 0 && key_idx < 8; key_idx++)
|
||||
;
|
||||
|
||||
/* we have no more room for this key */
|
||||
otEXPECT_ACTION(key_idx < 8, retval = -2);
|
||||
@@ -140,7 +141,7 @@ exit:
|
||||
int mbedtls_aes_setkey_dec(mbedtls_aes_context *ctx, const unsigned char *key, unsigned int keybits)
|
||||
{
|
||||
unsigned char key_idx;
|
||||
int retval = 0;
|
||||
int retval = 0;
|
||||
|
||||
otEXPECT_ACTION(ctx->magic == CC2650_AES_CTX_MAGIC, retval = -1);
|
||||
|
||||
@@ -152,7 +153,8 @@ int mbedtls_aes_setkey_dec(mbedtls_aes_context *ctx, const unsigned char *key, u
|
||||
/* our hardware only supports 128 bit keys */
|
||||
otEXPECT_ACTION(keybits == 128u, retval = MBEDTLS_ERR_AES_INVALID_KEY_LENGTH);
|
||||
|
||||
for (key_idx = 0; ((sUsedKeys >> key_idx) & 0x01) != 0 && key_idx < 8; key_idx++);
|
||||
for (key_idx = 0; ((sUsedKeys >> key_idx) & 0x01) != 0 && key_idx < 8; key_idx++)
|
||||
;
|
||||
|
||||
/* we have no more room for this key */
|
||||
otEXPECT_ACTION(key_idx < 8, retval = -2);
|
||||
@@ -183,7 +185,8 @@ int mbedtls_aes_crypt_ecb(mbedtls_aes_context *ctx, int mode, const unsigned cha
|
||||
retval = CRYPTOAesEcb((uint32_t *)input, (uint32_t *)output, ctx->key_idx, mode == MBEDTLS_AES_ENCRYPT, false);
|
||||
otEXPECT(retval == AES_SUCCESS);
|
||||
|
||||
while ((retval = CRYPTOAesEcbStatus()) == AES_DMA_BSY);
|
||||
while ((retval = CRYPTOAesEcbStatus()) == AES_DMA_BSY)
|
||||
;
|
||||
|
||||
CRYPTOAesEcbFinish();
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ void mbedtls_sha256_finish(mbedtls_sha256_context *ctx, unsigned char output[32]
|
||||
* Make a 64byte buffer on the stack..
|
||||
* And force the compiler to think it requires this buffer.
|
||||
*/
|
||||
char buffer[ 64 ];
|
||||
char buffer[64];
|
||||
workaround_cc2650_rom = &buffer[0];
|
||||
SHA256_output(ctx, (uint8_t *)output);
|
||||
return;
|
||||
|
||||
@@ -49,6 +49,6 @@ void __cxa_guard_abort(__guard *g)
|
||||
|
||||
void __cxa_pure_virtual(void)
|
||||
{
|
||||
while (1);
|
||||
while (1)
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,15 +27,15 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file logging.c
|
||||
* Platform abstraction for the logging
|
||||
*
|
||||
*/
|
||||
#include <openthread/config.h>
|
||||
* @file logging.c
|
||||
* Platform abstraction for the logging
|
||||
*
|
||||
*/
|
||||
#include <openthread-core-config.h>
|
||||
#include <openthread/config.h>
|
||||
#include <openthread/platform/logging.h>
|
||||
|
||||
#if (OPENTHREAD_CONFIG_LOG_OUTPUT == OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED)
|
||||
#if (OPENTHREAD_CONFIG_LOG_OUTPUT == OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED)
|
||||
void otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, ...)
|
||||
{
|
||||
(void)aLogLevel;
|
||||
@@ -43,4 +43,3 @@ void otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat
|
||||
(void)aFormat;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -26,9 +26,9 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <driverlib/sys_ctrl.h>
|
||||
#include <openthread/types.h>
|
||||
#include <openthread/platform/misc.h>
|
||||
#include <driverlib/sys_ctrl.h>
|
||||
|
||||
/**
|
||||
* Function documented in platform/misc.h
|
||||
|
||||
@@ -29,9 +29,9 @@
|
||||
#ifndef PLATFORM_H_
|
||||
#define PLATFORM_H_
|
||||
|
||||
#include <openthread/config.h>
|
||||
#include <openthread-core-config.h>
|
||||
#include <stdint.h>
|
||||
#include <openthread/config.h>
|
||||
#include "openthread/types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -78,7 +78,7 @@ void cc2650RandomInit(void);
|
||||
void cc2650UartProcess(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // PLATFORM_H_
|
||||
#endif // PLATFORM_H_
|
||||
|
||||
@@ -26,9 +26,9 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "platform-cc2650.h"
|
||||
#include <stdio.h>
|
||||
#include <openthread/types.h>
|
||||
#include "platform-cc2650.h"
|
||||
#include "inc/hw_ccfg_simple_struct.h"
|
||||
|
||||
extern const ccfg_t __ccfg;
|
||||
@@ -40,16 +40,16 @@ void *dummy_ccfg_ref = ((void *)(&(__ccfg)));
|
||||
*/
|
||||
void PlatformInit(int argc, char *argv[])
|
||||
{
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
|
||||
while (dummy_ccfg_ref == NULL)
|
||||
{
|
||||
/*
|
||||
* This provides a code reference to the customer configuration
|
||||
* area of the flash, otherwise the data is skipped by the
|
||||
* linker and not put into the final flash image.
|
||||
*/
|
||||
* This provides a code reference to the customer configuration
|
||||
* area of the flash, otherwise the data is skipped by the
|
||||
* linker and not put into the final flash image.
|
||||
*/
|
||||
}
|
||||
|
||||
cc2650AlarmInit();
|
||||
|
||||
@@ -28,30 +28,30 @@
|
||||
|
||||
#include <openthread/types.h>
|
||||
|
||||
#include "cc2650_radio.h"
|
||||
#include <assert.h>
|
||||
#include <utils/code_utils.h>
|
||||
#include "cc2650_radio.h"
|
||||
#include <openthread/platform/alarm-milli.h>
|
||||
#include <openthread/platform/radio.h>
|
||||
#include <openthread/platform/random.h> /* to seed the CSMA-CA funciton */
|
||||
|
||||
#include <driverlib/prcm.h>
|
||||
#include <inc/hw_prcm.h>
|
||||
#include <inc/hw_memmap.h>
|
||||
#include <inc/hw_fcfg1.h>
|
||||
#include <inc/hw_ccfg.h>
|
||||
#include <driverlib/rfc.h>
|
||||
#include <driverlib/osc.h>
|
||||
#include <driverlib/rf_data_entry.h>
|
||||
#include <driverlib/rf_mailbox.h>
|
||||
#include <driverlib/rf_common_cmd.h>
|
||||
#include <driverlib/rf_ieee_mailbox.h>
|
||||
#include <driverlib/rf_ieee_cmd.h>
|
||||
#include <driverlib/chipinfo.h>
|
||||
#include <driverlib/osc.h>
|
||||
#include <driverlib/prcm.h>
|
||||
#include <driverlib/rf_common_cmd.h>
|
||||
#include <driverlib/rf_data_entry.h>
|
||||
#include <driverlib/rf_ieee_cmd.h>
|
||||
#include <driverlib/rf_ieee_mailbox.h>
|
||||
#include <driverlib/rf_mailbox.h>
|
||||
#include <driverlib/rfc.h>
|
||||
#include <inc/hw_ccfg.h>
|
||||
#include <inc/hw_fcfg1.h>
|
||||
#include <inc/hw_memmap.h>
|
||||
#include <inc/hw_prcm.h>
|
||||
|
||||
enum
|
||||
{
|
||||
CC2650_RECEIVE_SENSITIVITY = -100, // dBm
|
||||
CC2650_RECEIVE_SENSITIVITY = -100, // dBm
|
||||
};
|
||||
|
||||
/* phy state as defined by openthread */
|
||||
@@ -60,8 +60,7 @@ static volatile cc2650_PhyState sState;
|
||||
static output_config_t const *sCurrentOutputPower = &(rgOutputPower[OUTPUT_CONFIG_COUNT - 1]);
|
||||
|
||||
/* Overrides for IEEE 802.15.4, differential mode */
|
||||
static uint32_t sIEEEOverrides[] =
|
||||
{
|
||||
static uint32_t sIEEEOverrides[] = {
|
||||
0x00354038, /* Synth: Set RTRIM (POTAILRESTRIM) to 5 */
|
||||
0x4001402D, /* Synth: Correct CKVD latency setting (address) */
|
||||
0x00608402, /* Synth: Correct CKVD latency setting (value) */
|
||||
@@ -129,11 +128,11 @@ static uint8_t sRxBuf0[RX_BUF_SIZE] __attribute__((aligned(4)));
|
||||
static uint8_t sRxBuf1[RX_BUF_SIZE] __attribute__((aligned(4)));
|
||||
|
||||
/* The RX Data Queue */
|
||||
static dataQueue_t sRxDataQueue = { 0 };
|
||||
static dataQueue_t sRxDataQueue = {0};
|
||||
|
||||
/* openthread data primatives */
|
||||
static otRadioFrame sTransmitFrame;
|
||||
static otError sTransmitError;
|
||||
static otError sTransmitError;
|
||||
|
||||
static __attribute__((aligned(4))) uint8_t sTransmitPsdu[OT_RADIO_FRAME_MAX_SIZE];
|
||||
|
||||
@@ -297,7 +296,7 @@ static uint_fast8_t rfCoreClearReceiveQueue(dataQueue_t *aQueue)
|
||||
{
|
||||
/* memset skipped because sClearReceiveQueueCmd has only 2 members and padding */
|
||||
sClearReceiveQueueCmd.commandNo = CMD_CLEAR_RX;
|
||||
sClearReceiveQueueCmd.pQueue = aQueue;
|
||||
sClearReceiveQueueCmd.pQueue = aQueue;
|
||||
|
||||
return (RFCDoorbellSendTo((uint32_t)&sClearReceiveQueueCmd) & 0xFF);
|
||||
}
|
||||
@@ -412,7 +411,7 @@ static uint_fast8_t rfCoreModifySourceMatchEntry(uint8_t aEntryNo, cc2650_addres
|
||||
}
|
||||
|
||||
sModifyReceiveSrcMatchCmd.options.entryType = aType;
|
||||
sModifyReceiveSrcMatchCmd.entryNo = aEntryNo;
|
||||
sModifyReceiveSrcMatchCmd.entryNo = aEntryNo;
|
||||
|
||||
return (RFCDoorbellSendTo((uint32_t)&sModifyReceiveSrcMatchCmd) & 0xFF);
|
||||
}
|
||||
@@ -595,24 +594,24 @@ static uint_fast8_t rfCoreSendTransmitCmd(uint8_t *aPsdu, uint8_t aLen)
|
||||
/* reset retry count */
|
||||
sTransmitRetryCount = 0;
|
||||
|
||||
sCsmacaBackoffCmd = cCsmacaBackoffCmd;
|
||||
sCsmacaBackoffCmd = cCsmacaBackoffCmd;
|
||||
/* initialize the random state with a true random seed for the radio core's
|
||||
* psudo rng */
|
||||
sCsmacaBackoffCmd.randomState = otPlatRandomGet();
|
||||
sCsmacaBackoffCmd.pNextOp = (rfc_radioOp_t *) &sTransmitCmd;
|
||||
sCsmacaBackoffCmd.randomState = otPlatRandomGet();
|
||||
sCsmacaBackoffCmd.pNextOp = (rfc_radioOp_t *)&sTransmitCmd;
|
||||
|
||||
sTransmitCmd = cTransmitCmd;
|
||||
/* no need to look for an ack if the tx operation was stopped */
|
||||
sTransmitCmd.payloadLen = aLen;
|
||||
sTransmitCmd.pPayload = aPsdu;
|
||||
sTransmitCmd.pPayload = aPsdu;
|
||||
|
||||
if (aPsdu[0] & IEEE802154_ACK_REQUEST)
|
||||
{
|
||||
/* setup the receive ack command to follow the tx command */
|
||||
sTransmitCmd.condition.rule = COND_STOP_ON_FALSE;
|
||||
sTransmitCmd.pNextOp = (rfc_radioOp_t *) &sTransmitRxAckCmd;
|
||||
sTransmitCmd.pNextOp = (rfc_radioOp_t *)&sTransmitRxAckCmd;
|
||||
|
||||
sTransmitRxAckCmd = cTransmitRxAckCmd;
|
||||
sTransmitRxAckCmd = cTransmitRxAckCmd;
|
||||
sTransmitRxAckCmd.seqNo = aPsdu[IEEE802154_DSN_OFFSET];
|
||||
}
|
||||
|
||||
@@ -816,12 +815,14 @@ static uint_fast8_t rfCorePowerOn(void)
|
||||
/* Enable RF Core power domain */
|
||||
PRCMPowerDomainOn(PRCM_DOMAIN_RFCORE);
|
||||
|
||||
while (PRCMPowerDomainStatus(PRCM_DOMAIN_RFCORE) != PRCM_DOMAIN_POWER_ON);
|
||||
while (PRCMPowerDomainStatus(PRCM_DOMAIN_RFCORE) != PRCM_DOMAIN_POWER_ON)
|
||||
;
|
||||
|
||||
PRCMDomainEnable(PRCM_DOMAIN_RFCORE);
|
||||
PRCMLoadSet();
|
||||
|
||||
while (!PRCMLoadGet());
|
||||
while (!PRCMLoadGet())
|
||||
;
|
||||
|
||||
rfCoreSetupInt();
|
||||
|
||||
@@ -831,8 +832,8 @@ static uint_fast8_t rfCorePowerOn(void)
|
||||
}
|
||||
|
||||
/* Let CPE boot */
|
||||
HWREG(RFC_PWR_NONBUF_BASE + RFC_PWR_O_PWMCLKEN) = (RFC_PWR_PWMCLKEN_RFC_M | RFC_PWR_PWMCLKEN_CPE_M |
|
||||
RFC_PWR_PWMCLKEN_CPERAM_M);
|
||||
HWREG(RFC_PWR_NONBUF_BASE + RFC_PWR_O_PWMCLKEN) =
|
||||
(RFC_PWR_PWMCLKEN_RFC_M | RFC_PWR_PWMCLKEN_CPE_M | RFC_PWR_PWMCLKEN_CPERAM_M);
|
||||
|
||||
/* Send ping (to verify RFCore is ready and alive) */
|
||||
return rfCoreExecutePingCmd();
|
||||
@@ -854,11 +855,13 @@ static void rfCorePowerOff(void)
|
||||
PRCMDomainDisable(PRCM_DOMAIN_RFCORE);
|
||||
PRCMLoadSet();
|
||||
|
||||
while (!PRCMLoadGet());
|
||||
while (!PRCMLoadGet())
|
||||
;
|
||||
|
||||
PRCMPowerDomainOff(PRCM_DOMAIN_RFCORE);
|
||||
|
||||
while (PRCMPowerDomainStatus(PRCM_DOMAIN_RFCORE) != PRCM_DOMAIN_POWER_OFF);
|
||||
while (PRCMPowerDomainStatus(PRCM_DOMAIN_RFCORE) != PRCM_DOMAIN_POWER_OFF)
|
||||
;
|
||||
|
||||
if (OSCClockSourceGet(OSC_SRC_CLK_HF) != OSC_RCOSC_HF)
|
||||
{
|
||||
@@ -914,11 +917,11 @@ static uint_fast16_t rfCoreSendEnableCmd(void)
|
||||
|
||||
/* initialize the rat start command */
|
||||
sStartRatCmd = cStartRatCmd;
|
||||
sStartRatCmd.pNextOp = (rfc_radioOp_t *) &sRadioSetupCmd;
|
||||
sStartRatCmd.pNextOp = (rfc_radioOp_t *)&sRadioSetupCmd;
|
||||
sStartRatCmd.rat0 = sRatOffset;
|
||||
|
||||
/* initialize radio setup command */
|
||||
sRadioSetupCmd = cRadioSetupCmd;
|
||||
sRadioSetupCmd = cRadioSetupCmd;
|
||||
/* initally set the radio tx power to the max */
|
||||
sRadioSetupCmd.txPower = sCurrentOutputPower->value;
|
||||
sRadioSetupCmd.pRegOverride = sIEEEOverrides;
|
||||
@@ -929,7 +932,8 @@ static uint_fast16_t rfCoreSendEnableCmd(void)
|
||||
otEXPECT_ACTION(CMDSTA_Done == doorbellRet, ret = doorbellRet);
|
||||
|
||||
/* synchronously wait for the CM0 to stop executing */
|
||||
while ((HWREG(RFC_DBELL_NONBUF_BASE + RFC_DBELL_O_RFCPEIFG) & IRQ_LAST_COMMAND_DONE) == 0x00);
|
||||
while ((HWREG(RFC_DBELL_NONBUF_BASE + RFC_DBELL_O_RFCPEIFG) & IRQ_LAST_COMMAND_DONE) == 0x00)
|
||||
;
|
||||
|
||||
ret = sRadioSetupCmd.status;
|
||||
|
||||
@@ -987,7 +991,7 @@ static uint_fast16_t rfCoreSendDisableCmd(void)
|
||||
HWREGBITW(AON_RTC_BASE + AON_RTC_O_CTL, AON_RTC_CTL_RTC_UPD_EN_BITN) = 1;
|
||||
|
||||
/* initialize the command to power down the frequency synth */
|
||||
sFsPowerdownCmd = cFsPowerdownCmd;
|
||||
sFsPowerdownCmd = cFsPowerdownCmd;
|
||||
sFsPowerdownCmd.pNextOp = (rfc_radioOp_t *)&sStopRatCmd;
|
||||
|
||||
sStopRatCmd = cStopRatCmd;
|
||||
@@ -999,9 +1003,9 @@ static uint_fast16_t rfCoreSendDisableCmd(void)
|
||||
doorbellRet = (RFCDoorbellSendTo((uint32_t)&sFsPowerdownCmd) & 0xFF);
|
||||
otEXPECT_ACTION(CMDSTA_Done == doorbellRet, ret = doorbellRet);
|
||||
|
||||
|
||||
/* synchronously wait for the CM0 to stop */
|
||||
while ((HWREG(RFC_DBELL_NONBUF_BASE + RFC_DBELL_O_RFCPEIFG) & IRQ_LAST_COMMAND_DONE) == 0x00);
|
||||
while ((HWREG(RFC_DBELL_NONBUF_BASE + RFC_DBELL_O_RFCPEIFG) & IRQ_LAST_COMMAND_DONE) == 0x00)
|
||||
;
|
||||
|
||||
ret = sStopRatCmd.status;
|
||||
|
||||
@@ -1038,9 +1042,7 @@ void RFCCPE0IntHandler(void)
|
||||
{
|
||||
HWREG(RFC_DBELL_NONBUF_BASE + RFC_DBELL_O_RFCPEIFG) = ~IRQ_LAST_COMMAND_DONE;
|
||||
|
||||
if (sState == cc2650_stateReceive &&
|
||||
sReceiveCmd.status != ACTIVE &&
|
||||
sReceiveCmd.status != IEEE_SUSPENDED)
|
||||
if (sState == cc2650_stateReceive && sReceiveCmd.status != ACTIVE && sReceiveCmd.status != IEEE_SUSPENDED)
|
||||
{
|
||||
/* the rx command was probably aborted to change the channel */
|
||||
sState = cc2650_stateSleep;
|
||||
@@ -1203,7 +1205,7 @@ otError otPlatRadioDisable(otInstance *aInstance)
|
||||
*/
|
||||
rfCorePowerOff();
|
||||
sState = cc2650_stateDisabled;
|
||||
error = OT_ERROR_NONE;
|
||||
error = OT_ERROR_NONE;
|
||||
}
|
||||
|
||||
return error;
|
||||
@@ -1248,7 +1250,7 @@ exit:
|
||||
*/
|
||||
otError otPlatRadioSetTransmitPower(otInstance *aInstance, int8_t aPower)
|
||||
{
|
||||
unsigned int i;
|
||||
unsigned int i;
|
||||
output_config_t const *powerCfg = &(rgOutputPower[0]);
|
||||
(void)aInstance;
|
||||
|
||||
@@ -1295,7 +1297,7 @@ otError otPlatRadioReceive(otInstance *aInstance, uint8_t aChannel)
|
||||
{
|
||||
/* we are already running on the right channel */
|
||||
sState = cc2650_stateReceive;
|
||||
error = OT_ERROR_NONE;
|
||||
error = OT_ERROR_NONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1312,7 +1314,7 @@ otError otPlatRadioReceive(otInstance *aInstance, uint8_t aChannel)
|
||||
otEXPECT_ACTION(rfCoreSendReceiveCmd() == CMDSTA_Done, error = OT_ERROR_FAILED);
|
||||
|
||||
sState = cc2650_stateReceive;
|
||||
error = OT_ERROR_NONE;
|
||||
error = OT_ERROR_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1370,8 +1372,8 @@ otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aFrame)
|
||||
/* removing 2 bytes of CRC placeholder because we generate that in hardware */
|
||||
otEXPECT_ACTION(rfCoreSendTransmitCmd(aFrame->mPsdu, aFrame->mLength - 2) == CMDSTA_Done,
|
||||
error = OT_ERROR_FAILED);
|
||||
error = OT_ERROR_NONE;
|
||||
sTransmitError = OT_ERROR_NONE;
|
||||
error = OT_ERROR_NONE;
|
||||
sTransmitError = OT_ERROR_NONE;
|
||||
sTxCmdChainDone = false;
|
||||
otPlatRadioTxStarted(aInstance, aFrame);
|
||||
}
|
||||
@@ -1429,17 +1431,15 @@ otError otPlatRadioAddSrcMatchShortEntry(otInstance *aInstance, const uint16_t a
|
||||
if (idx == CC2650_SRC_MATCH_NONE)
|
||||
{
|
||||
/* the entry does not exist already, add it */
|
||||
otEXPECT_ACTION((idx = rfCoreFindEmptyShortSrcMatchIdx()) != CC2650_SRC_MATCH_NONE,
|
||||
error = OT_ERROR_NO_BUFS);
|
||||
otEXPECT_ACTION((idx = rfCoreFindEmptyShortSrcMatchIdx()) != CC2650_SRC_MATCH_NONE, error = OT_ERROR_NO_BUFS);
|
||||
sSrcMatchShortData.extAddrEnt[idx].shortAddr = aShortAddress;
|
||||
sSrcMatchShortData.extAddrEnt[idx].panId = sReceiveCmd.localPanID;
|
||||
sSrcMatchShortData.extAddrEnt[idx].panId = sReceiveCmd.localPanID;
|
||||
}
|
||||
|
||||
if (sReceiveCmd.status == ACTIVE || sReceiveCmd.status == IEEE_SUSPENDED)
|
||||
{
|
||||
/* we have a running or backgrounded rx command */
|
||||
otEXPECT_ACTION(rfCoreModifySourceMatchEntry(idx, SHORT_ADDRESS, true) == CMDSTA_Done,
|
||||
error = OT_ERROR_FAILED);
|
||||
otEXPECT_ACTION(rfCoreModifySourceMatchEntry(idx, SHORT_ADDRESS, true) == CMDSTA_Done, error = OT_ERROR_FAILED);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1499,8 +1499,7 @@ otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const otExtAddress
|
||||
if (sReceiveCmd.status == ACTIVE || sReceiveCmd.status == IEEE_SUSPENDED)
|
||||
{
|
||||
/* we have a running or backgrounded rx command */
|
||||
otEXPECT_ACTION(rfCoreModifySourceMatchEntry(idx, EXT_ADDRESS, true) == CMDSTA_Done,
|
||||
error = OT_ERROR_FAILED);
|
||||
otEXPECT_ACTION(rfCoreModifySourceMatchEntry(idx, EXT_ADDRESS, true) == CMDSTA_Done, error = OT_ERROR_FAILED);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1527,13 +1526,12 @@ otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const otExtAddre
|
||||
if (sReceiveCmd.status == ACTIVE || sReceiveCmd.status == IEEE_SUSPENDED)
|
||||
{
|
||||
/* we have a running or backgrounded rx command */
|
||||
otEXPECT_ACTION(rfCoreModifySourceMatchEntry(idx, EXT_ADDRESS, false) == CMDSTA_Done,
|
||||
error = OT_ERROR_FAILED);
|
||||
otEXPECT_ACTION(rfCoreModifySourceMatchEntry(idx, EXT_ADDRESS, false) == CMDSTA_Done, error = OT_ERROR_FAILED);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* we are not running, so we must update the values ourselves */
|
||||
sSrcMatchExtData.srcPendEn[idx] = 0u;
|
||||
sSrcMatchExtData.srcPendEn[idx] = 0u;
|
||||
sSrcMatchExtData.srcMatchEn[idx] = 0u;
|
||||
sSrcMatchExtData.srcPendEn[idx / 32] &= ~(1 << (idx % 32));
|
||||
sSrcMatchExtData.srcMatchEn[idx / 32] &= ~(1 << (idx % 32));
|
||||
@@ -1544,8 +1542,8 @@ exit:
|
||||
}
|
||||
|
||||
/**
|
||||
* Function documented in platform/radio.h
|
||||
*/
|
||||
* Function documented in platform/radio.h
|
||||
*/
|
||||
void otPlatRadioClearSrcMatchShortEntries(otInstance *aInstance)
|
||||
{
|
||||
(void)aInstance;
|
||||
@@ -1571,8 +1569,8 @@ exit:
|
||||
}
|
||||
|
||||
/**
|
||||
* Function documented in platform/radio.h
|
||||
*/
|
||||
* Function documented in platform/radio.h
|
||||
*/
|
||||
void otPlatRadioClearSrcMatchExtEntries(otInstance *aInstance)
|
||||
{
|
||||
(void)aInstance;
|
||||
@@ -1633,7 +1631,7 @@ void otPlatRadioSetPromiscuous(otInstance *aInstance, bool aEnable)
|
||||
*/
|
||||
void otPlatRadioGetIeeeEui64(otInstance *aInstance, uint8_t *aIeeeEui64)
|
||||
{
|
||||
uint8_t *eui64;
|
||||
uint8_t * eui64;
|
||||
unsigned int i;
|
||||
(void)aInstance;
|
||||
|
||||
@@ -1762,8 +1760,10 @@ exit:
|
||||
return;
|
||||
}
|
||||
|
||||
static void cc2650RadioProcessTransmitDone(otInstance *aInstance, otRadioFrame *aTransmitFrame, otRadioFrame *aAckFrame,
|
||||
otError aTransmitError)
|
||||
static void cc2650RadioProcessTransmitDone(otInstance * aInstance,
|
||||
otRadioFrame *aTransmitFrame,
|
||||
otRadioFrame *aAckFrame,
|
||||
otError aTransmitError)
|
||||
{
|
||||
#if OPENTHREAD_ENABLE_DIAG
|
||||
|
||||
@@ -1795,12 +1795,12 @@ static void cc2650RadioProcessReceiveDone(otInstance *aInstance, otRadioFrame *a
|
||||
|
||||
static void cc2650RadioProcessReceiveQueue(otInstance *aInstance)
|
||||
{
|
||||
rfc_ieeeRxCorrCrc_t *crcCorr;
|
||||
rfc_ieeeRxCorrCrc_t * crcCorr;
|
||||
rfc_dataEntryGeneral_t *curEntry, *startEntry;
|
||||
uint8_t rssi;
|
||||
|
||||
startEntry = (rfc_dataEntryGeneral_t *)sRxDataQueue.pCurrEntry;
|
||||
curEntry = startEntry;
|
||||
curEntry = startEntry;
|
||||
|
||||
/* loop through receive queue */
|
||||
do
|
||||
@@ -1825,8 +1825,8 @@ static void cc2650RadioProcessReceiveQueue(otInstance *aInstance)
|
||||
{
|
||||
#if OPENTHREAD_ENABLE_RAW_LINK_API
|
||||
// TODO: Propagate CM0 timestamp
|
||||
receiveFrame.mMsec = otPlatAlarmMilliGetNow();
|
||||
receiveFrame.mUsec = 0; // Don't support microsecond timer for now.
|
||||
receiveFrame.mMsec = otPlatAlarmMilliGetNow();
|
||||
receiveFrame.mUsec = 0; // Don't support microsecond timer for now.
|
||||
#endif
|
||||
|
||||
receiveFrame.mLength = len;
|
||||
@@ -1864,8 +1864,7 @@ static void cc2650RadioProcessReceiveQueue(otInstance *aInstance)
|
||||
}
|
||||
|
||||
curEntry = (rfc_dataEntryGeneral_t *)(curEntry->pNextEntry);
|
||||
}
|
||||
while (curEntry != startEntry);
|
||||
} while (curEntry != startEntry);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1885,8 +1884,7 @@ void cc2650RadioProcess(otInstance *aInstance)
|
||||
}
|
||||
}
|
||||
|
||||
if (sState == cc2650_stateReceive
|
||||
|| sState == cc2650_stateTransmit)
|
||||
if (sState == cc2650_stateReceive || sState == cc2650_stateTransmit)
|
||||
{
|
||||
cc2650RadioProcessReceiveQueue(aInstance);
|
||||
}
|
||||
@@ -1900,7 +1898,7 @@ void cc2650RadioProcess(otInstance *aInstance)
|
||||
cc2650RadioProcessTransmitDone(aInstance, &sTransmitFrame, NULL, sTransmitError);
|
||||
}
|
||||
|
||||
sTransmitError = OT_ERROR_NONE;
|
||||
sTransmitError = OT_ERROR_NONE;
|
||||
sTxCmdChainDone = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,8 +26,8 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <openthread/types.h>
|
||||
#include <utils/code_utils.h>
|
||||
#include <openthread/types.h>
|
||||
|
||||
#include <driverlib/prcm.h>
|
||||
#include <driverlib/trng.h>
|
||||
@@ -55,7 +55,8 @@ void cc2650RandomInit(void)
|
||||
{
|
||||
PRCMPowerDomainOn(PRCM_DOMAIN_PERIPH);
|
||||
|
||||
while (PRCMPowerDomainStatus(PRCM_DOMAIN_PERIPH) != PRCM_DOMAIN_POWER_ON);
|
||||
while (PRCMPowerDomainStatus(PRCM_DOMAIN_PERIPH) != PRCM_DOMAIN_POWER_ON)
|
||||
;
|
||||
|
||||
PRCMPeripheralRunEnable(PRCM_PERIPH_TRNG);
|
||||
PRCMPeripheralSleepEnable(PRCM_DOMAIN_PERIPH);
|
||||
@@ -70,7 +71,8 @@ void cc2650RandomInit(void)
|
||||
*/
|
||||
uint32_t otPlatRandomGet(void)
|
||||
{
|
||||
while (!(TRNGStatusGet() & TRNG_NUMBER_READY));
|
||||
while (!(TRNGStatusGet() & TRNG_NUMBER_READY))
|
||||
;
|
||||
|
||||
return TRNGNumberGet(TRNG_LOW_WORD);
|
||||
}
|
||||
@@ -91,7 +93,7 @@ static int TRNGPoll(unsigned char *aOutput, size_t aLen)
|
||||
union
|
||||
{
|
||||
uint32_t u32[2];
|
||||
uint8_t u8[8];
|
||||
uint8_t u8[8];
|
||||
} buffer;
|
||||
|
||||
while (length < aLen)
|
||||
@@ -99,14 +101,15 @@ static int TRNGPoll(unsigned char *aOutput, size_t aLen)
|
||||
if (length % 8 == 0)
|
||||
{
|
||||
/* we've run to the end of the buffer */
|
||||
while (!(TRNGStatusGet() & TRNG_NUMBER_READY));
|
||||
while (!(TRNGStatusGet() & TRNG_NUMBER_READY))
|
||||
;
|
||||
|
||||
/*
|
||||
* don't use TRNGNumberGet here because it will tell the TRNG to
|
||||
* refil the entropy pool, instad we do it ourself.
|
||||
*/
|
||||
buffer.u32[0] = HWREG(TRNG_BASE + TRNG_O_OUT0);
|
||||
buffer.u32[1] = HWREG(TRNG_BASE + TRNG_O_OUT1);
|
||||
buffer.u32[0] = HWREG(TRNG_BASE + TRNG_O_OUT0);
|
||||
buffer.u32[1] = HWREG(TRNG_BASE + TRNG_O_OUT1);
|
||||
HWREG(TRNG_BASE + TRNG_O_IRQFLAGCLR) = 0x1;
|
||||
}
|
||||
|
||||
@@ -118,14 +121,13 @@ static int TRNGPoll(unsigned char *aOutput, size_t aLen)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function documented in platform/random.h
|
||||
*/
|
||||
otError otPlatRandomGetTrue(uint8_t *aOutput, uint16_t aOutputLength)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
size_t length = aOutputLength;
|
||||
otError error = OT_ERROR_NONE;
|
||||
size_t length = aOutputLength;
|
||||
|
||||
otEXPECT_ACTION(aOutput, error = OT_ERROR_INVALID_ARGS);
|
||||
|
||||
|
||||
@@ -28,13 +28,13 @@
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include <driverlib/uart.h>
|
||||
#include <driverlib/prcm.h>
|
||||
#include <driverlib/ioc.h>
|
||||
#include <driverlib/prcm.h>
|
||||
#include <driverlib/sys_ctrl.h>
|
||||
#include <driverlib/uart.h>
|
||||
|
||||
#include <openthread/types.h>
|
||||
#include <utils/code_utils.h>
|
||||
#include <openthread/types.h>
|
||||
#include <openthread/platform/uart.h>
|
||||
|
||||
/**
|
||||
@@ -52,9 +52,9 @@ enum
|
||||
static uint8_t const *sSendBuffer = NULL;
|
||||
static uint16_t sSendLen = 0;
|
||||
|
||||
static uint8_t sReceiveBuffer[CC2650_RECV_CIRC_BUFF_SIZE];
|
||||
static uint16_t sReceiveHeadIdx = 0;
|
||||
static uint16_t sReceiveTailIdx = 0;
|
||||
static uint8_t sReceiveBuffer[CC2650_RECV_CIRC_BUFF_SIZE];
|
||||
static uint16_t sReceiveHeadIdx = 0;
|
||||
static uint16_t sReceiveTailIdx = 0;
|
||||
|
||||
void UART0_intHandler(void);
|
||||
|
||||
@@ -65,14 +65,16 @@ otError otPlatUartEnable(void)
|
||||
{
|
||||
PRCMPowerDomainOn(PRCM_DOMAIN_SERIAL);
|
||||
|
||||
while (PRCMPowerDomainStatus(PRCM_DOMAIN_SERIAL) != PRCM_DOMAIN_POWER_ON);
|
||||
while (PRCMPowerDomainStatus(PRCM_DOMAIN_SERIAL) != PRCM_DOMAIN_POWER_ON)
|
||||
;
|
||||
|
||||
PRCMPeripheralRunEnable(PRCM_PERIPH_UART0);
|
||||
PRCMPeripheralSleepEnable(PRCM_PERIPH_UART0);
|
||||
PRCMPeripheralDeepSleepEnable(PRCM_PERIPH_UART0);
|
||||
PRCMLoadSet();
|
||||
|
||||
while (!PRCMLoadGet());
|
||||
while (!PRCMLoadGet())
|
||||
;
|
||||
|
||||
IOCPinTypeUart(UART0_BASE, IOID_2, IOID_3, IOID_UNUSED, IOID_UNUSED);
|
||||
|
||||
@@ -116,7 +118,7 @@ otError otPlatUartSend(const uint8_t *aBuf, uint16_t aBufLength)
|
||||
otEXPECT_ACTION(sSendBuffer == NULL, error = OT_ERROR_BUSY);
|
||||
|
||||
sSendBuffer = aBuf;
|
||||
sSendLen = aBufLength;
|
||||
sSendLen = aBufLength;
|
||||
|
||||
exit:
|
||||
return error;
|
||||
@@ -160,7 +162,7 @@ static void processTransmit(void)
|
||||
}
|
||||
|
||||
sSendBuffer = NULL;
|
||||
sSendLen = 0;
|
||||
sSendLen = 0;
|
||||
otPlatUartSendDone();
|
||||
|
||||
exit:
|
||||
@@ -194,4 +196,3 @@ void UART0_intHandler(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,9 +34,9 @@
|
||||
|
||||
#include <openthread/config.h>
|
||||
|
||||
#include <driverlib/aon_rtc.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <driverlib/aon_rtc.h>
|
||||
|
||||
#include <openthread/openthread.h>
|
||||
|
||||
@@ -128,4 +128,3 @@ void cc2652AlarmProcess(otInstance *aInstance)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,18 +26,18 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "mbedtls/aes.h"
|
||||
#include "aes_alt.h"
|
||||
#include "mbedtls/aes.h"
|
||||
|
||||
#ifdef MBEDTLS_AES_ALT
|
||||
|
||||
#include <string.h>
|
||||
#include <driverlib/crypto.h>
|
||||
#include <driverlib/prcm.h>
|
||||
#include <string.h>
|
||||
#include <utils/code_utils.h>
|
||||
|
||||
#define CC2652_AES_KEY_UNUSED (-1)
|
||||
#define CC2652_AES_CTX_MAGIC (0x7E)
|
||||
#define CC2652_AES_CTX_MAGIC (0x7E)
|
||||
|
||||
/**
|
||||
* bitmap of which key stores are currently used
|
||||
@@ -69,11 +69,11 @@ void mbedtls_aes_init(mbedtls_aes_context *ctx)
|
||||
PRCMPeripheralDeepSleepEnable(PRCM_PERIPH_CRYPTO);
|
||||
PRCMLoadSet();
|
||||
|
||||
while (!PRCMLoadGet());
|
||||
|
||||
while (!PRCMLoadGet())
|
||||
;
|
||||
}
|
||||
|
||||
ctx->magic = CC2652_AES_CTX_MAGIC;
|
||||
ctx->magic = CC2652_AES_CTX_MAGIC;
|
||||
ctx->key_idx = CC2652_AES_KEY_UNUSED;
|
||||
}
|
||||
|
||||
@@ -104,8 +104,8 @@ void mbedtls_aes_free(mbedtls_aes_context *ctx)
|
||||
PRCMPeripheralDeepSleepDisable(PRCM_PERIPH_CRYPTO);
|
||||
PRCMLoadSet();
|
||||
|
||||
while (!PRCMLoadGet());
|
||||
|
||||
while (!PRCMLoadGet())
|
||||
;
|
||||
}
|
||||
|
||||
memset((void *)ctx, 0x00, sizeof(ctx));
|
||||
@@ -120,7 +120,7 @@ exit:
|
||||
int mbedtls_aes_setkey_enc(mbedtls_aes_context *ctx, const unsigned char *key, unsigned int keybits)
|
||||
{
|
||||
unsigned char key_idx;
|
||||
int retval = 0;
|
||||
int retval = 0;
|
||||
|
||||
otEXPECT_ACTION(ctx->magic == CC2652_AES_CTX_MAGIC, retval = -1);
|
||||
|
||||
@@ -132,7 +132,8 @@ int mbedtls_aes_setkey_enc(mbedtls_aes_context *ctx, const unsigned char *key, u
|
||||
/* our hardware only supports 128 bit keys */
|
||||
otEXPECT_ACTION(keybits == 128u, retval = MBEDTLS_ERR_AES_INVALID_KEY_LENGTH);
|
||||
|
||||
for (key_idx = 0; ((sUsedKeys >> key_idx) & 0x01) != 0 && key_idx < 8; key_idx++);
|
||||
for (key_idx = 0; ((sUsedKeys >> key_idx) & 0x01) != 0 && key_idx < 8; key_idx++)
|
||||
;
|
||||
|
||||
/* we have no more room for this key */
|
||||
otEXPECT_ACTION(key_idx < 8, retval = -2);
|
||||
@@ -152,7 +153,7 @@ exit:
|
||||
int mbedtls_aes_setkey_dec(mbedtls_aes_context *ctx, const unsigned char *key, unsigned int keybits)
|
||||
{
|
||||
unsigned char key_idx;
|
||||
int retval = 0;
|
||||
int retval = 0;
|
||||
|
||||
otEXPECT_ACTION(ctx->magic == CC2652_AES_CTX_MAGIC, retval = -1);
|
||||
|
||||
@@ -164,7 +165,8 @@ int mbedtls_aes_setkey_dec(mbedtls_aes_context *ctx, const unsigned char *key, u
|
||||
/* our hardware only supports 128 bit keys */
|
||||
otEXPECT_ACTION(keybits == 128u, retval = MBEDTLS_ERR_AES_INVALID_KEY_LENGTH);
|
||||
|
||||
for (key_idx = 0; ((sUsedKeys >> key_idx) & 0x01) != 0 && key_idx < 8; key_idx++);
|
||||
for (key_idx = 0; ((sUsedKeys >> key_idx) & 0x01) != 0 && key_idx < 8; key_idx++)
|
||||
;
|
||||
|
||||
/* we have no more room for this key */
|
||||
otEXPECT_ACTION(key_idx < 8, retval = -2);
|
||||
@@ -188,7 +190,8 @@ int mbedtls_aes_crypt_ecb(mbedtls_aes_context *ctx, int mode, const unsigned cha
|
||||
retval = CRYPTOAesEcb((uint32_t *)input, (uint32_t *)output, ctx->key_idx, mode == MBEDTLS_AES_ENCRYPT, false);
|
||||
otEXPECT(retval == AES_SUCCESS);
|
||||
|
||||
while ((retval = CRYPTOAesEcbStatus()) == AES_DMA_BSY);
|
||||
while ((retval = CRYPTOAesEcbStatus()) == AES_DMA_BSY)
|
||||
;
|
||||
|
||||
CRYPTOAesEcbFinish();
|
||||
|
||||
|
||||
@@ -49,6 +49,6 @@ void __cxa_guard_abort(__guard *g)
|
||||
|
||||
void __cxa_pure_virtual(void)
|
||||
{
|
||||
while (1);
|
||||
while (1)
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,8 +33,8 @@
|
||||
#include <driverlib/interrupt.h>
|
||||
#include <driverlib/vims.h>
|
||||
|
||||
#include <openthread/config.h>
|
||||
#include <openthread-core-config.h>
|
||||
#include <openthread/config.h>
|
||||
#include <openthread/platform/alarm-milli.h>
|
||||
|
||||
#include <utils/code_utils.h>
|
||||
@@ -48,7 +48,7 @@
|
||||
*/
|
||||
#ifndef SETTINGS_CONFIG_BASE_ADDRESS
|
||||
#error "SETTINGS_CONFIG_BASE_ADDRESS not defined in the OpenThread Core Config"
|
||||
#endif /* SETTINGS_CONFIG_BASE_ADDRESS */
|
||||
#endif /* SETTINGS_CONFIG_BASE_ADDRESS */
|
||||
|
||||
/*
|
||||
* The settings configuration page size *MUST* be defined in the core config
|
||||
@@ -64,14 +64,14 @@
|
||||
*/
|
||||
#ifndef SETTINGS_CONFIG_PAGE_NUM
|
||||
#warn "SETTINGS_CONFIG_PAGE_NUM not defined in the OpenThread Core Config"
|
||||
#endif /* SETTINGS_CONFIG_PAGE_NUM */
|
||||
#endif /* SETTINGS_CONFIG_PAGE_NUM */
|
||||
|
||||
enum
|
||||
{
|
||||
MIN_VDD_FLASH = 0x18, /* 1.50 volts (0.50=128/256 -> 128=0x80) */
|
||||
MAX_WRITE_INCREMENT = 8, /* maximum number of bytes to write at a time to
|
||||
* avoid interrupt latency while in ROM
|
||||
*/
|
||||
MIN_VDD_FLASH = 0x18, /* 1.50 volts (0.50=128/256 -> 128=0x80) */
|
||||
MAX_WRITE_INCREMENT = 8, /* maximum number of bytes to write at a time to
|
||||
* avoid interrupt latency while in ROM
|
||||
*/
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -84,10 +84,8 @@ enum
|
||||
static bool isBatMonOn(void)
|
||||
{
|
||||
uint32_t batMonCtl = HWREG(AON_BATMON_BASE + AON_BATMON_O_CTL);
|
||||
return ((batMonCtl & AON_BATMON_CTL_CALC_EN_M)
|
||||
== AON_BATMON_CTL_CALC_EN
|
||||
&& (batMonCtl & AON_BATMON_CTL_MEAS_EN_M)
|
||||
== AON_BATMON_CTL_MEAS_EN);
|
||||
return ((batMonCtl & AON_BATMON_CTL_CALC_EN_M) == AON_BATMON_CTL_CALC_EN &&
|
||||
(batMonCtl & AON_BATMON_CTL_MEAS_EN_M) == AON_BATMON_CTL_MEAS_EN);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -138,7 +136,8 @@ static uint32_t disableFlashCache(void)
|
||||
{
|
||||
VIMSModeSet(VIMS_BASE, VIMS_MODE_DISABLED);
|
||||
|
||||
while (VIMSModeGet(VIMS_BASE) != VIMS_MODE_DISABLED);
|
||||
while (VIMSModeGet(VIMS_BASE) != VIMS_MODE_DISABLED)
|
||||
;
|
||||
}
|
||||
|
||||
return mode;
|
||||
@@ -151,7 +150,6 @@ static uint32_t disableFlashCache(void)
|
||||
*/
|
||||
static void restoreFlashCache(uint32_t mode)
|
||||
{
|
||||
|
||||
if (mode != VIMS_MODE_DISABLED)
|
||||
{
|
||||
VIMSModeSet(VIMS_BASE, mode);
|
||||
@@ -238,7 +236,7 @@ exit:
|
||||
otError utilsFlashStatusWait(uint32_t aTimeout)
|
||||
{
|
||||
uint32_t start = otPlatAlarmMilliGetNow();
|
||||
otError ret = OT_ERROR_BUSY;
|
||||
otError ret = OT_ERROR_BUSY;
|
||||
|
||||
while ((otPlatAlarmMilliGetNow() - start) < aTimeout)
|
||||
{
|
||||
@@ -267,10 +265,10 @@ uint32_t utilsFlashWrite(uint32_t aAddress, uint8_t *aData, uint32_t aSize)
|
||||
while (written < aSize)
|
||||
{
|
||||
uint32_t toWrite = aSize - written;
|
||||
uint8_t *data = aData + written;
|
||||
uint8_t *data = aData + written;
|
||||
uint32_t address = aAddress + written;
|
||||
uint32_t fsmRet;
|
||||
bool interruptsWereDisabled;
|
||||
bool interruptsWereDisabled;
|
||||
|
||||
if (toWrite > MAX_WRITE_INCREMENT)
|
||||
{
|
||||
@@ -313,4 +311,3 @@ uint32_t utilsFlashRead(uint32_t aAddress, uint8_t *aData, uint32_t aSize)
|
||||
|
||||
return aSize;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,15 +27,15 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file logging.c
|
||||
* Platform abstraction for the logging
|
||||
*
|
||||
*/
|
||||
#include <openthread/config.h>
|
||||
* @file logging.c
|
||||
* Platform abstraction for the logging
|
||||
*
|
||||
*/
|
||||
#include <openthread-core-config.h>
|
||||
#include <openthread/config.h>
|
||||
#include <openthread/platform/logging.h>
|
||||
|
||||
#if (OPENTHREAD_CONFIG_LOG_OUTPUT == OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED)
|
||||
#if (OPENTHREAD_CONFIG_LOG_OUTPUT == OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED)
|
||||
void otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, ...)
|
||||
{
|
||||
(void)aLogLevel;
|
||||
@@ -43,4 +43,3 @@ void otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat
|
||||
(void)aFormat;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -29,8 +29,8 @@
|
||||
#include <openthread/config.h>
|
||||
|
||||
#include <driverlib/sys_ctrl.h>
|
||||
#include <openthread/platform/misc.h>
|
||||
#include <openthread/types.h>
|
||||
#include <openthread/platform/misc.h>
|
||||
|
||||
/*
|
||||
* NOTE: if the system is flashed with Flash Programmer 2 or Uniflash, this
|
||||
@@ -91,4 +91,3 @@ void otPlatWakeHost(void)
|
||||
{
|
||||
// TODO: implement an operation to wake the host from sleep state.
|
||||
}
|
||||
|
||||
|
||||
@@ -29,9 +29,9 @@
|
||||
#ifndef PLATFORM_H_
|
||||
#define PLATFORM_H_
|
||||
|
||||
#include <openthread/config.h>
|
||||
#include <openthread-core-config.h>
|
||||
#include <stdint.h>
|
||||
#include <openthread/config.h>
|
||||
#include "openthread/types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -83,7 +83,7 @@ void cc2652RandomInit(void);
|
||||
void cc2652UartProcess(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // PLATFORM_H_
|
||||
#endif // PLATFORM_H_
|
||||
|
||||
@@ -34,13 +34,13 @@
|
||||
|
||||
#include <openthread/config.h>
|
||||
|
||||
#include "platform-cc2652.h"
|
||||
#include <stdio.h>
|
||||
#include <openthread/types.h>
|
||||
#include "platform-cc2652.h"
|
||||
|
||||
#include "inc/hw_types.h"
|
||||
#include "inc/hw_ccfg.h"
|
||||
#include "inc/hw_ccfg_simple_struct.h"
|
||||
#include "inc/hw_types.h"
|
||||
|
||||
extern const ccfg_t __ccfg;
|
||||
|
||||
@@ -51,8 +51,8 @@ const char *dummy_ccfg_ref = ((const char *)(&(__ccfg)));
|
||||
*/
|
||||
void PlatformInit(int argc, char *argv[])
|
||||
{
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
|
||||
while (dummy_ccfg_ref == NULL)
|
||||
{
|
||||
@@ -82,4 +82,3 @@ void PlatformProcessDrivers(otInstance *aInstance)
|
||||
cc2652RadioProcess(aInstance);
|
||||
cc2652AlarmProcess(aInstance);
|
||||
}
|
||||
|
||||
|
||||
@@ -35,32 +35,32 @@
|
||||
#include <openthread/config.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <utils/code_utils.h>
|
||||
#include <openthread/openthread.h>
|
||||
#include <openthread/types.h>
|
||||
#include <openthread/platform/alarm-milli.h>
|
||||
#include <openthread/platform/diag.h>
|
||||
#include <openthread/platform/radio.h>
|
||||
#include <openthread/platform/random.h> /* to seed the CSMA-CA funciton */
|
||||
#include <openthread/types.h>
|
||||
#include <utils/code_utils.h>
|
||||
|
||||
#include "cc2652_radio.h"
|
||||
#include <driverlib/chipinfo.h>
|
||||
#include <driverlib/osc.h>
|
||||
#include <driverlib/prcm.h>
|
||||
#include <driverlib/rf_common_cmd.h>
|
||||
#include <driverlib/rf_data_entry.h>
|
||||
#include <driverlib/rf_ieee_cmd.h>
|
||||
#include <driverlib/rf_ieee_mailbox.h>
|
||||
#include <driverlib/rf_mailbox.h>
|
||||
#include <driverlib/rfc.h>
|
||||
#include <inc/hw_ccfg.h>
|
||||
#include <inc/hw_fcfg1.h>
|
||||
#include <inc/hw_memmap.h>
|
||||
#include <inc/hw_prcm.h>
|
||||
#include <driverlib/chipinfo.h>
|
||||
#include <driverlib/osc.h>
|
||||
#include <driverlib/prcm.h>
|
||||
#include <driverlib/rfc.h>
|
||||
#include <driverlib/rf_data_entry.h>
|
||||
#include <driverlib/rf_mailbox.h>
|
||||
#include <driverlib/rf_common_cmd.h>
|
||||
#include <driverlib/rf_ieee_mailbox.h>
|
||||
#include <driverlib/rf_ieee_cmd.h>
|
||||
|
||||
enum
|
||||
{
|
||||
CC2652_RECEIVE_SENSITIVITY = -100, // dBm
|
||||
CC2652_RECEIVE_SENSITIVITY = -100, // dBm
|
||||
};
|
||||
|
||||
/* phy state as defined by openthread */
|
||||
@@ -71,8 +71,7 @@ static output_config_t const *sCurrentOutputPower = &(rgOutputPower[0]);
|
||||
|
||||
/* TODO: replace with correct overrides, pre-Alpha */
|
||||
/* Overrides for IEEE 802.15.4, differential mode */
|
||||
static uint32_t sIEEEOverrides[] =
|
||||
{
|
||||
static uint32_t sIEEEOverrides[] = {
|
||||
0x00008403, // Use 48 MHz Crystal
|
||||
0x000088C3, // Disabling dynamic DCDC settings control in RX
|
||||
0x000088D3, // Disabling dynamic DCDC settings control in TX
|
||||
@@ -141,13 +140,13 @@ static __attribute__((aligned(4))) uint8_t sRxBuf3[RX_BUF_SIZE];
|
||||
/*
|
||||
* The RX Data Queue used by @ref sReceiveCmd.
|
||||
*/
|
||||
static __attribute__((aligned(4))) dataQueue_t sRxDataQueue = { 0 };
|
||||
static __attribute__((aligned(4))) dataQueue_t sRxDataQueue = {0};
|
||||
|
||||
/*
|
||||
* OpenThread data primitives
|
||||
*/
|
||||
static otRadioFrame sTransmitFrame;
|
||||
static otError sTransmitError;
|
||||
static otError sTransmitError;
|
||||
|
||||
static __attribute__((aligned(4))) uint8_t sTransmitPsdu[OT_RADIO_FRAME_MAX_SIZE];
|
||||
|
||||
@@ -323,7 +322,7 @@ static uint_fast8_t rfCoreClearReceiveQueue(dataQueue_t *aQueue)
|
||||
{
|
||||
/* memset skipped because sClearReceiveQueueCmd has only 2 members and padding */
|
||||
sClearReceiveQueueCmd.commandNo = CMD_CLEAR_RX;
|
||||
sClearReceiveQueueCmd.pQueue = aQueue;
|
||||
sClearReceiveQueueCmd.pQueue = aQueue;
|
||||
|
||||
return (RFCDoorbellSendTo((uint32_t)&sClearReceiveQueueCmd) & 0xFF);
|
||||
}
|
||||
@@ -438,7 +437,7 @@ static uint_fast8_t rfCoreModifySourceMatchEntry(uint8_t aEntryNo, cc2652_addres
|
||||
}
|
||||
|
||||
sModifyReceiveSrcMatchCmd.options.entryType = aType;
|
||||
sModifyReceiveSrcMatchCmd.entryNo = aEntryNo;
|
||||
sModifyReceiveSrcMatchCmd.entryNo = aEntryNo;
|
||||
|
||||
return (RFCDoorbellSendTo((uint32_t)&sModifyReceiveSrcMatchCmd) & 0xFF);
|
||||
}
|
||||
@@ -621,24 +620,24 @@ static uint_fast8_t rfCoreSendTransmitCmd(uint8_t *aPsdu, uint8_t aLen)
|
||||
/* reset retry count */
|
||||
sTransmitRetryCount = 0;
|
||||
|
||||
sCsmacaBackoffCmd = cCsmacaBackoffCmd;
|
||||
sCsmacaBackoffCmd = cCsmacaBackoffCmd;
|
||||
/* initialize the random state with a true random seed for the radio core's
|
||||
* psudo rng */
|
||||
sCsmacaBackoffCmd.randomState = otPlatRandomGet();
|
||||
sCsmacaBackoffCmd.pNextOp = (rfc_radioOp_t *) &sTransmitCmd;
|
||||
sCsmacaBackoffCmd.randomState = otPlatRandomGet();
|
||||
sCsmacaBackoffCmd.pNextOp = (rfc_radioOp_t *)&sTransmitCmd;
|
||||
|
||||
sTransmitCmd = cTransmitCmd;
|
||||
/* no need to look for an ack if the tx operation was stopped */
|
||||
sTransmitCmd.payloadLen = aLen;
|
||||
sTransmitCmd.pPayload = aPsdu;
|
||||
sTransmitCmd.pPayload = aPsdu;
|
||||
|
||||
if (aPsdu[0] & IEEE802154_ACK_REQUEST)
|
||||
{
|
||||
/* setup the receive ack command to follow the tx command */
|
||||
sTransmitCmd.condition.rule = COND_STOP_ON_FALSE;
|
||||
sTransmitCmd.pNextOp = (rfc_radioOp_t *) &sTransmitRxAckCmd;
|
||||
sTransmitCmd.pNextOp = (rfc_radioOp_t *)&sTransmitRxAckCmd;
|
||||
|
||||
sTransmitRxAckCmd = cTransmitRxAckCmd;
|
||||
sTransmitRxAckCmd = cTransmitRxAckCmd;
|
||||
sTransmitRxAckCmd.seqNo = aPsdu[IEEE802154_DSN_OFFSET];
|
||||
}
|
||||
|
||||
@@ -812,7 +811,8 @@ static uint_fast8_t rfCorePowerOn(void)
|
||||
if (oscSourceSwitch)
|
||||
{
|
||||
/* Block until the high frequency clock source is ready */
|
||||
while (!OSCHfSourceReady());
|
||||
while (!OSCHfSourceReady())
|
||||
;
|
||||
|
||||
/* Switch the HF clock source (cc26xxware executes this from ROM) */
|
||||
OSCHfSourceSwitch();
|
||||
@@ -823,12 +823,14 @@ static uint_fast8_t rfCorePowerOn(void)
|
||||
/* Enable RF Core power domain */
|
||||
PRCMPowerDomainOn(PRCM_DOMAIN_RFCORE);
|
||||
|
||||
while (PRCMPowerDomainStatus(PRCM_DOMAIN_RFCORE) != PRCM_DOMAIN_POWER_ON);
|
||||
while (PRCMPowerDomainStatus(PRCM_DOMAIN_RFCORE) != PRCM_DOMAIN_POWER_ON)
|
||||
;
|
||||
|
||||
PRCMDomainEnable(PRCM_DOMAIN_RFCORE);
|
||||
PRCMLoadSet();
|
||||
|
||||
while (!PRCMLoadGet());
|
||||
while (!PRCMLoadGet())
|
||||
;
|
||||
|
||||
rfCoreSetupInt();
|
||||
|
||||
@@ -838,8 +840,8 @@ static uint_fast8_t rfCorePowerOn(void)
|
||||
}
|
||||
|
||||
/* Let CPE boot */
|
||||
HWREG(RFC_PWR_NONBUF_BASE + RFC_PWR_O_PWMCLKEN) = (RFC_PWR_PWMCLKEN_RFC_M | RFC_PWR_PWMCLKEN_CPE_M |
|
||||
RFC_PWR_PWMCLKEN_CPERAM_M);
|
||||
HWREG(RFC_PWR_NONBUF_BASE + RFC_PWR_O_PWMCLKEN) =
|
||||
(RFC_PWR_PWMCLKEN_RFC_M | RFC_PWR_PWMCLKEN_CPE_M | RFC_PWR_PWMCLKEN_CPERAM_M);
|
||||
|
||||
/* Send ping (to verify RFCore is ready and alive) */
|
||||
return rfCoreExecutePingCmd();
|
||||
@@ -861,11 +863,13 @@ static void rfCorePowerOff(void)
|
||||
PRCMDomainDisable(PRCM_DOMAIN_RFCORE);
|
||||
PRCMLoadSet();
|
||||
|
||||
while (!PRCMLoadGet());
|
||||
while (!PRCMLoadGet())
|
||||
;
|
||||
|
||||
PRCMPowerDomainOff(PRCM_DOMAIN_RFCORE);
|
||||
|
||||
while (PRCMPowerDomainStatus(PRCM_DOMAIN_RFCORE) != PRCM_DOMAIN_POWER_OFF);
|
||||
while (PRCMPowerDomainStatus(PRCM_DOMAIN_RFCORE) != PRCM_DOMAIN_POWER_OFF)
|
||||
;
|
||||
|
||||
if (OSCClockSourceGet(OSC_SRC_CLK_HF) != OSC_RCOSC_HF)
|
||||
{
|
||||
@@ -921,11 +925,11 @@ static uint_fast16_t rfCoreSendEnableCmd(void)
|
||||
|
||||
/* initialize the rat start command */
|
||||
sStartRatCmd = cStartRatCmd;
|
||||
sStartRatCmd.pNextOp = (rfc_radioOp_t *) &sRadioSetupCmd;
|
||||
sStartRatCmd.pNextOp = (rfc_radioOp_t *)&sRadioSetupCmd;
|
||||
sStartRatCmd.rat0 = sRatOffset;
|
||||
|
||||
/* initialize radio setup command */
|
||||
sRadioSetupCmd = cRadioSetupCmd;
|
||||
sRadioSetupCmd = cRadioSetupCmd;
|
||||
/* initally set the radio tx power to the max */
|
||||
sRadioSetupCmd.txPower = sCurrentOutputPower->value;
|
||||
sRadioSetupCmd.pRegOverride = sIEEEOverrides;
|
||||
@@ -936,7 +940,8 @@ static uint_fast16_t rfCoreSendEnableCmd(void)
|
||||
otEXPECT_ACTION(CMDSTA_Done == doorbellRet, ret = doorbellRet);
|
||||
|
||||
/* synchronously wait for the CM0 to stop executing */
|
||||
while ((HWREG(RFC_DBELL_NONBUF_BASE + RFC_DBELL_O_RFCPEIFG) & IRQ_LAST_COMMAND_DONE) == 0x00);
|
||||
while ((HWREG(RFC_DBELL_NONBUF_BASE + RFC_DBELL_O_RFCPEIFG) & IRQ_LAST_COMMAND_DONE) == 0x00)
|
||||
;
|
||||
|
||||
ret = sRadioSetupCmd.status;
|
||||
|
||||
@@ -994,7 +999,7 @@ static uint_fast16_t rfCoreSendDisableCmd(void)
|
||||
HWREGBITW(AON_RTC_BASE + AON_RTC_O_CTL, AON_RTC_CTL_RTC_UPD_EN_BITN) = 1;
|
||||
|
||||
/* initialize the command to power down the frequency synth */
|
||||
sFsPowerdownCmd = cFsPowerdownCmd;
|
||||
sFsPowerdownCmd = cFsPowerdownCmd;
|
||||
sFsPowerdownCmd.pNextOp = (rfc_radioOp_t *)&sStopRatCmd;
|
||||
|
||||
sStopRatCmd = cStopRatCmd;
|
||||
@@ -1006,9 +1011,9 @@ static uint_fast16_t rfCoreSendDisableCmd(void)
|
||||
doorbellRet = (RFCDoorbellSendTo((uint32_t)&sFsPowerdownCmd) & 0xFF);
|
||||
otEXPECT_ACTION(CMDSTA_Done == doorbellRet, ret = doorbellRet);
|
||||
|
||||
|
||||
/* synchronously wait for the CM0 to stop */
|
||||
while ((HWREG(RFC_DBELL_NONBUF_BASE + RFC_DBELL_O_RFCPEIFG) & IRQ_LAST_COMMAND_DONE) == 0x00);
|
||||
while ((HWREG(RFC_DBELL_NONBUF_BASE + RFC_DBELL_O_RFCPEIFG) & IRQ_LAST_COMMAND_DONE) == 0x00)
|
||||
;
|
||||
|
||||
ret = sStopRatCmd.status;
|
||||
|
||||
@@ -1045,9 +1050,7 @@ void RFCCPE0IntHandler(void)
|
||||
{
|
||||
HWREG(RFC_DBELL_NONBUF_BASE + RFC_DBELL_O_RFCPEIFG) = ~IRQ_LAST_COMMAND_DONE;
|
||||
|
||||
if (sState == cc2652_stateReceive &&
|
||||
sReceiveCmd.status != ACTIVE &&
|
||||
sReceiveCmd.status != IEEE_SUSPENDED)
|
||||
if (sState == cc2652_stateReceive && sReceiveCmd.status != ACTIVE && sReceiveCmd.status != IEEE_SUSPENDED)
|
||||
{
|
||||
/* the rx command was probably aborted to change the channel */
|
||||
sState = cc2652_stateSleep;
|
||||
@@ -1211,7 +1214,7 @@ otError otPlatRadioDisable(otInstance *aInstance)
|
||||
*/
|
||||
rfCorePowerOff();
|
||||
sState = cc2652_stateDisabled;
|
||||
error = OT_ERROR_NONE;
|
||||
error = OT_ERROR_NONE;
|
||||
}
|
||||
|
||||
return error;
|
||||
@@ -1256,7 +1259,7 @@ exit:
|
||||
*/
|
||||
otError otPlatRadioSetTransmitPower(otInstance *aInstance, int8_t aPower)
|
||||
{
|
||||
unsigned int i;
|
||||
unsigned int i;
|
||||
output_config_t const *powerCfg = &(rgOutputPower[0]);
|
||||
(void)aInstance;
|
||||
|
||||
@@ -1304,7 +1307,7 @@ otError otPlatRadioReceive(otInstance *aInstance, uint8_t aChannel)
|
||||
{
|
||||
/* we are already running on the right channel */
|
||||
sState = cc2652_stateReceive;
|
||||
error = OT_ERROR_NONE;
|
||||
error = OT_ERROR_NONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1322,7 +1325,7 @@ otError otPlatRadioReceive(otInstance *aInstance, uint8_t aChannel)
|
||||
otEXPECT_ACTION(rfCoreSendReceiveCmd() == CMDSTA_Done, error = OT_ERROR_FAILED);
|
||||
|
||||
sState = cc2652_stateReceive;
|
||||
error = OT_ERROR_NONE;
|
||||
error = OT_ERROR_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1380,8 +1383,8 @@ otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aFrame)
|
||||
/* removing 2 bytes of CRC placeholder because we generate that in hardware */
|
||||
otEXPECT_ACTION(rfCoreSendTransmitCmd(aFrame->mPsdu, aFrame->mLength - 2) == CMDSTA_Done,
|
||||
error = OT_ERROR_FAILED);
|
||||
error = OT_ERROR_NONE;
|
||||
sTransmitError = OT_ERROR_NONE;
|
||||
error = OT_ERROR_NONE;
|
||||
sTransmitError = OT_ERROR_NONE;
|
||||
sTxCmdChainDone = false;
|
||||
otPlatRadioTxStarted(aInstance, aFrame);
|
||||
}
|
||||
@@ -1439,17 +1442,15 @@ otError otPlatRadioAddSrcMatchShortEntry(otInstance *aInstance, const uint16_t a
|
||||
if (idx == CC2652_SRC_MATCH_NONE)
|
||||
{
|
||||
/* the entry does not exist already, add it */
|
||||
otEXPECT_ACTION((idx = rfCoreFindEmptyShortSrcMatchIdx()) != CC2652_SRC_MATCH_NONE,
|
||||
error = OT_ERROR_NO_BUFS);
|
||||
otEXPECT_ACTION((idx = rfCoreFindEmptyShortSrcMatchIdx()) != CC2652_SRC_MATCH_NONE, error = OT_ERROR_NO_BUFS);
|
||||
sSrcMatchShortData.extAddrEnt[idx].shortAddr = aShortAddress;
|
||||
sSrcMatchShortData.extAddrEnt[idx].panId = sReceiveCmd.localPanID;
|
||||
sSrcMatchShortData.extAddrEnt[idx].panId = sReceiveCmd.localPanID;
|
||||
}
|
||||
|
||||
if (sReceiveCmd.status == ACTIVE || sReceiveCmd.status == IEEE_SUSPENDED)
|
||||
{
|
||||
/* we have a running or backgrounded rx command */
|
||||
otEXPECT_ACTION(rfCoreModifySourceMatchEntry(idx, SHORT_ADDRESS, true) == CMDSTA_Done,
|
||||
error = OT_ERROR_FAILED);
|
||||
otEXPECT_ACTION(rfCoreModifySourceMatchEntry(idx, SHORT_ADDRESS, true) == CMDSTA_Done, error = OT_ERROR_FAILED);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1509,8 +1510,7 @@ otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const otExtAddress
|
||||
if (sReceiveCmd.status == ACTIVE || sReceiveCmd.status == IEEE_SUSPENDED)
|
||||
{
|
||||
/* we have a running or backgrounded rx command */
|
||||
otEXPECT_ACTION(rfCoreModifySourceMatchEntry(idx, EXT_ADDRESS, true) == CMDSTA_Done,
|
||||
error = OT_ERROR_FAILED);
|
||||
otEXPECT_ACTION(rfCoreModifySourceMatchEntry(idx, EXT_ADDRESS, true) == CMDSTA_Done, error = OT_ERROR_FAILED);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1537,13 +1537,12 @@ otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const otExtAddre
|
||||
if (sReceiveCmd.status == ACTIVE || sReceiveCmd.status == IEEE_SUSPENDED)
|
||||
{
|
||||
/* we have a running or backgrounded rx command */
|
||||
otEXPECT_ACTION(rfCoreModifySourceMatchEntry(idx, EXT_ADDRESS, false) == CMDSTA_Done,
|
||||
error = OT_ERROR_FAILED);
|
||||
otEXPECT_ACTION(rfCoreModifySourceMatchEntry(idx, EXT_ADDRESS, false) == CMDSTA_Done, error = OT_ERROR_FAILED);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* we are not running, so we must update the values ourselves */
|
||||
sSrcMatchExtData.srcPendEn[idx] = 0u;
|
||||
sSrcMatchExtData.srcPendEn[idx] = 0u;
|
||||
sSrcMatchExtData.srcMatchEn[idx] = 0u;
|
||||
sSrcMatchExtData.srcPendEn[idx / 32] &= ~(1 << (idx % 32));
|
||||
sSrcMatchExtData.srcMatchEn[idx / 32] &= ~(1 << (idx % 32));
|
||||
@@ -1554,8 +1553,8 @@ exit:
|
||||
}
|
||||
|
||||
/**
|
||||
* Function documented in platform/radio.h
|
||||
*/
|
||||
* Function documented in platform/radio.h
|
||||
*/
|
||||
void otPlatRadioClearSrcMatchShortEntries(otInstance *aInstance)
|
||||
{
|
||||
(void)aInstance;
|
||||
@@ -1581,8 +1580,8 @@ exit:
|
||||
}
|
||||
|
||||
/**
|
||||
* Function documented in platform/radio.h
|
||||
*/
|
||||
* Function documented in platform/radio.h
|
||||
*/
|
||||
void otPlatRadioClearSrcMatchExtEntries(otInstance *aInstance)
|
||||
{
|
||||
(void)aInstance;
|
||||
@@ -1643,7 +1642,7 @@ void otPlatRadioSetPromiscuous(otInstance *aInstance, bool aEnable)
|
||||
*/
|
||||
void otPlatRadioGetIeeeEui64(otInstance *aInstance, uint8_t *aIeeeEui64)
|
||||
{
|
||||
uint8_t *eui64;
|
||||
uint8_t * eui64;
|
||||
unsigned int i;
|
||||
(void)aInstance;
|
||||
|
||||
@@ -1773,8 +1772,10 @@ exit:
|
||||
return;
|
||||
}
|
||||
|
||||
static void cc2652RadioProcessTransmitDone(otInstance *aInstance, otRadioFrame *aTransmitFrame, otRadioFrame *aAckFrame,
|
||||
otError aTransmitError)
|
||||
static void cc2652RadioProcessTransmitDone(otInstance * aInstance,
|
||||
otRadioFrame *aTransmitFrame,
|
||||
otRadioFrame *aAckFrame,
|
||||
otError aTransmitError)
|
||||
{
|
||||
#if OPENTHREAD_ENABLE_DIAG
|
||||
|
||||
@@ -1806,12 +1807,12 @@ static void cc2652RadioProcessReceiveDone(otInstance *aInstance, otRadioFrame *a
|
||||
|
||||
static void cc2652RadioProcessReceiveQueue(otInstance *aInstance)
|
||||
{
|
||||
rfc_ieeeRxCorrCrc_t *crcCorr;
|
||||
rfc_ieeeRxCorrCrc_t * crcCorr;
|
||||
rfc_dataEntryGeneral_t *curEntry, *startEntry;
|
||||
uint8_t rssi;
|
||||
|
||||
startEntry = (rfc_dataEntryGeneral_t *)sRxDataQueue.pCurrEntry;
|
||||
curEntry = startEntry;
|
||||
curEntry = startEntry;
|
||||
|
||||
/* loop through receive queue */
|
||||
do
|
||||
@@ -1836,8 +1837,8 @@ static void cc2652RadioProcessReceiveQueue(otInstance *aInstance)
|
||||
{
|
||||
#if OPENTHREAD_ENABLE_RAW_LINK_API
|
||||
// TODO: Propagate CM0 timestamp
|
||||
receiveFrame.mMsec = otPlatAlarmMilliGetNow();
|
||||
receiveFrame.mUsec = 0; // Don't support microsecond timer for now.
|
||||
receiveFrame.mMsec = otPlatAlarmMilliGetNow();
|
||||
receiveFrame.mUsec = 0; // Don't support microsecond timer for now.
|
||||
#endif
|
||||
|
||||
receiveFrame.mLength = len;
|
||||
@@ -1875,8 +1876,7 @@ static void cc2652RadioProcessReceiveQueue(otInstance *aInstance)
|
||||
}
|
||||
|
||||
curEntry = (rfc_dataEntryGeneral_t *)(curEntry->pNextEntry);
|
||||
}
|
||||
while (curEntry != startEntry);
|
||||
} while (curEntry != startEntry);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1896,8 +1896,7 @@ void cc2652RadioProcess(otInstance *aInstance)
|
||||
}
|
||||
}
|
||||
|
||||
if (sState == cc2652_stateReceive
|
||||
|| sState == cc2652_stateTransmit)
|
||||
if (sState == cc2652_stateReceive || sState == cc2652_stateTransmit)
|
||||
{
|
||||
cc2652RadioProcessReceiveQueue(aInstance);
|
||||
}
|
||||
@@ -1911,7 +1910,7 @@ void cc2652RadioProcess(otInstance *aInstance)
|
||||
cc2652RadioProcessTransmitDone(aInstance, &sTransmitFrame, NULL, sTransmitError);
|
||||
}
|
||||
|
||||
sTransmitError = OT_ERROR_NONE;
|
||||
sTransmitError = OT_ERROR_NONE;
|
||||
sTxCmdChainDone = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,9 +30,9 @@
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include <openthread/platform/random.h>
|
||||
#include <openthread/types.h>
|
||||
#include <utils/code_utils.h>
|
||||
#include <openthread/types.h>
|
||||
#include <openthread/platform/random.h>
|
||||
|
||||
#include <driverlib/prcm.h>
|
||||
#include <driverlib/trng.h>
|
||||
@@ -56,7 +56,8 @@ void cc2652RandomInit(void)
|
||||
{
|
||||
PRCMPowerDomainOn(PRCM_DOMAIN_PERIPH);
|
||||
|
||||
while (PRCMPowerDomainStatus(PRCM_DOMAIN_PERIPH) != PRCM_DOMAIN_POWER_ON);
|
||||
while (PRCMPowerDomainStatus(PRCM_DOMAIN_PERIPH) != PRCM_DOMAIN_POWER_ON)
|
||||
;
|
||||
|
||||
PRCMPeripheralRunEnable(PRCM_PERIPH_TRNG);
|
||||
PRCMPeripheralSleepEnable(PRCM_DOMAIN_PERIPH);
|
||||
@@ -71,7 +72,8 @@ void cc2652RandomInit(void)
|
||||
*/
|
||||
uint32_t otPlatRandomGet(void)
|
||||
{
|
||||
while (!(TRNGStatusGet() & TRNG_NUMBER_READY));
|
||||
while (!(TRNGStatusGet() & TRNG_NUMBER_READY))
|
||||
;
|
||||
|
||||
return TRNGNumberGet(TRNG_LOW_WORD);
|
||||
}
|
||||
@@ -92,7 +94,7 @@ static int TRNGPoll(unsigned char *aOutput, size_t aLen)
|
||||
union
|
||||
{
|
||||
uint32_t u32[2];
|
||||
uint8_t u8[8];
|
||||
uint8_t u8[8];
|
||||
} buffer;
|
||||
|
||||
while (length < aLen)
|
||||
@@ -100,14 +102,15 @@ static int TRNGPoll(unsigned char *aOutput, size_t aLen)
|
||||
if (length % 8 == 0)
|
||||
{
|
||||
/* we've run to the end of the buffer */
|
||||
while (!(TRNGStatusGet() & TRNG_NUMBER_READY));
|
||||
while (!(TRNGStatusGet() & TRNG_NUMBER_READY))
|
||||
;
|
||||
|
||||
/*
|
||||
* don't use TRNGNumberGet here because it will tell the TRNG to
|
||||
* refill the entropy pool, instead we do it ourself.
|
||||
*/
|
||||
buffer.u32[0] = HWREG(TRNG_BASE + TRNG_O_OUT0);
|
||||
buffer.u32[1] = HWREG(TRNG_BASE + TRNG_O_OUT1);
|
||||
buffer.u32[0] = HWREG(TRNG_BASE + TRNG_O_OUT0);
|
||||
buffer.u32[1] = HWREG(TRNG_BASE + TRNG_O_OUT1);
|
||||
HWREG(TRNG_BASE + TRNG_O_IRQFLAGCLR) = 0x1;
|
||||
}
|
||||
|
||||
@@ -119,14 +122,13 @@ static int TRNGPoll(unsigned char *aOutput, size_t aLen)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function documented in platform/random.h
|
||||
*/
|
||||
otError otPlatRandomGetTrue(uint8_t *aOutput, uint16_t aOutputLength)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
size_t length = aOutputLength;
|
||||
otError error = OT_ERROR_NONE;
|
||||
size_t length = aOutputLength;
|
||||
|
||||
otEXPECT_ACTION(aOutput, error = OT_ERROR_INVALID_ARGS);
|
||||
|
||||
|
||||
@@ -32,12 +32,12 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <openthread/config.h>
|
||||
#include <openthread-core-config.h>
|
||||
#include <openthread/config.h>
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <openthread/types.h>
|
||||
#include <openthread/platform/debug_uart.h>
|
||||
@@ -68,9 +68,9 @@ enum
|
||||
static uint8_t const *sSendBuffer = NULL;
|
||||
static uint16_t sSendLen = 0;
|
||||
|
||||
static uint8_t sReceiveBuffer[CC2652_RECV_CIRC_BUFF_SIZE];
|
||||
static uint16_t sReceiveHeadIdx = 0;
|
||||
static uint16_t sReceiveTailIdx = 0;
|
||||
static uint8_t sReceiveBuffer[CC2652_RECV_CIRC_BUFF_SIZE];
|
||||
static uint16_t sReceiveHeadIdx = 0;
|
||||
static uint16_t sReceiveTailIdx = 0;
|
||||
|
||||
void UART0_intHandler(void);
|
||||
|
||||
@@ -87,7 +87,8 @@ static void uart_power_control(uint32_t who_base, int turnon)
|
||||
value = (who_base == UART0_BASE) ? PRCM_DOMAIN_SERIAL : PRCM_DOMAIN_PERIPH;
|
||||
PRCMPowerDomainOn(value);
|
||||
|
||||
while (PRCMPowerDomainStatus(value) != PRCM_DOMAIN_POWER_ON);
|
||||
while (PRCMPowerDomainStatus(value) != PRCM_DOMAIN_POWER_ON)
|
||||
;
|
||||
|
||||
value = (who_base == UART0_BASE) ? PRCM_PERIPH_UART0 : PRCM_PERIPH_UART1;
|
||||
PRCMPeripheralRunEnable(value);
|
||||
@@ -95,7 +96,8 @@ static void uart_power_control(uint32_t who_base, int turnon)
|
||||
PRCMPeripheralDeepSleepEnable(value);
|
||||
PRCMLoadSet();
|
||||
|
||||
while (!PRCMLoadGet());
|
||||
while (!PRCMLoadGet())
|
||||
;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -114,7 +116,6 @@ static void uart_power_control(uint32_t who_base, int turnon)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function documented in platform/uart.h
|
||||
*/
|
||||
@@ -162,7 +163,7 @@ otError otPlatUartSend(const uint8_t *aBuf, uint16_t aBufLength)
|
||||
otEXPECT_ACTION(sSendBuffer == NULL, error = OT_ERROR_BUSY);
|
||||
|
||||
sSendBuffer = aBuf;
|
||||
sSendLen = aBufLength;
|
||||
sSendLen = aBufLength;
|
||||
|
||||
exit:
|
||||
return error;
|
||||
@@ -206,7 +207,7 @@ static void processTransmit(void)
|
||||
}
|
||||
|
||||
sSendBuffer = NULL;
|
||||
sSendLen = 0;
|
||||
sSendLen = 0;
|
||||
otPlatUartSendDone();
|
||||
|
||||
exit:
|
||||
@@ -246,8 +247,7 @@ void UART0_intHandler(void)
|
||||
/*
|
||||
* Documented in platform-cc2652.h
|
||||
*/
|
||||
void
|
||||
cc2652DebugUartInit(void)
|
||||
void cc2652DebugUartInit(void)
|
||||
{
|
||||
uart_power_control(UART1_BASE, true);
|
||||
/*
|
||||
@@ -279,7 +279,7 @@ int otPlatDebugUart_getc(void)
|
||||
if (otPlatDebugUart_kbhit())
|
||||
{
|
||||
/* get & clear 0x100 bit used below as flag */
|
||||
ch = debug_uart_ungetbuf & 0x0ff;
|
||||
ch = debug_uart_ungetbuf & 0x0ff;
|
||||
debug_uart_ungetbuf = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,9 +27,9 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file alarm.c
|
||||
* Platform abstraction for the alarm
|
||||
*/
|
||||
* @file alarm.c
|
||||
* Platform abstraction for the alarm
|
||||
*/
|
||||
|
||||
#include <openthread/platform/alarm-milli.h>
|
||||
|
||||
@@ -37,10 +37,10 @@
|
||||
|
||||
#include "hw_timer0.h"
|
||||
|
||||
static bool sIsRunning = false;
|
||||
static uint32_t sAlarm = 0;
|
||||
static bool sIsRunning = false;
|
||||
static uint32_t sAlarm = 0;
|
||||
static uint32_t sCounter;
|
||||
volatile bool sAlarmFired = false;
|
||||
volatile bool sAlarmFired = false;
|
||||
|
||||
static void timer0_interrupt_cb(void)
|
||||
{
|
||||
@@ -75,7 +75,7 @@ uint32_t otPlatAlarmMilliGetNow(void)
|
||||
void otPlatAlarmMilliStartAt(otInstance *aInstance, uint32_t t0, uint32_t dt)
|
||||
{
|
||||
(void)aInstance;
|
||||
sAlarm = t0 + dt;
|
||||
sAlarm = t0 + dt;
|
||||
sIsRunning = true;
|
||||
|
||||
if (sCounter == 0)
|
||||
|
||||
@@ -26,21 +26,24 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "mbedtls/aes.h"
|
||||
#include "aes_alt.h"
|
||||
#include "mbedtls/aes.h"
|
||||
|
||||
#ifdef MBEDTLS_AES_ALT
|
||||
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <common/code_utils.hpp>
|
||||
#include "hw_aes_hash.h"
|
||||
#include <common/code_utils.hpp>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
static void mbedtls_zeroize(void *v, size_t n)
|
||||
{
|
||||
volatile unsigned char *p = (unsigned char *)v;
|
||||
|
||||
while (n--) { *p++ = 0; }
|
||||
while (n--)
|
||||
{
|
||||
*p++ = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void mbedtls_aes_init(mbedtls_aes_context *ctx)
|
||||
@@ -127,10 +130,7 @@ int mbedtls_aes_setkey_dec(mbedtls_aes_context *ctx, const unsigned char *key, u
|
||||
*
|
||||
* \return 0 if successful
|
||||
*/
|
||||
int mbedtls_aes_crypt_ecb(mbedtls_aes_context *ctx,
|
||||
int mode,
|
||||
const unsigned char input[16],
|
||||
unsigned char output[16])
|
||||
int mbedtls_aes_crypt_ecb(mbedtls_aes_context *ctx, int mode, const unsigned char input[16], unsigned char output[16])
|
||||
{
|
||||
int retval = 0;
|
||||
|
||||
@@ -169,15 +169,14 @@ int mbedtls_aes_self_test(int verbose)
|
||||
{
|
||||
(void)verbose;
|
||||
/* 128-bit Key 2b7e151628aed2a6abf7158809cf4f3c */
|
||||
const uint8_t key_128b[16] = { 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88,
|
||||
0x09, 0xcf, 0x4f, 0x3c
|
||||
};
|
||||
const uint8_t key_128b[16] = {0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6,
|
||||
0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c};
|
||||
|
||||
int retval = 0;
|
||||
int retval = 0;
|
||||
mbedtls_aes_context aes;
|
||||
uint8_t input[16] = {0};
|
||||
uint8_t output[16] = {0};
|
||||
uint8_t decrypt[16] = {0};
|
||||
uint8_t input[16] = {0};
|
||||
uint8_t output[16] = {0};
|
||||
uint8_t decrypt[16] = {0};
|
||||
|
||||
strcpy((char *)input, (const char *)"hw_cryptaes_test");
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
#define FLASH_BUFFER_SIZE 0x2000
|
||||
#define FLASH_SECTOR_SIZE 0x1000
|
||||
#define FLASH_PAGE_SIZE 0x0100
|
||||
#define FLASH_PAGE_SIZE 0x0100
|
||||
|
||||
/*
|
||||
* In case that user tries to write data to flash passing as source QSPI mapped flash address
|
||||
@@ -72,19 +72,19 @@ otError utilsFlashStatusWait(uint32_t aTimeout)
|
||||
|
||||
static inline bool FlashQspiAddress(const void *aBuf)
|
||||
{
|
||||
if (((uint32_t) aBuf >= MEMORY_QSPIF_BASE) && ((uint32_t) aBuf < MEMORY_QSPIF_END))
|
||||
if (((uint32_t)aBuf >= MEMORY_QSPIF_BASE) && ((uint32_t)aBuf < MEMORY_QSPIF_END))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return ((uint32_t) aBuf >= MEMORY_REMAPPED_BASE) && ((uint32_t) aBuf < MEMORY_REMAPPED_END)
|
||||
&& (REG_GETF(CRG_TOP, SYS_CTRL_REG, REMAP_ADR0) == 2);
|
||||
return ((uint32_t)aBuf >= MEMORY_REMAPPED_BASE) && ((uint32_t)aBuf < MEMORY_REMAPPED_END) &&
|
||||
(REG_GETF(CRG_TOP, SYS_CTRL_REG, REMAP_ADR0) == 2);
|
||||
}
|
||||
|
||||
static size_t FlashWriteFromQspi(uint32_t aAddress, const uint8_t *aQspiBuf, size_t aSize)
|
||||
{
|
||||
size_t written;
|
||||
size_t offset = 0;
|
||||
size_t written;
|
||||
size_t offset = 0;
|
||||
uint8_t buf[ON_STACK_BUFFER_SIZE];
|
||||
|
||||
/*
|
||||
@@ -107,8 +107,8 @@ static size_t FlashWriteFromQspi(uint32_t aAddress, const uint8_t *aQspiBuf, siz
|
||||
uint32_t utilsFlashWrite(uint32_t aAddress, uint8_t *aData, uint32_t aSize)
|
||||
{
|
||||
size_t written;
|
||||
size_t offset = 0;
|
||||
bool buf_from_flash = FlashQspiAddress(aData);
|
||||
size_t offset = 0;
|
||||
bool buf_from_flash = FlashQspiAddress(aData);
|
||||
|
||||
while (offset < aSize)
|
||||
{
|
||||
@@ -118,8 +118,7 @@ uint32_t utilsFlashWrite(uint32_t aAddress, uint8_t *aData, uint32_t aSize)
|
||||
*/
|
||||
if (buf_from_flash)
|
||||
{
|
||||
written = FlashWriteFromQspi(aAddress + offset, aData + offset,
|
||||
aSize - offset);
|
||||
written = FlashWriteFromQspi(aAddress + offset, aData + offset, aSize - offset);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -127,8 +126,7 @@ uint32_t utilsFlashWrite(uint32_t aAddress, uint8_t *aData, uint32_t aSize)
|
||||
* Try write everything, lower driver will reduce this value to accommodate
|
||||
* page boundary and and maximum write size limitation
|
||||
*/
|
||||
written = qspi_automode_write_flash_page(aAddress + offset, aData + offset,
|
||||
aSize - offset);
|
||||
written = qspi_automode_write_flash_page(aAddress + offset, aData + offset, aSize - offset);
|
||||
}
|
||||
|
||||
offset += written;
|
||||
@@ -141,5 +139,6 @@ uint32_t utilsFlashWrite(uint32_t aAddress, uint8_t *aData, uint32_t aSize)
|
||||
|
||||
uint32_t utilsFlashRead(uint32_t aAddress, uint8_t *aData, uint32_t aSize)
|
||||
{
|
||||
return qspi_automode_read(aAddress, aData, aSize);;
|
||||
return qspi_automode_read(aAddress, aData, aSize);
|
||||
;
|
||||
}
|
||||
|
||||
@@ -27,10 +27,10 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file logging.c
|
||||
* Platform abstraction for the logging
|
||||
*
|
||||
*/
|
||||
* @file logging.c
|
||||
* Platform abstraction for the logging
|
||||
*
|
||||
*/
|
||||
|
||||
#include <openthread/platform/logging.h>
|
||||
|
||||
|
||||
Executable → Regular
+1
-1
@@ -29,8 +29,8 @@
|
||||
#ifndef PLATFORM_DA15000_H_
|
||||
#define PLATFORM_DA15000_H_
|
||||
|
||||
#include <openthread/config.h>
|
||||
#include <openthread-core-config.h>
|
||||
#include <openthread/config.h>
|
||||
#include <openthread/types.h>
|
||||
|
||||
/**
|
||||
|
||||
@@ -66,16 +66,16 @@ static otInstance *sInstance = NULL;
|
||||
*/
|
||||
static void ExampleProcess(otInstance *aInstance)
|
||||
{
|
||||
static int aliveLEDcounter = 0;
|
||||
otDeviceRole devRole;
|
||||
static int thrValue;
|
||||
static int aliveLEDcounter = 0;
|
||||
otDeviceRole devRole;
|
||||
static int thrValue;
|
||||
|
||||
devRole = otThreadGetDeviceRole(aInstance);
|
||||
|
||||
if (sBlink == false && otPlatAlarmMilliGetNow() != 0)
|
||||
{
|
||||
sMsCounterInit = otPlatAlarmMilliGetNow();
|
||||
sBlink = true;
|
||||
sBlink = true;
|
||||
}
|
||||
|
||||
sMsCounter = otPlatAlarmMilliGetNow() - sMsCounterInit;
|
||||
@@ -140,8 +140,8 @@ void PlatformInit(int argc, char *argv[])
|
||||
|
||||
static sys_clk_t ClkGet(void)
|
||||
{
|
||||
sys_clk_t clk = sysclk_RC16;
|
||||
uint32_t hw_clk = hw_cpm_get_sysclk();
|
||||
sys_clk_t clk = sysclk_RC16;
|
||||
uint32_t hw_clk = hw_cpm_get_sysclk();
|
||||
|
||||
switch (hw_clk)
|
||||
{
|
||||
@@ -175,7 +175,7 @@ static sys_clk_t ClkGet(void)
|
||||
|
||||
case SYS_CLK_IS_LP:
|
||||
|
||||
// fall-through
|
||||
// fall-through
|
||||
|
||||
default:
|
||||
ASSERT_WARNING(0);
|
||||
@@ -192,16 +192,17 @@ static void ClkSet(sys_clk_t clock)
|
||||
case sysclk_XTAL16M:
|
||||
if (!hw_cpm_check_xtal16m_status()) // XTAL16M disabled
|
||||
{
|
||||
hw_cpm_enable_xtal16m(); // Enable XTAL16M
|
||||
hw_cpm_enable_xtal16m(); // Enable XTAL16M
|
||||
}
|
||||
|
||||
hw_cpm_set_sysclk(SYS_CLK_IS_XTAL16M); // Set XTAL16 as sys_clk
|
||||
hw_watchdog_unfreeze(); // Start watchdog
|
||||
hw_cpm_set_sysclk(SYS_CLK_IS_XTAL16M); // Set XTAL16 as sys_clk
|
||||
hw_watchdog_unfreeze(); // Start watchdog
|
||||
|
||||
while (!hw_cpm_is_xtal16m_started()); // Block until XTAL16M starts
|
||||
while (!hw_cpm_is_xtal16m_started())
|
||||
; // Block until XTAL16M starts
|
||||
|
||||
hw_qspi_set_div(HW_QSPI_DIV_1);
|
||||
hw_watchdog_freeze(); // Stop watchdog
|
||||
hw_watchdog_freeze(); // Stop watchdog
|
||||
hw_cpm_set_hclk_div(0);
|
||||
hw_cpm_set_pclk_div(0);
|
||||
break;
|
||||
@@ -209,10 +210,10 @@ static void ClkSet(sys_clk_t clock)
|
||||
case sysclk_PLL48:
|
||||
if (hw_cpm_is_pll_locked() == 0)
|
||||
{
|
||||
hw_cpm_pll_sys_on(); // Turn on PLL
|
||||
hw_cpm_pll_sys_on(); // Turn on PLL
|
||||
}
|
||||
|
||||
hw_cpm_enable_pll_divider(); // Enable divider (div by 2)
|
||||
hw_cpm_enable_pll_divider(); // Enable divider (div by 2)
|
||||
hw_qspi_set_div(HW_QSPI_DIV_1);
|
||||
hw_cpm_set_sysclk(SYS_CLK_IS_PLL);
|
||||
hw_cpm_set_hclk_div(0);
|
||||
@@ -222,10 +223,10 @@ static void ClkSet(sys_clk_t clock)
|
||||
case sysclk_PLL96:
|
||||
if (hw_cpm_is_pll_locked() == 0)
|
||||
{
|
||||
hw_cpm_pll_sys_on(); // Turn on PLL
|
||||
hw_cpm_pll_sys_on(); // Turn on PLL
|
||||
}
|
||||
|
||||
hw_cpm_disable_pll_divider(); // Disable divider (div by 1)
|
||||
hw_cpm_disable_pll_divider(); // Disable divider (div by 1)
|
||||
hw_qspi_set_div(HW_QSPI_DIV_2);
|
||||
hw_cpm_set_sysclk(SYS_CLK_IS_PLL);
|
||||
hw_cpm_set_hclk_div(0);
|
||||
@@ -245,7 +246,7 @@ static void ClkChange(sys_clk_t lastClock, sys_clk_t newClock)
|
||||
}
|
||||
}
|
||||
|
||||
static void StateChangedCallback(uint32_t aFlags, void *aContext)
|
||||
static void StateChangedCallback(uint32_t aFlags, void *aContext)
|
||||
{
|
||||
if ((aFlags & OT_CHANGED_COMMISSIONER_STATE) != 0)
|
||||
{
|
||||
|
||||
@@ -27,9 +27,9 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file radio.cpp
|
||||
* Platform abstraction for radio communication.
|
||||
*/
|
||||
* @file radio.cpp
|
||||
* Platform abstraction for radio communication.
|
||||
*/
|
||||
|
||||
#include <openthread/platform/alarm-milli.h>
|
||||
#include <openthread/platform/radio.h>
|
||||
@@ -57,51 +57,51 @@
|
||||
|
||||
enum
|
||||
{
|
||||
DA15000_RECEIVE_SENSITIVITY = -100, // dBm
|
||||
DA15000_RECEIVE_SENSITIVITY = -100, // dBm
|
||||
};
|
||||
|
||||
static ftdf_dbm sRssiReal = -100; // Initialize with the worst power
|
||||
static otInstance *sThreadInstance;
|
||||
static otRadioState sRadioState = OT_RADIO_STATE_DISABLED;
|
||||
static ftdf_dbm sRssiReal = -100; // Initialize with the worst power
|
||||
static otInstance * sThreadInstance;
|
||||
static otRadioState sRadioState = OT_RADIO_STATE_DISABLED;
|
||||
static otRadioFrame sReceiveFrame[RADIO_FRAMES_BUFFER_SIZE];
|
||||
static otRadioFrame *sReceiveFrameAck;
|
||||
static otRadioFrame sTransmitFrame;
|
||||
static otError sTransmitStatus;
|
||||
static bool sAckFrame = false;
|
||||
static bool sDropFrame = false;
|
||||
static bool sRadioPromiscuous = false;
|
||||
static bool sTransmitDoneFrame = false;
|
||||
static uint8_t sChannel = RADIO_DEFAULT_CHANNEL;
|
||||
static uint8_t sEnableRX = 0;
|
||||
static int8_t sTxPower = OPENTHREAD_CONFIG_DEFAULT_TRANSMIT_POWER;
|
||||
static uint8_t sReadFrame = 0;
|
||||
static uint8_t sWriteFrame = 0;
|
||||
static uint32_t sSleepInitDelay = 0;
|
||||
static bool sAckFrame = false;
|
||||
static bool sDropFrame = false;
|
||||
static bool sRadioPromiscuous = false;
|
||||
static bool sTransmitDoneFrame = false;
|
||||
static uint8_t sChannel = RADIO_DEFAULT_CHANNEL;
|
||||
static uint8_t sEnableRX = 0;
|
||||
static int8_t sTxPower = OPENTHREAD_CONFIG_DEFAULT_TRANSMIT_POWER;
|
||||
static uint8_t sReadFrame = 0;
|
||||
static uint8_t sWriteFrame = 0;
|
||||
static uint32_t sSleepInitDelay = 0;
|
||||
|
||||
static uint8_t sEui64[RADIO_EUI64_TABLE_SIZE];
|
||||
static uint8_t sReceivePsdu[RADIO_FRAMES_BUFFER_SIZE][OT_RADIO_FRAME_MAX_SIZE];
|
||||
static uint8_t sTransmitPsdu[OT_RADIO_FRAME_MAX_SIZE];
|
||||
static uint8_t sEui64[RADIO_EUI64_TABLE_SIZE];
|
||||
static uint8_t sReceivePsdu[RADIO_FRAMES_BUFFER_SIZE][OT_RADIO_FRAME_MAX_SIZE];
|
||||
static uint8_t sTransmitPsdu[OT_RADIO_FRAME_MAX_SIZE];
|
||||
|
||||
static void da15000OtpRead(void)
|
||||
{
|
||||
hw_otpc_init(); // Start clock.
|
||||
hw_otpc_disable(); // Make sure it is in standby mode.
|
||||
hw_otpc_init(); // Restart clock.
|
||||
hw_otpc_init(); // Start clock.
|
||||
hw_otpc_disable(); // Make sure it is in standby mode.
|
||||
hw_otpc_init(); // Restart clock.
|
||||
hw_otpc_manual_read_on(false);
|
||||
|
||||
__DMB();
|
||||
uint32_t *factoryTestTimeStamp = (uint32_t *) FACTORY_TEST_TIMESTAMP;
|
||||
uint32_t *factoryTestId = (uint32_t *) FACTORY_TESTER_ID;
|
||||
uint32_t *factoryTestTimeStamp = (uint32_t *)FACTORY_TEST_TIMESTAMP;
|
||||
uint32_t *factoryTestId = (uint32_t *)FACTORY_TESTER_ID;
|
||||
__DMB();
|
||||
|
||||
sEui64[0] = 0x80; //80-EA-CA is for Dialog Semiconductor
|
||||
sEui64[0] = 0x80; // 80-EA-CA is for Dialog Semiconductor
|
||||
sEui64[1] = 0xEA;
|
||||
sEui64[2] = 0xCA;
|
||||
sEui64[3] = (*factoryTestId >> 8) & 0xff;
|
||||
sEui64[3] = (*factoryTestId >> 8) & 0xff;
|
||||
sEui64[4] = (*factoryTestTimeStamp >> 24) & 0xff;
|
||||
sEui64[5] = (*factoryTestTimeStamp >> 16) & 0xff;
|
||||
sEui64[6] = (*factoryTestTimeStamp >> 8) & 0xff;
|
||||
sEui64[7] = *factoryTestTimeStamp & 0xff;
|
||||
sEui64[6] = (*factoryTestTimeStamp >> 8) & 0xff;
|
||||
sEui64[7] = *factoryTestTimeStamp & 0xff;
|
||||
|
||||
hw_otpc_manual_read_off();
|
||||
hw_otpc_disable();
|
||||
@@ -114,11 +114,13 @@ void da15000RadioInit(void)
|
||||
/* Wake up power domains */
|
||||
REG_CLR_BIT(CRG_TOP, PMU_CTRL_REG, FTDF_SLEEP);
|
||||
|
||||
while (REG_GETF(CRG_TOP, SYS_STAT_REG, FTDF_IS_UP) == 0x0);
|
||||
while (REG_GETF(CRG_TOP, SYS_STAT_REG, FTDF_IS_UP) == 0x0)
|
||||
;
|
||||
|
||||
REG_CLR_BIT(CRG_TOP, PMU_CTRL_REG, RADIO_SLEEP);
|
||||
|
||||
while (REG_GETF(CRG_TOP, SYS_STAT_REG, RAD_IS_UP) == 0x0);
|
||||
while (REG_GETF(CRG_TOP, SYS_STAT_REG, RAD_IS_UP) == 0x0)
|
||||
;
|
||||
|
||||
REG_SETF(CRG_TOP, CLK_RADIO_REG, FTDF_MAC_ENABLE, 1);
|
||||
REG_SETF(CRG_TOP, CLK_RADIO_REG, FTDF_MAC_DIV, 0);
|
||||
@@ -130,8 +132,8 @@ void da15000RadioInit(void)
|
||||
|
||||
da15000OtpRead();
|
||||
|
||||
sChannel = RADIO_DEFAULT_CHANNEL;
|
||||
sTransmitFrame.mPsdu = sTransmitPsdu;
|
||||
sChannel = RADIO_DEFAULT_CHANNEL;
|
||||
sTransmitFrame.mPsdu = sTransmitPsdu;
|
||||
|
||||
for (ptr = 0; ptr != RADIO_FRAMES_BUFFER_SIZE; ptr++)
|
||||
{
|
||||
@@ -157,9 +159,8 @@ void otPlatRadioSetPanId(otInstance *aInstance, uint16_t aPanid)
|
||||
|
||||
void otPlatRadioSetExtendedAddress(otInstance *aInstance, const otExtAddress *aAddress)
|
||||
{
|
||||
otLogInfoPlat(aInstance, "Set Extended Address: %X%X%X%X%X%X%X%X",
|
||||
aAddress->m8[7], aAddress->m8[6], aAddress->m8[5], aAddress->m8[4],
|
||||
aAddress->m8[3], aAddress->m8[2], aAddress->m8[1], aAddress->m8[0]);
|
||||
otLogInfoPlat(aInstance, "Set Extended Address: %X%X%X%X%X%X%X%X", aAddress->m8[7], aAddress->m8[6],
|
||||
aAddress->m8[5], aAddress->m8[4], aAddress->m8[3], aAddress->m8[2], aAddress->m8[1], aAddress->m8[0]);
|
||||
|
||||
ftdf_set_value(FTDF_PIB_EXTENDED_ADDRESS, aAddress->m8);
|
||||
}
|
||||
@@ -174,8 +175,8 @@ void otPlatRadioSetShortAddress(otInstance *aInstance, uint16_t aAddress)
|
||||
otError otPlatRadioEnable(otInstance *aInstance)
|
||||
{
|
||||
ftdf_bitmap32_t options;
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint8_t modeCCA;
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint8_t modeCCA;
|
||||
|
||||
otEXPECT_ACTION(sRadioState == OT_RADIO_STATE_DISABLED, error = OT_ERROR_INVALID_STATE);
|
||||
|
||||
@@ -189,7 +190,7 @@ otError otPlatRadioEnable(otInstance *aInstance)
|
||||
modeCCA = FTDF_CCA_MODE_2;
|
||||
ftdf_set_value(FTDF_PIB_CCA_MODE, &modeCCA);
|
||||
|
||||
options = FTDF_TRANSPARENT_ENABLE_FCS_GENERATION;
|
||||
options = FTDF_TRANSPARENT_ENABLE_FCS_GENERATION;
|
||||
options |= FTDF_TRANSPARENT_WAIT_FOR_ACK;
|
||||
options |= FTDF_TRANSPARENT_AUTO_ACK;
|
||||
|
||||
@@ -299,21 +300,20 @@ otError otPlatRadioAddSrcMatchShortEntry(otInstance *aInstance, const uint16_t a
|
||||
|
||||
exit:
|
||||
return error;
|
||||
|
||||
}
|
||||
|
||||
otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint8_t entry;
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint8_t entry;
|
||||
ftdf_ext_address_t addr;
|
||||
uint32_t addrL;
|
||||
uint64_t addrH;
|
||||
uint32_t addrL;
|
||||
uint64_t addrH;
|
||||
|
||||
addrL = (aExtAddress->m8[3] << 24) | (aExtAddress->m8[2] << 16) |
|
||||
(aExtAddress->m8[1] << 8) | (aExtAddress->m8[0] << 0);
|
||||
addrH = (aExtAddress->m8[7] << 24) | (aExtAddress->m8[6] << 16) |
|
||||
(aExtAddress->m8[5] << 8) | (aExtAddress->m8[4] << 0);
|
||||
addrL =
|
||||
(aExtAddress->m8[3] << 24) | (aExtAddress->m8[2] << 16) | (aExtAddress->m8[1] << 8) | (aExtAddress->m8[0] << 0);
|
||||
addrH =
|
||||
(aExtAddress->m8[7] << 24) | (aExtAddress->m8[6] << 16) | (aExtAddress->m8[5] << 8) | (aExtAddress->m8[4] << 0);
|
||||
addr = addrL | (addrH << 32);
|
||||
|
||||
// check if address already stored
|
||||
@@ -349,16 +349,16 @@ exit:
|
||||
|
||||
otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint8_t entry;
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint8_t entry;
|
||||
ftdf_ext_address_t addr;
|
||||
uint32_t addrL;
|
||||
uint64_t addrH;
|
||||
uint32_t addrL;
|
||||
uint64_t addrH;
|
||||
|
||||
addrL = (aExtAddress->m8[3] << 24) | (aExtAddress->m8[2] << 16) |
|
||||
(aExtAddress->m8[1] << 8) | (aExtAddress->m8[0] << 0);
|
||||
addrH = (aExtAddress->m8[7] << 24) | (aExtAddress->m8[6] << 16) |
|
||||
(aExtAddress->m8[5] << 8) | (aExtAddress->m8[4] << 0);
|
||||
addrL =
|
||||
(aExtAddress->m8[3] << 24) | (aExtAddress->m8[2] << 16) | (aExtAddress->m8[1] << 8) | (aExtAddress->m8[0] << 0);
|
||||
addrH =
|
||||
(aExtAddress->m8[7] << 24) | (aExtAddress->m8[6] << 16) | (aExtAddress->m8[5] << 8) | (aExtAddress->m8[4] << 0);
|
||||
addr = addrL | (addrH << 32);
|
||||
|
||||
otEXPECT_ACTION(ftdf_fppr_lookup_ext_address(addr, &entry), error = OT_ERROR_NO_ADDRESS);
|
||||
@@ -504,7 +504,7 @@ void da15000RadioProcess(otInstance *aInstance)
|
||||
if (frameHeader.frame_type == FTDF_ACKNOWLEDGEMENT_FRAME)
|
||||
{
|
||||
sReceiveFrameAck = &sReceiveFrame[sReadFrame];
|
||||
sAckFrame = true;
|
||||
sAckFrame = true;
|
||||
}
|
||||
|
||||
otPlatRadioReceiveDone(sThreadInstance, &sReceiveFrame[sReadFrame], OT_ERROR_NONE);
|
||||
@@ -572,9 +572,9 @@ static void radioRssiCalc(ftdf_link_quality_t link_quality)
|
||||
sRssiReal = (ftdf_dbm)((0.5239 * (float)link_quality) - 114.8604);
|
||||
}
|
||||
|
||||
void ftdf_rcv_frame_transparent(ftdf_data_length_t frame_length,
|
||||
ftdf_octet_t *frame,
|
||||
ftdf_bitmap32_t status,
|
||||
void ftdf_rcv_frame_transparent(ftdf_data_length_t frame_length,
|
||||
ftdf_octet_t * frame,
|
||||
ftdf_bitmap32_t status,
|
||||
ftdf_link_quality_t link_quality)
|
||||
{
|
||||
otEXPECT(frame_length <= OT_RADIO_FRAME_MAX_SIZE);
|
||||
@@ -590,12 +590,12 @@ void ftdf_rcv_frame_transparent(ftdf_data_length_t frame_length,
|
||||
#if OPENTHREAD_ENABLE_RAW_LINK_API
|
||||
// Timestamp
|
||||
sReceiveFrame[sWriteFrame].mMsec = otPlatAlarmMilliGetNow();
|
||||
sReceiveFrame[sWriteFrame].mUsec = 0; // Don't support microsecond timer for now.
|
||||
sReceiveFrame[sWriteFrame].mUsec = 0; // Don't support microsecond timer for now.
|
||||
#endif
|
||||
sReceiveFrame[sWriteFrame].mChannel = sChannel;
|
||||
sReceiveFrame[sWriteFrame].mLength = frame_length;
|
||||
sReceiveFrame[sWriteFrame].mLqi = OT_RADIO_LQI_NONE;
|
||||
sReceiveFrame[sWriteFrame].mRssi = otPlatRadioGetRssi(sThreadInstance);
|
||||
sReceiveFrame[sWriteFrame].mChannel = sChannel;
|
||||
sReceiveFrame[sWriteFrame].mLength = frame_length;
|
||||
sReceiveFrame[sWriteFrame].mLqi = OT_RADIO_LQI_NONE;
|
||||
sReceiveFrame[sWriteFrame].mRssi = otPlatRadioGetRssi(sThreadInstance);
|
||||
memcpy(sReceiveFrame[sWriteFrame].mPsdu, frame, frame_length);
|
||||
|
||||
sWriteFrame = (sWriteFrame + 1) % RADIO_FRAMES_BUFFER_SIZE;
|
||||
|
||||
@@ -40,11 +40,11 @@
|
||||
#include "hw_trng.h"
|
||||
#include "sdk_defs.h"
|
||||
|
||||
#define RANDOM_SIZE_OF_BUFFER 32
|
||||
#define RANDOM_SIZE_OF_BUFFER 32
|
||||
|
||||
static uint32_t sRandomNumbers[RANDOM_SIZE_OF_BUFFER];
|
||||
static uint8_t sRandomNextNumberIndex = 0;
|
||||
static bool sRandomGeneratorStarted = false;
|
||||
static uint8_t sRandomNextNumberIndex = 0;
|
||||
static bool sRandomGeneratorStarted = false;
|
||||
|
||||
static void RandomCallback(void)
|
||||
{
|
||||
@@ -70,7 +70,7 @@ void da15000RandomInit(void)
|
||||
uint32_t otPlatRandomGet(void)
|
||||
{
|
||||
uint32_t randomNumber;
|
||||
bool randomGet = false;
|
||||
bool randomGet = false;
|
||||
|
||||
do
|
||||
{
|
||||
@@ -79,7 +79,7 @@ uint32_t otPlatRandomGet(void)
|
||||
if (sRandomNextNumberIndex < RANDOM_SIZE_OF_BUFFER)
|
||||
{
|
||||
randomNumber = sRandomNumbers[sRandomNextNumberIndex++];
|
||||
randomGet = true;
|
||||
randomGet = true;
|
||||
|
||||
if (sRandomNextNumberIndex == RANDOM_SIZE_OF_BUFFER)
|
||||
{
|
||||
@@ -89,7 +89,7 @@ uint32_t otPlatRandomGet(void)
|
||||
else if (hw_trng_get_fifo_level() > 0)
|
||||
{
|
||||
randomNumber = hw_trng_get_number();
|
||||
randomGet = true;
|
||||
randomGet = true;
|
||||
}
|
||||
else if (!sRandomGeneratorStarted)
|
||||
{
|
||||
@@ -97,8 +97,7 @@ uint32_t otPlatRandomGet(void)
|
||||
}
|
||||
|
||||
GLOBAL_INT_RESTORE();
|
||||
}
|
||||
while (!randomGet);
|
||||
} while (!randomGet);
|
||||
|
||||
return randomNumber;
|
||||
}
|
||||
|
||||
@@ -33,9 +33,9 @@
|
||||
#include "hw_gpio.h"
|
||||
#include "hw_uart.h"
|
||||
|
||||
static bool sUartWriteDone = false;
|
||||
static bool sUartReadDone = false;
|
||||
static char *sInitBuf = NULL;
|
||||
static bool sUartWriteDone = false;
|
||||
static bool sUartReadDone = false;
|
||||
static char * sInitBuf = NULL;
|
||||
static uint8_t sUartBuf;
|
||||
|
||||
static void UartSignalWrite(void *p, uint16_t transferred)
|
||||
@@ -75,12 +75,9 @@ otError otPlatUartEnable(void)
|
||||
|
||||
hw_uart_init_ex(HW_UART2, &uart_init);
|
||||
|
||||
hw_gpio_set_pin_function(HW_GPIO_PORT_1, HW_GPIO_PIN_3,
|
||||
HW_GPIO_MODE_OUTPUT, HW_GPIO_FUNC_UART2_TX);
|
||||
hw_gpio_set_pin_function(HW_GPIO_PORT_2, HW_GPIO_PIN_3,
|
||||
HW_GPIO_MODE_OUTPUT, HW_GPIO_FUNC_UART2_RX);
|
||||
hw_gpio_set_pin_function(HW_GPIO_PORT_1, HW_GPIO_PIN_5, HW_GPIO_MODE_OUTPUT,
|
||||
HW_GPIO_FUNC_GPIO);
|
||||
hw_gpio_set_pin_function(HW_GPIO_PORT_1, HW_GPIO_PIN_3, HW_GPIO_MODE_OUTPUT, HW_GPIO_FUNC_UART2_TX);
|
||||
hw_gpio_set_pin_function(HW_GPIO_PORT_2, HW_GPIO_PIN_3, HW_GPIO_MODE_OUTPUT, HW_GPIO_FUNC_UART2_RX);
|
||||
hw_gpio_set_pin_function(HW_GPIO_PORT_1, HW_GPIO_PIN_5, HW_GPIO_MODE_OUTPUT, HW_GPIO_FUNC_GPIO);
|
||||
|
||||
hw_uart_receive(HW_UART2, &sUartBuf, 1, UartSignalRead, NULL);
|
||||
|
||||
|
||||
@@ -44,11 +44,11 @@
|
||||
#include "em_core.h"
|
||||
#include "rail.h"
|
||||
|
||||
static uint32_t sTimerHi = 0;
|
||||
static uint32_t sTimerLo = 0;
|
||||
static uint32_t sAlarmT0 = 0;
|
||||
static uint32_t sAlarmDt = 0;
|
||||
static bool sIsRunning = false;
|
||||
static uint32_t sTimerHi = 0;
|
||||
static uint32_t sTimerLo = 0;
|
||||
static uint32_t sAlarmT0 = 0;
|
||||
static uint32_t sAlarmDt = 0;
|
||||
static bool sIsRunning = false;
|
||||
|
||||
void efr32AlarmInit(void)
|
||||
{
|
||||
@@ -81,8 +81,8 @@ uint32_t otPlatAlarmMilliGetNow(void)
|
||||
void otPlatAlarmMilliStartAt(otInstance *aInstance, uint32_t t0, uint32_t dt)
|
||||
{
|
||||
(void)aInstance;
|
||||
sAlarmT0 = t0;
|
||||
sAlarmDt = dt;
|
||||
sAlarmT0 = t0;
|
||||
sAlarmDt = dt;
|
||||
sIsRunning = true;
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ void efr32AlarmProcess(otInstance *aInstance)
|
||||
{
|
||||
uint32_t now = otPlatAlarmMilliGetNow();
|
||||
uint32_t expires;
|
||||
bool fire = false;
|
||||
bool fire = false;
|
||||
|
||||
otEXPECT(sIsRunning);
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ otError utilsFlashErasePage(uint32_t aAddress)
|
||||
|
||||
otError utilsFlashStatusWait(uint32_t aTimeout)
|
||||
{
|
||||
otError error = OT_ERROR_BUSY;
|
||||
otError error = OT_ERROR_BUSY;
|
||||
uint32_t start = otPlatAlarmMilliGetNow();
|
||||
|
||||
do
|
||||
@@ -104,8 +104,7 @@ otError utilsFlashStatusWait(uint32_t aTimeout)
|
||||
error = OT_ERROR_NONE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (aTimeout && ((otPlatAlarmMilliGetNow() - start) < aTimeout));
|
||||
} while (aTimeout && ((otPlatAlarmMilliGetNow() - start) < aTimeout));
|
||||
|
||||
return error;
|
||||
}
|
||||
@@ -113,11 +112,10 @@ otError utilsFlashStatusWait(uint32_t aTimeout)
|
||||
uint32_t utilsFlashWrite(uint32_t aAddress, uint8_t *aData, uint32_t aSize)
|
||||
{
|
||||
uint32_t rval = aSize;
|
||||
int32_t status;
|
||||
int32_t status;
|
||||
|
||||
otEXPECT_ACTION(aData, rval = 0);
|
||||
otEXPECT_ACTION(((aAddress + aSize) < utilsFlashGetSize()) &&
|
||||
(!(aAddress & 3)) && (!(aSize & 3)), rval = 0);
|
||||
otEXPECT_ACTION(((aAddress + aSize) < utilsFlashGetSize()) && (!(aAddress & 3)) && (!(aSize & 3)), rval = 0);
|
||||
|
||||
status = MSC_WriteWord((uint32_t *)mapAddress(aAddress), aData, aSize);
|
||||
otEXPECT_ACTION(returnTypeConvert(status) == OT_ERROR_NONE, rval = 0);
|
||||
@@ -128,9 +126,9 @@ exit:
|
||||
|
||||
uint32_t utilsFlashRead(uint32_t aAddress, uint8_t *aData, uint32_t aSize)
|
||||
{
|
||||
uint32_t rval = aSize;
|
||||
uint32_t rval = aSize;
|
||||
uint32_t pAddress = mapAddress(aAddress);
|
||||
uint8_t *byte = aData;
|
||||
uint8_t *byte = aData;
|
||||
|
||||
otEXPECT_ACTION(aData, rval = 0);
|
||||
otEXPECT_ACTION((aAddress + aSize) < utilsFlashGetSize(), rval = 0);
|
||||
|
||||
@@ -32,15 +32,15 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <openthread/config.h>
|
||||
#include <openthread-core-config.h>
|
||||
#include <openthread/config.h>
|
||||
|
||||
#include <openthread/cli.h>
|
||||
#include <openthread/platform/logging.h>
|
||||
|
||||
#include "utils/code_utils.h"
|
||||
|
||||
#if (OPENTHREAD_CONFIG_LOG_OUTPUT == OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED)
|
||||
#if (OPENTHREAD_CONFIG_LOG_OUTPUT == OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED)
|
||||
void otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, ...)
|
||||
{
|
||||
#if OPENTHREAD_ENABLE_CLI_LOGGING
|
||||
|
||||
@@ -34,8 +34,8 @@
|
||||
#include <openthread/types.h>
|
||||
#include <openthread/platform/misc.h>
|
||||
|
||||
#include "platform-efr32.h"
|
||||
#include "em_rmu.h"
|
||||
#include "platform-efr32.h"
|
||||
|
||||
static uint32_t sResetCause;
|
||||
|
||||
@@ -79,10 +79,8 @@ otPlatResetReason otPlatGetResetReason(otInstance *aInstance)
|
||||
{
|
||||
reason = OT_PLAT_RESET_REASON_FAULT;
|
||||
}
|
||||
else if ((sResetCause & RMU_RSTCAUSE_AVDDBOD) ||
|
||||
(sResetCause & RMU_RSTCAUSE_DECBOD) ||
|
||||
(sResetCause & RMU_RSTCAUSE_DVDDBOD) ||
|
||||
(sResetCause & RMU_RSTCAUSE_EM4RST))
|
||||
else if ((sResetCause & RMU_RSTCAUSE_AVDDBOD) || (sResetCause & RMU_RSTCAUSE_DECBOD) ||
|
||||
(sResetCause & RMU_RSTCAUSE_DVDDBOD) || (sResetCause & RMU_RSTCAUSE_EM4RST))
|
||||
{
|
||||
reason = OT_PLAT_RESET_REASON_ASSERT;
|
||||
}
|
||||
|
||||
@@ -42,8 +42,8 @@
|
||||
#include "em_chip.h"
|
||||
#include "hal_common.h"
|
||||
|
||||
#include "platform-efr32.h"
|
||||
#include "openthread-core-efr32-config.h"
|
||||
#include "platform-efr32.h"
|
||||
|
||||
void halInitChipSpecific(void);
|
||||
|
||||
|
||||
+105
-117
@@ -34,55 +34,55 @@
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include <openthread/types.h>
|
||||
#include <openthread/config.h>
|
||||
#include <openthread/types.h>
|
||||
#include <openthread/platform/alarm-milli.h>
|
||||
#include <openthread/platform/radio.h>
|
||||
#include <openthread/platform/diag.h>
|
||||
#include <openthread/platform/radio.h>
|
||||
|
||||
#include "common/logging.hpp"
|
||||
#include "utils/code_utils.h"
|
||||
|
||||
#include "em_core.h"
|
||||
#include "em_system.h"
|
||||
#include "openthread-core-efr32-config.h"
|
||||
#include "pa_conversions_efr32.h"
|
||||
#include "rail.h"
|
||||
#include "rail_config.h"
|
||||
#include "rail_ieee802154.h"
|
||||
#include "openthread-core-efr32-config.h"
|
||||
|
||||
enum
|
||||
{
|
||||
IEEE802154_MIN_LENGTH = 5,
|
||||
IEEE802154_MAX_LENGTH = 127,
|
||||
IEEE802154_ACK_LENGTH = 5,
|
||||
IEEE802154_FRAME_TYPE_MASK = 0x7,
|
||||
IEEE802154_FRAME_TYPE_ACK = 0x2,
|
||||
IEEE802154_FRAME_PENDING = 1 << 4,
|
||||
IEEE802154_ACK_REQUEST = 1 << 5,
|
||||
IEEE802154_DSN_OFFSET = 2,
|
||||
IEEE802154_MIN_LENGTH = 5,
|
||||
IEEE802154_MAX_LENGTH = 127,
|
||||
IEEE802154_ACK_LENGTH = 5,
|
||||
IEEE802154_FRAME_TYPE_MASK = 0x7,
|
||||
IEEE802154_FRAME_TYPE_ACK = 0x2,
|
||||
IEEE802154_FRAME_PENDING = 1 << 4,
|
||||
IEEE802154_ACK_REQUEST = 1 << 5,
|
||||
IEEE802154_DSN_OFFSET = 2,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
EFR32_RECEIVE_SENSITIVITY = -100, // dBm
|
||||
EFR32_RECEIVE_SENSITIVITY = -100, // dBm
|
||||
};
|
||||
|
||||
static uint16_t sPanId = 0;
|
||||
static bool sTransmitBusy = false;
|
||||
static bool sPromiscuous = false;
|
||||
static bool sIsSrcMatchEnabled = false;
|
||||
static otRadioState sState = OT_RADIO_STATE_DISABLED;
|
||||
static uint16_t sPanId = 0;
|
||||
static bool sTransmitBusy = false;
|
||||
static bool sPromiscuous = false;
|
||||
static bool sIsSrcMatchEnabled = false;
|
||||
static otRadioState sState = OT_RADIO_STATE_DISABLED;
|
||||
|
||||
static uint8_t sReceivePsdu[IEEE802154_MAX_LENGTH];
|
||||
static otRadioFrame sReceiveFrame;
|
||||
static otError sReceiveError;
|
||||
static uint8_t sReceivePsdu[IEEE802154_MAX_LENGTH];
|
||||
static otRadioFrame sReceiveFrame;
|
||||
static otError sReceiveError;
|
||||
|
||||
static otRadioFrame sTransmitFrame;
|
||||
static uint8_t sTransmitPsdu[IEEE802154_MAX_LENGTH];
|
||||
static otError sTransmitError;
|
||||
static otRadioFrame sTransmitFrame;
|
||||
static uint8_t sTransmitPsdu[IEEE802154_MAX_LENGTH];
|
||||
static otError sTransmitError;
|
||||
|
||||
typedef struct srcMatchEntry
|
||||
typedef struct srcMatchEntry
|
||||
{
|
||||
uint16_t checksum;
|
||||
bool allocated;
|
||||
@@ -95,43 +95,41 @@ static uint8_t sRailTxFifo[1 + IEEE802154_MAX_LENGTH];
|
||||
|
||||
static void RAILCb_Generic(RAIL_Handle_t aRailHandle, RAIL_Events_t aEvents);
|
||||
|
||||
static RAIL_Config_t sRailConfig =
|
||||
{
|
||||
static RAIL_Config_t sRailConfig = {
|
||||
.eventsCallback = &RAILCb_Generic,
|
||||
.protocol = NULL,
|
||||
.scheduler = NULL,
|
||||
.protocol = NULL,
|
||||
.scheduler = NULL,
|
||||
};
|
||||
|
||||
static const RAIL_IEEE802154_Config_t sRailIeee802154Config =
|
||||
{
|
||||
NULL, // addresses
|
||||
static const RAIL_IEEE802154_Config_t sRailIeee802154Config = {
|
||||
NULL, // addresses
|
||||
{
|
||||
// ackConfig
|
||||
true, // ackConfig.enable
|
||||
894, // ackConfig.ackTimeout
|
||||
true, // ackConfig.enable
|
||||
894, // ackConfig.ackTimeout
|
||||
{
|
||||
// ackConfig.rxTransitions
|
||||
RAIL_RF_STATE_RX, // ackConfig.rxTransitions.success
|
||||
RAIL_RF_STATE_RX, // ackConfig.rxTransitions.error
|
||||
RAIL_RF_STATE_RX, // ackConfig.rxTransitions.success
|
||||
RAIL_RF_STATE_RX, // ackConfig.rxTransitions.error
|
||||
},
|
||||
{
|
||||
// ackConfig.txTransitions
|
||||
RAIL_RF_STATE_RX, // ackConfig.txTransitions.success
|
||||
RAIL_RF_STATE_RX, // ackConfig.txTransitions.error
|
||||
RAIL_RF_STATE_RX, // ackConfig.txTransitions.success
|
||||
RAIL_RF_STATE_RX, // ackConfig.txTransitions.error
|
||||
},
|
||||
},
|
||||
{
|
||||
// timings
|
||||
100, // timings.idleToRx
|
||||
192 - 10, // timings.txToRx
|
||||
100, // timings.idleToTx
|
||||
192, // timings.rxToTx
|
||||
0, // timings.rxSearchTimeout
|
||||
0, // timings.txToRxSearchTimeout
|
||||
100, // timings.idleToRx
|
||||
192 - 10, // timings.txToRx
|
||||
100, // timings.idleToTx
|
||||
192, // timings.rxToTx
|
||||
0, // timings.rxSearchTimeout
|
||||
0, // timings.txToRxSearchTimeout
|
||||
},
|
||||
RAIL_IEEE802154_ACCEPT_STANDARD_FRAMES, // framesMask
|
||||
false, // promiscuousMode
|
||||
false, // isPanCoordinator
|
||||
RAIL_IEEE802154_ACCEPT_STANDARD_FRAMES, // framesMask
|
||||
false, // promiscuousMode
|
||||
false, // isPanCoordinator
|
||||
};
|
||||
|
||||
static RAIL_Handle_t sRailHandle = NULL;
|
||||
@@ -145,8 +143,7 @@ void efr32RadioInit(void)
|
||||
sRailHandle = RAIL_Init(&sRailConfig, NULL);
|
||||
assert(sRailHandle != NULL);
|
||||
|
||||
RAIL_DataConfig_t railDataConfig =
|
||||
{
|
||||
RAIL_DataConfig_t railDataConfig = {
|
||||
TX_PACKET_DATA,
|
||||
RX_PACKET_DATA,
|
||||
PACKET_MODE,
|
||||
@@ -166,24 +163,24 @@ void efr32RadioInit(void)
|
||||
assert(status == RAIL_STATUS_NO_ERROR);
|
||||
|
||||
status = RAIL_ConfigEvents(sRailHandle, RAIL_EVENTS_ALL,
|
||||
RAIL_EVENT_RX_ACK_TIMEOUT | //
|
||||
RAIL_EVENT_TX_PACKET_SENT | //
|
||||
RAIL_EVENT_RX_PACKET_RECEIVED | //
|
||||
RAIL_EVENT_TX_CHANNEL_BUSY | //
|
||||
RAIL_EVENT_TX_ABORTED | //
|
||||
RAIL_EVENT_TX_BLOCKED | //
|
||||
RAIL_EVENT_TX_UNDERFLOW | //
|
||||
RAIL_EVENT_IEEE802154_DATA_REQUEST_COMMAND | //
|
||||
RAIL_EVENT_CAL_NEEDED //
|
||||
);
|
||||
RAIL_EVENT_RX_ACK_TIMEOUT | //
|
||||
RAIL_EVENT_TX_PACKET_SENT | //
|
||||
RAIL_EVENT_RX_PACKET_RECEIVED | //
|
||||
RAIL_EVENT_TX_CHANNEL_BUSY | //
|
||||
RAIL_EVENT_TX_ABORTED | //
|
||||
RAIL_EVENT_TX_BLOCKED | //
|
||||
RAIL_EVENT_TX_UNDERFLOW | //
|
||||
RAIL_EVENT_IEEE802154_DATA_REQUEST_COMMAND | //
|
||||
RAIL_EVENT_CAL_NEEDED //
|
||||
);
|
||||
assert(status == RAIL_STATUS_NO_ERROR);
|
||||
|
||||
RAIL_TxPowerCurvesConfig_t txPowerCurvesConfig = { curves24Hp, curvesSg, curves24Lp, piecewiseSegments };
|
||||
status = RAIL_InitTxPowerCurves(&txPowerCurvesConfig);
|
||||
RAIL_TxPowerCurvesConfig_t txPowerCurvesConfig = {curves24Hp, curvesSg, curves24Lp, piecewiseSegments};
|
||||
status = RAIL_InitTxPowerCurves(&txPowerCurvesConfig);
|
||||
assert(status == RAIL_STATUS_NO_ERROR);
|
||||
|
||||
RAIL_TxPowerConfig_t txPowerConfig = { RAIL_TX_POWER_MODE_2P4_HP, 3300, 10 };
|
||||
status = RAIL_ConfigTxPower(sRailHandle, &txPowerConfig);
|
||||
RAIL_TxPowerConfig_t txPowerConfig = {RAIL_TX_POWER_MODE_2P4_HP, 3300, 10};
|
||||
status = RAIL_ConfigTxPower(sRailHandle, &txPowerConfig);
|
||||
assert(status == RAIL_STATUS_NO_ERROR);
|
||||
|
||||
status = RAIL_SetTxPowerDbm(sRailHandle, ((RAIL_TxPower_t)OPENTHREAD_CONFIG_DEFAULT_TRANSMIT_POWER) * 10);
|
||||
@@ -215,7 +212,7 @@ void otPlatRadioGetIeeeEui64(otInstance *aInstance, uint8_t *aIeeeEui64)
|
||||
uint8_t *eui64Ptr = NULL;
|
||||
(void)aInstance;
|
||||
|
||||
eui64 = SYSTEM_GetUnique();
|
||||
eui64 = SYSTEM_GetUnique();
|
||||
eui64Ptr = (uint8_t *)&eui64;
|
||||
|
||||
for (uint8_t i = 0; i < OT_EXT_ADDRESS_SIZE; i++)
|
||||
@@ -243,9 +240,8 @@ void otPlatRadioSetExtendedAddress(otInstance *aInstance, const otExtAddress *aA
|
||||
|
||||
(void)aInstance;
|
||||
|
||||
otLogInfoPlat(sInstance, "ExtAddr=%X%X%X%X%X%X%X%X",
|
||||
aAddress->m8[7], aAddress->m8[6], aAddress->m8[5], aAddress->m8[4],
|
||||
aAddress->m8[3], aAddress->m8[2], aAddress->m8[1], aAddress->m8[0]);
|
||||
otLogInfoPlat(sInstance, "ExtAddr=%X%X%X%X%X%X%X%X", aAddress->m8[7], aAddress->m8[6], aAddress->m8[5],
|
||||
aAddress->m8[4], aAddress->m8[3], aAddress->m8[2], aAddress->m8[1], aAddress->m8[0]);
|
||||
|
||||
status = RAIL_IEEE802154_SetLongAddress(sRailHandle, (uint8_t *)aAddress->m8, 0);
|
||||
assert(status == RAIL_STATUS_NO_ERROR);
|
||||
@@ -310,7 +306,7 @@ exit:
|
||||
|
||||
otError otPlatRadioReceive(otInstance *aInstance, uint8_t aChannel)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
RAIL_Status_t status;
|
||||
(void)aInstance;
|
||||
|
||||
@@ -320,7 +316,7 @@ otError otPlatRadioReceive(otInstance *aInstance, uint8_t aChannel)
|
||||
otEXPECT_ACTION(status == RAIL_STATUS_NO_ERROR, error = OT_ERROR_FAILED);
|
||||
|
||||
otLogInfoPlat(sInstance, "State=OT_RADIO_STATE_RECEIVE", NULL);
|
||||
sState = OT_RADIO_STATE_RECEIVE;
|
||||
sState = OT_RADIO_STATE_RECEIVE;
|
||||
sReceiveFrame.mChannel = aChannel;
|
||||
|
||||
exit:
|
||||
@@ -329,18 +325,18 @@ exit:
|
||||
|
||||
otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aFrame)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
RAIL_CsmaConfig_t csmaConfig = RAIL_CSMA_CONFIG_802_15_4_2003_2p4_GHz_OQPSK_CSMA;
|
||||
RAIL_TxOptions_t txOptions = RAIL_TX_OPTIONS_NONE;
|
||||
RAIL_Status_t status;
|
||||
RAIL_TxOptions_t txOptions = RAIL_TX_OPTIONS_NONE;
|
||||
RAIL_Status_t status;
|
||||
(void)aInstance;
|
||||
|
||||
otEXPECT_ACTION((sState != OT_RADIO_STATE_DISABLED) && (sState != OT_RADIO_STATE_TRANSMIT),
|
||||
error = OT_ERROR_INVALID_STATE);
|
||||
|
||||
sState = OT_RADIO_STATE_TRANSMIT;
|
||||
sState = OT_RADIO_STATE_TRANSMIT;
|
||||
sTransmitError = OT_ERROR_NONE;
|
||||
sTransmitBusy = true;
|
||||
sTransmitBusy = true;
|
||||
|
||||
RAIL_WriteTxFifo(sRailHandle, &aFrame->mLength, sizeof(aFrame->mLength), true);
|
||||
RAIL_WriteTxFifo(sRailHandle, aFrame->mPsdu, aFrame->mLength - 2, false);
|
||||
@@ -390,7 +386,7 @@ void otPlatRadioSetPromiscuous(otInstance *aInstance, bool aEnable)
|
||||
(void)aInstance;
|
||||
|
||||
sPromiscuous = aEnable;
|
||||
status = RAIL_IEEE802154_SetPromiscuousMode(sRailHandle, aEnable);
|
||||
status = RAIL_IEEE802154_SetPromiscuousMode(sRailHandle, aEnable);
|
||||
assert(status == RAIL_STATUS_NO_ERROR);
|
||||
}
|
||||
|
||||
@@ -426,13 +422,12 @@ int8_t findSrcMatchAvailEntry(bool aShortAddress)
|
||||
|
||||
int8_t findSrcMatchShortEntry(const uint16_t aShortAddress)
|
||||
{
|
||||
int8_t entry = -1;
|
||||
int8_t entry = -1;
|
||||
uint16_t checksum = aShortAddress + sPanId;
|
||||
|
||||
for (uint8_t i = 0; i < RADIO_CONFIG_SRC_MATCH_SHORT_ENTRY_NUM; i++)
|
||||
{
|
||||
if (checksum == srcMatchShortEntry[i].checksum &&
|
||||
srcMatchShortEntry[i].allocated)
|
||||
if (checksum == srcMatchShortEntry[i].checksum && srcMatchShortEntry[i].allocated)
|
||||
{
|
||||
entry = i;
|
||||
break;
|
||||
@@ -444,7 +439,7 @@ int8_t findSrcMatchShortEntry(const uint16_t aShortAddress)
|
||||
|
||||
int8_t findSrcMatchExtEntry(const otExtAddress *aExtAddress)
|
||||
{
|
||||
int8_t entry = -1;
|
||||
int8_t entry = -1;
|
||||
uint16_t checksum = sPanId;
|
||||
|
||||
checksum += (uint16_t)aExtAddress->m8[0] | (uint16_t)(aExtAddress->m8[1] << 8);
|
||||
@@ -454,8 +449,7 @@ int8_t findSrcMatchExtEntry(const otExtAddress *aExtAddress)
|
||||
|
||||
for (uint8_t i = 0; i < RADIO_CONFIG_SRC_MATCH_EXT_ENTRY_NUM; i++)
|
||||
{
|
||||
if (checksum == srcMatchExtEntry[i].checksum &&
|
||||
srcMatchExtEntry[i].allocated)
|
||||
if (checksum == srcMatchExtEntry[i].checksum && srcMatchExtEntry[i].allocated)
|
||||
{
|
||||
entry = i;
|
||||
break;
|
||||
@@ -469,7 +463,7 @@ void addToSrcMatchShortIndirect(uint8_t entry, const uint16_t aShortAddress)
|
||||
{
|
||||
uint16_t checksum = aShortAddress + sPanId;
|
||||
|
||||
srcMatchShortEntry[entry].checksum = checksum;
|
||||
srcMatchShortEntry[entry].checksum = checksum;
|
||||
srcMatchShortEntry[entry].allocated = true;
|
||||
}
|
||||
|
||||
@@ -482,7 +476,7 @@ void addToSrcMatchExtIndirect(uint8_t entry, const otExtAddress *aExtAddress)
|
||||
checksum += (uint16_t)aExtAddress->m8[4] | (uint16_t)(aExtAddress->m8[5] << 8);
|
||||
checksum += (uint16_t)aExtAddress->m8[6] | (uint16_t)(aExtAddress->m8[7] << 8);
|
||||
|
||||
srcMatchExtEntry[entry].checksum = checksum;
|
||||
srcMatchExtEntry[entry].checksum = checksum;
|
||||
srcMatchExtEntry[entry].allocated = true;
|
||||
}
|
||||
|
||||
@@ -510,13 +504,12 @@ otError otPlatRadioAddSrcMatchShortEntry(otInstance *aInstance, const uint16_t a
|
||||
{
|
||||
(void)aInstance;
|
||||
otError error = OT_ERROR_NONE;
|
||||
int8_t entry = -1;
|
||||
int8_t entry = -1;
|
||||
|
||||
entry = findSrcMatchAvailEntry(true);
|
||||
otLogDebgPlat(sInstance, "Add ShortAddr entry: %d", entry);
|
||||
|
||||
otEXPECT_ACTION(entry >= 0 && entry < RADIO_CONFIG_SRC_MATCH_SHORT_ENTRY_NUM,
|
||||
error = OT_ERROR_NO_BUFS);
|
||||
otEXPECT_ACTION(entry >= 0 && entry < RADIO_CONFIG_SRC_MATCH_SHORT_ENTRY_NUM, error = OT_ERROR_NO_BUFS);
|
||||
|
||||
addToSrcMatchShortIndirect(entry, aShortAddress);
|
||||
|
||||
@@ -527,14 +520,13 @@ exit:
|
||||
otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
int8_t entry = -1;
|
||||
int8_t entry = -1;
|
||||
(void)aInstance;
|
||||
|
||||
entry = findSrcMatchAvailEntry(false);
|
||||
otLogDebgPlat(sInstance, "Add ExtAddr entry: %d", entry);
|
||||
|
||||
otEXPECT_ACTION(entry >= 0 && entry < RADIO_CONFIG_SRC_MATCH_EXT_ENTRY_NUM,
|
||||
error = OT_ERROR_NO_BUFS);
|
||||
otEXPECT_ACTION(entry >= 0 && entry < RADIO_CONFIG_SRC_MATCH_EXT_ENTRY_NUM, error = OT_ERROR_NO_BUFS);
|
||||
|
||||
addToSrcMatchExtIndirect(entry, aExtAddress);
|
||||
|
||||
@@ -545,14 +537,13 @@ exit:
|
||||
otError otPlatRadioClearSrcMatchShortEntry(otInstance *aInstance, const uint16_t aShortAddress)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
int8_t entry = -1;
|
||||
int8_t entry = -1;
|
||||
(void)aInstance;
|
||||
|
||||
entry = findSrcMatchShortEntry(aShortAddress);
|
||||
otLogDebgPlat(sInstance, "Clear ShortAddr entry: %d", entry);
|
||||
|
||||
otEXPECT_ACTION(entry >= 0 && entry < RADIO_CONFIG_SRC_MATCH_SHORT_ENTRY_NUM,
|
||||
error = OT_ERROR_NO_ADDRESS);
|
||||
otEXPECT_ACTION(entry >= 0 && entry < RADIO_CONFIG_SRC_MATCH_SHORT_ENTRY_NUM, error = OT_ERROR_NO_ADDRESS);
|
||||
|
||||
removeFromSrcMatchShortIndirect(entry);
|
||||
|
||||
@@ -563,14 +554,13 @@ exit:
|
||||
otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
int8_t entry = -1;
|
||||
int8_t entry = -1;
|
||||
(void)aInstance;
|
||||
|
||||
entry = findSrcMatchExtEntry(aExtAddress);
|
||||
otLogDebgPlat(sInstance, "Clear ExtAddr entry: %d", entry);
|
||||
|
||||
otEXPECT_ACTION(entry >= 0 && entry < RADIO_CONFIG_SRC_MATCH_EXT_ENTRY_NUM,
|
||||
error = OT_ERROR_NO_ADDRESS);
|
||||
otEXPECT_ACTION(entry >= 0 && entry < RADIO_CONFIG_SRC_MATCH_EXT_ENTRY_NUM, error = OT_ERROR_NO_ADDRESS);
|
||||
|
||||
removeFromSrcMatchExtIndirect(entry);
|
||||
|
||||
@@ -598,19 +588,19 @@ void otPlatRadioClearSrcMatchExtEntries(otInstance *aInstance)
|
||||
|
||||
static void checkForAck(RAIL_Handle_t aRailHandle)
|
||||
{
|
||||
RAIL_RxPacketHandle_t packetHandle;
|
||||
RAIL_RxPacketInfo_t packetInfo;
|
||||
RAIL_RxPacketHandle_t packetHandle;
|
||||
RAIL_RxPacketInfo_t packetInfo;
|
||||
RAIL_RxPacketDetails_t packetDetails;
|
||||
RAIL_Status_t status;
|
||||
uint8_t frame[IEEE802154_ACK_LENGTH];
|
||||
uint16_t length;
|
||||
RAIL_Status_t status;
|
||||
uint8_t frame[IEEE802154_ACK_LENGTH];
|
||||
uint16_t length;
|
||||
|
||||
packetHandle = RAIL_GetRxPacketInfo(aRailHandle, RAIL_RX_PACKET_HANDLE_NEWEST, &packetInfo);
|
||||
assert(packetInfo.packetStatus == RAIL_RX_PACKET_READY_SUCCESS);
|
||||
|
||||
packetDetails.timeReceived.timePosition = RAIL_PACKET_TIME_INVALID;
|
||||
packetDetails.timeReceived.timePosition = RAIL_PACKET_TIME_INVALID;
|
||||
packetDetails.timeReceived.totalPacketBytes = 0;
|
||||
status = RAIL_GetRxPacketDetails(aRailHandle, packetHandle, &packetDetails);
|
||||
status = RAIL_GetRxPacketDetails(aRailHandle, packetHandle, &packetDetails);
|
||||
assert(status == RAIL_STATUS_NO_ERROR);
|
||||
otEXPECT(packetDetails.isAck);
|
||||
|
||||
@@ -627,8 +617,7 @@ static void checkForAck(RAIL_Handle_t aRailHandle)
|
||||
|
||||
// read packet
|
||||
memcpy(frame, packetInfo.firstPortionData, packetInfo.firstPortionBytes);
|
||||
memcpy(frame + packetInfo.firstPortionBytes,
|
||||
packetInfo.lastPortionData,
|
||||
memcpy(frame + packetInfo.firstPortionBytes, packetInfo.lastPortionData,
|
||||
packetInfo.packetBytes - packetInfo.firstPortionBytes);
|
||||
|
||||
assert((frame[0] & IEEE802154_FRAME_TYPE_MASK) == IEEE802154_FRAME_TYPE_ACK);
|
||||
@@ -651,19 +640,19 @@ exit:
|
||||
|
||||
static void processNextRxPacket(otInstance *aInstance, RAIL_Handle_t aRailHandle)
|
||||
{
|
||||
RAIL_RxPacketHandle_t packetHandle = RAIL_RX_PACKET_HANDLE_INVALID;
|
||||
RAIL_RxPacketInfo_t packetInfo;
|
||||
RAIL_RxPacketHandle_t packetHandle = RAIL_RX_PACKET_HANDLE_INVALID;
|
||||
RAIL_RxPacketInfo_t packetInfo;
|
||||
RAIL_RxPacketDetails_t packetDetails;
|
||||
RAIL_Status_t status;
|
||||
uint16_t length;
|
||||
RAIL_Status_t status;
|
||||
uint16_t length;
|
||||
|
||||
packetHandle = RAIL_GetRxPacketInfo(aRailHandle, RAIL_RX_PACKET_HANDLE_OLDEST, &packetInfo);
|
||||
otEXPECT_ACTION(packetInfo.packetStatus == RAIL_RX_PACKET_READY_SUCCESS,
|
||||
packetHandle = RAIL_RX_PACKET_HANDLE_INVALID);
|
||||
|
||||
packetDetails.timeReceived.timePosition = RAIL_PACKET_TIME_INVALID;
|
||||
packetDetails.timeReceived.timePosition = RAIL_PACKET_TIME_INVALID;
|
||||
packetDetails.timeReceived.totalPacketBytes = 0;
|
||||
status = RAIL_GetRxPacketDetails(aRailHandle, packetHandle, &packetDetails);
|
||||
status = RAIL_GetRxPacketDetails(aRailHandle, packetHandle, &packetDetails);
|
||||
otEXPECT(status != RAIL_STATUS_INVALID_STATE);
|
||||
assert(status == RAIL_STATUS_NO_ERROR);
|
||||
length = packetInfo.packetBytes + 1;
|
||||
@@ -687,13 +676,12 @@ static void processNextRxPacket(otInstance *aInstance, RAIL_Handle_t aRailHandle
|
||||
|
||||
// read packet
|
||||
memcpy(sReceiveFrame.mPsdu, packetInfo.firstPortionData, packetInfo.firstPortionBytes);
|
||||
memcpy(sReceiveFrame.mPsdu + packetInfo.firstPortionBytes,
|
||||
packetInfo.lastPortionData,
|
||||
memcpy(sReceiveFrame.mPsdu + packetInfo.firstPortionBytes, packetInfo.lastPortionData,
|
||||
packetInfo.packetBytes - packetInfo.firstPortionBytes);
|
||||
|
||||
sReceiveFrame.mLength = length;
|
||||
sReceiveFrame.mRssi = packetDetails.rssi;
|
||||
sReceiveFrame.mLqi = packetDetails.lqi;
|
||||
sReceiveFrame.mRssi = packetDetails.rssi;
|
||||
sReceiveFrame.mLqi = packetDetails.lqi;
|
||||
|
||||
// TODO: grab timestamp and handle conversion to msec/usec
|
||||
// sReceiveFrame.mMsec = packetDetails.packetTime;
|
||||
@@ -759,13 +747,13 @@ static void RAILCb_Generic(RAIL_Handle_t aRailHandle, RAIL_Events_t aEvents)
|
||||
if (aEvents & (RAIL_EVENT_TX_ABORTED | RAIL_EVENT_TX_BLOCKED | RAIL_EVENT_TX_UNDERFLOW))
|
||||
{
|
||||
sTransmitError = OT_ERROR_ABORT;
|
||||
sTransmitBusy = false;
|
||||
sTransmitBusy = false;
|
||||
}
|
||||
|
||||
if (aEvents & RAIL_EVENT_RX_ACK_TIMEOUT)
|
||||
{
|
||||
sTransmitError = OT_ERROR_NO_ACK;
|
||||
sTransmitBusy = false;
|
||||
sTransmitBusy = false;
|
||||
}
|
||||
|
||||
if (aEvents & RAIL_EVENT_RX_PACKET_RECEIVED)
|
||||
@@ -784,14 +772,14 @@ static void RAILCb_Generic(RAIL_Handle_t aRailHandle, RAIL_Events_t aEvents)
|
||||
if ((sTransmitFrame.mPsdu[0] & IEEE802154_ACK_REQUEST) == 0)
|
||||
{
|
||||
sTransmitError = OT_ERROR_NONE;
|
||||
sTransmitBusy = false;
|
||||
sTransmitBusy = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (aEvents & RAIL_EVENT_TX_CHANNEL_BUSY)
|
||||
{
|
||||
sTransmitError = OT_ERROR_CHANNEL_ACCESS_FAILURE;
|
||||
sTransmitBusy = false;
|
||||
sTransmitBusy = false;
|
||||
}
|
||||
|
||||
if (aEvents & RAIL_EVENT_CAL_NEEDED)
|
||||
|
||||
@@ -49,7 +49,7 @@ void efr32RandomInit(void)
|
||||
{
|
||||
/* Enable ADC Clock */
|
||||
CMU_ClockEnable(cmuClock_ADC0, true);
|
||||
ADC_Init_TypeDef init = ADC_INIT_DEFAULT;
|
||||
ADC_Init_TypeDef init = ADC_INIT_DEFAULT;
|
||||
ADC_InitSingle_TypeDef singleInit = ADC_INITSINGLE_DEFAULT;
|
||||
|
||||
/* Initialize the ADC with the required values */
|
||||
@@ -59,9 +59,9 @@ void efr32RandomInit(void)
|
||||
|
||||
/* Initialize for single conversion specific to RNG */
|
||||
singleInit.reference = adcRefVEntropy;
|
||||
singleInit.diff = true;
|
||||
singleInit.posSel = adcPosSelVSS;
|
||||
singleInit.negSel = adcNegSelVSS;
|
||||
singleInit.diff = true;
|
||||
singleInit.posSel = adcPosSelVSS;
|
||||
singleInit.negSel = adcNegSelVSS;
|
||||
ADC_InitSingle(ADC0, &singleInit);
|
||||
|
||||
/* Set VINATT to maximum value and clear FIFO */
|
||||
@@ -71,7 +71,7 @@ void efr32RandomInit(void)
|
||||
|
||||
uint32_t otPlatRandomGet(void)
|
||||
{
|
||||
uint8_t tmp = 0;
|
||||
uint8_t tmp = 0;
|
||||
uint32_t random = 0;
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
@@ -80,7 +80,8 @@ uint32_t otPlatRandomGet(void)
|
||||
{
|
||||
ADC_Start(ADC0, adcStartSingle);
|
||||
|
||||
while ((ADC0->IF & ADC_IF_SINGLE) == 0);
|
||||
while ((ADC0->IF & ADC_IF_SINGLE) == 0)
|
||||
;
|
||||
|
||||
tmp |= ((ADC_DataSingleGet(ADC0) & 0x07) << (j * 3));
|
||||
}
|
||||
|
||||
@@ -33,10 +33,23 @@
|
||||
|
||||
__extension__ typedef int __guard __attribute__((mode(__DI__)));
|
||||
|
||||
int __cxa_guard_acquire(__guard *g) { return !*(char *)(g); }
|
||||
int __cxa_guard_acquire(__guard *g)
|
||||
{
|
||||
return !*(char *)(g);
|
||||
}
|
||||
|
||||
void __cxa_guard_release(__guard *g) { *(char *)g = 1; }
|
||||
void __cxa_guard_release(__guard *g)
|
||||
{
|
||||
*(char *)g = 1;
|
||||
}
|
||||
|
||||
void __cxa_guard_abort(__guard *g) { (void)g; }
|
||||
void __cxa_guard_abort(__guard *g)
|
||||
{
|
||||
(void)g;
|
||||
}
|
||||
|
||||
void __cxa_pure_virtual(void) { while (1); }
|
||||
void __cxa_pure_virtual(void)
|
||||
{
|
||||
while (1)
|
||||
;
|
||||
}
|
||||
|
||||
@@ -49,35 +49,35 @@ enum
|
||||
kReceiveFifoSize = 128,
|
||||
};
|
||||
|
||||
#define USART_INIT \
|
||||
{ \
|
||||
USART0, /* USART port */ \
|
||||
115200, /* Baud rate */ \
|
||||
BSP_SERIAL_APP_TX_LOC, /* USART Tx pin location number */ \
|
||||
BSP_SERIAL_APP_RX_LOC, /* USART Rx pin location number */ \
|
||||
(USART_Stopbits_TypeDef)USART_FRAME_STOPBITS_ONE, /* Stop bits */ \
|
||||
(USART_Parity_TypeDef)USART_FRAME_PARITY_NONE, /* Parity */ \
|
||||
(USART_OVS_TypeDef)USART_CTRL_OVS_X16, /* Oversampling mode*/ \
|
||||
false, /* Majority vote disable */ \
|
||||
uartdrvFlowControlHwUart, /* Flow control */ \
|
||||
BSP_SERIAL_APP_CTS_PORT, /* CTS port number */ \
|
||||
BSP_SERIAL_APP_CTS_PIN, /* CTS pin number */ \
|
||||
BSP_SERIAL_APP_RTS_PORT, /* RTS port number */ \
|
||||
BSP_SERIAL_APP_RTS_PIN, /* RTS pin number */ \
|
||||
(UARTDRV_Buffer_FifoQueue_t *)&sUartRxQueue, /* RX operation queue */ \
|
||||
(UARTDRV_Buffer_FifoQueue_t *)&sUartTxQueue, /* TX operation queue */ \
|
||||
BSP_SERIAL_APP_CTS_LOC, /* CTS location */ \
|
||||
BSP_SERIAL_APP_RTS_LOC /* RTS location */ \
|
||||
#define USART_INIT \
|
||||
{ \
|
||||
USART0, /* USART port */ \
|
||||
115200, /* Baud rate */ \
|
||||
BSP_SERIAL_APP_TX_LOC, /* USART Tx pin location number */ \
|
||||
BSP_SERIAL_APP_RX_LOC, /* USART Rx pin location number */ \
|
||||
(USART_Stopbits_TypeDef)USART_FRAME_STOPBITS_ONE, /* Stop bits */ \
|
||||
(USART_Parity_TypeDef)USART_FRAME_PARITY_NONE, /* Parity */ \
|
||||
(USART_OVS_TypeDef)USART_CTRL_OVS_X16, /* Oversampling mode*/ \
|
||||
false, /* Majority vote disable */ \
|
||||
uartdrvFlowControlHwUart, /* Flow control */ \
|
||||
BSP_SERIAL_APP_CTS_PORT, /* CTS port number */ \
|
||||
BSP_SERIAL_APP_CTS_PIN, /* CTS pin number */ \
|
||||
BSP_SERIAL_APP_RTS_PORT, /* RTS port number */ \
|
||||
BSP_SERIAL_APP_RTS_PIN, /* RTS pin number */ \
|
||||
(UARTDRV_Buffer_FifoQueue_t *)&sUartRxQueue, /* RX operation queue */ \
|
||||
(UARTDRV_Buffer_FifoQueue_t *)&sUartTxQueue, /* TX operation queue */ \
|
||||
BSP_SERIAL_APP_CTS_LOC, /* CTS location */ \
|
||||
BSP_SERIAL_APP_RTS_LOC /* RTS location */ \
|
||||
}
|
||||
|
||||
DEFINE_BUF_QUEUE(EMDRV_UARTDRV_MAX_CONCURRENT_RX_BUFS, sUartRxQueue);
|
||||
DEFINE_BUF_QUEUE(EMDRV_UARTDRV_MAX_CONCURRENT_TX_BUFS, sUartTxQueue);
|
||||
|
||||
static UARTDRV_HandleData_t sUartHandleData;
|
||||
static UARTDRV_Handle_t sUartHandle = &sUartHandleData;
|
||||
static uint8_t sReceiveBuffer[2];
|
||||
static const uint8_t *sTransmitBuffer = NULL;
|
||||
static uint16_t sTransmitLength = 0;
|
||||
static UARTDRV_HandleData_t sUartHandleData;
|
||||
static UARTDRV_Handle_t sUartHandle = &sUartHandleData;
|
||||
static uint8_t sReceiveBuffer[2];
|
||||
static const uint8_t * sTransmitBuffer = NULL;
|
||||
static uint16_t sTransmitLength = 0;
|
||||
|
||||
typedef struct ReceiveFifo_t
|
||||
{
|
||||
@@ -99,7 +99,7 @@ static void receiveDone(UARTDRV_Handle_t aHandle, Ecode_t aStatus, uint8_t *aDat
|
||||
if (sReceiveFifo.mHead != (sReceiveFifo.mTail + 1) % kReceiveFifoSize)
|
||||
{
|
||||
sReceiveFifo.mBuffer[sReceiveFifo.mTail] = aData[0];
|
||||
sReceiveFifo.mTail = (sReceiveFifo.mTail + 1) % kReceiveFifoSize;
|
||||
sReceiveFifo.mTail = (sReceiveFifo.mTail + 1) % kReceiveFifoSize;
|
||||
}
|
||||
|
||||
UARTDRV_Receive(aHandle, aData, 1, receiveDone);
|
||||
|
||||
Executable → Regular
+3
-6
@@ -32,14 +32,14 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "platform-emsk.h"
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "openthread/platform/alarm-milli.h"
|
||||
#include "platform-emsk.h"
|
||||
|
||||
static uint32_t sCounter = 0;
|
||||
static uint32_t expires;
|
||||
static bool sIsRunning = false;
|
||||
static bool sIsRunning = false;
|
||||
|
||||
void emskAlarmInit(void)
|
||||
{
|
||||
@@ -54,7 +54,7 @@ uint32_t otPlatAlarmMilliGetNow(void)
|
||||
void otPlatAlarmMilliStartAt(otInstance *aInstance, uint32_t t0, uint32_t dt)
|
||||
{
|
||||
(void)aInstance;
|
||||
expires = t0 + dt;
|
||||
expires = t0 + dt;
|
||||
sIsRunning = true;
|
||||
}
|
||||
|
||||
@@ -90,7 +90,6 @@ void emskAlarmUpdateTimeout(int32_t *aTimeout)
|
||||
|
||||
exit:
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
void emskAlarmProcess(otInstance *aInstance)
|
||||
@@ -106,7 +105,5 @@ void emskAlarmProcess(otInstance *aInstance)
|
||||
sIsRunning = false;
|
||||
otPlatAlarmMilliFired(aInstance);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -32,11 +32,11 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "platform-emsk.h"
|
||||
#include <utils/code_utils.h>
|
||||
#include <utils/flash.h>
|
||||
#include <openthread/config.h>
|
||||
#include "openthread/platform/alarm-milli.h"
|
||||
#include <utils/flash.h>
|
||||
#include <utils/code_utils.h>
|
||||
#include "platform-emsk.h"
|
||||
|
||||
/**
|
||||
* EMSK HAS 128 Mbit (16 MB) SPI flash memory (Winbond W25Q128BV).
|
||||
@@ -51,8 +51,8 @@
|
||||
* Secondary bootloader: from 0x0078 0000
|
||||
* Available for OpenThread: from 0x00FF D000 to 0x00FF EFFF
|
||||
*/
|
||||
#define OPENTHREAD_FLASH_BASE 0x00ffd000
|
||||
#define OPENTHREAD_FLASH_SIZE 0x00002000
|
||||
#define OPENTHREAD_FLASH_BASE 0x00ffd000
|
||||
#define OPENTHREAD_FLASH_SIZE 0x00002000
|
||||
|
||||
/**
|
||||
* Define SETTINGS_CONFIG_BASE_ADDRESS,
|
||||
@@ -62,17 +62,17 @@
|
||||
#ifdef SETTINGS_CONFIG_BASE_ADDRESS
|
||||
#undef SETTINGS_CONFIG_BASE_ADDRESS
|
||||
#endif // SETTINGS_CONFIG_BASE_ADDRESS
|
||||
#define SETTINGS_CONFIG_BASE_ADDRESS 0x00ffe000
|
||||
#define SETTINGS_CONFIG_BASE_ADDRESS 0x00ffe000
|
||||
|
||||
#ifdef SETTINGS_CONFIG_PAGE_SIZE
|
||||
#undef SETTINGS_CONFIG_PAGE_SIZE
|
||||
#endif // SETTINGS_CONFIG_PAGE_SIZE
|
||||
#define SETTINGS_CONFIG_PAGE_SIZE FLASH_SECTOR_SIZE
|
||||
#define SETTINGS_CONFIG_PAGE_SIZE FLASH_SECTOR_SIZE
|
||||
|
||||
#ifdef SETTINGS_CONFIG_PAGE_NUM
|
||||
#undef SETTINGS_CONFIG_PAGE_NUM
|
||||
#endif // SETTINGS_CONFIG_PAGE_NUM
|
||||
#define SETTINGS_CONFIG_PAGE_NUM 1
|
||||
#define SETTINGS_CONFIG_PAGE_NUM 1
|
||||
|
||||
otError utilsFlashInit(void)
|
||||
{
|
||||
@@ -90,7 +90,8 @@ otError utilsFlashErasePage(uint32_t aAddress)
|
||||
otError error = OT_ERROR_NONE;
|
||||
int32_t status;
|
||||
|
||||
otEXPECT_ACTION((aAddress >= OPENTHREAD_FLASH_BASE) && (aAddress < (OPENTHREAD_FLASH_BASE + OPENTHREAD_FLASH_SIZE - 1)),
|
||||
otEXPECT_ACTION((aAddress >= OPENTHREAD_FLASH_BASE) &&
|
||||
(aAddress < (OPENTHREAD_FLASH_BASE + OPENTHREAD_FLASH_SIZE - 1)),
|
||||
error = OT_ERROR_INVALID_ARGS);
|
||||
|
||||
/* Use 2 sectors in the implementation, cannot erase the address over the boundry */
|
||||
@@ -104,15 +105,15 @@ exit:
|
||||
|
||||
otError utilsFlashStatusWait(uint32_t aTimeout)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint32_t start = otPlatAlarmMilliGetNow();
|
||||
bool busy = true;
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint32_t start = otPlatAlarmMilliGetNow();
|
||||
bool busy = true;
|
||||
uint32_t status = 0x01;
|
||||
|
||||
while (busy && ((otPlatAlarmMilliGetNow() - start) < aTimeout))
|
||||
{
|
||||
status = flash_read_status();
|
||||
busy = status & 0x01;
|
||||
busy = status & 0x01;
|
||||
}
|
||||
|
||||
otEXPECT_ACTION(!busy, error = OT_ERROR_BUSY);
|
||||
@@ -123,12 +124,13 @@ exit:
|
||||
|
||||
uint32_t utilsFlashWrite(uint32_t aAddress, uint8_t *aData, uint32_t aSize)
|
||||
{
|
||||
int32_t written_size = 0;
|
||||
uint32_t size = 0;
|
||||
int32_t written_size = 0;
|
||||
uint32_t size = 0;
|
||||
|
||||
otEXPECT_ACTION((aAddress >= OPENTHREAD_FLASH_BASE) &&
|
||||
((aAddress + aSize) <= OPENTHREAD_FLASH_BASE + OPENTHREAD_FLASH_SIZE) &&
|
||||
(!(aAddress & 3)) && (!(aSize & 3)), ;);
|
||||
((aAddress + aSize) <= OPENTHREAD_FLASH_BASE + OPENTHREAD_FLASH_SIZE) && (!(aAddress & 3)) &&
|
||||
(!(aSize & 3)),
|
||||
;);
|
||||
|
||||
written_size = flash_write(aAddress, aSize, aData);
|
||||
|
||||
@@ -147,11 +149,12 @@ exit:
|
||||
|
||||
uint32_t utilsFlashRead(uint32_t aAddress, uint8_t *aData, uint32_t aSize)
|
||||
{
|
||||
int32_t read_size = 0;
|
||||
uint32_t size = 0;
|
||||
int32_t read_size = 0;
|
||||
uint32_t size = 0;
|
||||
|
||||
otEXPECT_ACTION((aAddress >= OPENTHREAD_FLASH_BASE) &&
|
||||
((aAddress + aSize) <= OPENTHREAD_FLASH_BASE + OPENTHREAD_FLASH_SIZE), ;);
|
||||
((aAddress + aSize) <= OPENTHREAD_FLASH_BASE + OPENTHREAD_FLASH_SIZE),
|
||||
;);
|
||||
|
||||
read_size = flash_read(aAddress, aSize, aData);
|
||||
|
||||
@@ -164,7 +167,6 @@ uint32_t utilsFlashRead(uint32_t aAddress, uint8_t *aData, uint32_t aSize)
|
||||
size = (uint32_t)read_size;
|
||||
}
|
||||
|
||||
|
||||
exit:
|
||||
return size;
|
||||
}
|
||||
|
||||
Executable → Regular
+3
-3
@@ -32,11 +32,11 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <openthread/config.h>
|
||||
#include <openthread-core-config.h>
|
||||
#include "openthread/platform/logging.h"
|
||||
#include <openthread-core-config.h>
|
||||
#include <openthread/config.h>
|
||||
|
||||
#if (OPENTHREAD_CONFIG_LOG_OUTPUT == OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED)
|
||||
#if (OPENTHREAD_CONFIG_LOG_OUTPUT == OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED)
|
||||
void otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, ...)
|
||||
{
|
||||
(void)aLogLevel;
|
||||
|
||||
Executable → Regular
+3
-3
@@ -35,10 +35,10 @@
|
||||
#ifndef PLATFORM_EMSK_H_
|
||||
#define PLATFORM_EMSK_H_
|
||||
|
||||
#include <openthread/config.h>
|
||||
#include <openthread-core-config.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <openthread/config.h>
|
||||
#include "openthread/types.h"
|
||||
|
||||
#include "board/board.h"
|
||||
@@ -87,4 +87,4 @@ void emskRandomInit(void);
|
||||
*/
|
||||
void emskUartProcess(void);
|
||||
|
||||
#endif // PLATFORM_EMSK_H_
|
||||
#endif // PLATFORM_EMSK_H_
|
||||
|
||||
Executable → Regular
+2
-2
@@ -33,12 +33,12 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "platform-emsk.h"
|
||||
#include "openthread/openthread.h"
|
||||
#include "openthread/platform/uart.h"
|
||||
#include "platform-emsk.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
|
||||
#define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
|
||||
|
||||
void PlatformInit(int argc, char *argv[])
|
||||
{
|
||||
|
||||
@@ -31,73 +31,73 @@
|
||||
* This file implements the OpenThread platform abstraction for radio communication.
|
||||
*
|
||||
*/
|
||||
#include <openthread/config.h>
|
||||
#include <openthread-core-config.h>
|
||||
#include <openthread/config.h>
|
||||
|
||||
#include "openthread/types.h"
|
||||
|
||||
#include "platform-emsk.h"
|
||||
#include <utils/code_utils.h>
|
||||
#include <openthread/platform/alarm-milli.h>
|
||||
#include <openthread/platform/radio.h>
|
||||
#include "platform-emsk.h"
|
||||
|
||||
#include "device/device_hal/inc/dev_gpio.h"
|
||||
#include <string.h>
|
||||
#include "device/device_hal/inc/dev_gpio.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
|
||||
#define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
|
||||
|
||||
enum
|
||||
{
|
||||
IEEE802154_MIN_LENGTH = 5,
|
||||
IEEE802154_MAX_LENGTH = 127,
|
||||
IEEE802154_ACK_LENGTH = 5,
|
||||
IEEE802154_MIN_LENGTH = 5,
|
||||
IEEE802154_MAX_LENGTH = 127,
|
||||
IEEE802154_ACK_LENGTH = 5,
|
||||
|
||||
IEEE802154_BROADCAST = 0xffff,
|
||||
IEEE802154_BROADCAST = 0xffff,
|
||||
|
||||
IEEE802154_FRAME_TYPE_ACK = 2 << 0,
|
||||
IEEE802154_FRAME_TYPE_MACCMD = 3 << 0,
|
||||
IEEE802154_FRAME_TYPE_MASK = 7 << 0,
|
||||
IEEE802154_FRAME_TYPE_ACK = 2 << 0,
|
||||
IEEE802154_FRAME_TYPE_MACCMD = 3 << 0,
|
||||
IEEE802154_FRAME_TYPE_MASK = 7 << 0,
|
||||
|
||||
IEEE802154_SECURITY_ENABLED = 1 << 3,
|
||||
IEEE802154_FRAME_PENDING = 1 << 4,
|
||||
IEEE802154_ACK_REQUEST = 1 << 5,
|
||||
IEEE802154_PANID_COMPRESSION = 1 << 6,
|
||||
IEEE802154_SECURITY_ENABLED = 1 << 3,
|
||||
IEEE802154_FRAME_PENDING = 1 << 4,
|
||||
IEEE802154_ACK_REQUEST = 1 << 5,
|
||||
IEEE802154_PANID_COMPRESSION = 1 << 6,
|
||||
|
||||
IEEE802154_DST_ADDR_NONE = 0 << 2,
|
||||
IEEE802154_DST_ADDR_SHORT = 2 << 2,
|
||||
IEEE802154_DST_ADDR_EXT = 3 << 2,
|
||||
IEEE802154_DST_ADDR_MASK = 3 << 2,
|
||||
IEEE802154_DST_ADDR_NONE = 0 << 2,
|
||||
IEEE802154_DST_ADDR_SHORT = 2 << 2,
|
||||
IEEE802154_DST_ADDR_EXT = 3 << 2,
|
||||
IEEE802154_DST_ADDR_MASK = 3 << 2,
|
||||
|
||||
IEEE802154_SRC_ADDR_NONE = 0 << 6,
|
||||
IEEE802154_SRC_ADDR_SHORT = 2 << 6,
|
||||
IEEE802154_SRC_ADDR_EXT = 3 << 6,
|
||||
IEEE802154_SRC_ADDR_MASK = 3 << 6,
|
||||
IEEE802154_SRC_ADDR_NONE = 0 << 6,
|
||||
IEEE802154_SRC_ADDR_SHORT = 2 << 6,
|
||||
IEEE802154_SRC_ADDR_EXT = 3 << 6,
|
||||
IEEE802154_SRC_ADDR_MASK = 3 << 6,
|
||||
|
||||
IEEE802154_DSN_OFFSET = 2,
|
||||
IEEE802154_DSTPAN_OFFSET = 3,
|
||||
IEEE802154_DSTADDR_OFFSET = 5,
|
||||
IEEE802154_DSN_OFFSET = 2,
|
||||
IEEE802154_DSTPAN_OFFSET = 3,
|
||||
IEEE802154_DSTADDR_OFFSET = 5,
|
||||
|
||||
IEEE802154_SEC_LEVEL_MASK = 7 << 0,
|
||||
IEEE802154_SEC_LEVEL_MASK = 7 << 0,
|
||||
|
||||
IEEE802154_KEY_ID_MODE_0 = 0 << 3,
|
||||
IEEE802154_KEY_ID_MODE_1 = 1 << 3,
|
||||
IEEE802154_KEY_ID_MODE_2 = 2 << 3,
|
||||
IEEE802154_KEY_ID_MODE_3 = 3 << 3,
|
||||
IEEE802154_KEY_ID_MODE_MASK = 3 << 3,
|
||||
IEEE802154_KEY_ID_MODE_0 = 0 << 3,
|
||||
IEEE802154_KEY_ID_MODE_1 = 1 << 3,
|
||||
IEEE802154_KEY_ID_MODE_2 = 2 << 3,
|
||||
IEEE802154_KEY_ID_MODE_3 = 3 << 3,
|
||||
IEEE802154_KEY_ID_MODE_MASK = 3 << 3,
|
||||
|
||||
IEEE802154_MACCMD_DATA_REQ = 4
|
||||
IEEE802154_MACCMD_DATA_REQ = 4
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
EMSK_RECEIVE_SENSITIVITY = -100, // dBm
|
||||
EMSK_RECEIVE_SENSITIVITY = -100, // dBm
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
MRF24J40_RSSI_OFFSET = 90,
|
||||
MRF24J40_RSSI_SLOPE = 5
|
||||
MRF24J40_RSSI_SLOPE = 5
|
||||
};
|
||||
|
||||
static void radioTransmitMessage(otInstance *aInstance);
|
||||
@@ -113,21 +113,21 @@ static uint8_t sTransmitPsdu[IEEE802154_MAX_LENGTH];
|
||||
static uint8_t sReceivePsdu[IEEE802154_MAX_LENGTH];
|
||||
static uint8_t sAckPsdu[IEEE802154_MAX_LENGTH];
|
||||
|
||||
static otRadioState sState = OT_RADIO_STATE_DISABLED;
|
||||
static bool sIsReceiverEnabled = false;
|
||||
static otRadioState sState = OT_RADIO_STATE_DISABLED;
|
||||
static bool sIsReceiverEnabled = false;
|
||||
|
||||
static volatile uint8_t Mrf24StatusTx = 0;
|
||||
static volatile uint8_t Mrf24StatusRx = 0;
|
||||
static volatile uint8_t Mrf24StatusTx = 0;
|
||||
static volatile uint8_t Mrf24StatusRx = 0;
|
||||
static volatile uint8_t Mrf24StatusSec = 0;
|
||||
|
||||
static DEV_SPI_PTR pmrf_spi_ptr;
|
||||
static DEV_SPI_PTR pmrf_spi_ptr;
|
||||
static DEV_GPIO_PTR pmrf_gpio_ptr;
|
||||
static void RadioIsr(void *ptr);
|
||||
static void RadioIsr(void *ptr);
|
||||
|
||||
/* Variables for test */
|
||||
static uint32_t numInterruptRev = 0;
|
||||
static uint32_t numInterruptRev = 0;
|
||||
static uint32_t numInterruptTrans = 0;
|
||||
static uint32_t numRadioProcess = 0;
|
||||
static uint32_t numRadioProcess = 0;
|
||||
|
||||
static inline bool isSecurityEnabled(const uint8_t *frame)
|
||||
{
|
||||
@@ -267,18 +267,18 @@ void emskRadioInit(void)
|
||||
DEV_GPIO_BIT_ISR isr;
|
||||
DEV_GPIO_INT_CFG int_cfg;
|
||||
|
||||
int32_t ercd;
|
||||
int32_t ercd;
|
||||
uint32_t temp;
|
||||
|
||||
sTransmitFrame.mLength = 0;
|
||||
sTransmitFrame.mPsdu = sTransmitPsdu;
|
||||
sReceiveFrame.mLength = 0;
|
||||
sReceiveFrame.mPsdu = sReceivePsdu;
|
||||
sAckFrame.mLength = 0;
|
||||
sAckFrame.mPsdu = sAckPsdu;
|
||||
sTransmitFrame.mPsdu = sTransmitPsdu;
|
||||
sReceiveFrame.mLength = 0;
|
||||
sReceiveFrame.mPsdu = sReceivePsdu;
|
||||
sAckFrame.mLength = 0;
|
||||
sAckFrame.mPsdu = sAckPsdu;
|
||||
|
||||
pmrf_spi_ptr = spi_get_dev(EMSK_PMRF_0_SPI_ID);
|
||||
ercd = pmrf_spi_ptr->spi_open(DEV_MASTER_MODE, EMSK_PMRF_0_SPIFREQ);
|
||||
ercd = pmrf_spi_ptr->spi_open(DEV_MASTER_MODE, EMSK_PMRF_0_SPIFREQ);
|
||||
|
||||
if ((ercd != E_OK) && (ercd != E_OPNED))
|
||||
{
|
||||
@@ -289,7 +289,7 @@ void emskRadioInit(void)
|
||||
|
||||
/*MRF24J40 wakepin:output, rstpin:output, INT_PIN:input, interrupt */
|
||||
pmrf_gpio_ptr = gpio_get_dev(EMSK_PMRF_0_GPIO_ID);
|
||||
ercd = pmrf_gpio_ptr->gpio_open(MRF24J40_WAKE_PIN | MRF24J40_RST_PIN);
|
||||
ercd = pmrf_gpio_ptr->gpio_open(MRF24J40_WAKE_PIN | MRF24J40_RST_PIN);
|
||||
|
||||
if ((ercd != E_OK) && (ercd != E_OPNED))
|
||||
{
|
||||
@@ -304,14 +304,14 @@ void emskRadioInit(void)
|
||||
|
||||
pmrf_gpio_ptr->gpio_control(GPIO_CMD_DIS_BIT_INT, (void *)MRF24J40_INT_PIN);
|
||||
|
||||
temp = MRF24J40_INT_PIN;
|
||||
int_cfg.int_bit_mask = temp;
|
||||
int_cfg.int_bit_type = GPIO_INT_BITS_EDGE_TRIG(temp);
|
||||
temp = MRF24J40_INT_PIN;
|
||||
int_cfg.int_bit_mask = temp;
|
||||
int_cfg.int_bit_type = GPIO_INT_BITS_EDGE_TRIG(temp);
|
||||
int_cfg.int_bit_polarity = GPIO_INT_BITS_POL_FALL_EDGE(temp);
|
||||
int_cfg.int_bit_debounce = GPIO_INT_BITS_DIS_DEBOUNCE(temp);
|
||||
pmrf_gpio_ptr->gpio_control(GPIO_CMD_SET_BIT_INT_CFG, (void *)(&int_cfg));
|
||||
|
||||
isr.int_bit_ofs = MRF24J40_INT_PIN_OFS;
|
||||
isr.int_bit_ofs = MRF24J40_INT_PIN_OFS;
|
||||
isr.int_bit_handler = RadioIsr;
|
||||
pmrf_gpio_ptr->gpio_control(GPIO_CMD_SET_BIT_ISR, (void *)(&isr));
|
||||
|
||||
@@ -321,7 +321,6 @@ void emskRadioInit(void)
|
||||
DBG("MRF24J40 Init Finished\r\n");
|
||||
|
||||
pmrf_gpio_ptr->gpio_control(GPIO_CMD_ENA_BIT_INT, (void *)MRF24J40_INT_PIN);
|
||||
|
||||
}
|
||||
|
||||
bool otPlatRadioIsEnabled(otInstance *aInstance)
|
||||
@@ -357,7 +356,7 @@ otError otPlatRadioSleep(otInstance *aInstance)
|
||||
|
||||
if (sState == OT_RADIO_STATE_SLEEP || sState == OT_RADIO_STATE_RECEIVE)
|
||||
{
|
||||
error = OT_ERROR_NONE;
|
||||
error = OT_ERROR_NONE;
|
||||
sState = OT_RADIO_STATE_SLEEP;
|
||||
disableReceiver();
|
||||
}
|
||||
@@ -372,7 +371,7 @@ otError otPlatRadioReceive(otInstance *aInstance, uint8_t aChannel)
|
||||
|
||||
if (sState != OT_RADIO_STATE_DISABLED)
|
||||
{
|
||||
error = OT_ERROR_NONE;
|
||||
error = OT_ERROR_NONE;
|
||||
sState = OT_RADIO_STATE_RECEIVE;
|
||||
setChannel(aChannel);
|
||||
sReceiveFrame.mChannel = aChannel;
|
||||
@@ -390,12 +389,11 @@ otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aFrame)
|
||||
|
||||
if (sState == OT_RADIO_STATE_RECEIVE)
|
||||
{
|
||||
error = OT_ERROR_NONE;
|
||||
error = OT_ERROR_NONE;
|
||||
sState = OT_RADIO_STATE_TRANSMIT;
|
||||
}
|
||||
|
||||
return error;
|
||||
|
||||
}
|
||||
|
||||
otRadioFrame *otPlatRadioGetTransmitBuffer(otInstance *aInstance)
|
||||
@@ -431,7 +429,6 @@ void otPlatRadioSetPromiscuous(otInstance *aInstance, bool aEnable)
|
||||
|
||||
void readFrame(void)
|
||||
{
|
||||
|
||||
/* readBuffer
|
||||
* 1 bit -- 5 to 127 bits -- 1 bit -- 1bit
|
||||
* Frame Length -- PSDU (Header + Data Payload + FCS) -- LQI -- RSSI
|
||||
@@ -441,7 +438,7 @@ void readFrame(void)
|
||||
uint8_t readRssi = 0;
|
||||
|
||||
uint16_t length;
|
||||
int16_t i;
|
||||
int16_t i;
|
||||
|
||||
memset(readBuffer, 0, MRF24J40_RXFIFO_SIZE);
|
||||
|
||||
@@ -466,19 +463,18 @@ void readFrame(void)
|
||||
#if OPENTHREAD_ENABLE_RAW_LINK_API
|
||||
// Timestamp
|
||||
sReceiveFrame.mMsec = otPlatAlarmMilliGetNow();
|
||||
sReceiveFrame.mUsec = 0; // Don't support microsecond timer for now.
|
||||
sReceiveFrame.mUsec = 0; // Don't support microsecond timer for now.
|
||||
#endif
|
||||
|
||||
/* Read PSDU */
|
||||
memcpy(sReceiveFrame.mPsdu, readBuffer, length - 2);
|
||||
|
||||
sReceiveFrame.mRssi = (int8_t)(readRssi / MRF24J40_RSSI_SLOPE) - MRF24J40_RSSI_OFFSET;
|
||||
sReceiveFrame.mLength = (uint8_t) length;
|
||||
sReceiveFrame.mLqi = readPlqi;
|
||||
sReceiveFrame.mRssi = (int8_t)(readRssi / MRF24J40_RSSI_SLOPE) - MRF24J40_RSSI_OFFSET;
|
||||
sReceiveFrame.mLength = (uint8_t)length;
|
||||
sReceiveFrame.mLqi = readPlqi;
|
||||
|
||||
exit:
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
void radioTransmitMessage(otInstance *aInstance)
|
||||
@@ -508,7 +504,8 @@ void radioTransmitMessage(otInstance *aInstance)
|
||||
else
|
||||
{
|
||||
reg &= ~(MRF24J40_TXNSECEN);
|
||||
mrf24j40_write_short_ctrl_reg(MRF24J40_TXNCON, mrf24j40_read_short_ctrl_reg(MRF24J40_TXNCON) & (~MRF24J40_TXNSECEN));
|
||||
mrf24j40_write_short_ctrl_reg(MRF24J40_TXNCON,
|
||||
mrf24j40_read_short_ctrl_reg(MRF24J40_TXNCON) & (~MRF24J40_TXNSECEN));
|
||||
}
|
||||
|
||||
mrf24j40_txfifo_write(MRF24J40_TXNFIFO, sTransmitFrame.mPsdu, header_len, (sTransmitFrame.mLength - 2));
|
||||
@@ -518,7 +515,7 @@ void radioTransmitMessage(otInstance *aInstance)
|
||||
otPlatRadioTxStarted(aInstance, &sTransmitFrame);
|
||||
|
||||
int16_t tx_timeout = 500;
|
||||
Mrf24StatusTx = 0;
|
||||
Mrf24StatusTx = 0;
|
||||
|
||||
while ((tx_timeout > 0) && (Mrf24StatusTx != 1))
|
||||
{
|
||||
@@ -566,13 +563,12 @@ void emskRadioProcess(otInstance *aInstance)
|
||||
else if (Mrf24StatusTx == 1)
|
||||
{
|
||||
Mrf24StatusTx = 0;
|
||||
sState = OT_RADIO_STATE_RECEIVE;
|
||||
sState = OT_RADIO_STATE_RECEIVE;
|
||||
otPlatRadioTxDone(aInstance, &sTransmitFrame, &sReceiveFrame, sTransmitError);
|
||||
}
|
||||
}
|
||||
|
||||
sReceiveFrame.mLength = 0;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -618,7 +614,6 @@ static void RadioIsr(void *ptr)
|
||||
Mrf24StatusSec = 1;
|
||||
mrf24j40_sec_intcb(false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* CC2538 supports source address matching for low power consumption
|
||||
|
||||
Executable → Regular
+4
-5
@@ -37,9 +37,9 @@
|
||||
|
||||
#include <utils/code_utils.h>
|
||||
|
||||
#include "openthread/platform/random.h"
|
||||
#include "openthread/platform/radio.h"
|
||||
#include "platform-emsk.h"
|
||||
#include "openthread/platform/radio.h"
|
||||
#include "openthread/platform/random.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
@@ -60,14 +60,13 @@ void emskRandomInit(void)
|
||||
|
||||
uint32_t otPlatRandomGet(void)
|
||||
{
|
||||
|
||||
return (uint32_t)rand();
|
||||
}
|
||||
|
||||
otError otPlatRandomGetTrue(uint8_t *aOutput, uint16_t aOutputLength)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint8_t channel = 0;
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint8_t channel = 0;
|
||||
otInstance *aInstance = NULL;
|
||||
|
||||
otEXPECT_ACTION(aOutput && aOutputLength, error = OT_ERROR_INVALID_ARGS);
|
||||
|
||||
@@ -34,18 +34,18 @@
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "openthread/types.h"
|
||||
#include "platform-emsk.h"
|
||||
#include <utils/code_utils.h>
|
||||
#include "openthread/platform/uart.h"
|
||||
#include "platform-emsk.h"
|
||||
#include "openthread/types.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
|
||||
#define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
|
||||
|
||||
enum
|
||||
{
|
||||
kUartId = BOARD_CONSOLE_UART_ID,
|
||||
kBaudRate = BOARD_CONSOLE_UART_BAUD,
|
||||
kUartId = BOARD_CONSOLE_UART_ID,
|
||||
kBaudRate = BOARD_CONSOLE_UART_BAUD,
|
||||
kReceiveBufferSize = 128,
|
||||
};
|
||||
|
||||
@@ -53,9 +53,9 @@ static void processReceive(void);
|
||||
static void processTransmit(void);
|
||||
|
||||
static const uint8_t *sTransmitBuffer = NULL;
|
||||
static uint16_t sTransmitLength = 0;
|
||||
static uint16_t sTransmitLength = 0;
|
||||
|
||||
static uint8_t sReceiveBuffer[kReceiveBufferSize];
|
||||
static uint8_t sReceiveBuffer[kReceiveBufferSize];
|
||||
static uint16_t sReceiveHead = 0;
|
||||
|
||||
static DEV_UART *consoleUart;
|
||||
@@ -63,7 +63,7 @@ static DEV_UART *consoleUart;
|
||||
otError otPlatUartEnable(void)
|
||||
{
|
||||
int32_t stateUart = 0;
|
||||
otError error = OT_ERROR_DROP;
|
||||
otError error = OT_ERROR_DROP;
|
||||
|
||||
/* UART in embARC */
|
||||
consoleUart = uart_get_dev(BOARD_CONSOLE_UART_ID);
|
||||
@@ -91,7 +91,6 @@ otError otPlatUartEnable(void)
|
||||
exit:
|
||||
|
||||
return error;
|
||||
|
||||
}
|
||||
|
||||
otError otPlatUartDisable(void)
|
||||
@@ -114,8 +113,7 @@ exit:
|
||||
|
||||
void processReceive(void)
|
||||
{
|
||||
|
||||
int32_t rdAvail = 0;
|
||||
int32_t rdAvail = 0;
|
||||
uint16_t remaining;
|
||||
|
||||
consoleUart->uart_control(UART_CMD_GET_RXAVAIL, (void *)(&rdAvail));
|
||||
@@ -167,4 +165,3 @@ void emskUartProcess(void)
|
||||
processReceive();
|
||||
processTransmit();
|
||||
}
|
||||
|
||||
|
||||
@@ -36,10 +36,10 @@
|
||||
#include <stdint.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include "alarm_qorvo.h"
|
||||
#include <openthread/openthread.h>
|
||||
#include <openthread/platform/alarm-milli.h>
|
||||
#include <openthread/platform/diag.h>
|
||||
#include "alarm_qorvo.h"
|
||||
|
||||
void qorvoAlarmInit(void)
|
||||
{
|
||||
|
||||
@@ -45,9 +45,9 @@
|
||||
static int sFlashFd;
|
||||
uint32_t sEraseAddress;
|
||||
|
||||
#define FLASH_SIZE 0x40000
|
||||
#define FLASH_SIZE 0x40000
|
||||
#define FLASH_PAGE_SIZE 0x800
|
||||
#define FLASH_PAGE_NUM 128
|
||||
#define FLASH_PAGE_NUM 128
|
||||
|
||||
otError utilsFlashInit(void)
|
||||
{
|
||||
@@ -95,10 +95,10 @@ uint32_t utilsFlashGetSize(void)
|
||||
|
||||
otError utilsFlashErasePage(uint32_t aAddress)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint32_t address;
|
||||
uint8_t dummyPage[ FLASH_SIZE ];
|
||||
ssize_t r;
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint32_t address;
|
||||
uint8_t dummyPage[FLASH_SIZE];
|
||||
ssize_t r;
|
||||
|
||||
otEXPECT_ACTION(sFlashFd >= 0, error = OT_ERROR_FAILED);
|
||||
otEXPECT_ACTION(aAddress < FLASH_SIZE, error = OT_ERROR_INVALID_ARGS);
|
||||
@@ -110,10 +110,9 @@ otError utilsFlashErasePage(uint32_t aAddress)
|
||||
memset((void *)(&dummyPage[0]), 0xff, FLASH_PAGE_SIZE);
|
||||
|
||||
// Write the page
|
||||
r = pwrite(sFlashFd, &(dummyPage[0]), FLASH_PAGE_SIZE, (off_t)address);
|
||||
r = pwrite(sFlashFd, &(dummyPage[0]), FLASH_PAGE_SIZE, (off_t)address);
|
||||
otEXPECT_ACTION((r) == ((FLASH_PAGE_SIZE)), error = OT_ERROR_FAILED);
|
||||
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
@@ -126,9 +125,9 @@ otError utilsFlashStatusWait(uint32_t aTimeout)
|
||||
|
||||
uint32_t utilsFlashWrite(uint32_t aAddress, uint8_t *aData, uint32_t aSize)
|
||||
{
|
||||
uint32_t ret = 0;
|
||||
uint32_t ret = 0;
|
||||
uint32_t index = 0;
|
||||
uint8_t byte;
|
||||
uint8_t byte;
|
||||
|
||||
otEXPECT(sFlashFd >= 0 && aAddress < FLASH_SIZE);
|
||||
|
||||
|
||||
@@ -26,15 +26,15 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <openthread/config.h>
|
||||
#include <openthread-core-config.h>
|
||||
#include "platform_qorvo.h"
|
||||
#include <openthread-core-config.h>
|
||||
#include <openthread/config.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
@@ -47,13 +47,13 @@
|
||||
|
||||
// Macro to append content to end of the log string.
|
||||
|
||||
#define LOG_PRINTF(...) \
|
||||
charsWritten = snprintf(&logString[offset], sizeof(logString) - offset , __VA_ARGS__); \
|
||||
otEXPECT_ACTION(charsWritten >= 0, logString[offset] = 0); \
|
||||
offset += (unsigned int)charsWritten; \
|
||||
otEXPECT_ACTION(offset < sizeof(logString), logString[sizeof(logString) -1 ] = 0)
|
||||
#define LOG_PRINTF(...) \
|
||||
charsWritten = snprintf(&logString[offset], sizeof(logString) - offset, __VA_ARGS__); \
|
||||
otEXPECT_ACTION(charsWritten >= 0, logString[offset] = 0); \
|
||||
offset += (unsigned int)charsWritten; \
|
||||
otEXPECT_ACTION(offset < sizeof(logString), logString[sizeof(logString) - 1] = 0)
|
||||
|
||||
#if (OPENTHREAD_CONFIG_LOG_OUTPUT == OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED)
|
||||
#if (OPENTHREAD_CONFIG_LOG_OUTPUT == OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED)
|
||||
|
||||
int PlatOtLogLevelToSysLogLevel(otLogLevel aLogLevel)
|
||||
{
|
||||
|
||||
@@ -28,16 +28,16 @@
|
||||
|
||||
#include "platform_qorvo.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <openthread/types.h>
|
||||
#include <openthread/platform/misc.h>
|
||||
#include "radio_qorvo.h"
|
||||
#include <stdlib.h>
|
||||
#include <openthread/types.h>
|
||||
#include <openthread/platform/misc.h>
|
||||
|
||||
extern int gArgumentsCount;
|
||||
extern char **gArguments;
|
||||
extern int gArgumentsCount;
|
||||
extern char **gArguments;
|
||||
|
||||
extern void platformUartRestore(void);
|
||||
|
||||
|
||||
@@ -49,8 +49,8 @@ void platformUartProcess(void);
|
||||
|
||||
otInstance *localInstance = NULL;
|
||||
|
||||
int gArgumentsCount = 0;
|
||||
char **gArguments = NULL;
|
||||
int gArgumentsCount = 0;
|
||||
char **gArguments = NULL;
|
||||
|
||||
bool qorvoPlatGotoSleepCheck(void)
|
||||
{
|
||||
@@ -71,10 +71,9 @@ void PlatformInit(int argc, char *argv[])
|
||||
|
||||
qorvoPlatInit((qorvoPlatGotoSleepCheckCallback_t)qorvoPlatGotoSleepCheck);
|
||||
platformUartInit();
|
||||
//qorvoAlarmInit();
|
||||
// qorvoAlarmInit();
|
||||
qorvoRandomInit();
|
||||
qorvoRadioInit();
|
||||
|
||||
}
|
||||
|
||||
void PlatformProcessDrivers(otInstance *aInstance)
|
||||
@@ -87,7 +86,6 @@ void PlatformProcessDrivers(otInstance *aInstance)
|
||||
|
||||
qorvoPlatMainLoop(!otTaskletsArePending(aInstance));
|
||||
platformUartProcess();
|
||||
//qorvoRadioProcess();
|
||||
//qorvoAlarmProcess();
|
||||
|
||||
// qorvoRadioProcess();
|
||||
// qorvoAlarmProcess();
|
||||
}
|
||||
|
||||
@@ -36,8 +36,8 @@
|
||||
|
||||
#include <openthread/openthread.h>
|
||||
|
||||
#include <openthread/platform/radio.h>
|
||||
#include <openthread/platform/diag.h>
|
||||
#include <openthread/platform/radio.h>
|
||||
|
||||
#include "utils/code_utils.h"
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
|
||||
enum
|
||||
{
|
||||
GP712_RECEIVE_SENSITIVITY = -100, // dBm
|
||||
GP712_RECEIVE_SENSITIVITY = -100, // dBm
|
||||
};
|
||||
|
||||
enum
|
||||
@@ -62,15 +62,15 @@ enum
|
||||
|
||||
enum
|
||||
{
|
||||
QORVO_RSSI_OFFSET = 73,
|
||||
QORVO_CRC_BIT_MASK = 0x80,
|
||||
QORVO_LQI_BIT_MASK = 0x7f,
|
||||
QORVO_RSSI_OFFSET = 73,
|
||||
QORVO_CRC_BIT_MASK = 0x80,
|
||||
QORVO_LQI_BIT_MASK = 0x7f,
|
||||
};
|
||||
|
||||
extern otRadioFrame sTransmitFrame;
|
||||
extern otRadioFrame sTransmitFrame;
|
||||
|
||||
static otRadioState sState;
|
||||
static otInstance *pQorvoInstance;
|
||||
static otRadioState sState;
|
||||
static otInstance * pQorvoInstance;
|
||||
|
||||
typedef struct otCachedSettings_s
|
||||
{
|
||||
@@ -79,8 +79,8 @@ typedef struct otCachedSettings_s
|
||||
|
||||
static otCachedSettings_t otCachedSettings;
|
||||
|
||||
static uint8_t sScanstate = 0;
|
||||
static int8_t sLastReceivedPower = 127;
|
||||
static uint8_t sScanstate = 0;
|
||||
static int8_t sLastReceivedPower = 127;
|
||||
|
||||
void otPlatRadioGetIeeeEui64(otInstance *aInstance, uint8_t *aIeeeEui64)
|
||||
{
|
||||
@@ -150,7 +150,7 @@ otError otPlatRadioSleep(otInstance *aInstance)
|
||||
if (sState == OT_RADIO_STATE_RECEIVE)
|
||||
{
|
||||
qorvoRadioSetRxOnWhenIdle(false);
|
||||
error = OT_ERROR_NONE;
|
||||
error = OT_ERROR_NONE;
|
||||
sState = OT_RADIO_STATE_SLEEP;
|
||||
}
|
||||
|
||||
@@ -159,7 +159,7 @@ otError otPlatRadioSleep(otInstance *aInstance)
|
||||
|
||||
otError otPlatRadioReceive(otInstance *aInstance, uint8_t aChannel)
|
||||
{
|
||||
otError error = OT_ERROR_INVALID_STATE;
|
||||
otError error = OT_ERROR_INVALID_STATE;
|
||||
pQorvoInstance = aInstance;
|
||||
|
||||
if ((sState != OT_RADIO_STATE_DISABLED) && (sScanstate == 0))
|
||||
@@ -171,12 +171,11 @@ otError otPlatRadioReceive(otInstance *aInstance, uint8_t aChannel)
|
||||
if (sState == OT_RADIO_STATE_SLEEP)
|
||||
{
|
||||
qorvoRadioSetRxOnWhenIdle(true);
|
||||
error = OT_ERROR_NONE;
|
||||
error = OT_ERROR_NONE;
|
||||
sState = OT_RADIO_STATE_RECEIVE;
|
||||
}
|
||||
|
||||
return error;
|
||||
|
||||
}
|
||||
|
||||
otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aPacket)
|
||||
@@ -197,10 +196,10 @@ void cbQorvoRadioTransmitDone(otRadioFrame *aPacket, bool aFramePending, otError
|
||||
{
|
||||
// TODO: pass received ACK frame instead of generating one.
|
||||
otRadioFrame ackFrame;
|
||||
uint8_t psdu[IEEE802154_ACK_LENGTH];
|
||||
uint8_t psdu[IEEE802154_ACK_LENGTH];
|
||||
|
||||
ackFrame.mPsdu = psdu;
|
||||
ackFrame.mLength = IEEE802154_ACK_LENGTH;
|
||||
ackFrame.mPsdu = psdu;
|
||||
ackFrame.mLength = IEEE802154_ACK_LENGTH;
|
||||
ackFrame.mPsdu[0] = IEEE802154_FRAME_TYPE_ACK;
|
||||
|
||||
if (aFramePending)
|
||||
@@ -254,7 +253,6 @@ void otPlatRadioSetPromiscuous(otInstance *aInstance, bool aEnable)
|
||||
(void)aEnable;
|
||||
}
|
||||
|
||||
|
||||
void otPlatRadioEnableSrcMatch(otInstance *aInstance, bool aEnable)
|
||||
{
|
||||
(void)aInstance;
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
#include <openthread/types.h>
|
||||
#include <openthread/platform/random.h>
|
||||
|
||||
@@ -52,11 +51,11 @@ void qorvoRandomInit(void)
|
||||
error = otPlatRandomGetTrue((uint8_t *)&sState, sizeof(sState));
|
||||
assert(error == OT_ERROR_NONE);
|
||||
|
||||
#else // __SANITIZE_ADDRESS__
|
||||
#else // __SANITIZE_ADDRESS__
|
||||
|
||||
sState = (uint32_t)time(NULL);
|
||||
|
||||
#endif // __SANITIZE_ADDRESS__
|
||||
#endif // __SANITIZE_ADDRESS__
|
||||
}
|
||||
|
||||
uint32_t otPlatRandomGet(void)
|
||||
@@ -65,10 +64,10 @@ uint32_t otPlatRandomGet(void)
|
||||
uint64_t tmpstate;
|
||||
|
||||
tmpstate = (uint64_t)33614 * (uint64_t)sState;
|
||||
q = tmpstate & 0xffffffff;
|
||||
q = q >> 1;
|
||||
p = tmpstate >> 32;
|
||||
mlcg = p + q;
|
||||
q = tmpstate & 0xffffffff;
|
||||
q = q >> 1;
|
||||
p = tmpstate >> 32;
|
||||
mlcg = p + q;
|
||||
|
||||
if (mlcg & 0x80000000)
|
||||
{
|
||||
@@ -87,7 +86,7 @@ otError otPlatRandomGetTrue(uint8_t *aOutput, uint16_t aOutputLength)
|
||||
|
||||
#if __SANITIZE_ADDRESS__ == 0
|
||||
|
||||
FILE *file = NULL;
|
||||
FILE * file = NULL;
|
||||
size_t readLength;
|
||||
|
||||
otEXPECT_ACTION(aOutput && aOutputLength, error = OT_ERROR_INVALID_ARGS);
|
||||
@@ -105,7 +104,7 @@ exit:
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
#else // __SANITIZE_ADDRESS__
|
||||
#else // __SANITIZE_ADDRESS__
|
||||
|
||||
/*
|
||||
* THE IMPLEMENTATION BELOW IS NOT COMPLIANT WITH THE THREAD SPECIFICATION.
|
||||
@@ -124,7 +123,7 @@ exit:
|
||||
|
||||
exit:
|
||||
|
||||
#endif // __SANITIZE_ADDRESS__
|
||||
#endif // __SANITIZE_ADDRESS__
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -26,16 +26,16 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "platform_qorvo.h"
|
||||
#include "alarm_qorvo.h"
|
||||
#include "platform_qorvo.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <poll.h>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
|
||||
@@ -45,17 +45,17 @@
|
||||
|
||||
#ifdef OPENTHREAD_TARGET_LINUX
|
||||
#include <sys/prctl.h>
|
||||
int posix_openpt(int oflag);
|
||||
int grantpt(int fildes);
|
||||
int unlockpt(int fd);
|
||||
int posix_openpt(int oflag);
|
||||
int grantpt(int fildes);
|
||||
int unlockpt(int fd);
|
||||
char *ptsname(int fd);
|
||||
#endif // OPENTHREAD_TARGET_LINUX
|
||||
#endif // OPENTHREAD_TARGET_LINUX
|
||||
|
||||
static uint8_t s_receive_buffer[128];
|
||||
static uint8_t s_receive_buffer[128];
|
||||
static const uint8_t *s_write_buffer;
|
||||
static uint16_t s_write_length;
|
||||
static int s_in_fd;
|
||||
static int s_out_fd;
|
||||
static uint16_t s_write_length;
|
||||
static int s_in_fd;
|
||||
static int s_out_fd;
|
||||
|
||||
static struct termios original_stdin_termios;
|
||||
static struct termios original_stdout_termios;
|
||||
@@ -77,8 +77,8 @@ void platformDummy(void *dummyPointer)
|
||||
|
||||
static void cbKeyPressed(uint8_t Param)
|
||||
{
|
||||
(void) Param;
|
||||
qorvoAlarmScheduleEventArg(0, platformDummy, (void *) &s_in_fd);
|
||||
(void)Param;
|
||||
qorvoAlarmScheduleEventArg(0, platformDummy, (void *)&s_in_fd);
|
||||
}
|
||||
|
||||
void platformUartRestore(void)
|
||||
@@ -90,7 +90,7 @@ void platformUartRestore(void)
|
||||
|
||||
void platformUartInit(void)
|
||||
{
|
||||
s_in_fd = dup(STDIN_FILENO);
|
||||
s_in_fd = dup(STDIN_FILENO);
|
||||
s_out_fd = dup(STDOUT_FILENO);
|
||||
dup2(STDERR_FILENO, STDOUT_FILENO);
|
||||
|
||||
@@ -100,7 +100,7 @@ void platformUartInit(void)
|
||||
|
||||
otError otPlatUartEnable(void)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
struct termios termios;
|
||||
|
||||
#ifdef OPENTHREAD_TARGET_LINUX
|
||||
@@ -138,7 +138,7 @@ otError otPlatUartEnable(void)
|
||||
termios.c_cflag |= HUPCL | CREAD | CLOCAL;
|
||||
|
||||
// "Minimum number of characters for noncanonical read"
|
||||
termios.c_cc[VMIN] = 1;
|
||||
termios.c_cc[VMIN] = 1;
|
||||
|
||||
// "Timeout in deciseconds for noncanonical read"
|
||||
termios.c_cc[VTIME] = 0;
|
||||
@@ -208,12 +208,11 @@ exit:
|
||||
|
||||
void platformUartProcess(void)
|
||||
{
|
||||
ssize_t rval;
|
||||
const int error_flags = POLLERR | POLLNVAL | POLLHUP;
|
||||
struct pollfd pollfd[] =
|
||||
{
|
||||
{ s_in_fd, POLLIN | error_flags, 0 },
|
||||
{ s_out_fd, POLLOUT | error_flags, 0 },
|
||||
ssize_t rval;
|
||||
const int error_flags = POLLERR | POLLNVAL | POLLHUP;
|
||||
struct pollfd pollfd[] = {
|
||||
{s_in_fd, POLLIN | error_flags, 0},
|
||||
{s_out_fd, POLLOUT | error_flags, 0},
|
||||
};
|
||||
|
||||
errno = 0;
|
||||
|
||||
@@ -32,10 +32,10 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "fsl_device_registers.h"
|
||||
#include "fsl_clock.h"
|
||||
#include "fsl_device_registers.h"
|
||||
#include "fsl_pit.h"
|
||||
#include <stdint.h>
|
||||
|
||||
#include "openthread/openthread.h"
|
||||
#include "openthread/platform/alarm-milli.h"
|
||||
@@ -47,7 +47,7 @@ static uint32_t sAlarmTime = 0;
|
||||
void kw41zAlarmInit(void)
|
||||
{
|
||||
pit_config_t config;
|
||||
uint32_t count = (CLOCK_GetBusClkFreq() / 1000) - 1;
|
||||
uint32_t count = (CLOCK_GetBusClkFreq() / 1000) - 1;
|
||||
|
||||
PIT_GetDefaultConfig(&config);
|
||||
PIT_Init(PIT, &config);
|
||||
|
||||
@@ -26,12 +26,12 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "fsl_device_registers.h"
|
||||
#include "fsl_flash.h"
|
||||
#include "openthread/platform/alarm-milli.h"
|
||||
#include <utils/flash.h>
|
||||
#include <stdint.h>
|
||||
#include <utils/code_utils.h>
|
||||
#include <utils/flash.h>
|
||||
#include "openthread/platform/alarm-milli.h"
|
||||
|
||||
static flash_config_t sFlashConfig;
|
||||
|
||||
@@ -54,7 +54,7 @@ uint32_t utilsFlashGetSize(void)
|
||||
|
||||
otError utilsFlashErasePage(uint32_t aAddress)
|
||||
{
|
||||
otError error;
|
||||
otError error;
|
||||
status_t status;
|
||||
|
||||
status = FLASH_Erase(&sFlashConfig, aAddress, FSL_FEATURE_FLASH_PFLASH_BLOCK_SECTOR_SIZE, kFLASH_ApiEraseKey);
|
||||
@@ -77,7 +77,7 @@ otError utilsFlashErasePage(uint32_t aAddress)
|
||||
|
||||
otError utilsFlashStatusWait(uint32_t aTimeout)
|
||||
{
|
||||
otError error = OT_ERROR_BUSY;
|
||||
otError error = OT_ERROR_BUSY;
|
||||
uint32_t start = otPlatAlarmMilliGetNow();
|
||||
|
||||
do
|
||||
@@ -87,8 +87,7 @@ otError utilsFlashStatusWait(uint32_t aTimeout)
|
||||
error = OT_ERROR_NONE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (aTimeout && ((otPlatAlarmMilliGetNow() - start) < aTimeout));
|
||||
} while (aTimeout && ((otPlatAlarmMilliGetNow() - start) < aTimeout));
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -32,11 +32,11 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "fsl_device_registers.h"
|
||||
#include <stdint.h>
|
||||
|
||||
#include <openthread/config.h>
|
||||
#include <openthread-core-config.h>
|
||||
#include <openthread/config.h>
|
||||
|
||||
#include "openthread/platform/logging.h"
|
||||
#if OPENTHREAD_ENABLE_CLI_LOGGING
|
||||
@@ -46,11 +46,11 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <utils/code_utils.h>
|
||||
#include <cli/cli-uart.h>
|
||||
#include <utils/code_utils.h>
|
||||
#endif
|
||||
|
||||
#if (OPENTHREAD_CONFIG_LOG_OUTPUT == OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED)
|
||||
#if (OPENTHREAD_CONFIG_LOG_OUTPUT == OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED)
|
||||
void otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, ...)
|
||||
{
|
||||
#if OPENTHREAD_ENABLE_CLI_LOGGING
|
||||
|
||||
@@ -26,17 +26,19 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "fsl_device_registers.h"
|
||||
#include "openthread/types.h"
|
||||
#include "openthread/platform/misc.h"
|
||||
#include "fsl_device_registers.h"
|
||||
#include <stdint.h>
|
||||
#include "openthread/types.h"
|
||||
|
||||
void otPlatReset(otInstance *aInstance)
|
||||
{
|
||||
(void)aInstance;
|
||||
NVIC_SystemReset();
|
||||
|
||||
while (1) {}
|
||||
while (1)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
otPlatResetReason otPlatGetResetReason(otInstance *aInstance)
|
||||
@@ -60,14 +62,12 @@ otPlatResetReason otPlatGetResetReason(otInstance *aInstance)
|
||||
{
|
||||
reason = OT_PLAT_RESET_REASON_EXTERNAL;
|
||||
}
|
||||
else if ((RCM->SRS0 & RCM_SRS0_LOC_MASK) ||
|
||||
(RCM->SRS1 & RCM_SRS1_SACKERR_MASK) ||
|
||||
else if ((RCM->SRS0 & RCM_SRS0_LOC_MASK) || (RCM->SRS1 & RCM_SRS1_SACKERR_MASK) ||
|
||||
(RCM->SRS1 & RCM_SRS1_LOCKUP_MASK))
|
||||
{
|
||||
reason = OT_PLAT_RESET_REASON_FAULT;
|
||||
}
|
||||
else if ((RCM->SRS0 & RCM_SRS0_WAKEUP_MASK) ||
|
||||
(RCM->SRS0 & RCM_SRS0_LVD_MASK) ||
|
||||
else if ((RCM->SRS0 & RCM_SRS0_WAKEUP_MASK) || (RCM->SRS0 & RCM_SRS0_LVD_MASK) ||
|
||||
(RCM->SRS1 & RCM_SRS1_MDM_AP_MASK))
|
||||
{
|
||||
reason = OT_PLAT_RESET_REASON_ASSERT;
|
||||
|
||||
@@ -32,21 +32,21 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "fsl_device_registers.h"
|
||||
#include "openthread/types.h"
|
||||
#include "openthread/platform/uart.h"
|
||||
#include "platform-kw41z.h"
|
||||
#include "fsl_clock.h"
|
||||
#include "fsl_port.h"
|
||||
#include "clock_config.h"
|
||||
#include "fsl_clock.h"
|
||||
#include "fsl_device_registers.h"
|
||||
#include "fsl_port.h"
|
||||
#include "platform-kw41z.h"
|
||||
#include <stdint.h>
|
||||
#include "openthread/platform/uart.h"
|
||||
#include "openthread/types.h"
|
||||
|
||||
otInstance *sInstance;
|
||||
|
||||
void PlatformInit(int argc, char *argv[])
|
||||
{
|
||||
uint32_t temp, tempTrim;
|
||||
uint8_t revId;
|
||||
uint8_t revId;
|
||||
|
||||
/* enable clock for PORTs */
|
||||
CLOCK_EnableClock(kCLOCK_PortA);
|
||||
@@ -74,7 +74,9 @@ void PlatformInit(int argc, char *argv[])
|
||||
RSIM->RF_OSC_CTRL |= RSIM_RF_OSC_CTRL_RADIO_EXT_OSC_OVRD_EN_MASK;
|
||||
|
||||
/* wait for RF_OSC_READY */
|
||||
while ((RSIM->CONTROL & RSIM_CONTROL_RF_OSC_READY_MASK) == 0) {}
|
||||
while ((RSIM->CONTROL & RSIM_CONTROL_RF_OSC_READY_MASK) == 0)
|
||||
{
|
||||
}
|
||||
|
||||
if (revId == 0)
|
||||
{
|
||||
@@ -83,7 +85,7 @@ void PlatformInit(int argc, char *argv[])
|
||||
XCVR_TSM_OVRD0_BB_LDO_ADCDAC_EN_OVRD_MASK; /* Force ADC DAC LDO on to prevent BGAP failure */
|
||||
/* Reset LDO trim settings */
|
||||
RSIM->ANA_TRIM = tempTrim;
|
||||
}/* Workaround for Rev 1.0 XTAL startup and ADC analog diagnostics circuitry */
|
||||
} /* Workaround for Rev 1.0 XTAL startup and ADC analog diagnostics circuitry */
|
||||
|
||||
/* Init board clock */
|
||||
BOARD_BootClockRUN();
|
||||
|
||||
+107
-107
@@ -32,16 +32,16 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "fsl_device_registers.h"
|
||||
#include "fsl_xcvr.h"
|
||||
#include "openthread-core-kw41z-config.h"
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include "fsl_device_registers.h"
|
||||
#include "openthread-core-kw41z-config.h"
|
||||
#include "fsl_xcvr.h"
|
||||
|
||||
#include <openthread/platform/alarm-milli.h>
|
||||
#include <openthread/platform/radio.h>
|
||||
#include <openthread/platform/diag.h>
|
||||
#include <utils/code_utils.h>
|
||||
#include <openthread/platform/alarm-milli.h>
|
||||
#include <openthread/platform/diag.h>
|
||||
#include <openthread/platform/radio.h>
|
||||
|
||||
// clang-format off
|
||||
#define DOUBLE_BUFFERING (1)
|
||||
@@ -65,8 +65,7 @@
|
||||
ZLL_IRQSTS_TMR4MSK_MASK )
|
||||
// clang-format on
|
||||
|
||||
typedef enum xcvr_state_tag
|
||||
{
|
||||
typedef enum xcvr_state_tag {
|
||||
XCVR_Idle_c,
|
||||
XCVR_RX_c,
|
||||
XCVR_TX_c,
|
||||
@@ -75,31 +74,30 @@ typedef enum xcvr_state_tag
|
||||
XCVR_CCCA_c,
|
||||
} xcvr_state_t;
|
||||
|
||||
typedef enum xcvr_cca_type_tag
|
||||
{
|
||||
XCVR_ED_c, /* energy detect - CCA bit not active, not to be used for T and CCCA sequences */
|
||||
XCVR_CCA_MODE1_c, /* energy detect - CCA bit ACTIVE */
|
||||
SCVR_CCA_MODE2_c, /* 802.15.4 compliant signal detect - CCA bit ACTIVE */
|
||||
XCVR_CCA_MODE3_c /* 802.15.4 compliant signal detect and energy detect - CCA bit ACTIVE */
|
||||
typedef enum xcvr_cca_type_tag {
|
||||
XCVR_ED_c, /* energy detect - CCA bit not active, not to be used for T and CCCA sequences */
|
||||
XCVR_CCA_MODE1_c, /* energy detect - CCA bit ACTIVE */
|
||||
SCVR_CCA_MODE2_c, /* 802.15.4 compliant signal detect - CCA bit ACTIVE */
|
||||
XCVR_CCA_MODE3_c /* 802.15.4 compliant signal detect and energy detect - CCA bit ACTIVE */
|
||||
} xcvr_cca_type_t;
|
||||
|
||||
static otRadioState sState = OT_RADIO_STATE_DISABLED;
|
||||
static uint16_t sPanId;
|
||||
static uint8_t sExtSrcAddrBitmap[(RADIO_CONFIG_SRC_MATCH_ENTRY_NUM + 7) / 8];
|
||||
static uint8_t sChannel;
|
||||
static int8_t sMaxED;
|
||||
static int8_t sAutoTxPwrLevel = 0;
|
||||
static otRadioState sState = OT_RADIO_STATE_DISABLED;
|
||||
static uint16_t sPanId;
|
||||
static uint8_t sExtSrcAddrBitmap[(RADIO_CONFIG_SRC_MATCH_ENTRY_NUM + 7) / 8];
|
||||
static uint8_t sChannel;
|
||||
static int8_t sMaxED;
|
||||
static int8_t sAutoTxPwrLevel = 0;
|
||||
|
||||
/* ISR Signaling Flags */
|
||||
static bool sTxDone = false;
|
||||
static bool sRxDone = false;
|
||||
static bool sEdScanDone = false;
|
||||
static otError sTxStatus;
|
||||
static bool sTxDone = false;
|
||||
static bool sRxDone = false;
|
||||
static bool sEdScanDone = false;
|
||||
static otError sTxStatus;
|
||||
|
||||
static otRadioFrame sTxFrame;
|
||||
static otRadioFrame sRxFrame;
|
||||
static otRadioFrame sTxFrame;
|
||||
static otRadioFrame sRxFrame;
|
||||
#if DOUBLE_BUFFERING
|
||||
static uint8_t sRxData[OT_RADIO_FRAME_MAX_SIZE];
|
||||
static uint8_t sRxData[OT_RADIO_FRAME_MAX_SIZE];
|
||||
#endif
|
||||
|
||||
/* Private functions */
|
||||
@@ -146,7 +144,7 @@ void otPlatRadioGetIeeeEui64(otInstance *aInstance, uint8_t *aIeeeEui64)
|
||||
|
||||
void otPlatRadioSetPanId(otInstance *aInstance, uint16_t aPanId)
|
||||
{
|
||||
(void) aInstance;
|
||||
(void)aInstance;
|
||||
|
||||
sPanId = aPanId;
|
||||
ZLL->MACSHORTADDRS0 &= ~ZLL_MACSHORTADDRS0_MACPANID0_MASK;
|
||||
@@ -155,7 +153,7 @@ void otPlatRadioSetPanId(otInstance *aInstance, uint16_t aPanId)
|
||||
|
||||
void otPlatRadioSetExtendedAddress(otInstance *aInstance, const otExtAddress *aExtAddress)
|
||||
{
|
||||
(void) aInstance;
|
||||
(void)aInstance;
|
||||
uint32_t addrLo;
|
||||
uint32_t addrHi;
|
||||
|
||||
@@ -168,7 +166,7 @@ void otPlatRadioSetExtendedAddress(otInstance *aInstance, const otExtAddress *aE
|
||||
|
||||
void otPlatRadioSetShortAddress(otInstance *aInstance, uint16_t aShortAddress)
|
||||
{
|
||||
(void) aInstance;
|
||||
(void)aInstance;
|
||||
|
||||
ZLL->MACSHORTADDRS0 &= ~ZLL_MACSHORTADDRS0_MACSHORTADDRS0_MASK;
|
||||
ZLL->MACSHORTADDRS0 |= ZLL_MACSHORTADDRS0_MACSHORTADDRS0(aShortAddress);
|
||||
@@ -202,17 +200,17 @@ exit:
|
||||
|
||||
bool otPlatRadioIsEnabled(otInstance *aInstance)
|
||||
{
|
||||
(void) aInstance;
|
||||
(void)aInstance;
|
||||
return sState != OT_RADIO_STATE_DISABLED;
|
||||
}
|
||||
|
||||
otError otPlatRadioSleep(otInstance *aInstance)
|
||||
{
|
||||
otError status = OT_ERROR_NONE;
|
||||
(void) aInstance;
|
||||
(void)aInstance;
|
||||
|
||||
otEXPECT_ACTION(((sState != OT_RADIO_STATE_TRANSMIT) &&
|
||||
(sState != OT_RADIO_STATE_DISABLED)), status = OT_ERROR_INVALID_STATE);
|
||||
otEXPECT_ACTION(((sState != OT_RADIO_STATE_TRANSMIT) && (sState != OT_RADIO_STATE_DISABLED)),
|
||||
status = OT_ERROR_INVALID_STATE);
|
||||
|
||||
rf_abort();
|
||||
sState = OT_RADIO_STATE_SLEEP;
|
||||
@@ -224,10 +222,10 @@ exit:
|
||||
otError otPlatRadioReceive(otInstance *aInstance, uint8_t aChannel)
|
||||
{
|
||||
otError status = OT_ERROR_NONE;
|
||||
(void) aInstance;
|
||||
(void)aInstance;
|
||||
|
||||
otEXPECT_ACTION(((sState != OT_RADIO_STATE_TRANSMIT) &&
|
||||
(sState != OT_RADIO_STATE_DISABLED)), status = OT_ERROR_INVALID_STATE);
|
||||
otEXPECT_ACTION(((sState != OT_RADIO_STATE_TRANSMIT) && (sState != OT_RADIO_STATE_DISABLED)),
|
||||
status = OT_ERROR_INVALID_STATE);
|
||||
|
||||
sState = OT_RADIO_STATE_RECEIVE;
|
||||
|
||||
@@ -243,7 +241,7 @@ otError otPlatRadioReceive(otInstance *aInstance, uint8_t aChannel)
|
||||
/* Clear all IRQ flags */
|
||||
ZLL->IRQSTS = ZLL->IRQSTS;
|
||||
/* Start the RX sequence */
|
||||
ZLL->PHY_CTRL |= XCVR_RX_c ;
|
||||
ZLL->PHY_CTRL |= XCVR_RX_c;
|
||||
|
||||
/* Unmask SEQ interrupt */
|
||||
ZLL->PHY_CTRL &= ~ZLL_PHY_CTRL_SEQMSK_MASK;
|
||||
@@ -254,7 +252,7 @@ exit:
|
||||
|
||||
void otPlatRadioEnableSrcMatch(otInstance *aInstance, bool aEnable)
|
||||
{
|
||||
(void) aInstance;
|
||||
(void)aInstance;
|
||||
|
||||
if (aEnable)
|
||||
{
|
||||
@@ -268,7 +266,7 @@ void otPlatRadioEnableSrcMatch(otInstance *aInstance, bool aEnable)
|
||||
|
||||
otError otPlatRadioAddSrcMatchShortEntry(otInstance *aInstance, const uint16_t aShortAddress)
|
||||
{
|
||||
(void) aInstance;
|
||||
(void)aInstance;
|
||||
uint16_t checksum = sPanId + aShortAddress;
|
||||
|
||||
return rf_add_addr_table_entry(checksum, false);
|
||||
@@ -276,7 +274,7 @@ otError otPlatRadioAddSrcMatchShortEntry(otInstance *aInstance, const uint16_t a
|
||||
|
||||
otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress)
|
||||
{
|
||||
(void) aInstance;
|
||||
(void)aInstance;
|
||||
uint16_t checksum = rf_get_addr_checksum((uint8_t *)aExtAddress->m8, true, sPanId);
|
||||
|
||||
return rf_add_addr_table_entry(checksum, true);
|
||||
@@ -284,7 +282,7 @@ otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const otExtAddress
|
||||
|
||||
otError otPlatRadioClearSrcMatchShortEntry(otInstance *aInstance, const uint16_t aShortAddress)
|
||||
{
|
||||
(void) aInstance;
|
||||
(void)aInstance;
|
||||
uint16_t checksum = sPanId + aShortAddress;
|
||||
|
||||
return rf_remove_addr_table_entry(checksum);
|
||||
@@ -292,7 +290,7 @@ otError otPlatRadioClearSrcMatchShortEntry(otInstance *aInstance, const uint16_t
|
||||
|
||||
otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress)
|
||||
{
|
||||
(void) aInstance;
|
||||
(void)aInstance;
|
||||
uint16_t checksum = rf_get_addr_checksum((uint8_t *)aExtAddress->m8, true, sPanId);
|
||||
|
||||
return rf_remove_addr_table_entry(checksum);
|
||||
@@ -300,7 +298,7 @@ otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const otExtAddre
|
||||
|
||||
void otPlatRadioClearSrcMatchShortEntries(otInstance *aInstance)
|
||||
{
|
||||
(void) aInstance;
|
||||
(void)aInstance;
|
||||
uint32_t i;
|
||||
|
||||
for (i = 0; i < RADIO_CONFIG_SRC_MATCH_ENTRY_NUM; i++)
|
||||
@@ -315,7 +313,7 @@ void otPlatRadioClearSrcMatchShortEntries(otInstance *aInstance)
|
||||
|
||||
void otPlatRadioClearSrcMatchExtEntries(otInstance *aInstance)
|
||||
{
|
||||
(void) aInstance;
|
||||
(void)aInstance;
|
||||
uint32_t i;
|
||||
|
||||
for (i = 0; i < RADIO_CONFIG_SRC_MATCH_ENTRY_NUM; i++)
|
||||
@@ -336,11 +334,11 @@ otRadioFrame *otPlatRadioGetTransmitBuffer(otInstance *aInstance)
|
||||
|
||||
otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aFrame)
|
||||
{
|
||||
otError status = OT_ERROR_NONE;
|
||||
otError status = OT_ERROR_NONE;
|
||||
uint32_t timeout;
|
||||
|
||||
otEXPECT_ACTION(((sState != OT_RADIO_STATE_TRANSMIT) &&
|
||||
(sState != OT_RADIO_STATE_DISABLED)), status = OT_ERROR_INVALID_STATE);
|
||||
otEXPECT_ACTION(((sState != OT_RADIO_STATE_TRANSMIT) && (sState != OT_RADIO_STATE_DISABLED)),
|
||||
status = OT_ERROR_INVALID_STATE);
|
||||
|
||||
if (rf_get_state() != XCVR_Idle_c)
|
||||
{
|
||||
@@ -363,9 +361,10 @@ otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aFrame)
|
||||
{
|
||||
ZLL->PHY_CTRL |= XCVR_TR_c;
|
||||
/* Set ACK wait time-out */
|
||||
timeout = rf_get_timestamp();
|
||||
timeout = rf_get_timestamp();
|
||||
timeout += (((XCVR_TSM->END_OF_SEQ & XCVR_TSM_END_OF_SEQ_END_OF_TX_WU_MASK) >>
|
||||
XCVR_TSM_END_OF_SEQ_END_OF_TX_WU_SHIFT) >> 4);
|
||||
XCVR_TSM_END_OF_SEQ_END_OF_TX_WU_SHIFT) >>
|
||||
4);
|
||||
timeout += IEEE802154_CCA_LEN + IEEE802154_TURNAROUND_LEN + IEEE802154_PHY_SHR_LEN +
|
||||
(1 + aFrame->mLength) * OT_RADIO_SYMBOLS_PER_OCTET + IEEE802154_ACK_WAIT;
|
||||
rf_set_timeout(timeout);
|
||||
@@ -376,7 +375,7 @@ otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aFrame)
|
||||
}
|
||||
|
||||
sTxStatus = OT_ERROR_NONE;
|
||||
sState = OT_RADIO_STATE_TRANSMIT;
|
||||
sState = OT_RADIO_STATE_TRANSMIT;
|
||||
/* Unmask SEQ interrupt */
|
||||
ZLL->PHY_CTRL &= ~ZLL_PHY_CTRL_SEQMSK_MASK;
|
||||
|
||||
@@ -388,7 +387,7 @@ exit:
|
||||
|
||||
int8_t otPlatRadioGetRssi(otInstance *aInstance)
|
||||
{
|
||||
(void) aInstance;
|
||||
(void)aInstance;
|
||||
return (ZLL->LQI_AND_RSSI & ZLL_LQI_AND_RSSI_RSSI_MASK) >> ZLL_LQI_AND_RSSI_RSSI_SHIFT;
|
||||
}
|
||||
|
||||
@@ -400,20 +399,19 @@ otRadioCaps otPlatRadioGetCaps(otInstance *aInstance)
|
||||
|
||||
bool otPlatRadioGetPromiscuous(otInstance *aInstance)
|
||||
{
|
||||
(void) aInstance;
|
||||
(void)aInstance;
|
||||
return (ZLL->PHY_CTRL & ZLL_PHY_CTRL_PROMISCUOUS_MASK) == ZLL_PHY_CTRL_PROMISCUOUS_MASK;
|
||||
}
|
||||
|
||||
void otPlatRadioSetPromiscuous(otInstance *aInstance, bool aEnable)
|
||||
{
|
||||
(void) aInstance;
|
||||
(void)aInstance;
|
||||
|
||||
if (aEnable)
|
||||
{
|
||||
ZLL->PHY_CTRL |= ZLL_PHY_CTRL_PROMISCUOUS_MASK;
|
||||
/* FRM_VER[11:8] = b1111. Any FrameVersion accepted */
|
||||
ZLL->RX_FRAME_FILTER |= (ZLL_RX_FRAME_FILTER_FRM_VER_FILTER_MASK |
|
||||
ZLL_RX_FRAME_FILTER_ACK_FT_MASK |
|
||||
ZLL->RX_FRAME_FILTER |= (ZLL_RX_FRAME_FILTER_FRM_VER_FILTER_MASK | ZLL_RX_FRAME_FILTER_ACK_FT_MASK |
|
||||
ZLL_RX_FRAME_FILTER_NS_FT_MASK);
|
||||
}
|
||||
else
|
||||
@@ -421,22 +419,20 @@ void otPlatRadioSetPromiscuous(otInstance *aInstance, bool aEnable)
|
||||
ZLL->PHY_CTRL &= ~ZLL_PHY_CTRL_PROMISCUOUS_MASK;
|
||||
/* FRM_VER[11:8] = b0011. Accept FrameVersion 0 and 1 packets, reject all others */
|
||||
/* Beacon, Data and MAC command frame types accepted */
|
||||
ZLL->RX_FRAME_FILTER &= ~(ZLL_RX_FRAME_FILTER_FRM_VER_FILTER_MASK |
|
||||
ZLL_RX_FRAME_FILTER_ACK_FT_MASK |
|
||||
ZLL_RX_FRAME_FILTER_NS_FT_MASK |
|
||||
ZLL_RX_FRAME_FILTER_ACTIVE_PROMISCUOUS_MASK);
|
||||
ZLL->RX_FRAME_FILTER &= ~(ZLL_RX_FRAME_FILTER_FRM_VER_FILTER_MASK | ZLL_RX_FRAME_FILTER_ACK_FT_MASK |
|
||||
ZLL_RX_FRAME_FILTER_NS_FT_MASK | ZLL_RX_FRAME_FILTER_ACTIVE_PROMISCUOUS_MASK);
|
||||
ZLL->RX_FRAME_FILTER |= ZLL_RX_FRAME_FILTER_FRM_VER_FILTER(3);
|
||||
}
|
||||
}
|
||||
|
||||
otError otPlatRadioEnergyScan(otInstance *aInstance, uint8_t aScanChannel, uint16_t aScanDuration)
|
||||
{
|
||||
otError status = OT_ERROR_NONE;
|
||||
otError status = OT_ERROR_NONE;
|
||||
uint32_t timeout;
|
||||
(void) aInstance;
|
||||
(void)aInstance;
|
||||
|
||||
otEXPECT_ACTION(((sState != OT_RADIO_STATE_TRANSMIT) &&
|
||||
(sState != OT_RADIO_STATE_DISABLED)), status = OT_ERROR_INVALID_STATE);
|
||||
otEXPECT_ACTION(((sState != OT_RADIO_STATE_TRANSMIT) && (sState != OT_RADIO_STATE_DISABLED)),
|
||||
status = OT_ERROR_INVALID_STATE);
|
||||
|
||||
if (rf_get_state() != XCVR_Idle_c)
|
||||
{
|
||||
@@ -455,7 +451,7 @@ otError otPlatRadioEnergyScan(otInstance *aInstance, uint8_t aScanChannel, uint1
|
||||
/* Unmask SEQ interrupt */
|
||||
ZLL->PHY_CTRL &= ~ZLL_PHY_CTRL_SEQMSK_MASK;
|
||||
/* Set Scan time-out */
|
||||
timeout = rf_get_timestamp();
|
||||
timeout = rf_get_timestamp();
|
||||
timeout += (aScanDuration * 1000) / OT_RADIO_SYMBOL_TIME;
|
||||
rf_set_timeout(timeout);
|
||||
|
||||
@@ -535,7 +531,7 @@ static void rf_set_channel(uint8_t channel)
|
||||
if (sChannel != channel)
|
||||
{
|
||||
ZLL->CHANNEL_NUM0 = channel;
|
||||
sChannel = channel;
|
||||
sChannel = channel;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -592,7 +588,7 @@ static uint16_t rf_get_addr_checksum(uint8_t *pAddr, bool ExtendedAddr, uint16_t
|
||||
uint16_t checksum;
|
||||
|
||||
/* Short address */
|
||||
checksum = PanId;
|
||||
checksum = PanId;
|
||||
checksum += *pAddr++;
|
||||
checksum += (uint16_t)(*pAddr++) << 8;
|
||||
|
||||
@@ -627,9 +623,9 @@ static otError rf_add_addr_table_entry(uint16_t checksum, bool extendedAddr)
|
||||
otEXPECT_ACTION((index < RADIO_CONFIG_SRC_MATCH_ENTRY_NUM), status = OT_ERROR_NO_BUFS);
|
||||
|
||||
/* Insert the checksum at the index found */
|
||||
ZLL->SAM_TABLE = ((uint32_t)index << ZLL_SAM_TABLE_SAM_INDEX_SHIFT) |
|
||||
((uint32_t)checksum << ZLL_SAM_TABLE_SAM_CHECKSUM_SHIFT) |
|
||||
ZLL_SAM_TABLE_SAM_INDEX_WR_MASK | ZLL_SAM_TABLE_SAM_INDEX_EN_MASK;
|
||||
ZLL->SAM_TABLE = ((uint32_t)index << ZLL_SAM_TABLE_SAM_INDEX_SHIFT) |
|
||||
((uint32_t)checksum << ZLL_SAM_TABLE_SAM_CHECKSUM_SHIFT) | ZLL_SAM_TABLE_SAM_INDEX_WR_MASK |
|
||||
ZLL_SAM_TABLE_SAM_INDEX_EN_MASK;
|
||||
|
||||
if (extendedAddr)
|
||||
{
|
||||
@@ -645,7 +641,7 @@ exit:
|
||||
|
||||
static otError rf_remove_addr_table_entry(uint16_t checksum)
|
||||
{
|
||||
otError status = OT_ERROR_NO_ADDRESS;
|
||||
otError status = OT_ERROR_NO_ADDRESS;
|
||||
uint32_t i, temp;
|
||||
|
||||
/* Search for an entry to match the provided checksum */
|
||||
@@ -673,8 +669,8 @@ static otError rf_remove_addr_table_entry_index(uint8_t index)
|
||||
otEXPECT_ACTION(index < RADIO_CONFIG_SRC_MATCH_ENTRY_NUM, status = OT_ERROR_NO_ADDRESS);
|
||||
|
||||
ZLL->SAM_TABLE = ((uint32_t)0xFFFF << ZLL_SAM_TABLE_SAM_CHECKSUM_SHIFT) |
|
||||
((uint32_t)index << ZLL_SAM_TABLE_SAM_INDEX_SHIFT) |
|
||||
ZLL_SAM_TABLE_SAM_INDEX_INV_MASK | ZLL_SAM_TABLE_SAM_INDEX_WR_MASK;
|
||||
((uint32_t)index << ZLL_SAM_TABLE_SAM_INDEX_SHIFT) | ZLL_SAM_TABLE_SAM_INDEX_INV_MASK |
|
||||
ZLL_SAM_TABLE_SAM_INDEX_WR_MASK;
|
||||
|
||||
/* Clear bitmap */
|
||||
/* Optimization: sExtSrcAddrBitmap[index / 8] &= ~(1 << (index % 8)); */
|
||||
@@ -719,7 +715,7 @@ static void rf_set_timeout(uint32_t abs_timeout)
|
||||
/* Set time-out value */
|
||||
ZLL->T3CMP = abs_timeout;
|
||||
/* Aknowledge and unmask TMR3 IRQ */
|
||||
irqSts = ZLL->IRQSTS & ZLL_IRQSTS_TMR_ALL_MSK_MASK;
|
||||
irqSts = ZLL->IRQSTS & ZLL_IRQSTS_TMR_ALL_MSK_MASK;
|
||||
irqSts &= ~ZLL_IRQSTS_TMR3MSK_MASK;
|
||||
irqSts |= ZLL_IRQSTS_TMR3IRQ_MASK;
|
||||
ZLL->IRQSTS = irqSts;
|
||||
@@ -730,7 +726,7 @@ static void rf_set_timeout(uint32_t abs_timeout)
|
||||
static bool rf_process_rx_frame(void)
|
||||
{
|
||||
uint8_t temp;
|
||||
bool status = true;
|
||||
bool status = true;
|
||||
|
||||
/* Get Rx length */
|
||||
temp = (ZLL->IRQSTS & ZLL_IRQSTS_RX_FRAME_LENGTH_MASK) >> ZLL_IRQSTS_RX_FRAME_LENGTH_SHIFT;
|
||||
@@ -741,13 +737,13 @@ static bool rf_process_rx_frame(void)
|
||||
#if OPENTHREAD_ENABLE_RAW_LINK_API
|
||||
// Timestamp
|
||||
sRxFrame.mMsec = otPlatAlarmMilliGetNow();
|
||||
sRxFrame.mUsec = 0; // Don't support microsecond timer for now.
|
||||
sRxFrame.mUsec = 0; // Don't support microsecond timer for now.
|
||||
#endif
|
||||
|
||||
sRxFrame.mLength = temp;
|
||||
temp = (ZLL->LQI_AND_RSSI & ZLL_LQI_AND_RSSI_LQI_VALUE_MASK) >> ZLL_LQI_AND_RSSI_LQI_VALUE_SHIFT;
|
||||
sRxFrame.mLqi = rf_lqi_adjust(temp);
|
||||
sRxFrame.mRssi = rf_lqi_to_rssi(sRxFrame.mLqi);
|
||||
temp = (ZLL->LQI_AND_RSSI & ZLL_LQI_AND_RSSI_LQI_VALUE_MASK) >> ZLL_LQI_AND_RSSI_LQI_VALUE_SHIFT;
|
||||
sRxFrame.mLqi = rf_lqi_adjust(temp);
|
||||
sRxFrame.mRssi = rf_lqi_to_rssi(sRxFrame.mLqi);
|
||||
#if DOUBLE_BUFFERING
|
||||
|
||||
for (temp = 0; temp < sRxFrame.mLength - 2; temp++)
|
||||
@@ -763,9 +759,9 @@ exit:
|
||||
|
||||
void Radio_1_IRQHandler(void)
|
||||
{
|
||||
xcvr_state_t state = rf_get_state();
|
||||
uint32_t irqStatus = ZLL->IRQSTS;
|
||||
int8_t temp;
|
||||
xcvr_state_t state = rf_get_state();
|
||||
uint32_t irqStatus = ZLL->IRQSTS;
|
||||
int8_t temp;
|
||||
|
||||
ZLL->IRQSTS = irqStatus;
|
||||
|
||||
@@ -784,9 +780,9 @@ void Radio_1_IRQHandler(void)
|
||||
else if ((state == XCVR_TR_c) && !(irqStatus & ZLL_IRQSTS_RXIRQ_MASK))
|
||||
{
|
||||
rf_abort();
|
||||
sState = OT_RADIO_STATE_RECEIVE;
|
||||
sState = OT_RADIO_STATE_RECEIVE;
|
||||
sTxStatus = OT_ERROR_NO_ACK;
|
||||
sTxDone = true;
|
||||
sTxDone = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -808,16 +804,16 @@ void Radio_1_IRQHandler(void)
|
||||
{
|
||||
sTxStatus = OT_ERROR_CHANNEL_ACCESS_FAILURE;
|
||||
}
|
||||
else if (!(irqStatus & ZLL_IRQSTS_RXIRQ_MASK) ||
|
||||
(rf_process_rx_frame() == false) ||
|
||||
else if (!(irqStatus & ZLL_IRQSTS_RXIRQ_MASK) || (rf_process_rx_frame() == false) ||
|
||||
(sRxFrame.mLength != IEEE802154_ACK_LENGTH) ||
|
||||
((sRxFrame.mPsdu[IEEE802154_FRM_CTL_LO_OFFSET] & IEEE802154_FRM_TYPE_MASK) != IEEE802154_FRM_TYPE_ACK) ||
|
||||
((sRxFrame.mPsdu[IEEE802154_FRM_CTL_LO_OFFSET] & IEEE802154_FRM_TYPE_MASK) !=
|
||||
IEEE802154_FRM_TYPE_ACK) ||
|
||||
(sRxFrame.mPsdu[IEEE802154_DSN_OFFSET] != sTxFrame.mPsdu[IEEE802154_DSN_OFFSET]))
|
||||
{
|
||||
sTxStatus = OT_ERROR_NO_ACK;
|
||||
}
|
||||
|
||||
sState = OT_RADIO_STATE_RECEIVE;
|
||||
sState = OT_RADIO_STATE_RECEIVE;
|
||||
sTxDone = true;
|
||||
break;
|
||||
|
||||
@@ -827,7 +823,7 @@ void Radio_1_IRQHandler(void)
|
||||
sTxStatus = OT_ERROR_CHANNEL_ACCESS_FAILURE;
|
||||
}
|
||||
|
||||
sState = OT_RADIO_STATE_RECEIVE;
|
||||
sState = OT_RADIO_STATE_RECEIVE;
|
||||
sTxDone = true;
|
||||
break;
|
||||
|
||||
@@ -842,7 +838,9 @@ void Radio_1_IRQHandler(void)
|
||||
if (!sEdScanDone)
|
||||
{
|
||||
/* Restart ED */
|
||||
while (ZLL->SEQ_STATE & ZLL_SEQ_STATE_SEQ_STATE_MASK) {}
|
||||
while (ZLL->SEQ_STATE & ZLL_SEQ_STATE_SEQ_STATE_MASK)
|
||||
{
|
||||
}
|
||||
|
||||
ZLL->IRQSTS = (ZLL->IRQSTS & ZLL_IRQSTS_TMR_ALL_MSK_MASK) | ZLL_IRQSTS_SEQIRQ_MASK;
|
||||
ZLL->PHY_CTRL |= XCVR_CCA_c;
|
||||
@@ -860,7 +858,9 @@ void Radio_1_IRQHandler(void)
|
||||
if ((sState == OT_RADIO_STATE_RECEIVE) && (rf_get_state() == XCVR_Idle_c))
|
||||
{
|
||||
/* Restart RX */
|
||||
while (ZLL->SEQ_STATE & ZLL_SEQ_STATE_SEQ_STATE_MASK) {}
|
||||
while (ZLL->SEQ_STATE & ZLL_SEQ_STATE_SEQ_STATE_MASK)
|
||||
{
|
||||
}
|
||||
|
||||
ZLL->IRQSTS = ZLL->IRQSTS;
|
||||
ZLL->PHY_CTRL |= XCVR_RX_c;
|
||||
@@ -874,18 +874,18 @@ void kw41zRadioInit(void)
|
||||
|
||||
/* Disable all timers, enable AUTOACK and CCA before TX, mask all interrupts */
|
||||
ZLL->PHY_CTRL = ZLL_PHY_CTRL_CCATYPE(DEFAULT_CCA_MODE) | //
|
||||
ZLL_PHY_CTRL_CCABFRTX_MASK | //
|
||||
ZLL_PHY_CTRL_TSM_MSK_MASK | //
|
||||
ZLL_PHY_CTRL_WAKE_MSK_MASK | //
|
||||
ZLL_PHY_CTRL_CRC_MSK_MASK | //
|
||||
ZLL_PHY_CTRL_PLL_UNLOCK_MSK_MASK | //
|
||||
ZLL_PHY_CTRL_FILTERFAIL_MSK_MASK | //
|
||||
ZLL_PHY_CTRL_RX_WMRK_MSK_MASK | //
|
||||
ZLL_PHY_CTRL_CCAMSK_MASK | //
|
||||
ZLL_PHY_CTRL_RXMSK_MASK | //
|
||||
ZLL_PHY_CTRL_TXMSK_MASK | //
|
||||
ZLL_PHY_CTRL_SEQMSK_MASK | //
|
||||
ZLL_PHY_CTRL_AUTOACK_MASK | //
|
||||
ZLL_PHY_CTRL_CCABFRTX_MASK | //
|
||||
ZLL_PHY_CTRL_TSM_MSK_MASK | //
|
||||
ZLL_PHY_CTRL_WAKE_MSK_MASK | //
|
||||
ZLL_PHY_CTRL_CRC_MSK_MASK | //
|
||||
ZLL_PHY_CTRL_PLL_UNLOCK_MSK_MASK | //
|
||||
ZLL_PHY_CTRL_FILTERFAIL_MSK_MASK | //
|
||||
ZLL_PHY_CTRL_RX_WMRK_MSK_MASK | //
|
||||
ZLL_PHY_CTRL_CCAMSK_MASK | //
|
||||
ZLL_PHY_CTRL_RXMSK_MASK | //
|
||||
ZLL_PHY_CTRL_TXMSK_MASK | //
|
||||
ZLL_PHY_CTRL_SEQMSK_MASK | //
|
||||
ZLL_PHY_CTRL_AUTOACK_MASK | //
|
||||
ZLL_PHY_CTRL_TRCV_MSK_MASK;
|
||||
|
||||
/* Clear all IRQ flags and disable all timer interrupts */
|
||||
@@ -895,9 +895,9 @@ void kw41zRadioInit(void)
|
||||
FRM_VER[7:6] = b11. Accept FrameVersion 0 and 1 packets, reject all others */
|
||||
ZLL->RX_FRAME_FILTER &= ~ZLL_RX_FRAME_FILTER_FRM_VER_FILTER_MASK;
|
||||
ZLL->RX_FRAME_FILTER = ZLL_RX_FRAME_FILTER_FRM_VER_FILTER(3) | //
|
||||
ZLL_RX_FRAME_FILTER_CMD_FT_MASK | //
|
||||
ZLL_RX_FRAME_FILTER_DATA_FT_MASK | //
|
||||
ZLL_RX_FRAME_FILTER_ACK_FT_MASK | //
|
||||
ZLL_RX_FRAME_FILTER_CMD_FT_MASK | //
|
||||
ZLL_RX_FRAME_FILTER_DATA_FT_MASK | //
|
||||
ZLL_RX_FRAME_FILTER_ACK_FT_MASK | //
|
||||
ZLL_RX_FRAME_FILTER_BEACON_FT_MASK;
|
||||
|
||||
/* Set prescaller to obtain 1 symbol (16us) timebase */
|
||||
@@ -922,7 +922,7 @@ void kw41zRadioInit(void)
|
||||
rf_set_tx_power(0);
|
||||
|
||||
sTxFrame.mLength = 0;
|
||||
sTxFrame.mPsdu = (uint8_t *)ZLL->PKT_BUFFER_TX + 1;
|
||||
sTxFrame.mPsdu = (uint8_t *)ZLL->PKT_BUFFER_TX + 1;
|
||||
sRxFrame.mLength = 0;
|
||||
#if DOUBLE_BUFFERING
|
||||
sRxFrame.mPsdu = sRxData;
|
||||
|
||||
@@ -32,24 +32,24 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include "openthread/platform/random.h"
|
||||
#include "fsl_device_registers.h"
|
||||
#include "fsl_trng.h"
|
||||
#include "openthread/types.h"
|
||||
#include "openthread/platform/random.h"
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <utils/code_utils.h>
|
||||
#include "openthread/types.h"
|
||||
|
||||
void kw41zRandomInit(void)
|
||||
{
|
||||
trng_config_t config;
|
||||
uint32_t seed;
|
||||
uint32_t seed;
|
||||
|
||||
TRNG_GetDefaultConfig(&config);
|
||||
config.frequencyCountLimit.minimum = 0x00000100;
|
||||
config.frequencyCountLimit.maximum = 0x000F0000;
|
||||
config.ringOscDiv = kTRNG_RingOscDiv0;
|
||||
config.entropyDelay = 1200;
|
||||
config.ringOscDiv = kTRNG_RingOscDiv0;
|
||||
config.entropyDelay = 1200;
|
||||
|
||||
otEXPECT(TRNG_Init(TRNG0, &config) == kStatus_Success);
|
||||
|
||||
|
||||
@@ -32,18 +32,17 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "fsl_device_registers.h"
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <utils/code_utils.h>
|
||||
#include "openthread/types.h"
|
||||
#include "openthread/platform/uart.h"
|
||||
#include "openthread/types.h"
|
||||
|
||||
#include "fsl_clock.h"
|
||||
#include "fsl_port.h"
|
||||
#include "fsl_lpuart.h"
|
||||
#include "fsl_port.h"
|
||||
|
||||
enum
|
||||
{
|
||||
@@ -62,7 +61,7 @@ static bool sTransmitDone = false;
|
||||
typedef struct RecvBuffer
|
||||
{
|
||||
// The data buffer
|
||||
uint8_t mBuffer[kReceiveBufferSize];
|
||||
uint8_t mBuffer[kReceiveBufferSize];
|
||||
// The offset of the first item written to the list.
|
||||
uint16_t mHead;
|
||||
// The offset of the next item to be written to the list.
|
||||
@@ -87,8 +86,8 @@ otError otPlatUartEnable(void)
|
||||
CLOCK_SetLpuartClock(2);
|
||||
|
||||
LPUART_GetDefaultConfig(&config);
|
||||
config.enableRx = 1;
|
||||
config.enableTx = 1;
|
||||
config.enableRx = 1;
|
||||
config.enableTx = 1;
|
||||
config.baudRate_Bps = kBaudRate;
|
||||
LPUART_Init(LPUART0, &config, kPlatformClock);
|
||||
LPUART_EnableInterrupts(LPUART0, kLPUART_RxDataRegFullInterruptEnable);
|
||||
@@ -113,7 +112,7 @@ otError otPlatUartSend(const uint8_t *aBuf, uint16_t aBufLength)
|
||||
|
||||
sTransmitBuffer = aBuf + 1;
|
||||
sTransmitLength = aBufLength - 1;
|
||||
sTransmitDone = false;
|
||||
sTransmitDone = false;
|
||||
LPUART_WriteByte(LPUART0, *aBuf);
|
||||
LPUART_ClearStatusFlags(LPUART0, kLPUART_TxDataRegEmptyFlag);
|
||||
LPUART_EnableInterrupts(LPUART0, kLPUART_TxDataRegEmptyInterruptEnable);
|
||||
@@ -126,7 +125,7 @@ static void processTransmit(void)
|
||||
{
|
||||
if (sTransmitBuffer && sTransmitDone)
|
||||
{
|
||||
sTransmitDone = false;
|
||||
sTransmitDone = false;
|
||||
sTransmitBuffer = NULL;
|
||||
otPlatUartSendDone();
|
||||
}
|
||||
@@ -165,7 +164,7 @@ static void processReceive(void)
|
||||
void LPUART0_IRQHandler(void)
|
||||
{
|
||||
uint32_t interrupts = LPUART_GetEnabledInterrupts(LPUART0);
|
||||
uint8_t rx_data;
|
||||
uint8_t rx_data;
|
||||
|
||||
/* Check if data was received */
|
||||
while (LPUART_GetStatusFlags(LPUART0) & (kLPUART_RxDataRegFullFlag))
|
||||
@@ -176,7 +175,7 @@ void LPUART0_IRQHandler(void)
|
||||
if (sReceive.mHead != (sReceive.mTail + 1) % kReceiveBufferSize)
|
||||
{
|
||||
sReceive.mBuffer[sReceive.mTail] = rx_data;
|
||||
sReceive.mTail = (sReceive.mTail + 1) % kReceiveBufferSize;
|
||||
sReceive.mTail = (sReceive.mTail + 1) % kReceiveBufferSize;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,8 +32,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <openthread/config.h>
|
||||
#include <openthread-core-config.h>
|
||||
#include <openthread/config.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdbool.h>
|
||||
@@ -67,17 +67,12 @@
|
||||
#define MS_PER_OVERFLOW (512UL * MS_PER_S) ///< Time that has passed between overflow events. On full RTC speed, it occurs every 512 s.
|
||||
// clang-format on
|
||||
|
||||
typedef enum
|
||||
{
|
||||
kMsTimer,
|
||||
kUsTimer,
|
||||
kNumTimers
|
||||
} AlarmIndex;
|
||||
typedef enum { kMsTimer, kUsTimer, kNumTimers } AlarmIndex;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
volatile bool mFireAlarm; ///< Information for processing function, that alarm should fire.
|
||||
uint64_t mTargetTime; ///< Alarm fire time (in millisecond for MsTimer, in microsecond for UsTimer)
|
||||
volatile bool mFireAlarm; ///< Information for processing function, that alarm should fire.
|
||||
uint64_t mTargetTime; ///< Alarm fire time (in millisecond for MsTimer, in microsecond for UsTimer)
|
||||
} AlarmData;
|
||||
|
||||
typedef struct
|
||||
@@ -88,23 +83,23 @@ typedef struct
|
||||
nrf_rtc_int_t mCompareInt;
|
||||
} AlarmChannelData;
|
||||
|
||||
static volatile uint64_t sTimeOffset = 0; ///< Time offset to keep track of current time (in millisecond).
|
||||
static AlarmData sTimerData[kNumTimers]; ///< Data of the timers.
|
||||
static volatile uint64_t sTimeOffset = 0; ///< Time offset to keep track of current time (in millisecond).
|
||||
static AlarmData sTimerData[kNumTimers]; ///< Data of the timers.
|
||||
static const AlarmChannelData sChannelData[kNumTimers] = //
|
||||
{ //
|
||||
[kMsTimer] = {
|
||||
.mChannelNumber = 0,
|
||||
.mCompareEventMask = RTC_EVTEN_COMPARE0_Msk,
|
||||
.mCompareEvent = NRF_RTC_EVENT_COMPARE_0,
|
||||
.mCompareInt = NRF_RTC_INT_COMPARE0_MASK,
|
||||
},
|
||||
[kUsTimer] = {
|
||||
.mChannelNumber = 1,
|
||||
.mCompareEventMask = RTC_EVTEN_COMPARE1_Msk,
|
||||
.mCompareEvent = NRF_RTC_EVENT_COMPARE_1,
|
||||
.mCompareInt = NRF_RTC_INT_COMPARE1_MASK,
|
||||
}
|
||||
};
|
||||
{ //
|
||||
[kMsTimer] =
|
||||
{
|
||||
.mChannelNumber = 0,
|
||||
.mCompareEventMask = RTC_EVTEN_COMPARE0_Msk,
|
||||
.mCompareEvent = NRF_RTC_EVENT_COMPARE_0,
|
||||
.mCompareInt = NRF_RTC_INT_COMPARE0_MASK,
|
||||
},
|
||||
[kUsTimer] = {
|
||||
.mChannelNumber = 1,
|
||||
.mCompareEventMask = RTC_EVTEN_COMPARE1_Msk,
|
||||
.mCompareEvent = NRF_RTC_EVENT_COMPARE_1,
|
||||
.mCompareInt = NRF_RTC_INT_COMPARE1_MASK,
|
||||
}};
|
||||
|
||||
static void HandleOverflow(void);
|
||||
|
||||
@@ -118,7 +113,7 @@ static inline uint32_t TimeToTicks(uint64_t aTime, AlarmIndex aIndex)
|
||||
}
|
||||
else
|
||||
{
|
||||
ticks = (uint32_t)CEIL_DIV((aTime * RTC_FREQUENCY), US_PER_S) & RTC_CC_COMPARE_Msk;
|
||||
ticks = (uint32_t)CEIL_DIV((aTime * RTC_FREQUENCY), US_PER_S) & RTC_CC_COMPARE_Msk;
|
||||
}
|
||||
|
||||
return ticks;
|
||||
@@ -244,7 +239,9 @@ void nrf5AlarmInit(void)
|
||||
// Setup low frequency clock.
|
||||
nrf_drv_clock_lfclk_request(NULL);
|
||||
|
||||
while (!nrf_drv_clock_lfclk_is_running()) {}
|
||||
while (!nrf_drv_clock_lfclk_is_running())
|
||||
{
|
||||
}
|
||||
|
||||
// Setup RTC timer.
|
||||
NVIC_SetPriority(RTC_IRQN, RTC_IRQ_PRIORITY);
|
||||
|
||||
@@ -26,14 +26,14 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <openthread/config.h>
|
||||
#include <openthread-core-config.h>
|
||||
#include <openthread/config.h>
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "platform-nrf5.h"
|
||||
|
||||
@@ -46,15 +46,10 @@
|
||||
#include <openthread/platform/toolchain.h>
|
||||
|
||||
#include <common/logging.hpp>
|
||||
#include <utils/code_utils.h>
|
||||
#include <drivers/radio/nrf_drv_radio802154.h>
|
||||
#include <utils/code_utils.h>
|
||||
|
||||
typedef enum
|
||||
{
|
||||
kDiagTransmitModeIdle,
|
||||
kDiagTransmitModePackets,
|
||||
kDiagTransmitModeCarrier
|
||||
} DiagTrasmitMode;
|
||||
typedef enum { kDiagTransmitModeIdle, kDiagTransmitModePackets, kDiagTransmitModeCarrier } DiagTrasmitMode;
|
||||
|
||||
struct PlatformDiagCommand
|
||||
{
|
||||
@@ -65,25 +60,28 @@ struct PlatformDiagCommand
|
||||
struct PlatformDiagMessage
|
||||
{
|
||||
const char mMessageDescriptor[11];
|
||||
uint8_t mChannel;
|
||||
int16_t mID;
|
||||
uint32_t mCnt;
|
||||
uint8_t mChannel;
|
||||
int16_t mID;
|
||||
uint32_t mCnt;
|
||||
};
|
||||
|
||||
/**
|
||||
* Diagnostics mode variables.
|
||||
*
|
||||
*/
|
||||
static bool sDiagMode = false;
|
||||
static bool sListen = false;
|
||||
static DiagTrasmitMode sTransmitMode = kDiagTransmitModeIdle;
|
||||
static uint8_t sChannel = 20;
|
||||
static int8_t sTxPower = 0;
|
||||
static uint32_t sTxPeriod = 1;
|
||||
static int32_t sTxCount = 0;
|
||||
static int32_t sTxRequestedCount = 1;
|
||||
static int16_t sID = -1;
|
||||
static struct PlatformDiagMessage sDiagMessage = {.mMessageDescriptor = "DiagMessage", .mChannel = 0, .mID = 0, .mCnt = 0};
|
||||
static bool sDiagMode = false;
|
||||
static bool sListen = false;
|
||||
static DiagTrasmitMode sTransmitMode = kDiagTransmitModeIdle;
|
||||
static uint8_t sChannel = 20;
|
||||
static int8_t sTxPower = 0;
|
||||
static uint32_t sTxPeriod = 1;
|
||||
static int32_t sTxCount = 0;
|
||||
static int32_t sTxRequestedCount = 1;
|
||||
static int16_t sID = -1;
|
||||
static struct PlatformDiagMessage sDiagMessage = {.mMessageDescriptor = "DiagMessage",
|
||||
.mChannel = 0,
|
||||
.mID = 0,
|
||||
.mCnt = 0};
|
||||
|
||||
static otError parseLong(char *argv, long *aValue)
|
||||
{
|
||||
@@ -110,7 +108,7 @@ static bool startCarrierTransmision(void)
|
||||
|
||||
static void processListen(otInstance *aInstance, int argc, char *argv[], char *aOutput, size_t aOutputMaxLen)
|
||||
{
|
||||
(void) aInstance;
|
||||
(void)aInstance;
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
otEXPECT_ACTION(otPlatDiagModeGet(), error = OT_ERROR_INVALID_STATE);
|
||||
@@ -126,7 +124,8 @@ static void processListen(otInstance *aInstance, int argc, char *argv[], char *a
|
||||
error = parseLong(argv[0], &value);
|
||||
otEXPECT(error == OT_ERROR_NONE);
|
||||
sListen = (bool)(value);
|
||||
snprintf(aOutput, aOutputMaxLen, "set listen to %s\r\nstatus 0x%02x\r\n", sListen == true ? "yes" : "no", error);
|
||||
snprintf(aOutput, aOutputMaxLen, "set listen to %s\r\nstatus 0x%02x\r\n", sListen == true ? "yes" : "no",
|
||||
error);
|
||||
}
|
||||
|
||||
exit:
|
||||
@@ -135,7 +134,7 @@ exit:
|
||||
|
||||
static void processID(otInstance *aInstance, int argc, char *argv[], char *aOutput, size_t aOutputMaxLen)
|
||||
{
|
||||
(void) aInstance;
|
||||
(void)aInstance;
|
||||
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
@@ -160,8 +159,7 @@ exit:
|
||||
appendErrorResult(error, aOutput, aOutputMaxLen);
|
||||
}
|
||||
|
||||
static void processTransmit(otInstance *aInstance, int argc, char *argv[], char *aOutput,
|
||||
size_t aOutputMaxLen)
|
||||
static void processTransmit(otInstance *aInstance, int argc, char *argv[], char *aOutput, size_t aOutputMaxLen)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
@@ -169,8 +167,8 @@ static void processTransmit(otInstance *aInstance, int argc, char *argv[], char
|
||||
|
||||
if (argc == 0)
|
||||
{
|
||||
snprintf(aOutput, aOutputMaxLen, "transmit will send %" PRId32 " diagnostic messages with %" PRIu32
|
||||
" ms interval\r\nstatus 0x%02x\r\n",
|
||||
snprintf(aOutput, aOutputMaxLen,
|
||||
"transmit will send %" PRId32 " diagnostic messages with %" PRIu32 " ms interval\r\nstatus 0x%02x\r\n",
|
||||
sTxRequestedCount, sTxPeriod, error);
|
||||
}
|
||||
else if (strcmp(argv[0], "stop") == 0)
|
||||
@@ -188,11 +186,11 @@ static void processTransmit(otInstance *aInstance, int argc, char *argv[], char
|
||||
|
||||
otPlatAlarmMilliStop(aInstance);
|
||||
sTransmitMode = kDiagTransmitModePackets;
|
||||
sTxCount = sTxRequestedCount;
|
||||
uint32_t now = otPlatAlarmMilliGetNow();
|
||||
sTxCount = sTxRequestedCount;
|
||||
uint32_t now = otPlatAlarmMilliGetNow();
|
||||
otPlatAlarmMilliStartAt(aInstance, now, sTxPeriod);
|
||||
snprintf(aOutput, aOutputMaxLen, "sending %" PRId32 " diagnostic messages with %" PRIu32
|
||||
" ms interval\r\nstatus 0x%02x\r\n",
|
||||
snprintf(aOutput, aOutputMaxLen,
|
||||
"sending %" PRId32 " diagnostic messages with %" PRIu32 " ms interval\r\nstatus 0x%02x\r\n",
|
||||
sTxRequestedCount, sTxPeriod, error);
|
||||
}
|
||||
else if (strcmp(argv[0], "carrier") == 0)
|
||||
@@ -216,8 +214,8 @@ static void processTransmit(otInstance *aInstance, int argc, char *argv[], char
|
||||
otEXPECT(error == OT_ERROR_NONE);
|
||||
otEXPECT_ACTION(value > 0, error = OT_ERROR_INVALID_ARGS);
|
||||
sTxPeriod = (uint32_t)(value);
|
||||
snprintf(aOutput, aOutputMaxLen, "set diagnostic messages interval to %" PRIu32 " ms\r\nstatus 0x%02x\r\n", sTxPeriod,
|
||||
error);
|
||||
snprintf(aOutput, aOutputMaxLen, "set diagnostic messages interval to %" PRIu32 " ms\r\nstatus 0x%02x\r\n",
|
||||
sTxPeriod, error);
|
||||
}
|
||||
else if (strcmp(argv[0], "count") == 0)
|
||||
{
|
||||
@@ -229,8 +227,8 @@ static void processTransmit(otInstance *aInstance, int argc, char *argv[], char
|
||||
otEXPECT(error == OT_ERROR_NONE);
|
||||
otEXPECT_ACTION((value > 0) || (value == -1), error = OT_ERROR_INVALID_ARGS);
|
||||
sTxRequestedCount = (uint32_t)(value);
|
||||
snprintf(aOutput, aOutputMaxLen, "set diagnostic messages count to %" PRId32 "\r\nstatus 0x%02x\r\n", sTxRequestedCount,
|
||||
error);
|
||||
snprintf(aOutput, aOutputMaxLen, "set diagnostic messages count to %" PRId32 "\r\nstatus 0x%02x\r\n",
|
||||
sTxRequestedCount, error);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -241,12 +239,11 @@ exit:
|
||||
appendErrorResult(error, aOutput, aOutputMaxLen);
|
||||
}
|
||||
|
||||
static void processGpio(otInstance *aInstance, int argc, char *argv[],
|
||||
char *aOutput, size_t aOutputMaxLen)
|
||||
static void processGpio(otInstance *aInstance, int argc, char *argv[], char *aOutput, size_t aOutputMaxLen)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
|
||||
long pinnum;
|
||||
long pinnum;
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
otEXPECT_ACTION(otPlatDiagModeGet(), error = OT_ERROR_INVALID_STATE);
|
||||
@@ -260,8 +257,7 @@ static void processGpio(otInstance *aInstance, int argc, char *argv[],
|
||||
|
||||
value = nrf_gpio_pin_read(pinnum);
|
||||
|
||||
snprintf(aOutput, aOutputMaxLen, "gpio %d = %d\r\n",
|
||||
(uint8_t)pinnum, (uint8_t)value);
|
||||
snprintf(aOutput, aOutputMaxLen, "gpio %d = %d\r\n", (uint8_t)pinnum, (uint8_t)value);
|
||||
}
|
||||
else if (strcmp(argv[0], "set") == 0)
|
||||
{
|
||||
@@ -301,8 +297,7 @@ static void processGpio(otInstance *aInstance, int argc, char *argv[],
|
||||
|
||||
nrf_gpio_cfg_input(pinnum, NRF_GPIO_PIN_NOPULL);
|
||||
|
||||
snprintf(aOutput, aOutputMaxLen, "gpio %d: in no pull\r\n",
|
||||
(uint8_t)pinnum);
|
||||
snprintf(aOutput, aOutputMaxLen, "gpio %d: in no pull\r\n", (uint8_t)pinnum);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -313,7 +308,6 @@ exit:
|
||||
appendErrorResult(error, aOutput, aOutputMaxLen);
|
||||
}
|
||||
|
||||
|
||||
static void processTemp(otInstance *aInstance, int argc, char *argv[], char *aOutput, size_t aOutputMaxLen)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
@@ -337,7 +331,7 @@ exit:
|
||||
|
||||
static void processCcaThreshold(otInstance *aInstance, int argc, char *argv[], char *aOutput, size_t aOutputMaxLen)
|
||||
{
|
||||
(void) aInstance;
|
||||
(void)aInstance;
|
||||
|
||||
otError error = OT_ERROR_NONE;
|
||||
nrf_drv_radio802154_cca_cfg_t ccaConfig;
|
||||
@@ -362,22 +356,20 @@ static void processCcaThreshold(otInstance *aInstance, int argc, char *argv[], c
|
||||
ccaConfig.ed_threshold = (uint8_t)value;
|
||||
|
||||
nrf_drv_radio802154_cca_cfg_set(&ccaConfig);
|
||||
snprintf(aOutput, aOutputMaxLen, "set cca threshold to %u\r\nstatus 0x%02x\r\n",
|
||||
ccaConfig.ed_threshold, error);
|
||||
snprintf(aOutput, aOutputMaxLen, "set cca threshold to %u\r\nstatus 0x%02x\r\n", ccaConfig.ed_threshold, error);
|
||||
}
|
||||
|
||||
exit:
|
||||
appendErrorResult(error, aOutput, aOutputMaxLen);
|
||||
}
|
||||
|
||||
const struct PlatformDiagCommand sCommands[] =
|
||||
{
|
||||
{ "ccathreshold", &processCcaThreshold },
|
||||
{ "gpio", &processGpio },
|
||||
{ "id", &processID },
|
||||
{ "listen", &processListen },
|
||||
{ "temp", &processTemp },
|
||||
{ "transmit", &processTransmit },
|
||||
const struct PlatformDiagCommand sCommands[] = {
|
||||
{"ccathreshold", &processCcaThreshold},
|
||||
{"gpio", &processGpio},
|
||||
{"id", &processID},
|
||||
{"listen", &processListen},
|
||||
{"temp", &processTemp},
|
||||
{"transmit", &processTransmit},
|
||||
};
|
||||
|
||||
void otPlatDiagProcess(otInstance *aInstance, int argc, char *argv[], char *aOutput, size_t aOutputMaxLen)
|
||||
@@ -432,7 +424,7 @@ void otPlatDiagTxPowerSet(int8_t aTxPower)
|
||||
|
||||
void otPlatDiagRadioReceived(otInstance *aInstance, otRadioFrame *aFrame, otError aError)
|
||||
{
|
||||
(void) aInstance;
|
||||
(void)aInstance;
|
||||
|
||||
if (sListen && (aError == OT_ERROR_NONE))
|
||||
{
|
||||
@@ -451,13 +443,7 @@ void otPlatDiagRadioReceived(otInstance *aInstance, otRadioFrame *aFrame, otErro
|
||||
"\"RemoteID\":%" PRId16 ","
|
||||
"\"RSSI\":%d"
|
||||
"}}\r\n",
|
||||
aFrame->mChannel,
|
||||
message->mChannel,
|
||||
message->mCnt,
|
||||
sID,
|
||||
message->mID,
|
||||
aFrame->mRssi
|
||||
);
|
||||
aFrame->mChannel, message->mChannel, message->mCnt, sID, message->mID, aFrame->mRssi);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -465,18 +451,17 @@ void otPlatDiagRadioReceived(otInstance *aInstance, otRadioFrame *aFrame, otErro
|
||||
|
||||
void otPlatDiagAlarmCallback(otInstance *aInstance)
|
||||
{
|
||||
|
||||
if (sTransmitMode == kDiagTransmitModePackets)
|
||||
{
|
||||
if ((sTxCount > 0) || (sTxCount == -1))
|
||||
{
|
||||
otRadioFrame *sTxPacket = otPlatRadioGetTransmitBuffer(aInstance);
|
||||
|
||||
sTxPacket->mLength = sizeof(struct PlatformDiagMessage);
|
||||
sTxPacket->mLength = sizeof(struct PlatformDiagMessage);
|
||||
sTxPacket->mChannel = sChannel;
|
||||
|
||||
sDiagMessage.mChannel = sTxPacket->mChannel;
|
||||
sDiagMessage.mID = sID;
|
||||
sDiagMessage.mID = sID;
|
||||
|
||||
memcpy(sTxPacket->mPsdu, &sDiagMessage, sizeof(struct PlatformDiagMessage));
|
||||
otPlatRadioTransmit(aInstance, sTxPacket);
|
||||
|
||||
@@ -32,8 +32,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <openthread/config.h>
|
||||
#include <openthread-core-config.h>
|
||||
#include <openthread/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -26,22 +26,22 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <openthread/config.h>
|
||||
#include <openthread-core-config.h>
|
||||
#include <openthread/config.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <utils/code_utils.h>
|
||||
#include <utils/flash.h>
|
||||
#include <openthread/types.h>
|
||||
#include <openthread/platform/alarm-milli.h>
|
||||
#include <utils/flash.h>
|
||||
#include <utils/code_utils.h>
|
||||
|
||||
#include "platform-nrf5.h"
|
||||
|
||||
#define FLASH_PAGE_ADDR_MASK 0xFFFFF000
|
||||
#define FLASH_PAGE_SIZE 4096
|
||||
#define FLASH_PAGE_SIZE 4096
|
||||
|
||||
static uint32_t sFlashDataStart;
|
||||
static uint32_t sFlashDataEnd;
|
||||
@@ -124,8 +124,7 @@ otError utilsFlashStatusWait(uint32_t aTimeout)
|
||||
error = OT_ERROR_NONE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (otPlatAlarmMilliGetNow() - startTime < aTimeout);
|
||||
} while (otPlatAlarmMilliGetNow() - startTime < aTimeout);
|
||||
}
|
||||
|
||||
return error;
|
||||
|
||||
@@ -32,15 +32,15 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <openthread/config.h>
|
||||
#include <openthread-core-config.h>
|
||||
#include <openthread/config.h>
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <openthread/platform/logging.h>
|
||||
#include <openthread/platform/alarm-milli.h>
|
||||
#include <utils/code_utils.h>
|
||||
#include <openthread/platform/alarm-milli.h>
|
||||
#include <openthread/platform/logging.h>
|
||||
|
||||
#include "platform-nrf5.h"
|
||||
|
||||
@@ -53,19 +53,19 @@
|
||||
|
||||
#if (LOG_RTT_COLOR_ENABLE == 1)
|
||||
#define RTT_COLOR_CODE_DEFAULT "\x1B[0m"
|
||||
#define RTT_COLOR_CODE_RED "\x1B[1;31m"
|
||||
#define RTT_COLOR_CODE_GREEN "\x1B[1;32m"
|
||||
#define RTT_COLOR_CODE_YELLOW "\x1B[1;33m"
|
||||
#define RTT_COLOR_CODE_CYAN "\x1B[1;36m"
|
||||
#define RTT_COLOR_CODE_RED "\x1B[1;31m"
|
||||
#define RTT_COLOR_CODE_GREEN "\x1B[1;32m"
|
||||
#define RTT_COLOR_CODE_YELLOW "\x1B[1;33m"
|
||||
#define RTT_COLOR_CODE_CYAN "\x1B[1;36m"
|
||||
#else // LOG_RTT_COLOR_ENABLE == 1
|
||||
#define RTT_COLOR_CODE_DEFAULT ""
|
||||
#define RTT_COLOR_CODE_RED ""
|
||||
#define RTT_COLOR_CODE_GREEN ""
|
||||
#define RTT_COLOR_CODE_YELLOW ""
|
||||
#define RTT_COLOR_CODE_CYAN ""
|
||||
#define RTT_COLOR_CODE_RED ""
|
||||
#define RTT_COLOR_CODE_GREEN ""
|
||||
#define RTT_COLOR_CODE_YELLOW ""
|
||||
#define RTT_COLOR_CODE_CYAN ""
|
||||
#endif // LOG_RTT_COLOR_ENABLE == 1
|
||||
|
||||
static bool sLogInitialized = false;
|
||||
static bool sLogInitialized = false;
|
||||
static uint8_t sLogBuffer[LOG_RTT_BUFFER_SIZE];
|
||||
|
||||
/**
|
||||
@@ -105,8 +105,7 @@ static inline const char *levelToString(otLogLevel aLogLevel)
|
||||
*/
|
||||
static inline uint16_t logTimestamp(char *aLogString, uint16_t aMaxSize)
|
||||
{
|
||||
return snprintf(aLogString, aMaxSize, "%s[%010ld]", RTT_COLOR_CODE_CYAN,
|
||||
otPlatAlarmMilliGetNow());
|
||||
return snprintf(aLogString, aMaxSize, "%s[%010ld]", RTT_COLOR_CODE_CYAN, otPlatAlarmMilliGetNow());
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -119,17 +118,14 @@ static inline uint16_t logTimestamp(char *aLogString, uint16_t aMaxSize)
|
||||
*
|
||||
* @returns Number of bytes successfully written to the log buffer.
|
||||
*/
|
||||
static inline uint16_t logLevel(char *aLogString, uint16_t aMaxSize,
|
||||
otLogLevel aLogLevel)
|
||||
static inline uint16_t logLevel(char *aLogString, uint16_t aMaxSize, otLogLevel aLogLevel)
|
||||
{
|
||||
return snprintf(aLogString, aMaxSize, "%s ", levelToString(aLogLevel));
|
||||
}
|
||||
|
||||
void nrf5LogInit()
|
||||
{
|
||||
int res = SEGGER_RTT_ConfigUpBuffer(LOG_RTT_BUFFER_INDEX,
|
||||
LOG_RTT_BUFFER_NAME, sLogBuffer,
|
||||
LOG_RTT_BUFFER_SIZE,
|
||||
int res = SEGGER_RTT_ConfigUpBuffer(LOG_RTT_BUFFER_INDEX, LOG_RTT_BUFFER_NAME, sLogBuffer, LOG_RTT_BUFFER_SIZE,
|
||||
SEGGER_RTT_MODE_NO_BLOCK_TRIM);
|
||||
otEXPECT(res >= 0);
|
||||
|
||||
@@ -144,13 +140,12 @@ void nrf5LogDeinit()
|
||||
sLogInitialized = false;
|
||||
}
|
||||
|
||||
void otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion,
|
||||
const char *aFormat, ...)
|
||||
void otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, ...)
|
||||
{
|
||||
(void) aLogRegion;
|
||||
(void)aLogRegion;
|
||||
|
||||
uint16_t length = 0;
|
||||
char logString[LOG_PARSE_BUFFER_SIZE + 1];
|
||||
char logString[LOG_PARSE_BUFFER_SIZE + 1];
|
||||
|
||||
otEXPECT(sLogInitialized == true);
|
||||
|
||||
@@ -159,14 +154,12 @@ void otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion,
|
||||
#endif
|
||||
|
||||
// Add level information.
|
||||
length += logLevel(&logString[length], (LOG_PARSE_BUFFER_SIZE - length),
|
||||
aLogLevel);
|
||||
length += logLevel(&logString[length], (LOG_PARSE_BUFFER_SIZE - length), aLogLevel);
|
||||
|
||||
// Parse user string.
|
||||
va_list paramList;
|
||||
va_start(paramList, aFormat);
|
||||
length += vsnprintf(&logString[length], (LOG_PARSE_BUFFER_SIZE - length),
|
||||
aFormat, paramList);
|
||||
length += vsnprintf(&logString[length], (LOG_PARSE_BUFFER_SIZE - length), aFormat, paramList);
|
||||
|
||||
if (length > LOG_PARSE_BUFFER_SIZE)
|
||||
{
|
||||
|
||||
@@ -26,8 +26,8 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <openthread/config.h>
|
||||
#include <openthread-core-config.h>
|
||||
#include <openthread/config.h>
|
||||
#include <openthread/platform/misc.h>
|
||||
|
||||
#include <device/nrf.h>
|
||||
@@ -56,9 +56,9 @@ void nrf5MiscInit(void)
|
||||
sd_power_reset_reason_get(&sResetReason);
|
||||
sd_power_reset_reason_clr(0xFFFFFFFF);
|
||||
#else
|
||||
sResetReason = NRF_POWER->RESETREAS;
|
||||
sResetReason = NRF_POWER->RESETREAS;
|
||||
NRF_POWER->RESETREAS = 0xFFFFFFFF;
|
||||
#endif // SOFTDEVICE_PRESENT
|
||||
#endif // SOFTDEVICE_PRESENT
|
||||
}
|
||||
|
||||
void nrf5MiscDeinit(void)
|
||||
@@ -94,10 +94,8 @@ otPlatResetReason otPlatGetResetReason(otInstance *aInstance)
|
||||
{
|
||||
reason = OT_PLAT_RESET_REASON_FAULT;
|
||||
}
|
||||
else if ((sResetReason & POWER_RESETREAS_OFF_Msk) ||
|
||||
(sResetReason & POWER_RESETREAS_LPCOMP_Msk) ||
|
||||
(sResetReason & POWER_RESETREAS_DIF_Msk) ||
|
||||
(sResetReason & POWER_RESETREAS_NFC_Msk) ||
|
||||
else if ((sResetReason & POWER_RESETREAS_OFF_Msk) || (sResetReason & POWER_RESETREAS_LPCOMP_Msk) ||
|
||||
(sResetReason & POWER_RESETREAS_DIF_Msk) || (sResetReason & POWER_RESETREAS_NFC_Msk) ||
|
||||
(sResetReason & POWER_RESETREAS_VBUS_Msk))
|
||||
{
|
||||
reason = OT_PLAT_RESET_REASON_OTHER;
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
*
|
||||
*/
|
||||
#ifndef UART_INSTANCE
|
||||
#define UART_INSTANCE NRF_UART0
|
||||
#define UART_INSTANCE NRF_UART0
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -69,7 +69,7 @@
|
||||
*
|
||||
*/
|
||||
#ifndef UART_PARITY
|
||||
#define UART_PARITY NRF_UART_PARITY_EXCLUDED
|
||||
#define UART_PARITY NRF_UART_PARITY_EXCLUDED
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -83,7 +83,7 @@
|
||||
*
|
||||
*/
|
||||
#ifndef UART_HWFC
|
||||
#define UART_HWFC NRF_UART_HWFC_ENABLED
|
||||
#define UART_HWFC NRF_UART_HWFC_ENABLED
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -111,7 +111,7 @@
|
||||
*
|
||||
*/
|
||||
#ifndef UART_BAUDRATE
|
||||
#define UART_BAUDRATE NRF_UART_BAUDRATE_115200
|
||||
#define UART_BAUDRATE NRF_UART_BAUDRATE_115200
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -121,7 +121,7 @@
|
||||
*
|
||||
*/
|
||||
#ifndef UART_IRQN
|
||||
#define UART_IRQN UARTE0_UART0_IRQn
|
||||
#define UART_IRQN UARTE0_UART0_IRQn
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -131,7 +131,7 @@
|
||||
*
|
||||
*/
|
||||
#ifndef UART_IRQ_PRIORITY
|
||||
#define UART_IRQ_PRIORITY 6
|
||||
#define UART_IRQ_PRIORITY 6
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -141,7 +141,7 @@
|
||||
*
|
||||
*/
|
||||
#ifndef UART_RX_BUFFER_SIZE
|
||||
#define UART_RX_BUFFER_SIZE 256
|
||||
#define UART_RX_BUFFER_SIZE 256
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -151,7 +151,7 @@
|
||||
*
|
||||
*/
|
||||
#ifndef UART_PIN_TX
|
||||
#define UART_PIN_TX 6
|
||||
#define UART_PIN_TX 6
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -161,7 +161,7 @@
|
||||
*
|
||||
*/
|
||||
#ifndef UART_PIN_RX
|
||||
#define UART_PIN_RX 8
|
||||
#define UART_PIN_RX 8
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -171,7 +171,7 @@
|
||||
*
|
||||
*/
|
||||
#ifndef UART_PIN_CTS
|
||||
#define UART_PIN_CTS 7
|
||||
#define UART_PIN_CTS 7
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -181,7 +181,7 @@
|
||||
*
|
||||
*/
|
||||
#ifndef UART_PIN_RTS
|
||||
#define UART_PIN_RTS 5
|
||||
#define UART_PIN_RTS 5
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -195,7 +195,7 @@
|
||||
*
|
||||
*/
|
||||
#ifndef RTC_INSTANCE
|
||||
#define RTC_INSTANCE NRF_RTC2
|
||||
#define RTC_INSTANCE NRF_RTC2
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -205,7 +205,7 @@
|
||||
*
|
||||
*/
|
||||
#ifndef RTC_IRQ_HANDLER
|
||||
#define RTC_IRQ_HANDLER RTC2_IRQHandler
|
||||
#define RTC_IRQ_HANDLER RTC2_IRQHandler
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -215,7 +215,7 @@
|
||||
*
|
||||
*/
|
||||
#ifndef RTC_IRQN
|
||||
#define RTC_IRQN RTC2_IRQn
|
||||
#define RTC_IRQN RTC2_IRQn
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -225,7 +225,7 @@
|
||||
*
|
||||
*/
|
||||
#ifndef RTC_IRQ_PRIORITY
|
||||
#define RTC_IRQ_PRIORITY 6
|
||||
#define RTC_IRQ_PRIORITY 6
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -239,7 +239,7 @@
|
||||
*
|
||||
*/
|
||||
#ifndef RNG_BUFFER_SIZE
|
||||
#define RNG_BUFFER_SIZE 64
|
||||
#define RNG_BUFFER_SIZE 64
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -249,7 +249,7 @@
|
||||
*
|
||||
*/
|
||||
#ifndef RNG_IRQ_PRIORITY
|
||||
#define RNG_IRQ_PRIORITY 6
|
||||
#define RNG_IRQ_PRIORITY 6
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -263,7 +263,7 @@
|
||||
*
|
||||
*/
|
||||
#ifndef LOG_RTT_BUFFER_INDEX
|
||||
#define LOG_RTT_BUFFER_INDEX 0
|
||||
#define LOG_RTT_BUFFER_INDEX 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -273,7 +273,7 @@
|
||||
*
|
||||
*/
|
||||
#ifndef LOG_RTT_BUFFER_NAME
|
||||
#define LOG_RTT_BUFFER_NAME "Terminal"
|
||||
#define LOG_RTT_BUFFER_NAME "Terminal"
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -283,7 +283,7 @@
|
||||
*
|
||||
*/
|
||||
#ifndef LOG_RTT_BUFFER_SIZE
|
||||
#define LOG_RTT_BUFFER_SIZE 256
|
||||
#define LOG_RTT_BUFFER_SIZE 256
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -293,7 +293,7 @@
|
||||
*
|
||||
*/
|
||||
#ifndef LOG_RTT_COLOR_ENABLE
|
||||
#define LOG_RTT_COLOR_ENABLE 1
|
||||
#define LOG_RTT_COLOR_ENABLE 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -304,7 +304,7 @@
|
||||
*
|
||||
*/
|
||||
#ifndef LOG_PARSE_BUFFER_SIZE
|
||||
#define LOG_PARSE_BUFFER_SIZE 128
|
||||
#define LOG_PARSE_BUFFER_SIZE 128
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -314,7 +314,7 @@
|
||||
*
|
||||
*/
|
||||
#ifndef LOG_TIMESTAMP_ENABLE
|
||||
#define LOG_TIMESTAMP_ENABLE 1
|
||||
#define LOG_TIMESTAMP_ENABLE 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -324,7 +324,7 @@
|
||||
*
|
||||
*/
|
||||
#ifndef USB_INITIAL_DELAY_MS
|
||||
#define USB_INITIAL_DELAY_MS 600
|
||||
#define USB_INITIAL_DELAY_MS 600
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -344,7 +344,7 @@
|
||||
* Use USB CDC driver for serial communication.
|
||||
*/
|
||||
#ifndef USB_CDC_AS_SERIAL_TRANSPORT
|
||||
#define USB_CDC_AS_SERIAL_TRANSPORT 0
|
||||
#define USB_CDC_AS_SERIAL_TRANSPORT 0
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -358,7 +358,7 @@
|
||||
*
|
||||
*/
|
||||
#ifndef NRF_DRV_RADIO802154_PENDING_SHORT_ADDRESSES
|
||||
#define NRF_DRV_RADIO802154_PENDING_SHORT_ADDRESSES OPENTHREAD_CONFIG_MAX_CHILDREN
|
||||
#define NRF_DRV_RADIO802154_PENDING_SHORT_ADDRESSES OPENTHREAD_CONFIG_MAX_CHILDREN
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -368,7 +368,7 @@
|
||||
*
|
||||
*/
|
||||
#ifndef NRF_DRV_RADIO802154_PENDING_EXTENDED_ADDRESSES
|
||||
#define NRF_DRV_RADIO802154_PENDING_EXTENDED_ADDRESSES OPENTHREAD_CONFIG_MAX_CHILDREN
|
||||
#define NRF_DRV_RADIO802154_PENDING_EXTENDED_ADDRESSES OPENTHREAD_CONFIG_MAX_CHILDREN
|
||||
#endif
|
||||
|
||||
#endif // PLATFORM_CONFIG_H_
|
||||
#endif // PLATFORM_CONFIG_H_
|
||||
|
||||
@@ -49,23 +49,25 @@
|
||||
|
||||
// clang-format on
|
||||
|
||||
#define PLATFORM_FEM_DEFAULT_CONFIG \
|
||||
((PlatformFemConfigParams) { \
|
||||
.mPaCfg = { \
|
||||
.mEnable = 1, \
|
||||
.mActiveHigh = 1, \
|
||||
.mGpioPin = PLATFORM_FEM_DEFAULT_PA_PIN, \
|
||||
}, \
|
||||
.mLnaCfg = { \
|
||||
.mEnable = 1, \
|
||||
.mActiveHigh = 1, \
|
||||
.mGpioPin = PLATFORM_FEM_DEFAULT_LNA_PIN, \
|
||||
}, \
|
||||
.mPpiChIdClr = PLATFORM_FEM_DEFAULT_CLR_PPI_CHANNEL, \
|
||||
.mPpiChIdSet = PLATFORM_FEM_DEFAULT_SET_PPI_CHANNEL, \
|
||||
.mTimerPpiGrp = PLATFORM_FEM_DEFAULT_TIMER_MATCH_PPI_GROUP, \
|
||||
.mRadioPpiGrp = PLATFORM_FEM_DEFAULT_RADIO_DISABLED_PPI_GROUP, \
|
||||
.mGpioteChId = PLATFORM_FEM_DEFAULT_GPIOTE_CHANNEL, \
|
||||
#define PLATFORM_FEM_DEFAULT_CONFIG \
|
||||
((PlatformFemConfigParams){ \
|
||||
.mPaCfg = \
|
||||
{ \
|
||||
.mEnable = 1, \
|
||||
.mActiveHigh = 1, \
|
||||
.mGpioPin = PLATFORM_FEM_DEFAULT_PA_PIN, \
|
||||
}, \
|
||||
.mLnaCfg = \
|
||||
{ \
|
||||
.mEnable = 1, \
|
||||
.mActiveHigh = 1, \
|
||||
.mGpioPin = PLATFORM_FEM_DEFAULT_LNA_PIN, \
|
||||
}, \
|
||||
.mPpiChIdClr = PLATFORM_FEM_DEFAULT_CLR_PPI_CHANNEL, \
|
||||
.mPpiChIdSet = PLATFORM_FEM_DEFAULT_SET_PPI_CHANNEL, \
|
||||
.mTimerPpiGrp = PLATFORM_FEM_DEFAULT_TIMER_MATCH_PPI_GROUP, \
|
||||
.mRadioPpiGrp = PLATFORM_FEM_DEFAULT_RADIO_DISABLED_PPI_GROUP, \
|
||||
.mGpioteChId = PLATFORM_FEM_DEFAULT_GPIOTE_CHANNEL, \
|
||||
})
|
||||
|
||||
/**
|
||||
@@ -73,9 +75,9 @@
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t mEnable : 1; /**< Enable toggling for this amplifier */
|
||||
uint8_t mActiveHigh : 1; /**< Set the pin to be active high */
|
||||
uint8_t mGpioPin : 6; /**< The GPIO pin to toggle for this amplifier */
|
||||
uint8_t mEnable : 1; /**< Enable toggling for this amplifier */
|
||||
uint8_t mActiveHigh : 1; /**< Set the pin to be active high */
|
||||
uint8_t mGpioPin : 6; /**< The GPIO pin to toggle for this amplifier */
|
||||
} PlatformFemConfigPaLna;
|
||||
|
||||
/**
|
||||
@@ -107,4 +109,4 @@ typedef struct
|
||||
*/
|
||||
void PlatformFemSetConfigParams(const PlatformFemConfigParams *aConfig);
|
||||
|
||||
#endif // PLATFORM_FEM_H_
|
||||
#endif // PLATFORM_FEM_H_
|
||||
|
||||
@@ -201,4 +201,4 @@ otError nrf5SdErrorToOtError(uint32_t aSdError);
|
||||
void nrf5SdSocFlashProcess(uint32_t aEvtId);
|
||||
#endif // SOFTDEVICE_PRESENT
|
||||
|
||||
#endif // PLATFORM_NRF5_H_
|
||||
#endif // PLATFORM_NRF5_H_
|
||||
|
||||
@@ -32,18 +32,22 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <openthread/config.h>
|
||||
#include <openthread-core-config.h>
|
||||
#include <openthread/config.h>
|
||||
|
||||
#include <openthread/platform/logging.h>
|
||||
|
||||
#include "platform-nrf5.h"
|
||||
#include <device/nrf.h>
|
||||
#include <drivers/clock/nrf_drv_clock.h>
|
||||
#include "platform-nrf5.h"
|
||||
|
||||
#include <openthread/config.h>
|
||||
|
||||
void __cxa_pure_virtual(void) { while (1); }
|
||||
void __cxa_pure_virtual(void)
|
||||
{
|
||||
while (1)
|
||||
;
|
||||
}
|
||||
|
||||
void PlatformInit(int argc, char *argv[])
|
||||
{
|
||||
|
||||
@@ -32,9 +32,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <openthread/config.h>
|
||||
#include <openthread/config.h>
|
||||
#include <openthread-core-config.h>
|
||||
#include <openthread/config.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdbool.h>
|
||||
@@ -48,8 +47,8 @@
|
||||
#include <openthread/platform/logging.h>
|
||||
#include <openthread/platform/radio.h>
|
||||
|
||||
#include "platform.h"
|
||||
#include "platform-nrf5.h"
|
||||
#include "platform.h"
|
||||
|
||||
#include <device/nrf.h>
|
||||
#include <nrf_drv_radio802154.h>
|
||||
@@ -69,7 +68,7 @@
|
||||
|
||||
enum
|
||||
{
|
||||
NRF52840_RECEIVE_SENSITIVITY = -100, // dBm
|
||||
NRF52840_RECEIVE_SENSITIVITY = -100, // dBm
|
||||
};
|
||||
|
||||
static bool sDisabled;
|
||||
@@ -81,14 +80,13 @@ static uint8_t sTransmitPsdu[OT_RADIO_FRAME_MAX_SIZE + 1];
|
||||
|
||||
static otRadioFrame sAckFrame;
|
||||
|
||||
static int8_t sDefaultTxPower;
|
||||
static int8_t sDefaultTxPower;
|
||||
|
||||
static uint32_t sEnergyDetectionTime;
|
||||
static uint8_t sEnergyDetectionChannel;
|
||||
static int8_t sEnergyDetected;
|
||||
static uint32_t sEnergyDetectionTime;
|
||||
static uint8_t sEnergyDetectionChannel;
|
||||
static int8_t sEnergyDetected;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
kPendingEventSleep, // Requested to enter Sleep state.
|
||||
kPendingEventTransmit, // Frame is queued for transmission.
|
||||
kPendingEventFrameTransmitted, // Transmitted frame and received ACK (if requested).
|
||||
@@ -119,7 +117,7 @@ static void dataInit(void)
|
||||
|
||||
static void convertShortAddress(uint8_t *aTo, uint16_t aFrom)
|
||||
{
|
||||
aTo[0] = (uint8_t) aFrom;
|
||||
aTo[0] = (uint8_t)aFrom;
|
||||
aTo[1] = (uint8_t)(aFrom >> 8);
|
||||
}
|
||||
|
||||
@@ -137,8 +135,7 @@ static void setPendingEvent(RadioPendingEvents aEvent)
|
||||
{
|
||||
pendingEvents = __LDREXW((unsigned long volatile *)&sPendingEvents);
|
||||
pendingEvents |= bitToSet;
|
||||
}
|
||||
while (__STREXW(pendingEvents, (unsigned long volatile *)&sPendingEvents));
|
||||
} while (__STREXW(pendingEvents, (unsigned long volatile *)&sPendingEvents));
|
||||
|
||||
PlatformEventSignalPending();
|
||||
}
|
||||
@@ -152,8 +149,7 @@ static void resetPendingEvent(RadioPendingEvents aEvent)
|
||||
{
|
||||
pendingEvents = __LDREXW((unsigned long volatile *)&sPendingEvents);
|
||||
pendingEvents &= bitsToRemain;
|
||||
}
|
||||
while (__STREXW(pendingEvents, (unsigned long volatile *)&sPendingEvents));
|
||||
} while (__STREXW(pendingEvents, (unsigned long volatile *)&sPendingEvents));
|
||||
}
|
||||
|
||||
static inline void clearPendingEvents(void)
|
||||
@@ -172,23 +168,22 @@ static inline void clearPendingEvents(void)
|
||||
{
|
||||
pendingEvents = __LDREXW((unsigned long volatile *)&sPendingEvents);
|
||||
pendingEvents &= bitsToRemain;
|
||||
}
|
||||
while (__STREXW(pendingEvents, (unsigned long volatile *)&sPendingEvents));
|
||||
} while (__STREXW(pendingEvents, (unsigned long volatile *)&sPendingEvents));
|
||||
}
|
||||
|
||||
void otPlatRadioGetIeeeEui64(otInstance *aInstance, uint8_t *aIeeeEui64)
|
||||
{
|
||||
(void) aInstance;
|
||||
(void)aInstance;
|
||||
|
||||
uint64_t factoryAddress = (uint64_t)NRF_FICR->DEVICEID[0] << 32;
|
||||
factoryAddress |= NRF_FICR->DEVICEID[1];
|
||||
factoryAddress |= NRF_FICR->DEVICEID[1];
|
||||
|
||||
memcpy(aIeeeEui64, &factoryAddress, sizeof(factoryAddress));
|
||||
}
|
||||
|
||||
void otPlatRadioSetPanId(otInstance *aInstance, uint16_t aPanId)
|
||||
{
|
||||
(void) aInstance;
|
||||
(void)aInstance;
|
||||
|
||||
uint8_t address[SHORT_ADDRESS_SIZE];
|
||||
convertShortAddress(address, aPanId);
|
||||
@@ -198,14 +193,14 @@ void otPlatRadioSetPanId(otInstance *aInstance, uint16_t aPanId)
|
||||
|
||||
void otPlatRadioSetExtendedAddress(otInstance *aInstance, const otExtAddress *aExtAddress)
|
||||
{
|
||||
(void) aInstance;
|
||||
(void)aInstance;
|
||||
|
||||
nrf_drv_radio802154_extended_address_set(aExtAddress->m8);
|
||||
}
|
||||
|
||||
void otPlatRadioSetShortAddress(otInstance *aInstance, uint16_t aShortAddress)
|
||||
{
|
||||
(void) aInstance;
|
||||
(void)aInstance;
|
||||
|
||||
uint8_t address[SHORT_ADDRESS_SIZE];
|
||||
convertShortAddress(address, aShortAddress);
|
||||
@@ -226,7 +221,7 @@ void nrf5RadioDeinit(void)
|
||||
|
||||
otRadioState otPlatRadioGetState(otInstance *aInstance)
|
||||
{
|
||||
(void) aInstance;
|
||||
(void)aInstance;
|
||||
|
||||
if (sDisabled)
|
||||
{
|
||||
@@ -254,14 +249,14 @@ otRadioState otPlatRadioGetState(otInstance *aInstance)
|
||||
|
||||
otError otPlatRadioEnable(otInstance *aInstance)
|
||||
{
|
||||
(void) aInstance;
|
||||
(void)aInstance;
|
||||
|
||||
otError error;
|
||||
|
||||
if (sDisabled)
|
||||
{
|
||||
sDisabled = false;
|
||||
error = OT_ERROR_NONE;
|
||||
error = OT_ERROR_NONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -273,14 +268,14 @@ otError otPlatRadioEnable(otInstance *aInstance)
|
||||
|
||||
otError otPlatRadioDisable(otInstance *aInstance)
|
||||
{
|
||||
(void) aInstance;
|
||||
(void)aInstance;
|
||||
|
||||
otError error;
|
||||
|
||||
if (!sDisabled)
|
||||
{
|
||||
sDisabled = true;
|
||||
error = OT_ERROR_NONE;
|
||||
error = OT_ERROR_NONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -292,14 +287,14 @@ otError otPlatRadioDisable(otInstance *aInstance)
|
||||
|
||||
bool otPlatRadioIsEnabled(otInstance *aInstance)
|
||||
{
|
||||
(void) aInstance;
|
||||
(void)aInstance;
|
||||
|
||||
return !sDisabled;
|
||||
}
|
||||
|
||||
otError otPlatRadioSleep(otInstance *aInstance)
|
||||
{
|
||||
(void) aInstance;
|
||||
(void)aInstance;
|
||||
|
||||
if (nrf_drv_radio802154_sleep())
|
||||
{
|
||||
@@ -316,7 +311,7 @@ otError otPlatRadioSleep(otInstance *aInstance)
|
||||
|
||||
otError otPlatRadioReceive(otInstance *aInstance, uint8_t aChannel)
|
||||
{
|
||||
(void) aInstance;
|
||||
(void)aInstance;
|
||||
|
||||
nrf_drv_radio802154_channel_set(aChannel);
|
||||
nrf_drv_radio802154_tx_power_set(sDefaultTxPower);
|
||||
@@ -328,7 +323,7 @@ otError otPlatRadioReceive(otInstance *aInstance, uint8_t aChannel)
|
||||
|
||||
otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aFrame)
|
||||
{
|
||||
(void) aInstance;
|
||||
(void)aInstance;
|
||||
|
||||
aFrame->mPsdu[-1] = aFrame->mLength;
|
||||
|
||||
@@ -350,49 +345,49 @@ otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aFrame)
|
||||
|
||||
otRadioFrame *otPlatRadioGetTransmitBuffer(otInstance *aInstance)
|
||||
{
|
||||
(void) aInstance;
|
||||
(void)aInstance;
|
||||
|
||||
return &sTransmitFrame;
|
||||
}
|
||||
|
||||
int8_t otPlatRadioGetRssi(otInstance *aInstance)
|
||||
{
|
||||
(void) aInstance;
|
||||
(void)aInstance;
|
||||
|
||||
return nrf_drv_radio802154_rssi_last_get();
|
||||
}
|
||||
|
||||
otRadioCaps otPlatRadioGetCaps(otInstance *aInstance)
|
||||
{
|
||||
(void) aInstance;
|
||||
(void)aInstance;
|
||||
|
||||
return OT_RADIO_CAPS_ENERGY_SCAN;
|
||||
}
|
||||
|
||||
bool otPlatRadioGetPromiscuous(otInstance *aInstance)
|
||||
{
|
||||
(void) aInstance;
|
||||
(void)aInstance;
|
||||
|
||||
return nrf_drv_radio802154_promiscuous_get();
|
||||
}
|
||||
|
||||
void otPlatRadioSetPromiscuous(otInstance *aInstance, bool aEnable)
|
||||
{
|
||||
(void) aInstance;
|
||||
(void)aInstance;
|
||||
|
||||
nrf_drv_radio802154_promiscuous_set(aEnable);
|
||||
}
|
||||
|
||||
void otPlatRadioEnableSrcMatch(otInstance *aInstance, bool aEnable)
|
||||
{
|
||||
(void) aInstance;
|
||||
(void)aInstance;
|
||||
|
||||
nrf_drv_radio802154_auto_pending_bit_set(aEnable);
|
||||
}
|
||||
|
||||
otError otPlatRadioAddSrcMatchShortEntry(otInstance *aInstance, const uint16_t aShortAddress)
|
||||
{
|
||||
(void) aInstance;
|
||||
(void)aInstance;
|
||||
|
||||
otError error;
|
||||
|
||||
@@ -413,7 +408,7 @@ otError otPlatRadioAddSrcMatchShortEntry(otInstance *aInstance, const uint16_t a
|
||||
|
||||
otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress)
|
||||
{
|
||||
(void) aInstance;
|
||||
(void)aInstance;
|
||||
|
||||
otError error;
|
||||
|
||||
@@ -431,7 +426,7 @@ otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const otExtAddress
|
||||
|
||||
otError otPlatRadioClearSrcMatchShortEntry(otInstance *aInstance, const uint16_t aShortAddress)
|
||||
{
|
||||
(void) aInstance;
|
||||
(void)aInstance;
|
||||
|
||||
otError error;
|
||||
|
||||
@@ -452,7 +447,7 @@ otError otPlatRadioClearSrcMatchShortEntry(otInstance *aInstance, const uint16_t
|
||||
|
||||
otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress)
|
||||
{
|
||||
(void) aInstance;
|
||||
(void)aInstance;
|
||||
|
||||
otError error;
|
||||
|
||||
@@ -470,23 +465,23 @@ otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const otExtAddre
|
||||
|
||||
void otPlatRadioClearSrcMatchShortEntries(otInstance *aInstance)
|
||||
{
|
||||
(void) aInstance;
|
||||
(void)aInstance;
|
||||
|
||||
nrf_drv_radio802154_pending_bit_for_addr_reset(false);
|
||||
}
|
||||
|
||||
void otPlatRadioClearSrcMatchExtEntries(otInstance *aInstance)
|
||||
{
|
||||
(void) aInstance;
|
||||
(void)aInstance;
|
||||
|
||||
nrf_drv_radio802154_pending_bit_for_addr_reset(true);
|
||||
}
|
||||
|
||||
otError otPlatRadioEnergyScan(otInstance *aInstance, uint8_t aScanChannel, uint16_t aScanDuration)
|
||||
{
|
||||
(void) aInstance;
|
||||
(void)aInstance;
|
||||
|
||||
sEnergyDetectionTime = (uint32_t) aScanDuration * 1000UL;
|
||||
sEnergyDetectionTime = (uint32_t)aScanDuration * 1000UL;
|
||||
sEnergyDetectionChannel = aScanChannel;
|
||||
|
||||
clearPendingEvents();
|
||||
@@ -550,7 +545,7 @@ void nrf5RadioProcess(otInstance *aInstance)
|
||||
otPlatRadioReceiveDone(aInstance, &sReceivedFrames[i], OT_ERROR_NONE);
|
||||
}
|
||||
|
||||
uint8_t *bufferAddress = &sReceivedFrames[i].mPsdu[-1];
|
||||
uint8_t *bufferAddress = &sReceivedFrames[i].mPsdu[-1];
|
||||
sReceivedFrames[i].mPsdu = NULL;
|
||||
nrf_drv_radio802154_buffer_free_raw(bufferAddress);
|
||||
}
|
||||
@@ -691,9 +686,9 @@ void nrf_drv_radio802154_received_raw(uint8_t *p_data, int8_t power, int8_t lqi)
|
||||
receivedFrame->mLqi = lqi;
|
||||
receivedFrame->mChannel = nrf_drv_radio802154_channel_get();
|
||||
#if OPENTHREAD_ENABLE_RAW_LINK_API
|
||||
uint64_t timestamp = nrf5AlarmGetCurrentTime();
|
||||
receivedFrame->mMsec = timestamp / US_PER_MS;
|
||||
receivedFrame->mUsec = timestamp - receivedFrame->mMsec * US_PER_MS;
|
||||
uint64_t timestamp = nrf5AlarmGetCurrentTime();
|
||||
receivedFrame->mMsec = timestamp / US_PER_MS;
|
||||
receivedFrame->mUsec = timestamp - receivedFrame->mMsec * US_PER_MS;
|
||||
#endif
|
||||
|
||||
PlatformEventSignalPending();
|
||||
|
||||
@@ -32,15 +32,15 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <openthread/config.h>
|
||||
#include <openthread-core-config.h>
|
||||
#include <openthread/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <openthread/platform/random.h>
|
||||
#include <utils/code_utils.h>
|
||||
#include <openthread/platform/random.h>
|
||||
|
||||
#include "platform-nrf5.h"
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
#else
|
||||
#include <hal/nrf_rng.h>
|
||||
|
||||
static uint8_t sBuffer[RNG_BUFFER_SIZE];
|
||||
static uint8_t sBuffer[RNG_BUFFER_SIZE];
|
||||
static volatile uint32_t sReadPosition;
|
||||
static volatile uint32_t sWritePosition;
|
||||
|
||||
@@ -125,8 +125,7 @@ static void generatorStop(void)
|
||||
|
||||
void RNG_IRQHandler(void)
|
||||
{
|
||||
if (nrf_rng_event_get(NRF_RNG_EVENT_VALRDY) &&
|
||||
nrf_rng_int_get(NRF_RNG_INT_VALRDY_MASK))
|
||||
if (nrf_rng_event_get(NRF_RNG_EVENT_VALRDY) && nrf_rng_int_get(NRF_RNG_INT_VALRDY_MASK))
|
||||
{
|
||||
nrf_rng_event_clear(NRF_RNG_EVENT_VALRDY);
|
||||
|
||||
@@ -151,12 +150,11 @@ void nrf5RandomInit(void)
|
||||
{
|
||||
// Wait for the first randomized 4 bytes, to randomize software generator seed.
|
||||
retval = sd_rand_application_vector_get((uint8_t *)&seed, sizeof(seed));
|
||||
}
|
||||
while (retval != NRF_SUCCESS && seed == 0);
|
||||
} while (retval != NRF_SUCCESS && seed == 0);
|
||||
|
||||
#else // SOFTDEVICE_PRESENT
|
||||
#else // SOFTDEVICE_PRESENT
|
||||
memset(sBuffer, 0, sizeof(sBuffer));
|
||||
sReadPosition = 0;
|
||||
sReadPosition = 0;
|
||||
sWritePosition = 0;
|
||||
|
||||
NVIC_SetPriority(RNG_IRQn, RNG_IRQ_PRIORITY);
|
||||
@@ -168,7 +166,8 @@ void nrf5RandomInit(void)
|
||||
generatorStart();
|
||||
|
||||
// Wait for the first randomized 4 bytes, to randomize software generator seed.
|
||||
while (!bufferIsUint32Ready()) ;
|
||||
while (!bufferIsUint32Ready())
|
||||
;
|
||||
|
||||
seed = bufferGetUint32();
|
||||
#endif // SOFTDEVICE_PRESENT
|
||||
@@ -194,7 +193,7 @@ uint32_t otPlatRandomGet(void)
|
||||
|
||||
otError otPlatRandomGetTrue(uint8_t *aOutput, uint16_t aOutputLength)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint8_t copyLength;
|
||||
uint16_t index = 0;
|
||||
|
||||
@@ -204,7 +203,7 @@ otError otPlatRandomGetTrue(uint8_t *aOutput, uint16_t aOutputLength)
|
||||
{
|
||||
#if SOFTDEVICE_PRESENT
|
||||
sd_rand_application_bytes_available_get(©Length);
|
||||
#else // SOFTDEVICE_PRESENT
|
||||
#else // SOFTDEVICE_PRESENT
|
||||
copyLength = (uint8_t)bufferCount();
|
||||
#endif // SOFTDEVICE_PRESENT
|
||||
|
||||
@@ -215,11 +214,10 @@ otError otPlatRandomGetTrue(uint8_t *aOutput, uint16_t aOutputLength)
|
||||
|
||||
if (copyLength > 0)
|
||||
{
|
||||
|
||||
#if SOFTDEVICE_PRESENT
|
||||
uint32_t retval = sd_rand_application_vector_get(aOutput + index, copyLength);
|
||||
otEXPECT_ACTION(retval == NRF_SUCCESS, error = OT_ERROR_FAILED);
|
||||
#else // SOFTDEVICE_PRESENT
|
||||
#else // SOFTDEVICE_PRESENT
|
||||
|
||||
for (uint32_t i = 0; i < copyLength; i++)
|
||||
{
|
||||
@@ -231,8 +229,7 @@ otError otPlatRandomGetTrue(uint8_t *aOutput, uint16_t aOutputLength)
|
||||
|
||||
index += copyLength;
|
||||
}
|
||||
}
|
||||
while (index < aOutputLength);
|
||||
} while (index < aOutputLength);
|
||||
|
||||
exit:
|
||||
return error;
|
||||
|
||||
@@ -30,8 +30,8 @@
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <utils/code_utils.h>
|
||||
#include <hal/nrf_temp.h>
|
||||
#include <utils/code_utils.h>
|
||||
|
||||
#include "platform-nrf5.h"
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
__STATIC_INLINE void dataReadyEventClear(void)
|
||||
{
|
||||
NRF_TEMP->EVENTS_DATARDY = 0;
|
||||
volatile uint32_t dummy = NRF_TEMP->EVENTS_DATARDY;
|
||||
volatile uint32_t dummy = NRF_TEMP->EVENTS_DATARDY;
|
||||
(void)dummy;
|
||||
}
|
||||
#endif
|
||||
@@ -66,7 +66,7 @@ int32_t nrf5TempGet(void)
|
||||
{
|
||||
#if SOFTDEVICE_PRESENT
|
||||
int32_t temperature;
|
||||
(void) sd_temp_get(&temperature);
|
||||
(void)sd_temp_get(&temperature);
|
||||
#else
|
||||
NRF_TEMP->TASKS_START = 1;
|
||||
|
||||
|
||||
@@ -32,23 +32,23 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <openthread/config.h>
|
||||
#include <openthread-core-config.h>
|
||||
#include <openthread/config.h>
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <utils/code_utils.h>
|
||||
#include <openthread/types.h>
|
||||
#include <openthread/platform/toolchain.h>
|
||||
#include <openthread/platform/uart.h>
|
||||
#include <utils/code_utils.h>
|
||||
|
||||
#include "platform.h"
|
||||
|
||||
#include <drivers/clock/nrf_drv_clock.h>
|
||||
#include <hal/nrf_uart.h>
|
||||
#include <hal/nrf_gpio.h>
|
||||
#include "platform-nrf5.h"
|
||||
#include <drivers/clock/nrf_drv_clock.h>
|
||||
#include <hal/nrf_gpio.h>
|
||||
#include <hal/nrf_uart.h>
|
||||
|
||||
#if (USB_CDC_AS_SERIAL_TRANSPORT == 0)
|
||||
|
||||
@@ -58,13 +58,13 @@ bool sUartEnabled = false;
|
||||
* UART TX buffer variables.
|
||||
*/
|
||||
static const uint8_t *sTransmitBuffer = NULL;
|
||||
static uint16_t sTransmitLength = 0;
|
||||
static bool sTransmitDone = 0;
|
||||
static uint16_t sTransmitLength = 0;
|
||||
static bool sTransmitDone = 0;
|
||||
|
||||
/**
|
||||
* UART RX ring buffer variables.
|
||||
*/
|
||||
static uint8_t sReceiveBuffer[UART_RX_BUFFER_SIZE];
|
||||
static uint8_t sReceiveBuffer[UART_RX_BUFFER_SIZE];
|
||||
static uint16_t sReceiveHead = 0;
|
||||
static uint16_t sReceiveTail = 0;
|
||||
|
||||
@@ -105,16 +105,14 @@ static void processReceive(void)
|
||||
// bytes from the end of the buffer.
|
||||
if (head < sReceiveTail)
|
||||
{
|
||||
otPlatUartReceived(&sReceiveBuffer[sReceiveTail],
|
||||
(UART_RX_BUFFER_SIZE - sReceiveTail));
|
||||
otPlatUartReceived(&sReceiveBuffer[sReceiveTail], (UART_RX_BUFFER_SIZE - sReceiveTail));
|
||||
sReceiveTail = 0;
|
||||
}
|
||||
|
||||
// Notify about received bytes.
|
||||
if (head > sReceiveTail)
|
||||
{
|
||||
otPlatUartReceived(&sReceiveBuffer[sReceiveTail],
|
||||
(head - sReceiveTail));
|
||||
otPlatUartReceived(&sReceiveBuffer[sReceiveTail], (head - sReceiveTail));
|
||||
sReceiveTail = head;
|
||||
}
|
||||
|
||||
@@ -134,7 +132,7 @@ static void processTransmit(void)
|
||||
// Clear Transmition transaction and notify application.
|
||||
sTransmitBuffer = NULL;
|
||||
sTransmitLength = 0;
|
||||
sTransmitDone = false;
|
||||
sTransmitDone = false;
|
||||
otPlatUartSendDone();
|
||||
}
|
||||
|
||||
@@ -206,7 +204,9 @@ otError otPlatUartEnable(void)
|
||||
// Start HFCLK
|
||||
nrf_drv_clock_hfclk_request(NULL);
|
||||
|
||||
while (!nrf_drv_clock_hfclk_is_running()) {}
|
||||
while (!nrf_drv_clock_hfclk_is_running())
|
||||
{
|
||||
}
|
||||
|
||||
// Enable UART instance, and start RX on it.
|
||||
nrf_uart_enable(UART_INSTANCE);
|
||||
@@ -289,7 +289,7 @@ void UARTE0_UART0_IRQHandler(void)
|
||||
if (!isRxBufferFull())
|
||||
{
|
||||
sReceiveBuffer[sReceiveHead] = byte;
|
||||
sReceiveHead = (sReceiveHead + 1) % UART_RX_BUFFER_SIZE;
|
||||
sReceiveHead = (sReceiveHead + 1) % UART_RX_BUFFER_SIZE;
|
||||
PlatformEventSignalPending();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,20 +36,20 @@
|
||||
#pragma GCC diagnostic ignored "-Wpedantic"
|
||||
#endif
|
||||
|
||||
#include <openthread/config.h>
|
||||
#include <openthread-core-config.h>
|
||||
#include <openthread/config.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <openthread/types.h>
|
||||
#include <openthread/platform/diag.h>
|
||||
#include <openthread/platform/uart.h>
|
||||
#include <openthread/platform/alarm-milli.h>
|
||||
#include <openthread/platform/misc.h>
|
||||
#include <utils/code_utils.h>
|
||||
#include <common/logging.hpp>
|
||||
#include <utils/code_utils.h>
|
||||
#include <openthread/types.h>
|
||||
#include <openthread/platform/alarm-milli.h>
|
||||
#include <openthread/platform/diag.h>
|
||||
#include <openthread/platform/misc.h>
|
||||
#include <openthread/platform/uart.h>
|
||||
|
||||
#include "platform-nrf5.h"
|
||||
|
||||
@@ -60,40 +60,28 @@
|
||||
|
||||
#if (USB_CDC_AS_SERIAL_TRANSPORT == 1)
|
||||
|
||||
static void cdcAcmUserEventHandler(app_usbd_class_inst_t const *aInstance,
|
||||
app_usbd_cdc_acm_user_event_t aEvent);
|
||||
static void cdcAcmUserEventHandler(app_usbd_class_inst_t const *aInstance, app_usbd_cdc_acm_user_event_t aEvent);
|
||||
|
||||
#define CDC_ACM_COMM_INTERFACE 0
|
||||
#define CDC_ACM_COMM_EPIN NRF_DRV_USBD_EPIN2
|
||||
#define CDC_ACM_COMM_INTERFACE 0
|
||||
#define CDC_ACM_COMM_EPIN NRF_DRV_USBD_EPIN2
|
||||
|
||||
#define CDC_ACM_DATA_INTERFACE 1
|
||||
#define CDC_ACM_DATA_EPIN NRF_DRV_USBD_EPIN1
|
||||
#define CDC_ACM_DATA_EPOUT NRF_DRV_USBD_EPOUT1
|
||||
#define CDC_ACM_DATA_INTERFACE 1
|
||||
#define CDC_ACM_DATA_EPIN NRF_DRV_USBD_EPIN1
|
||||
#define CDC_ACM_DATA_EPOUT NRF_DRV_USBD_EPOUT1
|
||||
|
||||
#define SERIAL_NUMBER_STRING_SIZE 16
|
||||
|
||||
#define CDC_ACM_INTERFACES_CONFIG() \
|
||||
APP_USBD_CDC_ACM_CONFIG(CDC_ACM_COMM_INTERFACE, \
|
||||
CDC_ACM_COMM_EPIN, \
|
||||
CDC_ACM_DATA_INTERFACE, \
|
||||
CDC_ACM_DATA_EPIN, \
|
||||
#define CDC_ACM_INTERFACES_CONFIG() \
|
||||
APP_USBD_CDC_ACM_CONFIG(CDC_ACM_COMM_INTERFACE, CDC_ACM_COMM_EPIN, CDC_ACM_DATA_INTERFACE, CDC_ACM_DATA_EPIN, \
|
||||
CDC_ACM_DATA_EPOUT)
|
||||
|
||||
static const uint8_t sCdcAcmClassDescriptors[] = {APP_USBD_CDC_ACM_DEFAULT_DESC(CDC_ACM_COMM_INTERFACE,
|
||||
CDC_ACM_COMM_EPIN,
|
||||
CDC_ACM_DATA_INTERFACE,
|
||||
CDC_ACM_DATA_EPIN,
|
||||
CDC_ACM_DATA_EPOUT)};
|
||||
|
||||
static const uint8_t sCdcAcmClassDescriptors[] =
|
||||
{
|
||||
APP_USBD_CDC_ACM_DEFAULT_DESC(
|
||||
CDC_ACM_COMM_INTERFACE,
|
||||
CDC_ACM_COMM_EPIN,
|
||||
CDC_ACM_DATA_INTERFACE,
|
||||
CDC_ACM_DATA_EPIN,
|
||||
CDC_ACM_DATA_EPOUT)
|
||||
};
|
||||
|
||||
APP_USBD_CDC_ACM_GLOBAL_DEF(sAppCdcAcm,
|
||||
CDC_ACM_INTERFACES_CONFIG(),
|
||||
cdcAcmUserEventHandler,
|
||||
sCdcAcmClassDescriptors);
|
||||
APP_USBD_CDC_ACM_GLOBAL_DEF(sAppCdcAcm, CDC_ACM_INTERFACES_CONFIG(), cdcAcmUserEventHandler, sCdcAcmClassDescriptors);
|
||||
|
||||
// Rx buffer length must by multiple of NRF_DRV_USBD_EPSIZE.
|
||||
static char sRxBuffer[NRF_DRV_USBD_EPSIZE * ((UART_RX_BUFFER_SIZE + NRF_DRV_USBD_EPSIZE - 1) / NRF_DRV_USBD_EPSIZE)];
|
||||
@@ -133,8 +121,7 @@ static void serialNumberStringCreate(void)
|
||||
}
|
||||
}
|
||||
|
||||
static void cdcAcmUserEventHandler(app_usbd_class_inst_t const *aCdcAcmInstance,
|
||||
app_usbd_cdc_acm_user_event_t aEvent)
|
||||
static void cdcAcmUserEventHandler(app_usbd_class_inst_t const *aCdcAcmInstance, app_usbd_cdc_acm_user_event_t aEvent)
|
||||
{
|
||||
app_usbd_cdc_acm_t const *cdcAcmClass = app_usbd_cdc_acm_class_get(aCdcAcmInstance);
|
||||
|
||||
@@ -293,15 +280,15 @@ static void processTransmit(void)
|
||||
if (app_usbd_cdc_acm_write(&sAppCdcAcm, sUsbState.mTxBuffer, sUsbState.mTxSize) == NRF_SUCCESS)
|
||||
{
|
||||
sUsbState.mTransferInProgress = true;
|
||||
sUsbState.mTxBuffer = NULL;
|
||||
sUsbState.mTxSize = 0;
|
||||
sUsbState.mTxBuffer = NULL;
|
||||
sUsbState.mTxSize = 0;
|
||||
}
|
||||
}
|
||||
else if (sUsbState.mTransferDone)
|
||||
{
|
||||
otPlatLog(OT_LOG_LEVEL_DEBG, OT_LOG_REGION_PLATFORM, "otPlatUartSendDone");
|
||||
|
||||
sUsbState.mTransferDone = false;
|
||||
sUsbState.mTransferDone = false;
|
||||
sUsbState.mTransferInProgress = false;
|
||||
|
||||
otPlatUartSendDone();
|
||||
@@ -310,15 +297,9 @@ static void processTransmit(void)
|
||||
|
||||
void nrf5UartInit(void)
|
||||
{
|
||||
static const nrf_drv_power_usbevt_config_t powerConfig =
|
||||
{
|
||||
.handler = powerUsbEventHandler
|
||||
};
|
||||
static const nrf_drv_power_usbevt_config_t powerConfig = {.handler = powerUsbEventHandler};
|
||||
|
||||
static const app_usbd_config_t usbdConfig =
|
||||
{
|
||||
.ev_state_proc = usbdUserEventHandler
|
||||
};
|
||||
static const app_usbd_config_t usbdConfig = {.ev_state_proc = usbdUserEventHandler};
|
||||
|
||||
memset((void *)&sUsbState, 0, sizeof(sUsbState));
|
||||
|
||||
@@ -331,7 +312,7 @@ void nrf5UartInit(void)
|
||||
assert(ret == NRF_SUCCESS);
|
||||
|
||||
app_usbd_class_inst_t const *cdcAcmInstance = app_usbd_cdc_acm_class_inst_get(&sAppCdcAcm);
|
||||
ret = app_usbd_class_append(cdcAcmInstance);
|
||||
ret = app_usbd_class_append(cdcAcmInstance);
|
||||
assert(ret == NRF_SUCCESS);
|
||||
|
||||
ret = nrf_drv_power_usbevt_init(&powerConfig);
|
||||
@@ -344,7 +325,9 @@ void nrf5UartDeinit(void)
|
||||
{
|
||||
app_usbd_stop();
|
||||
|
||||
while (app_usbd_event_queue_process()) { }
|
||||
while (app_usbd_event_queue_process())
|
||||
{
|
||||
}
|
||||
}
|
||||
else if (nrf_drv_usbd_is_enabled())
|
||||
{
|
||||
@@ -361,7 +344,9 @@ void nrf5UartDeinit(void)
|
||||
|
||||
void nrf5UartProcess(void)
|
||||
{
|
||||
while (app_usbd_event_queue_process()) { }
|
||||
while (app_usbd_event_queue_process())
|
||||
{
|
||||
}
|
||||
|
||||
processConnection();
|
||||
processReceive();
|
||||
@@ -393,7 +378,7 @@ otError otPlatUartSend(const uint8_t *aBuf, uint16_t aBufLength)
|
||||
{
|
||||
// If port is closed, queue the message until it can be sent.
|
||||
sUsbState.mTxBuffer = aBuf;
|
||||
sUsbState.mTxSize = aBufLength;
|
||||
sUsbState.mTxSize = aBufLength;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -68,7 +68,7 @@ void PlatformProcessDrivers(otInstance *aInstance);
|
||||
extern void PlatformEventSignalPending(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // end of extern "C"
|
||||
} // end of extern "C"
|
||||
#endif
|
||||
|
||||
#endif // PLATFORM_H_
|
||||
#endif // PLATFORM_H_
|
||||
|
||||
@@ -38,17 +38,17 @@
|
||||
#include <openthread/platform/alarm-milli.h>
|
||||
#include <openthread/platform/diag.h>
|
||||
|
||||
#define MS_PER_S 1000
|
||||
#define MS_PER_S 1000
|
||||
#define US_PER_MS 1000
|
||||
#define US_PER_S 1000000
|
||||
#define US_PER_S 1000000
|
||||
|
||||
#define DEFAULT_TIMEOUT 10 // seconds
|
||||
#define DEFAULT_TIMEOUT 10 // seconds
|
||||
|
||||
static bool sIsMsRunning = false;
|
||||
static uint32_t sMsAlarm = 0;
|
||||
static bool sIsMsRunning = false;
|
||||
static uint32_t sMsAlarm = 0;
|
||||
|
||||
static bool sIsUsRunning = false;
|
||||
static uint32_t sUsAlarm = 0;
|
||||
static bool sIsUsRunning = false;
|
||||
static uint32_t sUsAlarm = 0;
|
||||
|
||||
static struct timeval sStart;
|
||||
|
||||
@@ -70,7 +70,7 @@ uint32_t otPlatAlarmMilliGetNow(void)
|
||||
void otPlatAlarmMilliStartAt(otInstance *aInstance, uint32_t aT0, uint32_t aDt)
|
||||
{
|
||||
(void)aInstance;
|
||||
sMsAlarm = aT0 + aDt;
|
||||
sMsAlarm = aT0 + aDt;
|
||||
sIsMsRunning = true;
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ uint32_t otPlatAlarmMicroGetNow(void)
|
||||
void otPlatAlarmMicroStartAt(otInstance *aInstance, uint32_t aT0, uint32_t aDt)
|
||||
{
|
||||
(void)aInstance;
|
||||
sUsAlarm = aT0 + aDt;
|
||||
sUsAlarm = aT0 + aDt;
|
||||
sIsUsRunning = true;
|
||||
}
|
||||
|
||||
@@ -125,17 +125,17 @@ void platformAlarmUpdateTimeout(struct timeval *aTimeout)
|
||||
|
||||
if (usRemaining <= 0 || msRemaining <= 0)
|
||||
{
|
||||
aTimeout->tv_sec = 0;
|
||||
aTimeout->tv_sec = 0;
|
||||
aTimeout->tv_usec = 0;
|
||||
}
|
||||
else if (msRemaining * US_PER_MS < usRemaining)
|
||||
{
|
||||
aTimeout->tv_sec = msRemaining / MS_PER_S;
|
||||
aTimeout->tv_sec = msRemaining / MS_PER_S;
|
||||
aTimeout->tv_usec = (msRemaining % MS_PER_S) * US_PER_MS;
|
||||
}
|
||||
else
|
||||
{
|
||||
aTimeout->tv_sec = usRemaining / US_PER_S;
|
||||
aTimeout->tv_sec = usRemaining / US_PER_S;
|
||||
aTimeout->tv_usec = usRemaining % US_PER_S;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,21 +41,21 @@
|
||||
#include "utils/flash.h"
|
||||
|
||||
static int sFlashFd = -1;
|
||||
uint32_t sEraseAddress;
|
||||
uint32_t sEraseAddress;
|
||||
|
||||
enum
|
||||
{
|
||||
FLASH_SIZE = 0x40000,
|
||||
FLASH_SIZE = 0x40000,
|
||||
FLASH_PAGE_SIZE = 0x800,
|
||||
FLASH_PAGE_NUM = 128,
|
||||
FLASH_PAGE_NUM = 128,
|
||||
};
|
||||
|
||||
otError utilsFlashInit(void)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
char fileName[20];
|
||||
otError error = OT_ERROR_NONE;
|
||||
char fileName[20];
|
||||
struct stat st;
|
||||
bool create = false;
|
||||
bool create = false;
|
||||
const char *offset = getenv("PORT_OFFSET");
|
||||
|
||||
memset(&st, 0, sizeof(st));
|
||||
@@ -102,9 +102,9 @@ uint32_t utilsFlashGetSize(void)
|
||||
|
||||
otError utilsFlashErasePage(uint32_t aAddress)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint32_t address;
|
||||
uint8_t dummyPage[ FLASH_SIZE ];
|
||||
uint8_t dummyPage[FLASH_SIZE];
|
||||
|
||||
otEXPECT_ACTION(sFlashFd >= 0, error = OT_ERROR_FAILED);
|
||||
otEXPECT_ACTION(aAddress < FLASH_SIZE, error = OT_ERROR_INVALID_ARGS);
|
||||
@@ -117,10 +117,9 @@ otError utilsFlashErasePage(uint32_t aAddress)
|
||||
|
||||
// Write the page
|
||||
ssize_t r;
|
||||
r = pwrite(sFlashFd, &(dummyPage[0]), FLASH_PAGE_SIZE, (off_t)address);
|
||||
r = pwrite(sFlashFd, &(dummyPage[0]), FLASH_PAGE_SIZE, (off_t)address);
|
||||
otEXPECT_ACTION(((int)r) == ((int)(FLASH_PAGE_SIZE)), error = OT_ERROR_FAILED);
|
||||
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
@@ -133,9 +132,9 @@ otError utilsFlashStatusWait(uint32_t aTimeout)
|
||||
|
||||
uint32_t utilsFlashWrite(uint32_t aAddress, uint8_t *aData, uint32_t aSize)
|
||||
{
|
||||
uint32_t ret = 0;
|
||||
uint32_t ret = 0;
|
||||
uint32_t index = 0;
|
||||
uint8_t byte;
|
||||
uint8_t byte;
|
||||
|
||||
otEXPECT(sFlashFd >= 0 && aAddress < FLASH_SIZE);
|
||||
|
||||
|
||||
@@ -26,15 +26,15 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <openthread/config.h>
|
||||
#include <openthread-core-config.h>
|
||||
#include "platform-posix.h"
|
||||
#include <openthread-core-config.h>
|
||||
#include <openthread/config.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
@@ -47,20 +47,19 @@
|
||||
|
||||
// Macro to append content to end of the log string.
|
||||
|
||||
#define LOG_PRINTF(...) \
|
||||
charsWritten = snprintf(&logString[offset], sizeof(logString) - offset , __VA_ARGS__); \
|
||||
otEXPECT_ACTION(charsWritten >= 0, logString[offset] = 0); \
|
||||
offset += (unsigned int)charsWritten; \
|
||||
otEXPECT_ACTION(offset < sizeof(logString), logString[sizeof(logString) -1 ] = 0)
|
||||
|
||||
#define LOG_PRINTF(...) \
|
||||
charsWritten = snprintf(&logString[offset], sizeof(logString) - offset, __VA_ARGS__); \
|
||||
otEXPECT_ACTION(charsWritten >= 0, logString[offset] = 0); \
|
||||
offset += (unsigned int)charsWritten; \
|
||||
otEXPECT_ACTION(offset < sizeof(logString), logString[sizeof(logString) - 1] = 0)
|
||||
|
||||
#if (OPENTHREAD_CONFIG_LOG_OUTPUT == OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED)
|
||||
void otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, ...)
|
||||
{
|
||||
char logString[512];
|
||||
char logString[512];
|
||||
unsigned int offset;
|
||||
int charsWritten;
|
||||
va_list args;
|
||||
int charsWritten;
|
||||
va_list args;
|
||||
|
||||
offset = 0;
|
||||
|
||||
|
||||
@@ -38,8 +38,8 @@
|
||||
#include "platform.h"
|
||||
|
||||
#ifndef _WIN32
|
||||
extern int gArgumentsCount;
|
||||
extern char **gArguments;
|
||||
extern int gArgumentsCount;
|
||||
extern char **gArguments;
|
||||
#endif
|
||||
|
||||
void otPlatReset(otInstance *aInstance)
|
||||
@@ -63,7 +63,7 @@ void otPlatReset(otInstance *aInstance)
|
||||
perror("reset failed");
|
||||
exit(EXIT_FAILURE);
|
||||
#else
|
||||
// This function does nothing on the Windows platform.
|
||||
// This function does nothing on the Windows platform.
|
||||
#endif // _WIN32
|
||||
(void)aInstance;
|
||||
}
|
||||
|
||||
@@ -35,18 +35,18 @@
|
||||
#ifndef PLATFORM_POSIX_H_
|
||||
#define PLATFORM_POSIX_H_
|
||||
|
||||
#include <openthread/config.h>
|
||||
#include <openthread-core-config.h>
|
||||
#include <openthread/config.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#if _WIN32
|
||||
#include <WinSock2.h>
|
||||
#include <WS2tcpip.h>
|
||||
#include <WinSock2.h>
|
||||
#include <windows.h>
|
||||
#define POLL WSAPoll
|
||||
#define ssize_t int
|
||||
@@ -56,13 +56,13 @@
|
||||
__forceinline int gettimeofday(struct timeval *tv, struct timezone *tz)
|
||||
{
|
||||
(void)tz;
|
||||
tv->tv_sec = _time32(NULL);
|
||||
tv->tv_sec = _time32(NULL);
|
||||
tv->tv_usec = 0;
|
||||
return 0;
|
||||
}
|
||||
__forceinline void timersub(struct timeval *a, struct timeval *b, struct timeval *res)
|
||||
{
|
||||
res->tv_sec = (long)_difftime32(a->tv_sec, b->tv_sec);
|
||||
res->tv_sec = (long)_difftime32(a->tv_sec, b->tv_sec);
|
||||
res->tv_usec = 0;
|
||||
}
|
||||
#else
|
||||
@@ -93,9 +93,9 @@ OT_TOOL_PACKED_BEGIN
|
||||
struct Event
|
||||
{
|
||||
uint64_t mDelay;
|
||||
uint8_t mEvent;
|
||||
uint8_t mEvent;
|
||||
uint16_t mDataLength;
|
||||
uint8_t mData[OT_EVENT_DATA_MAX_SIZE];
|
||||
uint8_t mData[OT_EVENT_DATA_MAX_SIZE];
|
||||
} OT_TOOL_PACKED_END;
|
||||
|
||||
/**
|
||||
@@ -224,4 +224,4 @@ void platformUartProcess(void);
|
||||
*/
|
||||
void platformUartRestore(void);
|
||||
|
||||
#endif // PLATFORM_POSIX_H_
|
||||
#endif // PLATFORM_POSIX_H_
|
||||
|
||||
@@ -52,12 +52,12 @@
|
||||
#include <openthread/tasklet.h>
|
||||
#include <openthread/platform/alarm-milli.h>
|
||||
|
||||
uint32_t NODE_ID = 1;
|
||||
uint32_t NODE_ID = 1;
|
||||
uint32_t WELLKNOWN_NODE_ID = 34;
|
||||
|
||||
#ifndef _WIN32
|
||||
int gArgumentsCount = 0;
|
||||
char **gArguments = NULL;
|
||||
int gArgumentsCount = 0;
|
||||
char **gArguments = NULL;
|
||||
#endif
|
||||
|
||||
void PlatformInit(int argc, char *argv[])
|
||||
@@ -74,7 +74,7 @@ void PlatformInit(int argc, char *argv[])
|
||||
setlogmask(setlogmask(0) & LOG_UPTO(LOG_NOTICE));
|
||||
|
||||
gArgumentsCount = argc;
|
||||
gArguments = argv;
|
||||
gArguments = argv;
|
||||
#endif
|
||||
|
||||
NODE_ID = (uint32_t)strtol(argv[1], &endptr, 0);
|
||||
@@ -97,12 +97,12 @@ void PlatformDeinit(void)
|
||||
|
||||
void PlatformProcessDrivers(otInstance *aInstance)
|
||||
{
|
||||
fd_set read_fds;
|
||||
fd_set write_fds;
|
||||
fd_set error_fds;
|
||||
int max_fd = -1;
|
||||
fd_set read_fds;
|
||||
fd_set write_fds;
|
||||
fd_set error_fds;
|
||||
int max_fd = -1;
|
||||
struct timeval timeout;
|
||||
int rval;
|
||||
int rval;
|
||||
|
||||
FD_ZERO(&read_fds);
|
||||
FD_ZERO(&write_fds);
|
||||
|
||||
@@ -38,49 +38,49 @@
|
||||
|
||||
enum
|
||||
{
|
||||
IEEE802154_MIN_LENGTH = 5,
|
||||
IEEE802154_MAX_LENGTH = 127,
|
||||
IEEE802154_ACK_LENGTH = 5,
|
||||
IEEE802154_MIN_LENGTH = 5,
|
||||
IEEE802154_MAX_LENGTH = 127,
|
||||
IEEE802154_ACK_LENGTH = 5,
|
||||
|
||||
IEEE802154_BROADCAST = 0xffff,
|
||||
IEEE802154_BROADCAST = 0xffff,
|
||||
|
||||
IEEE802154_FRAME_TYPE_ACK = 2 << 0,
|
||||
IEEE802154_FRAME_TYPE_MACCMD = 3 << 0,
|
||||
IEEE802154_FRAME_TYPE_MASK = 7 << 0,
|
||||
IEEE802154_FRAME_TYPE_ACK = 2 << 0,
|
||||
IEEE802154_FRAME_TYPE_MACCMD = 3 << 0,
|
||||
IEEE802154_FRAME_TYPE_MASK = 7 << 0,
|
||||
|
||||
IEEE802154_SECURITY_ENABLED = 1 << 3,
|
||||
IEEE802154_FRAME_PENDING = 1 << 4,
|
||||
IEEE802154_ACK_REQUEST = 1 << 5,
|
||||
IEEE802154_PANID_COMPRESSION = 1 << 6,
|
||||
IEEE802154_SECURITY_ENABLED = 1 << 3,
|
||||
IEEE802154_FRAME_PENDING = 1 << 4,
|
||||
IEEE802154_ACK_REQUEST = 1 << 5,
|
||||
IEEE802154_PANID_COMPRESSION = 1 << 6,
|
||||
|
||||
IEEE802154_DST_ADDR_NONE = 0 << 2,
|
||||
IEEE802154_DST_ADDR_SHORT = 2 << 2,
|
||||
IEEE802154_DST_ADDR_EXT = 3 << 2,
|
||||
IEEE802154_DST_ADDR_MASK = 3 << 2,
|
||||
IEEE802154_DST_ADDR_NONE = 0 << 2,
|
||||
IEEE802154_DST_ADDR_SHORT = 2 << 2,
|
||||
IEEE802154_DST_ADDR_EXT = 3 << 2,
|
||||
IEEE802154_DST_ADDR_MASK = 3 << 2,
|
||||
|
||||
IEEE802154_SRC_ADDR_NONE = 0 << 6,
|
||||
IEEE802154_SRC_ADDR_SHORT = 2 << 6,
|
||||
IEEE802154_SRC_ADDR_EXT = 3 << 6,
|
||||
IEEE802154_SRC_ADDR_MASK = 3 << 6,
|
||||
IEEE802154_SRC_ADDR_NONE = 0 << 6,
|
||||
IEEE802154_SRC_ADDR_SHORT = 2 << 6,
|
||||
IEEE802154_SRC_ADDR_EXT = 3 << 6,
|
||||
IEEE802154_SRC_ADDR_MASK = 3 << 6,
|
||||
|
||||
IEEE802154_DSN_OFFSET = 2,
|
||||
IEEE802154_DSTPAN_OFFSET = 3,
|
||||
IEEE802154_DSTADDR_OFFSET = 5,
|
||||
IEEE802154_DSN_OFFSET = 2,
|
||||
IEEE802154_DSTPAN_OFFSET = 3,
|
||||
IEEE802154_DSTADDR_OFFSET = 5,
|
||||
|
||||
IEEE802154_SEC_LEVEL_MASK = 7 << 0,
|
||||
IEEE802154_SEC_LEVEL_MASK = 7 << 0,
|
||||
|
||||
IEEE802154_KEY_ID_MODE_0 = 0 << 3,
|
||||
IEEE802154_KEY_ID_MODE_1 = 1 << 3,
|
||||
IEEE802154_KEY_ID_MODE_2 = 2 << 3,
|
||||
IEEE802154_KEY_ID_MODE_3 = 3 << 3,
|
||||
IEEE802154_KEY_ID_MODE_MASK = 3 << 3,
|
||||
IEEE802154_KEY_ID_MODE_0 = 0 << 3,
|
||||
IEEE802154_KEY_ID_MODE_1 = 1 << 3,
|
||||
IEEE802154_KEY_ID_MODE_2 = 2 << 3,
|
||||
IEEE802154_KEY_ID_MODE_3 = 3 << 3,
|
||||
IEEE802154_KEY_ID_MODE_MASK = 3 << 3,
|
||||
|
||||
IEEE802154_MACCMD_DATA_REQ = 4,
|
||||
IEEE802154_MACCMD_DATA_REQ = 4,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
POSIX_RECEIVE_SENSITIVITY = -100, // dBm
|
||||
POSIX_RECEIVE_SENSITIVITY = -100, // dBm
|
||||
POSIX_MAX_SRC_MATCH_ENTRIES = OPENTHREAD_CONFIG_MAX_CHILDREN,
|
||||
};
|
||||
|
||||
@@ -96,27 +96,27 @@ static void radioSendMessage(otInstance *aInstance);
|
||||
static void radioSendAck(void);
|
||||
static void radioProcessFrame(otInstance *aInstance);
|
||||
|
||||
static otRadioState sState = OT_RADIO_STATE_DISABLED;
|
||||
static otRadioState sState = OT_RADIO_STATE_DISABLED;
|
||||
static struct RadioMessage sReceiveMessage;
|
||||
static struct RadioMessage sTransmitMessage;
|
||||
static struct RadioMessage sAckMessage;
|
||||
static otRadioFrame sReceiveFrame;
|
||||
static otRadioFrame sTransmitFrame;
|
||||
static otRadioFrame sAckFrame;
|
||||
static otRadioFrame sReceiveFrame;
|
||||
static otRadioFrame sTransmitFrame;
|
||||
static otRadioFrame sAckFrame;
|
||||
|
||||
static uint8_t sExtendedAddress[OT_EXT_ADDRESS_SIZE];
|
||||
static uint8_t sExtendedAddress[OT_EXT_ADDRESS_SIZE];
|
||||
static uint16_t sShortAddress;
|
||||
static uint16_t sPanid;
|
||||
static uint16_t sPortOffset = 0;
|
||||
static int sSockFd;
|
||||
static bool sPromiscuous = false;
|
||||
static bool sAckWait = false;
|
||||
static int sSockFd;
|
||||
static bool sPromiscuous = false;
|
||||
static bool sAckWait = false;
|
||||
|
||||
static uint8_t sShortAddressMatchTableCount = 0;
|
||||
static uint8_t sExtAddressMatchTableCount = 0;
|
||||
static uint16_t sShortAddressMatchTable[POSIX_MAX_SRC_MATCH_ENTRIES];
|
||||
static uint8_t sShortAddressMatchTableCount = 0;
|
||||
static uint8_t sExtAddressMatchTableCount = 0;
|
||||
static uint16_t sShortAddressMatchTable[POSIX_MAX_SRC_MATCH_ENTRIES];
|
||||
static otExtAddress sExtAddressMatchTable[POSIX_MAX_SRC_MATCH_ENTRIES];
|
||||
static bool sSrcMatchEnabled = false;
|
||||
static bool sSrcMatchEnabled = false;
|
||||
|
||||
static bool findShortAddress(uint16_t aShortAddress)
|
||||
{
|
||||
@@ -176,9 +176,9 @@ static inline bool isPanIdCompressed(const uint8_t *frame)
|
||||
static inline bool isDataRequestAndHasFramePending(const uint8_t *frame)
|
||||
{
|
||||
const uint8_t *cur = frame;
|
||||
uint8_t securityControl;
|
||||
bool isDataRequest = false;
|
||||
bool hasFramePending = false;
|
||||
uint8_t securityControl;
|
||||
bool isDataRequest = false;
|
||||
bool hasFramePending = false;
|
||||
|
||||
// FCF + DSN
|
||||
cur += 2 + 1;
|
||||
@@ -302,41 +302,26 @@ static uint16_t crc16_citt(uint16_t aFcs, uint8_t aByte)
|
||||
// CRC-16/CCITT, CRC-16/CCITT-TRUE, CRC-CCITT
|
||||
// width=16 poly=0x1021 init=0x0000 refin=true refout=true xorout=0x0000 check=0x2189 name="KERMIT"
|
||||
// http://reveng.sourceforge.net/crc-catalogue/16.htm#crc.cat.kermit
|
||||
static const uint16_t sFcsTable[256] =
|
||||
{
|
||||
0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf,
|
||||
0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7,
|
||||
0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e,
|
||||
0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876,
|
||||
0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd,
|
||||
0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5,
|
||||
0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c,
|
||||
0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974,
|
||||
0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb,
|
||||
0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3,
|
||||
0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a,
|
||||
0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72,
|
||||
0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9,
|
||||
0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1,
|
||||
0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738,
|
||||
0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70,
|
||||
0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7,
|
||||
0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff,
|
||||
0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036,
|
||||
0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e,
|
||||
0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5,
|
||||
0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd,
|
||||
0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134,
|
||||
0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c,
|
||||
0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3,
|
||||
0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb,
|
||||
0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232,
|
||||
0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a,
|
||||
0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1,
|
||||
0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9,
|
||||
0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330,
|
||||
0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78
|
||||
};
|
||||
static const uint16_t sFcsTable[256] = {
|
||||
0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf, 0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5,
|
||||
0xe97e, 0xf8f7, 0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e, 0x9cc9, 0x8d40, 0xbfdb, 0xae52,
|
||||
0xdaed, 0xcb64, 0xf9ff, 0xe876, 0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd, 0xad4a, 0xbcc3,
|
||||
0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5, 0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c,
|
||||
0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974, 0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9,
|
||||
0x2732, 0x36bb, 0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3, 0x5285, 0x430c, 0x7197, 0x601e,
|
||||
0x14a1, 0x0528, 0x37b3, 0x263a, 0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72, 0x6306, 0x728f,
|
||||
0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9, 0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1,
|
||||
0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738, 0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862,
|
||||
0x9af9, 0x8b70, 0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7, 0x0840, 0x19c9, 0x2b52, 0x3adb,
|
||||
0x4e64, 0x5fed, 0x6d76, 0x7cff, 0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036, 0x18c1, 0x0948,
|
||||
0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e, 0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5,
|
||||
0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd, 0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226,
|
||||
0xd0bd, 0xc134, 0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c, 0xc60c, 0xd785, 0xe51e, 0xf497,
|
||||
0x8028, 0x91a1, 0xa33a, 0xb2b3, 0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb, 0xd68d, 0xc704,
|
||||
0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232, 0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a,
|
||||
0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1, 0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb,
|
||||
0x0e70, 0x1ff9, 0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330, 0x7bc7, 0x6a4e, 0x58d5, 0x495c,
|
||||
0x3de3, 0x2c6a, 0x1ef1, 0x0f78};
|
||||
return (aFcs >> 8) ^ sFcsTable[(aFcs ^ aByte) & 0xff];
|
||||
}
|
||||
|
||||
@@ -384,7 +369,7 @@ void otPlatRadioSetPromiscuous(otInstance *aInstance, bool aEnable)
|
||||
void platformRadioInit(void)
|
||||
{
|
||||
struct sockaddr_in sockaddr;
|
||||
char *offset;
|
||||
char * offset;
|
||||
memset(&sockaddr, 0, sizeof(sockaddr));
|
||||
sockaddr.sin_family = AF_INET;
|
||||
|
||||
@@ -430,9 +415,9 @@ void platformRadioInit(void)
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
sReceiveFrame.mPsdu = sReceiveMessage.mPsdu;
|
||||
sReceiveFrame.mPsdu = sReceiveMessage.mPsdu;
|
||||
sTransmitFrame.mPsdu = sTransmitMessage.mPsdu;
|
||||
sAckFrame.mPsdu = sAckMessage.mPsdu;
|
||||
sAckFrame.mPsdu = sAckMessage.mPsdu;
|
||||
}
|
||||
|
||||
void platformRadioDeinit(void)
|
||||
@@ -473,7 +458,7 @@ otError otPlatRadioSleep(otInstance *aInstance)
|
||||
|
||||
if (sState == OT_RADIO_STATE_SLEEP || sState == OT_RADIO_STATE_RECEIVE)
|
||||
{
|
||||
error = OT_ERROR_NONE;
|
||||
error = OT_ERROR_NONE;
|
||||
sState = OT_RADIO_STATE_SLEEP;
|
||||
}
|
||||
|
||||
@@ -487,9 +472,9 @@ otError otPlatRadioReceive(otInstance *aInstance, uint8_t aChannel)
|
||||
|
||||
if (sState != OT_RADIO_STATE_DISABLED)
|
||||
{
|
||||
error = OT_ERROR_NONE;
|
||||
sState = OT_RADIO_STATE_RECEIVE;
|
||||
sAckWait = false;
|
||||
error = OT_ERROR_NONE;
|
||||
sState = OT_RADIO_STATE_RECEIVE;
|
||||
sAckWait = false;
|
||||
sReceiveFrame.mChannel = aChannel;
|
||||
}
|
||||
|
||||
@@ -504,7 +489,7 @@ otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aRadio)
|
||||
|
||||
if (sState == OT_RADIO_STATE_RECEIVE)
|
||||
{
|
||||
error = OT_ERROR_NONE;
|
||||
error = OT_ERROR_NONE;
|
||||
sState = OT_RADIO_STATE_TRANSMIT;
|
||||
}
|
||||
|
||||
@@ -548,17 +533,15 @@ void radioReceive(otInstance *aInstance)
|
||||
#if OPENTHREAD_ENABLE_RAW_LINK_API
|
||||
// Timestamp
|
||||
sReceiveFrame.mMsec = otPlatAlarmMilliGetNow();
|
||||
sReceiveFrame.mUsec = 0; // Don't support microsecond timer for now.
|
||||
sReceiveFrame.mUsec = 0; // Don't support microsecond timer for now.
|
||||
#endif
|
||||
|
||||
sReceiveFrame.mLength = (uint8_t)(rval - 1);
|
||||
|
||||
if (sAckWait &&
|
||||
sTransmitFrame.mChannel == sReceiveMessage.mChannel &&
|
||||
isFrameTypeAck(sReceiveFrame.mPsdu) &&
|
||||
if (sAckWait && sTransmitFrame.mChannel == sReceiveMessage.mChannel && isFrameTypeAck(sReceiveFrame.mPsdu) &&
|
||||
getDsn(sReceiveFrame.mPsdu) == getDsn(sTransmitFrame.mPsdu))
|
||||
{
|
||||
sState = OT_RADIO_STATE_RECEIVE;
|
||||
sState = OT_RADIO_STATE_RECEIVE;
|
||||
sAckWait = false;
|
||||
|
||||
otPlatRadioTxDone(aInstance, &sTransmitFrame, &sReceiveFrame, OT_ERROR_NONE);
|
||||
@@ -622,8 +605,8 @@ void platformRadioUpdateFdSet(fd_set *aReadFdSet, fd_set *aWriteFdSet, int *aMax
|
||||
|
||||
void platformRadioProcess(otInstance *aInstance)
|
||||
{
|
||||
const int flags = POLLIN | POLLRDNORM | POLLERR | POLLNVAL | POLLHUP;
|
||||
struct pollfd pollfd = { sSockFd, flags, 0 };
|
||||
const int flags = POLLIN | POLLRDNORM | POLLERR | POLLNVAL | POLLHUP;
|
||||
struct pollfd pollfd = {sSockFd, flags, 0};
|
||||
|
||||
if (POLL(&pollfd, 1, 0) > 0 && (pollfd.revents & flags) != 0)
|
||||
{
|
||||
@@ -638,10 +621,10 @@ void platformRadioProcess(otInstance *aInstance)
|
||||
|
||||
void radioTransmit(struct RadioMessage *aMessage, const struct otRadioFrame *aFrame)
|
||||
{
|
||||
uint32_t i;
|
||||
uint32_t i;
|
||||
struct sockaddr_in sockaddr;
|
||||
|
||||
uint16_t crc = 0;
|
||||
uint16_t crc = 0;
|
||||
uint16_t crc_offset = aFrame->mLength - sizeof(uint16_t);
|
||||
|
||||
for (i = 0; i < crc_offset; i++)
|
||||
@@ -649,7 +632,7 @@ void radioTransmit(struct RadioMessage *aMessage, const struct otRadioFrame *aFr
|
||||
crc = crc16_citt(crc, aMessage->mPsdu[i]);
|
||||
}
|
||||
|
||||
aMessage->mPsdu[crc_offset] = crc & 0xff;
|
||||
aMessage->mPsdu[crc_offset] = crc & 0xff;
|
||||
aMessage->mPsdu[crc_offset + 1] = crc >> 8;
|
||||
|
||||
memset(&sockaddr, 0, sizeof(sockaddr));
|
||||
@@ -666,8 +649,8 @@ void radioTransmit(struct RadioMessage *aMessage, const struct otRadioFrame *aFr
|
||||
}
|
||||
|
||||
sockaddr.sin_port = htons(9000 + sPortOffset + i);
|
||||
rval = sendto(sSockFd, (const char *)aMessage, 1 + aFrame->mLength,
|
||||
0, (struct sockaddr *)&sockaddr, sizeof(sockaddr));
|
||||
rval = sendto(sSockFd, (const char *)aMessage, 1 + aFrame->mLength, 0, (struct sockaddr *)&sockaddr,
|
||||
sizeof(sockaddr));
|
||||
|
||||
if (rval < 0)
|
||||
{
|
||||
@@ -679,7 +662,7 @@ void radioTransmit(struct RadioMessage *aMessage, const struct otRadioFrame *aFr
|
||||
|
||||
void radioSendAck(void)
|
||||
{
|
||||
sAckFrame.mLength = IEEE802154_ACK_LENGTH;
|
||||
sAckFrame.mLength = IEEE802154_ACK_LENGTH;
|
||||
sAckMessage.mPsdu[0] = IEEE802154_FRAME_TYPE_ACK;
|
||||
|
||||
if (isDataRequestAndHasFramePending(sReceiveFrame.mPsdu))
|
||||
@@ -697,10 +680,10 @@ void radioSendAck(void)
|
||||
|
||||
void radioProcessFrame(otInstance *aInstance)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otPanId dstpan;
|
||||
otError error = OT_ERROR_NONE;
|
||||
otPanId dstpan;
|
||||
otShortAddress short_address;
|
||||
otExtAddress ext_address;
|
||||
otExtAddress ext_address;
|
||||
|
||||
otEXPECT_ACTION(sPromiscuous == false, error = OT_ERROR_NONE);
|
||||
|
||||
@@ -710,10 +693,10 @@ void radioProcessFrame(otInstance *aInstance)
|
||||
break;
|
||||
|
||||
case IEEE802154_DST_ADDR_SHORT:
|
||||
dstpan = getDstPan(sReceiveFrame.mPsdu);
|
||||
dstpan = getDstPan(sReceiveFrame.mPsdu);
|
||||
short_address = getShortAddress(sReceiveFrame.mPsdu);
|
||||
otEXPECT_ACTION((dstpan == IEEE802154_BROADCAST || dstpan == sPanid) &&
|
||||
(short_address == IEEE802154_BROADCAST || short_address == sShortAddress),
|
||||
(short_address == IEEE802154_BROADCAST || short_address == sShortAddress),
|
||||
error = OT_ERROR_ABORT);
|
||||
break;
|
||||
|
||||
@@ -721,7 +704,7 @@ void radioProcessFrame(otInstance *aInstance)
|
||||
dstpan = getDstPan(sReceiveFrame.mPsdu);
|
||||
getExtAddress(sReceiveFrame.mPsdu, &ext_address);
|
||||
otEXPECT_ACTION((dstpan == IEEE802154_BROADCAST || dstpan == sPanid) &&
|
||||
memcmp(&ext_address, sExtendedAddress, sizeof(ext_address)) == 0,
|
||||
memcmp(&ext_address, sExtendedAddress, sizeof(ext_address)) == 0,
|
||||
error = OT_ERROR_ABORT);
|
||||
break;
|
||||
|
||||
@@ -731,7 +714,7 @@ void radioProcessFrame(otInstance *aInstance)
|
||||
}
|
||||
|
||||
sReceiveFrame.mRssi = -20;
|
||||
sReceiveFrame.mLqi = OT_RADIO_LQI_NONE;
|
||||
sReceiveFrame.mLqi = OT_RADIO_LQI_NONE;
|
||||
|
||||
// generate acknowledgment
|
||||
if (isAckRequested(sReceiveFrame.mPsdu))
|
||||
@@ -808,7 +791,7 @@ otError otPlatRadioClearSrcMatchShortEntry(otInstance *aInstance, const uint16_t
|
||||
if (sShortAddressMatchTable[i] == aShortAddress)
|
||||
{
|
||||
sShortAddressMatchTable[i] = sShortAddressMatchTable[--sShortAddressMatchTableCount];
|
||||
error = OT_ERROR_NONE;
|
||||
error = OT_ERROR_NONE;
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
@@ -829,7 +812,7 @@ otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const otExtAddre
|
||||
if (!memcmp(&sExtAddressMatchTable[i], aExtAddress, sizeof(otExtAddress)))
|
||||
{
|
||||
sExtAddressMatchTable[i] = sExtAddressMatchTable[--sExtAddressMatchTableCount];
|
||||
error = OT_ERROR_NONE;
|
||||
error = OT_ERROR_NONE;
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user