diff --git a/Android.mk b/Android.mk
index cc6c51132..79c5c98a5 100644
--- a/Android.mk
+++ b/Android.mk
@@ -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 \
diff --git a/etc/visual-studio/libopenthread-windows.vcxproj b/etc/visual-studio/libopenthread-windows.vcxproj
index ea68f4d3e..fc9b9d7b8 100644
--- a/etc/visual-studio/libopenthread-windows.vcxproj
+++ b/etc/visual-studio/libopenthread-windows.vcxproj
@@ -59,10 +59,10 @@
-
+
diff --git a/etc/visual-studio/libopenthread-windows.vcxproj.filters b/etc/visual-studio/libopenthread-windows.vcxproj.filters
index d8d92025a..2b2b26828 100644
--- a/etc/visual-studio/libopenthread-windows.vcxproj.filters
+++ b/etc/visual-studio/libopenthread-windows.vcxproj.filters
@@ -22,9 +22,6 @@
Source Files
-
- Source Files
-
Source Files
@@ -34,6 +31,9 @@
Source Files
+
+ Source Files
+
Source Files
diff --git a/examples/apps/cli/main.c b/examples/apps/cli/main.c
index 2354e2791..ecbdc549e 100644
--- a/examples/apps/cli/main.c
+++ b/examples/apps/cli/main.c
@@ -35,7 +35,7 @@
#include
#include
-#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);
diff --git a/examples/apps/ncp/main.c b/examples/apps/ncp/main.c
index c68010ad4..4d87bd3c4 100644
--- a/examples/apps/ncp/main.c
+++ b/examples/apps/ncp/main.c
@@ -34,7 +34,7 @@
#include
#include
-#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);
diff --git a/examples/platforms/Makefile.am b/examples/platforms/Makefile.am
index 69b281e15..96fba27d3 100644
--- a/examples/platforms/Makefile.am
+++ b/examples/platforms/Makefile.am
@@ -101,7 +101,7 @@ SUBDIRS += samr21
endif
noinst_HEADERS = \
- platform.h \
+ openthread-system.h \
$(NULL)
# Always pretty (e.g. for 'make pretty') these subdirectories.
diff --git a/examples/platforms/cc1352/Makefile.am b/examples/platforms/cc1352/Makefile.am
index 7214dd1cc..1cdd20458 100644
--- a/examples/platforms/cc1352/Makefile.am
+++ b/examples/platforms/cc1352/Makefile.am
@@ -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 \
diff --git a/examples/platforms/cc1352/platform.c b/examples/platforms/cc1352/system.c
similarity index 95%
rename from examples/platforms/cc1352/platform.c
rename to examples/platforms/cc1352/system.c
index 77881e4eb..078cb865b 100644
--- a/examples/platforms/cc1352/platform.c
+++ b/examples/platforms/cc1352/system.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
diff --git a/examples/platforms/cc2538/Makefile.am b/examples/platforms/cc2538/Makefile.am
index 654fcc656..a510cba0b 100644
--- a/examples/platforms/cc2538/Makefile.am
+++ b/examples/platforms/cc2538/Makefile.am
@@ -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)
diff --git a/examples/platforms/cc2538/platform.c b/examples/platforms/cc2538/system.c
similarity index 94%
rename from examples/platforms/cc2538/platform.c
rename to examples/platforms/cc2538/system.c
index cf469be0e..40dc9b20f 100644
--- a/examples/platforms/cc2538/platform.c
+++ b/examples/platforms/cc2538/system.c
@@ -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;
diff --git a/examples/platforms/cc2650/Makefile.am b/examples/platforms/cc2650/Makefile.am
index 1917ec87a..fe7135203 100644
--- a/examples/platforms/cc2650/Makefile.am
+++ b/examples/platforms/cc2650/Makefile.am
@@ -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 \
diff --git a/examples/platforms/cc2650/platform.c b/examples/platforms/cc2650/system.c
similarity index 94%
rename from examples/platforms/cc2650/platform.c
rename to examples/platforms/cc2650/system.c
index 9ee6dd013..bd95b801c 100644
--- a/examples/platforms/cc2650/platform.c
+++ b/examples/platforms/cc2650/system.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
diff --git a/examples/platforms/cc2652/Makefile.am b/examples/platforms/cc2652/Makefile.am
index f63e99dc7..722fdafd8 100644
--- a/examples/platforms/cc2652/Makefile.am
+++ b/examples/platforms/cc2652/Makefile.am
@@ -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 \
diff --git a/examples/platforms/cc2652/platform.c b/examples/platforms/cc2652/system.c
similarity index 95%
rename from examples/platforms/cc2652/platform.c
rename to examples/platforms/cc2652/system.c
index b1ca9ff69..6a96d2c3a 100644
--- a/examples/platforms/cc2652/platform.c
+++ b/examples/platforms/cc2652/system.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
diff --git a/examples/platforms/da15000/Makefile.am b/examples/platforms/da15000/Makefile.am
index dfe902429..71842399a 100755
--- a/examples/platforms/da15000/Makefile.am
+++ b/examples/platforms/da15000/Makefile.am
@@ -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)
diff --git a/examples/platforms/da15000/platform.c b/examples/platforms/da15000/system.c
similarity index 98%
rename from examples/platforms/da15000/platform.c
rename to examples/platforms/da15000/system.c
index ad3cea081..68dfb9466 100644
--- a/examples/platforms/da15000/platform.c
+++ b/examples/platforms/da15000/system.c
@@ -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)
{
diff --git a/examples/platforms/efr32/Makefile.am b/examples/platforms/efr32/Makefile.am
index 476ab45d5..776f68856 100644
--- a/examples/platforms/efr32/Makefile.am
+++ b/examples/platforms/efr32/Makefile.am
@@ -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)
diff --git a/examples/platforms/efr32/radio.c b/examples/platforms/efr32/radio.c
index 8eddbe2d7..d20952c87 100644
--- a/examples/platforms/efr32/radio.c
+++ b/examples/platforms/efr32/radio.c
@@ -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"
diff --git a/examples/platforms/efr32/platform.c b/examples/platforms/efr32/system.c
similarity index 94%
rename from examples/platforms/efr32/platform.c
rename to examples/platforms/efr32/system.c
index 11db9a9b8..6e00ed3cc 100644
--- a/examples/platforms/efr32/platform.c
+++ b/examples/platforms/efr32/system.c
@@ -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;
diff --git a/examples/platforms/emsk/Makefile.am b/examples/platforms/emsk/Makefile.am
index 98697bc75..302d60727 100644
--- a/examples/platforms/emsk/Makefile.am
+++ b/examples/platforms/emsk/Makefile.am
@@ -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)
diff --git a/examples/platforms/emsk/platform.c b/examples/platforms/emsk/system.c
similarity index 94%
rename from examples/platforms/emsk/platform.c
rename to examples/platforms/emsk/system.c
index 7f3e8d681..e9f4ff4d6 100644
--- a/examples/platforms/emsk/platform.c
+++ b/examples/platforms/emsk/system.c
@@ -40,7 +40,7 @@
#include
#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);
diff --git a/examples/platforms/gp712/Makefile.am b/examples/platforms/gp712/Makefile.am
index eb1cf548d..afc6c9367 100644
--- a/examples/platforms/gp712/Makefile.am
+++ b/examples/platforms/gp712/Makefile.am
@@ -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 \
diff --git a/examples/platforms/gp712/platform.c b/examples/platforms/gp712/system.c
similarity index 95%
rename from examples/platforms/gp712/platform.c
rename to examples/platforms/gp712/system.c
index 9bfa6e4f2..3126ad090 100644
--- a/examples/platforms/gp712/platform.c
+++ b/examples/platforms/gp712/system.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)
{
diff --git a/examples/platforms/kw41z/Makefile.am b/examples/platforms/kw41z/Makefile.am
index b400935da..2c06434b2 100644
--- a/examples/platforms/kw41z/Makefile.am
+++ b/examples/platforms/kw41z/Makefile.am
@@ -54,9 +54,9 @@ PLATFORM_SOURCES
flash.c \
logging.c \
misc.c \
- platform.c \
radio.c \
random.c \
+ system.c \
uart.c \
$(NULL)
diff --git a/examples/platforms/kw41z/platform.c b/examples/platforms/kw41z/system.c
similarity index 96%
rename from examples/platforms/kw41z/platform.c
rename to examples/platforms/kw41z/system.c
index a4b76e505..f226493e8 100644
--- a/examples/platforms/kw41z/platform.c
+++ b/examples/platforms/kw41z/system.c
@@ -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();
diff --git a/examples/platforms/nrf52840/Makefile.am b/examples/platforms/nrf52840/Makefile.am
index 97aec57b4..f4fa65b08 100644
--- a/examples/platforms/nrf52840/Makefile.am
+++ b/examples/platforms/nrf52840/Makefile.am
@@ -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)
diff --git a/examples/platforms/nrf52840/alarm.c b/examples/platforms/nrf52840/alarm.c
index 8f9c26bf3..170986fc3 100644
--- a/examples/platforms/nrf52840/alarm.c
+++ b/examples/platforms/nrf52840/alarm.c
@@ -45,7 +45,7 @@
#include
#include
-#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();
}
}
}
diff --git a/examples/platforms/nrf52840/radio.c b/examples/platforms/nrf52840/radio.c
index c9daae9de..1ecc2fae3 100644
--- a/examples/platforms/nrf52840/radio.c
+++ b/examples/platforms/nrf52840/radio.c
@@ -49,8 +49,8 @@
#include
#include
+#include "openthread-system.h"
#include "platform-nrf5.h"
-#include "platform.h"
#include
#include
@@ -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)
diff --git a/examples/platforms/nrf52840/platform.c b/examples/platforms/nrf52840/system.c
similarity index 93%
rename from examples/platforms/nrf52840/platform.c
rename to examples/platforms/nrf52840/system.c
index ab40ad1bd..446a5650c 100644
--- a/examples/platforms/nrf52840/platform.c
+++ b/examples/platforms/nrf52840/system.c
@@ -37,8 +37,8 @@
#include
+#include "openthread-system.h"
#include "platform-nrf5.h"
-#include "platform.h"
#include
#include
@@ -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
}
diff --git a/examples/platforms/nrf52840/uart.c b/examples/platforms/nrf52840/uart.c
index ca0b3750e..aec403ed3 100644
--- a/examples/platforms/nrf52840/uart.c
+++ b/examples/platforms/nrf52840/uart.c
@@ -43,7 +43,7 @@
#include
#include
-#include "platform.h"
+#include "openthread-system.h"
#include "platform-nrf5.h"
#include
@@ -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();
}
}
}
diff --git a/src/posix/platform/platform.h b/examples/platforms/openthread-system.h
similarity index 54%
rename from src/posix/platform/platform.h
rename to examples/platforms/openthread-system.h
index c1378526b..461fcc645 100644
--- a/src/posix/platform/platform.h
+++ b/examples/platforms/openthread-system.h
@@ -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
@@ -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_
diff --git a/examples/platforms/posix/Makefile.am b/examples/platforms/posix/Makefile.am
index 61ffd0344..e7f2e9e23 100644
--- a/examples/platforms/posix/Makefile.am
+++ b/examples/platforms/posix/Makefile.am
@@ -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 \
diff --git a/examples/platforms/posix/misc.c b/examples/platforms/posix/misc.c
index c70049bee..25501abd3 100644
--- a/examples/platforms/posix/misc.c
+++ b/examples/platforms/posix/misc.c
@@ -35,7 +35,7 @@
#include
#include
-#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);
diff --git a/examples/platforms/posix/sim/platform-sim.c b/examples/platforms/posix/sim/platform-sim.c
index a5c389430..2451fbd18 100644
--- a/examples/platforms/posix/sim/platform-sim.c
+++ b/examples/platforms/posix/sim/platform-sim.c
@@ -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;
diff --git a/examples/platforms/posix/platform.c b/examples/platforms/posix/system.c
similarity index 96%
rename from examples/platforms/posix/platform.c
rename to examples/platforms/posix/system.c
index 1295e3b2c..e8b1d225c 100644
--- a/examples/platforms/posix/platform.c
+++ b/examples/platforms/posix/system.c
@@ -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;
diff --git a/examples/platforms/samr21/Makefile.am b/examples/platforms/samr21/Makefile.am
index f8f5bb0e3..fd136c211 100644
--- a/examples/platforms/samr21/Makefile.am
+++ b/examples/platforms/samr21/Makefile.am
@@ -102,9 +102,9 @@ PLATFORM_SOURCES
flash.c \
logging.c \
misc.c \
- platform.c \
radio.c \
random.c \
+ system.c \
uart.c \
$(NULL)
diff --git a/examples/platforms/samr21/diag.c b/examples/platforms/samr21/diag.c
index 6013624a9..129edf5b6 100644
--- a/examples/platforms/samr21/diag.c
+++ b/examples/platforms/samr21/diag.c
@@ -86,4 +86,4 @@ void otPlatDiagAlarmCallback(otInstance *aInstance)
(void)aInstance;
}
-#endif // OPENTHREAD_ENABLE_DIAG
\ No newline at end of file
+#endif // OPENTHREAD_ENABLE_DIAG
diff --git a/examples/platforms/samr21/platform.c b/examples/platforms/samr21/system.c
similarity index 96%
rename from examples/platforms/samr21/platform.c
rename to examples/platforms/samr21/system.c
index 4890990e7..94eeba111 100644
--- a/examples/platforms/samr21/platform.c
+++ b/examples/platforms/samr21/system.c
@@ -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;
diff --git a/src/posix/main.c b/src/posix/main.c
index c3da2c81a..c757d28d2 100644
--- a/src/posix/main.c
+++ b/src/posix/main.c
@@ -45,7 +45,7 @@
#include
#include
-#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);
diff --git a/src/posix/platform/Makefile.am b/src/posix/platform/Makefile.am
index bbe87b2da..91873813b 100644
--- a/src/posix/platform/Makefile.am
+++ b/src/posix/platform/Makefile.am
@@ -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)
diff --git a/src/posix/platform/misc.c b/src/posix/platform/misc.c
index 7d5561460..ee4b296d5 100644
--- a/src/posix/platform/misc.c
+++ b/src/posix/platform/misc.c
@@ -33,7 +33,7 @@
#include
#include
-#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);
diff --git a/examples/platforms/platform.h b/src/posix/platform/openthread-system.h
similarity index 54%
rename from examples/platforms/platform.h
rename to src/posix/platform/openthread-system.h
index c1378526b..461fcc645 100644
--- a/examples/platforms/platform.h
+++ b/src/posix/platform/openthread-system.h
@@ -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
@@ -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_
diff --git a/src/posix/platform/platform.c b/src/posix/platform/system.c
similarity index 96%
rename from src/posix/platform/platform.c
rename to src/posix/platform/system.c
index 019e6dac2..859bc5f77 100644
--- a/src/posix/platform/platform.c
+++ b/src/posix/platform/system.c
@@ -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;
diff --git a/tests/unit/test_diag.cpp b/tests/unit/test_diag.cpp
index 76549d194..151a65155 100644
--- a/tests/unit/test_diag.cpp
+++ b/tests/unit/test_diag.cpp
@@ -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);