diff --git a/examples/platforms/nrf528xx/nrf52811/Makefile.am b/examples/platforms/nrf528xx/nrf52811/Makefile.am index a62ec793a..5136f2318 100644 --- a/examples/platforms/nrf528xx/nrf52811/Makefile.am +++ b/examples/platforms/nrf528xx/nrf52811/Makefile.am @@ -62,6 +62,7 @@ COMMONCPPFLAGS -I$(top_srcdir)/third_party/NordicSemiconductor/libraries/app_error \ -I$(top_srcdir)/third_party/NordicSemiconductor/libraries/atfifo \ -I$(top_srcdir)/third_party/NordicSemiconductor/libraries/atomic \ + -I$(top_srcdir)/third_party/NordicSemiconductor/libraries/block_dev \ -I$(top_srcdir)/third_party/NordicSemiconductor/libraries/delay \ -I$(top_srcdir)/third_party/NordicSemiconductor/libraries/utf_converter \ -I$(top_srcdir)/third_party/NordicSemiconductor/nrfx \ diff --git a/examples/platforms/nrf528xx/nrf52833/Makefile.am b/examples/platforms/nrf528xx/nrf52833/Makefile.am index 03e74ae01..0b2103e1f 100644 --- a/examples/platforms/nrf528xx/nrf52833/Makefile.am +++ b/examples/platforms/nrf528xx/nrf52833/Makefile.am @@ -64,6 +64,7 @@ COMMONCPPFLAGS -I$(top_srcdir)/third_party/NordicSemiconductor/libraries/app_error \ -I$(top_srcdir)/third_party/NordicSemiconductor/libraries/atfifo \ -I$(top_srcdir)/third_party/NordicSemiconductor/libraries/atomic \ + -I$(top_srcdir)/third_party/NordicSemiconductor/libraries/block_dev \ -I$(top_srcdir)/third_party/NordicSemiconductor/libraries/delay \ -I$(top_srcdir)/third_party/NordicSemiconductor/libraries/usb \ -I$(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/config \ diff --git a/examples/platforms/nrf528xx/nrf52840/Makefile.am b/examples/platforms/nrf528xx/nrf52840/Makefile.am index de69f2945..e558e00e7 100644 --- a/examples/platforms/nrf528xx/nrf52840/Makefile.am +++ b/examples/platforms/nrf528xx/nrf52840/Makefile.am @@ -64,6 +64,7 @@ COMMONCPPFLAGS -I$(top_srcdir)/third_party/NordicSemiconductor/libraries/app_error \ -I$(top_srcdir)/third_party/NordicSemiconductor/libraries/atfifo \ -I$(top_srcdir)/third_party/NordicSemiconductor/libraries/atomic \ + -I$(top_srcdir)/third_party/NordicSemiconductor/libraries/block_dev \ -I$(top_srcdir)/third_party/NordicSemiconductor/libraries/delay \ -I$(top_srcdir)/third_party/NordicSemiconductor/libraries/usb \ -I$(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/config \ diff --git a/third_party/NordicSemiconductor/Makefile.am b/third_party/NordicSemiconductor/Makefile.am index 9138b1fce..c3760ba99 100644 --- a/third_party/NordicSemiconductor/Makefile.am +++ b/third_party/NordicSemiconductor/Makefile.am @@ -81,6 +81,7 @@ COMMONCPPFLAGS -I$(top_srcdir)/third_party/NordicSemiconductor/libraries/app_error \ -I$(top_srcdir)/third_party/NordicSemiconductor/libraries/atfifo \ -I$(top_srcdir)/third_party/NordicSemiconductor/libraries/atomic \ + -I$(top_srcdir)/third_party/NordicSemiconductor/libraries/block_dev \ -I$(top_srcdir)/third_party/NordicSemiconductor/libraries/delay \ -I$(top_srcdir)/third_party/NordicSemiconductor/libraries/usb \ -I$(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/config \ @@ -318,7 +319,7 @@ noinst_HEADERS $(top_srcdir)/third_party/NordicSemiconductor/cmsis/core_cmSimd.h \ $(top_srcdir)/third_party/NordicSemiconductor/dependencies/app_util_platform.h \ $(top_srcdir)/third_party/NordicSemiconductor/dependencies/app_util.h \ - $(top_srcdir)/third_party/NordicSemiconductor/dependencies/apply_old_config.h \ + $(top_srcdir)/third_party/NordicSemiconductor/dependencies/legacy/apply_old_config.h \ $(top_srcdir)/third_party/NordicSemiconductor/dependencies/nordic_common.h \ $(top_srcdir)/third_party/NordicSemiconductor/dependencies/nrf_assert.h \ $(top_srcdir)/third_party/NordicSemiconductor/dependencies/nrf_error.h \ @@ -400,6 +401,7 @@ noinst_HEADERS $(top_srcdir)/third_party/NordicSemiconductor/libraries/atfifo/nrf_atfifo.h \ $(top_srcdir)/third_party/NordicSemiconductor/libraries/atomic/nrf_atomic_internal.h \ $(top_srcdir)/third_party/NordicSemiconductor/libraries/atomic/nrf_atomic.h \ + $(top_srcdir)/third_party/NordicSemiconductor/libraries/block_dev/nrf_block_dev.h \ $(top_srcdir)/third_party/NordicSemiconductor/libraries/delay/nrf_delay.h \ $(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/app_usbd_class_base.h \ $(top_srcdir)/third_party/NordicSemiconductor/libraries/usb/app_usbd_core.h \ diff --git a/third_party/NordicSemiconductor/README.md b/third_party/NordicSemiconductor/README.md index 13d7a240a..b51ba0ef4 100644 --- a/third_party/NordicSemiconductor/README.md +++ b/third_party/NordicSemiconductor/README.md @@ -1,15 +1,15 @@ Description: This folder consists of selected components from the nRF5 SDK, that are used -in process of building the OpenThread's nRF52840 platform. +in process of building the OpenThread's nRF528xx platform. Directory consists of following folders: - /cmsis - Core Peripheral Access Layer Headers files - - /dependencies - Dependencies for drivers and libraries from nrf5 SDK - - /drivers - Drivers for the nRF52840 that are used in the platform - - /libraries - Libraries for the nRF52840 chip + - /dependencies - Dependencies for drivers and libraries from nRF5 SDK + - /drivers - Drivers for the nRF528xx platform + - /libraries - Libraries for the nRF528xx platform - /nrfx - Standalone drivers for peripherals present in Nordic SoCs (https://github.com/NordicSemiconductor/nrfx) - - /segger_rtt - Library for the RTT communication + - /segger_rtt - Configuration files for RTT communication - /softdevice - SoftDevice s140 headers - The following changes comparing to the nRF5 SDK 15.2 have been incorporated: -- modified nrf_log_ctrl.h file in order to remove unused backend logging functions \ No newline at end of file + The following changes comparing to the nRF5 SDK 16.0 have been incorporated: +- modified nrf_log module files in order to remove unused backend logging functions \ No newline at end of file diff --git a/third_party/NordicSemiconductor/dependencies/app_util.h b/third_party/NordicSemiconductor/dependencies/app_util.h index 7fd701291..b21e25df5 100644 --- a/third_party/NordicSemiconductor/dependencies/app_util.h +++ b/third_party/NordicSemiconductor/dependencies/app_util.h @@ -1,5 +1,5 @@ /** - * Copyright (c) 2012 - 2018, Nordic Semiconductor ASA + * Copyright (c) 2012 - 2019, Nordic Semiconductor ASA * * All rights reserved. * @@ -129,6 +129,15 @@ extern uint32_t __etext; */ /* lint -restore */ +#if defined(MBR_PRESENT) || defined(SOFTDEVICE_PRESENT) +#include "nrf_mbr.h" +#define BOOTLOADER_ADDRESS ((*(uint32_t *)MBR_BOOTLOADER_ADDR) == 0xFFFFFFFF ? *MBR_UICR_BOOTLOADER_ADDR : *(uint32_t *)MBR_BOOTLOADER_ADDR) /**< The currently configured start address of the bootloader. If 0xFFFFFFFF, no bootloader start address is configured. */ +#define MBR_PARAMS_PAGE_ADDRESS ((*(uint32_t *)MBR_PARAM_PAGE_ADDR) == 0xFFFFFFFF ? *MBR_UICR_PARAM_PAGE_ADDR : *(uint32_t *)MBR_PARAM_PAGE_ADDR) /**< The currently configured address of the MBR params page. If 0xFFFFFFFF, no MBR params page address is configured. */ +#else +#define BOOTLOADER_ADDRESS (NRF_UICR->NRFFW[0]) /**< Check UICR, just in case. */ +#define MBR_PARAMS_PAGE_ADDRESS (NRF_UICR->NRFFW[1]) /**< Check UICR, just in case. */ +#endif + enum { UNIT_0_625_MS = 625, /**< Number of microseconds in 0.625 milliseconds. */ @@ -203,9 +212,14 @@ enum #ifndef __LINT__ #ifdef __GNUC__ +#ifdef __cplusplus +#define STATIC_ASSERT_SIMPLE(EXPR) extern char (*_do_assert(void)) [sizeof(char[1 - 2*!(EXPR)])] +#define STATIC_ASSERT_MSG(EXPR, MSG) extern char (*_do_assert(void)) [sizeof(char[1 - 2*!(EXPR)])] +#else #define STATIC_ASSERT_SIMPLE(EXPR) _Static_assert(EXPR, "unspecified message") #define STATIC_ASSERT_MSG(EXPR, MSG) _Static_assert(EXPR, MSG) #endif +#endif #ifdef __CC_ARM #define STATIC_ASSERT_SIMPLE(EXPR) extern char (*_do_assert(void)) [sizeof(char[1 - 2*!(EXPR)])] @@ -775,7 +789,8 @@ typedef struct * @return All arguments processed by given macro */ #define MACRO_MAP_FOR(...) MACRO_MAP_FOR_(__VA_ARGS__) -#define MACRO_MAP_FOR_N_LIST 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 +#define MACRO_MAP_FOR_N_LIST 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, \ + 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32 #define MACRO_MAP_FOR_(...) MACRO_MAP_FOR_N(NUM_VA_ARGS_LESS_1(__VA_ARGS__), __VA_ARGS__) /** @@ -1177,6 +1192,7 @@ static __INLINE uint8_t uint16_big_encode(uint16_t value, uint8_t * p_encoded_da * * @param[in] value Value to be encoded. * @param[out] p_encoded_data Buffer where the encoded data will be written. + * The address pointed to must be word alligned. * * @return Number of bytes written. */ diff --git a/third_party/NordicSemiconductor/dependencies/app_util_platform.c b/third_party/NordicSemiconductor/dependencies/app_util_platform.c index 3c7129a58..8e4f121e4 100644 --- a/third_party/NordicSemiconductor/dependencies/app_util_platform.c +++ b/third_party/NordicSemiconductor/dependencies/app_util_platform.c @@ -1,5 +1,5 @@ /** - * Copyright (c) 2014 - 2018, Nordic Semiconductor ASA + * Copyright (c) 2014 - 2019, Nordic Semiconductor ASA * * All rights reserved. * @@ -71,7 +71,7 @@ void app_util_critical_region_enter(uint8_t *p_nested) /* return value can be safely ignored */ (void) sd_nvic_critical_region_enter(p_nested); #else - (void)p_nested; + UNUSED_PARAMETER(p_nested); app_util_disable_irq(); #endif } @@ -86,8 +86,8 @@ void app_util_critical_region_exit(uint8_t nested) /* return value can be safely ignored */ (void) sd_nvic_critical_region_exit(nested); #else + UNUSED_PARAMETER(nested); app_util_enable_irq(); - (void)nested; #endif } diff --git a/third_party/NordicSemiconductor/dependencies/app_util_platform.h b/third_party/NordicSemiconductor/dependencies/app_util_platform.h index 263258a8b..dd41339ac 100644 --- a/third_party/NordicSemiconductor/dependencies/app_util_platform.h +++ b/third_party/NordicSemiconductor/dependencies/app_util_platform.h @@ -1,5 +1,5 @@ /** - * Copyright (c) 2014 - 2018, Nordic Semiconductor ASA + * Copyright (c) 2014 - 2019, Nordic Semiconductor ASA * * All rights reserved. * @@ -68,6 +68,7 @@ extern "C" { #define _PRIO_APP_HIGH 1 #define _PRIO_APP_MID 1 #define _PRIO_SD_LOW 2 +#define _PRIO_APP_LOW_MID 3 #define _PRIO_APP_LOW 3 #define _PRIO_APP_LOWEST 3 #define _PRIO_THREAD 4 @@ -77,7 +78,7 @@ extern "C" { #define _PRIO_APP_HIGH 2 #define _PRIO_APP_MID 3 #define _PRIO_SD_LOW 4 -#define _PRIO_SD_LOWEST 5 +#define _PRIO_APP_LOW_MID 5 #define _PRIO_APP_LOW 6 #define _PRIO_APP_LOWEST 7 #define _PRIO_THREAD 15 @@ -101,6 +102,7 @@ typedef enum #else APP_IRQ_PRIORITY_MID = _PRIO_APP_MID, #endif + APP_IRQ_PRIORITY_LOW_MID = _PRIO_APP_LOW_MID, APP_IRQ_PRIORITY_LOW = _PRIO_APP_LOW, APP_IRQ_PRIORITY_LOWEST = _PRIO_APP_LOWEST, APP_IRQ_PRIORITY_THREAD = _PRIO_THREAD /**< "Interrupt level" when running in Thread Mode. */ diff --git a/third_party/NordicSemiconductor/dependencies/apply_old_config.h b/third_party/NordicSemiconductor/dependencies/legacy/apply_old_config.h similarity index 99% rename from third_party/NordicSemiconductor/dependencies/apply_old_config.h rename to third_party/NordicSemiconductor/dependencies/legacy/apply_old_config.h index 62ef4755f..b371852cf 100644 --- a/third_party/NordicSemiconductor/dependencies/apply_old_config.h +++ b/third_party/NordicSemiconductor/dependencies/legacy/apply_old_config.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, Nordic Semiconductor ASA + * * 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, except as embedded into a Nordic * Semiconductor ASA integrated circuit in a product or a software update for * such product, 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 Nordic Semiconductor ASA nor the names of its * contributors may be used to endorse or promote products derived from this * software without specific prior written permission. - * + * * 4. This software, with or without modification, must only be used with a * Nordic Semiconductor ASA integrated circuit. - * + * * 5. Any software provided in binary form under this license must not be reverse * engineered, decompiled, modified and/or disassembled. - * + * * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE @@ -35,7 +35,7 @@ * 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. - * + * */ @@ -76,10 +76,16 @@ //------------------------------------------------------------------------------ // CLOCK -#if defined(CLOCK_ENABLED) +#if defined(NRF_CLOCK_ENABLED) + +#if defined(CLOCK_CONFIG_LF_CAL_ENABLED) && defined(CLOCK_CONFIG_LF_SRC) +#if (CLOCK_CONFIG_LF_SRC == CLOCK_LFCLKSRC_SRC_RC) +#define NRFX_CLOCK_CONFIG_LF_CAL_ENABLED 1 +#endif +#endif #undef NRFX_CLOCK_ENABLED -#define NRFX_CLOCK_ENABLED CLOCK_ENABLED +#define NRFX_CLOCK_ENABLED NRF_CLOCK_ENABLED #if defined(CLOCK_CONFIG_LF_SRC) #undef NRFX_CLOCK_CONFIG_LF_SRC @@ -107,7 +113,7 @@ #define NRFX_CLOCK_CONFIG_DEBUG_COLOR CLOCK_CONFIG_DEBUG_COLOR #endif -#endif // defined(CLOCK_ENABLED) +#endif // defined(NRF_CLOCK_ENABLED) //------------------------------------------------------------------------------ // COMP diff --git a/third_party/NordicSemiconductor/dependencies/nordic_common.h b/third_party/NordicSemiconductor/dependencies/nordic_common.h index 82884b1fc..8fcaf5d4a 100644 --- a/third_party/NordicSemiconductor/dependencies/nordic_common.h +++ b/third_party/NordicSemiconductor/dependencies/nordic_common.h @@ -1,5 +1,5 @@ /** - * Copyright (c) 2008 - 2018, Nordic Semiconductor ASA + * Copyright (c) 2008 - 2019, Nordic Semiconductor ASA * * All rights reserved. * diff --git a/third_party/NordicSemiconductor/dependencies/nrf_assert.h b/third_party/NordicSemiconductor/dependencies/nrf_assert.h index 438ab95d8..86853622a 100644 --- a/third_party/NordicSemiconductor/dependencies/nrf_assert.h +++ b/third_party/NordicSemiconductor/dependencies/nrf_assert.h @@ -1,5 +1,5 @@ /** - * Copyright (c) 2006 - 2018, Nordic Semiconductor ASA + * Copyright (c) 2006 - 2019, Nordic Semiconductor ASA * * All rights reserved. * diff --git a/third_party/NordicSemiconductor/dependencies/nrf_section.h b/third_party/NordicSemiconductor/dependencies/nrf_section.h index 62eda6448..a482be0f5 100644 --- a/third_party/NordicSemiconductor/dependencies/nrf_section.h +++ b/third_party/NordicSemiconductor/dependencies/nrf_section.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2016 - 2018, Nordic Semiconductor ASA - * + * Copyright (c) 2016 - 2019, Nordic Semiconductor ASA + * * 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, except as embedded into a Nordic * Semiconductor ASA integrated circuit in a product or a software update for * such product, 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 Nordic Semiconductor ASA nor the names of its * contributors may be used to endorse or promote products derived from this * software without specific prior written permission. - * + * * 4. This software, with or without modification, must only be used with a * Nordic Semiconductor ASA integrated circuit. - * + * * 5. Any software provided in binary form under this license must not be reverse * engineered, decompiled, modified and/or disassembled. - * + * * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE @@ -35,7 +35,7 @@ * 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. - * + * */ #ifndef NRF_SECTION_H__ #define NRF_SECTION_H__ diff --git a/third_party/NordicSemiconductor/dependencies/nrfx_config.h b/third_party/NordicSemiconductor/dependencies/nrfx_config.h index 72577ef2f..b006b6bcd 100644 --- a/third_party/NordicSemiconductor/dependencies/nrfx_config.h +++ b/third_party/NordicSemiconductor/dependencies/nrfx_config.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, Nordic Semiconductor ASA + * * 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, except as embedded into a Nordic * Semiconductor ASA integrated circuit in a product or a software update for * such product, 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 Nordic Semiconductor ASA nor the names of its * contributors may be used to endorse or promote products derived from this * software without specific prior written permission. - * + * * 4. This software, with or without modification, must only be used with a * Nordic Semiconductor ASA integrated circuit. - * + * * 5. Any software provided in binary form under this license must not be reverse * engineered, decompiled, modified and/or disassembled. - * + * * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE @@ -35,7 +35,7 @@ * 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. - * + * */ #ifndef NRFX_CONFIG_H__ diff --git a/third_party/NordicSemiconductor/dependencies/nrfx_glue.h b/third_party/NordicSemiconductor/dependencies/nrfx_glue.h index 0a41b981a..20c5fbdcb 100644 --- a/third_party/NordicSemiconductor/dependencies/nrfx_glue.h +++ b/third_party/NordicSemiconductor/dependencies/nrfx_glue.h @@ -1,30 +1,30 @@ /** * Copyright (c) 2017 - 2019, Nordic Semiconductor ASA - * + * * 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, except as embedded into a Nordic * Semiconductor ASA integrated circuit in a product or a software update for * such product, 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 Nordic Semiconductor ASA nor the names of its * contributors may be used to endorse or promote products derived from this * software without specific prior written permission. - * + * * 4. This software, with or without modification, must only be used with a * Nordic Semiconductor ASA integrated circuit. - * + * * 5. Any software provided in binary form under this license must not be reverse * engineered, decompiled, modified and/or disassembled. - * + * * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE @@ -35,7 +35,7 @@ * 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. - * + * */ #ifndef NRFX_GLUE_H__ @@ -54,7 +54,7 @@ extern "C" { * the needs of the host environment into which @em nrfx is integrated. */ -#include +#include #include diff --git a/third_party/NordicSemiconductor/dependencies/nrfx_log.h b/third_party/NordicSemiconductor/dependencies/nrfx_log.h index 4c2546ef3..c4d81a70e 100644 --- a/third_party/NordicSemiconductor/dependencies/nrfx_log.h +++ b/third_party/NordicSemiconductor/dependencies/nrfx_log.h @@ -1,30 +1,30 @@ /** - * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA - * + * Copyright (c) 2017 - 2019, Nordic Semiconductor ASA + * * 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, except as embedded into a Nordic * Semiconductor ASA integrated circuit in a product or a software update for * such product, 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 Nordic Semiconductor ASA nor the names of its * contributors may be used to endorse or promote products derived from this * software without specific prior written permission. - * + * * 4. This software, with or without modification, must only be used with a * Nordic Semiconductor ASA integrated circuit. - * + * * 5. Any software provided in binary form under this license must not be reverse * engineered, decompiled, modified and/or disassembled. - * + * * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE @@ -35,7 +35,7 @@ * 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. - * + * */ #ifndef NRFX_LOG_H__ diff --git a/third_party/NordicSemiconductor/dependencies/sdk_common.h b/third_party/NordicSemiconductor/dependencies/sdk_common.h index 5f42f03a4..29b200b70 100644 --- a/third_party/NordicSemiconductor/dependencies/sdk_common.h +++ b/third_party/NordicSemiconductor/dependencies/sdk_common.h @@ -1,5 +1,5 @@ /** - * Copyright (c) 2013 - 2018, Nordic Semiconductor ASA + * Copyright (c) 2013 - 2019, Nordic Semiconductor ASA * * All rights reserved. * diff --git a/third_party/NordicSemiconductor/dependencies/sdk_config.h b/third_party/NordicSemiconductor/dependencies/sdk_config.h index e7b144bda..e9d08f0bf 100644 --- a/third_party/NordicSemiconductor/dependencies/sdk_config.h +++ b/third_party/NordicSemiconductor/dependencies/sdk_config.h @@ -36,24 +36,33 @@ #define APP_USBD_PID 0xCAFE #endif -// APP_USBD_DEVICE_VER_MAJOR - Device version, major part <0-99> +// APP_USBD_DEVICE_VER_MAJOR - Major device version <0-99> -// Device version, will be converted automatically to BCD notation. Use just decimal values. +// Major device version, will be converted automatically to BCD notation. Use just decimal values. #ifndef APP_USBD_DEVICE_VER_MAJOR #define APP_USBD_DEVICE_VER_MAJOR 1 #endif -// APP_USBD_DEVICE_VER_MINOR - Device version, minor part <0-99> +// APP_USBD_DEVICE_VER_MINOR - Minor device version <0-9> -// Device version, will be converted automatically to BCD notation. Use just decimal values. +// Minor device version, will be converted automatically to BCD notation. Use just decimal values. #ifndef APP_USBD_DEVICE_VER_MINOR #define APP_USBD_DEVICE_VER_MINOR 0 #endif +// APP_USBD_DEVICE_VER_SUB - Sub-minor device version <0-9> + + +// Sub-minor device version, will be converted automatically to BCD notation. Use just decimal values. + +#ifndef APP_USBD_DEVICE_VER_SUB +#define APP_USBD_DEVICE_VER_SUB 0 +#endif + // APP_USBD_CONFIG_SELF_POWERED - Self powered @@ -559,10 +568,10 @@ // //========================================================== -// CLOCK_ENABLED - nrf_drv_clock - CLOCK peripheral driver +// NRF_CLOCK_ENABLED - nrf_drv_clock - CLOCK peripheral driver //========================================================== -#ifndef CLOCK_ENABLED -#define CLOCK_ENABLED 1 +#ifndef NRF_CLOCK_ENABLED +#define NRF_CLOCK_ENABLED 1 #endif // CLOCK_CONFIG_XTAL_FREQ - HF XTAL Frequency diff --git a/third_party/NordicSemiconductor/dependencies/sdk_errors.h b/third_party/NordicSemiconductor/dependencies/sdk_errors.h index b482522aa..7d3a96b49 100644 --- a/third_party/NordicSemiconductor/dependencies/sdk_errors.h +++ b/third_party/NordicSemiconductor/dependencies/sdk_errors.h @@ -1,5 +1,5 @@ /** - * Copyright (c) 2013 - 2018, Nordic Semiconductor ASA + * Copyright (c) 2013 - 2019, Nordic Semiconductor ASA * * All rights reserved. * @@ -93,6 +93,7 @@ extern "C" { #define NRF_ERROR_GAZELLE_ERR_BASE (0x8300) /**< Base address for Gazelle related errors. */ #define NRF_ERROR_BLE_IPSP_ERR_BASE (0x8400) /**< Base address for BLE IPSP related errors. */ #define NRF_ERROR_CRYPTO_ERR_BASE (0x8500) /**< Base address for crypto related errors. */ +#define NRF_ERROR_FDS_ERR_BASE (0x8600) /**< Base address for FDS related errors. */ /** @} */ diff --git a/third_party/NordicSemiconductor/dependencies/sdk_macros.h b/third_party/NordicSemiconductor/dependencies/sdk_macros.h index b93821d4a..4a0b2e9d9 100644 --- a/third_party/NordicSemiconductor/dependencies/sdk_macros.h +++ b/third_party/NordicSemiconductor/dependencies/sdk_macros.h @@ -1,5 +1,5 @@ /** - * Copyright (c) 2013 - 2018, Nordic Semiconductor ASA + * Copyright (c) 2013 - 2019, Nordic Semiconductor ASA * * All rights reserved. * @@ -190,6 +190,15 @@ do \ #define VERIFY_MODULE_INITIALIZED_VOID() VERIFY_TRUE_VOID((MODULE_INITIALIZED)) +/**@brief Macro for verifying that the module is initialized. It will cause the exterior function to + * return false if not. + * + * @note MODULE_INITIALIZED must be defined in each module using this macro. MODULE_INITIALIZED + * should be true if the module is initialized, false if not. + */ +#define VERIFY_MODULE_INITIALIZED_BOOL() VERIFY_TRUE((MODULE_INITIALIZED), false) + + /**@brief Macro for verifying that the module is initialized. It will cause the exterior function to * return if not. * diff --git a/third_party/NordicSemiconductor/dependencies/sdk_os.h b/third_party/NordicSemiconductor/dependencies/sdk_os.h index dd356bb00..b75954c08 100644 --- a/third_party/NordicSemiconductor/dependencies/sdk_os.h +++ b/third_party/NordicSemiconductor/dependencies/sdk_os.h @@ -1,5 +1,5 @@ /** - * Copyright (c) 2013 - 2018, Nordic Semiconductor ASA + * Copyright (c) 2013 - 2019, Nordic Semiconductor ASA * * All rights reserved. * diff --git a/third_party/NordicSemiconductor/dependencies/sdk_resources.h b/third_party/NordicSemiconductor/dependencies/sdk_resources.h index 0185632f7..c066b1741 100644 --- a/third_party/NordicSemiconductor/dependencies/sdk_resources.h +++ b/third_party/NordicSemiconductor/dependencies/sdk_resources.h @@ -1,5 +1,5 @@ /** - * Copyright (c) 2015 - 2018, Nordic Semiconductor ASA + * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA * * All rights reserved. * diff --git a/third_party/NordicSemiconductor/drivers/clock/nrf_drv_clock.c b/third_party/NordicSemiconductor/drivers/clock/nrf_drv_clock.c index d45ca8d9d..cc3a07cfe 100644 --- a/third_party/NordicSemiconductor/drivers/clock/nrf_drv_clock.c +++ b/third_party/NordicSemiconductor/drivers/clock/nrf_drv_clock.c @@ -1,5 +1,5 @@ /** - * Copyright (c) 2016 - 2018, Nordic Semiconductor ASA + * Copyright (c) 2016 - 2019, Nordic Semiconductor ASA * * All rights reserved. * @@ -41,6 +41,8 @@ #include #include "nrf_drv_clock.h" +#if NRF_MODULE_ENABLED(NRF_CLOCK) + #ifdef SOFTDEVICE_PRESENT #include "nrf_sdh.h" #include "nrf_sdh_soc.h" @@ -599,3 +601,5 @@ NRF_SDH_STATE_OBSERVER(m_sd_state_observer, CLOCK_CONFIG_STATE_OBSERVER_PRIO) = #undef NRF_CLOCK_LFCLK_RC #undef NRF_CLOCK_LFCLK_Xtal #undef NRF_CLOCK_LFCLK_Synth + +#endif // NRF_MODULE_ENABLED(NRF_CLOCK) diff --git a/third_party/NordicSemiconductor/drivers/clock/nrf_drv_clock.h b/third_party/NordicSemiconductor/drivers/clock/nrf_drv_clock.h index 8b9867cbe..53c0ec84d 100644 --- a/third_party/NordicSemiconductor/drivers/clock/nrf_drv_clock.h +++ b/third_party/NordicSemiconductor/drivers/clock/nrf_drv_clock.h @@ -1,5 +1,5 @@ /** - * Copyright (c) 2016 - 2018, Nordic Semiconductor ASA + * Copyright (c) 2016 - 2019, Nordic Semiconductor ASA * * All rights reserved. * diff --git a/third_party/NordicSemiconductor/drivers/common/nrf_drv_common.h b/third_party/NordicSemiconductor/drivers/common/nrf_drv_common.h index 5eccd8b81..909562f14 100644 --- a/third_party/NordicSemiconductor/drivers/common/nrf_drv_common.h +++ b/third_party/NordicSemiconductor/drivers/common/nrf_drv_common.h @@ -1,5 +1,5 @@ /** - * Copyright (c) 2015 - 2018, Nordic Semiconductor ASA + * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA * * All rights reserved. * diff --git a/third_party/NordicSemiconductor/drivers/power/nrf_drv_power.c b/third_party/NordicSemiconductor/drivers/power/nrf_drv_power.c index 44f7c2d1d..5141ec4e4 100644 --- a/third_party/NordicSemiconductor/drivers/power/nrf_drv_power.c +++ b/third_party/NordicSemiconductor/drivers/power/nrf_drv_power.c @@ -1,5 +1,5 @@ /** - * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA + * Copyright (c) 2017 - 2019, Nordic Semiconductor ASA * * All rights reserved. * @@ -67,11 +67,12 @@ bool nrf_drv_power_init_check(void) ret_code_t nrf_drv_power_init(nrf_drv_power_config_t const * p_config) { -#ifdef SOFTDEVICE_PRESENT if (m_initialized) { return NRF_ERROR_MODULE_ALREADY_INITIALIZED; } + +#ifdef SOFTDEVICE_PRESENT if (nrf_sdh_is_enabled()) { return NRF_ERROR_INVALID_STATE; diff --git a/third_party/NordicSemiconductor/drivers/power/nrf_drv_power.h b/third_party/NordicSemiconductor/drivers/power/nrf_drv_power.h index 347b18c89..105dda27b 100644 --- a/third_party/NordicSemiconductor/drivers/power/nrf_drv_power.h +++ b/third_party/NordicSemiconductor/drivers/power/nrf_drv_power.h @@ -1,5 +1,5 @@ /** - * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA + * Copyright (c) 2017 - 2019, Nordic Semiconductor ASA * * All rights reserved. * diff --git a/third_party/NordicSemiconductor/drivers/systick/nrf_drv_systick.h b/third_party/NordicSemiconductor/drivers/systick/nrf_drv_systick.h index d037fd37d..cb3f4f337 100644 --- a/third_party/NordicSemiconductor/drivers/systick/nrf_drv_systick.h +++ b/third_party/NordicSemiconductor/drivers/systick/nrf_drv_systick.h @@ -1,5 +1,5 @@ /** - * Copyright (c) 2016 - 2018, Nordic Semiconductor ASA + * Copyright (c) 2016 - 2019, Nordic Semiconductor ASA * * All rights reserved. * diff --git a/third_party/NordicSemiconductor/drivers/usbd/nrf_drv_usbd.h b/third_party/NordicSemiconductor/drivers/usbd/nrf_drv_usbd.h index 427cc1da8..db30fce08 100644 --- a/third_party/NordicSemiconductor/drivers/usbd/nrf_drv_usbd.h +++ b/third_party/NordicSemiconductor/drivers/usbd/nrf_drv_usbd.h @@ -1,4 +1,42 @@ -/*$$$LICENCE_NORDIC_STANDARD<2016>$$$*/ +/** + * Copyright (c) 2016 - 2019, Nordic Semiconductor ASA + * + * 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, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, 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 Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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. + * + */ #ifndef NRF_DRV_USBD_H__ #define NRF_DRV_USBD_H__ diff --git a/third_party/NordicSemiconductor/libraries/atfifo/nrf_atfifo.c b/third_party/NordicSemiconductor/libraries/atfifo/nrf_atfifo.c index ff852d649..836e3b909 100644 --- a/third_party/NordicSemiconductor/libraries/atfifo/nrf_atfifo.c +++ b/third_party/NordicSemiconductor/libraries/atfifo/nrf_atfifo.c @@ -1,5 +1,5 @@ /** - * Copyright (c) 2011 - 2018, Nordic Semiconductor ASA + * Copyright (c) 2011 - 2019, Nordic Semiconductor ASA * * All rights reserved. * diff --git a/third_party/NordicSemiconductor/libraries/atfifo/nrf_atfifo.h b/third_party/NordicSemiconductor/libraries/atfifo/nrf_atfifo.h index 934f9acd0..e8c2ad0f0 100644 --- a/third_party/NordicSemiconductor/libraries/atfifo/nrf_atfifo.h +++ b/third_party/NordicSemiconductor/libraries/atfifo/nrf_atfifo.h @@ -1,5 +1,5 @@ /** - * Copyright (c) 2011 - 2018, Nordic Semiconductor ASA + * Copyright (c) 2011 - 2019, Nordic Semiconductor ASA * * All rights reserved. * diff --git a/third_party/NordicSemiconductor/libraries/atfifo/nrf_atfifo_internal.h b/third_party/NordicSemiconductor/libraries/atfifo/nrf_atfifo_internal.h index eeb0aaa1e..8e87eb576 100644 --- a/third_party/NordicSemiconductor/libraries/atfifo/nrf_atfifo_internal.h +++ b/third_party/NordicSemiconductor/libraries/atfifo/nrf_atfifo_internal.h @@ -1,5 +1,5 @@ /** - * Copyright (c) 2011 - 2018, Nordic Semiconductor ASA + * Copyright (c) 2011 - 2019, Nordic Semiconductor ASA * * All rights reserved. * diff --git a/third_party/NordicSemiconductor/libraries/atomic/nrf_atomic.c b/third_party/NordicSemiconductor/libraries/atomic/nrf_atomic.c index ce091cae9..cf4681226 100644 --- a/third_party/NordicSemiconductor/libraries/atomic/nrf_atomic.c +++ b/third_party/NordicSemiconductor/libraries/atomic/nrf_atomic.c @@ -1,5 +1,5 @@ /** - * Copyright (c) 2018, Nordic Semiconductor ASA + * Copyright (c) 2018 - 2019, Nordic Semiconductor ASA * * All rights reserved. * diff --git a/third_party/NordicSemiconductor/libraries/atomic/nrf_atomic.h b/third_party/NordicSemiconductor/libraries/atomic/nrf_atomic.h index 7493197a5..137aadc4d 100644 --- a/third_party/NordicSemiconductor/libraries/atomic/nrf_atomic.h +++ b/third_party/NordicSemiconductor/libraries/atomic/nrf_atomic.h @@ -1,5 +1,5 @@ /** - * Copyright (c) 2016 - 2018, Nordic Semiconductor ASA + * Copyright (c) 2016 - 2019, Nordic Semiconductor ASA * * All rights reserved. * diff --git a/third_party/NordicSemiconductor/libraries/atomic/nrf_atomic_internal.h b/third_party/NordicSemiconductor/libraries/atomic/nrf_atomic_internal.h index 7ed7bb18e..ab114f675 100644 --- a/third_party/NordicSemiconductor/libraries/atomic/nrf_atomic_internal.h +++ b/third_party/NordicSemiconductor/libraries/atomic/nrf_atomic_internal.h @@ -1,5 +1,5 @@ /** - * Copyright (c) 2016 - 2018, Nordic Semiconductor ASA + * Copyright (c) 2016 - 2019, Nordic Semiconductor ASA * * All rights reserved. * diff --git a/third_party/NordicSemiconductor/libraries/block_dev/nrf_block_dev.h b/third_party/NordicSemiconductor/libraries/block_dev/nrf_block_dev.h new file mode 100644 index 000000000..0f57d92ce --- /dev/null +++ b/third_party/NordicSemiconductor/libraries/block_dev/nrf_block_dev.h @@ -0,0 +1,352 @@ +/** + * Copyright (c) 2016 - 2019, Nordic Semiconductor ASA + * + * 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, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, 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 Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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. + * + */ +#ifndef NRF_BLOCK_DEV_H__ +#define NRF_BLOCK_DEV_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "sdk_common.h" +#include "nrf_assert.h" + +#include + +/**@file + * + * @defgroup nrf_block_dev Block device + * @{ + * @ingroup app_common + * + * @brief This module implements unified block device API. It could used as a middle layer between + * filesystems and memories. + */ + +/** + * @brief Block device request descriptor item. + */ +typedef struct { + uint32_t blk_id; //!< Block ID + uint32_t blk_count; //!< Block count + void * p_buff; //!< Data buffer +} nrf_block_req_t; + + +/** + * @brief Helper macro to create block device read/write request item + * + * @param name Instance name + * @param block_start Block number start + * @param block_count Number of blocks + * @param buff Buffer to read/write + */ +#define NRF_BLOCK_DEV_REQUEST(name, block_start, block_count, buff) \ + nrf_block_req_t name = { \ + .blk_id = block_start, \ + .blk_count = block_count, \ + .p_buff = buff, \ + } +/** + * @brief Block device events. + * + * Events are propagated when event handler is defined (@ref nrf_blk_dev_init) + * + */ +typedef enum { + NRF_BLOCK_DEV_EVT_INIT, /**< Passed to event handler when init is done*/ + NRF_BLOCK_DEV_EVT_UNINIT, /**< Passed to event handler when uninit is done*/ + NRF_BLOCK_DEV_EVT_BLK_READ_DONE, /**< Passed to event handler block read operation is done*/ + NRF_BLOCK_DEV_EVT_BLK_WRITE_DONE, /**< Passed to event handler block write operation is done*/ +} nrf_block_dev_event_type_t; + +typedef enum { + NRF_BLOCK_DEV_RESULT_SUCCESS = 0, /**< Operation completed succsefully*/ + NRF_BLOCK_DEV_RESULT_IO_ERROR, /**< I/O error*/ + NRF_BLOCK_DEV_RESULT_TIMEOUT, /**< Device timeout*/ +} nrf_block_dev_result_t; + +/** + * @brief Block device event + * */ +typedef struct { + nrf_block_dev_event_type_t ev_type; //!< Event type + nrf_block_dev_result_t result; //!< Operation status + nrf_block_req_t const * p_blk_req; //!< Block request + void const * p_context; //!< Event context +} nrf_block_dev_event_t; + +struct nrf_block_dev_s; + +/** + * @brief Block device event handler. + * + * @param[in] p_blk_dev Block device handle + * @param[in] p_event Block device event + */ +typedef void (* nrf_block_dev_ev_handler)(struct nrf_block_dev_s const * p_blk_dev, + nrf_block_dev_event_t const * p_event); + +/** + * @brief Block device geometry + */ +typedef struct { + uint32_t blk_count; //!< Block count + uint32_t blk_size; //!< Block size +} nrf_block_dev_geometry_t; + +/** + * @brief Block device information strings + */ +typedef struct { + const char * p_vendor; //!< Vendor string + const char * p_product; //!< Product string + const char * p_revision; //!< Revision string +} nrf_block_dev_info_strings_t; + +/** + * @brief Block device information config + * + * @param vendor Vendor string + * @param product Product string + * @param revision Revision string + * */ +#define NFR_BLOCK_DEV_INFO_CONFIG(vendor, product, revision) ( { \ + .p_vendor = vendor, \ + .p_product = product, \ + .p_revision = revision, \ +}) + +/** + * @brief Empty info string initializer + * */ +#define NFR_BLOCK_DEV_INFO_CONFIG_EMPTY \ + NFR_BLOCK_DEV_INFO_CONFIG(NULL, NULL, NULL) + +/** + * @brief Block device IOCTL requests + */ +typedef enum { + NRF_BLOCK_DEV_IOCTL_REQ_CACHE_FLUSH = 0, /**< Cache flush IOCTL request*/ + NRF_BLOCK_DEV_IOCTL_REQ_INFO_STRINGS, /**< Get info strings IOCTL request*/ +} nrf_block_dev_ioctl_req_t; + + +/** + * @brief Helper macro to get block device address from specific instance + * + * @param instance Block device instance + * @param member Block device member name + * */ +#define NRF_BLOCKDEV_BASE_ADDR(instance, member) &(instance).member + +/** + * @brief Block device API + * */ +typedef struct nrf_block_dev_s { + struct nrf_block_dev_ops_s { + /** + * @brief @ref nrf_blk_dev_init + */ + ret_code_t (*init)(struct nrf_block_dev_s const * p_blk_dev, + nrf_block_dev_ev_handler ev_handler, + void const * p_context); + + /** + * @brief @ref nrf_blk_dev_uninit + */ + ret_code_t (*uninit)(struct nrf_block_dev_s const * p_blk_dev); + + /** + * @brief @ref nrf_blk_dev_read_req + */ + ret_code_t (*read_req)(struct nrf_block_dev_s const * p_blk_dev, + nrf_block_req_t const * p_blk); + + /** + * @brief @ref nrf_blk_dev_write_req + */ + ret_code_t (*write_req)(struct nrf_block_dev_s const * p_blk_dev, + nrf_block_req_t const * p_blk); + + /** + * @brief @ref nrf_blk_dev_ioctl + */ + ret_code_t (*ioctl)(struct nrf_block_dev_s const * p_blk_dev, + nrf_block_dev_ioctl_req_t req, + void * p_data); + + /** + * @brief @ref nrf_blk_dev_geometry + */ + nrf_block_dev_geometry_t const * (*geometry)(struct nrf_block_dev_s const * p_blk_dev); + } const * p_ops; +} nrf_block_dev_t; + +/** + * @brief Internals of @ref nrf_block_dev_t + * */ +typedef struct nrf_block_dev_ops_s nrf_block_dev_ops_t; + +/** + * @brief Initializes a block device. + * + * @param[in] p_blk_dev Block device handle + * @param[in] ev_handler Event handler (pass NULL to work in synchronous mode) + * @param[in] p_context Context passed to event handler + * + * @return Standard error code + */ +static inline ret_code_t nrf_blk_dev_init(nrf_block_dev_t const * p_blk_dev, + nrf_block_dev_ev_handler ev_handler, + void const * p_context) +{ + ASSERT(p_blk_dev->p_ops->init); + return p_blk_dev->p_ops->init(p_blk_dev, ev_handler, p_context); +} + +/** + * @brief Un-initializes a block device. + * + * @param[in] p_blk_dev Block device handle + * + * @return Standard error code + */ +static inline ret_code_t nrf_blk_dev_uninit(nrf_block_dev_t const * p_blk_dev) +{ + ASSERT(p_blk_dev->p_ops->uninit); + return p_blk_dev->p_ops->uninit(p_blk_dev); +} + +/** + * @brief Block read request. + * + * In synchronous mode this function will execute the read operation + * and wait for its completion. In asynchronous mode the function will only request + * the operation and return immediately. Then, the @ref NRF_BLOCK_DEV_EVT_BLK_READ_DONE + * event will signal that operation has been completed and the specified buffer contains + * valid data. + * + * @param[in] p_blk_dev Block device handle + * @param[in] p_blk Block device request + * + * @return Standard error code + */ +static inline ret_code_t nrf_blk_dev_read_req(nrf_block_dev_t const * p_blk_dev, + nrf_block_req_t const * p_blk) +{ + ASSERT(p_blk_dev->p_ops->read_req); + ASSERT(p_blk_dev->p_ops->geometry); + + if (p_blk->blk_id >= p_blk_dev->p_ops->geometry(p_blk_dev)->blk_count) + { + return NRF_ERROR_INVALID_PARAM; + } + + return p_blk_dev->p_ops->read_req(p_blk_dev, p_blk); +} + +/** + * @brief Block write request. + * + * In synchronous mode this function will execute the write operation + * and wait for its completion. In asynchronous mode the function will only request + * the operation and return immediately. Then, the @ref NRF_BLOCK_DEV_EVT_BLK_WRITE_DONE + * event will signal that operation has been completed and the specified buffer + * can be freed. + * + * @param[in] p_blk_dev Block device handle + * @param[in] p_blk Block device request + * + * @return Standard error code + */ +static inline ret_code_t nrf_blk_dev_write_req(nrf_block_dev_t const * p_blk_dev, + nrf_block_req_t const * p_blk) +{ + ASSERT(p_blk_dev->p_ops->write_req); + ASSERT(p_blk_dev->p_ops->geometry); + + if (p_blk->blk_id >= p_blk_dev->p_ops->geometry(p_blk_dev)->blk_count) + { + return NRF_ERROR_INVALID_PARAM; + } + + return p_blk_dev->p_ops->write_req(p_blk_dev, p_blk); +} + +/** + * @brief IO control function. + * + * @param[in] p_blk_dev Block device handle + * @param[in] req Block device ioctl request + * @param[in] p_data Block device ioctl data + * + * @return Standard error code + * */ +static inline ret_code_t nrf_blk_dev_ioctl(nrf_block_dev_t const * p_blk_dev, + nrf_block_dev_ioctl_req_t req, + void * p_data) +{ + ASSERT(p_blk_dev->p_ops->ioctl); + return p_blk_dev->p_ops->ioctl(p_blk_dev, req, p_data); +} + +/** + * @brief Return a geometry of a block device. + * + * @param[in] p_blk_dev Block device handle + * + * @return Block size and count @ref nrf_block_dev_geometry_t + */ +static inline nrf_block_dev_geometry_t const * +nrf_blk_dev_geometry(nrf_block_dev_t const * p_blk_dev) +{ + ASSERT(p_blk_dev->p_ops->geometry); + return p_blk_dev->p_ops->geometry(p_blk_dev); +} + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* NRF_BLOCK_DEV_H__ */ + + diff --git a/third_party/NordicSemiconductor/libraries/delay/nrf_delay.h b/third_party/NordicSemiconductor/libraries/delay/nrf_delay.h index 1b58a587b..3719683d3 100644 --- a/third_party/NordicSemiconductor/libraries/delay/nrf_delay.h +++ b/third_party/NordicSemiconductor/libraries/delay/nrf_delay.h @@ -1,5 +1,5 @@ /** - * Copyright (c) 2011 - 2018, Nordic Semiconductor ASA + * Copyright (c) 2011 - 2019, Nordic Semiconductor ASA * * All rights reserved. * diff --git a/third_party/NordicSemiconductor/libraries/usb/app_usbd.c b/third_party/NordicSemiconductor/libraries/usb/app_usbd.c index 998cb7b1f..23a8c4bc5 100644 --- a/third_party/NordicSemiconductor/libraries/usb/app_usbd.c +++ b/third_party/NordicSemiconductor/libraries/usb/app_usbd.c @@ -1,5 +1,5 @@ /** - * Copyright (c) 2016 - 2018, Nordic Semiconductor ASA + * Copyright (c) 2016 - 2019, Nordic Semiconductor ASA * * All rights reserved. * diff --git a/third_party/NordicSemiconductor/libraries/usb/app_usbd.h b/third_party/NordicSemiconductor/libraries/usb/app_usbd.h index 0bb881d90..c5369fc9d 100644 --- a/third_party/NordicSemiconductor/libraries/usb/app_usbd.h +++ b/third_party/NordicSemiconductor/libraries/usb/app_usbd.h @@ -1,5 +1,5 @@ /** - * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA + * Copyright (c) 2017 - 2019, Nordic Semiconductor ASA * * All rights reserved. * diff --git a/third_party/NordicSemiconductor/libraries/usb/app_usbd_class_base.h b/third_party/NordicSemiconductor/libraries/usb/app_usbd_class_base.h index 7420c7bf2..a770b57ff 100644 --- a/third_party/NordicSemiconductor/libraries/usb/app_usbd_class_base.h +++ b/third_party/NordicSemiconductor/libraries/usb/app_usbd_class_base.h @@ -1,5 +1,5 @@ /** - * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA + * Copyright (c) 2017 - 2019, Nordic Semiconductor ASA * * All rights reserved. * diff --git a/third_party/NordicSemiconductor/libraries/usb/app_usbd_core.c b/third_party/NordicSemiconductor/libraries/usb/app_usbd_core.c index 8988679d5..6200bfe8a 100644 --- a/third_party/NordicSemiconductor/libraries/usb/app_usbd_core.c +++ b/third_party/NordicSemiconductor/libraries/usb/app_usbd_core.c @@ -1,5 +1,5 @@ /** - * Copyright (c) 2016 - 2018, Nordic Semiconductor ASA + * Copyright (c) 2016 - 2019, Nordic Semiconductor ASA * * All rights reserved. * @@ -95,7 +95,7 @@ NRF_LOG_MODULE_REGISTER(); #define APP_USBD_CORE_DEVICE_DESCRIPTOR { \ .bLength = sizeof(app_usbd_descriptor_device_t), /* descriptor size */ \ .bDescriptorType = APP_USBD_DESCRIPTOR_DEVICE, /* descriptor type */ \ - .bcdUSB = APP_USBD_BCD_VER_MAKE(2,0), /* USB BCD version: 2.0 */ \ + .bcdUSB = APP_USBD_BCD_VER_MAKE(2,0,0), /* USB BCD version: 2.0 */ \ .bDeviceClass = 0, /* device class: 0 - specified by interface */ \ .bDeviceSubClass = 0, /* device subclass: 0 - specified by interface */ \ .bDeviceProtocol = 0, /* device protocol: 0 - specified by interface */ \ @@ -104,7 +104,8 @@ NRF_LOG_MODULE_REGISTER(); .idProduct = APP_USBD_PID, /* Product ID*/ \ .bcdDevice = APP_USBD_BCD_VER_MAKE( /* Device version BCD */ \ APP_USBD_DEVICE_VER_MAJOR, \ - APP_USBD_DEVICE_VER_MINOR), \ + APP_USBD_DEVICE_VER_MINOR, \ + APP_USBD_DEVICE_VER_SUB), \ .iManufacturer = APP_USBD_STRING_ID_MANUFACTURER, /* String ID: manufacturer */ \ .iProduct = APP_USBD_STRING_ID_PRODUCT, /* String ID: product */ \ .iSerialNumber = APP_USBD_STRING_ID_SERIAL, /* String ID: serial */ \ @@ -508,7 +509,7 @@ static ret_code_t setup_endpoint_req_std(app_usbd_setup_evt_t const * p_setup_ev nrf_drv_usbd_ep_t ep_addr = (nrf_drv_usbd_ep_t)(p_setup_ev->setup.wIndex.lb); app_usbd_state_t usb_state = usbd_core_state_get(); - switch (p_setup_ev->setup.bmRequest) + switch (p_setup_ev->setup.bRequest) { case APP_USBD_SETUP_STDREQ_GET_STATUS: { @@ -589,7 +590,7 @@ static ret_code_t setup_interface_req_std_handle( if (app_usbd_setup_req_dir(p_setup_ev->setup.bmRequestType) == APP_USBD_SETUP_REQDIR_IN) { - switch (p_setup_ev->setup.bmRequest) + switch (p_setup_ev->setup.bRequest) { case APP_USBD_SETUP_STDREQ_GET_STATUS: { @@ -617,7 +618,7 @@ static ret_code_t setup_interface_req_std_handle( } else /* APP_USBD_SETUP_REQDIR_OUT */ { - switch (p_setup_ev->setup.bmRequest) + switch (p_setup_ev->setup.bRequest) { case APP_USBD_SETUP_STDREQ_SET_INTERFACE: { @@ -679,12 +680,22 @@ static ret_code_t setup_device_req_get_descriptor(app_usbd_class_inst_t const * { case APP_USBD_DESCRIPTOR_DEVICE: { + if(p_setup_ev->setup.wLength.w == 0) + { + return NRF_SUCCESS; + } + return app_usbd_core_setup_rsp(&(p_setup_ev->setup), &m_device_dsc, sizeof(m_device_dsc)); } case APP_USBD_DESCRIPTOR_CONFIGURATION: { + if(p_setup_ev->setup.wLength.w == 0) + { + return NRF_SUCCESS; + } + /* The size equals the size of configuration descriptor and all classes descriptors */ const size_t size = MIN( sizeof(app_usbd_descriptor_configuration_t), @@ -756,6 +767,11 @@ static ret_code_t setup_device_req_get_descriptor(app_usbd_class_inst_t const * } case APP_USBD_DESCRIPTOR_STRING: { + if(p_setup_ev->setup.wLength.w == 0) + { + return NRF_SUCCESS; + } + app_usbd_string_desc_idx_t id = (app_usbd_string_desc_idx_t)(p_setup_ev->setup.wValue.lb); uint16_t langid = p_setup_ev->setup.wIndex.w; @@ -853,7 +869,7 @@ static ret_code_t setup_device_req_std_handler(app_usbd_class_inst_t const * con if (app_usbd_setup_req_dir(p_setup_ev->setup.bmRequestType) == APP_USBD_SETUP_REQDIR_IN) { - switch (p_setup_ev->setup.bmRequest) + switch (p_setup_ev->setup.bRequest) { case APP_USBD_SETUP_STDREQ_GET_STATUS: { @@ -875,7 +891,7 @@ static ret_code_t setup_device_req_std_handler(app_usbd_class_inst_t const * con } else /* APP_USBD_SETUP_REQDIR_OUT */ { - switch (p_setup_ev->setup.bmRequest) + switch (p_setup_ev->setup.bRequest) { case APP_USBD_SETUP_STDREQ_SET_ADDRESS: { @@ -940,7 +956,7 @@ static inline ret_code_t app_usbd_core_setup_req_handler(app_usbd_class_inst_t c NRF_LOG_DEBUG("SETUP: t: 0x%.2x r: 0x%.2x", setup_ev.setup.bmRequestType, - setup_ev.setup.bmRequest); + setup_ev.setup.bRequest); if (usb_core_ep0_handler_check()) { NRF_LOG_WARNING("Previous setup not finished!"); diff --git a/third_party/NordicSemiconductor/libraries/usb/app_usbd_core.h b/third_party/NordicSemiconductor/libraries/usb/app_usbd_core.h index bdbf861dd..efa9d3e56 100644 --- a/third_party/NordicSemiconductor/libraries/usb/app_usbd_core.h +++ b/third_party/NordicSemiconductor/libraries/usb/app_usbd_core.h @@ -1,5 +1,5 @@ /** - * Copyright (c) 2016 - 2018, Nordic Semiconductor ASA + * Copyright (c) 2016 - 2019, Nordic Semiconductor ASA * * All rights reserved. * diff --git a/third_party/NordicSemiconductor/libraries/usb/app_usbd_descriptor.h b/third_party/NordicSemiconductor/libraries/usb/app_usbd_descriptor.h index 3cffc74e9..5c2e100cf 100644 --- a/third_party/NordicSemiconductor/libraries/usb/app_usbd_descriptor.h +++ b/third_party/NordicSemiconductor/libraries/usb/app_usbd_descriptor.h @@ -1,5 +1,5 @@ /** - * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA + * Copyright (c) 2017 - 2019, Nordic Semiconductor ASA * * All rights reserved. * @@ -85,7 +85,7 @@ ANON_UNIONS_ENABLE; * @brief Descriptor types. * * Descriptor types used in two situations: - * - when processing @ref APP_USBD_SETUP_STDREQ_GET_DESCRIPTOR SETUP request, + * - When processing @ref APP_USBD_SETUP_STDREQ_GET_DESCRIPTOR SETUP request, * the required descriptor type may be placed in wValue in HighByte. * - As a descriptor identifier itself inside descriptor stream. * @@ -118,9 +118,9 @@ typedef enum * Cannot be accessed by GetDescriptor or SetDescriptor */ APP_USBD_DESCRIPTOR_DEVICE_QUALIFIER = 6, /**< @note Not supported - used only in HighSpeed capable devices. */ - APP_USBD_DESCRIPTOR_OTHER_SPEED_CONFIGURATION = 7, /**< @note Not supported - our USB implementation supports only one speed. */ + APP_USBD_DESCRIPTOR_OTHER_SPEED_CONFIGURATION = 7, /**< @note Not supported - USB library supports only one speed. */ APP_USBD_DESCRIPTOR_INTERFACE_POWER = 8, /**< @note Not supported */ - APP_USBD_DESCRIPTOR_OTG = 9, /**< @note Not supported - Our USB have not OTG functionality */ + APP_USBD_DESCRIPTOR_OTG = 9, /**< @note Not supported - USB library does not have OTG functionality */ APP_USBD_DESCRIPTOR_DEBUG = 10, /**< Debug channel descriptor if available, can be only reached by GetDescriptor */ APP_USBD_DESCRIPTOR_INTERFACE_ASSOCIATION = 11, /**< * Descriptor used to describe that two or more interfaces are associated to the same function. diff --git a/third_party/NordicSemiconductor/libraries/usb/app_usbd_langid.h b/third_party/NordicSemiconductor/libraries/usb/app_usbd_langid.h index b38cddf2b..14a464d10 100644 --- a/third_party/NordicSemiconductor/libraries/usb/app_usbd_langid.h +++ b/third_party/NordicSemiconductor/libraries/usb/app_usbd_langid.h @@ -1,5 +1,5 @@ /** - * Copyright (c) 2016 - 2018, Nordic Semiconductor ASA + * Copyright (c) 2016 - 2019, Nordic Semiconductor ASA * * All rights reserved. * diff --git a/third_party/NordicSemiconductor/libraries/usb/app_usbd_nrf_dfu_trigger.c b/third_party/NordicSemiconductor/libraries/usb/app_usbd_nrf_dfu_trigger.c index 7ed4a2bff..1f5c36f15 100755 --- a/third_party/NordicSemiconductor/libraries/usb/app_usbd_nrf_dfu_trigger.c +++ b/third_party/NordicSemiconductor/libraries/usb/app_usbd_nrf_dfu_trigger.c @@ -1,5 +1,5 @@ /** - * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA + * Copyright (c) 2017 - 2019, Nordic Semiconductor ASA * * All rights reserved. * @@ -110,7 +110,7 @@ static ret_code_t setup_req_std_in(app_usbd_class_inst_t const * p_inst, /* Only Get Descriptor standard IN request is supported by DFU class */ if ((app_usbd_setup_req_rec(p_setup_ev->setup.bmRequestType) == APP_USBD_SETUP_REQREC_INTERFACE) && - (p_setup_ev->setup.bmRequest == APP_USBD_SETUP_STDREQ_GET_DESCRIPTOR)) + (p_setup_ev->setup.bRequest == APP_USBD_SETUP_STDREQ_GET_DESCRIPTOR)) { size_t dsc_len = 0; size_t max_size; @@ -146,7 +146,7 @@ static ret_code_t setup_req_std_out(app_usbd_class_inst_t const * p_inst, app_usbd_setup_evt_t const * p_setup_ev) { - switch (p_setup_ev->setup.bmRequest) + switch (p_setup_ev->setup.bRequest) { default: break; @@ -185,7 +185,7 @@ static ret_code_t setup_req_class_in(app_usbd_class_inst_t const * p_inst, { app_usbd_nrf_dfu_trigger_t const * p_dfu = nrf_dfu_trigger_get(p_inst); - switch (p_setup_ev->setup.bmRequest) + switch (p_setup_ev->setup.bRequest) { case APP_USBD_NRF_DFU_TRIGGER_REQ_NORDIC_INFO: if (p_setup_ev->setup.wLength.w != sizeof(app_usbd_nrf_dfu_trigger_nordic_info_t)) @@ -224,7 +224,7 @@ static ret_code_t setup_req_class_out(app_usbd_class_inst_t const * p_inst, app_usbd_nrf_dfu_trigger_t const * p_dfu = nrf_dfu_trigger_get(p_inst); app_usbd_nrf_dfu_trigger_ctx_t * p_dfu_ctx = nrf_dfu_trigger_ctx_get(p_dfu); - switch (p_setup_ev->setup.bmRequest) + switch (p_setup_ev->setup.bRequest) { case APP_USBD_NRF_DFU_TRIGGER_REQ_DETACH: { @@ -370,4 +370,5 @@ const app_usbd_class_methods_t app_usbd_nrf_dfu_trigger_class_methods = { .feed_descriptors = nrf_dfu_trigger_feed_descriptors, }; -#endif /* NRF_MODULE_ENABLED(APP_USBD_NRF_DFU_TRIGGER) */ + +#endif //NRF_MODULE_ENABLED(APP_USBD_NRF_DFU_TRIGGER) diff --git a/third_party/NordicSemiconductor/libraries/usb/app_usbd_nrf_dfu_trigger.h b/third_party/NordicSemiconductor/libraries/usb/app_usbd_nrf_dfu_trigger.h index 82aa1326b..63452516e 100644 --- a/third_party/NordicSemiconductor/libraries/usb/app_usbd_nrf_dfu_trigger.h +++ b/third_party/NordicSemiconductor/libraries/usb/app_usbd_nrf_dfu_trigger.h @@ -1,5 +1,5 @@ /** - * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA + * Copyright (c) 2017 - 2019, Nordic Semiconductor ASA * * All rights reserved. * @@ -44,6 +44,7 @@ #include #include "nrf_drv_usbd.h" +#include "nrf_block_dev.h" #include "app_usbd_class_base.h" #include "app_usbd.h" #include "app_usbd_core.h" diff --git a/third_party/NordicSemiconductor/libraries/usb/app_usbd_nrf_dfu_trigger_internal.h b/third_party/NordicSemiconductor/libraries/usb/app_usbd_nrf_dfu_trigger_internal.h index b1bd290c0..551d88054 100644 --- a/third_party/NordicSemiconductor/libraries/usb/app_usbd_nrf_dfu_trigger_internal.h +++ b/third_party/NordicSemiconductor/libraries/usb/app_usbd_nrf_dfu_trigger_internal.h @@ -1,5 +1,5 @@ /** - * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA + * Copyright (c) 2017 - 2019, Nordic Semiconductor ASA * * All rights reserved. * diff --git a/third_party/NordicSemiconductor/libraries/usb/app_usbd_nrf_dfu_trigger_types.h b/third_party/NordicSemiconductor/libraries/usb/app_usbd_nrf_dfu_trigger_types.h index 928f0d848..77b4b2be7 100644 --- a/third_party/NordicSemiconductor/libraries/usb/app_usbd_nrf_dfu_trigger_types.h +++ b/third_party/NordicSemiconductor/libraries/usb/app_usbd_nrf_dfu_trigger_types.h @@ -1,5 +1,5 @@ /** - * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA + * Copyright (c) 2017 - 2019, Nordic Semiconductor ASA * * All rights reserved. * diff --git a/third_party/NordicSemiconductor/libraries/usb/app_usbd_request.h b/third_party/NordicSemiconductor/libraries/usb/app_usbd_request.h index 27adcf140..8ef5494ef 100644 --- a/third_party/NordicSemiconductor/libraries/usb/app_usbd_request.h +++ b/third_party/NordicSemiconductor/libraries/usb/app_usbd_request.h @@ -1,5 +1,5 @@ /** - * Copyright (c) 2016 - 2018, Nordic Semiconductor ASA + * Copyright (c) 2016 - 2019, Nordic Semiconductor ASA * * All rights reserved. * @@ -276,7 +276,7 @@ typedef union { */ typedef struct { uint8_t bmRequestType; //!< Setup type bitfield - uint8_t bmRequest; //!< One of @ref app_usbd_setup_stdrequest_t values or class dependent one. + uint8_t bRequest; //!< One of @ref app_usbd_setup_stdrequest_t values or class dependent one. app_usbd_setup_w_t wValue; //!< byte 2, 3 app_usbd_setup_w_t wIndex; //!< byte 4, 5 app_usbd_setup_w_t wLength; //!< byte 6, 7 diff --git a/third_party/NordicSemiconductor/libraries/usb/app_usbd_serial_num.c b/third_party/NordicSemiconductor/libraries/usb/app_usbd_serial_num.c index aff65035c..1f0b46ad2 100644 --- a/third_party/NordicSemiconductor/libraries/usb/app_usbd_serial_num.c +++ b/third_party/NordicSemiconductor/libraries/usb/app_usbd_serial_num.c @@ -1,5 +1,5 @@ /** - * Copyright (c) 2018, Nordic Semiconductor ASA + * Copyright (c) 2018 - 2019, Nordic Semiconductor ASA * * All rights reserved. * diff --git a/third_party/NordicSemiconductor/libraries/usb/app_usbd_serial_num.h b/third_party/NordicSemiconductor/libraries/usb/app_usbd_serial_num.h index 11d4f886b..59124bbff 100644 --- a/third_party/NordicSemiconductor/libraries/usb/app_usbd_serial_num.h +++ b/third_party/NordicSemiconductor/libraries/usb/app_usbd_serial_num.h @@ -1,5 +1,5 @@ /** - * Copyright (c) 2018, Nordic Semiconductor ASA + * Copyright (c) 2018 - 2019, Nordic Semiconductor ASA * * All rights reserved. * diff --git a/third_party/NordicSemiconductor/libraries/usb/app_usbd_string_desc.c b/third_party/NordicSemiconductor/libraries/usb/app_usbd_string_desc.c index c0c3fe73d..c808e81c4 100644 --- a/third_party/NordicSemiconductor/libraries/usb/app_usbd_string_desc.c +++ b/third_party/NordicSemiconductor/libraries/usb/app_usbd_string_desc.c @@ -1,5 +1,5 @@ /** - * Copyright (c) 2016 - 2018, Nordic Semiconductor ASA + * Copyright (c) 2016 - 2019, Nordic Semiconductor ASA * * All rights reserved. * diff --git a/third_party/NordicSemiconductor/libraries/usb/app_usbd_string_desc.h b/third_party/NordicSemiconductor/libraries/usb/app_usbd_string_desc.h index e0b2fe450..21d75e8be 100644 --- a/third_party/NordicSemiconductor/libraries/usb/app_usbd_string_desc.h +++ b/third_party/NordicSemiconductor/libraries/usb/app_usbd_string_desc.h @@ -1,5 +1,5 @@ /** - * Copyright (c) 2016 - 2018, Nordic Semiconductor ASA + * Copyright (c) 2016 - 2019, Nordic Semiconductor ASA * * All rights reserved. * diff --git a/third_party/NordicSemiconductor/libraries/usb/app_usbd_types.h b/third_party/NordicSemiconductor/libraries/usb/app_usbd_types.h index 44ea273a4..0d4a0c277 100644 --- a/third_party/NordicSemiconductor/libraries/usb/app_usbd_types.h +++ b/third_party/NordicSemiconductor/libraries/usb/app_usbd_types.h @@ -1,5 +1,5 @@ /** - * Copyright (c) 2016 - 2018, Nordic Semiconductor ASA + * Copyright (c) 2016 - 2019, Nordic Semiconductor ASA * * All rights reserved. * @@ -75,16 +75,17 @@ extern "C" { * @brief Change given decimal version values to 4 digits in BCD notation. * * USB specification uses 4 digits BCD version notation in many descriptors. - * This macro changes 2 values to 4 BCD digits (one 16 bit value) + * This macro changes 3 values to 4 BCD digits (one 16 bit value) * that describes version in USB standard. * * @param[in] major Major version. * @param[in] minor Minor version. + * @param[in] sub Sub-minor version. * * @return Calculated 16 bit value with BCD representation of the version. */ -#define APP_USBD_BCD_VER_MAKE(major, minor) \ - ((APP_USBD_BCD_2_MAKE(major) << 8) | APP_USBD_BCD_2_MAKE(minor)) +#define APP_USBD_BCD_VER_MAKE(major, minor, sub) \ + ((APP_USBD_BCD_2_MAKE(major) << 8) | (minor) << 4 | (sub)) /** * @brief Combine endpoint address and its interval. diff --git a/third_party/NordicSemiconductor/libraries/usb/class/cdc/acm/app_usbd_cdc_acm.c b/third_party/NordicSemiconductor/libraries/usb/class/cdc/acm/app_usbd_cdc_acm.c index 87d901bf5..249a9099b 100644 --- a/third_party/NordicSemiconductor/libraries/usb/class/cdc/acm/app_usbd_cdc_acm.c +++ b/third_party/NordicSemiconductor/libraries/usb/class/cdc/acm/app_usbd_cdc_acm.c @@ -1,5 +1,5 @@ /** - * Copyright (c) 2016 - 2018, Nordic Semiconductor ASA + * Copyright (c) 2016 - 2019, Nordic Semiconductor ASA * * All rights reserved. * @@ -181,7 +181,7 @@ static ret_code_t setup_req_std_in(app_usbd_class_inst_t const * p_inst, /* Only Get Descriptor standard IN request is supported by CDC class */ if ((app_usbd_setup_req_rec(p_setup_ev->setup.bmRequestType) == APP_USBD_SETUP_REQREC_INTERFACE) && - (p_setup_ev->setup.bmRequest == APP_USBD_SETUP_STDREQ_GET_DESCRIPTOR)) + (p_setup_ev->setup.bRequest == APP_USBD_SETUP_STDREQ_GET_DESCRIPTOR)) { size_t dsc_len = 0; size_t max_size; @@ -218,7 +218,7 @@ static ret_code_t setup_req_std_out(app_usbd_class_inst_t const * p_inst, app_usbd_setup_evt_t const * p_setup_ev) { - switch (p_setup_ev->setup.bmRequest) + switch (p_setup_ev->setup.bRequest) { default: break; @@ -241,7 +241,7 @@ static ret_code_t setup_req_class_in(app_usbd_class_inst_t const * p_inst, app_usbd_cdc_acm_t const * p_cdc_acm = cdc_acm_get(p_inst); app_usbd_cdc_acm_ctx_t * p_cdc_acm_ctx = cdc_acm_ctx_get(p_cdc_acm); - switch (p_setup_ev->setup.bmRequest) + switch (p_setup_ev->setup.bRequest) { case APP_USBD_CDC_REQ_GET_LINE_CODING: { @@ -317,7 +317,7 @@ static ret_code_t cdc_acm_req_out_datastage(app_usbd_class_inst_t const * p_inst app_usbd_cdc_acm_t const * p_cdc_acm = cdc_acm_get(p_inst); app_usbd_cdc_acm_ctx_t * p_cdc_acm_ctx = cdc_acm_ctx_get(p_cdc_acm); - p_cdc_acm_ctx->request.type = p_setup_ev->setup.bmRequest; + p_cdc_acm_ctx->request.type = p_setup_ev->setup.bRequest; p_cdc_acm_ctx->request.len = p_setup_ev->setup.wLength.w; /*Request setup data*/ @@ -377,7 +377,7 @@ static ret_code_t setup_req_class_out(app_usbd_class_inst_t const * p_inst, app_usbd_cdc_acm_t const * p_cdc_acm = cdc_acm_get(p_inst); app_usbd_cdc_acm_ctx_t * p_cdc_acm_ctx = cdc_acm_ctx_get(p_cdc_acm); - switch (p_setup_ev->setup.bmRequest) + switch (p_setup_ev->setup.bRequest) { case APP_USBD_CDC_REQ_SET_LINE_CODING: { @@ -1158,7 +1158,7 @@ ret_code_t app_usbd_cdc_acm_serial_state_notify(app_usbd_cdc_acm_t const * notify->cdc_notify.bmRequestType = app_usbd_setup_req_val(APP_USBD_SETUP_REQREC_INTERFACE, APP_USBD_SETUP_REQTYPE_CLASS, APP_USBD_SETUP_REQDIR_IN); - notify->cdc_notify.bmRequest = APP_USBD_CDC_NOTIF_SERIAL_STATE; + notify->cdc_notify.bRequest = APP_USBD_CDC_NOTIF_SERIAL_STATE; notify->cdc_notify.wValue = 0; notify->cdc_notify.wIndex = 0; notify->cdc_notify.wLength = sizeof(notify->serial_state); diff --git a/third_party/NordicSemiconductor/libraries/usb/class/cdc/acm/app_usbd_cdc_acm.h b/third_party/NordicSemiconductor/libraries/usb/class/cdc/acm/app_usbd_cdc_acm.h index 4c8ccbeec..af81dc43b 100644 --- a/third_party/NordicSemiconductor/libraries/usb/class/cdc/acm/app_usbd_cdc_acm.h +++ b/third_party/NordicSemiconductor/libraries/usb/class/cdc/acm/app_usbd_cdc_acm.h @@ -1,5 +1,5 @@ /** - * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA + * Copyright (c) 2017 - 2019, Nordic Semiconductor ASA * * All rights reserved. * diff --git a/third_party/NordicSemiconductor/libraries/usb/class/cdc/acm/app_usbd_cdc_acm_internal.h b/third_party/NordicSemiconductor/libraries/usb/class/cdc/acm/app_usbd_cdc_acm_internal.h index 58251c9df..8b7844df6 100644 --- a/third_party/NordicSemiconductor/libraries/usb/class/cdc/acm/app_usbd_cdc_acm_internal.h +++ b/third_party/NordicSemiconductor/libraries/usb/class/cdc/acm/app_usbd_cdc_acm_internal.h @@ -1,5 +1,5 @@ /** - * Copyright (c) 2016 - 2018, Nordic Semiconductor ASA + * Copyright (c) 2016 - 2019, Nordic Semiconductor ASA * * All rights reserved. * diff --git a/third_party/NordicSemiconductor/libraries/usb/class/cdc/app_usbd_cdc_desc.h b/third_party/NordicSemiconductor/libraries/usb/class/cdc/app_usbd_cdc_desc.h index 72ad224ff..c6c8375a6 100644 --- a/third_party/NordicSemiconductor/libraries/usb/class/cdc/app_usbd_cdc_desc.h +++ b/third_party/NordicSemiconductor/libraries/usb/class/cdc/app_usbd_cdc_desc.h @@ -1,5 +1,5 @@ /** - * Copyright (c) 2016 - 2018, Nordic Semiconductor ASA + * Copyright (c) 2016 - 2019, Nordic Semiconductor ASA * * All rights reserved. * diff --git a/third_party/NordicSemiconductor/libraries/usb/class/cdc/app_usbd_cdc_types.h b/third_party/NordicSemiconductor/libraries/usb/class/cdc/app_usbd_cdc_types.h index 24a0e7354..e880d8238 100644 --- a/third_party/NordicSemiconductor/libraries/usb/class/cdc/app_usbd_cdc_types.h +++ b/third_party/NordicSemiconductor/libraries/usb/class/cdc/app_usbd_cdc_types.h @@ -1,5 +1,5 @@ /** - * Copyright (c) 2016 - 2018, Nordic Semiconductor ASA + * Copyright (c) 2016 - 2019, Nordic Semiconductor ASA * * All rights reserved. * @@ -313,7 +313,7 @@ typedef enum { * */ typedef struct { uint8_t bmRequestType; //!< Request type. - uint8_t bmRequest; //!< Request ID @ref app_usbd_cdc_req_id_t. + uint8_t bRequest; //!< Request ID @ref app_usbd_cdc_req_id_t. uint16_t wValue; //!< Value field. uint16_t wIndex; //!< Index field. uint16_t wLength; //!< Length of payload following. @@ -342,11 +342,11 @@ typedef enum { * @brief Possible values of @ref app_usbd_cdc_line_coding_t::bParityType. */ typedef enum { - APP_USBD_CDC_LINE_PARITY_NONE = 0, /**< No parity. */ - APP_USBD_CDC_LINE_PARITY_ODD = 1, /**< Odd parity. */ - APP_USBD_CDC_LINE_PARITY_EVEN = 2, /**< Even parity. */ - APP_USBD_CDC_LINE_PARITY_MARK = 3, /**< Parity forced to 0 (space).*/ - APP_USBD_CDC_LINE_PARITY_SPACE = 4, /**< Parity forced to 1 (mark). */ + APP_USBD_CDC_LINE_PARITY_NONE = 0, /**< No parity. */ + APP_USBD_CDC_LINE_PARITY_ODD = 1, /**< Odd parity. */ + APP_USBD_CDC_LINE_PARITY_EVEN = 2, /**< Even parity. */ + APP_USBD_CDC_LINE_PARITY_MARK = 3, /**< Parity forced to 0 (mark). */ + APP_USBD_CDC_LINE_PARITY_SPACE = 4, /**< Parity forced to 1 (space). */ } app_usbd_cdc_line_parity_t; diff --git a/third_party/NordicSemiconductor/libraries/usb/nrf_dfu_trigger_usb.c b/third_party/NordicSemiconductor/libraries/usb/nrf_dfu_trigger_usb.c index 68c642416..081eab498 100644 --- a/third_party/NordicSemiconductor/libraries/usb/nrf_dfu_trigger_usb.c +++ b/third_party/NordicSemiconductor/libraries/usb/nrf_dfu_trigger_usb.c @@ -1,5 +1,5 @@ /** - * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA + * Copyright (c) 2017 - 2019, Nordic Semiconductor ASA * * All rights reserved. * @@ -37,10 +37,6 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ - -#include "nordic_common.h" - -#if NRF_MODULE_ENABLED(APP_USBD_NRF_DFU_TRIGGER) #include "nrf_dfu_trigger_usb.h" #include "app_usbd.h" #include "app_usbd_nrf_dfu_trigger.h" @@ -53,11 +49,19 @@ #include "nrf_log.h" NRF_LOG_MODULE_REGISTER(); - #ifndef BSP_SELF_PINRESET_PIN #error "This module is intended to be used with boards that have the GP pin shortened with the RESET pin." #endif +/** + * @brief Enable power USB detection. + * + * Configure if the example supports USB port connection. + */ +#ifndef USBD_POWER_DETECTION +#define USBD_POWER_DETECTION true +#endif + #define DFU_FLASH_PAGE_SIZE (NRF_FICR->CODEPAGESIZE) #define DFU_FLASH_PAGE_COUNT (NRF_FICR->CODESIZE) @@ -237,6 +241,3 @@ ret_code_t nrf_dfu_trigger_usb_init(void) return ret; } - -#endif /* NRF_MODULE_ENABLED(APP_USBD_NRF_DFU_TRIGGER) */ - diff --git a/third_party/NordicSemiconductor/libraries/usb/nrf_dfu_trigger_usb.h b/third_party/NordicSemiconductor/libraries/usb/nrf_dfu_trigger_usb.h index 7b0c0f18f..895b59ab1 100644 --- a/third_party/NordicSemiconductor/libraries/usb/nrf_dfu_trigger_usb.h +++ b/third_party/NordicSemiconductor/libraries/usb/nrf_dfu_trigger_usb.h @@ -1,5 +1,5 @@ /** - * Copyright (c) 2017 - 2018, Nordic Semiconductor ASA + * Copyright (c) 2017 - 2019, Nordic Semiconductor ASA * * All rights reserved. *