diff --git a/examples/Makefile-nrf52811 b/examples/Makefile-nrf52811 index 63e892048..317bd9cc2 100644 --- a/examples/Makefile-nrf52811 +++ b/examples/Makefile-nrf52811 @@ -60,7 +60,6 @@ NRF52811_MBEDTLS_CPPFLAGS += -DMBEDTLS_USER_CONFIG_FILE='\"nrf52811-mbedtls-conf NRF52811_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/mbedtls NRF52811_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/mbedtls/repo/include NRF52811_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/mbedtls/repo/include/mbedtls -NRF52811_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/NordicSemiconductor/libraries/crypto NRF52811_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/NordicSemiconductor/libraries/nrf_security/mbedtls_plat_config NRF52811_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/NordicSemiconductor/nrfx/mdk NRF52811_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/NordicSemiconductor/cmsis diff --git a/examples/Makefile-nrf52833 b/examples/Makefile-nrf52833 index b13286cd6..5f6ad35c2 100644 --- a/examples/Makefile-nrf52833 +++ b/examples/Makefile-nrf52833 @@ -61,7 +61,6 @@ NRF52833_MBEDTLS_CPPFLAGS += -DMBEDTLS_USER_CONFIG_FILE='\"nrf52833-mbedtls-conf NRF52833_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/mbedtls NRF52833_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/mbedtls/repo/include NRF52833_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/mbedtls/repo/include/mbedtls -NRF52833_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/NordicSemiconductor/libraries/crypto NRF52833_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/NordicSemiconductor/libraries/nrf_security/mbedtls_plat_config NRF52833_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/NordicSemiconductor/nrfx/mdk NRF52833_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/NordicSemiconductor/cmsis diff --git a/examples/platforms/nrf528xx/Makefile.am b/examples/platforms/nrf528xx/Makefile.am index a7bf49cf6..b227c272c 100644 --- a/examples/platforms/nrf528xx/Makefile.am +++ b/examples/platforms/nrf528xx/Makefile.am @@ -27,7 +27,7 @@ # # Use automake includes since we cannot use SUBDIRS feature due to cleanup -# errors - few targets may use the same source file but dependency file is +# errors - few targets may use the same source file but dependency file is # created only once which leads to errors when auto-generated Makefile tries # to remove .Po files that were already removed diff --git a/examples/platforms/nrf528xx/nrf52811/Makefile.am b/examples/platforms/nrf528xx/nrf52811/Makefile.am index fad5acaf2..d49167014 100644 --- a/examples/platforms/nrf528xx/nrf52811/Makefile.am +++ b/examples/platforms/nrf528xx/nrf52811/Makefile.am @@ -31,6 +31,7 @@ include $(abs_top_nlbuild_autotools_dir)/automake/pre.am lib_LIBRARIES = \ libopenthread-nrf52811.a \ libopenthread-nrf52811-sdk.a \ + libopenthread-nrf52811-transport.a \ $(NULL) # Do not enable -pedantic-errors for nRF52811 driver library @@ -49,9 +50,9 @@ COMMONCPPFLAGS -I$(top_srcdir)/include \ -I$(top_srcdir)/examples/platforms \ -I$(top_srcdir)/examples/platforms/nrf528xx/src \ + -I$(top_srcdir)/examples/platforms/nrf528xx/src/transport \ -I$(top_srcdir)/src/core \ -I$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio \ - -I$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/hal \ -I$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/mac_features \ -I$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/fem/three_pin_gpio \ -I$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/mac_features/ack_generator \ @@ -107,10 +108,14 @@ PLATFORM_COMMON_SOURCES src/logging.c \ src/misc.c \ src/radio.c \ - src/spi-slave.c \ src/system.c \ src/temp.c \ - src/uart.c \ + $(NULL) + +TRANSPORT_SOURCES = \ + src/transport/spi-slave.c \ + src/transport/uart.c \ + src/transport/transport.c \ $(NULL) SINGLEPHY_SOURCES = \ @@ -145,6 +150,14 @@ libopenthread_nrf52811_sdk_a_SOURCES $(SINGLEPHY_SOURCES) \ $(NULL) +libopenthread_nrf52811_transport_a_CPPFLAGS = \ + $(COMMONCPPFLAGS) \ + $(NULL) + +libopenthread_nrf52811_transport_a_SOURCES = \ + $(TRANSPORT_SOURCES) \ + $(NULL) + Dash = - libopenthread_nrf52811_a_LIBADD = \ @@ -154,4 +167,7 @@ libopenthread_nrf52811_a_LIBADD libopenthread_nrf52811_sdk_a_LIBADD = \ $(shell find $(top_builddir)/examples/platforms/utils $(Dash)type f $(Dash)name "*.o") +libopenthread_nrf52811_transport_a_LIBADD = \ + $(shell find $(top_builddir)/examples/platforms/utils $(Dash)type f $(Dash)name "*.o") + include $(abs_top_nlbuild_autotools_dir)/automake/post.am diff --git a/examples/platforms/nrf528xx/nrf52811/Makefile.platform.am b/examples/platforms/nrf528xx/nrf52811/Makefile.platform.am index f05f37755..d0042b053 100644 --- a/examples/platforms/nrf528xx/nrf52811/Makefile.platform.am +++ b/examples/platforms/nrf528xx/nrf52811/Makefile.platform.am @@ -32,6 +32,7 @@ LDADD_COMMON += \ $(top_builddir)/examples/platforms/nrf528xx/libopenthread-nrf52811.a \ + $(top_builddir)/examples/platforms/nrf528xx/libopenthread-nrf52811-transport.a \ $(top_builddir)/third_party/NordicSemiconductor/libnordicsemi-nrf52811-sdk.a \ $(top_builddir)/third_party/NordicSemiconductor/libnordicsemi-nrf52811-radio-driver.a \ $(NULL) diff --git a/examples/platforms/nrf528xx/nrf52833/Makefile.am b/examples/platforms/nrf528xx/nrf52833/Makefile.am index c24e41c50..27a20ae85 100644 --- a/examples/platforms/nrf528xx/nrf52833/Makefile.am +++ b/examples/platforms/nrf528xx/nrf52833/Makefile.am @@ -32,6 +32,7 @@ lib_LIBRARIES libopenthread-nrf52833.a \ libopenthread-nrf52833-sdk.a \ libopenthread-nrf52833-softdevice-sdk.a \ + libopenthread-nrf52833-transport.a \ $(NULL) # Do not enable -pedantic-errors for nRF52833 driver library @@ -50,10 +51,10 @@ COMMONCPPFLAGS -I$(top_srcdir)/include \ -I$(top_srcdir)/examples/platforms \ -I$(top_srcdir)/examples/platforms/nrf528xx/src \ + -I$(top_srcdir)/examples/platforms/nrf528xx/src/transport \ -I$(top_srcdir)/src/core \ -I$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio \ -I$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/fem/three_pin_gpio \ - -I$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/hal \ -I$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/mac_features \ -I$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/mac_features/ack_generator \ -I$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/rsch \ @@ -116,11 +117,15 @@ PLATFORM_COMMON_SOURCES src/logging.c \ src/misc.c \ src/radio.c \ - src/temp.c \ - src/spi-slave.c \ src/system.c \ - src/uart.c \ - src/usb-cdc-uart.c \ + src/temp.c \ + $(NULL) + +TRANSPORT_SOURCES = \ + src/transport/spi-slave.c \ + src/transport/uart.c \ + src/transport/usb-cdc-uart.c \ + src/transport/transport.c \ $(NULL) SINGLEPHY_SOURCES = \ @@ -171,6 +176,14 @@ libopenthread_nrf52833_softdevice_sdk_a_SOURCES $(SOFTDEVICE_SOURCES) \ $(NULL) +libopenthread_nrf52833_transport_a_CPPFLAGS = \ + $(COMMONCPPFLAGS) \ + $(NULL) + +libopenthread_nrf52833_transport_a_SOURCES = \ + $(TRANSPORT_SOURCES) \ + $(NULL) + Dash = - libopenthread_nrf52833_a_LIBADD = \ @@ -183,4 +196,7 @@ libopenthread_nrf52833_sdk_a_LIBADD libopenthread_nrf52833_softdevice_sdk_a_LIBADD = \ $(shell find $(top_builddir)/examples/platforms/utils $(Dash)type f $(Dash)name "*.o") +libopenthread_nrf52833_transport_a_LIBADD = \ + $(shell find $(top_builddir)/examples/platforms/utils $(Dash)type f $(Dash)name "*.o") + include $(abs_top_nlbuild_autotools_dir)/automake/post.am diff --git a/examples/platforms/nrf528xx/nrf52833/Makefile.platform.am b/examples/platforms/nrf528xx/nrf52833/Makefile.platform.am index ab0fc8ded..1412d57a9 100644 --- a/examples/platforms/nrf528xx/nrf52833/Makefile.platform.am +++ b/examples/platforms/nrf528xx/nrf52833/Makefile.platform.am @@ -32,6 +32,7 @@ LDADD_COMMON += \ $(top_builddir)/examples/platforms/nrf528xx/libopenthread-nrf52833.a \ + $(top_builddir)/examples/platforms/nrf528xx/libopenthread-nrf52833-transport.a \ $(top_builddir)/third_party/NordicSemiconductor/libnordicsemi-nrf52833-sdk.a \ $(top_builddir)/third_party/NordicSemiconductor/libnordicsemi-nrf52833-radio-driver.a \ $(NULL) diff --git a/examples/platforms/nrf528xx/nrf52840/Makefile.am b/examples/platforms/nrf528xx/nrf52840/Makefile.am index 448fcce0e..ba6323700 100644 --- a/examples/platforms/nrf528xx/nrf52840/Makefile.am +++ b/examples/platforms/nrf528xx/nrf52840/Makefile.am @@ -32,6 +32,7 @@ lib_LIBRARIES libopenthread-nrf52840.a \ libopenthread-nrf52840-sdk.a \ libopenthread-nrf52840-softdevice-sdk.a \ + libopenthread-nrf52840-transport.a \ $(NULL) # Do not enable -pedantic-errors for nRF52840 driver library @@ -50,10 +51,10 @@ COMMONCPPFLAGS -I$(top_srcdir)/include \ -I$(top_srcdir)/examples/platforms \ -I$(top_srcdir)/examples/platforms/nrf528xx/src \ + -I$(top_srcdir)/examples/platforms/nrf528xx/src/transport \ -I$(top_srcdir)/src/core \ -I$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio \ -I$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/fem/three_pin_gpio \ - -I$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/hal \ -I$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/mac_features \ -I$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/mac_features/ack_generator \ -I$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/rsch \ @@ -116,11 +117,15 @@ PLATFORM_COMMON_SOURCES src/logging.c \ src/misc.c \ src/radio.c \ - src/spi-slave.c \ src/system.c \ src/temp.c \ - src/uart.c \ - src/usb-cdc-uart.c \ + $(NULL) + +TRANSPORT_SOURCES = \ + src/transport/spi-slave.c \ + src/transport/uart.c \ + src/transport/usb-cdc-uart.c \ + src/transport/transport.c \ $(NULL) SINGLEPHY_SOURCES = \ @@ -173,6 +178,14 @@ libopenthread_nrf52840_softdevice_sdk_a_SOURCES $(SOFTDEVICE_SOURCES) \ $(NULL) +libopenthread_nrf52840_transport_a_CPPFLAGS = \ + $(COMMONCPPFLAGS) \ + $(NULL) + +libopenthread_nrf52840_transport_a_SOURCES = \ + $(TRANSPORT_SOURCES) \ + $(NULL) + Dash = - libopenthread_nrf52840_a_LIBADD = \ @@ -185,4 +198,7 @@ libopenthread_nrf52840_sdk_a_LIBADD libopenthread_nrf52840_softdevice_sdk_a_LIBADD = \ $(shell find $(top_builddir)/examples/platforms/utils $(Dash)type f $(Dash)name "*.o") +libopenthread_nrf52840_transport_a_LIBADD = \ + $(shell find $(top_builddir)/examples/platforms/utils $(Dash)type f $(Dash)name "*.o") + include $(abs_top_nlbuild_autotools_dir)/automake/post.am diff --git a/examples/platforms/nrf528xx/nrf52840/Makefile.platform.am b/examples/platforms/nrf528xx/nrf52840/Makefile.platform.am index 4e28e5884..1fa02b6a7 100644 --- a/examples/platforms/nrf528xx/nrf52840/Makefile.platform.am +++ b/examples/platforms/nrf528xx/nrf52840/Makefile.platform.am @@ -32,6 +32,7 @@ LDADD_COMMON += \ $(top_builddir)/examples/platforms/nrf528xx/libopenthread-nrf52840.a \ + $(top_builddir)/examples/platforms/nrf528xx/libopenthread-nrf52840-transport.a \ $(top_builddir)/third_party/NordicSemiconductor/libnordicsemi-nrf52840-sdk.a \ $(top_builddir)/third_party/NordicSemiconductor/libnordicsemi-nrf52840-radio-driver.a \ $(NULL) diff --git a/examples/platforms/nrf528xx/src/platform-nrf5-transport.h b/examples/platforms/nrf528xx/src/platform-nrf5-transport.h new file mode 100644 index 000000000..6a63a30d7 --- /dev/null +++ b/examples/platforms/nrf528xx/src/platform-nrf5-transport.h @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2020, The OpenThread Authors. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * This file includes the platform-specific transport initializers. + * + */ + +#ifndef PLATFORM_NRF5_TRANSPORT_H_ +#define PLATFORM_NRF5_TRANSPORT_H_ + +#include + +#include "platform-config.h" + +/** + * Initialization of transport. + * + */ +void nrf5TransportInit(bool aPseudoReset); + +/** + * Deinitialization of transport. + * + */ +void nrf5TransportDeinit(bool aPseudoReset); + +/** + * This function performs transport processing. + * + */ +void nrf5TransportProcess(void); + +#endif diff --git a/examples/platforms/nrf528xx/src/platform-nrf5.h b/examples/platforms/nrf528xx/src/platform-nrf5.h index 4f4e3f774..428a716be 100644 --- a/examples/platforms/nrf528xx/src/platform-nrf5.h +++ b/examples/platforms/nrf528xx/src/platform-nrf5.h @@ -41,34 +41,6 @@ #include "platform-config.h" -/** - * Initialization of UART driver. - * - */ -void nrf5UartInit(void); - -/** - * Deinitialization of UART driver. - * - */ -void nrf5UartDeinit(void); - -/** - * Clear pending UART data. - * - */ -void nrf5UartClearPendingData(void); - -/** - * This function performs UART driver processing. - * - */ -void nrf5UartProcess(void); - -/** - * Initialization of Alarm driver. - * - */ void nrf5AlarmInit(void); /** @@ -119,23 +91,6 @@ void nrf5LogInit(void); */ void nrf5LogDeinit(void); -/** - * Initialization of SPI Slave driver. - * - */ -void nrf5SpiSlaveInit(void); - -/** - * Deinitialization of SPI Slave driver. - * - */ -void nrf5SpiSlaveDeinit(void); - -/** - * Function for processing SPI Slave driver. - */ -void nrf5SpiSlaveProcess(void); - /** * Initialization of Misc module. * diff --git a/examples/platforms/nrf528xx/src/system.c b/examples/platforms/nrf528xx/src/system.c index 9fac41ad7..3f8c3c49c 100644 --- a/examples/platforms/nrf528xx/src/system.c +++ b/examples/platforms/nrf528xx/src/system.c @@ -39,6 +39,7 @@ #include "openthread-system.h" #include "platform-fem.h" +#include "platform-nrf5-transport.h" #include "platform-nrf5.h" #include #include @@ -94,23 +95,11 @@ void otSysInit(int argc, char *argv[]) nrf5RandomInit(); if (!gPlatformPseudoResetWasRequested) { -#if ((UART_AS_SERIAL_TRANSPORT == 1) || (USB_CDC_AS_SERIAL_TRANSPORT == 1)) - nrf5UartInit(); -#endif #if NRF52840_XXAA nrf5CryptoInit(); #endif } - else - { -#if ((UART_AS_SERIAL_TRANSPORT == 1) || (USB_CDC_AS_SERIAL_TRANSPORT == 1)) - nrf5UartClearPendingData(); -#endif - } - -#if (SPIS_AS_SERIAL_TRANSPORT == 1) - nrf5SpiSlaveInit(); -#endif + nrf5TransportInit(gPlatformPseudoResetWasRequested); nrf5MiscInit(); nrf5RadioInit(); nrf5TempInit(); @@ -127,18 +116,13 @@ void otSysDeinit(void) nrf5TempDeinit(); nrf5RadioDeinit(); nrf5MiscDeinit(); -#if (SPIS_AS_SERIAL_TRANSPORT == 1) - nrf5SpiSlaveDeinit(); -#endif if (!gPlatformPseudoResetWasRequested) { #if NRF52840_XXAA nrf5CryptoDeinit(); -#endif -#if ((UART_AS_SERIAL_TRANSPORT == 1) || (USB_CDC_AS_SERIAL_TRANSPORT == 1)) - nrf5UartDeinit(); #endif } + nrf5TransportDeinit(gPlatformPseudoResetWasRequested); nrf5RandomDeinit(); nrf5AlarmDeinit(); #if (OPENTHREAD_CONFIG_LOG_OUTPUT == OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED) || \ @@ -159,12 +143,7 @@ bool otSysPseudoResetWasRequested(void) void otSysProcessDrivers(otInstance *aInstance) { nrf5RadioProcess(aInstance); -#if ((UART_AS_SERIAL_TRANSPORT == 1) || (USB_CDC_AS_SERIAL_TRANSPORT == 1)) - nrf5UartProcess(); -#endif -#if (SPIS_AS_SERIAL_TRANSPORT == 1) - nrf5SpiSlaveProcess(); -#endif + nrf5TransportProcess(); nrf5TempProcess(); nrf5AlarmProcess(aInstance); } diff --git a/examples/platforms/nrf528xx/src/spi-slave.c b/examples/platforms/nrf528xx/src/transport/spi-slave.c similarity index 99% rename from examples/platforms/nrf528xx/src/spi-slave.c rename to examples/platforms/nrf528xx/src/transport/spi-slave.c index 481b4b2af..2c8219fb8 100644 --- a/examples/platforms/nrf528xx/src/spi-slave.c +++ b/examples/platforms/nrf528xx/src/transport/spi-slave.c @@ -36,10 +36,10 @@ #include #include +#include "platform-nrf5-transport.h" #include #include #include -#include #include "openthread-system.h" diff --git a/examples/platforms/nrf528xx/src/transport/transport-drivers.h b/examples/platforms/nrf528xx/src/transport/transport-drivers.h new file mode 100644 index 000000000..fd46d00e2 --- /dev/null +++ b/examples/platforms/nrf528xx/src/transport/transport-drivers.h @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2016, The OpenThread Authors. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * This file includes UART/USB and SPI driver initializers. + * + */ + +#ifndef TRANSPORT_DRIVERS_H_ +#define TRANSPORT_DRIVERS_H_ + +/** + * Initialization of UART driver. + * + */ +void nrf5UartInit(void); + +/** + * Deinitialization of UART driver. + * + */ +void nrf5UartDeinit(void); + +/** + * Clear pending UART data. + * + */ +void nrf5UartClearPendingData(void); + +/** + * This function performs UART driver processing. + * + */ +void nrf5UartProcess(void); + +/** + * Initialization of SPI Slave driver. + * + */ +void nrf5SpiSlaveInit(void); + +/** + * Deinitialization of SPI Slave driver. + * + */ +void nrf5SpiSlaveDeinit(void); + +/** + * Function for processing SPI Slave driver. + */ +void nrf5SpiSlaveProcess(void); + +#endif diff --git a/examples/platforms/nrf528xx/src/transport/transport.c b/examples/platforms/nrf528xx/src/transport/transport.c new file mode 100644 index 000000000..33639d6ed --- /dev/null +++ b/examples/platforms/nrf528xx/src/transport/transport.c @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2020, The OpenThread Authors. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * This file implements the nrf5 platform transport initialization functions. + * + */ + +#include "platform-nrf5-transport.h" + +#include "transport-drivers.h" + +void nrf5TransportInit(bool aPseudoReset) +{ +#if ((UART_AS_SERIAL_TRANSPORT == 1) || (USB_CDC_AS_SERIAL_TRANSPORT == 1)) + if (!aPseudoReset) + { + nrf5UartInit(); + } + else + { + nrf5UartClearPendingData(); + } +#endif + +#if (SPIS_AS_SERIAL_TRANSPORT == 1) + nrf5SpiSlaveInit(); +#endif +} + +void nrf5TransportDeinit(bool aPseudoReset) +{ +#if ((UART_AS_SERIAL_TRANSPORT == 1) || (USB_CDC_AS_SERIAL_TRANSPORT == 1)) + if (!aPseudoReset) + { + nrf5UartDeinit(); + } +#endif + +#if (SPIS_AS_SERIAL_TRANSPORT == 1) + nrf5SpiSlaveDeinit(); +#endif +} + +void nrf5TransportProcess(void) +{ +#if ((UART_AS_SERIAL_TRANSPORT == 1) || (USB_CDC_AS_SERIAL_TRANSPORT == 1)) + nrf5UartProcess(); +#endif +#if (SPIS_AS_SERIAL_TRANSPORT == 1) + nrf5SpiSlaveProcess(); +#endif +} diff --git a/examples/platforms/nrf528xx/src/uart.c b/examples/platforms/nrf528xx/src/transport/uart.c similarity index 99% rename from examples/platforms/nrf528xx/src/uart.c rename to examples/platforms/nrf528xx/src/transport/uart.c index 367c59085..2a24bc118 100644 --- a/examples/platforms/nrf528xx/src/uart.c +++ b/examples/platforms/nrf528xx/src/transport/uart.c @@ -44,7 +44,7 @@ #include "openthread-system.h" -#include "platform-nrf5.h" +#include "platform-nrf5-transport.h" #include #include #include diff --git a/examples/platforms/nrf528xx/src/usb-cdc-uart.c b/examples/platforms/nrf528xx/src/transport/usb-cdc-uart.c similarity index 99% rename from examples/platforms/nrf528xx/src/usb-cdc-uart.c rename to examples/platforms/nrf528xx/src/transport/usb-cdc-uart.c index dfc8c9980..31e53a0b8 100644 --- a/examples/platforms/nrf528xx/src/usb-cdc-uart.c +++ b/examples/platforms/nrf528xx/src/transport/usb-cdc-uart.c @@ -51,7 +51,7 @@ #include #include -#include "platform-nrf5.h" +#include "platform-nrf5-transport.h" #include "app_usbd.h" #include "app_usbd_serial_num.h" diff --git a/third_party/NordicSemiconductor/Makefile.am b/third_party/NordicSemiconductor/Makefile.am index caff7ef11..a0629c459 100644 --- a/third_party/NordicSemiconductor/Makefile.am +++ b/third_party/NordicSemiconductor/Makefile.am @@ -90,7 +90,6 @@ COMMONCPPFLAGS -I$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio \ -I$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/fem \ -I$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/fem/three_pin_gpio \ - -I$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/hal \ -I$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/rsch \ -I$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/rsch/raal \ -I$(top_srcdir)/third_party/NordicSemiconductor/drivers/radio/rsch/raal/softdevice \