[examples] change example platform namespacing (#2927)

This commit is contained in:
Jonathan Hui
2018-08-03 14:13:47 -05:00
committed by GitHub
parent 1ca81fbb16
commit f0bb0982ee
44 changed files with 169 additions and 133 deletions
+1 -1
View File
@@ -180,8 +180,8 @@ LOCAL_SRC_FILES := \
src/posix/platform/diag.c \
src/posix/platform/misc.c \
src/posix/platform/logging.c \
src/posix/platform/platform.c \
src/posix/platform/random.c \
src/posix/platform/system.c \
src/posix/platform/uart.c \
src/posix/platform/flash.c \
src/posix/platform/spi-stubs.c \
@@ -59,10 +59,10 @@
<ClCompile Include="..\..\examples\platforms\posix\flash-windows-stubs.c" />
<ClCompile Include="..\..\examples\platforms\posix\logging.c" />
<ClCompile Include="..\..\examples\platforms\posix\misc.c" />
<ClCompile Include="..\..\examples\platforms\posix\platform.c" />
<ClCompile Include="..\..\examples\platforms\posix\radio.c" />
<ClCompile Include="..\..\examples\platforms\posix\random.c" />
<ClCompile Include="..\..\examples\platforms\posix\spi-stubs.c" />
<ClCompile Include="..\..\examples\platforms\posix\system.c" />
<ClCompile Include="..\..\examples\platforms\posix\uart-windows.c" />
<ClCompile Include="..\..\examples\platforms\utils\settings_flash.c" />
</ItemGroup>
@@ -22,9 +22,6 @@
<ClCompile Include="..\..\examples\platforms\posix\misc.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\examples\platforms\posix\platform.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\examples\platforms\posix\random.c">
<Filter>Source Files</Filter>
</ClCompile>
@@ -34,6 +31,9 @@
<ClCompile Include="..\..\examples\platforms\posix\spi-stubs.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\examples\platforms\posix\system.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\examples\platforms\posix\uart-windows.c">
<Filter>Source Files</Filter>
</ClCompile>
+4 -4
View File
@@ -35,7 +35,7 @@
#include <openthread/openthread.h>
#include <openthread/platform/logging.h>
#include "platform.h"
#include "openthread-system.h"
#if OPENTHREAD_ENABLE_MULTIPLE_INSTANCES
void *otPlatCAlloc(size_t aNum, size_t aSize)
@@ -65,7 +65,7 @@ int main(int argc, char *argv[])
pseudo_reset:
PlatformInit(argc, argv);
otSysInit(argc, argv);
#if OPENTHREAD_ENABLE_MULTIPLE_INSTANCES
// Call to query the buffer size
@@ -88,10 +88,10 @@ pseudo_reset:
otDiagInit(sInstance);
#endif
while (!PlatformPseudoResetWasRequested())
while (!otSysPseudoResetWasRequested())
{
otTaskletsProcess(sInstance);
PlatformProcessDrivers(sInstance);
otSysProcessDrivers(sInstance);
}
otInstanceFinalize(sInstance);
+4 -4
View File
@@ -34,7 +34,7 @@
#include <openthread/ncp.h>
#include <openthread/openthread.h>
#include "platform.h"
#include "openthread-system.h"
#if OPENTHREAD_ENABLE_MULTIPLE_INSTANCES
void *otPlatCAlloc(size_t aNum, size_t aSize)
@@ -64,7 +64,7 @@ int main(int argc, char *argv[])
pseudo_reset:
PlatformInit(argc, argv);
otSysInit(argc, argv);
#if OPENTHREAD_ENABLE_MULTIPLE_INSTANCES
// Call to query the buffer size
@@ -87,10 +87,10 @@ pseudo_reset:
otDiagInit(sInstance);
#endif
while (!PlatformPseudoResetWasRequested())
while (!otSysPseudoResetWasRequested())
{
otTaskletsProcess(sInstance);
PlatformProcessDrivers(sInstance);
otSysProcessDrivers(sInstance);
}
otInstanceFinalize(sInstance);
+1 -1
View File
@@ -101,7 +101,7 @@ SUBDIRS += samr21
endif
noinst_HEADERS = \
platform.h \
openthread-system.h \
$(NULL)
# Always pretty (e.g. for 'make pretty') these subdirectories.
+1 -1
View File
@@ -51,9 +51,9 @@ PLATFORM_SOURCES
flash.c \
logging.c \
misc.c \
platform.c \
radio.c \
random.c \
system.c \
uart.c \
crypto/aes_alt.c \
cc1352_ccfg.c \
@@ -49,7 +49,7 @@ const char *dummy_ccfg_ref = ((const char *)(&(__ccfg)));
/**
* Function documented in platform-cc1352.h
*/
void PlatformInit(int argc, char *argv[])
void otSysInit(int argc, char *argv[])
{
(void)argc;
(void)argv;
@@ -71,7 +71,7 @@ void PlatformInit(int argc, char *argv[])
cc1352RadioInit();
}
bool PlatformPseudoResetWasRequested(void)
bool otSysPseudoResetWasRequested(void)
{
return false;
}
@@ -79,7 +79,7 @@ bool PlatformPseudoResetWasRequested(void)
/**
* Function documented in platform-cc1352.h
*/
void PlatformProcessDrivers(otInstance *aInstance)
void otSysProcessDrivers(otInstance *aInstance)
{
// should sleep and wait for interrupts here
+1 -1
View File
@@ -41,10 +41,10 @@ PLATFORM_SOURCES = \
diag.c \
flash.c \
misc.c \
platform.c \
radio.c \
random.c \
startup-gcc.c \
system.c \
logging.c \
uart.c \
$(NULL)
@@ -36,7 +36,7 @@
otInstance *sInstance;
void PlatformInit(int argc, char *argv[])
void otSysInit(int argc, char *argv[])
{
#if OPENTHREAD_CONFIG_ENABLE_DEBUG_UART
cc2538DebugUartInit();
@@ -49,12 +49,12 @@ void PlatformInit(int argc, char *argv[])
(void)argv;
}
bool PlatformPseudoResetWasRequested(void)
bool otSysPseudoResetWasRequested(void)
{
return false;
}
void PlatformProcessDrivers(otInstance *aInstance)
void otSysProcessDrivers(otInstance *aInstance)
{
sInstance = aInstance;
+1 -1
View File
@@ -51,9 +51,9 @@ PLATFORM_SOURCES = \
flash.c \
misc.c \
logging.c \
platform.c \
radio.c \
random.c \
system.c \
uart.c \
crypto/sha256_alt.c \
crypto/aes_alt.c \
@@ -38,7 +38,7 @@ void *dummy_ccfg_ref = ((void *)(&(__ccfg)));
/**
* Function documented in platform-cc2650.h
*/
void PlatformInit(int argc, char *argv[])
void otSysInit(int argc, char *argv[])
{
(void)argc;
(void)argv;
@@ -57,7 +57,7 @@ void PlatformInit(int argc, char *argv[])
cc2650RadioInit();
}
bool PlatformPseudoResetWasRequested(void)
bool otSysPseudoResetWasRequested(void)
{
return false;
}
@@ -65,7 +65,7 @@ bool PlatformPseudoResetWasRequested(void)
/**
* Function documented in platform-cc2650.h
*/
void PlatformProcessDrivers(otInstance *aInstance)
void otSysProcessDrivers(otInstance *aInstance)
{
// should sleep and wait for interrupts here
+1 -1
View File
@@ -51,9 +51,9 @@ PLATFORM_SOURCES
flash.c \
logging.c \
misc.c \
platform.c \
radio.c \
random.c \
system.c \
uart.c \
crypto/aes_alt.c \
cc2652_ccfg.c \
@@ -49,7 +49,7 @@ const char *dummy_ccfg_ref = ((const char *)(&(__ccfg)));
/**
* Function documented in platform-cc2652.h
*/
void PlatformInit(int argc, char *argv[])
void otSysInit(int argc, char *argv[])
{
(void)argc;
(void)argv;
@@ -71,7 +71,7 @@ void PlatformInit(int argc, char *argv[])
cc2652RadioInit();
}
bool PlatformPseudoResetWasRequested(void)
bool otSysPseudoResetWasRequested(void)
{
return false;
}
@@ -79,7 +79,7 @@ bool PlatformPseudoResetWasRequested(void)
/**
* Function documented in platform-cc2652.h
*/
void PlatformProcessDrivers(otInstance *aInstance)
void otSysProcessDrivers(otInstance *aInstance)
{
// should sleep and wait for interrupts here
+1 -1
View File
@@ -63,9 +63,9 @@ PLATFORM_SOURCES
flash.c \
logging.c \
misc.c \
platform.c \
radio.c \
random.c \
system.c \
uart.c \
crypto/aes_alt.c \
$(NULL)
@@ -125,7 +125,7 @@ static void ExampleProcess(otInstance *aInstance)
}
}
void PlatformInit(int argc, char *argv[])
void otSysInit(int argc, char *argv[])
{
// Initialize Random number generator
da15000RandomInit();
@@ -138,7 +138,7 @@ void PlatformInit(int argc, char *argv[])
(void)argv;
}
bool PlatformPseudoResetWasRequested(void)
bool otSysPseudoResetWasRequested(void)
{
return false;
}
@@ -280,7 +280,7 @@ static void StateChangedCallback(uint32_t aFlags, void *aContext)
}
#endif // (OPENTHREAD_MTD || OPENTHREAD_FTD) && (OPENTHREAD_ENABLE_COMMISSIONER || OPENTHREAD_ENABLE_JOINER)
void PlatformProcessDrivers(otInstance *aInstance)
void otSysProcessDrivers(otInstance *aInstance)
{
if (sInstance == NULL)
{
+1 -1
View File
@@ -78,10 +78,10 @@ PLATFORM_SOURCES =
flash.c \
logging.c \
misc.c \
platform.c \
radio.c \
random.c \
startup-gcc.c \
system.c \
uart.c \
$(NULL)
+1 -1
View File
@@ -44,7 +44,7 @@
#include "utils/code_utils.h"
#include "em_core.h"
#include "em_system.h"
#include "em_openthread-system.h"
#include "openthread-core-efr32-config.h"
#include "pa_conversions_efr32.h"
#include "rail.h"
@@ -55,7 +55,7 @@ void halInitChipSpecific(void);
otInstance *sInstance;
void PlatformInit(int argc, char *argv[])
void otSysInit(int argc, char *argv[])
{
(void)argc;
(void)argv;
@@ -77,17 +77,17 @@ void PlatformInit(int argc, char *argv[])
efr32RandomInit();
}
bool PlatformPseudoResetWasRequested(void)
bool otSysPseudoResetWasRequested(void)
{
return false;
}
void PlatformDeinit(void)
void otSysDeinit(void)
{
efr32RadioDeinit();
}
void PlatformProcessDrivers(otInstance *aInstance)
void otSysProcessDrivers(otInstance *aInstance)
{
sInstance = aInstance;
+1 -1
View File
@@ -70,9 +70,9 @@ PLATFORM_SOURCES
flash.c \
logging.c \
misc.c \
platform.c \
radio.c \
random.c \
system.c \
uart.c \
platform-emsk.h \
$(NULL)
@@ -40,7 +40,7 @@
#include <stdio.h>
#define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
void PlatformInit(int argc, char *argv[])
void otSysInit(int argc, char *argv[])
{
emskAlarmInit();
emskRadioInit();
@@ -53,12 +53,12 @@ void PlatformInit(int argc, char *argv[])
(void)argv;
}
bool PlatformPseudoResetWasRequested(void)
bool otSysPseudoResetWasRequested(void)
{
return false;
}
void PlatformProcessDrivers(otInstance *aInstance)
void otSysProcessDrivers(otInstance *aInstance)
{
emskUartProcess();
emskRadioProcess(aInstance);
+3 -3
View File
@@ -41,13 +41,13 @@ libopenthread_gp712_a_CPPFLAGS = \
PLATFORM_SOURCES = \
alarm.c \
diag.c \
misc.c \
flash.c \
logging.c \
platform.c \
misc.c \
radio.c \
random.c \
system.c \
uart-posix.c \
flash.c \
$(NULL)
# uart-socket.c \
@@ -64,7 +64,7 @@ bool qorvoPlatGotoSleepCheck(void)
return canGotoSleep;
}
void PlatformInit(int argc, char *argv[])
void otSysInit(int argc, char *argv[])
{
gArgumentsCount = argc;
gArguments = argv;
@@ -76,12 +76,12 @@ void PlatformInit(int argc, char *argv[])
qorvoRadioInit();
}
bool PlatformPseudoResetWasRequested(void)
bool otSysPseudoResetWasRequested(void)
{
return false;
}
void PlatformProcessDrivers(otInstance *aInstance)
void otSysProcessDrivers(otInstance *aInstance)
{
if (localInstance == NULL)
{
+1 -1
View File
@@ -54,9 +54,9 @@ PLATFORM_SOURCES
flash.c \
logging.c \
misc.c \
platform.c \
radio.c \
random.c \
system.c \
uart.c \
$(NULL)
@@ -43,7 +43,7 @@
otInstance *sInstance;
void PlatformInit(int argc, char *argv[])
void otSysInit(int argc, char *argv[])
{
uint32_t temp, tempTrim;
uint8_t revId;
@@ -100,16 +100,16 @@ void PlatformInit(int argc, char *argv[])
(void)argv;
}
bool PlatformPseudoResetWasRequested(void)
bool otSysPseudoResetWasRequested(void)
{
return false;
}
void PlatformDeinit(void)
void otSysDeinit(void)
{
}
void PlatformProcessDrivers(otInstance *aInstance)
void otSysProcessDrivers(otInstance *aInstance)
{
sInstance = aInstance;
kw41zUartProcess();
+1 -1
View File
@@ -81,7 +81,6 @@ PLATFORM_COMMON_SOURCES
flash.c \
logging.c \
misc.c \
platform.c \
platform-config.h \
platform-fem.h \
platform-nrf5.h \
@@ -89,6 +88,7 @@ PLATFORM_COMMON_SOURCES
random.c \
temp.c \
spi-slave.c \
system.c \
uart.c \
usb-cdc-uart.c \
$(NULL)
+2 -2
View File
@@ -45,7 +45,7 @@
#include <openthread/platform/diag.h>
#include <openthread/platform/time.h>
#include "platform.h"
#include "openthread-system.h"
#include "platform-config.h"
#include "platform-nrf5.h"
@@ -217,7 +217,7 @@ static void HandleCompareMatch(AlarmIndex aIndex, bool aSkipCheck)
else
{
sTimerData[aIndex].mFireAlarm = true;
PlatformEventSignalPending();
otSysEventSignalPending();
}
}
}
+3 -3
View File
@@ -49,8 +49,8 @@
#include <openthread/platform/radio.h>
#include <openthread/platform/time.h>
#include "openthread-system.h"
#include "platform-nrf5.h"
#include "platform.h"
#include <nrf.h>
#include <nrf_802154.h>
@@ -147,7 +147,7 @@ static void setPendingEvent(RadioPendingEvents aEvent)
pendingEvents |= bitToSet;
} while (__STREXW(pendingEvents, (unsigned long volatile *)&sPendingEvents));
PlatformEventSignalPending();
otSysEventSignalPending();
}
static void resetPendingEvent(RadioPendingEvents aEvent)
@@ -717,7 +717,7 @@ void nrf_802154_received_raw(uint8_t *p_data, int8_t power, uint8_t lqi)
receivedFrame->mIeInfo->mTimestamp = otPlatTimeGet() - offset;
#endif
PlatformEventSignalPending();
otSysEventSignalPending();
}
void nrf_802154_receive_failed(nrf_802154_rx_error_t error)
@@ -37,8 +37,8 @@
#include <openthread/platform/logging.h>
#include "openthread-system.h"
#include "platform-nrf5.h"
#include "platform.h"
#include <drivers/clock/nrf_drv_clock.h>
#include <nrf.h>
@@ -52,11 +52,11 @@ void __cxa_pure_virtual(void)
;
}
void PlatformInit(int argc, char *argv[])
void otSysInit(int argc, char *argv[])
{
if (gPlatformPseudoResetWasRequested)
{
PlatformDeinit();
otSysDeinit();
}
(void)argc;
@@ -90,7 +90,7 @@ void PlatformInit(int argc, char *argv[])
gPlatformPseudoResetWasRequested = false;
}
void PlatformDeinit(void)
void otSysDeinit(void)
{
nrf5TempDeinit();
nrf5RadioDeinit();
@@ -111,12 +111,12 @@ void PlatformDeinit(void)
#endif
}
bool PlatformPseudoResetWasRequested(void)
bool otSysPseudoResetWasRequested(void)
{
return gPlatformPseudoResetWasRequested;
}
void PlatformProcessDrivers(otInstance *aInstance)
void otSysProcessDrivers(otInstance *aInstance)
{
nrf5AlarmProcess(aInstance);
nrf5RadioProcess(aInstance);
@@ -127,7 +127,7 @@ void PlatformProcessDrivers(otInstance *aInstance)
#endif
}
__WEAK void PlatformEventSignalPending(void)
__WEAK void otSysEventSignalPending(void)
{
// Intentionally empty
}
+3 -3
View File
@@ -43,7 +43,7 @@
#include <openthread/platform/toolchain.h>
#include <openthread/platform/uart.h>
#include "platform.h"
#include "openthread-system.h"
#include "platform-nrf5.h"
#include <drivers/clock/nrf_drv_clock.h>
@@ -290,7 +290,7 @@ void UARTE0_UART0_IRQHandler(void)
{
sReceiveBuffer[sReceiveHead] = byte;
sReceiveHead = (sReceiveHead + 1) % UART_RX_BUFFER_SIZE;
PlatformEventSignalPending();
otSysEventSignalPending();
}
}
@@ -309,7 +309,7 @@ void UARTE0_UART0_IRQHandler(void)
{
sTransmitDone = true;
nrf_uart_task_trigger(UART_INSTANCE, NRF_UART_TASK_STOPTX);
PlatformEventSignalPending();
otSysEventSignalPending();
}
}
}
@@ -29,11 +29,11 @@
/**
* @file
* @brief
* This file defines the platform-specific initializers.
* This file defines the platform-specific functions needed by OpenThread's example applications.
*/
#ifndef PLATFORM_H_
#define PLATFORM_H_
#ifndef OPENTHREAD_SYSTEM_H_
#define OPENTHREAD_SYSTEM_H_
#include <openthread/types.h>
@@ -42,41 +42,59 @@ extern "C" {
#endif
/**
* This function performs all platform-specific initialization.
* This function performs all platform-specific initialization of OpenThread's drivers.
*
* @note This function is not called by the OpenThread library. Instead, the system/RTOS should call this function
* when initialization of OpenThread's drivers is most approriate.
*
* @param[in] argc Number of arguments in @p argv.
* @param[in] argv Argument vector.
*
*/
void PlatformInit(int argc, char *argv[]);
void otSysInit(int argc, char *argv[]);
/**
* This function performs all platform-specific deinitialization.
* This function performs all platform-specific deinitialization for OpenThread's drivers.
*
* @note This function is not called by the OpenThread library. Instead, the system/RTOS should call this function
* when deinitialization of OpenThread's drivers is most appropriate.
*
*/
void PlatformDeinit(void);
void otSysDeinit(void);
/**
* This function returns true is a pseudo-reset was requested.
* In such a case, the main loop should shut down and re-initialize
* the OpenThread instance.
* This function returns true if a pseudo-reset was requested.
*
* In such a case, the main loop should shut down and re-initialize the OpenThread instance.
*
* @note This function is not called by the OpenThread library. Instead, the system/RTOS should call this function
* in the main loop to determine when to shut down and re-initialize the OpenThread instance.
*
*/
bool PlatformPseudoResetWasRequested(void);
bool otSysPseudoResetWasRequested(void);
/**
* This function performs all platform-specific processing.
* This function performs all platform-specific processing for OpenThread's example applications.
*
* @note This function is not called by the OpenThread library. Instead, the system/RTOS should call this function
* in the main loop when processing OpenThread's drivers is most appropriate.
*
* @param[in] aInstance The OpenThread instance structure.
*
*/
void PlatformProcessDrivers(otInstance *aInstance);
void otSysProcessDrivers(otInstance *aInstance);
/**
* This function is called whenever platform drivers needs processing.
*
* @note This function is not handled by the OpenThread library. Instead, the system/RTOS should handle this function
* and schedule a call to `otSysProcessDrivers()`.
*
*/
extern void PlatformEventSignalPending(void);
extern void otSysEventSignalPending(void);
#ifdef __cplusplus
} // end of extern "C"
#endif
#endif // PLATFORM_H_
#endif // OPENTHREAD_SYSTEM_H_
+1 -1
View File
@@ -42,12 +42,12 @@ PLATFORM_SOURCES = \
diag.c \
misc.c \
logging.c \
platform.c \
radio.c \
random.c \
uart-posix.c \
flash.c \
spi-stubs.c \
system.c \
sim/alarm-sim.c \
sim/platform-sim.c \
sim/radio-sim.c \
+2 -2
View File
@@ -35,7 +35,7 @@
#include <openthread/types.h>
#include <openthread/platform/misc.h>
#include "platform.h"
#include "openthread-system.h"
#ifndef _WIN32
extern int gArgumentsCount;
@@ -66,7 +66,7 @@ void otPlatReset(otInstance *aInstance)
argv[gArgumentsCount] = NULL;
PlatformDeinit();
otSysDeinit();
platformUartRestore();
alarm(0);
+4 -4
View File
@@ -168,7 +168,7 @@ static void socket_init(void)
}
}
void PlatformInit(int argc, char *argv[])
void otSysInit(int argc, char *argv[])
{
char *endptr;
@@ -204,17 +204,17 @@ void PlatformInit(int argc, char *argv[])
platformRandomInit();
}
bool PlatformPseudoResetWasRequested(void)
bool otSysPseudoResetWasRequested(void)
{
return gPlatformPseudoResetWasRequested;
}
void PlatformDeinit(void)
void otSysDeinit(void)
{
close(sSockFd);
}
void PlatformProcessDrivers(otInstance *aInstance)
void otSysProcessDrivers(otInstance *aInstance)
{
fd_set read_fds;
fd_set write_fds;
@@ -70,7 +70,7 @@ static void handleSignal(int aSignal)
}
#endif
void PlatformInit(int aArgCount, char *aArgVector[])
void otSysInit(int aArgCount, char *aArgVector[])
{
char * endptr;
uint32_t speedUpFactor = 1;
@@ -122,17 +122,17 @@ void PlatformInit(int aArgCount, char *aArgVector[])
platformRandomInit();
}
bool PlatformPseudoResetWasRequested(void)
bool otSysPseudoResetWasRequested(void)
{
return gPlatformPseudoResetWasRequested;
}
void PlatformDeinit(void)
void otSysDeinit(void)
{
platformRadioDeinit();
}
void PlatformProcessDrivers(otInstance *aInstance)
void otSysProcessDrivers(otInstance *aInstance)
{
fd_set read_fds;
fd_set write_fds;
+1 -1
View File
@@ -102,9 +102,9 @@ PLATFORM_SOURCES
flash.c \
logging.c \
misc.c \
platform.c \
radio.c \
random.c \
system.c \
uart.c \
$(NULL)
+1 -1
View File
@@ -86,4 +86,4 @@ void otPlatDiagAlarmCallback(otInstance *aInstance)
(void)aInstance;
}
#endif // OPENTHREAD_ENABLE_DIAG
#endif // OPENTHREAD_ENABLE_DIAG
@@ -34,7 +34,7 @@
#include "asf.h"
#include "platform.h"
#include "openthread-system.h"
#include "platform-samr21.h"
@@ -160,7 +160,7 @@ void samr21GetIeeeEui64(otInstance *aInstance, uint8_t *aIeeeEui64)
#endif
}
void PlatformInit(int argc, char *argv[])
void otSysInit(int argc, char *argv[])
{
system_clock_init();
@@ -175,16 +175,16 @@ void PlatformInit(int argc, char *argv[])
samr21RadioInit();
}
bool PlatformPseudoResetWasRequested(void)
bool otSysPseudoResetWasRequested(void)
{
return false;
}
void PlatformDeinit(void)
void otSysDeinit(void)
{
}
void PlatformProcessDrivers(otInstance *aInstance)
void otSysProcessDrivers(otInstance *aInstance)
{
sInstance = aInstance;
+4 -4
View File
@@ -45,7 +45,7 @@
#include <openthread/openthread.h>
#include <openthread/platform/logging.h>
#include "platform.h"
#include "openthread-system.h"
void otTaskletsSignalPending(otInstance *aInstance)
{
@@ -58,7 +58,7 @@ int main(int argc, char *argv[])
pseudo_reset:
PlatformInit(argc, argv);
otSysInit(argc, argv);
sInstance = otInstanceInitSingle();
assert(sInstance);
@@ -73,10 +73,10 @@ pseudo_reset:
otDiagInit(sInstance);
#endif
while (!PlatformPseudoResetWasRequested())
while (!otSysPseudoResetWasRequested())
{
otTaskletsProcess(sInstance);
PlatformProcessDrivers(sInstance);
otSysProcessDrivers(sInstance);
}
otInstanceFinalize(sInstance);
+2 -2
View File
@@ -46,19 +46,19 @@ libopenthread_posix_a_SOURCES = \
hdlc.cpp \
logging.c \
misc.c \
platform.c \
radio_spinel.cpp \
random.c \
settings.cpp \
spi-stubs.c \
spinel.c \
system.c \
uart.c \
$(NULL)
noinst_HEADERS = \
flash.h \
frame_queue.hpp \
platform.h \
openthread-system.h \
platform-posix.h \
radio_spinel.hpp \
$(NULL)
+2 -2
View File
@@ -33,7 +33,7 @@
#include <openthread/types.h>
#include <openthread/platform/misc.h>
#include "platform.h"
#include "openthread-system.h"
extern int gArgumentsCount;
extern char **gArguments;
@@ -61,7 +61,7 @@ void otPlatReset(otInstance *aInstance)
argv[gArgumentsCount] = NULL;
PlatformDeinit();
otSysDeinit();
platformUartRestore();
alarm(0);
@@ -29,11 +29,11 @@
/**
* @file
* @brief
* This file defines the platform-specific initializers.
* This file defines the platform-specific functions needed by OpenThread's example applications.
*/
#ifndef PLATFORM_H_
#define PLATFORM_H_
#ifndef OPENTHREAD_SYSTEM_H_
#define OPENTHREAD_SYSTEM_H_
#include <openthread/types.h>
@@ -42,41 +42,59 @@ extern "C" {
#endif
/**
* This function performs all platform-specific initialization.
* This function performs all platform-specific initialization of OpenThread's drivers.
*
* @note This function is not called by the OpenThread library. Instead, the system/RTOS should call this function
* when initialization of OpenThread's drivers is most approriate.
*
* @param[in] argc Number of arguments in @p argv.
* @param[in] argv Argument vector.
*
*/
void PlatformInit(int argc, char *argv[]);
void otSysInit(int argc, char *argv[]);
/**
* This function performs all platform-specific deinitialization.
* This function performs all platform-specific deinitialization for OpenThread's drivers.
*
* @note This function is not called by the OpenThread library. Instead, the system/RTOS should call this function
* when deinitialization of OpenThread's drivers is most appropriate.
*
*/
void PlatformDeinit(void);
void otSysDeinit(void);
/**
* This function returns true is a pseudo-reset was requested.
* In such a case, the main loop should shut down and re-initialize
* the OpenThread instance.
* This function returns true if a pseudo-reset was requested.
*
* In such a case, the main loop should shut down and re-initialize the OpenThread instance.
*
* @note This function is not called by the OpenThread library. Instead, the system/RTOS should call this function
* in the main loop to determine when to shut down and re-initialize the OpenThread instance.
*
*/
bool PlatformPseudoResetWasRequested(void);
bool otSysPseudoResetWasRequested(void);
/**
* This function performs all platform-specific processing.
* This function performs all platform-specific processing for OpenThread's example applications.
*
* @note This function is not called by the OpenThread library. Instead, the system/RTOS should call this function
* in the main loop when processing OpenThread's drivers is most appropriate.
*
* @param[in] aInstance The OpenThread instance structure.
*
*/
void PlatformProcessDrivers(otInstance *aInstance);
void otSysProcessDrivers(otInstance *aInstance);
/**
* This function is called whenever platform drivers needs processing.
*
* @note This function is not handled by the OpenThread library. Instead, the system/RTOS should handle this function
* and schedule a call to `otSysProcessDrivers()`.
*
*/
extern void PlatformEventSignalPending(void);
extern void otSysEventSignalPending(void);
#ifdef __cplusplus
} // end of extern "C"
#endif
#endif // PLATFORM_H_
#endif // OPENTHREAD_SYSTEM_H_
@@ -60,7 +60,7 @@ void PrintUsage(const char *aArg0)
exit(EXIT_FAILURE);
}
void PlatformInit(int aArgCount, char *aArgVector[])
void otSysInit(int aArgCount, char *aArgVector[])
{
int i;
uint32_t speedUpFactor = 1;
@@ -115,17 +115,17 @@ void PlatformInit(int aArgCount, char *aArgVector[])
platformRandomInit();
}
bool PlatformPseudoResetWasRequested(void)
bool otSysPseudoResetWasRequested(void)
{
return gPlatformPseudoResetWasRequested;
}
void PlatformDeinit(void)
void otSysDeinit(void)
{
platformRadioDeinit();
}
void PlatformProcessDrivers(otInstance *aInstance)
void otSysProcessDrivers(otInstance *aInstance)
{
fd_set read_fds;
fd_set write_fds;
+2 -2
View File
@@ -33,7 +33,7 @@
#include "utils/wrap_string.h"
#include "platform.h"
#include "openthread-system.h"
#include "test_util.h"
extern "C" void otTaskletsSignalPending(otInstance *)
@@ -234,7 +234,7 @@ void TestDiag(void)
#else
char *argv[] = {(char *)"test_diag", (char *)"1"};
#endif
PlatformInit(sizeof(argv) / sizeof(char *), argv);
otSysInit(sizeof(argv) / sizeof(char *), argv);
// initialize diagnostics module
otDiagInit(NULL);