From 4f772dd5c1bdb15afe070d568b1b34190c356c05 Mon Sep 17 00:00:00 2001 From: Chris Snow Date: Tue, 5 Sep 2017 16:09:41 +0100 Subject: [PATCH 001/108] Enable LPC1768 bootloader support --- targets/targets.json | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/targets/targets.json b/targets/targets.json index 8db1289a216..9bb25c26be8 100644 --- a/targets/targets.json +++ b/targets/targets.json @@ -241,7 +241,8 @@ "device_has": ["ANALOGIN", "ANALOGOUT", "CAN", "DEBUG_AWARENESS", "ETHERNET", "I2C", "I2CSLAVE", "INTERRUPTIN", "LOCALFILESYSTEM", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SEMIHOST", "SERIAL", "SERIAL_FC", "SLEEP", "SPI", "SPISLAVE", "STDIO_MESSAGES", "FLASH"], "release_versions": ["2", "5"], "features": ["LWIP"], - "device_name": "LPC1768" + "device_name": "LPC1768", + "bootloader_supported": true }, "ARCH_PRO": { "supported_form_factors": ["ARDUINO"], @@ -253,7 +254,8 @@ "device_has": ["ANALOGIN", "ANALOGOUT", "CAN", "DEBUG_AWARENESS", "ETHERNET", "I2C", "I2CSLAVE", "INTERRUPTIN", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SERIAL_FC", "SLEEP", "SPI", "SPISLAVE", "STDIO_MESSAGES", "FLASH"], "release_versions": ["2", "5"], "features": ["LWIP"], - "device_name": "LPC1768" + "device_name": "LPC1768", + "bootloader_supported": true }, "UBLOX_C027": { "supported_form_factors": ["ARDUINO"], @@ -277,7 +279,8 @@ "device_has": ["ANALOGIN", "ANALOGOUT", "CAN", "DEBUG_AWARENESS", "ETHERNET", "I2C", "I2CSLAVE", "INTERRUPTIN", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SERIAL_FC", "SLEEP", "SPI", "SPISLAVE", "STDIO_MESSAGES", "FLASH"], "release_versions": ["2", "5"], "features": ["LWIP"], - "device_name": "LPC1768" + "device_name": "LPC1768", + "bootloader_supported": true }, "XBED_LPC1768": { "inherits": ["LPCTarget"], From 2461d0c5063e5dc16054f628fdfe3a9c7c7086be Mon Sep 17 00:00:00 2001 From: Chris Snow Date: Tue, 5 Sep 2017 16:35:55 +0100 Subject: [PATCH 002/108] Move CRP out of startup and into CRP.c so it can be conditionally compiled --- targets/TARGET_NXP/TARGET_LPC176X/device/CRP.c | 18 ++++++++++++++++++ .../device/TOOLCHAIN_ARM_STD/startup_LPC17xx.S | 6 ------ 2 files changed, 18 insertions(+), 6 deletions(-) create mode 100644 targets/TARGET_NXP/TARGET_LPC176X/device/CRP.c diff --git a/targets/TARGET_NXP/TARGET_LPC176X/device/CRP.c b/targets/TARGET_NXP/TARGET_LPC176X/device/CRP.c new file mode 100644 index 00000000000..6b1c5a94a0a --- /dev/null +++ b/targets/TARGET_NXP/TARGET_LPC176X/device/CRP.c @@ -0,0 +1,18 @@ +/* mbed Microcontroller Library + * Copyright (c) 2017 ARM Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#if !defined(MBED_APP_START) // do not include CRP if there is a bootloader. + long CRP_Key __attribute__((section(".ARM.__at_0x000002FC "))) = 0xFFFFFFFF; +#endif diff --git a/targets/TARGET_NXP/TARGET_LPC176X/device/TOOLCHAIN_ARM_STD/startup_LPC17xx.S b/targets/TARGET_NXP/TARGET_LPC176X/device/TOOLCHAIN_ARM_STD/startup_LPC17xx.S index 32e2abf7fbf..e844d2f9acb 100644 --- a/targets/TARGET_NXP/TARGET_LPC176X/device/TOOLCHAIN_ARM_STD/startup_LPC17xx.S +++ b/targets/TARGET_NXP/TARGET_LPC176X/device/TOOLCHAIN_ARM_STD/startup_LPC17xx.S @@ -82,12 +82,6 @@ __Vectors DCD __initial_sp ; Top of Stack DCD PLL1_IRQHandler ; 48: PLL1 Lock (USB PLL) - IF :LNOT::DEF:NO_CRP - AREA |.ARM.__at_0x02FC|, CODE, READONLY -CRP_Key DCD 0xFFFFFFFF - ENDIF - - AREA |.text|, CODE, READONLY From 224ac4d453008ed34c7b9a9a970faac3082a77ce Mon Sep 17 00:00:00 2001 From: Chris Snow Date: Tue, 5 Sep 2017 16:39:36 +0100 Subject: [PATCH 003/108] Linker update for bootloader support --- .../device/TOOLCHAIN_ARM_MICRO/LPC1768.sct | 13 +++++++++++-- .../device/TOOLCHAIN_ARM_STD/LPC1768.sct | 13 +++++++++++-- .../device/TOOLCHAIN_GCC_ARM/LPC1768.ld | 8 +++++++- .../TARGET_LPC176X/device/TOOLCHAIN_IAR/LPC17xx.icf | 8 +++++--- 4 files changed, 34 insertions(+), 8 deletions(-) diff --git a/targets/TARGET_NXP/TARGET_LPC176X/device/TOOLCHAIN_ARM_MICRO/LPC1768.sct b/targets/TARGET_NXP/TARGET_LPC176X/device/TOOLCHAIN_ARM_MICRO/LPC1768.sct index 6af8037232f..2999e8081d0 100644 --- a/targets/TARGET_NXP/TARGET_LPC176X/device/TOOLCHAIN_ARM_MICRO/LPC1768.sct +++ b/targets/TARGET_NXP/TARGET_LPC176X/device/TOOLCHAIN_ARM_MICRO/LPC1768.sct @@ -1,6 +1,15 @@ +#! armcc -E -LR_IROM1 0x00000000 0x80000 { ; load region size_region - ER_IROM1 0x00000000 0x80000 { ; load address = execution address +#if !defined(MBED_APP_START) + #define MBED_APP_START 0x00000000 +#endif + +#if !defined(MBED_APP_SIZE) + #define MBED_APP_SIZE 0x80000 +#endif + +LR_IROM1 MBED_APP_START MBED_APP_SIZE { ; load region size_region + ER_IROM1 MBED_APP_START MBED_APP_SIZE { ; load address = execution address *.o (RESET, +First) *(InRoot$$Sections) .ANY (+RO) diff --git a/targets/TARGET_NXP/TARGET_LPC176X/device/TOOLCHAIN_ARM_STD/LPC1768.sct b/targets/TARGET_NXP/TARGET_LPC176X/device/TOOLCHAIN_ARM_STD/LPC1768.sct index 2e5afcd5e1e..42f4a764926 100644 --- a/targets/TARGET_NXP/TARGET_LPC176X/device/TOOLCHAIN_ARM_STD/LPC1768.sct +++ b/targets/TARGET_NXP/TARGET_LPC176X/device/TOOLCHAIN_ARM_STD/LPC1768.sct @@ -1,6 +1,15 @@ +#! armcc -E -LR_IROM1 0x00000000 0x80000 { ; load region size_region - ER_IROM1 0x00000000 0x80000 { ; load address = execution address +#if !defined(MBED_APP_START) + #define MBED_APP_START 0x00000000 +#endif + +#if !defined(MBED_APP_SIZE) + #define MBED_APP_SIZE 0x80000 +#endif + +LR_IROM1 MBED_APP_START MBED_APP_SIZE { ; load region size_region + ER_IROM1 MBED_APP_START MBED_APP_SIZE { ; load address = execution address *.o (RESET, +First) *(InRoot$$Sections) .ANY (+RO) diff --git a/targets/TARGET_NXP/TARGET_LPC176X/device/TOOLCHAIN_GCC_ARM/LPC1768.ld b/targets/TARGET_NXP/TARGET_LPC176X/device/TOOLCHAIN_GCC_ARM/LPC1768.ld index 8ab5bcaf22e..59d08ecc759 100644 --- a/targets/TARGET_NXP/TARGET_LPC176X/device/TOOLCHAIN_GCC_ARM/LPC1768.ld +++ b/targets/TARGET_NXP/TARGET_LPC176X/device/TOOLCHAIN_GCC_ARM/LPC1768.ld @@ -1,9 +1,15 @@ /* Linker script for mbed LPC1768 */ +#if !defined(MBED_APP_START) + #define MBED_APP_START 0x00000000 +#endif +#if !defined(MBED_APP_SIZE) + #define MBED_APP_SIZE 512K +#endif /* Linker script to configure memory regions. */ MEMORY { - FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 512K + FLASH (rx) : ORIGIN = MBED_APP_START, LENGTH = MBED_APP_SIZE RAM (rwx) : ORIGIN = 0x100000C8, LENGTH = (32K - 0xC8 - 32) /* topmost 32 bytes used by IAP functions */ USB_RAM(rwx) : ORIGIN = 0x2007C000, LENGTH = 16K diff --git a/targets/TARGET_NXP/TARGET_LPC176X/device/TOOLCHAIN_IAR/LPC17xx.icf b/targets/TARGET_NXP/TARGET_LPC176X/device/TOOLCHAIN_IAR/LPC17xx.icf index 57037ba6900..6051abd55af 100644 --- a/targets/TARGET_NXP/TARGET_LPC176X/device/TOOLCHAIN_IAR/LPC17xx.icf +++ b/targets/TARGET_NXP/TARGET_LPC176X/device/TOOLCHAIN_IAR/LPC17xx.icf @@ -1,11 +1,13 @@ +if (!isdefinedsymbol(MBED_APP_START)) { define symbol MBED_APP_START = 0x00000000; } +if (!isdefinedsymbol(MBED_APP_SIZE)) { define symbol MBED_APP_SIZE = 0x80000; } /*###ICF### Section handled by ICF editor, don't touch! ****/ /*-Editor annotation file-*/ /* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */ /*-Specials-*/ -define symbol __ICFEDIT_intvec_start__ = 0x00000000; +define symbol __ICFEDIT_intvec_start__ = MBED_APP_START; /*-Memory Regions-*/ -define symbol __ICFEDIT_region_ROM_start__ = 0x00000000; -define symbol __ICFEDIT_region_ROM_end__ = 0x0007FFFF; +define symbol __ICFEDIT_region_ROM_start__ = MBED_APP_START; +define symbol __ICFEDIT_region_ROM_end__ = MBED_APP_START + MBED_APP_SIZE - 1; define symbol __ICFEDIT_region_NVIC_start__ = 0x10000000; define symbol __ICFEDIT_region_NVIC_end__ = 0x100000C7; define symbol __ICFEDIT_region_RAM_start__ = 0x100000C8; From e0c2ea2876bc0b950a1eb68d8d9e3e1c2c370545 Mon Sep 17 00:00:00 2001 From: Chris Snow Date: Tue, 5 Sep 2017 18:05:29 +0100 Subject: [PATCH 004/108] Ensure CRP is set correctly for IAR, GCC and ARM CRP value can be set through a macro in mbed_app such as "macros": [ "CRP=CRP_NONE" ] --- .../TARGET_NXP/TARGET_LPC176X/device/CRP.c | 46 ++++++++++++++++++- .../TOOLCHAIN_ARM_MICRO/startup_LPC17xx.S | 6 --- .../device/TOOLCHAIN_GCC_ARM/LPC1768.ld | 6 +++ .../device/TOOLCHAIN_IAR/startup_LPC17xx.S | 22 --------- 4 files changed, 50 insertions(+), 30 deletions(-) diff --git a/targets/TARGET_NXP/TARGET_LPC176X/device/CRP.c b/targets/TARGET_NXP/TARGET_LPC176X/device/CRP.c index 6b1c5a94a0a..5b80b4dcb39 100644 --- a/targets/TARGET_NXP/TARGET_LPC176X/device/CRP.c +++ b/targets/TARGET_NXP/TARGET_LPC176X/device/CRP.c @@ -13,6 +13,48 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#if !defined(MBED_APP_START) // do not include CRP if there is a bootloader. - long CRP_Key __attribute__((section(".ARM.__at_0x000002FC "))) = 0xFFFFFFFF; + + #include "mbed_toolchain.h" + + /* Code Read Protection + +NONE 0xFFFFFFFF - No code protection. + +CRP1 0x12345678 - Write to RAM command can not access RAM below 0x10000200. + - Read Memory command: disabled. + - Copy RAM to Flash command: cannot write to Sector 0. + - "Go" command: disabled. + - Erase sector(s) command: can erase any individual sector except + sector 0 only, or can erase all sectors at once. + - Compare command: disabled + +CRP2 0x87654321 - Write to RAM command: disabled. + - Copy RAM to Flash: disabled. + - Erase command: only allows erase of all sectors. + +CRP3 0x43218765 - Access to chip via the SWD pins is disabled. ISP entry + by pulling PIO0_1 LOW is disabled if a valid user code is + present in flash sector 0. +Caution: If CRP3 is selected, no future factory testing can be +performed on the device. +*/ +#if !defined(APPLICATION_ADDR) // Relocate CRP if there is a bootloader. + #define APPLICATION_ADDR 0 +#endif + +#define CRP_NONE 0xFFFFFFFF +#define CRP_1 0x12345678 +#define CRP_2 0x87654321 +#define CRP_3 0x43218765 + +#ifndef CRP +#define CRP CRP_NONE +#endif + +#if defined (__ICCARM__) + __root const long CRP_Key@APPLICATION_ADDR + 0x000002FC = CRP; +#elif defined (__ARMCC_VERSION) + const long CRP_Key __attribute__((used)) __attribute__((at(APPLICATION_ADDR+0x000002FC))) = CRP; +#elif defined (__GNUC__) + const long CRP_Key __attribute__((used)) __attribute__((section(".CRPSection"))) = CRP; #endif diff --git a/targets/TARGET_NXP/TARGET_LPC176X/device/TOOLCHAIN_ARM_MICRO/startup_LPC17xx.S b/targets/TARGET_NXP/TARGET_LPC176X/device/TOOLCHAIN_ARM_MICRO/startup_LPC17xx.S index 9646f2f17c7..01b19858c3a 100644 --- a/targets/TARGET_NXP/TARGET_LPC176X/device/TOOLCHAIN_ARM_MICRO/startup_LPC17xx.S +++ b/targets/TARGET_NXP/TARGET_LPC176X/device/TOOLCHAIN_ARM_MICRO/startup_LPC17xx.S @@ -99,12 +99,6 @@ __Vectors DCD __initial_sp ; Top of Stack DCD PLL1_IRQHandler ; 48: PLL1 Lock (USB PLL) - IF :LNOT::DEF:NO_CRP - AREA |.ARM.__at_0x02FC|, CODE, READONLY -CRP_Key DCD 0xFFFFFFFF - ENDIF - - AREA |.text|, CODE, READONLY diff --git a/targets/TARGET_NXP/TARGET_LPC176X/device/TOOLCHAIN_GCC_ARM/LPC1768.ld b/targets/TARGET_NXP/TARGET_LPC176X/device/TOOLCHAIN_GCC_ARM/LPC1768.ld index 59d08ecc759..a4a05fcbfb9 100644 --- a/targets/TARGET_NXP/TARGET_LPC176X/device/TOOLCHAIN_GCC_ARM/LPC1768.ld +++ b/targets/TARGET_NXP/TARGET_LPC176X/device/TOOLCHAIN_GCC_ARM/LPC1768.ld @@ -49,6 +49,10 @@ SECTIONS .text : { KEEP(*(.isr_vector)) + /* Code Read Protect data */ + . = 0x000002FC ; + KEEP(*(.CRPSection)) + /* End of Code Read Protect */ *(.text*) KEEP(*(.init)) @@ -71,6 +75,8 @@ SECTIONS *(.rodata*) KEEP(*(.eh_frame*)) + + } > FLASH .ARM.extab : diff --git a/targets/TARGET_NXP/TARGET_LPC176X/device/TOOLCHAIN_IAR/startup_LPC17xx.S b/targets/TARGET_NXP/TARGET_LPC176X/device/TOOLCHAIN_IAR/startup_LPC17xx.S index 4ffb5331abf..52b1c39d4f8 100644 --- a/targets/TARGET_NXP/TARGET_LPC176X/device/TOOLCHAIN_IAR/startup_LPC17xx.S +++ b/targets/TARGET_NXP/TARGET_LPC176X/device/TOOLCHAIN_IAR/startup_LPC17xx.S @@ -350,26 +350,4 @@ USBActivity_IRQHandler CANActivity_IRQHandler B CANActivity_IRQHandler -#ifndef SRAM - SECTION .crp:CODE:ROOT(2) - DATA -/* Code Read Protection -CRP1 0x12345678 - Write to RAM command can not access RAM below 0x10000200. - - Read Memory command: disabled. - - Copy RAM to Flash command: cannot write to Sector 0. - - "Go" command: disabled. - - Erase sector(s) command: can erase any individual sector except - sector 0 only, or can erase all sectors at once. - - Compare command: disabled -CRP2 0x87654321 - Write to RAM command: disabled. - - Copy RAM to Flash: disabled. - - Erase command: only allows erase of all sectors. -CRP3 0x43218765 - Access to chip via the SWD pins is disabled. ISP entry - by pulling PIO0_1 LOW is disabled if a valid user code is - present in flash sector 0. -Caution: If CRP3 is selected, no future factory testing can be -performed on the device. -*/ - DCD 0xFFFFFFFF -#endif END From 1c5c0adbacea026d376e0af9983fce51d7b3bf6a Mon Sep 17 00:00:00 2001 From: Chris Snow Date: Sat, 30 Sep 2017 18:33:31 +0100 Subject: [PATCH 005/108] Implement MBED_USED --- platform/mbed_toolchain.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/platform/mbed_toolchain.h b/platform/mbed_toolchain.h index c5bec189bcd..f5d5e79e611 100644 --- a/platform/mbed_toolchain.h +++ b/platform/mbed_toolchain.h @@ -92,6 +92,26 @@ #endif #endif +/** MBED_USED + * Inform the compiler that a static variable is to be retained in the object file, even if it is unreferenced. + * + * @code + * #include "mbed_toolchain.h" + * + * MBED_USED int foo; + * + * @endcode + */ +#ifndef MBED_USED +#if defined(__GNUC__) || defined(__clang__) || defined(__CC_ARM) +#define MBED_USED __attribute__((used)) +#elif defined(__ICCARM__) +#define MBED_USED __root +#else +#define MBED_USED +#endif +#endif + /** MBED_WEAK * Mark a function as being weak. * From 2b0ff329d6f80f666e56dd9be10db255f1a03c38 Mon Sep 17 00:00:00 2001 From: Chris Snow Date: Sat, 30 Sep 2017 18:39:11 +0100 Subject: [PATCH 006/108] Simplify CRP placement. --- targets/TARGET_NXP/TARGET_LPC176X/device/CRP.c | 8 +------- .../device/TOOLCHAIN_ARM_MICRO/LPC1768.sct | 14 ++++++++++---- .../device/TOOLCHAIN_ARM_STD/LPC1768.sct | 14 ++++++++++---- .../device/TOOLCHAIN_IAR/LPC17xx.icf | 6 +++--- 4 files changed, 24 insertions(+), 18 deletions(-) diff --git a/targets/TARGET_NXP/TARGET_LPC176X/device/CRP.c b/targets/TARGET_NXP/TARGET_LPC176X/device/CRP.c index 5b80b4dcb39..f2ae329670b 100644 --- a/targets/TARGET_NXP/TARGET_LPC176X/device/CRP.c +++ b/targets/TARGET_NXP/TARGET_LPC176X/device/CRP.c @@ -51,10 +51,4 @@ performed on the device. #define CRP CRP_NONE #endif -#if defined (__ICCARM__) - __root const long CRP_Key@APPLICATION_ADDR + 0x000002FC = CRP; -#elif defined (__ARMCC_VERSION) - const long CRP_Key __attribute__((used)) __attribute__((at(APPLICATION_ADDR+0x000002FC))) = CRP; -#elif defined (__GNUC__) - const long CRP_Key __attribute__((used)) __attribute__((section(".CRPSection"))) = CRP; -#endif +MBED_SECTION(".CRPSection") MBED_USED const long CRP_Key = CRP; diff --git a/targets/TARGET_NXP/TARGET_LPC176X/device/TOOLCHAIN_ARM_MICRO/LPC1768.sct b/targets/TARGET_NXP/TARGET_LPC176X/device/TOOLCHAIN_ARM_MICRO/LPC1768.sct index 2999e8081d0..44d51132a1d 100644 --- a/targets/TARGET_NXP/TARGET_LPC176X/device/TOOLCHAIN_ARM_MICRO/LPC1768.sct +++ b/targets/TARGET_NXP/TARGET_LPC176X/device/TOOLCHAIN_ARM_MICRO/LPC1768.sct @@ -9,10 +9,16 @@ #endif LR_IROM1 MBED_APP_START MBED_APP_SIZE { ; load region size_region - ER_IROM1 MBED_APP_START MBED_APP_SIZE { ; load address = execution address - *.o (RESET, +First) - *(InRoot$$Sections) - .ANY (+RO) + ER_IROM0 MBED_APP_START 0x2FC { ; load address = execution address + *.o (RESET, +First) + .ANY (+RO) + } + ER_CRP (MBED_APP_START + 0x2FC) FIXED 4 { + *.o (.CRPSection) + } + ER_IROM1 (MBED_APP_START + (0x2FC + 4)) FIXED (MBED_APP_SIZE - (0x2FC + 4)) { + *(InRoot$$Sections) + .ANY (+RO) } ; 8_byte_aligned(49 vect * 4 bytes) = 8_byte_aligned(0xC4) = 0xC8 ; 32KB (RAM size) - 0xC8 (NIVT) - 32 (topmost 32 bytes used by IAP functions) = 0x7F18 diff --git a/targets/TARGET_NXP/TARGET_LPC176X/device/TOOLCHAIN_ARM_STD/LPC1768.sct b/targets/TARGET_NXP/TARGET_LPC176X/device/TOOLCHAIN_ARM_STD/LPC1768.sct index 42f4a764926..f56aae73897 100644 --- a/targets/TARGET_NXP/TARGET_LPC176X/device/TOOLCHAIN_ARM_STD/LPC1768.sct +++ b/targets/TARGET_NXP/TARGET_LPC176X/device/TOOLCHAIN_ARM_STD/LPC1768.sct @@ -9,10 +9,16 @@ #endif LR_IROM1 MBED_APP_START MBED_APP_SIZE { ; load region size_region - ER_IROM1 MBED_APP_START MBED_APP_SIZE { ; load address = execution address - *.o (RESET, +First) - *(InRoot$$Sections) - .ANY (+RO) + ER_IROM0 MBED_APP_START 0x2FC { ; load address = execution address + *.o (RESET, +First) + .ANY (+RO) + } + ER_CRP (MBED_APP_START + 0x2FC) FIXED 4 { + *.o (.CRPSection) + } + ER_IROM1 (MBED_APP_START + (0x2FC + 4)) FIXED (MBED_APP_SIZE - (0x2FC + 4)) { + *(InRoot$$Sections) + .ANY (+RO) } ; 8_byte_aligned(49 vect * 4 bytes) = 8_byte_aligned(0xC4) = 0xC8 ; 32KB (RAM size) - 0xC8 (NIVT) - 32 (topmost 32 bytes used by IAP functions) = 0x7F18 diff --git a/targets/TARGET_NXP/TARGET_LPC176X/device/TOOLCHAIN_IAR/LPC17xx.icf b/targets/TARGET_NXP/TARGET_LPC176X/device/TOOLCHAIN_IAR/LPC17xx.icf index 6051abd55af..0cea4b47c71 100644 --- a/targets/TARGET_NXP/TARGET_LPC176X/device/TOOLCHAIN_IAR/LPC17xx.icf +++ b/targets/TARGET_NXP/TARGET_LPC176X/device/TOOLCHAIN_IAR/LPC17xx.icf @@ -19,8 +19,8 @@ define symbol __ICFEDIT_size_cstack__ = 0x1000; define symbol __ICFEDIT_size_heap__ = 0x2000; /**** End of ICF editor section. ###ICF###*/ -define symbol __CRP_start__ = 0x000002FC; -define symbol __CRP_end__ = 0x000002FF; +define symbol __CRP_start__ = MBED_APP_START + 0x000002FC; +define symbol __CRP_end__ = MBED_APP_START + 0x000002FF; define symbol __RAM1_start__ = 0x2007C000; define symbol __RAM1_end__ = 0x20083FFF; @@ -43,5 +43,5 @@ place in ROM_region { readonly }; place in RAM_region { readwrite, block HEAP, block CSTACK }; -place in CRP_region { section .crp }; +place in CRP_region { section .CRPSection }; place in RAM1_region { section .ethusbram }; From 8d71ca21c9e2c08c061c468d25b5848042d5bb56 Mon Sep 17 00:00:00 2001 From: David Walters Date: Mon, 11 Sep 2017 16:54:32 +0100 Subject: [PATCH 007/108] Added additional DAPLink version info for `mbed detect` command` --- tools/detect_targets.py | 7 +++++-- tools/test_api.py | 6 ++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/tools/detect_targets.py b/tools/detect_targets.py index 5f32801db82..1ef57e764bd 100644 --- a/tools/detect_targets.py +++ b/tools/detect_targets.py @@ -31,6 +31,7 @@ # Imports related to mbed build api from tools.build_api import mcu_toolchain_matrix from tools.test_api import get_autodetected_MUTS_list +from tools.test_api import get_mounted_details_txt from argparse import ArgumentParser @@ -75,9 +76,11 @@ def main(): count = 0 for mut in muts.values(): if re.match(mcu_filter, mut['mcu']): + # Grab additional target details about the mut + details_txt = get_mounted_details_txt(mut['disk']) print "" - print "[mbed] Detected %s, port %s, mounted %s" % \ - (mut['mcu'], mut['port'], mut['disk']) + print "[mbed] Detected %s, port %s, mounted %s, DAPLink version %s" % \ + (mut['mcu'], mut['port'], mut['disk'], details_txt['Interface Version']) print "[mbed] Supported toolchains for %s" % mut['mcu'] print mcu_toolchain_matrix(platform_filter=mut['mcu']) count += 1 diff --git a/tools/test_api.py b/tools/test_api.py index 7bebb8da755..944e47d0d02 100644 --- a/tools/test_api.py +++ b/tools/test_api.py @@ -1648,6 +1648,12 @@ def get_module_avail(module_name): """ return module_name in sys.modules.keys() +def get_mounted_details_txt(mount_point): + """ Function returns object containing details.txt information from the specified mount point + @param mount_point Name of disk where platform is connected to host machine. + """ + mbeds = mbed_lstools.create() + return mbeds.get_details_txt(mount_point) def get_autodetected_MUTS_list(platform_name_filter=None): oldError = None From 11e688136c276842e080dc0252a5c3782524e0d4 Mon Sep 17 00:00:00 2001 From: David Walters Date: Tue, 12 Sep 2017 10:46:07 +0100 Subject: [PATCH 008/108] Changed DAPLink version to interface version. --- tools/detect_targets.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/detect_targets.py b/tools/detect_targets.py index 1ef57e764bd..bf70c1c024c 100644 --- a/tools/detect_targets.py +++ b/tools/detect_targets.py @@ -79,7 +79,7 @@ def main(): # Grab additional target details about the mut details_txt = get_mounted_details_txt(mut['disk']) print "" - print "[mbed] Detected %s, port %s, mounted %s, DAPLink version %s" % \ + print "[mbed] Detected %s, port %s, mounted %s, interface version %s" % \ (mut['mcu'], mut['port'], mut['disk'], details_txt['Interface Version']) print "[mbed] Supported toolchains for %s" % mut['mcu'] print mcu_toolchain_matrix(platform_filter=mut['mcu']) From f730fe811705b88ab4f4c0f0b730da0528215d9a Mon Sep 17 00:00:00 2001 From: David Walters Date: Fri, 15 Sep 2017 10:15:24 +0100 Subject: [PATCH 009/108] Removed get_mounted_details_txt from test_api.py Fixed minor typos in test_api.py Added get_interface_version to detect_targets --- tools/detect_targets.py | 33 +++++++++++++++++++++++++++------ tools/test_api.py | 9 +-------- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/tools/detect_targets.py b/tools/detect_targets.py index bf70c1c024c..c3474a8e1cf 100644 --- a/tools/detect_targets.py +++ b/tools/detect_targets.py @@ -31,9 +31,13 @@ # Imports related to mbed build api from tools.build_api import mcu_toolchain_matrix from tools.test_api import get_autodetected_MUTS_list -from tools.test_api import get_mounted_details_txt +from tools.test_api import get_module_avail from argparse import ArgumentParser +try: + import mbed_lstools +except: + pass def main(): """Entry Point""" @@ -76,17 +80,17 @@ def main(): count = 0 for mut in muts.values(): if re.match(mcu_filter, mut['mcu']): - # Grab additional target details about the mut - details_txt = get_mounted_details_txt(mut['disk']) + interface_version = get_interface_version(mut['disk']) print "" - print "[mbed] Detected %s, port %s, mounted %s, interface version %s" % \ - (mut['mcu'], mut['port'], mut['disk'], details_txt['Interface Version']) + print "[mbed] Detected %s, port %s, mounted %s, interface version %s:" % \ + (mut['mcu'], mut['port'], mut['disk'], interface_version) + print "[mbed] Supported toolchains for %s" % mut['mcu'] print mcu_toolchain_matrix(platform_filter=mut['mcu']) count += 1 if count == 0: - print "[mbed] No mbed targets where detected on your system." + print "[mbed] No mbed targets were detected on your system." except KeyboardInterrupt: print "\n[CTRL+c] exit" @@ -95,6 +99,23 @@ def main(): traceback.print_exc(file=sys.stdout) print "[ERROR] %s" % str(exc) sys.exit(1) + +def get_interface_version(mount_point): + """ Function returns interface version from the target mounted on the specified mount point + mount_point = mut['port'] + @param mount_point Name of disk where platform is connected to host machine. + """ + if get_module_avail('mbed_lstools'): + mbeds = mbed_lstools.create() + details_txt = mbeds.get_details_txt(mount_point) + + if 'Interface Version' in details_txt: + return details_txt['Interface Version'] + + elif 'Version' in details_txt: + return details_txt['Version'] + + return 'unknown' if __name__ == '__main__': main() diff --git a/tools/test_api.py b/tools/test_api.py index 944e47d0d02..cc549d7d1e4 100644 --- a/tools/test_api.py +++ b/tools/test_api.py @@ -1644,17 +1644,10 @@ def detect_database_verbose(db_url): def get_module_avail(module_name): - """ This function returns True if module_name is already impored module + """ This function returns True if module_name is already imported module """ return module_name in sys.modules.keys() -def get_mounted_details_txt(mount_point): - """ Function returns object containing details.txt information from the specified mount point - @param mount_point Name of disk where platform is connected to host machine. - """ - mbeds = mbed_lstools.create() - return mbeds.get_details_txt(mount_point) - def get_autodetected_MUTS_list(platform_name_filter=None): oldError = None if os.name == 'nt': From c99e1e45e91c3d6d1369ecd9059f284bdec10746 Mon Sep 17 00:00:00 2001 From: David Walters Date: Fri, 15 Sep 2017 15:30:34 +0100 Subject: [PATCH 010/108] Fixed mount_point example usage --- tools/detect_targets.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/detect_targets.py b/tools/detect_targets.py index c3474a8e1cf..bdccab1f3f5 100644 --- a/tools/detect_targets.py +++ b/tools/detect_targets.py @@ -102,7 +102,8 @@ def main(): def get_interface_version(mount_point): """ Function returns interface version from the target mounted on the specified mount point - mount_point = mut['port'] + Example of mount_point: + mount_point = mut['disk'] @param mount_point Name of disk where platform is connected to host machine. """ if get_module_avail('mbed_lstools'): From 3c65f323cd18ff840f86cde7a906b00bb316cd5e Mon Sep 17 00:00:00 2001 From: David Walters Date: Fri, 15 Sep 2017 15:49:08 +0100 Subject: [PATCH 011/108] Edited get_interface_version info for clarity --- tools/detect_targets.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/detect_targets.py b/tools/detect_targets.py index bdccab1f3f5..ad90f5b0786 100644 --- a/tools/detect_targets.py +++ b/tools/detect_targets.py @@ -102,8 +102,12 @@ def main(): def get_interface_version(mount_point): """ Function returns interface version from the target mounted on the specified mount point - Example of mount_point: - mount_point = mut['disk'] + + mount_point can be acquired via the following: + muts = get_autodetected_MUTS_list() + for mut in muts.values(): + mount_point = mut['disk'] + @param mount_point Name of disk where platform is connected to host machine. """ if get_module_avail('mbed_lstools'): From 2a7bed252e29f388a9348dee872c06e8e255ca96 Mon Sep 17 00:00:00 2001 From: David Walters Date: Fri, 15 Sep 2017 16:00:20 +0100 Subject: [PATCH 012/108] Added in safety check if details_txt is None --- tools/detect_targets.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tools/detect_targets.py b/tools/detect_targets.py index ad90f5b0786..ec1d90cd59c 100644 --- a/tools/detect_targets.py +++ b/tools/detect_targets.py @@ -103,10 +103,10 @@ def main(): def get_interface_version(mount_point): """ Function returns interface version from the target mounted on the specified mount point - mount_point can be acquired via the following: - muts = get_autodetected_MUTS_list() - for mut in muts.values(): - mount_point = mut['disk'] + mount_point can be acquired via the following: + muts = get_autodetected_MUTS_list() + for mut in muts.values(): + mount_point = mut['disk'] @param mount_point Name of disk where platform is connected to host machine. """ @@ -114,6 +114,10 @@ def get_interface_version(mount_point): mbeds = mbed_lstools.create() details_txt = mbeds.get_details_txt(mount_point) + if (details_txt is None): + details_txt = {} + + if 'Interface Version' in details_txt: return details_txt['Interface Version'] From 41f761e474344318e62703f4052b59d891b3c2de Mon Sep 17 00:00:00 2001 From: David Walters Date: Mon, 25 Sep 2017 16:53:41 +0100 Subject: [PATCH 013/108] Added safety check, added test converage for new function --- tools/detect_targets.py | 22 ++++---- tools/test/detect_targets_test.py | 85 +++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+), 11 deletions(-) create mode 100644 tools/test/detect_targets_test.py diff --git a/tools/detect_targets.py b/tools/detect_targets.py index ec1d90cd59c..81a7b80e203 100644 --- a/tools/detect_targets.py +++ b/tools/detect_targets.py @@ -111,18 +111,18 @@ def get_interface_version(mount_point): @param mount_point Name of disk where platform is connected to host machine. """ if get_module_avail('mbed_lstools'): - mbeds = mbed_lstools.create() - details_txt = mbeds.get_details_txt(mount_point) - - if (details_txt is None): - details_txt = {} + try : + mbeds = mbed_lstools.create() + details_txt = mbeds.get_details_txt(mount_point) - - if 'Interface Version' in details_txt: - return details_txt['Interface Version'] - - elif 'Version' in details_txt: - return details_txt['Version'] + if 'Interface Version' in details_txt: + return details_txt['Interface Version'] + + elif 'Version' in details_txt: + return details_txt['Version'] + + except : + return 'unknown' return 'unknown' diff --git a/tools/test/detect_targets_test.py b/tools/test/detect_targets_test.py new file mode 100644 index 00000000000..c7a996ccbf8 --- /dev/null +++ b/tools/test/detect_targets_test.py @@ -0,0 +1,85 @@ +""" +mbed SDK +Copyright (c) 2016 ARM Limited + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +""" + +import unittest +from collections import namedtuple +from mock import patch, MagicMock +from tools.detect_targets import get_interface_version +from tools.test_api import get_autodetected_MUTS_list + +""" +Tests for detect_targets.py +""" + +class DetectTargetsTests(unittest.TestCase): + """ + Test cases for Detect Target functionality + """ + + def setUp(self): + """ + Called before each test case + + :return: + """ + # Gather a valid mount point from the host machine + muts = get_autodetected_MUTS_list() + + count = 0 + + for mut in muts.values(): + + count += 1 + self.valid_mount_point = mut['disk'] + break + + # If no targets are found, there is no way to determine Host OS mount point. + # Function should handle failure gracefully regardless of a mount point being present. + # Therefore it is safe to assume a valid mount point. + if count is 0: + self.valid_mount_point = "D:" + + self.invalid_mount_point = "23z/e\n" + self.missing_mount_point = None + + def tearDown(self): + """ + Nothing to tear down. + Called after each test case + + :return: + """ + pass + + def test_interface_version_valid_mount_point(self): + + interface_version = get_interface_version(self.valid_mount_point) + assert len(interface_version) > 0 + + def test_interface_version_invalid_mount_point(self): + + interface_version = get_interface_version(self.invalid_mount_point) + assert interface_version == 'unknown' + + def test_interface_version_missing_mount_point(self): + + interface_version = get_interface_version(self.missing_mount_point) + assert interface_version == 'unknown' + + +if __name__ == '__main__': + unittest.main() From dcc4f1bd76a0f199b4bdb86f458756c9b31e5c12 Mon Sep 17 00:00:00 2001 From: David Walters Date: Mon, 25 Sep 2017 16:58:52 +0100 Subject: [PATCH 014/108] Removing unused imports/update copywright` --- tools/test/detect_targets_test.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tools/test/detect_targets_test.py b/tools/test/detect_targets_test.py index c7a996ccbf8..33e790f020f 100644 --- a/tools/test/detect_targets_test.py +++ b/tools/test/detect_targets_test.py @@ -1,6 +1,6 @@ """ mbed SDK -Copyright (c) 2016 ARM Limited +Copyright (c) 2017 ARM Limited Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -16,8 +16,6 @@ """ import unittest -from collections import namedtuple -from mock import patch, MagicMock from tools.detect_targets import get_interface_version from tools.test_api import get_autodetected_MUTS_list From d3af9964e1e088ade6e14acd143f015cc76ae080 Mon Sep 17 00:00:00 2001 From: David Walters Date: Fri, 29 Sep 2017 09:56:49 +0100 Subject: [PATCH 015/108] Increased test coverage / mocking of external modules --- tools/detect_targets.py | 2 +- tools/test/detect_targets_test.py | 129 +++++++++++++++++++++++------- 2 files changed, 102 insertions(+), 29 deletions(-) diff --git a/tools/detect_targets.py b/tools/detect_targets.py index 81a7b80e203..b9aa80df1ca 100644 --- a/tools/detect_targets.py +++ b/tools/detect_targets.py @@ -113,7 +113,7 @@ def get_interface_version(mount_point): if get_module_avail('mbed_lstools'): try : mbeds = mbed_lstools.create() - details_txt = mbeds.get_details_txt(mount_point) + details_txt = mbeds.get_details_txt(mount_point) if 'Interface Version' in details_txt: return details_txt['Interface Version'] diff --git a/tools/test/detect_targets_test.py b/tools/test/detect_targets_test.py index 33e790f020f..f1c79945291 100644 --- a/tools/test/detect_targets_test.py +++ b/tools/test/detect_targets_test.py @@ -16,14 +16,59 @@ """ import unittest +from mock import patch from tools.detect_targets import get_interface_version -from tools.test_api import get_autodetected_MUTS_list + + +class MbedLsToolsMock(): + + def __init__(self, type): + self.interface_test_type = type + + def get_details_txt(self, mount_point): + return self.details_txt_types[self.interface_test_type]; + + # Static details.txt types. + details_txt_types = { + 'details_valid_interface_version' : { + 'Unique ID': '0226000029164e45002f0012706e0006f301000097969900', + 'HIF ID': '97969900', + 'Auto Reset': '0', + 'Automation allowed': '0', + 'Daplink Mode': 'Interface', + 'Interface Version': '0240', + 'Git SHA': 'c765cbb590f57598756683254ca38b211693ae5e', + 'Local Mods': '0', + 'USB Interfaces': 'MSD, CDC, HID', + 'Interface CRC': '0x26764ebf' + }, + 'details_valid_version' : { + 'Version': '0226', + 'Build': 'Aug 24 2015 17:06:30', + 'Git Commit SHA': '27a236b9fe39c674a703c5c89655fbd26b8e27e1', + 'Git Local mods': 'Yes' + }, + 'details_missing_interface_version' : { + 'Unique ID': '0226000033514e450044500585d4001de981000097969900', + 'HIC ID': '97969900', + 'Auto Reset': '0', + 'Automation allowed': '0', + 'Overflow detection': '0', + 'Daplink Mode': 'Interface', + 'Git SHA': 'b403a07e3696cee1e116d44cbdd64446e056ce38', + 'Local Mods': '0', + 'USB Interfaces': 'MSD, CDC, HID', + 'Interface CRC': '0x4d98bf7e', + 'Remount count': '0' + }, + 'details_invalid_none' : None + } """ Tests for detect_targets.py """ -class DetectTargetsTests(unittest.TestCase): +class DetectTargetsTest(unittest.TestCase): """ Test cases for Detect Target functionality """ @@ -33,26 +78,9 @@ def setUp(self): Called before each test case :return: - """ - # Gather a valid mount point from the host machine - muts = get_autodetected_MUTS_list() - - count = 0 - - for mut in muts.values(): - - count += 1 - self.valid_mount_point = mut['disk'] - break - - # If no targets are found, there is no way to determine Host OS mount point. - # Function should handle failure gracefully regardless of a mount point being present. - # Therefore it is safe to assume a valid mount point. - if count is 0: - self.valid_mount_point = "D:" - - self.invalid_mount_point = "23z/e\n" + """ self.missing_mount_point = None + self.mount_point = "D:" def tearDown(self): """ @@ -62,22 +90,67 @@ def tearDown(self): :return: """ pass + + @patch("mbed_lstools.create", return_value=MbedLsToolsMock('details_valid_interface_version')) + def test_interface_version_valid(self, mbed_lstools_mock): + """ + Test that checks function returns correctly when given a valid Interface Version + + :param mbed_lstools_mock: Mocks Mbed LS tools with MbedLsToolsMock + :return + """ - def test_interface_version_valid_mount_point(self): + interface_version = get_interface_version(self.mount_point) + assert interface_version == '0240' - interface_version = get_interface_version(self.valid_mount_point) - assert len(interface_version) > 0 + @patch("mbed_lstools.create", return_value=MbedLsToolsMock('details_valid_version')) + def test_version_valid(self, mbed_lstools_mock): + """ + Test that checks function returns correctly when given a valid Version + + :param mbed_lstools_mock: Mocks Mbed LS tools with MbedLsToolsMock + :return + """ - def test_interface_version_invalid_mount_point(self): + interface_version = get_interface_version(self.mount_point) + assert interface_version == '0226' - interface_version = get_interface_version(self.invalid_mount_point) + @patch("mbed_lstools.create", return_value=MbedLsToolsMock('details_missing_interface_version')) + def test_interface_version_missing_interface_version(self, mbed_lstools_mock): + """ + Test that checks function returns correctly when DETAILS.txt is present + but an interface version is not listed. + + :param mbed_lstools_mock: Mocks Mbed LS tools with MbedLsToolsMock + :return + """ + + interface_version = get_interface_version(self.mount_point) assert interface_version == 'unknown' - def test_interface_version_missing_mount_point(self): + @patch("mbed_lstools.create", return_value=MbedLsToolsMock('details_invalid_none')) + def test_version_none(self, mbed_lstools_mock): + """ + Test that checks function returns correctly when a valid mount point is supplied + but DETAILS.txt is not present. + + :param mbed_lstools_mock: Mocks Mbed LS tools with MbedLsToolsMock + :return + """ + + interface_version = get_interface_version(self.mount_point) + assert interface_version == 'unknown' + + @patch("mbed_lstools.create", return_value=MbedLsToolsMock('details_invalid_none')) + def test_interface_version_missing_mount_point(self, mbed_lstools_mock): + """ + Test that checks function returns correctly when no moint point is supplied. + :param mbed_lstools_mock: Mocks Mbed LS tools with MbedLsToolsMock + :return + """ interface_version = get_interface_version(self.missing_mount_point) assert interface_version == 'unknown' - if __name__ == '__main__': unittest.main() From 9a5aa7237f400f4e3d118aff69201e9d936f0f99 Mon Sep 17 00:00:00 2001 From: David Walters Date: Fri, 29 Sep 2017 10:12:02 +0100 Subject: [PATCH 016/108] Minor copy edits, added comment --- tools/test/detect_targets_test.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/test/detect_targets_test.py b/tools/test/detect_targets_test.py index f1c79945291..6bf107381b8 100644 --- a/tools/test/detect_targets_test.py +++ b/tools/test/detect_targets_test.py @@ -21,6 +21,9 @@ class MbedLsToolsMock(): + """ + Mock of mbedls tools + """ def __init__(self, type): self.interface_test_type = type @@ -144,11 +147,12 @@ def test_version_none(self, mbed_lstools_mock): @patch("mbed_lstools.create", return_value=MbedLsToolsMock('details_invalid_none')) def test_interface_version_missing_mount_point(self, mbed_lstools_mock): """ - Test that checks function returns correctly when no moint point is supplied. + Test that checks function returns correctly when no mount point is supplied. :param mbed_lstools_mock: Mocks Mbed LS tools with MbedLsToolsMock :return """ + interface_version = get_interface_version(self.missing_mount_point) assert interface_version == 'unknown' From a5f691ddd445fad8b5d322f45e8f7cba446c6c54 Mon Sep 17 00:00:00 2001 From: David Walters Date: Fri, 29 Sep 2017 15:34:32 +0100 Subject: [PATCH 017/108] Changed type => test_type --- tools/test/detect_targets_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/test/detect_targets_test.py b/tools/test/detect_targets_test.py index 6bf107381b8..be21a32956b 100644 --- a/tools/test/detect_targets_test.py +++ b/tools/test/detect_targets_test.py @@ -25,8 +25,8 @@ class MbedLsToolsMock(): Mock of mbedls tools """ - def __init__(self, type): - self.interface_test_type = type + def __init__(self, test_type): + self.interface_test_type = test_type def get_details_txt(self, mount_point): return self.details_txt_types[self.interface_test_type]; From 7320e7411da06917a7cbda4883af77438fdd0c4e Mon Sep 17 00:00:00 2001 From: adustm Date: Tue, 12 Sep 2017 13:41:25 +0200 Subject: [PATCH 018/108] Allow exporters for NUCLEO_L486RG --- tools/export/iar/iar_definitions.json | 3 +++ tools/export/sw4stm32/__init__.py | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/tools/export/iar/iar_definitions.json b/tools/export/iar/iar_definitions.json index 2116d1cf584..36bd4923c6d 100644 --- a/tools/export/iar/iar_definitions.json +++ b/tools/export/iar/iar_definitions.json @@ -23,6 +23,9 @@ "STM32L476RG": { "OGChipSelectEditMenu": "STM32L476RG\tST STM32L476RG" }, + "STM32L486RG": { + "OGChipSelectEditMenu": "STM32L486RG\tST STM32L486RG" + }, "STM32L011K4": { "OGChipSelectEditMenu": "STM32L011x4\tST STM32L011x4" }, diff --git a/tools/export/sw4stm32/__init__.py b/tools/export/sw4stm32/__init__.py index f76770b202f..d9fd0cf91f3 100644 --- a/tools/export/sw4stm32/__init__.py +++ b/tools/export/sw4stm32/__init__.py @@ -249,6 +249,11 @@ class Sw4STM32(GNUARMEclipse): 'name': 'NUCLEO-L476RG', 'mcuId': 'STM32L476RGTx' }, + 'NUCLEO_L486RG': + { + 'name': 'NUCLEO-L486RG', + 'mcuId': 'STM32L486RGTx' + }, } TARGETS = BOARDS.keys() From 2b1597a0079833f9cefec603cab39acbee0b56f1 Mon Sep 17 00:00:00 2001 From: Mathias Giacomuzzi Date: Tue, 26 Sep 2017 11:01:01 +0200 Subject: [PATCH 019/108] add quotation marks for compiler path --- tools/export/gnuarmeclipse/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/export/gnuarmeclipse/__init__.py b/tools/export/gnuarmeclipse/__init__.py index 1a432a4c458..f6cc2d0e4da 100644 --- a/tools/export/gnuarmeclipse/__init__.py +++ b/tools/export/gnuarmeclipse/__init__.py @@ -244,7 +244,7 @@ def create_jinja_ctx(self): opts['ld']['system_libraries'] = self.system_libraries opts['ld']['script'] = join(id.capitalize(), "linker-script-%s.ld" % id) - opts['cpp_cmd'] = " ".join(toolchain.preproc) + opts['cpp_cmd'] = "".join('"{}"'.format(toolchain.preproc[0])) + " " + " ".join(toolchain.preproc[1:]) # Unique IDs used in multiple places. # Those used only once are implemented with {{u.id}}. From 98b247a9635a901171a1e4db3418c614480c98a4 Mon Sep 17 00:00:00 2001 From: Mathias Giacomuzzi Date: Wed, 27 Sep 2017 12:31:45 +0200 Subject: [PATCH 020/108] remove the first join --- tools/export/gnuarmeclipse/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/export/gnuarmeclipse/__init__.py b/tools/export/gnuarmeclipse/__init__.py index f6cc2d0e4da..5d4dcc8b7d9 100644 --- a/tools/export/gnuarmeclipse/__init__.py +++ b/tools/export/gnuarmeclipse/__init__.py @@ -244,7 +244,7 @@ def create_jinja_ctx(self): opts['ld']['system_libraries'] = self.system_libraries opts['ld']['script'] = join(id.capitalize(), "linker-script-%s.ld" % id) - opts['cpp_cmd'] = "".join('"{}"'.format(toolchain.preproc[0])) + " " + " ".join(toolchain.preproc[1:]) + opts['cpp_cmd'] = '"{}"'.format(toolchain.preproc[0]) + " " + " ".join(toolchain.preproc[1:]) # Unique IDs used in multiple places. # Those used only once are implemented with {{u.id}}. From fbb184988a0d9caf0b4d5ad6beb96d839481b685 Mon Sep 17 00:00:00 2001 From: Senthil Ramakrishnan Date: Wed, 27 Sep 2017 10:46:01 -0500 Subject: [PATCH 021/108] Merging changes from ATParser towards parser unification --- platform/ATCmdParser.cpp | 41 ++++++++++++++++++++++++++++++++++++++++ platform/ATCmdParser.h | 10 ++++++++++ 2 files changed, 51 insertions(+) diff --git a/platform/ATCmdParser.cpp b/platform/ATCmdParser.cpp index 6200f1fa4b6..3e5ee2cde2a 100644 --- a/platform/ATCmdParser.cpp +++ b/platform/ATCmdParser.cpp @@ -380,3 +380,44 @@ void ATCmdParser::abort() { _aborted = true; } + +bool ATCmdParser::process_oob() +{ + if (!_fh->readable()) { + return false; + } + + int i = 0; + while (true) { + // Receive next character + int c = getc(); + if (c < 0) { + return false; + } + _buffer[i++] = c; + _buffer[i] = 0; + + // Check for oob data + struct oob *oob = _oobs; + while ( oob ) { + if (i == (int)oob->len && memcmp( + oob->prefix, _buffer, oob->len) == 0) { + debug_if(_dbg_on, "AT! %s\r\n", oob->prefix); + oob->cb(); + return true; + } + oob = oob->next; + } + + // Clear the buffer when we hit a newline or ran out of space + // running out of space usually means we ran into binary data + if (i+1 >= _buffer_size || + strcmp(&_buffer[i-_output_delim_size], _output_delimiter) == 0) { + + debug_if(_dbg_on, "AT< %s", _buffer); + i = 0; + } + } +} + + diff --git a/platform/ATCmdParser.h b/platform/ATCmdParser.h index 03b1ef6b2ac..1201a6055f5 100644 --- a/platform/ATCmdParser.h +++ b/platform/ATCmdParser.h @@ -288,6 +288,16 @@ class ATCmdParser : private NonCopyable * recv operation. */ void abort(); + + /** + * Process out-of-band data + * + * Process out-of-band data in the receive buffer. This function + * returns immediately if there is no data to process. + * + * @return true if oob data processed, false otherwise + */ + bool process_oob(void); }; } //namespace mbed From 634bde35a1bd5bab5c677d8585e84439cbf409df Mon Sep 17 00:00:00 2001 From: Senthil Ramakrishnan Date: Wed, 27 Sep 2017 11:40:36 -0500 Subject: [PATCH 022/108] Merging changes from ATParser got AT parser unification --- platform/ATCmdParser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/ATCmdParser.cpp b/platform/ATCmdParser.cpp index 3e5ee2cde2a..a787b58b2a2 100644 --- a/platform/ATCmdParser.cpp +++ b/platform/ATCmdParser.cpp @@ -399,7 +399,7 @@ bool ATCmdParser::process_oob() // Check for oob data struct oob *oob = _oobs; - while ( oob ) { + while (oob) { if (i == (int)oob->len && memcmp( oob->prefix, _buffer, oob->len) == 0) { debug_if(_dbg_on, "AT! %s\r\n", oob->prefix); From 06fa1dbbef69f3717c3b24e86c07019adb758ef1 Mon Sep 17 00:00:00 2001 From: Russ Butler Date: Wed, 4 Oct 2017 16:07:41 -0500 Subject: [PATCH 023/108] Prevent use of deleted ticker in Ticker test In test_case_2x_callbacks two tickers are setup to repeatedly reschedule each other. When these tickers are deleted this rescheduling is still occurring and can lead to a deleted ticker being scheduled. When this happens the following error message is displayed: Thread 0x0 error -6: Not allowed in ISR context Note - this problem was not detected by CI since the test reported the correct results back to the host test and only experienced this error on tear down. This problem can be reproduced on an nrf51 by first building the ticker test with: "mbed test -t GCC_ARM -m NRF51_DK -n tests-mbed_drivers-ticker --compile -DMBED_TRAP_ERRORS_ENABLED=1 -DMBED_HEAP_STATS_ENABLED=1 -DMBED_STACK_STATS_ENABLED=1" And then running testing with: "mbed test -t GCC_ARM -m NRF51_DK -n tests-mbed_drivers-ticker --run" --- TESTS/mbed_drivers/ticker/main.cpp | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/TESTS/mbed_drivers/ticker/main.cpp b/TESTS/mbed_drivers/ticker/main.cpp index b9ae733bf2d..9e12041de59 100644 --- a/TESTS/mbed_drivers/ticker/main.cpp +++ b/TESTS/mbed_drivers/ticker/main.cpp @@ -44,8 +44,8 @@ static const int total_ticks = 10; DigitalOut led1(LED1); DigitalOut led2(LED2); -Ticker *ticker1; -Ticker *ticker2; +Ticker *volatile ticker1; +Ticker *volatile ticker2; volatile int ticker_count = 0; volatile bool print_tick = false; @@ -67,15 +67,21 @@ void ticker_callback_2_led(void) { void ticker_callback_1_switch_to_2(void) { ++callback_trigger_count; - ticker1->detach(); - ticker1->attach_us(ticker_callback_2_switch_to_1, ONE_MILLI_SEC); + // If ticker is NULL then it is being or has been deleted + if (ticker1) { + ticker1->detach(); + ticker1->attach_us(ticker_callback_2_switch_to_1, ONE_MILLI_SEC); + } ticker_callback_1_led(); } void ticker_callback_2_switch_to_1(void) { ++callback_trigger_count; - ticker2->detach(); - ticker2->attach_us(ticker_callback_1_switch_to_2, ONE_MILLI_SEC); + // If ticker is NULL then it is being or has been deleted + if (ticker2) { + ticker2->detach(); + ticker2->attach_us(ticker_callback_1_switch_to_2, ONE_MILLI_SEC); + } ticker_callback_2_led(); } @@ -159,13 +165,19 @@ utest::v1::status_t two_ticker_case_setup_handler_t(const Case *const source, co } utest::v1::status_t one_ticker_case_teardown_handler_t(const Case *const source, const size_t passed, const size_t failed, const failure_t reason) { - delete ticker1; + Ticker *temp1 = ticker1; + ticker1 = NULL; + delete temp1; return greentea_case_teardown_handler(source, passed, failed, reason); } utest::v1::status_t two_ticker_case_teardown_handler_t(const Case *const source, const size_t passed, const size_t failed, const failure_t reason) { - delete ticker1; - delete ticker2; + Ticker *temp1 = ticker1; + Ticker *temp2 = ticker2; + ticker1 = NULL; + ticker2 = NULL; + delete temp1; + delete temp2; return greentea_case_teardown_handler(source, passed, failed, reason); } From ae4ce867f96f1ee995102debde2eb404e991a244 Mon Sep 17 00:00:00 2001 From: Filip Jagodzinski Date: Tue, 5 Sep 2017 13:31:12 +0200 Subject: [PATCH 024/108] HAL: ticker_api: Fix outdated comment --- hal/ticker_api.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hal/ticker_api.h b/hal/ticker_api.h index fceba2db87e..aaa063dd2b2 100644 --- a/hal/ticker_api.h +++ b/hal/ticker_api.h @@ -132,8 +132,9 @@ void ticker_insert_event(const ticker_data_t *const ticker, ticker_event_t *obj, * * The event will be executed in timestamp - ticker_read_us() us. * - * @warning If an event is inserted with a timestamp less than the current - * timestamp then the event will **not** be inserted. + * @note If an event is inserted with a timestamp less than the current + * timestamp then the event will be scheduled immediately resulting in + * an instant call to event handler. * * @param ticker The ticker object. * @param obj The event object to be inserted to the queue From 8c987698ad8799a6f91d8b0b3016bd23d872de8f Mon Sep 17 00:00:00 2001 From: cyliangtw Date: Wed, 23 Aug 2017 21:27:21 +0800 Subject: [PATCH 025/108] Fixed ethernet multi-function pin --- .../arch/TARGET_NUVOTON/TARGET_M480/m480_eth.c | 13 +++++++++---- .../arch/TARGET_NUVOTON/TARGET_NUC472/nuc472_eth.c | 6 +++++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/features/FEATURE_LWIP/lwip-interface/lwip-eth/arch/TARGET_NUVOTON/TARGET_M480/m480_eth.c b/features/FEATURE_LWIP/lwip-interface/lwip-eth/arch/TARGET_NUVOTON/TARGET_M480/m480_eth.c index 32918059f61..2e747a60ef5 100644 --- a/features/FEATURE_LWIP/lwip-interface/lwip-eth/arch/TARGET_NUVOTON/TARGET_M480/m480_eth.c +++ b/features/FEATURE_LWIP/lwip-interface/lwip-eth/arch/TARGET_NUVOTON/TARGET_M480/m480_eth.c @@ -215,10 +215,15 @@ static void __eth_clk_pin_init() /* Init I/O Multi-function */ /*---------------------------------------------------------------------------------------------------------*/ // Configure RMII pins - SYS->GPA_MFPL = SYS_GPA_MFPL_PA6MFP_EMAC_RMII_RXERR | SYS_GPA_MFPL_PA7MFP_EMAC_RMII_CRSDV; - SYS->GPC_MFPL = SYS_GPC_MFPL_PC6MFP_EMAC_RMII_RXD1 | SYS_GPC_MFPL_PC7MFP_EMAC_RMII_RXD0; - SYS->GPC_MFPH = SYS_GPC_MFPH_PC8MFP_EMAC_RMII_REFCLK; - SYS->GPE_MFPH = SYS_GPE_MFPH_PE8MFP_EMAC_RMII_MDC | + SYS->GPA_MFPL &= ~(SYS_GPA_MFPL_PA6MFP_Msk | SYS_GPA_MFPL_PA7MFP_Msk); + SYS->GPA_MFPL |= SYS_GPA_MFPL_PA6MFP_EMAC_RMII_RXERR | SYS_GPA_MFPL_PA7MFP_EMAC_RMII_CRSDV; + SYS->GPC_MFPL &= ~(SYS_GPC_MFPL_PC6MFP_Msk | SYS_GPC_MFPL_PC7MFP_Msk); + SYS->GPC_MFPL |= SYS_GPC_MFPL_PC6MFP_EMAC_RMII_RXD1 | SYS_GPC_MFPL_PC7MFP_EMAC_RMII_RXD0; + SYS->GPC_MFPH &= ~SYS_GPC_MFPH_PC8MFP_Msk; + SYS->GPC_MFPH |= SYS_GPC_MFPH_PC8MFP_EMAC_RMII_REFCLK; + SYS->GPE_MFPH &= ~(SYS_GPE_MFPH_PE8MFP_Msk | SYS_GPE_MFPH_PE9MFP_Msk | SYS_GPE_MFPH_PE10MFP_Msk | + SYS_GPE_MFPH_PE11MFP_Msk | SYS_GPE_MFPH_PE12MFP_Msk); + SYS->GPE_MFPH |= SYS_GPE_MFPH_PE8MFP_EMAC_RMII_MDC | SYS_GPE_MFPH_PE9MFP_EMAC_RMII_MDIO | SYS_GPE_MFPH_PE10MFP_EMAC_RMII_TXD0 | SYS_GPE_MFPH_PE11MFP_EMAC_RMII_TXD1 | diff --git a/features/FEATURE_LWIP/lwip-interface/lwip-eth/arch/TARGET_NUVOTON/TARGET_NUC472/nuc472_eth.c b/features/FEATURE_LWIP/lwip-interface/lwip-eth/arch/TARGET_NUVOTON/TARGET_NUC472/nuc472_eth.c index 1101f5b1e50..6c22b03bb57 100644 --- a/features/FEATURE_LWIP/lwip-interface/lwip-eth/arch/TARGET_NUVOTON/TARGET_NUC472/nuc472_eth.c +++ b/features/FEATURE_LWIP/lwip-interface/lwip-eth/arch/TARGET_NUVOTON/TARGET_NUC472/nuc472_eth.c @@ -207,6 +207,9 @@ static void __eth_clk_pin_init() /* Init I/O Multi-function */ /*---------------------------------------------------------------------------------------------------------*/ // Configure RMII pins + SYS->GPC_MFPL &= ~( SYS_GPC_MFPL_PC0MFP_Msk | SYS_GPC_MFPL_PC1MFP_Msk | + SYS_GPC_MFPL_PC2MFP_Msk | SYS_GPC_MFPL_PC3MFP_Msk | + SYS_GPC_MFPL_PC4MFP_Msk | SYS_GPC_MFPL_PC6MFP_Msk | SYS_GPC_MFPL_PC7MFP_Msk ); SYS->GPC_MFPL |= SYS_GPC_MFPL_PC0MFP_EMAC_REFCLK | SYS_GPC_MFPL_PC1MFP_EMAC_MII_RXERR | SYS_GPC_MFPL_PC2MFP_EMAC_MII_RXDV | @@ -215,12 +218,13 @@ static void __eth_clk_pin_init() SYS_GPC_MFPL_PC6MFP_EMAC_MII_TXD0 | SYS_GPC_MFPL_PC7MFP_EMAC_MII_TXD1; - + SYS->GPC_MFPH &= ~SYS_GPC_MFPH_PC8MFP_Msk; SYS->GPC_MFPH |= SYS_GPC_MFPH_PC8MFP_EMAC_MII_TXEN; // Enable high slew rate on all RMII pins PC->SLEWCTL |= 0x1DF; // Configure MDC, MDIO at PB14 & PB15 + SYS->GPB_MFPH &= ~(SYS_GPB_MFPH_PB14MFP_Msk | SYS_GPB_MFPH_PB15MFP_Msk); SYS->GPB_MFPH |= SYS_GPB_MFPH_PB14MFP_EMAC_MII_MDC | SYS_GPB_MFPH_PB15MFP_EMAC_MII_MDIO; } From 0ece4d02b00237e85db4f0403f714026abc7955c Mon Sep 17 00:00:00 2001 From: ccli8 Date: Mon, 4 Sep 2017 11:08:09 +0800 Subject: [PATCH 026/108] Replace mktime/localtime with interrupt-safe version in rtc The use of mktime was causing a fault when called in interrupt handler because on GCC it lock the mutex protecting the environment, To overcome this issue, this patch add dedicated routine to convert a time_t into a tm and vice versa. In the process mktime has been optimized and is now an order of magnitude faster than the routines present in the C library. --- targets/TARGET_NUVOTON/TARGET_M480/rtc_api.c | 22 ++++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/targets/TARGET_NUVOTON/TARGET_M480/rtc_api.c b/targets/TARGET_NUVOTON/TARGET_M480/rtc_api.c index 5047ccad033..186fffd6845 100644 --- a/targets/TARGET_NUVOTON/TARGET_M480/rtc_api.c +++ b/targets/TARGET_NUVOTON/TARGET_M480/rtc_api.c @@ -22,6 +22,7 @@ #include "mbed_error.h" #include "nu_modutil.h" #include "nu_miscutil.h" +#include "mbed_mktime.h" #define YEAR0 1900 //#define EPOCH_YR 1970 @@ -92,7 +93,7 @@ time_t rtc_read(void) timeinfo.tm_sec = rtc_datetime.u32Second; // Convert to timestamp - time_t t = mktime(&timeinfo); + time_t t = _rtc_mktime(&timeinfo); return t; } @@ -104,18 +105,21 @@ void rtc_write(time_t t) } // Convert timestamp to struct tm - struct tm *timeinfo = localtime(&t); + struct tm timeinfo; + if (_rtc_localtime(t, &timeinfo) == false) { + return; + } S_RTC_TIME_DATA_T rtc_datetime; // Convert S_RTC_TIME_DATA_T to struct tm - rtc_datetime.u32Year = timeinfo->tm_year + YEAR0; - rtc_datetime.u32Month = timeinfo->tm_mon + 1; - rtc_datetime.u32Day = timeinfo->tm_mday; - rtc_datetime.u32DayOfWeek = timeinfo->tm_wday; - rtc_datetime.u32Hour = timeinfo->tm_hour; - rtc_datetime.u32Minute = timeinfo->tm_min; - rtc_datetime.u32Second = timeinfo->tm_sec; + rtc_datetime.u32Year = timeinfo.tm_year + YEAR0; + rtc_datetime.u32Month = timeinfo.tm_mon + 1; + rtc_datetime.u32Day = timeinfo.tm_mday; + rtc_datetime.u32DayOfWeek = timeinfo.tm_wday; + rtc_datetime.u32Hour = timeinfo.tm_hour; + rtc_datetime.u32Minute = timeinfo.tm_min; + rtc_datetime.u32Second = timeinfo.tm_sec; rtc_datetime.u32TimeScale = RTC_CLOCK_24; // NOTE: Timing issue with write to RTC registers. This delay is empirical, not rational. From f7f1ed37ce4751c6362bd41e1f4bbd03ee678d00 Mon Sep 17 00:00:00 2001 From: ccli8 Date: Tue, 29 Aug 2017 16:16:56 +0800 Subject: [PATCH 027/108] Refine sleep code 1. Remove stale code with mbed OS 3. 2. Remove check for busy peripherals unorganizedly. This would be supported by e.g. official sleep manager. --- targets/TARGET_NUVOTON/TARGET_M451/sleep.c | 71 +++---------------- targets/TARGET_NUVOTON/TARGET_M480/sleep.c | 68 +++--------------- targets/TARGET_NUVOTON/TARGET_NUC472/sleep.c | 74 +++----------------- 3 files changed, 24 insertions(+), 189 deletions(-) diff --git a/targets/TARGET_NUVOTON/TARGET_M451/sleep.c b/targets/TARGET_NUVOTON/TARGET_M451/sleep.c index ab1b9daa37d..c2bb24eb7ef 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/sleep.c +++ b/targets/TARGET_NUVOTON/TARGET_M451/sleep.c @@ -15,8 +15,6 @@ */ #include "sleep_api.h" -#include "serial_api.h" -#include "lp_ticker_api.h" #if DEVICE_SLEEP @@ -25,77 +23,24 @@ #include "objects.h" #include "PeripheralPins.h" -static void mbed_enter_sleep(struct sleep_s *obj); -static void mbed_exit_sleep(struct sleep_s *obj); - -int serial_allow_powerdown(void); -int spi_allow_powerdown(void); -int i2c_allow_powerdown(void); -int pwmout_allow_powerdown(void); - /** - * Enter Idle mode. + * Enter idle mode, in which just CPU is halted. */ void hal_sleep(void) { - struct sleep_s sleep_obj; - sleep_obj.powerdown = 0; - mbed_enter_sleep(&sleep_obj); - mbed_exit_sleep(&sleep_obj); + SYS_UnlockReg(); + CLK_Idle(); + SYS_LockReg(); } /** - * Enter Power-down mode while no peripheral is active; otherwise, enter Idle mode. + * Enter power-down mode, in which HXT/HIRC are halted. */ void hal_deepsleep(void) { - struct sleep_s sleep_obj; - sleep_obj.powerdown = 1; - mbed_enter_sleep(&sleep_obj); - mbed_exit_sleep(&sleep_obj); -} - -static void mbed_enter_sleep(struct sleep_s *obj) -{ - // Check if serial allows entering power-down mode - if (obj->powerdown) { - obj->powerdown = serial_allow_powerdown(); - } - // Check if spi allows entering power-down mode - if (obj->powerdown) { - obj->powerdown = spi_allow_powerdown(); - } - // Check if i2c allows entering power-down mode - if (obj->powerdown) { - obj->powerdown = i2c_allow_powerdown(); - } - // Check if pwmout allows entering power-down mode - if (obj->powerdown) { - obj->powerdown = pwmout_allow_powerdown(); - } - // TODO: Check if other peripherals allow entering power-down mode - - if (obj->powerdown) { // Power-down mode (HIRC/HXT disabled, LIRC/LXT enabled) - SYS_UnlockReg(); - CLK_PowerDown(); - SYS_LockReg(); - } - else { // CPU halt mode (HIRC/HXT enabled, LIRC/LXT enabled) - SYS_UnlockReg(); - CLK_Idle(); - SYS_LockReg(); - } - __NOP(); - __NOP(); - __NOP(); - __NOP(); -} - -static void mbed_exit_sleep(struct sleep_s *obj) -{ - // TODO: TO BE CONTINUED - - (void)obj; + SYS_UnlockReg(); + CLK_PowerDown(); + SYS_LockReg(); } #endif diff --git a/targets/TARGET_NUVOTON/TARGET_M480/sleep.c b/targets/TARGET_NUVOTON/TARGET_M480/sleep.c index a6fde61172b..c2bb24eb7ef 100644 --- a/targets/TARGET_NUVOTON/TARGET_M480/sleep.c +++ b/targets/TARGET_NUVOTON/TARGET_M480/sleep.c @@ -15,8 +15,6 @@ */ #include "sleep_api.h" -#include "serial_api.h" -#include "lp_ticker_api.h" #if DEVICE_SLEEP @@ -25,74 +23,24 @@ #include "objects.h" #include "PeripheralPins.h" -static void mbed_enter_sleep(struct sleep_s *obj); -static void mbed_exit_sleep(struct sleep_s *obj); - -int serial_allow_powerdown(void); -int spi_allow_powerdown(void); -int i2c_allow_powerdown(void); -int pwmout_allow_powerdown(void); - /** - * Enter Idle mode. + * Enter idle mode, in which just CPU is halted. */ void hal_sleep(void) { - struct sleep_s sleep_obj; - sleep_obj.powerdown = 0; - mbed_enter_sleep(&sleep_obj); - mbed_exit_sleep(&sleep_obj); + SYS_UnlockReg(); + CLK_Idle(); + SYS_LockReg(); } /** - * Enter Power-down mode while no peripheral is active; otherwise, enter Idle mode. + * Enter power-down mode, in which HXT/HIRC are halted. */ void hal_deepsleep(void) { - struct sleep_s sleep_obj; - sleep_obj.powerdown = 1; - mbed_enter_sleep(&sleep_obj); - mbed_exit_sleep(&sleep_obj); -} - -static void mbed_enter_sleep(struct sleep_s *obj) -{ - // Check if serial allows entering power-down mode - if (obj->powerdown) { - obj->powerdown = serial_allow_powerdown(); - } - // Check if spi allows entering power-down mode - if (obj->powerdown) { - obj->powerdown = spi_allow_powerdown(); - } - // Check if i2c allows entering power-down mode - if (obj->powerdown) { - obj->powerdown = i2c_allow_powerdown(); - } - // Check if pwmout allows entering power-down mode - if (obj->powerdown) { - obj->powerdown = pwmout_allow_powerdown(); - } - // TODO: Check if other peripherals allow entering power-down mode - - if (obj->powerdown) { // Power-down mode (HIRC/HXT disabled, LIRC/LXT enabled) - SYS_UnlockReg(); - CLK_PowerDown(); - SYS_LockReg(); - } else { // CPU halt mode (HIRC/HXT enabled, LIRC/LXT enabled) - SYS_UnlockReg(); - CLK_Idle(); - SYS_LockReg(); - } - __NOP(); - __NOP(); - __NOP(); - __NOP(); -} - -static void mbed_exit_sleep(struct sleep_s *obj) -{ - (void)obj; + SYS_UnlockReg(); + CLK_PowerDown(); + SYS_LockReg(); } #endif diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/sleep.c b/targets/TARGET_NUVOTON/TARGET_NUC472/sleep.c index 87f53ab6f61..c2bb24eb7ef 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/sleep.c +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/sleep.c @@ -15,8 +15,6 @@ */ #include "sleep_api.h" -#include "serial_api.h" -#include "lp_ticker_api.h" #if DEVICE_SLEEP @@ -25,80 +23,24 @@ #include "objects.h" #include "PeripheralPins.h" -static void mbed_enter_sleep(struct sleep_s *obj); -static void mbed_exit_sleep(struct sleep_s *obj); - -int serial_allow_powerdown(void); -int spi_allow_powerdown(void); -int i2c_allow_powerdown(void); -int pwmout_allow_powerdown(void); - /** - * Enter Idle mode. + * Enter idle mode, in which just CPU is halted. */ void hal_sleep(void) { - struct sleep_s sleep_obj; - sleep_obj.powerdown = 0; - mbed_enter_sleep(&sleep_obj); - mbed_exit_sleep(&sleep_obj); + SYS_UnlockReg(); + CLK_Idle(); + SYS_LockReg(); } /** - * Enter Power-down mode while no peripheral is active; otherwise, enter Idle mode. + * Enter power-down mode, in which HXT/HIRC are halted. */ void hal_deepsleep(void) { - struct sleep_s sleep_obj; - sleep_obj.powerdown = 1; - mbed_enter_sleep(&sleep_obj); - mbed_exit_sleep(&sleep_obj); -} - -static void mbed_enter_sleep(struct sleep_s *obj) -{ - // Check if serial allows entering power-down mode - if (obj->powerdown) { - obj->powerdown = serial_allow_powerdown(); - } - // Check if spi allows entering power-down mode - if (obj->powerdown) { - obj->powerdown = spi_allow_powerdown(); - } - // Check if i2c allows entering power-down mode - if (obj->powerdown) { - obj->powerdown = i2c_allow_powerdown(); - } - // Check if pwmout allows entering power-down mode - if (obj->powerdown) { - obj->powerdown = pwmout_allow_powerdown(); - } - // TODO: Check if other peripherals allow entering power-down mode - - if (obj->powerdown) { // Power-down mode (HIRC/HXT disabled, LIRC/LXT enabled) - SYS_UnlockReg(); - CLK_PowerDown(); - SYS_LockReg(); - } - else { // CPU halt mode (HIRC/HXT enabled, LIRC/LXT enabled) - // NOTE: NUC472's CLK_Idle() will also disable HIRC/HXT. - SYS_UnlockReg(); - SCB->SCR &= ~SCB_SCR_SLEEPDEEP_Msk; - CLK->PWRCTL &= ~CLK_PWRCTL_PDEN_Msk; - __WFI(); - SYS_LockReg(); - } - __NOP(); - __NOP(); - __NOP(); - __NOP(); -} - -static void mbed_exit_sleep(struct sleep_s *obj) -{ - // TODO: TO BE CONTINUED - - (void)obj; + SYS_UnlockReg(); + CLK_PowerDown(); + SYS_LockReg(); } #endif From 921f9e18fcfb95020c545c693a3218d19aaa162f Mon Sep 17 00:00:00 2001 From: ccli8 Date: Mon, 4 Sep 2017 15:01:31 +0800 Subject: [PATCH 028/108] Fix RTC macro function with no arguments in BSP --- .../TARGET_NUC472/device/StdDriver/nuc472_rtc.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_rtc.h b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_rtc.h index 9a87f8a6bb3..3d633b166d4 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_rtc.h +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_rtc.h @@ -129,7 +129,7 @@ typedef struct { * 1 = This year is a leap year. * \hideinitializer */ -#define RTC_IS_LEAP_YEAR ((RTC->LEAPYEAR & (RTC_LEAPYEAR_LEAPYEAR_Msk))?1:0) +#define RTC_IS_LEAP_YEAR() ((RTC->LEAPYEAR & (RTC_LEAPYEAR_LEAPYEAR_Msk))?1:0) /** * @brief Clear alarm interrupt status. @@ -139,7 +139,7 @@ typedef struct { * @return None * \hideinitializer */ -#define RTC_CLEAR_ALARM_INT_FLAG (RTC->INTSTS = RTC_INTSTS_ALMIF_Msk) +#define RTC_CLEAR_ALARM_INT_FLAG() (RTC->INTSTS = RTC_INTSTS_ALMIF_Msk) /** * @brief Clear tick interrupt status. @@ -149,7 +149,7 @@ typedef struct { * @return None * \hideinitializer */ -#define RTC_CLEAR_TICK_INT_FLAG (RTC->INTSTS = RTC_INTSTS_TICKIF_Msk) +#define RTC_CLEAR_TICK_INT_FLAG() (RTC->INTSTS = RTC_INTSTS_TICKIF_Msk) /** * @brief Clear tamper detect pin status. @@ -169,7 +169,7 @@ typedef struct { * @return Alarm interrupt status * \hideinitializer */ -#define RTC_GET_ALARM_INT_FLAG ((RTC->INTSTS & RTC_INTSTS_ALMIF_Msk) >> RTC_INTSTS_ALMIF_Pos) +#define RTC_GET_ALARM_INT_FLAG() ((RTC->INTSTS & RTC_INTSTS_ALMIF_Msk) >> RTC_INTSTS_ALMIF_Pos) /** * @brief Get alarm interrupt status. @@ -179,7 +179,7 @@ typedef struct { * @return Alarm interrupt status * \hideinitializer */ -#define RTC_GET_TICK_INT_FLAG ((RTC->INTSTS & RTC_INTSTS_TICKIF_Msk) >> RTC_INTSTS_TICKIF_Pos) +#define RTC_GET_TICK_INT_FLAG() ((RTC->INTSTS & RTC_INTSTS_TICKIF_Msk) >> RTC_INTSTS_TICKIF_Pos) /** * @brief Get tamper detect pin status. From cb10be0a34a8ebf5ba4d7200abcb44ad944c922e Mon Sep 17 00:00:00 2001 From: ccli8 Date: Mon, 4 Sep 2017 17:34:02 +0800 Subject: [PATCH 029/108] Fix RTC hour error with AM/PM --- targets/TARGET_NUVOTON/TARGET_M451/rtc_api.c | 3 +++ targets/TARGET_NUVOTON/TARGET_M480/rtc_api.c | 3 +++ targets/TARGET_NUVOTON/TARGET_NUC472/rtc_api.c | 3 +++ 3 files changed, 9 insertions(+) diff --git a/targets/TARGET_NUVOTON/TARGET_M451/rtc_api.c b/targets/TARGET_NUVOTON/TARGET_M451/rtc_api.c index 292adcf8938..fd3fa1b1a04 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/rtc_api.c +++ b/targets/TARGET_NUVOTON/TARGET_M451/rtc_api.c @@ -87,6 +87,9 @@ time_t rtc_read(void) timeinfo.tm_mday = rtc_datetime.u32Day; timeinfo.tm_wday = rtc_datetime.u32DayOfWeek; timeinfo.tm_hour = rtc_datetime.u32Hour; + if (rtc_datetime.u32TimeScale == RTC_CLOCK_12 && rtc_datetime.u32AmPm == RTC_PM) { + timeinfo.tm_hour += 12; + } timeinfo.tm_min = rtc_datetime.u32Minute; timeinfo.tm_sec = rtc_datetime.u32Second; diff --git a/targets/TARGET_NUVOTON/TARGET_M480/rtc_api.c b/targets/TARGET_NUVOTON/TARGET_M480/rtc_api.c index 186fffd6845..7535c3a72fa 100644 --- a/targets/TARGET_NUVOTON/TARGET_M480/rtc_api.c +++ b/targets/TARGET_NUVOTON/TARGET_M480/rtc_api.c @@ -89,6 +89,9 @@ time_t rtc_read(void) timeinfo.tm_mday = rtc_datetime.u32Day; timeinfo.tm_wday = rtc_datetime.u32DayOfWeek; timeinfo.tm_hour = rtc_datetime.u32Hour; + if (rtc_datetime.u32TimeScale == RTC_CLOCK_12 && rtc_datetime.u32AmPm == RTC_PM) { + timeinfo.tm_hour += 12; + } timeinfo.tm_min = rtc_datetime.u32Minute; timeinfo.tm_sec = rtc_datetime.u32Second; diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/rtc_api.c b/targets/TARGET_NUVOTON/TARGET_NUC472/rtc_api.c index cf7dfbf2d2a..41ec6042d9d 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/rtc_api.c +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/rtc_api.c @@ -87,6 +87,9 @@ time_t rtc_read(void) timeinfo.tm_mday = rtc_datetime.u32Day; timeinfo.tm_wday = rtc_datetime.u32DayOfWeek; timeinfo.tm_hour = rtc_datetime.u32Hour; + if (rtc_datetime.u32TimeScale == RTC_CLOCK_12 && rtc_datetime.u32AmPm == RTC_PM) { + timeinfo.tm_hour += 12; + } timeinfo.tm_min = rtc_datetime.u32Minute; timeinfo.tm_sec = rtc_datetime.u32Second; From 901fcba462435184b856cd8fc01e81372ec6c888 Mon Sep 17 00:00:00 2001 From: ccli8 Date: Wed, 13 Sep 2017 11:50:11 +0800 Subject: [PATCH 030/108] Move target configuration from mbed_lib.json to targets.json --- .../TARGET_NANO100/gpio_irq_api.c | 24 +++++++++---------- .../TARGET_NANO100/mbed_lib.json | 22 ----------------- targets/targets.json | 18 ++++++++++++++ 3 files changed, 30 insertions(+), 34 deletions(-) delete mode 100644 targets/TARGET_NUVOTON/TARGET_NANO100/mbed_lib.json diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/gpio_irq_api.c b/targets/TARGET_NUVOTON/TARGET_NANO100/gpio_irq_api.c index 07d92ddd307..fb26ccc24fe 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/gpio_irq_api.c +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/gpio_irq_api.c @@ -49,23 +49,23 @@ static struct nu_gpio_irq_var gpio_irq_var_arr[] = { #define NU_MAX_PORT (sizeof (gpio_irq_var_arr) / sizeof (gpio_irq_var_arr[0])) -#ifndef MBED_CONF_NANO100_GPIO_IRQ_DEBOUNCE_ENABLE -#define MBED_CONF_NANO100_GPIO_IRQ_DEBOUNCE_ENABLE 0 +#ifndef MBED_CONF_TARGET_GPIO_IRQ_DEBOUNCE_ENABLE +#define MBED_CONF_TARGET_GPIO_IRQ_DEBOUNCE_ENABLE 0 #endif -#ifndef MBED_CONF_NANO100_GPIO_IRQ_DEBOUNCE_ENABLE_LIST -#define MBED_CONF_NANO100_GPIO_IRQ_DEBOUNCE_ENABLE_LIST NC +#ifndef MBED_CONF_TARGET_GPIO_IRQ_DEBOUNCE_ENABLE_LIST +#define MBED_CONF_TARGET_GPIO_IRQ_DEBOUNCE_ENABLE_LIST NC #endif static PinName gpio_irq_debounce_arr[] = { - MBED_CONF_NANO100_GPIO_IRQ_DEBOUNCE_ENABLE_LIST + MBED_CONF_TARGET_GPIO_IRQ_DEBOUNCE_ENABLE_LIST }; -#ifndef MBED_CONF_NANO100_GPIO_IRQ_DEBOUNCE_CLOCK_SOURCE -#define MBED_CONF_NANO100_GPIO_IRQ_DEBOUNCE_CLOCK_SOURCE GPIO_DBCLKSRC_IRC10K +#ifndef MBED_CONF_TARGET_GPIO_IRQ_DEBOUNCE_CLOCK_SOURCE +#define MBED_CONF_TARGET_GPIO_IRQ_DEBOUNCE_CLOCK_SOURCE GPIO_DBCLKSRC_IRC10K #endif -#ifndef MBED_CONF_NANO100_GPIO_IRQ_DEBOUNCE_SAMPLE_RATE -#define MBED_CONF_NANO100_GPIO_IRQ_DEBOUNCE_SAMPLE_RATE GPIO_DBCLKSEL_16 +#ifndef MBED_CONF_TARGET_GPIO_IRQ_DEBOUNCE_SAMPLE_RATE +#define MBED_CONF_TARGET_GPIO_IRQ_DEBOUNCE_SAMPLE_RATE GPIO_DBCLKSEL_16 #endif int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32_t id) @@ -90,12 +90,12 @@ int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32 // There is no need to call gpio_set() redundantly. { -#if MBED_CONF_NANO100_GPIO_IRQ_DEBOUNCE_ENABLE +#if MBED_CONF_TARGET_GPIO_IRQ_DEBOUNCE_ENABLE // Suppress compiler warning (void) gpio_irq_debounce_arr; // Configure de-bounce clock source and sampling cycle time - GPIO_SET_DEBOUNCE_TIME(MBED_CONF_NANO100_GPIO_IRQ_DEBOUNCE_CLOCK_SOURCE, MBED_CONF_NANO100_GPIO_IRQ_DEBOUNCE_SAMPLE_RATE); + GPIO_SET_DEBOUNCE_TIME(MBED_CONF_TARGET_GPIO_IRQ_DEBOUNCE_CLOCK_SOURCE, MBED_CONF_TARGET_GPIO_IRQ_DEBOUNCE_SAMPLE_RATE); GPIO_ENABLE_DEBOUNCE(gpio_base, 1 << pin_index); #else // Enable de-bounce if the pin is in the de-bounce enable list @@ -112,7 +112,7 @@ int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32 if (pin_index == pin_index_debunce && port_index == port_index_debounce) { // Configure de-bounce clock source and sampling cycle time - GPIO_SET_DEBOUNCE_TIME(MBED_CONF_NANO100_GPIO_IRQ_DEBOUNCE_CLOCK_SOURCE, MBED_CONF_NANO100_GPIO_IRQ_DEBOUNCE_SAMPLE_RATE); + GPIO_SET_DEBOUNCE_TIME(MBED_CONF_TARGET_GPIO_IRQ_DEBOUNCE_CLOCK_SOURCE, MBED_CONF_TARGET_GPIO_IRQ_DEBOUNCE_SAMPLE_RATE); GPIO_ENABLE_DEBOUNCE(gpio_base, 1 << pin_index); break; } diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/mbed_lib.json b/targets/TARGET_NUVOTON/TARGET_NANO100/mbed_lib.json deleted file mode 100644 index 1494a976ff2..00000000000 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/mbed_lib.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "NANO100", - "config": { - "gpio-irq-debounce-enable": { - "help": "Enable GPIO IRQ debounce", - "value": 0 - }, - "gpio-irq-debounce-enable-list": { - "help": "Comma separated pin list to enable GPIO IRQ debounce", - "value": "NC" - }, - "gpio-irq-debounce-clock-source": { - "help": "Select GPIO IRQ debounce clock source: GPIO_DBCLKSRC_HCLK or GPIO_DBCLKSRC_IRC10K", - "value": "GPIO_DBCLKSRC_IRC10K" - }, - - "gpio-irq-debounce-sample-rate": { - "help": "Select GPIO IRQ debounce sample rate: GPIO_DBCLKSEL_1, GPIO_DBCLKSEL_2, GPIO_DBCLKSEL_4, ..., or GPIO_DBCLKSEL_32768", - "value": "GPIO_DBCLKSEL_16" - } - } -} diff --git a/targets/targets.json b/targets/targets.json index 9bb25c26be8..9c4fb629747 100644 --- a/targets/targets.json +++ b/targets/targets.json @@ -3247,6 +3247,24 @@ "extra_labels": ["NUVOTON", "NANO100", "NANO130KE3BN"], "is_disk_virtual": true, "supported_toolchains": ["ARM", "uARM", "GCC_ARM", "IAR"], + "config": { + "gpio-irq-debounce-enable": { + "help": "Enable GPIO IRQ debounce", + "value": 0 + }, + "gpio-irq-debounce-enable-list": { + "help": "Comma separated pin list to enable GPIO IRQ debounce", + "value": "NC" + }, + "gpio-irq-debounce-clock-source": { + "help": "Select GPIO IRQ debounce clock source: GPIO_DBCLKSRC_HCLK or GPIO_DBCLKSRC_IRC10K", + "value": "GPIO_DBCLKSRC_IRC10K" + }, + "gpio-irq-debounce-sample-rate": { + "help": "Select GPIO IRQ debounce sample rate: GPIO_DBCLKSEL_1, GPIO_DBCLKSEL_2, GPIO_DBCLKSEL_4, ..., or GPIO_DBCLKSEL_32768", + "value": "GPIO_DBCLKSEL_16" + } + }, "inherits": ["Target"], "macros": ["CMSIS_VECTAB_VIRTUAL", "CMSIS_VECTAB_VIRTUAL_HEADER_FILE=\"cmsis_nvic.h\""], "device_has": ["ANALOGIN", "I2C", "I2CSLAVE", "I2C_ASYNCH", "INTERRUPTIN", "LOWPOWERTIMER", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SERIAL_ASYNCH", "SERIAL_FC", "STDIO_MESSAGES", "SLEEP", "SPI", "SPISLAVE", "SPI_ASYNCH"], From f86f651226bb8f7e0b20f2359fd91bb193c3a98f Mon Sep 17 00:00:00 2001 From: ccli8 Date: Wed, 13 Sep 2017 14:51:18 +0800 Subject: [PATCH 031/108] Change SW2/SW3 to SW1/SW2 to match target board --- .../TARGET_NANO100/TARGET_NUMAKER_PFM_NANO130/PinNames.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/TARGET_NUMAKER_PFM_NANO130/PinNames.h b/targets/TARGET_NUVOTON/TARGET_NANO100/TARGET_NUMAKER_PFM_NANO130/PinNames.h index acd1297e01d..57661d2639e 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/TARGET_NUMAKER_PFM_NANO130/PinNames.h +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/TARGET_NUMAKER_PFM_NANO130/PinNames.h @@ -118,8 +118,8 @@ typedef enum { LED_GREEN = LED1, LED_YELLOW = LED2, // Button naming - SW2 = PE_5, - SW3 = PE_6, + SW1 = PE_5, + SW2 = PE_6, } PinName; From dfe78597a88204a5b9217b7bfe99d500bb61896d Mon Sep 17 00:00:00 2001 From: ccli8 Date: Fri, 15 Sep 2017 10:54:23 +0800 Subject: [PATCH 032/108] Fix lp_ticker typo --- targets/TARGET_NUVOTON/TARGET_NANO100/lp_ticker.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/lp_ticker.c b/targets/TARGET_NUVOTON/TARGET_NANO100/lp_ticker.c index 87b67b5ba87..5a17d20bcee 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/lp_ticker.c +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/lp_ticker.c @@ -141,7 +141,7 @@ timestamp_t lp_ticker_read() while (minor_clks == 0 || minor_clks == TMR2_CLK_PER_TMR2_INT); // Add power-down compensation - return ((uint64_t) major_minor_clks * US_PER_SEC / TMR3_CLK_PER_SEC / US_PER_TICK); + return ((uint64_t) major_minor_clks * US_PER_SEC / TMR2_CLK_PER_SEC / US_PER_TICK); } while (0); } From 148e1e28834d82b6dee0ae99985179aab4d1b65f Mon Sep 17 00:00:00 2001 From: ccli8 Date: Mon, 18 Sep 2017 15:05:44 +0800 Subject: [PATCH 033/108] Fix lp_ticker wake-up is incorrectly disabled --- targets/TARGET_NUVOTON/TARGET_NANO100/lp_ticker.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/lp_ticker.c b/targets/TARGET_NUVOTON/TARGET_NANO100/lp_ticker.c index 5a17d20bcee..7a9bf129b00 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/lp_ticker.c +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/lp_ticker.c @@ -222,6 +222,6 @@ static void lp_ticker_arm_cd(void) TIMER_EnableWakeup((TIMER_T *) NU_MODBASE(timer3_modinit.modname)); // Wait 2 cycles of engine clock to ensure previous CTL write action is finish wait_us(30 * 2); - timer3_base->CTL = ctl_timer3 | TIMER_CTL_TMR_EN_Msk; + timer3_base->CTL |= ctl_timer3 | TIMER_CTL_TMR_EN_Msk; } #endif From 37bf8e3c7d82b41141f601d73a630c717e380dbe Mon Sep 17 00:00:00 2001 From: ccli8 Date: Thu, 21 Sep 2017 16:42:00 +0800 Subject: [PATCH 034/108] Fix RTC hour error with AM/PM --- targets/TARGET_NUVOTON/TARGET_NANO100/rtc_api.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/rtc_api.c b/targets/TARGET_NUVOTON/TARGET_NANO100/rtc_api.c index c6836291377..a4a6bc0675a 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/rtc_api.c +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/rtc_api.c @@ -87,6 +87,9 @@ time_t rtc_read(void) timeinfo.tm_mday = rtc_datetime.u32Day; timeinfo.tm_wday = rtc_datetime.u32DayOfWeek; timeinfo.tm_hour = rtc_datetime.u32Hour; + if (rtc_datetime.u32TimeScale == RTC_CLOCK_12 && rtc_datetime.u32AmPm == RTC_PM) { + timeinfo.tm_hour += 12; + } timeinfo.tm_min = rtc_datetime.u32Minute; timeinfo.tm_sec = rtc_datetime.u32Second; From c32006ff3928d650563ab879327b002cd3dd9b58 Mon Sep 17 00:00:00 2001 From: ccli8 Date: Fri, 22 Sep 2017 09:33:53 +0800 Subject: [PATCH 035/108] Refine sleep code 1. Remove stale code with mbed OS 3. 2. Remove check for busy peripherals unorganizedly. This would be supported by e.g. official sleep manager. --- targets/TARGET_NUVOTON/TARGET_NANO100/sleep.c | 68 +++---------------- 1 file changed, 8 insertions(+), 60 deletions(-) diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/sleep.c b/targets/TARGET_NUVOTON/TARGET_NANO100/sleep.c index ec5126ec20d..dd32dd41718 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/sleep.c +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/sleep.c @@ -15,8 +15,6 @@ */ #include "sleep_api.h" -#include "serial_api.h" -#include "lp_ticker_api.h" #if DEVICE_SLEEP @@ -25,74 +23,24 @@ #include "objects.h" #include "PeripheralPins.h" -static void mbed_enter_sleep(struct sleep_s *obj); -static void mbed_exit_sleep(struct sleep_s *obj); - -int serial_allow_powerdown(void); -int spi_allow_powerdown(void); -int i2c_allow_powerdown(void); -int pwmout_allow_powerdown(void); - /** - * Enter Idle mode. + * Enter idle mode, in which just CPU is halted. */ void hal_sleep(void) { - struct sleep_s sleep_obj; - sleep_obj.powerdown = 0; - mbed_enter_sleep(&sleep_obj); - mbed_exit_sleep(&sleep_obj); + SYS_UnlockReg(); + CLK_Idle(); + SYS_LockReg(); } /** - * Enter Power-down mode while no peripheral is active; otherwise, enter Idle mode. + * Enter power-down mode, in which HXT/HIRC are halted. */ void hal_deepsleep(void) { - struct sleep_s sleep_obj; - sleep_obj.powerdown = 1; - mbed_enter_sleep(&sleep_obj); - mbed_exit_sleep(&sleep_obj); -} - -static void mbed_enter_sleep(struct sleep_s *obj) -{ - // Check if serial allows entering power-down mode - if (obj->powerdown) { - obj->powerdown = serial_allow_powerdown(); - } - // Check if spi allows entering power-down mode - if (obj->powerdown) { - obj->powerdown = spi_allow_powerdown(); - } - // Check if i2c allows entering power-down mode - if (obj->powerdown) { - obj->powerdown = i2c_allow_powerdown(); - } - // Check if pwmout allows entering power-down mode - if (obj->powerdown) { - obj->powerdown = pwmout_allow_powerdown(); - } - // TODO: Check if other peripherals allow entering power-down mode - - if (obj->powerdown) { // Power-down mode (HIRC/HXT disabled, LIRC/LXT enabled) - SYS_UnlockReg(); - CLK_PowerDown(); - SYS_LockReg(); - } else { // CPU halt mode (HIRC/HXT enabled, LIRC/LXT enabled) - SYS_UnlockReg(); - CLK_Idle(); - SYS_LockReg(); - } - __NOP(); - __NOP(); - __NOP(); - __NOP(); -} - -static void mbed_exit_sleep(struct sleep_s *obj) -{ - (void)obj; + SYS_UnlockReg(); + CLK_PowerDown(); + SYS_LockReg(); } #endif From 0bd4d5e72ceb0cb26b560526f8d3b36a705cfd0b Mon Sep 17 00:00:00 2001 From: ccli8 Date: Fri, 22 Sep 2017 09:42:51 +0800 Subject: [PATCH 036/108] Remove dead power-down code with mbed OS 3 These power-down code are stale and would be superseded by sleep manager. --- .../TARGET_NUMAKER_PFM_M453/objects.h | 4 --- targets/TARGET_NUVOTON/TARGET_M451/i2c_api.c | 19 ------------- .../TARGET_NUVOTON/TARGET_M451/pwmout_api.c | 20 -------------- .../TARGET_NUVOTON/TARGET_M451/serial_api.c | 27 ------------------- targets/TARGET_NUVOTON/TARGET_M451/spi_api.c | 19 ------------- .../TARGET_NUMAKER_PFM_M487/objects.h | 4 --- targets/TARGET_NUVOTON/TARGET_M480/i2c_api.c | 19 ------------- .../TARGET_NUVOTON/TARGET_M480/pwmout_api.c | 20 -------------- .../TARGET_NUVOTON/TARGET_M480/serial_api.c | 27 ------------------- targets/TARGET_NUVOTON/TARGET_M480/spi_api.c | 19 ------------- .../TARGET_NUMAKER_PFM_NANO130/objects.h | 3 --- .../TARGET_NUVOTON/TARGET_NANO100/i2c_api.c | 19 ------------- .../TARGET_NANO100/pwmout_api.c | 20 -------------- .../TARGET_NANO100/serial_api.c | 27 ------------------- .../TARGET_NUVOTON/TARGET_NANO100/spi_api.c | 18 ------------- .../TARGET_NUMAKER_PFM_NUC472/objects.h | 4 --- .../TARGET_NUVOTON/TARGET_NUC472/i2c_api.c | 19 ------------- .../TARGET_NUVOTON/TARGET_NUC472/pwmout_api.c | 20 -------------- .../TARGET_NUVOTON/TARGET_NUC472/serial_api.c | 27 ------------------- .../TARGET_NUVOTON/TARGET_NUC472/spi_api.c | 19 ------------- 20 files changed, 354 deletions(-) diff --git a/targets/TARGET_NUVOTON/TARGET_M451/TARGET_NUMAKER_PFM_M453/objects.h b/targets/TARGET_NUVOTON/TARGET_M451/TARGET_NUMAKER_PFM_M453/objects.h index 6744a32ce9a..9c633835d98 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/TARGET_NUMAKER_PFM_M453/objects.h +++ b/targets/TARGET_NUVOTON/TARGET_M451/TARGET_NUMAKER_PFM_M453/objects.h @@ -117,10 +117,6 @@ struct pwmout_s { uint32_t pulsewidth_us; }; -struct sleep_s { - int powerdown; -}; - struct can_s { CANName can; char index; diff --git a/targets/TARGET_NUVOTON/TARGET_M451/i2c_api.c b/targets/TARGET_NUVOTON/TARGET_M451/i2c_api.c index 8b05fe86275..7f918418cd8 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/i2c_api.c +++ b/targets/TARGET_NUVOTON/TARGET_M451/i2c_api.c @@ -339,25 +339,6 @@ static int i2c_set_int(i2c_t *obj, int inten) return inten_back; } -int i2c_allow_powerdown(void) -{ - uint32_t modinit_mask = i2c_modinit_mask; - while (modinit_mask) { - int i2c_idx = nu_ctz(modinit_mask); - const struct nu_modinit_s *modinit = i2c_modinit_tab + i2c_idx; - struct nu_i2c_var *var = (struct nu_i2c_var *) modinit->var; - if (var->obj) { - // Disallow entering power-down mode if I2C transfer is enabled. - if (i2c_active(var->obj)) { - return 0; - } - } - modinit_mask &= ~(1 << i2c_idx); - } - - return 1; -} - static int i2c_do_tran(i2c_t *obj, char *buf, int length, int read, int naklastdata) { if (! buf || ! length) { diff --git a/targets/TARGET_NUVOTON/TARGET_M451/pwmout_api.c b/targets/TARGET_NUVOTON/TARGET_M451/pwmout_api.c index f89dc4f6a00..d95197c3e4e 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/pwmout_api.c +++ b/targets/TARGET_NUVOTON/TARGET_M451/pwmout_api.c @@ -172,26 +172,6 @@ void pwmout_pulsewidth_us(pwmout_t* obj, int us) pwmout_config(obj); } -int pwmout_allow_powerdown(void) -{ - uint32_t modinit_mask = pwm_modinit_mask; - while (modinit_mask) { - int pwm_idx = nu_ctz(modinit_mask); - const struct nu_modinit_s *modinit = pwm_modinit_tab + pwm_idx; - if (modinit->modname != NC) { - PWM_T *pwm_base = (PWM_T *) NU_MODBASE(modinit->modname); - uint32_t chn = NU_MODSUBINDEX(modinit->modname); - // Disallow entering power-down mode if PWM counter is enabled. - if ((pwm_base->CNTEN & (1 << chn)) && pwm_base->CMPDAT[chn]) { - return 0; - } - } - modinit_mask &= ~(1 << pwm_idx); - } - - return 1; -} - static void pwmout_config(pwmout_t* obj) { PWM_T *pwm_base = (PWM_T *) NU_MODBASE(obj->pwm); diff --git a/targets/TARGET_NUVOTON/TARGET_M451/serial_api.c b/targets/TARGET_NUVOTON/TARGET_M451/serial_api.c index b0965477c70..382ea3e7e78 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/serial_api.c +++ b/targets/TARGET_NUVOTON/TARGET_M451/serial_api.c @@ -656,33 +656,6 @@ int serial_irq_handler_asynch(serial_t *obj) return (obj->serial.event & (event_rx | event_tx)); } -int serial_allow_powerdown(void) -{ - uint32_t modinit_mask = uart_modinit_mask; - while (modinit_mask) { - int uart_idx = nu_ctz(modinit_mask); - const struct nu_modinit_s *modinit = uart_modinit_tab + uart_idx; - if (modinit->modname != NC) { - UART_T *uart_base = (UART_T *) NU_MODBASE(modinit->modname); - // Disallow entering power-down mode if Tx FIFO has data to flush - if (! UART_IS_TX_EMPTY((uart_base))) { - return 0; - } - // Disallow entering power-down mode if async Rx transfer (not PDMA) is on-going - if (uart_base->INTEN & (UART_INTEN_RDAIEN_Msk | UART_INTEN_RXTOIEN_Msk)) { - return 0; - } - // Disallow entering power-down mode if async Rx transfer (PDMA) is on-going - if (uart_base->INTEN & UART_INTEN_RXPDMAEN_Msk) { - return 0; - } - } - modinit_mask &= ~(1 << uart_idx); - } - - return 1; -} - static void uart0_vec_async(void) { uart_irq_async(uart0_var.obj); diff --git a/targets/TARGET_NUVOTON/TARGET_M451/spi_api.c b/targets/TARGET_NUVOTON/TARGET_M451/spi_api.c index 5616bd60cc6..5d035ccf994 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/spi_api.c +++ b/targets/TARGET_NUVOTON/TARGET_M451/spi_api.c @@ -470,25 +470,6 @@ uint8_t spi_active(spi_t *obj) return (spi_base->CTL & SPI_CTL_SPIEN_Msk); } -int spi_allow_powerdown(void) -{ - uint32_t modinit_mask = spi_modinit_mask; - while (modinit_mask) { - int spi_idx = nu_ctz(modinit_mask); - const struct nu_modinit_s *modinit = spi_modinit_tab + spi_idx; - if (modinit->modname != NC) { - SPI_T *spi_base = (SPI_T *) NU_MODBASE(modinit->modname); - // Disallow entering power-down mode if SPI transfer is enabled. - if (spi_base->CTL & SPI_CTL_SPIEN_Msk) { - return 0; - } - } - modinit_mask &= ~(1 << spi_idx); - } - - return 1; -} - static int spi_writeable(spi_t * obj) { // Receive FIFO must not be full to avoid receive FIFO overflow on next transmit/receive diff --git a/targets/TARGET_NUVOTON/TARGET_M480/TARGET_NUMAKER_PFM_M487/objects.h b/targets/TARGET_NUVOTON/TARGET_M480/TARGET_NUMAKER_PFM_M487/objects.h index fef01cfdafd..e3d24534d81 100644 --- a/targets/TARGET_NUVOTON/TARGET_M480/TARGET_NUMAKER_PFM_M487/objects.h +++ b/targets/TARGET_NUVOTON/TARGET_M480/TARGET_NUMAKER_PFM_M487/objects.h @@ -118,10 +118,6 @@ struct pwmout_s { uint32_t pulsewidth_us; }; -struct sleep_s { - int powerdown; -}; - struct trng_s { uint8_t dummy; }; diff --git a/targets/TARGET_NUVOTON/TARGET_M480/i2c_api.c b/targets/TARGET_NUVOTON/TARGET_M480/i2c_api.c index 2313d4f9283..bf8e92a87c0 100644 --- a/targets/TARGET_NUVOTON/TARGET_M480/i2c_api.c +++ b/targets/TARGET_NUVOTON/TARGET_M480/i2c_api.c @@ -330,25 +330,6 @@ static int i2c_set_int(i2c_t *obj, int inten) return inten_back; } -int i2c_allow_powerdown(void) -{ - uint32_t modinit_mask = i2c_modinit_mask; - while (modinit_mask) { - int i2c_idx = nu_ctz(modinit_mask); - const struct nu_modinit_s *modinit = i2c_modinit_tab + i2c_idx; - struct nu_i2c_var *var = (struct nu_i2c_var *) modinit->var; - if (var->obj) { - // Disallow entering power-down mode if I2C transfer is enabled. - if (i2c_active(var->obj)) { - return 0; - } - } - modinit_mask &= ~(1 << i2c_idx); - } - - return 1; -} - static int i2c_do_tran(i2c_t *obj, char *buf, int length, int read, int naklastdata) { if (! buf || ! length) { diff --git a/targets/TARGET_NUVOTON/TARGET_M480/pwmout_api.c b/targets/TARGET_NUVOTON/TARGET_M480/pwmout_api.c index 93bfe68116c..12d49872563 100644 --- a/targets/TARGET_NUVOTON/TARGET_M480/pwmout_api.c +++ b/targets/TARGET_NUVOTON/TARGET_M480/pwmout_api.c @@ -167,26 +167,6 @@ void pwmout_pulsewidth_us(pwmout_t* obj, int us) pwmout_config(obj, 1); } -int pwmout_allow_powerdown(void) -{ - uint32_t modinit_mask = pwm_modinit_mask; - while (modinit_mask) { - int pwm_idx = nu_ctz(modinit_mask); - const struct nu_modinit_s *modinit = pwm_modinit_tab + pwm_idx; - if (modinit->modname != NC) { - EPWM_T *pwm_base = (EPWM_T *) NU_MODBASE(modinit->modname); - uint32_t chn = NU_MODSUBINDEX(modinit->modname); - // Disallow entering power-down mode if PWM counter is enabled. - if ((pwm_base->CNTEN & (1 << chn)) && pwm_base->CMPDAT[chn]) { - return 0; - } - } - modinit_mask &= ~(1 << pwm_idx); - } - - return 1; -} - static void pwmout_config(pwmout_t* obj, int start) { EPWM_T *pwm_base = (EPWM_T *) NU_MODBASE(obj->pwm); diff --git a/targets/TARGET_NUVOTON/TARGET_M480/serial_api.c b/targets/TARGET_NUVOTON/TARGET_M480/serial_api.c index e45867c118c..25695156a39 100644 --- a/targets/TARGET_NUVOTON/TARGET_M480/serial_api.c +++ b/targets/TARGET_NUVOTON/TARGET_M480/serial_api.c @@ -710,33 +710,6 @@ int serial_irq_handler_asynch(serial_t *obj) return (obj->serial.event & (event_rx | event_tx)); } -int serial_allow_powerdown(void) -{ - uint32_t modinit_mask = uart_modinit_mask; - while (modinit_mask) { - int uart_idx = nu_ctz(modinit_mask); - const struct nu_modinit_s *modinit = uart_modinit_tab + uart_idx; - if (modinit->modname != NC) { - UART_T *uart_base = (UART_T *) NU_MODBASE(modinit->modname); - // Disallow entering power-down mode if Tx FIFO has data to flush - if (! UART_IS_TX_EMPTY((uart_base))) { - return 0; - } - // Disallow entering power-down mode if async Rx transfer (not PDMA) is on-going - if (uart_base->INTEN & (UART_INTEN_RDAIEN_Msk | UART_INTEN_RXTOIEN_Msk)) { - return 0; - } - // Disallow entering power-down mode if async Rx transfer (PDMA) is on-going - if (uart_base->INTEN & UART_INTEN_RXPDMAEN_Msk) { - return 0; - } - } - modinit_mask &= ~(1 << uart_idx); - } - - return 1; -} - static void uart0_vec_async(void) { uart_irq_async(uart0_var.obj); diff --git a/targets/TARGET_NUVOTON/TARGET_M480/spi_api.c b/targets/TARGET_NUVOTON/TARGET_M480/spi_api.c index 88ae09d6ff8..79e6818d28a 100644 --- a/targets/TARGET_NUVOTON/TARGET_M480/spi_api.c +++ b/targets/TARGET_NUVOTON/TARGET_M480/spi_api.c @@ -461,25 +461,6 @@ uint8_t spi_active(spi_t *obj) return (spi_base->CTL & SPI_CTL_SPIEN_Msk); } -int spi_allow_powerdown(void) -{ - uint32_t modinit_mask = spi_modinit_mask; - while (modinit_mask) { - int spi_idx = nu_ctz(modinit_mask); - const struct nu_modinit_s *modinit = spi_modinit_tab + spi_idx; - if (modinit->modname != NC) { - SPI_T *spi_base = (SPI_T *) NU_MODBASE(modinit->modname); - // Disallow entering power-down mode if SPI transfer is enabled. - if (spi_base->CTL & SPI_CTL_SPIEN_Msk) { - return 0; - } - } - modinit_mask &= ~(1 << spi_idx); - } - - return 1; -} - static int spi_writeable(spi_t * obj) { // Receive FIFO must not be full to avoid receive FIFO overflow on next transmit/receive diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/TARGET_NUMAKER_PFM_NANO130/objects.h b/targets/TARGET_NUVOTON/TARGET_NANO100/TARGET_NUMAKER_PFM_NANO130/objects.h index 8ec51b38e86..12476fd7c14 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/TARGET_NUMAKER_PFM_NANO130/objects.h +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/TARGET_NUMAKER_PFM_NANO130/objects.h @@ -110,9 +110,6 @@ struct pwmout_s { uint32_t pulsewidth_us; }; -struct sleep_s { - int powerdown; -}; #ifdef __cplusplus } #endif diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/i2c_api.c b/targets/TARGET_NUVOTON/TARGET_NANO100/i2c_api.c index 375602b461e..3e146ee8b17 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/i2c_api.c +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/i2c_api.c @@ -358,25 +358,6 @@ static int i2c_set_int(i2c_t *obj, int inten) return inten_back; } -int i2c_allow_powerdown(void) -{ - uint32_t modinit_mask = i2c_modinit_mask; - while (modinit_mask) { - int i2c_idx = nu_ctz(modinit_mask); - const struct nu_modinit_s *modinit = i2c_modinit_tab + i2c_idx; - struct nu_i2c_var *var = (struct nu_i2c_var *) modinit->var; - if (var->obj) { - // Disallow entering power-down mode if I2C transfer is enabled. - if (i2c_active(var->obj)) { - return 0; - } - } - modinit_mask &= ~(1 << i2c_idx); - } - - return 1; -} - static int i2c_do_tran(i2c_t *obj, char *buf, int length, int read, int naklastdata) { if (! buf || ! length) { diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/pwmout_api.c b/targets/TARGET_NUVOTON/TARGET_NANO100/pwmout_api.c index eb648492079..7eca1a1ab33 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/pwmout_api.c +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/pwmout_api.c @@ -176,26 +176,6 @@ void pwmout_pulsewidth_us(pwmout_t* obj, int us) pwmout_config(obj); } -int pwmout_allow_powerdown(void) -{ - uint32_t modinit_mask = pwm_modinit_mask; - while (modinit_mask) { - int pwm_idx = nu_ctz(modinit_mask); - const struct nu_modinit_s *modinit = pwm_modinit_tab + pwm_idx; - if (modinit->modname != NC) { - PWM_T *pwm_base = (PWM_T *) NU_MODBASE(modinit->modname); - uint32_t chn = NU_MODSUBINDEX(modinit->modname); - // Disallow entering power-down mode if PWM counter is enabled. - if (pwm_base->OE & (1 << chn)) { - return 0; - } - } - modinit_mask &= ~(1 << pwm_idx); - } - - return 1; -} - static void pwmout_config(pwmout_t* obj) { PWM_T *pwm_base = (PWM_T *) NU_MODBASE(obj->pwm); diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/serial_api.c b/targets/TARGET_NUVOTON/TARGET_NANO100/serial_api.c index 93f91467515..7810d009776 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/serial_api.c +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/serial_api.c @@ -597,33 +597,6 @@ int serial_irq_handler_asynch(serial_t *obj) return (obj->serial.event & (event_rx | event_tx)); } -int serial_allow_powerdown(void) -{ - uint32_t modinit_mask = uart_modinit_mask; - while (modinit_mask) { - int uart_idx = nu_ctz(modinit_mask); - const struct nu_modinit_s *modinit = uart_modinit_tab + uart_idx; - if (modinit->modname != NC) { - UART_T *uart_base = (UART_T *) NU_MODBASE(modinit->modname); - // Disallow entering power-down mode if Tx FIFO has data to flush - if (! UART_IS_TX_EMPTY((uart_base))) { - return 0; - } - // Disallow entering power-down mode if async Rx transfer (not PDMA) is on-going - if (uart_base->IER & (UART_IER_RDA_IE_Msk | UART_IER_RTO_IE_Msk)) { - return 0; - } - // Disallow entering power-down mode if async Rx transfer (PDMA) is on-going - if (uart_base->CTL & UART_CTL_DMA_RX_EN_Msk) { - return 0; - } - } - modinit_mask &= ~(1 << uart_idx); - } - - return 1; -} - static void uart_irq_async(serial_t *obj) { if (serial_is_irq_en(obj, RxIrq)) { diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/spi_api.c b/targets/TARGET_NUVOTON/TARGET_NANO100/spi_api.c index 86def36d767..0bc47ae67f3 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/spi_api.c +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/spi_api.c @@ -505,24 +505,6 @@ uint8_t spi_active(spi_t *obj) return SPI_IS_BUSY(spi_base); } -int spi_allow_powerdown(void) -{ - uint32_t modinit_mask = spi_modinit_mask; - while (modinit_mask) { - int spi_idx = nu_ctz(modinit_mask); - const struct nu_modinit_s *modinit = spi_modinit_tab + spi_idx; - if (modinit->modname != NC) { - SPI_T *spi_base = (SPI_T *) NU_MODBASE(modinit->modname); - if (SPI_IS_BUSY(spi_base)) { - return 0; - } - } - modinit_mask &= ~(1 << spi_idx); - } - - return 1; -} - void SPI0_IRQHandler(void) { spi_irq(spi0_var.obj); diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/TARGET_NUMAKER_PFM_NUC472/objects.h b/targets/TARGET_NUVOTON/TARGET_NUC472/TARGET_NUMAKER_PFM_NUC472/objects.h index 2e62f15efc7..da3db2d54b2 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/TARGET_NUMAKER_PFM_NUC472/objects.h +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/TARGET_NUMAKER_PFM_NUC472/objects.h @@ -118,10 +118,6 @@ struct pwmout_s { uint32_t pulsewidth_us; }; -struct sleep_s { - int powerdown; -}; - struct trng_s { uint8_t dummy; }; diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/i2c_api.c b/targets/TARGET_NUVOTON/TARGET_NUC472/i2c_api.c index 481f7d6bd05..450451d89f2 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/i2c_api.c +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/i2c_api.c @@ -356,25 +356,6 @@ static int i2c_set_int(i2c_t *obj, int inten) return inten_back; } -int i2c_allow_powerdown(void) -{ - uint32_t modinit_mask = i2c_modinit_mask; - while (modinit_mask) { - int i2c_idx = nu_ctz(modinit_mask); - const struct nu_modinit_s *modinit = i2c_modinit_tab + i2c_idx; - struct nu_i2c_var *var = (struct nu_i2c_var *) modinit->var; - if (var->obj) { - // Disallow entering power-down mode if I2C transfer is enabled. - if (i2c_active(var->obj)) { - return 0; - } - } - modinit_mask &= ~(1 << i2c_idx); - } - - return 1; -} - static int i2c_do_tran(i2c_t *obj, char *buf, int length, int read, int naklastdata) { if (! buf || ! length) { diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/pwmout_api.c b/targets/TARGET_NUVOTON/TARGET_NUC472/pwmout_api.c index 90165697c63..bd2409ff8ce 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/pwmout_api.c +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/pwmout_api.c @@ -195,26 +195,6 @@ void pwmout_pulsewidth_us(pwmout_t* obj, int us) pwmout_config(obj); } -int pwmout_allow_powerdown(void) -{ - uint32_t modinit_mask = pwm_modinit_mask; - while (modinit_mask) { - int pwm_idx = nu_ctz(modinit_mask); - const struct nu_modinit_s *modinit = pwm_modinit_tab + pwm_idx; - if (modinit->modname != NC) { - PWM_T *pwm_base = (PWM_T *) NU_MODBASE(modinit->modname); - uint32_t chn = NU_MODSUBINDEX(modinit->modname); - // Disallow entering power-down mode if PWM counter is enabled. - if ((pwm_base->CNTEN & (1 << chn)) && pwm_base->CMPDAT[chn]) { - return 0; - } - } - modinit_mask &= ~(1 << pwm_idx); - } - - return 1; -} - static void pwmout_config(pwmout_t* obj) { PWM_T *pwm_base = (PWM_T *) NU_MODBASE(obj->pwm); diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/serial_api.c b/targets/TARGET_NUVOTON/TARGET_NUC472/serial_api.c index b3dd9737aaa..be8e304c4e9 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/serial_api.c +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/serial_api.c @@ -694,33 +694,6 @@ int serial_irq_handler_asynch(serial_t *obj) return (obj->serial.event & (event_rx | event_tx)); } -int serial_allow_powerdown(void) -{ - uint32_t modinit_mask = uart_modinit_mask; - while (modinit_mask) { - int uart_idx = nu_ctz(modinit_mask); - const struct nu_modinit_s *modinit = uart_modinit_tab + uart_idx; - if (modinit->modname != NC) { - UART_T *uart_base = (UART_T *) NU_MODBASE(modinit->modname); - // Disallow entering power-down mode if Tx FIFO has data to flush - if (! UART_IS_TX_EMPTY((uart_base))) { - return 0; - } - // Disallow entering power-down mode if async Rx transfer (not PDMA) is on-going - if (uart_base->INTEN & (UART_INTEN_RDAIEN_Msk | UART_INTEN_RXTOIEN_Msk)) { - return 0; - } - // Disallow entering power-down mode if async Rx transfer (PDMA) is on-going - if (uart_base->INTEN & UART_INTEN_RXPDMAEN_Msk) { - return 0; - } - } - modinit_mask &= ~(1 << uart_idx); - } - - return 1; -} - static void uart0_vec_async(void) { uart_irq_async(uart0_var.obj); diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/spi_api.c b/targets/TARGET_NUVOTON/TARGET_NUC472/spi_api.c index 6b12a925f29..1ab0704fc26 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/spi_api.c +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/spi_api.c @@ -469,25 +469,6 @@ uint8_t spi_active(spi_t *obj) return (spi_base->CTL & SPI_CTL_SPIEN_Msk); } -int spi_allow_powerdown(void) -{ - uint32_t modinit_mask = spi_modinit_mask; - while (modinit_mask) { - int spi_idx = nu_ctz(modinit_mask); - const struct nu_modinit_s *modinit = spi_modinit_tab + spi_idx; - if (modinit->modname != NC) { - SPI_T *spi_base = (SPI_T *) NU_MODBASE(modinit->modname); - // Disallow entering power-down mode if SPI transfer is enabled. - if (spi_base->CTL & SPI_CTL_SPIEN_Msk) { - return 0; - } - } - modinit_mask &= ~(1 << spi_idx); - } - - return 1; -} - static int spi_writeable(spi_t * obj) { // Receive FIFO must not be full to avoid receive FIFO overflow on next transmit/receive From 05439e0a2e2a78f135f55d4bdee65d8ffc103eda Mon Sep 17 00:00:00 2001 From: Seppo Takalo Date: Tue, 19 Sep 2017 20:16:36 +0300 Subject: [PATCH 037/108] Implement functional Wifi tests Implement 100% function coverage for WifiInterface as specified in "Wifi test plan" --- TESTS/network/wifi/get_interface.cpp | 21 ++ TESTS/network/wifi/main.cpp | 211 +++--------------- TESTS/network/wifi/wifi-constructor.cpp | 12 + TESTS/network/wifi/wifi_connect.cpp | 16 ++ .../wifi/wifi_connect_disconnect_repeat.cpp | 23 ++ .../wifi/wifi_connect_nocredentials.cpp | 16 ++ .../wifi/wifi_connect_params_channel.cpp | 21 ++ .../wifi/wifi_connect_params_channel_fail.cpp | 21 ++ .../network/wifi/wifi_connect_params_null.cpp | 13 ++ .../wifi/wifi_connect_params_valid_secure.cpp | 13 ++ .../wifi_connect_params_valid_unsecure.cpp | 14 ++ TESTS/network/wifi/wifi_connect_secure.cpp | 17 ++ .../network/wifi/wifi_connect_secure_fail.cpp | 17 ++ TESTS/network/wifi/wifi_get_rssi.cpp | 21 ++ TESTS/network/wifi/wifi_scan.cpp | 50 +++++ TESTS/network/wifi/wifi_scan_null.cpp | 14 ++ TESTS/network/wifi/wifi_set_channel.cpp | 56 +++++ TESTS/network/wifi/wifi_set_credential.cpp | 37 +++ TESTS/network/wifi/wifi_tests.h | 26 +++ 19 files changed, 435 insertions(+), 184 deletions(-) create mode 100644 TESTS/network/wifi/get_interface.cpp create mode 100644 TESTS/network/wifi/wifi-constructor.cpp create mode 100644 TESTS/network/wifi/wifi_connect.cpp create mode 100644 TESTS/network/wifi/wifi_connect_disconnect_repeat.cpp create mode 100644 TESTS/network/wifi/wifi_connect_nocredentials.cpp create mode 100644 TESTS/network/wifi/wifi_connect_params_channel.cpp create mode 100644 TESTS/network/wifi/wifi_connect_params_channel_fail.cpp create mode 100644 TESTS/network/wifi/wifi_connect_params_null.cpp create mode 100644 TESTS/network/wifi/wifi_connect_params_valid_secure.cpp create mode 100644 TESTS/network/wifi/wifi_connect_params_valid_unsecure.cpp create mode 100644 TESTS/network/wifi/wifi_connect_secure.cpp create mode 100644 TESTS/network/wifi/wifi_connect_secure_fail.cpp create mode 100644 TESTS/network/wifi/wifi_get_rssi.cpp create mode 100644 TESTS/network/wifi/wifi_scan.cpp create mode 100644 TESTS/network/wifi/wifi_scan_null.cpp create mode 100644 TESTS/network/wifi/wifi_set_channel.cpp create mode 100644 TESTS/network/wifi/wifi_set_credential.cpp create mode 100644 TESTS/network/wifi/wifi_tests.h diff --git a/TESTS/network/wifi/get_interface.cpp b/TESTS/network/wifi/get_interface.cpp new file mode 100644 index 00000000000..54e2bb2a963 --- /dev/null +++ b/TESTS/network/wifi/get_interface.cpp @@ -0,0 +1,21 @@ +#include "mbed.h" +#include "ESP8266Interface.h" + +WiFiInterface *get_interface() +{ + static WiFiInterface *interface = NULL; + + if (interface) + delete interface; + +#if TARGET_UBLOX_EVK_ODIN_W2 +#include "OdinWiFiInterface.h" + interface = new OdinWiFiInterface(); +#elif TARGET_REALTEK_RTL8195AM +#include "RTWInterface.h" + interface = new RTWInterface(); +#else + interface = new ESP8266Interface(D1, D0); +#endif + return interface; +} diff --git a/TESTS/network/wifi/main.cpp b/TESTS/network/wifi/main.cpp index c242a8c291f..9c029910df7 100644 --- a/TESTS/network/wifi/main.cpp +++ b/TESTS/network/wifi/main.cpp @@ -1,196 +1,39 @@ -/* mbed Microcontroller Library - * Copyright (c) 2016 ARM Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "utest/utest.h" -#include "unity/unity.h" -#include "greentea-client/test_env.h" - #include "mbed.h" - -#if TARGET_UBLOX_EVK_ODIN_W2 -#include "OdinWiFiInterface.h" -#else -#error [NOT_SUPPORTED] Only built in WiFi modules are supported at this time. -#endif +#include "greentea-client/test_env.h" +#include "unity.h" +#include "utest.h" +#include "wifi_tests.h" using namespace utest::v1; -/** - * WiFi tests require following macros to be defined: - * - MBED_CONF_APP_WIFI_SSID - SSID of a network the test will try connecting to - * - MBED_CONF_APP_WIFI_PASSWORD - Passphrase that will be used to connecting to the network - * - WIFI_TEST_NETWORKS - List of network that presence will be asserted e.g. "net1", "net2", "net3" - */ -#if !defined(MBED_CONF_APP_WIFI_SSID) || !defined(MBED_CONF_APP_WIFI_PASSWORD) || !defined(MBED_CONF_APP_WIFI_NETWORKS) -#error [NOT_SUPPORTED] MBED_CONF_APP_WIFI_SSID, MBED_CONF_APP_WIFI_PASSWORD and MBED_CONF_APP_WIFI_NETWORKS have to be defined for this test. -#endif - -const char *networks[] = {MBED_CONF_APP_WIFI_NETWORKS, NULL}; - -WiFiInterface *wifi; - -/* In normal circumstances the WiFi object could be global, but the delay introduced by WiFi initialization is an issue - for the tests. It causes Greentea to timeout on syncing with the board. To solve it we defer the actual object - creation till we actually need it. - */ -WiFiInterface *get_wifi() -{ - if (wifi == NULL) { - /* We don't really care about freeing this, as its lifetime is through the full test suit run. */ -#if TARGET_UBLOX_EVK_ODIN_W2 - wifi = new OdinWiFiInterface; -#endif - } - - return wifi; -} - -void check_wifi(const char *ssid, bool *net_stat) -{ - int i = 0; - while(networks[i]) { - if (strcmp(networks[i], ssid) == 0) { - net_stat[i] = true; - break; - } - i++; - } -} - -void wifi_scan() -{ - int count; - WiFiAccessPoint *aps; - const int net_len = sizeof(networks)/sizeof(networks[0]); - bool net_stat[net_len - 1]; - - memset(net_stat, 0, sizeof(net_stat)); - - count = get_wifi()->scan(NULL, 0); - TEST_ASSERT_MESSAGE(count >= 0, "WiFi interface returned error"); - TEST_ASSERT_MESSAGE(count > 0, "Scan result empty"); - - aps = new WiFiAccessPoint[count]; - count = get_wifi()->scan(aps, count); - for(int i = 0; i < count; i++) { - check_wifi(aps[i].get_ssid(), net_stat); - } - - delete[] aps; - - for (unsigned i = 0; i < sizeof(net_stat); i++) { - TEST_ASSERT_MESSAGE(net_stat[i] == true, "Not all required WiFi network detected"); - } -} - -void wifi_connect() -{ - int ret; - - ret = get_wifi()->connect(MBED_CONF_APP_WIFI_SSID, MBED_CONF_APP_WIFI_PASSWORD, NSAPI_SECURITY_WPA_WPA2); - TEST_ASSERT_MESSAGE(ret == 0, "Connect failed"); - - ret = get_wifi()->disconnect(); - TEST_ASSERT_MESSAGE(ret == 0, "Disconnect failed"); -} - -void wifi_connect_scan() -{ - int ret; - int count; - WiFiAccessPoint *aps; - const int net_len = sizeof(networks)/sizeof(networks[0]); - bool net_stat[net_len - 1]; - - memset(net_stat, 0, sizeof(net_stat)); - - ret = get_wifi()->connect(MBED_CONF_APP_WIFI_SSID, MBED_CONF_APP_WIFI_PASSWORD, NSAPI_SECURITY_WPA_WPA2); - TEST_ASSERT_MESSAGE(ret == 0, "Connect failed"); - - count = get_wifi()->scan(NULL, 0); - TEST_ASSERT_MESSAGE(count >= 0, "WiFi interface returned error"); - TEST_ASSERT_MESSAGE(count > 0, "Scan result empty"); - - aps = new WiFiAccessPoint[count]; - count = get_wifi()->scan(aps, count); - for(int i = 0; i < count; i++) { - check_wifi(aps[i].get_ssid(), net_stat); - } - - delete[] aps; - - ret = get_wifi()->disconnect(); - TEST_ASSERT_MESSAGE(ret == 0, "Disconnect failed"); - - for (unsigned i = 0; i < sizeof(net_stat); i++) { - TEST_ASSERT_MESSAGE(net_stat[i] == true, "Not all required WiFi network detected"); - } -} - -void wifi_http() -{ - TCPSocket socket; - int ret; - - ret = get_wifi()->connect(MBED_CONF_APP_WIFI_SSID, MBED_CONF_APP_WIFI_PASSWORD, NSAPI_SECURITY_WPA_WPA2); - TEST_ASSERT_MESSAGE(ret == 0, "Connect failed"); - - // Open a socket on the network interface, and create a TCP connection to www.arm.com - ret = socket.open(get_wifi()); - TEST_ASSERT_MESSAGE(ret == 0, "Socket open failed"); - ret = socket.connect("www.arm.com", 80); - TEST_ASSERT_MESSAGE(ret == 0, "Socket connect failed"); - - // Send a simple http request - char sbuffer[] = "GET / HTTP/1.1\r\nHost: www.arm.com\r\n\r\n"; - int scount = socket.send(sbuffer, sizeof sbuffer); - TEST_ASSERT_MESSAGE(scount >= 0, "Socket send failed"); - - // Recieve a simple http response and check if it's not empty - char rbuffer[64]; - int rcount = socket.recv(rbuffer, sizeof rbuffer); - TEST_ASSERT_MESSAGE(rcount >= 0, "Socket recv error"); - TEST_ASSERT_MESSAGE(rcount > 0, "No data received"); - - ret = socket.close(); - TEST_ASSERT_MESSAGE(ret == 0, "Socket close failed"); - - ret = get_wifi()->disconnect(); - TEST_ASSERT_MESSAGE(ret == 0, "Disconnect failed"); -} - -status_t greentea_failure_handler(const Case *const source, const failure_t reason) { - greentea_case_failure_abort_handler(source, reason); - return STATUS_CONTINUE; +utest::v1::status_t test_setup(const size_t number_of_cases) { + GREENTEA_SETUP(120, "default_auto"); + return verbose_test_setup_handler(number_of_cases); } +// Test cases Case cases[] = { - Case("Scan test", wifi_scan, greentea_failure_handler), - Case("Connect test", wifi_connect, greentea_failure_handler), - Case("Scan while connected test", wifi_connect_scan, greentea_failure_handler), - Case("HTTP test", wifi_http, greentea_failure_handler), + Case("WIFI-CONSTRUCTOR", wifi_constructor), + Case("WIFI-SET-CREDENTIAL", wifi_set_credential), + Case("WIFI-SET-CHANNEL", wifi_set_channel), + Case("WIFI-GET-RSSI", wifi_get_rssi), + Case("WIFI-CONNECT-PARAMS-NULL", wifi_connect_params_null), + Case("WIFI-CONNECT-PARAMS-VALID-UNSECURE", wifi_connect_params_valid_unsecure), + Case("WIFI-CONNECT-PARAMS-VALID-SECURE", wifi_connect_params_valid_secure), + Case("WIFI-CONNECT-PARAMS-CHANNEL", wifi_connect_params_channel), + Case("WIFI-CONNECT-PARAMS-CHANNEL-FAIL", wifi_connect_params_channel_fail), + Case("WIFI-CONNECT-NOCREDENTIALS", wifi_connect_nocredentials), + Case("WIFI-CONNECT", wifi_connect), + Case("WIFI-CONNECT-SECURE", wifi_connect_secure), + Case("WIFI-CONNECT-SECURE-FAIL", wifi_connect_secure_fail), + Case("WIFI-CONNECT-DISCONNECT-REPEAT", wifi_connect_disconnect_repeat), + Case("WIFI-SCAN-NULL", wifi_scan_null), + Case("WIFI-SCAN", wifi_scan), }; -status_t greentea_test_setup(const size_t number_of_cases) { - GREENTEA_SETUP(90, "default_auto"); - return greentea_test_setup_handler(number_of_cases); -} - +Specification specification(test_setup, cases); +// Entry point into the tests int main() { - Specification specification(greentea_test_setup, cases, greentea_test_teardown_handler); - Harness::run(specification); + return !Harness::run(specification); } diff --git a/TESTS/network/wifi/wifi-constructor.cpp b/TESTS/network/wifi/wifi-constructor.cpp new file mode 100644 index 00000000000..d2cffb36268 --- /dev/null +++ b/TESTS/network/wifi/wifi-constructor.cpp @@ -0,0 +1,12 @@ +#include "mbed.h" +#include "greentea-client/test_env.h" +#include "unity.h" +#include "utest.h" +#include "wifi_tests.h" + +using namespace utest::v1; + +void wifi_constructor() { + WiFiInterface *wifi = get_interface(); + TEST_ASSERT(wifi); +} diff --git a/TESTS/network/wifi/wifi_connect.cpp b/TESTS/network/wifi/wifi_connect.cpp new file mode 100644 index 00000000000..2d6ac51444e --- /dev/null +++ b/TESTS/network/wifi/wifi_connect.cpp @@ -0,0 +1,16 @@ +#include "mbed.h" +#include "greentea-client/test_env.h" +#include "unity.h" +#include "utest.h" +#include "wifi_tests.h" + +using namespace utest::v1; + +void wifi_connect(void) +{ + WiFiInterface *wifi = get_interface(); + + TEST_ASSERT_EQUAL_INT(NSAPI_ERROR_OK, wifi->set_credentials(MBED_CONF_APP_WIFI_UNSECURE_SSID, NULL)); + + TEST_ASSERT_EQUAL_INT(NSAPI_ERROR_OK, wifi->connect()); +} diff --git a/TESTS/network/wifi/wifi_connect_disconnect_repeat.cpp b/TESTS/network/wifi/wifi_connect_disconnect_repeat.cpp new file mode 100644 index 00000000000..971de306ff9 --- /dev/null +++ b/TESTS/network/wifi/wifi_connect_disconnect_repeat.cpp @@ -0,0 +1,23 @@ +#include "mbed.h" +#include "greentea-client/test_env.h" +#include "unity.h" +#include "utest.h" +#include "wifi_tests.h" + +using namespace utest::v1; + +void wifi_connect_disconnect_repeat(void) +{ + WiFiInterface *wifi = get_interface(); + nsapi_error_t error; + + error = wifi->set_credentials(MBED_CONF_APP_WIFI_UNSECURE_SSID, NULL); + TEST_ASSERT(error == NSAPI_ERROR_OK); + + for(int i=0; i<10; i++) { + error = wifi->connect(); + TEST_ASSERT(error == NSAPI_ERROR_OK); + error = wifi->disconnect(); + TEST_ASSERT(error == NSAPI_ERROR_OK); + } +} diff --git a/TESTS/network/wifi/wifi_connect_nocredentials.cpp b/TESTS/network/wifi/wifi_connect_nocredentials.cpp new file mode 100644 index 00000000000..f540328aebe --- /dev/null +++ b/TESTS/network/wifi/wifi_connect_nocredentials.cpp @@ -0,0 +1,16 @@ +#include "mbed.h" +#include "greentea-client/test_env.h" +#include "unity.h" +#include "utest.h" +#include "wifi_tests.h" + +using namespace utest::v1; + +void wifi_connect_nocredentials(void) +{ + WiFiInterface *wifi = get_interface(); + nsapi_error_t error; + error = wifi->connect(); + wifi->disconnect(); + TEST_ASSERT(error == NSAPI_ERROR_PARAMETER); +} diff --git a/TESTS/network/wifi/wifi_connect_params_channel.cpp b/TESTS/network/wifi/wifi_connect_params_channel.cpp new file mode 100644 index 00000000000..c440470a9d7 --- /dev/null +++ b/TESTS/network/wifi/wifi_connect_params_channel.cpp @@ -0,0 +1,21 @@ +#include "mbed.h" +#include "greentea-client/test_env.h" +#include "unity.h" +#include "utest.h" +#include "wifi_tests.h" + +using namespace utest::v1; + +void wifi_connect_params_channel(void) +{ + WiFiInterface *wifi = get_interface(); + + if (wifi->set_channel(1) == NSAPI_ERROR_UNSUPPORTED && wifi->set_channel(36) == NSAPI_ERROR_UNSUPPORTED) { + TEST_IGNORE_MESSAGE("set_channel() not supported"); + return; + } + + nsapi_error_t error = wifi->connect(MBED_CONF_APP_WIFI_SECURE_SSID, MBED_CONF_APP_WIFI_PASSWORD, NSAPI_SECURITY_WPA2, MBED_CONF_APP_WIFI_CH_SECURE); + TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, error); +} + diff --git a/TESTS/network/wifi/wifi_connect_params_channel_fail.cpp b/TESTS/network/wifi/wifi_connect_params_channel_fail.cpp new file mode 100644 index 00000000000..d5d9733a15b --- /dev/null +++ b/TESTS/network/wifi/wifi_connect_params_channel_fail.cpp @@ -0,0 +1,21 @@ +#include "mbed.h" +#include "greentea-client/test_env.h" +#include "unity.h" +#include "utest.h" +#include "wifi_tests.h" + +using namespace utest::v1; + +void wifi_connect_params_channel_fail(void) +{ + WiFiInterface *wifi = get_interface(); + + if (wifi->set_channel(1) == NSAPI_ERROR_UNSUPPORTED && wifi->set_channel(36) == NSAPI_ERROR_UNSUPPORTED) { + TEST_IGNORE_MESSAGE("set_channel() not supported"); + return; + } + + nsapi_error_t error = wifi->connect(MBED_CONF_APP_WIFI_SECURE_SSID, MBED_CONF_APP_WIFI_PASSWORD, NSAPI_SECURITY_WPA2, MBED_CONF_APP_WIFI_CH_UNSECURE); + TEST_ASSERT(error==NSAPI_ERROR_CONNECTION_TIMEOUT || error==NSAPI_ERROR_NO_CONNECTION); +} + diff --git a/TESTS/network/wifi/wifi_connect_params_null.cpp b/TESTS/network/wifi/wifi_connect_params_null.cpp new file mode 100644 index 00000000000..22f7c1917d4 --- /dev/null +++ b/TESTS/network/wifi/wifi_connect_params_null.cpp @@ -0,0 +1,13 @@ +#include "mbed.h" +#include "greentea-client/test_env.h" +#include "unity.h" +#include "utest.h" +#include "wifi_tests.h" + +using namespace utest::v1; + +void wifi_connect_params_null(void) +{ + WiFiInterface *wifi = get_interface(); + TEST_ASSERT_EQUAL_INT(NSAPI_ERROR_PARAMETER, wifi->connect(NULL, NULL)); +} diff --git a/TESTS/network/wifi/wifi_connect_params_valid_secure.cpp b/TESTS/network/wifi/wifi_connect_params_valid_secure.cpp new file mode 100644 index 00000000000..ba906a20d77 --- /dev/null +++ b/TESTS/network/wifi/wifi_connect_params_valid_secure.cpp @@ -0,0 +1,13 @@ +#include "mbed.h" +#include "greentea-client/test_env.h" +#include "unity.h" +#include "utest.h" +#include "wifi_tests.h" + +using namespace utest::v1; + +void wifi_connect_params_valid_secure(void) +{ + WiFiInterface *wifi = get_interface(); + TEST_ASSERT_EQUAL_INT(NSAPI_ERROR_OK, wifi->connect(MBED_CONF_APP_WIFI_SECURE_SSID, MBED_CONF_APP_WIFI_PASSWORD, NSAPI_SECURITY_WPA2)); +} diff --git a/TESTS/network/wifi/wifi_connect_params_valid_unsecure.cpp b/TESTS/network/wifi/wifi_connect_params_valid_unsecure.cpp new file mode 100644 index 00000000000..4a63e664f04 --- /dev/null +++ b/TESTS/network/wifi/wifi_connect_params_valid_unsecure.cpp @@ -0,0 +1,14 @@ +#include "mbed.h" +#include "greentea-client/test_env.h" +#include "unity.h" +#include "utest.h" +#include "wifi_tests.h" + +using namespace utest::v1; + +void wifi_connect_params_valid_unsecure(void) +{ + WiFiInterface *wifi = get_interface(); + TEST_ASSERT_EQUAL_INT(NSAPI_ERROR_OK, wifi->connect(MBED_CONF_APP_WIFI_UNSECURE_SSID, NULL)); +} + diff --git a/TESTS/network/wifi/wifi_connect_secure.cpp b/TESTS/network/wifi/wifi_connect_secure.cpp new file mode 100644 index 00000000000..b6d47051cf5 --- /dev/null +++ b/TESTS/network/wifi/wifi_connect_secure.cpp @@ -0,0 +1,17 @@ +#include "mbed.h" +#include "greentea-client/test_env.h" +#include "unity.h" +#include "utest.h" +#include "wifi_tests.h" + +using namespace utest::v1; + +void wifi_connect_secure(void) +{ + WiFiInterface *wifi = get_interface(); + + TEST_ASSERT_EQUAL_INT(NSAPI_ERROR_OK, wifi->set_credentials(MBED_CONF_APP_WIFI_SECURE_SSID, MBED_CONF_APP_WIFI_PASSWORD, NSAPI_SECURITY_WPA2)); + + TEST_ASSERT_EQUAL_INT(NSAPI_ERROR_OK, wifi->connect()); +} + diff --git a/TESTS/network/wifi/wifi_connect_secure_fail.cpp b/TESTS/network/wifi/wifi_connect_secure_fail.cpp new file mode 100644 index 00000000000..9b271f7fcb2 --- /dev/null +++ b/TESTS/network/wifi/wifi_connect_secure_fail.cpp @@ -0,0 +1,17 @@ +#include "mbed.h" +#include "greentea-client/test_env.h" +#include "unity.h" +#include "utest.h" +#include "wifi_tests.h" + +using namespace utest::v1; + +void wifi_connect_secure_fail(void) +{ + WiFiInterface *wifi = get_interface(); + + TEST_ASSERT_EQUAL_INT(NSAPI_ERROR_OK, wifi->set_credentials(MBED_CONF_APP_WIFI_SECURE_SSID, "aaaaaaaa", NSAPI_SECURITY_WPA2)); + + TEST_ASSERT_EQUAL_INT(NSAPI_ERROR_AUTH_FAILURE, wifi->connect()); +} + diff --git a/TESTS/network/wifi/wifi_get_rssi.cpp b/TESTS/network/wifi/wifi_get_rssi.cpp new file mode 100644 index 00000000000..7c980c5e280 --- /dev/null +++ b/TESTS/network/wifi/wifi_get_rssi.cpp @@ -0,0 +1,21 @@ +#include "mbed.h" +#include "greentea-client/test_env.h" +#include "unity.h" +#include "utest.h" +#include "wifi_tests.h" + +using namespace utest::v1; + +void wifi_get_rssi(void) +{ + WiFiInterface *wifi = get_interface(); + + TEST_ASSERT_EQUAL_INT(NSAPI_ERROR_OK, wifi->set_credentials(MBED_CONF_APP_WIFI_UNSECURE_SSID, NULL)); + + TEST_ASSERT_EQUAL_INT8(0, wifi->get_rssi()); + + TEST_ASSERT_EQUAL_INT(NSAPI_ERROR_OK, wifi->connect()); + + TEST_ASSERT_INT8_WITHIN(-35, -65, wifi->get_rssi()); // -30 ... -100 +} + diff --git a/TESTS/network/wifi/wifi_scan.cpp b/TESTS/network/wifi/wifi_scan.cpp new file mode 100644 index 00000000000..a9aa057873f --- /dev/null +++ b/TESTS/network/wifi/wifi_scan.cpp @@ -0,0 +1,50 @@ +#include "mbed.h" +#include "greentea-client/test_env.h" +#include "unity.h" +#include "utest.h" +#include "wifi_tests.h" +#include + +using namespace utest::v1; + +void wifi_scan(void) +{ + WiFiInterface *wifi = get_interface(); + + WiFiAccessPoint ap[MBED_CONF_APP_MAX_SCAN_SIZE]; + + int size = wifi->scan(ap, MBED_CONF_APP_MAX_SCAN_SIZE); + TEST_ASSERT(size >= 2); + + bool secure_found = false; + bool unsecure_found = false; + + char secure_bssid[6]; + char unsecure_bssid[6]; + const char *coversion_string = "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx"; + TEST_ASSERT_EQUAL_INT_MESSAGE(6, sscanf(MBED_CONF_APP_AP_MAC_SECURE, coversion_string, &secure_bssid[0], &secure_bssid[1], &secure_bssid[2], &secure_bssid[3], &secure_bssid[4], &secure_bssid[5]), "Failed to convert ap-mac-secure from mbed_app.json"); + TEST_ASSERT_EQUAL_INT_MESSAGE(6, sscanf(MBED_CONF_APP_AP_MAC_UNSECURE, coversion_string, &unsecure_bssid[0], &unsecure_bssid[1], &unsecure_bssid[2], &unsecure_bssid[3], &unsecure_bssid[4], &unsecure_bssid[5]), "Failed to convert ap-mac-unsecure from mbed_app.json"); + + for (int i=0; iscan(NULL, 0) >= 2); +} + diff --git a/TESTS/network/wifi/wifi_set_channel.cpp b/TESTS/network/wifi/wifi_set_channel.cpp new file mode 100644 index 00000000000..f7681b136f8 --- /dev/null +++ b/TESTS/network/wifi/wifi_set_channel.cpp @@ -0,0 +1,56 @@ +#include "mbed.h" +#include "greentea-client/test_env.h" +#include "unity.h" +#include "utest.h" +#include "wifi_tests.h" +#include + +using namespace utest::v1; + +void wifi_set_channel(void) +{ + bool is_2Ghz = false; + bool is_5Ghz = false; + + WiFiInterface *wifi = get_interface(); + + if (wifi->set_channel(1) == NSAPI_ERROR_UNSUPPORTED && wifi->set_channel(36) == NSAPI_ERROR_UNSUPPORTED) { + TEST_IGNORE_MESSAGE("set_channel() not supported"); + return; + } + + nsapi_error_t error; + error = wifi->set_channel(1); + if (error == NSAPI_ERROR_OK) { + is_2Ghz = true; + } + + error = wifi->set_channel(30); + if (error == NSAPI_ERROR_OK) { + is_5Ghz = true; + } + + TEST_ASSERT(is_2Ghz || is_5Ghz); + + if (is_2Ghz) { + error = wifi->set_channel(0); + TEST_ASSERT(error == NSAPI_ERROR_PARAMETER); + error = wifi->set_channel(1); + TEST_ASSERT(error == NSAPI_ERROR_OK); + error = wifi->set_channel(13); + TEST_ASSERT(error == NSAPI_ERROR_OK || error == NSAPI_ERROR_PARAMETER); + error = wifi->set_channel(15); + TEST_ASSERT(error == NSAPI_ERROR_PARAMETER); + } + + if (is_5Ghz) { + error = wifi->set_channel(30); + TEST_ASSERT(error == NSAPI_ERROR_PARAMETER); + error = wifi->set_channel(36); + TEST_ASSERT(error == NSAPI_ERROR_OK); + error = wifi->set_channel(169); + TEST_ASSERT(error == NSAPI_ERROR_PARAMETER); + } + +} + diff --git a/TESTS/network/wifi/wifi_set_credential.cpp b/TESTS/network/wifi/wifi_set_credential.cpp new file mode 100644 index 00000000000..b08df974fc6 --- /dev/null +++ b/TESTS/network/wifi/wifi_set_credential.cpp @@ -0,0 +1,37 @@ +#include "mbed.h" +#include "greentea-client/test_env.h" +#include "unity.h" +#include "utest.h" +#include "wifi_tests.h" + +using namespace utest::v1; + +void wifi_set_credential(void) +{ + WiFiInterface *iface = get_interface(); + nsapi_error_t error; + + error = iface->set_credentials(NULL, NULL, NSAPI_SECURITY_NONE); + TEST_ASSERT(error == NSAPI_ERROR_PARAMETER); + + error = iface->set_credentials("OK", NULL, NSAPI_SECURITY_NONE); + TEST_ASSERT(error == NSAPI_ERROR_OK); + + error = iface->set_credentials("OK", NULL, NSAPI_SECURITY_WEP); + TEST_ASSERT(error == NSAPI_ERROR_PARAMETER); + + error = iface->set_credentials("OK", NULL, NSAPI_SECURITY_WPA_WPA2); + TEST_ASSERT(error == NSAPI_ERROR_PARAMETER); + + error = iface->set_credentials("OK", "12345678", NSAPI_SECURITY_WPA); + TEST_ASSERT(error == NSAPI_ERROR_OK); + + error = iface->set_credentials("OK", "12345678", NSAPI_SECURITY_WPA2); + TEST_ASSERT(error == NSAPI_ERROR_OK); + + error = iface->set_credentials("OK", "12345678", NSAPI_SECURITY_WPA_WPA2); + TEST_ASSERT(error == NSAPI_ERROR_OK); + + error = iface->set_credentials("OK", "kUjd0PHHeAqaDoyfcDDEOvbyiVbYMpUHDukGoR6EJZnO5iLzWsfwiM9JQqOngni82", NSAPI_SECURITY_WPA2); + TEST_ASSERT(error == NSAPI_ERROR_PARAMETER); +} diff --git a/TESTS/network/wifi/wifi_tests.h b/TESTS/network/wifi/wifi_tests.h new file mode 100644 index 00000000000..0d66fb689d2 --- /dev/null +++ b/TESTS/network/wifi/wifi_tests.h @@ -0,0 +1,26 @@ +#ifndef WIFI_TESTS_H +#define WIFI_TESTS_H + +#include "WiFiInterface.h" + +WiFiInterface *get_interface(void); + +/* Test cases */ +void wifi_constructor(void); +void wifi_set_credential(void); +void wifi_set_channel(void); +void wifi_get_rssi(void); +void wifi_connect_params_null(void); +void wifi_connect_params_valid_unsecure(void); +void wifi_connect_params_valid_secure(void); +void wifi_connect_params_channel(void); +void wifi_connect_params_channel_fail(void); +void wifi_connect(void); +void wifi_connect_nocredentials(void); +void wifi_connect_secure(void); +void wifi_connect_secure_fail(void); +void wifi_connect_disconnect_repeat(void); +void wifi_scan_null(void); +void wifi_scan(void); + +#endif //WIFI_TESTS_H From 52b9716ad2329f698b712e4c6252fccfacc0c723 Mon Sep 17 00:00:00 2001 From: Seppo Takalo Date: Tue, 19 Sep 2017 20:16:36 +0300 Subject: [PATCH 038/108] Set timeout to 4 minutes. Wifi connections and scanning takes long time. 2 minutes might not be enough. --- TESTS/network/wifi/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TESTS/network/wifi/main.cpp b/TESTS/network/wifi/main.cpp index 9c029910df7..754df739d56 100644 --- a/TESTS/network/wifi/main.cpp +++ b/TESTS/network/wifi/main.cpp @@ -7,7 +7,7 @@ using namespace utest::v1; utest::v1::status_t test_setup(const size_t number_of_cases) { - GREENTEA_SETUP(120, "default_auto"); + GREENTEA_SETUP(240, "default_auto"); return verbose_test_setup_handler(number_of_cases); } From 6f118da42cc0bf1ffe26248a611dab4527dea0c7 Mon Sep 17 00:00:00 2001 From: Seppo Takalo Date: Fri, 22 Sep 2017 12:15:27 +0300 Subject: [PATCH 039/108] Update template mbed_app.json --- TESTS/network/wifi/template_mbed_app.txt | 37 +++++++++++++++++------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/TESTS/network/wifi/template_mbed_app.txt b/TESTS/network/wifi/template_mbed_app.txt index 77a7af0cf95..c3862ae983b 100644 --- a/TESTS/network/wifi/template_mbed_app.txt +++ b/TESTS/network/wifi/template_mbed_app.txt @@ -1,21 +1,36 @@ { "config": { - "wifi-ssid": { + "wifi-secure-ssid": { "help": "WiFi SSID", - "value": "\"SSID\"" + "value": "\"SSID-SECURE\"" + }, + "wifi-unsecure-ssid": { + "help": "WiFi SSID", + "value": "\"SSID-UNSECURE\"" }, "wifi-password": { "help": "WiFi Password", - "value": "\"PASS\"" + "value": "\"PASSWORD\"" }, - "wifi-networks": { - "help": "WiFi SSIDs which presence will be asserted in the test", - "value": "\"SSID1\",\"SSID2\",\"SSID3\"" - } - }, - "target_overrides": { - "UBLOX_EVK_ODIN_W2": { - "target.device_has": ["EMAC"] + "wifi-ch-secure": { + "help": "Channel number of secure SSID", + "value": 1 + }, + "wifi-ch-unsecure": { + "help": "Channel number of unsecure SSID", + "value": 2 + }, + "ap-mac-secure": { + "help": "BSSID of secure AP in form of AA:BB:CC:DD:EE:FF", + "value": "\"AA:AA:AA:AA:AA:AA\"" + }, + "ap-mac-unsecure": { + "help": "BSSID of unsecure AP in form of \"AA:BB:CC:DD:EE:FF\"", + "value": "\"BB:BB:BB:BB:BB:BB\"" + }, + "max-scan-size": { + "help": "How many networks may appear in Wifi scan result", + "value": 10 } } } From b2a884dcece5225ac58c1cd988b2d4df031323cb Mon Sep 17 00:00:00 2001 From: Seppo Takalo Date: Fri, 29 Sep 2017 12:55:04 +0300 Subject: [PATCH 040/108] Fix includes. Cannot include header file witin a function (without severe side effects) --- TESTS/network/wifi/get_interface.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/TESTS/network/wifi/get_interface.cpp b/TESTS/network/wifi/get_interface.cpp index 54e2bb2a963..99653e009c9 100644 --- a/TESTS/network/wifi/get_interface.cpp +++ b/TESTS/network/wifi/get_interface.cpp @@ -1,5 +1,12 @@ #include "mbed.h" + +#if TARGET_UBLOX_EVK_ODIN_W2 +#include "OdinWiFiInterface.h" +#elif TARGET_REALTEK_RTL8195AM +#include "RTWInterface.h" +#else #include "ESP8266Interface.h" +#endif WiFiInterface *get_interface() { @@ -9,10 +16,8 @@ WiFiInterface *get_interface() delete interface; #if TARGET_UBLOX_EVK_ODIN_W2 -#include "OdinWiFiInterface.h" interface = new OdinWiFiInterface(); #elif TARGET_REALTEK_RTL8195AM -#include "RTWInterface.h" interface = new RTWInterface(); #else interface = new ESP8266Interface(D1, D0); From 8cb7c14f901cf030e3b0632aa3c72b064e219431 Mon Sep 17 00:00:00 2001 From: Seppo Takalo Date: Tue, 3 Oct 2017 12:09:52 +0300 Subject: [PATCH 041/108] Update help text --- TESTS/network/wifi/template_mbed_app.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TESTS/network/wifi/template_mbed_app.txt b/TESTS/network/wifi/template_mbed_app.txt index c3862ae983b..847b7c0b047 100644 --- a/TESTS/network/wifi/template_mbed_app.txt +++ b/TESTS/network/wifi/template_mbed_app.txt @@ -1,11 +1,11 @@ { "config": { "wifi-secure-ssid": { - "help": "WiFi SSID", + "help": "WiFi SSID for WPA2 secured network", "value": "\"SSID-SECURE\"" }, "wifi-unsecure-ssid": { - "help": "WiFi SSID", + "help": "WiFi SSID for unsecure netwrok", "value": "\"SSID-UNSECURE\"" }, "wifi-password": { From ee9d04e248e6e13d92c8013d66f81377a2525837 Mon Sep 17 00:00:00 2001 From: Seppo Takalo Date: Tue, 3 Oct 2017 12:50:03 +0300 Subject: [PATCH 042/108] Fix builds for targets without wifi or without mbed_app.json --- TESTS/network/wifi/get_interface.cpp | 29 ++++++++++++++++++++---- TESTS/network/wifi/main.cpp | 15 ++++++++++++ TESTS/network/wifi/template_mbed_app.txt | 12 ++++++++++ 3 files changed, 51 insertions(+), 5 deletions(-) diff --git a/TESTS/network/wifi/get_interface.cpp b/TESTS/network/wifi/get_interface.cpp index 99653e009c9..d89751c8912 100644 --- a/TESTS/network/wifi/get_interface.cpp +++ b/TESTS/network/wifi/get_interface.cpp @@ -1,11 +1,32 @@ #include "mbed.h" +// Pick the correct driver based on mbed_app.json +#define INTERNAL 1 +#define WIFI_ESP8266 2 +#define X_NUCLEO_IDW01M1 3 + +#if MBED_CONF_APP_WIFI_DRIVER == INTERNAL + #if TARGET_UBLOX_EVK_ODIN_W2 #include "OdinWiFiInterface.h" +#define DRIVER OdinWiFiInterface + #elif TARGET_REALTEK_RTL8195AM #include "RTWInterface.h" +#define DRIVER RTWInterface #else +#error [NOT_SUPPORTED] Unsupported Wifi driver +#endif + +#elif MBED_CONF_APP_WIFI_DRIVER == WIFI_ESP8266 #include "ESP8266Interface.h" +#define DRIVER ESP8266Interface + +#elif MBED_CONF_APP_WIFI_DRIVER == X_NUCLEO_IDW01M1 +#include "SpwfSAInterface.h" +#define DRIVER SpwfSAInterface +#else +#error [NOT_SUPPORTED] Unsupported Wifi driver #endif WiFiInterface *get_interface() @@ -15,12 +36,10 @@ WiFiInterface *get_interface() if (interface) delete interface; -#if TARGET_UBLOX_EVK_ODIN_W2 - interface = new OdinWiFiInterface(); -#elif TARGET_REALTEK_RTL8195AM - interface = new RTWInterface(); +#if MBED_CONF_APP_WIFI_DRIVER == INTERNAL + interface = new DRIVER(); #else - interface = new ESP8266Interface(D1, D0); + interface = new DRIVER(MBED_CONF_APP_WIFI_TX, MBED_CONF_APP_WIFI_RX); #endif return interface; } diff --git a/TESTS/network/wifi/main.cpp b/TESTS/network/wifi/main.cpp index 754df739d56..85bb2e9a079 100644 --- a/TESTS/network/wifi/main.cpp +++ b/TESTS/network/wifi/main.cpp @@ -4,6 +4,21 @@ #include "utest.h" #include "wifi_tests.h" +// Test for parameters +#if !defined(MBED_CONF_APP_AP_MAC_SECURE) || \ + !defined(MBED_CONF_APP_AP_MAC_UNSECURE) || \ + !defined(MBED_CONF_APP_MAX_SCAN_SIZE) || \ + !defined(MBED_CONF_APP_WIFI_CH_SECURE) || \ + !defined(MBED_CONF_APP_WIFI_CH_UNSECURE) || \ + !defined(MBED_CONF_APP_WIFI_DRIVER) || \ + !defined(MBED_CONF_APP_WIFI_PASSWORD) || \ + !defined(MBED_CONF_APP_WIFI_RX) || \ + !defined(MBED_CONF_APP_WIFI_SECURE_SSID) || \ + !defined(MBED_CONF_APP_WIFI_TX) || \ + !defined(MBED_CONF_APP_WIFI_UNSECURE_SSID) +#error [NOT_SUPPORTED] Requires parameters from mbed_app.json +#endif + using namespace utest::v1; utest::v1::status_t test_setup(const size_t number_of_cases) { diff --git a/TESTS/network/wifi/template_mbed_app.txt b/TESTS/network/wifi/template_mbed_app.txt index 847b7c0b047..ddab934545a 100644 --- a/TESTS/network/wifi/template_mbed_app.txt +++ b/TESTS/network/wifi/template_mbed_app.txt @@ -20,6 +20,18 @@ "help": "Channel number of unsecure SSID", "value": 2 }, + "wifi-driver": { + "help": "Wifi driver to use, valid values are INTERNAL, WIFI_ESP8266 and X_NUCLEO_IDW01M1", + "value": "INTERNAL" + }, + "wifi-tx": { + "help": "TX pin for serial connection to external device", + "value": "D1" + }, + "wifi-rx": { + "help": "RX pin for serial connection to external device", + "value": "D0" + }, "ap-mac-secure": { "help": "BSSID of secure AP in form of AA:BB:CC:DD:EE:FF", "value": "\"AA:AA:AA:AA:AA:AA\"" From 1d8249133d341008644a1a71ec126e2fad1bd779 Mon Sep 17 00:00:00 2001 From: Seppo Takalo Date: Wed, 4 Oct 2017 12:32:46 +0300 Subject: [PATCH 043/108] Add Doxygen documentation for testcases. --- TESTS/network/wifi/wifi_tests.h | 39 ++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/TESTS/network/wifi/wifi_tests.h b/TESTS/network/wifi/wifi_tests.h index 0d66fb689d2..1ef40ccc2de 100644 --- a/TESTS/network/wifi/wifi_tests.h +++ b/TESTS/network/wifi/wifi_tests.h @@ -3,24 +3,61 @@ #include "WiFiInterface.h" +/** Get WiFiInterface based on provided + * app_json. */ WiFiInterface *get_interface(void); -/* Test cases */ +/* + * Test cases + */ + +/** Test that constructor of the driver works. */ void wifi_constructor(void); + +/** This test case is to test whether the driver accepts valid credentials and reject ones that are not valid. */ void wifi_set_credential(void); + +/** Test validity of WiFiInterface::set_channel(). */ void wifi_set_channel(void); + +/** Test WiFiInterface::get_rssi() API. + * When connected, it should return valid RSSI value. When unconnected it should return 0. */ void wifi_get_rssi(void); + +/** Test WiFiInterface::connect(ssid, pass, security, channel) with NULL parameters */ void wifi_connect_params_null(void); + +/** Test WiFiInterface::connect(ssid, pass, security) with valid parameters for unsecure network */ void wifi_connect_params_valid_unsecure(void); + +/** Test WiFiInterface::connect(ssid, pass, security) with valid parameters for secure network */ void wifi_connect_params_valid_secure(void); + +/** Test WiFiInterface::connect(ssid, pass, security, channel) with valid parameters for secure network using channel specified. */ void wifi_connect_params_channel(void); + +/** Test WiFiInterface::connect(ssid, pass, security, channel) with valid parameters for secure network using wrong channel number. */ void wifi_connect_params_channel_fail(void); + +/** Test WiFiInterface::connect() without parameters. Use set_credentials() for setting parameters. */ void wifi_connect(void); + +/** Test WiFiInterface::connect() without parameters. Don't set parameters with set_credentials() */ void wifi_connect_nocredentials(void); + +/** Test WiFiInterface::connect() without parameters. Use secure settings for set_credentials. */ void wifi_connect_secure(void); + +/** Test WiFiInterface::connect() failing with wrong password. */ void wifi_connect_secure_fail(void); + +/** Test WiFiInterface::connect() - disconnect() repeatition works. */ void wifi_connect_disconnect_repeat(void); + +/** Call WiFiInterface::scan() with null parameters to get number of networks available. */ void wifi_scan_null(void); + +/** Call WiFiInterface::scan() with valid accesspoint list allocated */ void wifi_scan(void); #endif //WIFI_TESTS_H From 609cd3bb88ecc128bbac2eff981bd14a72c04654 Mon Sep 17 00:00:00 2001 From: Seppo Takalo Date: Wed, 4 Oct 2017 17:45:25 +0300 Subject: [PATCH 044/108] Add license texts --- TESTS/network/wifi/get_interface.cpp | 17 +++++++++++++++++ TESTS/network/wifi/main.cpp | 17 +++++++++++++++++ TESTS/network/wifi/wifi-constructor.cpp | 17 +++++++++++++++++ TESTS/network/wifi/wifi_connect.cpp | 17 +++++++++++++++++ .../wifi/wifi_connect_disconnect_repeat.cpp | 17 +++++++++++++++++ .../network/wifi/wifi_connect_nocredentials.cpp | 17 +++++++++++++++++ .../wifi/wifi_connect_params_channel.cpp | 17 +++++++++++++++++ .../wifi/wifi_connect_params_channel_fail.cpp | 17 +++++++++++++++++ TESTS/network/wifi/wifi_connect_params_null.cpp | 17 +++++++++++++++++ .../wifi/wifi_connect_params_valid_secure.cpp | 17 +++++++++++++++++ .../wifi/wifi_connect_params_valid_unsecure.cpp | 17 +++++++++++++++++ TESTS/network/wifi/wifi_connect_secure.cpp | 17 +++++++++++++++++ TESTS/network/wifi/wifi_connect_secure_fail.cpp | 17 +++++++++++++++++ TESTS/network/wifi/wifi_get_rssi.cpp | 17 +++++++++++++++++ TESTS/network/wifi/wifi_scan.cpp | 17 +++++++++++++++++ TESTS/network/wifi/wifi_scan_null.cpp | 17 +++++++++++++++++ TESTS/network/wifi/wifi_set_channel.cpp | 17 +++++++++++++++++ TESTS/network/wifi/wifi_set_credential.cpp | 17 +++++++++++++++++ 18 files changed, 306 insertions(+) diff --git a/TESTS/network/wifi/get_interface.cpp b/TESTS/network/wifi/get_interface.cpp index d89751c8912..9bafab9b588 100644 --- a/TESTS/network/wifi/get_interface.cpp +++ b/TESTS/network/wifi/get_interface.cpp @@ -1,3 +1,20 @@ +/* + * Copyright (c) 2017, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "mbed.h" // Pick the correct driver based on mbed_app.json diff --git a/TESTS/network/wifi/main.cpp b/TESTS/network/wifi/main.cpp index 85bb2e9a079..1245b11e2dd 100644 --- a/TESTS/network/wifi/main.cpp +++ b/TESTS/network/wifi/main.cpp @@ -1,3 +1,20 @@ +/* + * Copyright (c) 2017, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "mbed.h" #include "greentea-client/test_env.h" #include "unity.h" diff --git a/TESTS/network/wifi/wifi-constructor.cpp b/TESTS/network/wifi/wifi-constructor.cpp index d2cffb36268..3fa80ff5cbb 100644 --- a/TESTS/network/wifi/wifi-constructor.cpp +++ b/TESTS/network/wifi/wifi-constructor.cpp @@ -1,3 +1,20 @@ +/* + * Copyright (c) 2017, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "mbed.h" #include "greentea-client/test_env.h" #include "unity.h" diff --git a/TESTS/network/wifi/wifi_connect.cpp b/TESTS/network/wifi/wifi_connect.cpp index 2d6ac51444e..c244e0247fc 100644 --- a/TESTS/network/wifi/wifi_connect.cpp +++ b/TESTS/network/wifi/wifi_connect.cpp @@ -1,3 +1,20 @@ +/* + * Copyright (c) 2017, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "mbed.h" #include "greentea-client/test_env.h" #include "unity.h" diff --git a/TESTS/network/wifi/wifi_connect_disconnect_repeat.cpp b/TESTS/network/wifi/wifi_connect_disconnect_repeat.cpp index 971de306ff9..9ee73fc5587 100644 --- a/TESTS/network/wifi/wifi_connect_disconnect_repeat.cpp +++ b/TESTS/network/wifi/wifi_connect_disconnect_repeat.cpp @@ -1,3 +1,20 @@ +/* + * Copyright (c) 2017, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "mbed.h" #include "greentea-client/test_env.h" #include "unity.h" diff --git a/TESTS/network/wifi/wifi_connect_nocredentials.cpp b/TESTS/network/wifi/wifi_connect_nocredentials.cpp index f540328aebe..c930d7d0a95 100644 --- a/TESTS/network/wifi/wifi_connect_nocredentials.cpp +++ b/TESTS/network/wifi/wifi_connect_nocredentials.cpp @@ -1,3 +1,20 @@ +/* + * Copyright (c) 2017, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "mbed.h" #include "greentea-client/test_env.h" #include "unity.h" diff --git a/TESTS/network/wifi/wifi_connect_params_channel.cpp b/TESTS/network/wifi/wifi_connect_params_channel.cpp index c440470a9d7..08c34a9c541 100644 --- a/TESTS/network/wifi/wifi_connect_params_channel.cpp +++ b/TESTS/network/wifi/wifi_connect_params_channel.cpp @@ -1,3 +1,20 @@ +/* + * Copyright (c) 2017, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "mbed.h" #include "greentea-client/test_env.h" #include "unity.h" diff --git a/TESTS/network/wifi/wifi_connect_params_channel_fail.cpp b/TESTS/network/wifi/wifi_connect_params_channel_fail.cpp index d5d9733a15b..f1d56d22496 100644 --- a/TESTS/network/wifi/wifi_connect_params_channel_fail.cpp +++ b/TESTS/network/wifi/wifi_connect_params_channel_fail.cpp @@ -1,3 +1,20 @@ +/* + * Copyright (c) 2017, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "mbed.h" #include "greentea-client/test_env.h" #include "unity.h" diff --git a/TESTS/network/wifi/wifi_connect_params_null.cpp b/TESTS/network/wifi/wifi_connect_params_null.cpp index 22f7c1917d4..6a471bd6049 100644 --- a/TESTS/network/wifi/wifi_connect_params_null.cpp +++ b/TESTS/network/wifi/wifi_connect_params_null.cpp @@ -1,3 +1,20 @@ +/* + * Copyright (c) 2017, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "mbed.h" #include "greentea-client/test_env.h" #include "unity.h" diff --git a/TESTS/network/wifi/wifi_connect_params_valid_secure.cpp b/TESTS/network/wifi/wifi_connect_params_valid_secure.cpp index ba906a20d77..0da25c67927 100644 --- a/TESTS/network/wifi/wifi_connect_params_valid_secure.cpp +++ b/TESTS/network/wifi/wifi_connect_params_valid_secure.cpp @@ -1,3 +1,20 @@ +/* + * Copyright (c) 2017, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "mbed.h" #include "greentea-client/test_env.h" #include "unity.h" diff --git a/TESTS/network/wifi/wifi_connect_params_valid_unsecure.cpp b/TESTS/network/wifi/wifi_connect_params_valid_unsecure.cpp index 4a63e664f04..e1540b24a8d 100644 --- a/TESTS/network/wifi/wifi_connect_params_valid_unsecure.cpp +++ b/TESTS/network/wifi/wifi_connect_params_valid_unsecure.cpp @@ -1,3 +1,20 @@ +/* + * Copyright (c) 2017, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "mbed.h" #include "greentea-client/test_env.h" #include "unity.h" diff --git a/TESTS/network/wifi/wifi_connect_secure.cpp b/TESTS/network/wifi/wifi_connect_secure.cpp index b6d47051cf5..dce86f969fd 100644 --- a/TESTS/network/wifi/wifi_connect_secure.cpp +++ b/TESTS/network/wifi/wifi_connect_secure.cpp @@ -1,3 +1,20 @@ +/* + * Copyright (c) 2017, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "mbed.h" #include "greentea-client/test_env.h" #include "unity.h" diff --git a/TESTS/network/wifi/wifi_connect_secure_fail.cpp b/TESTS/network/wifi/wifi_connect_secure_fail.cpp index 9b271f7fcb2..7e55a290a87 100644 --- a/TESTS/network/wifi/wifi_connect_secure_fail.cpp +++ b/TESTS/network/wifi/wifi_connect_secure_fail.cpp @@ -1,3 +1,20 @@ +/* + * Copyright (c) 2017, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "mbed.h" #include "greentea-client/test_env.h" #include "unity.h" diff --git a/TESTS/network/wifi/wifi_get_rssi.cpp b/TESTS/network/wifi/wifi_get_rssi.cpp index 7c980c5e280..ac4338ff934 100644 --- a/TESTS/network/wifi/wifi_get_rssi.cpp +++ b/TESTS/network/wifi/wifi_get_rssi.cpp @@ -1,3 +1,20 @@ +/* + * Copyright (c) 2017, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "mbed.h" #include "greentea-client/test_env.h" #include "unity.h" diff --git a/TESTS/network/wifi/wifi_scan.cpp b/TESTS/network/wifi/wifi_scan.cpp index a9aa057873f..d4722dd0d08 100644 --- a/TESTS/network/wifi/wifi_scan.cpp +++ b/TESTS/network/wifi/wifi_scan.cpp @@ -1,3 +1,20 @@ +/* + * Copyright (c) 2017, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "mbed.h" #include "greentea-client/test_env.h" #include "unity.h" diff --git a/TESTS/network/wifi/wifi_scan_null.cpp b/TESTS/network/wifi/wifi_scan_null.cpp index bfdd42391fc..784d91b8969 100644 --- a/TESTS/network/wifi/wifi_scan_null.cpp +++ b/TESTS/network/wifi/wifi_scan_null.cpp @@ -1,3 +1,20 @@ +/* + * Copyright (c) 2017, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "mbed.h" #include "greentea-client/test_env.h" #include "unity.h" diff --git a/TESTS/network/wifi/wifi_set_channel.cpp b/TESTS/network/wifi/wifi_set_channel.cpp index f7681b136f8..ecb79150042 100644 --- a/TESTS/network/wifi/wifi_set_channel.cpp +++ b/TESTS/network/wifi/wifi_set_channel.cpp @@ -1,3 +1,20 @@ +/* + * Copyright (c) 2017, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "mbed.h" #include "greentea-client/test_env.h" #include "unity.h" diff --git a/TESTS/network/wifi/wifi_set_credential.cpp b/TESTS/network/wifi/wifi_set_credential.cpp index b08df974fc6..78f5d604270 100644 --- a/TESTS/network/wifi/wifi_set_credential.cpp +++ b/TESTS/network/wifi/wifi_set_credential.cpp @@ -1,3 +1,20 @@ +/* + * Copyright (c) 2017, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "mbed.h" #include "greentea-client/test_env.h" #include "unity.h" From 3b45287824b23f5de160af2a1e8b3d2e4549eb9e Mon Sep 17 00:00:00 2001 From: "andreas.larsson" Date: Mon, 25 Sep 2017 16:47:38 +0200 Subject: [PATCH 045/108] Moved STDIO_UART defines to targets.json for UBLOX_EVK_ODIN_W2 instead of hardcoded. --- .../TARGET_UBLOX_EVK_ODIN_W2/PeripheralNames.h | 5 ++--- .../TARGET_UBLOX_EVK_ODIN_W2/PinNames.h | 4 ++-- targets/targets.json | 17 ++++++++++++++++- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F439xI/TARGET_UBLOX_EVK_ODIN_W2/PeripheralNames.h b/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F439xI/TARGET_UBLOX_EVK_ODIN_W2/PeripheralNames.h index fb1cdab06b6..fcd76d01523 100644 --- a/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F439xI/TARGET_UBLOX_EVK_ODIN_W2/PeripheralNames.h +++ b/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F439xI/TARGET_UBLOX_EVK_ODIN_W2/PeripheralNames.h @@ -57,9 +57,8 @@ typedef enum { UART_8 = (int)UART8_BASE } UARTName; -#define STDIO_UART_TX PA_9 -#define STDIO_UART_RX PA_10 -#define STDIO_UART UART_1 +#define STDIO_UART_TX USBTX +#define STDIO_UART_RX USBRX typedef enum { SPI_1 = (int)SPI1_BASE, diff --git a/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F439xI/TARGET_UBLOX_EVK_ODIN_W2/PinNames.h b/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F439xI/TARGET_UBLOX_EVK_ODIN_W2/PinNames.h index c4137a2e0f8..1be288b161d 100644 --- a/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F439xI/TARGET_UBLOX_EVK_ODIN_W2/PinNames.h +++ b/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F439xI/TARGET_UBLOX_EVK_ODIN_W2/PinNames.h @@ -166,8 +166,8 @@ typedef enum { BUTTON2 = SW1, // ST-Link - USBRX = PA_10, - USBTX = PA_9, + USBRX = MBED_CONF_TARGET_USB_RX, + USBTX = MBED_CONF_TARGET_USB_TX, SWDIO = PA_15, SWCLK = PA_14, NTRST = PB_4, diff --git a/targets/targets.json b/targets/targets.json index 9c4fb629747..7da9246274d 100644 --- a/targets/targets.json +++ b/targets/targets.json @@ -1704,7 +1704,22 @@ "features": ["LWIP"], "release_versions": ["5"], "device_name": "STM32F439ZI", - "bootloader_supported": true + "bootloader_supported": true, + "config": { + "usb_tx": { + "help": "Value: D8(default) or D1", + "value": "D8" + }, + "usb_rx": { + "help": "Value: D2(default) or D0", + "value": "D2" + }, + "stdio_uart": { + "help": "Value: UART_1(default) or UART_3", + "value": "UART_1", + "macro_name": "STDIO_UART" + } + } }, "UBLOX_C030": { "inherits": ["FAMILY_STM32"], From 10f94e972a33fd8d6940b6b2191c1713a0f3c8d1 Mon Sep 17 00:00:00 2001 From: Tony Wu Date: Sat, 30 Sep 2017 22:30:56 +0800 Subject: [PATCH 046/108] rtl8195am - remove obsolete configs The following configs were no longer necessary for RTX5. OS_TASKCNT OS_MAINSTKSIZE OS_CLOCK Signed-off-by: Tony Wu --- targets/TARGET_Realtek/mbed_rtx.h | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/targets/TARGET_Realtek/mbed_rtx.h b/targets/TARGET_Realtek/mbed_rtx.h index cbf7b73fbc1..9ac21a6be85 100644 --- a/targets/TARGET_Realtek/mbed_rtx.h +++ b/targets/TARGET_Realtek/mbed_rtx.h @@ -40,15 +40,5 @@ #endif #endif -#ifndef OS_TASKCNT -#define OS_TASKCNT 14 -#endif -#ifndef OS_MAINSTKSIZE -#define OS_MAINSTKSIZE 256 -#endif -#ifndef OS_CLOCK -#define OS_CLOCK PLATFORM_CLK -#endif - #endif #endif From b235e0a256e2335825c3592d1d2b2f3d17c4d8fc Mon Sep 17 00:00:00 2001 From: Tony Wu Date: Mon, 2 Oct 2017 14:16:34 +0800 Subject: [PATCH 047/108] rtl8195am - fix ARMC6 guards Fix ARMC6 guard typo introduced in commit 4f3f0cc9cc49 (Make Realtek link) While at it, remove redundant ISR_STACK_SIZE assignment for ARMCC. Signed-off-by: Tony Wu --- targets/TARGET_Realtek/mbed_rtx.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/targets/TARGET_Realtek/mbed_rtx.h b/targets/TARGET_Realtek/mbed_rtx.h index 9ac21a6be85..1da2503cd2c 100644 --- a/targets/TARGET_Realtek/mbed_rtx.h +++ b/targets/TARGET_Realtek/mbed_rtx.h @@ -20,7 +20,7 @@ #include "rtl8195a.h" -#if defined(__CC_ARM) || (defined(__ARMCC_VERSION) || (__ARMCC_VERSION >= 6010050)) +#if defined(__CC_ARM) || (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)) extern uint32_t Image$$ARM_LIB_STACK$$ZI$$Base[]; extern uint32_t Image$$ARM_LIB_STACK$$ZI$$Length[]; #define ISR_STACK_START (unsigned char *)(Image$$ARM_LIB_STACK$$ZI$$Base) @@ -33,8 +33,7 @@ #define INITIAL_SP (__StackTop) #endif - -#if defined(__CC_ARM) || defined(__GNUC__) +#if defined(__GNUC__) #ifndef ISR_STACK_SIZE #define ISR_STACK_SIZE (0x1000) #endif From f926eb430d630bdf740b173ed1de6ce59386292b Mon Sep 17 00:00:00 2001 From: Akos Kiss Date: Sun, 1 Oct 2017 16:06:52 +0200 Subject: [PATCH 048/108] Fix documentation of BLE GattCharacteristic The constructor doc incorrectly suggested that only short (16-bit) UUIDs were accepted. The same doc also referred to properties instead of characteristics. (And to "value length", which seemed to be completely out of place in the context of the current code.) --- features/FEATURE_BLE/ble/GattService.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/features/FEATURE_BLE/ble/GattService.h b/features/FEATURE_BLE/ble/GattService.h index d638b3c9167..bfc7c211dd3 100644 --- a/features/FEATURE_BLE/ble/GattService.h +++ b/features/FEATURE_BLE/ble/GattService.h @@ -46,8 +46,7 @@ class GattService { public: /** - * @brief Creates a new GattService using the specified 16-bit - * UUID, value length, and properties. + * @brief Creates a new GattService using the specified UUID and characteristics. * * @note The UUID value must be unique and is normally >1. * From d1e46c10353ad7d17bb88b05cbd3d1659565e7fb Mon Sep 17 00:00:00 2001 From: Shrikant Tudavekar Date: Sun, 8 Oct 2017 11:08:04 -0500 Subject: [PATCH 049/108] fix echo test handshake and reduce uart load 1) if we receive more than one __sync, previous handshake would consider it as echo_count and try to decode the value. Now we skip superfluous __sync. 2) reduce the uart load produced by the test, as we are heavily running tests in parallel and not one-to-one this update was required. --- TESTS/mbed_drivers/echo/main.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/TESTS/mbed_drivers/echo/main.cpp b/TESTS/mbed_drivers/echo/main.cpp index 8e849c9dd04..6388299c401 100644 --- a/TESTS/mbed_drivers/echo/main.cpp +++ b/TESTS/mbed_drivers/echo/main.cpp @@ -26,13 +26,18 @@ using namespace utest::v1; // Echo server (echo payload to host) template void test_case_echo_server_x() { - char _key[10] = {}; + char _key[11] = {}; char _value[128] = {}; const int echo_count = N; + const char _key_const[] = "echo_count"; + int expected_key = 1; + greentea_send_kv(_key_const, echo_count); // Handshake with host - greentea_send_kv("echo_count", echo_count); - greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value)); + do { + greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value)); + expected_key = strcmp(_key_const, _key); + } while (expected_key); TEST_ASSERT_EQUAL_INT(echo_count, atoi(_value)); for (int i=0; i < echo_count; ++i) { @@ -48,12 +53,10 @@ utest::v1::status_t greentea_failure_handler(const Case *const source, const fai Case cases[] = { Case("Echo server: x16", test_case_echo_server_x<16>, greentea_failure_handler), - Case("Echo server: x32", test_case_echo_server_x<32>, greentea_failure_handler), - Case("Echo server: x64", test_case_echo_server_x<64>, greentea_failure_handler), }; utest::v1::status_t greentea_test_setup(const size_t number_of_cases) { - GREENTEA_SETUP(180, "echo"); + GREENTEA_SETUP(30, "echo"); return greentea_test_setup_handler(number_of_cases); } From 006ca9747827303cdaeec8b8c43629d66d127ce5 Mon Sep 17 00:00:00 2001 From: Rob Meades Date: Mon, 14 Aug 2017 11:44:13 +0100 Subject: [PATCH 050/108] Enable crypto HW acceleration for STM32F437xG platforms (i.e. ublox C030 family). --- .../TARGET_STM32F437xG/mbedtls_device.h | 31 +++++++++++++++++++ targets/targets.json | 2 +- 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 features/mbedtls/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F437xG/mbedtls_device.h diff --git a/features/mbedtls/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F437xG/mbedtls_device.h b/features/mbedtls/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F437xG/mbedtls_device.h new file mode 100644 index 00000000000..dfbc82055ef --- /dev/null +++ b/features/mbedtls/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F437xG/mbedtls_device.h @@ -0,0 +1,31 @@ +/* + * mbedtls_device.h + ******************************************************************************* + * Copyright (c) 2017, STMicroelectronics + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef MBEDTLS_DEVICE_H +#define MBEDTLS_DEVICE_H + +#define MBEDTLS_AES_ALT + +#define MBEDTLS_SHA256_ALT + +#define MBEDTLS_SHA1_ALT + +#define MBEDTLS_MD5_ALT + +#endif /* MBEDTLS_DEVICE_H */ diff --git a/targets/targets.json b/targets/targets.json index 7da9246274d..17b52387c17 100644 --- a/targets/targets.json +++ b/targets/targets.json @@ -1739,7 +1739,7 @@ "macro_name": "MODEM_ON_BOARD_UART" } }, - "macros_add": ["RTC_LSI=1", "HSE_VALUE=12000000", "GNSSBAUD=9600"], + "macros_add": ["MBEDTLS_CONFIG_HW_SUPPORT", "RTC_LSI=1", "HSE_VALUE=12000000", "GNSSBAUD=9600"], "device_has_add": ["ANALOGOUT", "SERIAL_FC", "TRNG", "FLASH"], "features": ["LWIP"], "public": false, From 1c376d6475cbab5335746b1e05a47628bb2a2299 Mon Sep 17 00:00:00 2001 From: Przemyslaw Stekiel Date: Mon, 21 Aug 2017 14:05:49 +0100 Subject: [PATCH 051/108] Add test for Timer class. --- TESTS/mbedmicro-rtos-mbed/timer/main.cpp | 754 +++++++++++++++++++++++ 1 file changed, 754 insertions(+) create mode 100644 TESTS/mbedmicro-rtos-mbed/timer/main.cpp diff --git a/TESTS/mbedmicro-rtos-mbed/timer/main.cpp b/TESTS/mbedmicro-rtos-mbed/timer/main.cpp new file mode 100644 index 00000000000..971e9eb3ee2 --- /dev/null +++ b/TESTS/mbedmicro-rtos-mbed/timer/main.cpp @@ -0,0 +1,754 @@ +/* + * Copyright (c) 2017, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "mbed.h" +#include "greentea-client/test_env.h" +#include "unity.h" +#include "utest.h" +#include "rtos.h" +#include "hal/us_ticker_api.h" + +using namespace utest::v1; + +extern uint32_t SystemCoreClock; + +/* Macro to define delta based on CPU clock frequency. + * + * Note that some extra time is counted by the timer. + * Additional time is caused by the function calls and + * additional operations performed by wait and + * stop functions before in fact timer is stopped. This may + * add additional time to the counted result. + * + * To take in to account this extra time we introduce DELTA + * value based on CPU clock (speed): + * DELTA = TOLERANCE_FACTOR / SystemCoreClock * US_FACTOR + * + * e.g. + * For K64F DELTA = (15000 / 120000000) * 1000000 = 125[us] + * For NUCLEO_F070RB DELTA = (15000 / 48000000) * 1000000 = 312[us] + * For NRF51_DK DELTA = (15000 / 16000000) * 1000000 = 937[us] + */ +#define US_PER_SEC 1000000 +#define TOLERANCE_FACTOR 15000.0f +#define US_FACTOR 1000000.0f + +static const int delta_sys_clk_us = ((int) (TOLERANCE_FACTOR / (float)SystemCoreClock * US_FACTOR)); + +#define DELTA_US delta_sys_clk_us +#define DELTA_S ((float)delta_sys_clk_us/US_PER_SEC) +#define DELTA_MS 1 + +static Timer *p_timer = NULL; + +/* Global variable used to simulate passage of time + * in case when timer which uses user ticker is tested. + */ +static uint32_t curr_ticker_us_val; + +/* User ticker interface function. */ +static void stub_interface_init() +{ + /* do nothing. */ +} + +/* User ticker interface function - only this + * ticker interface function is used by Timer API. */ +static uint32_t stub_ticker_read(void) +{ + /* Simulate elapsed time. */ + return curr_ticker_us_val; +} + +/* User ticker interface function. */ +static void stub_disable_interrupt(void) +{ + /* do nothing. */ +} + +/* User ticker interface function. */ +static void stub_clear_interrupt(void) +{ + /* do nothing. */ +} + +/* User ticker interface function. */ +static void stub_set_interrupt(timestamp_t timestamp) +{ + /* do nothing. */ +} + +/* User ticker interface function. */ +static void stub_fire_interrupt(void) +{ + /* do nothing. */ +} + +/* User ticker event queue. */ +static ticker_event_queue_t my_events = { 0 }; + +/* User ticker interface data. */ +static const ticker_interface_t us_interface = { + .init = stub_interface_init, + .read = stub_ticker_read, /* Only this function is used by the Timer. */ + .disable_interrupt = stub_disable_interrupt, + .clear_interrupt = stub_clear_interrupt, + .set_interrupt = stub_set_interrupt, + .fire_interrupt = stub_fire_interrupt, +}; + +/* User ticker data structure. */ +static const ticker_data_t us_data = { + .interface = &us_interface, + .queue = &my_events +}; + +/* Function which returns user ticker data. */ +const ticker_data_t* get_user_ticker_data(void) +{ + return &us_data; +} + +/* Initialisation of the Timer object which uses + * ticker data provided by the user. + * + * */ +utest::v1::status_t timer_user_ticker_setup_handler(const Case *const source, const size_t index_of_case) +{ + p_timer = new Timer(get_user_ticker_data()); + + /* Check if Timer object has been created. */ + TEST_ASSERT_NOT_NULL(p_timer); + + return greentea_case_setup_handler(source, index_of_case); +} + +/* Initialisation of the Timer object which uses + * default os ticker data. + * + * */ +utest::v1::status_t timer_os_ticker_setup_handler(const Case *const source, const size_t index_of_case) +{ + p_timer = new Timer(); + + /* Check if Timer object has been created. */ + TEST_ASSERT_NOT_NULL(p_timer); + + return greentea_case_setup_handler(source, index_of_case); +} + +/* Test finalisation. + * + * */ +utest::v1::status_t cleanup_handler(const Case *const source, const size_t passed, const size_t failed, const failure_t reason) +{ + delete p_timer; + + p_timer = NULL; + + return greentea_case_teardown_handler(source, passed, failed, reason); +} + +/* This test verifies if timer is stopped after + * creation. + * + * Note: this function assumes that Timer uses os ticker. + * + * Given Timer has been successfully created. + * When read of timer elapsed time is requested. + * Then result is always 0. + */ +void test_timer_creation_os_ticker() +{ + /* Check results. */ + TEST_ASSERT_EQUAL_FLOAT(0, p_timer->read()); + TEST_ASSERT_EQUAL(0, p_timer->read_ms()); + TEST_ASSERT_EQUAL(0, p_timer->read_us()); + TEST_ASSERT_EQUAL(0, p_timer->read_high_resolution_us()); + + /* Wait 10 ms. + * After that operation timer read routines should still return 0. */ + wait_ms(10); + + /* Check results. */ + TEST_ASSERT_EQUAL_FLOAT(0, p_timer->read()); + TEST_ASSERT_EQUAL(0, p_timer->read_ms()); + TEST_ASSERT_EQUAL(0, p_timer->read_us()); + TEST_ASSERT_EQUAL(0, p_timer->read_high_resolution_us()); +} + +/* This test verifies if timer is stopped after + * creation. + * + * Note: this function assumes that Timer uses user/fake ticker + * which returns time value provided in curr_ticker_us_val + * global variable. + * + * Given Timer has been successfully created. + * When read of timer elapsed time is requested. + * Then result is always 0. + */ +void test_timer_creation_user_ticker() +{ + /* For timer which is using user ticker simulate timer + * creation time (irrelevant in case of os ticker). */ + curr_ticker_us_val = 10000; + + /* Check results. */ + TEST_ASSERT_EQUAL_FLOAT(0, p_timer->read()); + TEST_ASSERT_EQUAL(0, p_timer->read_ms()); + TEST_ASSERT_EQUAL(0, p_timer->read_us()); + TEST_ASSERT_EQUAL(0, p_timer->read_high_resolution_us()); + + /* Simulate that 10 ms has elapsed. + * After that operation timer read routines should still return 0. */ + curr_ticker_us_val += 10000; + + /* Check results. */ + TEST_ASSERT_EQUAL_FLOAT(0, p_timer->read()); + TEST_ASSERT_EQUAL(0, p_timer->read_ms()); + TEST_ASSERT_EQUAL(0, p_timer->read_us()); + TEST_ASSERT_EQUAL(0, p_timer->read_high_resolution_us()); +} + +/* This test verifies verifies if read(), read_us(), read_ms(), + * read_high_resolution_us() functions returns valid values. + * + * Note: this function assumes that Timer uses user/fake ticker + * which returns time value provided in curr_ticker_us_val + * global variable. + * + * Given Timer has been successfully created and + * few times started and stopped after a specified period of time. + * When timer read request is performed. + * Then read functions return accumulated time elapsed between starts + * and stops. + */ +void test_timer_time_accumulation_user_ticker() +{ + /* Simulate that current time is equal to 0 us. */ + curr_ticker_us_val = 0; + + /* Start the timer. */ + p_timer->start(); + + /* -- Simulate that current time is equal to 1 us -- */ + curr_ticker_us_val = 1; + + /* Stop the timer. */ + p_timer->stop(); + + /* Check results - 1 us has elapsed. */ + TEST_ASSERT_EQUAL_FLOAT(0.000001f, p_timer->read()); + TEST_ASSERT_EQUAL(0, p_timer->read_ms()); + TEST_ASSERT_EQUAL(1, p_timer->read_us()); + TEST_ASSERT_EQUAL(1, p_timer->read_high_resolution_us()); + + /* Simulate that 100 us has elapsed between stop and start. */ + curr_ticker_us_val = 101; + + /* Start the timer. */ + p_timer->start(); + + /* -- Simulate that current time is equal to 225 us -- */ + curr_ticker_us_val = 225; + + /* Stop the timer. */ + p_timer->stop(); + + /* Check results - 126 us have elapsed. */ + TEST_ASSERT_EQUAL_FLOAT(0.000125f, p_timer->read()); + TEST_ASSERT_EQUAL(0, p_timer->read_ms()); + TEST_ASSERT_EQUAL(125, p_timer->read_us()); + TEST_ASSERT_EQUAL(125, p_timer->read_high_resolution_us()); + + /* Simulate that 100 us has elapsed between stop and start. */ + curr_ticker_us_val = 325; + + /* Start the timer. */ + p_timer->start(); + + /* -- Simulate that current time is equal to 1200 us -- */ + curr_ticker_us_val = 1200; + + /* Stop the timer. */ + p_timer->stop(); + + /* Check results - 1 ms has elapsed. */ + TEST_ASSERT_EQUAL_FLOAT(0.001000f, p_timer->read()); + TEST_ASSERT_EQUAL(1, p_timer->read_ms()); + TEST_ASSERT_EQUAL(1000, p_timer->read_us()); + TEST_ASSERT_EQUAL(1000, p_timer->read_high_resolution_us()); + + /* Simulate that 100 us has elapsed between stop and start. */ + curr_ticker_us_val = 1300; + + /* Start the timer. */ + p_timer->start(); + + /* -- Simulate that current time is equal to 125300 us -- */ + curr_ticker_us_val = 125300; + + /* Stop the timer. */ + p_timer->stop(); + + /* Check results - 125 ms have elapsed. */ + TEST_ASSERT_EQUAL_FLOAT(0.125000f, p_timer->read()); + TEST_ASSERT_EQUAL(125, p_timer->read_ms()); + TEST_ASSERT_EQUAL(125000, p_timer->read_us()); + TEST_ASSERT_EQUAL(125000, p_timer->read_high_resolution_us()); + + /* Simulate that 100 us has elapsed between stop and start. */ + curr_ticker_us_val = 125400; + + /* Start the timer. */ + p_timer->start(); + + /* -- Simulate that current time is equal to 1000400 us -- */ + curr_ticker_us_val = 1000400; + + /* Stop the timer. */ + p_timer->stop(); + + /* Check results - 1 s has elapsed. */ + TEST_ASSERT_EQUAL_FLOAT(1.000000f, p_timer->read()); + TEST_ASSERT_EQUAL(1000, p_timer->read_ms()); + TEST_ASSERT_EQUAL(1000000, p_timer->read_us()); + TEST_ASSERT_EQUAL(1000000, p_timer->read_high_resolution_us()); + + /* Simulate that 100 us has elapsed between stop and start. */ + curr_ticker_us_val = 1000500; + + /* Start the timer. */ + p_timer->start(); + + /* -- Simulate that current time is equal to 125000500 us -- */ + curr_ticker_us_val = 125000500; + + /* Stop the timer. */ + p_timer->stop(); + + /* Check results - 125 s have elapsed. */ + TEST_ASSERT_EQUAL_FLOAT(125.000000f, p_timer->read()); + TEST_ASSERT_EQUAL(125000, p_timer->read_ms()); + TEST_ASSERT_EQUAL(125000000, p_timer->read_us()); + TEST_ASSERT_EQUAL(125000000, p_timer->read_high_resolution_us()); + + /* Simulate that 100 us has elapsed between stop and start. */ + curr_ticker_us_val = 125000600; + + /* Start the timer. */ + p_timer->start(); + + /* -- Simulate that current time is equal to MAX_INT_32 us + 600 us (delays + * between stops and starts) -- */ + + /* Note that ticker is based on unsigned 32-bit int microsecond counters + * while timers are based on 32-bit signed int microsecond counters, + * so timers can only count up to a maximum of 2^31-1 microseconds i.e. + * 2147483647 us (about 35 minutes). */ + curr_ticker_us_val = 2147484247; + + /* Stop the timer. */ + p_timer->stop(); + + /* Check results - 2147483647 (MAX_INT_32) us have elapsed. */ + TEST_ASSERT_EQUAL_FLOAT(2147.483647f, p_timer->read()); + TEST_ASSERT_EQUAL(2147483, p_timer->read_ms()); + TEST_ASSERT_EQUAL(2147483647, p_timer->read_us()); + TEST_ASSERT_EQUAL(2147483647, p_timer->read_high_resolution_us()); +} + +/* This test verifies if read(), read_us(), read_ms(), + * read_high_resolution_us() + * functions return time accumulated between + * timer starts and stops. + * + * Note this function assumes that Timer uses os ticker. + * + * Given Timer has been successfully created and + * few times started and stopped after a specified period of time. + * When timer read request is performed. + * Then read functions return accumulated time elapsed between starts + * and stops. + */ +void test_timer_time_accumulation_os_ticker() +{ + /* Start the timer. */ + p_timer->start(); + + /* Wait 10 ms. */ + wait_ms(10); + + /* Stop the timer. */ + p_timer->stop(); + + /* Check results - totally 10 ms have elapsed. */ + TEST_ASSERT_FLOAT_WITHIN(DELTA_S, 0.010f, p_timer->read()); + TEST_ASSERT_INT32_WITHIN(DELTA_MS, 10, p_timer->read_ms()); + TEST_ASSERT_INT32_WITHIN(DELTA_US, 10000, p_timer->read_us()); + TEST_ASSERT_UINT64_WITHIN(DELTA_US, 10000, p_timer->read_high_resolution_us()); + + /* Wait 50 ms - this is done to show that time elapsed when + * the timer is stopped does not have influence on the + * timer counted time. */ + wait_ms(50); + + /* ------ */ + + /* Start the timer. */ + p_timer->start(); + + /* Wait 20 ms. */ + wait_ms(20); + + /* Stop the timer. */ + p_timer->stop(); + + /* Check results - totally 30 ms have elapsed. */ + TEST_ASSERT_FLOAT_WITHIN(2 * DELTA_S, 0.030f, p_timer->read()); + TEST_ASSERT_INT32_WITHIN(2 * DELTA_MS, 30, p_timer->read_ms()); + TEST_ASSERT_INT32_WITHIN(2 * DELTA_US, 30000, p_timer->read_us()); + TEST_ASSERT_UINT64_WITHIN(2 * DELTA_US, 30000, p_timer->read_high_resolution_us()); + + /* Wait 50 ms - this is done to show that time elapsed when + * the timer is stopped does not have influence on the + * timer counted time. */ + + /* ------ */ + + /* Start the timer. */ + p_timer->start(); + + /* Wait 30 ms. */ + wait_ms(30); + + /* Stop the timer. */ + p_timer->stop(); + + /* Check results - totally 60 ms have elapsed. */ + TEST_ASSERT_FLOAT_WITHIN(3 * DELTA_S, 0.060f, p_timer->read()); + TEST_ASSERT_INT32_WITHIN(3 * DELTA_MS, 60, p_timer->read_ms()); + TEST_ASSERT_INT32_WITHIN(3 * DELTA_US, 60000, p_timer->read_us()); + TEST_ASSERT_UINT64_WITHIN(3 * DELTA_US, 60000, p_timer->read_high_resolution_us()); + + /* Wait 50 ms - this is done to show that time elapsed when + * the timer is stopped does not have influence on the + * timer time. */ + wait_ms(50); + + /* ------ */ + + /* Start the timer. */ + p_timer->start(); + + /* Wait 1 sec. */ + wait_ms(1000); + + /* Stop the timer. */ + p_timer->stop(); + + /* Check results - totally 1060 ms have elapsed. */ + TEST_ASSERT_FLOAT_WITHIN(4 * DELTA_S, 1.060f, p_timer->read()); + TEST_ASSERT_INT32_WITHIN(4 * DELTA_MS, 1060, p_timer->read_ms()); + TEST_ASSERT_INT32_WITHIN(4 * DELTA_US, 1060000, p_timer->read_us()); + TEST_ASSERT_UINT64_WITHIN(4 * DELTA_US, 1060000, p_timer->read_high_resolution_us()); +} + +/* This test verifies if reset() function resets the timer + * counted time. + * + * Note this function assumes that Timer uses os ticker. + * + * Given timer has been started and stopped once, then reset + * operation was performed. + * When timer is started and stopped next time. + * Then timer read functions returns only the the second + * measured time. + */ +void test_timer_reset_os_ticker() +{ + /* First measure 10 ms delay. */ + p_timer->start(); + + /* Wait 10 ms. */ + wait_ms(10); + + /* Stop the timer. */ + p_timer->stop(); + + /* Check results - totally 10 ms elapsed. */ + TEST_ASSERT_FLOAT_WITHIN(DELTA_S, 0.010f, p_timer->read()); + TEST_ASSERT_INT32_WITHIN(DELTA_MS, 10, p_timer->read_ms()); + TEST_ASSERT_INT32_WITHIN(DELTA_US, 10000, p_timer->read_us()); + TEST_ASSERT_UINT64_WITHIN(DELTA_US, 10000, p_timer->read_high_resolution_us()); + + /* Reset the timer - previous measured time should be lost now. */ + p_timer->reset(); + + /* Now measure 20 ms delay. */ + p_timer->start(); + + /* Wait 20 ms. */ + wait_ms(20); + + /* Stop the timer. */ + p_timer->stop(); + + /* Check results - 20 ms elapsed since the reset. */ + TEST_ASSERT_FLOAT_WITHIN(DELTA_S, 0.020f, p_timer->read()); + TEST_ASSERT_INT32_WITHIN(DELTA_MS, 20, p_timer->read_ms()); + TEST_ASSERT_INT32_WITHIN(DELTA_US, 20000, p_timer->read_us()); + TEST_ASSERT_UINT64_WITHIN(DELTA_US, 20000, p_timer->read_high_resolution_us()); +} + +/* This test verifies if reset() function resets the timer + * counted time. + * + * Note this function assumes that Timer uses user ticker. + * + * Given timer has been started and stopped once, then reset + * operation was performed. + * When timer is started and stopped next time. + * Then timer read functions returns only the the second + * measured time. + */ +void test_timer_reset_user_ticker() +{ + /* For timer which is using user ticker simulate set current + * time (irrelevant in case of os ticker). */ + curr_ticker_us_val = 0; + + /* First measure 10 ms delay. */ + p_timer->start(); + + /* Simulate that 10 ms have elapsed. */ + curr_ticker_us_val = 10000; + + /* Stop the timer. */ + p_timer->stop(); + + /* Check results - totally 10 ms elapsed. */ + TEST_ASSERT_FLOAT_WITHIN(DELTA_S, 0.010f, p_timer->read()); + TEST_ASSERT_INT32_WITHIN(DELTA_MS, 10, p_timer->read_ms()); + TEST_ASSERT_INT32_WITHIN(DELTA_US, 10000, p_timer->read_us()); + TEST_ASSERT_UINT64_WITHIN(DELTA_US, 10000, p_timer->read_high_resolution_us()); + + /* Reset the timer - previous measured time should be lost now. */ + p_timer->reset(); + + /* Now measure 20 ms delay. */ + p_timer->start(); + + /* Simulate that 20 ms have elapsed. */ + curr_ticker_us_val = 30000; + + /* Stop the timer. */ + p_timer->stop(); + + /* Check results - 20 ms elapsed since the reset. */ + TEST_ASSERT_FLOAT_WITHIN(DELTA_S, 0.020f, p_timer->read()); + TEST_ASSERT_INT32_WITHIN(DELTA_MS, 20, p_timer->read_ms()); + TEST_ASSERT_INT32_WITHIN(DELTA_US, 20000, p_timer->read_us()); + TEST_ASSERT_UINT64_WITHIN(DELTA_US, 20000, p_timer->read_high_resolution_us()); +} + +/* This test verifies if calling start() for already + * started timer does nothing. + * + * Note this function assumes that Timer uses os ticker. + * + * Given timer is already started. + * When timer is started again. + * Then second start operation is ignored. + */ +void test_timer_start_started_timer_os_ticker() +{ + /* Start the timer. */ + p_timer->start(); + + /* Wait 10 ms. */ + wait_ms(10); + + /* Now start timer again. */ + p_timer->start(); + + /* Wait 20 ms. */ + wait_ms(20); + + /* Stop the timer. */ + p_timer->stop(); + + /* Check results - 30 ms have elapsed since the first start. */ + TEST_ASSERT_FLOAT_WITHIN(2 * DELTA_S, 0.030f, p_timer->read()); + TEST_ASSERT_INT32_WITHIN(2 * DELTA_MS, 30, p_timer->read_ms()); + TEST_ASSERT_INT32_WITHIN(2 * DELTA_US, 30000, p_timer->read_us()); + TEST_ASSERT_UINT64_WITHIN(2 * DELTA_US, 30000, p_timer->read_high_resolution_us()); +} + +/* This test verifies if calling start() for already + * started timer does nothing. + * + * Note this function assumes that Timer uses user ticker. + * + * Given timer is already started. + * When timer is started again. + * Then second start operation is ignored. + */ +void test_timer_start_started_timer_user_ticker() +{ + /* For timer which is using user ticker set current + * time (irrelevant in case of os ticker). */ + curr_ticker_us_val = 0; + + /* Start the timer. */ + p_timer->start(); + + /* Simulate that 10 ms have elapsed. */ + curr_ticker_us_val = 10000; + + /* Now start timer again. */ + p_timer->start(); + + /* Simulate that 20 ms have elapsed. */ + curr_ticker_us_val = 30000; + + /* Stop the timer. */ + p_timer->stop(); + + /* Check results - 30 ms have elapsed since the first start. */ + TEST_ASSERT_FLOAT_WITHIN(2 * DELTA_S, 0.030f, p_timer->read()); + TEST_ASSERT_INT32_WITHIN(2 * DELTA_MS, 30, p_timer->read_ms()); + TEST_ASSERT_INT32_WITHIN(2 * DELTA_US, 30000, p_timer->read_us()); + TEST_ASSERT_UINT64_WITHIN(2 * DELTA_US, 30000, p_timer->read_high_resolution_us()); +} + +/* This test verifies Timer float operator. + * + * Note this function assumes that Timer uses os ticker. + * + * Given timer is created and a time period time is counted. + * When timer object is casted on float type. + * Then counted type in seconds is returned by means of + * read() function. + */ +void test_timer_float_operator_os_ticker() +{ + /* Start the timer. */ + p_timer->start(); + + /* Wait 10 ms. */ + wait_ms(10); + + /* Stop the timer. */ + p_timer->stop(); + + /* Check result - 10 ms elapsed. */ + TEST_ASSERT_FLOAT_WITHIN(DELTA_S, 0.010f, (float)(*p_timer)); +} + +/* This test verifies Timer float operator. + * + * Note this function assumes that Timer uses user ticker. + * + * Given timer is created and a time period time is counted. + * When timer object is casted on float type. + * Then counted type in seconds is returned by means of + * read() function. + */ +void test_timer_float_operator_user_ticker() +{ + /* For timer which is using user ticker set current + * time (irrelevant in case of os ticker). */ + curr_ticker_us_val = 0; + + /* Start the timer. */ + p_timer->start(); + + /* Simulate that 10 ms have elapsed. */ + curr_ticker_us_val = 10000; + + /* Stop the timer. */ + p_timer->stop(); + + /* Check result - 10 ms elapsed. */ + TEST_ASSERT_FLOAT_WITHIN(DELTA_S, 0.010f, (float)(*p_timer)); +} + +/* This test verifies if time counted by the timer is + * valid. + * + * For this test Timer which uses os ticker + * must be used. + * + * Given timer is created. + * When timer is used to measure 1ms/10ms/100ms/1s + * delays. + * Then the results are valid (within acceptable range). + */ +template +void test_timer_time_measurement() +{ + /* Start the timer. */ + p_timer->start(); + + /* Wait us. */ + wait_us(wait_val_us); + + /* Stop the timer. */ + p_timer->stop(); + + /* Check results. */ + TEST_ASSERT_FLOAT_WITHIN(DELTA_S, (float)wait_val_us / 1000000, p_timer->read()); + TEST_ASSERT_INT32_WITHIN(DELTA_MS, wait_val_us / 1000, p_timer->read_ms()); + TEST_ASSERT_INT32_WITHIN(DELTA_US, wait_val_us, p_timer->read_us()); + TEST_ASSERT_UINT64_WITHIN(DELTA_US, wait_val_us, p_timer->read_high_resolution_us()); +} + +utest::v1::status_t test_setup(const size_t number_of_cases) { + GREENTEA_SETUP(15, "default_auto"); + return verbose_test_setup_handler(number_of_cases); +} + +Case cases[] = { + Case("Test: Timer (based on os ticker) is stopped after creation.", timer_os_ticker_setup_handler, test_timer_creation_os_ticker, cleanup_handler), + Case("Test: Timer (based on user ticker) is stopped after creation.", timer_user_ticker_setup_handler, test_timer_creation_user_ticker, cleanup_handler), + + Case("Test: Timer (based on os ticker) - measured time accumulation.", timer_os_ticker_setup_handler, test_timer_time_accumulation_os_ticker, cleanup_handler), + Case("Test: Timer (based on user ticker) measured time accumulation.", timer_user_ticker_setup_handler, test_timer_time_accumulation_user_ticker, cleanup_handler), + + Case("Test: Timer (based on os ticker) - reset.", timer_os_ticker_setup_handler, test_timer_reset_os_ticker, cleanup_handler), + Case("Test: Timer (based on user ticker) - reset.", timer_user_ticker_setup_handler, test_timer_reset_user_ticker, cleanup_handler), + + Case("Test: Timer (based on os ticker) - start started timer.", timer_os_ticker_setup_handler, test_timer_start_started_timer_os_ticker, cleanup_handler), + Case("Test: Timer (based on user ticker) - start started timer.", timer_user_ticker_setup_handler, test_timer_start_started_timer_user_ticker, cleanup_handler), + + Case("Test: Timer (based on os ticker) - float operator.", timer_os_ticker_setup_handler, test_timer_float_operator_os_ticker, cleanup_handler), + Case("Test: Timer (based on user ticker) - float operator.", timer_user_ticker_setup_handler, test_timer_float_operator_user_ticker, cleanup_handler), + + Case("Test: Timer - time measurement 1 ms.", timer_os_ticker_setup_handler, test_timer_time_measurement<1000>, cleanup_handler), + Case("Test: Timer - time measurement 10 ms.", timer_os_ticker_setup_handler, test_timer_time_measurement<10000>, cleanup_handler), + Case("Test: Timer - time measurement 100 ms.", timer_os_ticker_setup_handler, test_timer_time_measurement<100000>, cleanup_handler), + Case("Test: Timer - time measurement 1 s.", timer_os_ticker_setup_handler, test_timer_time_measurement<1000000>, cleanup_handler), +}; + +Specification specification(test_setup, cases); + +int main() { + return !Harness::run(specification); +} + From 76deb7ee21848a8e135e9fb7ab925c6be731f3f6 Mon Sep 17 00:00:00 2001 From: Vincent Coubard Date: Wed, 13 Sep 2017 10:28:02 +0100 Subject: [PATCH 052/108] Sleep: Disallow sleep for targets turning of the systick clock at sleep entry. When the RTOS is present and the tickless mode is not implemented, it is expected that the next tick issued by the Systick timer will wake up the MCU. However nothing prevents an implementation of the ARM architecture to gate the systick clock signal upon sleep entry. Therefore on those targets sleep shall be prohibited if the RTOS is present and the tickless mode is not implemented. To ease life of porters , a new option has been added in the device add list: STCLK_OF_DURING_SLEEP. This option expose that the target turn of the systick clock during sleep. Targets which exhibit such behavior shall add this define in their device_has list. --- platform/mbed_sleep.h | 16 +++++++++++----- targets/targets.json | 9 +++++---- tools/targets/lint.py | 2 +- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/platform/mbed_sleep.h b/platform/mbed_sleep.h index a7dfb37d2c1..4f635d452ae 100644 --- a/platform/mbed_sleep.h +++ b/platform/mbed_sleep.h @@ -62,13 +62,13 @@ extern "C" { /** Lock the deep sleep mode * - * This locks the automatic deep mode selection. + * This locks the automatic deep mode selection. * sleep_manager_sleep_auto() will ignore deepsleep mode if * this function is invoked at least once (the internal counter is non-zero) * * Use this locking mechanism for interrupt driven API that are * running in the background and deepsleep could affect their functionality - * + * * The lock is a counter, can be locked up to USHRT_MAX * This function is IRQ and thread safe */ @@ -76,8 +76,8 @@ void sleep_manager_lock_deep_sleep(void); /** Unlock the deep sleep mode * - * Use unlocking in pair with sleep_manager_lock_deep_sleep(). - * + * Use unlocking in pair with sleep_manager_lock_deep_sleep(). + * * The lock is a counter, should be equally unlocked as locked * This function is IRQ and thread safe */ @@ -97,7 +97,7 @@ bool sleep_manager_can_deep_sleep(void); * @note * If MBED_DEBUG is defined, only hal_sleep is allowed. This ensures the debugger * to be active for debug modes. - * + * */ void sleep_manager_sleep_auto(void); @@ -106,6 +106,10 @@ void sleep_manager_sleep_auto(void); * @note This function can be a noop if not implemented by the platform. * @note This function will be a noop in debug mode (debug build profile when MBED_DEBUG is defined). * @note This function will be a noop while uVisor is in use. + * @note This function will be a noop if the following conditions are met: + * - The RTOS is present + * - The processor turn off the Systick clock during sleep + * - The target does not implement tickless mode * * The processor is setup ready for sleep, and sent to sleep using __WFI(). In this mode, the * system clock to the core is stopped until a reset or an interrupt occurs. This eliminates @@ -123,7 +127,9 @@ __INLINE static void sleep(void) { #if !(defined(FEATURE_UVISOR) && defined(TARGET_UVISOR_SUPPORTED)) #if DEVICE_SLEEP +#if (MBED_CONF_RTOS_PRESENT == 0) || (DEVICE_STCLK_OFF_DURING_SLEEP == 0) || defined(MBED_TICKLESS) sleep_manager_sleep_auto(); +#endif /* (MBED_CONF_RTOS_PRESENT == 0) || (DEVICE_STCLK_OFF_DURING_SLEEP == 0) || defined(MBED_TICKLESS) */ #endif /* DEVICE_SLEEP */ #endif /* !(defined(FEATURE_UVISOR) && defined(TARGET_UVISOR_SUPPORTED)) */ } diff --git a/targets/targets.json b/targets/targets.json index 17b52387c17..42978d30305 100644 --- a/targets/targets.json +++ b/targets/targets.json @@ -3025,6 +3025,7 @@ "inherits": ["Target"], "core": "Cortex-M4F", "macros": ["NRF52", "TARGET_NRF52832", "BLE_STACK_SUPPORT_REQD", "SOFTDEVICE_PRESENT", "S132", "CMSIS_VECTAB_VIRTUAL", "CMSIS_VECTAB_VIRTUAL_HEADER_FILE=\"cmsis_nvic.h\"", "MBED_TICKLESS"], + "device_has": ["STCLK_OFF_DURING_SLEEP"], "extra_labels": ["NORDIC", "MCU_NRF52", "MCU_NRF52832", "NRF5", "SDK11", "NRF52_COMMON"], "OUTPUT_EXT": "hex", "is_disk_virtual": true, @@ -3062,14 +3063,14 @@ "supported_form_factors": ["ARDUINO"], "inherits": ["MCU_NRF52"], "macros_add": ["BOARD_PCA10040", "NRF52_PAN_12", "NRF52_PAN_15", "NRF52_PAN_58", "NRF52_PAN_55", "NRF52_PAN_54", "NRF52_PAN_31", "NRF52_PAN_30", "NRF52_PAN_51", "NRF52_PAN_36", "NRF52_PAN_53", "S132", "CONFIG_GPIO_AS_PINRESET", "BLE_STACK_SUPPORT_REQD", "SWI_DISABLE0", "NRF52_PAN_20", "NRF52_PAN_64", "NRF52_PAN_62", "NRF52_PAN_63"], - "device_has": ["ANALOGIN", "I2C", "I2C_ASYNCH", "INTERRUPTIN", "LOWPOWERTIMER", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SERIAL_ASYNCH", "SERIAL_FC", "SLEEP", "SPI", "SPI_ASYNCH", "SPISLAVE"], + "device_has_add": ["ANALOGIN", "I2C", "I2C_ASYNCH", "INTERRUPTIN", "LOWPOWERTIMER", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SERIAL_ASYNCH", "SERIAL_FC", "SLEEP", "SPI", "SPI_ASYNCH", "SPISLAVE"], "release_versions": ["2", "5"], "device_name": "nRF52832_xxAA" }, "UBLOX_EVA_NINA": { "inherits": ["MCU_NRF52"], "macros_add": ["BOARD_PCA10040", "NRF52_PAN_12", "NRF52_PAN_15", "NRF52_PAN_58", "NRF52_PAN_55", "NRF52_PAN_54", "NRF52_PAN_31", "NRF52_PAN_30", "NRF52_PAN_51", "NRF52_PAN_36", "NRF52_PAN_53", "S132", "CONFIG_GPIO_AS_PINRESET", "BLE_STACK_SUPPORT_REQD", "SWI_DISABLE0", "NRF52_PAN_20", "NRF52_PAN_64", "NRF52_PAN_62", "NRF52_PAN_63"], - "device_has": ["ANALOGIN", "I2C", "I2C_ASYNCH", "INTERRUPTIN", "LOWPOWERTIMER", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SERIAL_ASYNCH", "SERIAL_FC", "SLEEP", "SPI", "SPI_ASYNCH", "SPISLAVE"], + "device_has_add": ["ANALOGIN", "I2C", "I2C_ASYNCH", "INTERRUPTIN", "LOWPOWERTIMER", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SERIAL_ASYNCH", "SERIAL_FC", "SLEEP", "SPI", "SPI_ASYNCH", "SPISLAVE"], "release_versions": ["2", "5"], "overrides": {"uart_hwfc": 0}, "device_name": "nRF52832_xxAA" @@ -3078,7 +3079,7 @@ "supported_form_factors": ["ARDUINO"], "inherits": ["MCU_NRF52"], "macros_add": ["BOARD_PCA10040", "NRF52_PAN_12", "NRF52_PAN_15", "NRF52_PAN_58", "NRF52_PAN_55", "NRF52_PAN_54", "NRF52_PAN_31", "NRF52_PAN_30", "NRF52_PAN_51", "NRF52_PAN_36", "NRF52_PAN_53", "S132", "CONFIG_GPIO_AS_PINRESET", "BLE_STACK_SUPPORT_REQD", "SWI_DISABLE0", "NRF52_PAN_20", "NRF52_PAN_64", "NRF52_PAN_62", "NRF52_PAN_63"], - "device_has": ["ANALOGIN", "I2C", "I2C_ASYNCH", "INTERRUPTIN", "LOWPOWERTIMER", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SERIAL_ASYNCH", "SERIAL_FC", "SLEEP", "SPI", "SPI_ASYNCH", "SPISLAVE"], + "device_has_add": ["ANALOGIN", "I2C", "I2C_ASYNCH", "INTERRUPTIN", "LOWPOWERTIMER", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SERIAL_ASYNCH", "SERIAL_FC", "SLEEP", "SPI", "SPI_ASYNCH", "SPISLAVE"], "release_versions": ["2", "5"], "device_name": "nRF52832_xxAA" }, @@ -3086,7 +3087,7 @@ "supported_form_factors": ["ARDUINO"], "inherits": ["MCU_NRF52"], "macros_add": ["BOARD_PCA10040", "NRF52_PAN_12", "NRF52_PAN_15", "NRF52_PAN_58", "NRF52_PAN_55", "NRF52_PAN_54", "NRF52_PAN_31", "NRF52_PAN_30", "NRF52_PAN_51", "NRF52_PAN_36", "NRF52_PAN_53", "S132", "CONFIG_GPIO_AS_PINRESET", "BLE_STACK_SUPPORT_REQD", "SWI_DISABLE0", "NRF52_PAN_20", "NRF52_PAN_64", "NRF52_PAN_62", "NRF52_PAN_63"], - "device_has": ["ANALOGIN", "I2C", "I2C_ASYNCH", "INTERRUPTIN", "LOWPOWERTIMER", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SERIAL_ASYNCH", "SLEEP", "SPI", "SPI_ASYNCH", "SPISLAVE"], + "device_has_had": ["ANALOGIN", "I2C", "I2C_ASYNCH", "INTERRUPTIN", "LOWPOWERTIMER", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SERIAL_ASYNCH", "SLEEP", "SPI", "SPI_ASYNCH", "SPISLAVE"], "release_versions": ["2", "5"], "overrides": {"lf_clock_src": "NRF_LF_SRC_RC"}, "config": { diff --git a/tools/targets/lint.py b/tools/targets/lint.py index f83838d8b3e..0202d45a315 100644 --- a/tools/targets/lint.py +++ b/tools/targets/lint.py @@ -82,7 +82,7 @@ def check_inherits(dict): "LOWPOWERTIMER", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "TRNG","SERIAL", "SERIAL_ASYNCH", "SERIAL_FC", "SLEEP", "SPI", "SPI_ASYNCH", "SPISLAVE", - "STORAGE"] + "STORAGE", "STCLK_OFF_DURING_SLEEP"] def check_device_has(dict): for name in dict.get("device_has", []): if name not in DEVICE_HAS_ALLOWED: From a3ef05dd315c326236e21971cc9ff2c17f5f21e4 Mon Sep 17 00:00:00 2001 From: Vincent Coubard Date: Mon, 25 Sep 2017 17:47:16 +0100 Subject: [PATCH 053/108] Fix typo in DELTA_DFBM_NQ620 target Replace `device_has_had` by `device_has_add` --- targets/targets.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/targets/targets.json b/targets/targets.json index 42978d30305..b764eb0277c 100644 --- a/targets/targets.json +++ b/targets/targets.json @@ -3087,7 +3087,7 @@ "supported_form_factors": ["ARDUINO"], "inherits": ["MCU_NRF52"], "macros_add": ["BOARD_PCA10040", "NRF52_PAN_12", "NRF52_PAN_15", "NRF52_PAN_58", "NRF52_PAN_55", "NRF52_PAN_54", "NRF52_PAN_31", "NRF52_PAN_30", "NRF52_PAN_51", "NRF52_PAN_36", "NRF52_PAN_53", "S132", "CONFIG_GPIO_AS_PINRESET", "BLE_STACK_SUPPORT_REQD", "SWI_DISABLE0", "NRF52_PAN_20", "NRF52_PAN_64", "NRF52_PAN_62", "NRF52_PAN_63"], - "device_has_had": ["ANALOGIN", "I2C", "I2C_ASYNCH", "INTERRUPTIN", "LOWPOWERTIMER", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SERIAL_ASYNCH", "SLEEP", "SPI", "SPI_ASYNCH", "SPISLAVE"], + "device_has_add": ["ANALOGIN", "I2C", "I2C_ASYNCH", "INTERRUPTIN", "LOWPOWERTIMER", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SERIAL_ASYNCH", "SLEEP", "SPI", "SPI_ASYNCH", "SPISLAVE"], "release_versions": ["2", "5"], "overrides": {"lf_clock_src": "NRF_LF_SRC_RC"}, "config": { From 3e3b70ed83062b1c31597db350c8d8e2c5f78b33 Mon Sep 17 00:00:00 2001 From: Vincent Coubard Date: Thu, 28 Sep 2017 09:43:58 +0100 Subject: [PATCH 054/108] NRF52840: add the device configuration STCLK_OFF_DURING_SLEEP --- targets/targets.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/targets/targets.json b/targets/targets.json index b764eb0277c..e2d1364b5bc 100644 --- a/targets/targets.json +++ b/targets/targets.json @@ -3106,6 +3106,7 @@ "inherits": ["Target"], "core": "Cortex-M4F", "macros": ["TARGET_NRF52840", "BLE_STACK_SUPPORT_REQD", "SOFTDEVICE_PRESENT", "S140", "NRF_SD_BLE_API_VERSION=5", "NRF52840_XXAA", "NRF_DFU_SETTINGS_VERSION=1", "NRF_SD_BLE_API_VERSION=5", "CMSIS_VECTAB_VIRTUAL", "CMSIS_VECTAB_VIRTUAL_HEADER_FILE=\"cmsis_nvic.h\""], + "device_has": ["STCLK_OFF_DURING_SLEEP"], "extra_labels": ["NORDIC", "MCU_NRF52840", "NRF5", "SDK13", "NRF52_COMMON"], "OUTPUT_EXT": "hex", "is_disk_virtual": true, @@ -3144,7 +3145,7 @@ "supported_form_factors": ["ARDUINO"], "inherits": ["MCU_NRF52840"], "macros_add": ["BOARD_PCA10056", "CONFIG_GPIO_AS_PINRESET", "SWI_DISABLE0", "NRF52_ERRATA_20"], - "device_has": ["FLASH", "ANALOGIN", "I2C", "I2C_ASYNCH", "INTERRUPTIN", "LOWPOWERTIMER", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SERIAL_ASYNCH", "SERIAL_FC", "SLEEP", "SPI", "SPISLAVE", "TRNG"], + "device_has_add": ["FLASH", "ANALOGIN", "I2C", "I2C_ASYNCH", "INTERRUPTIN", "LOWPOWERTIMER", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SERIAL_ASYNCH", "SERIAL_FC", "SLEEP", "SPI", "SPISLAVE", "TRNG"], "release_versions": ["2", "5"], "device_name": "nRF52840_xxAA" }, From 1f258ce367c4ca09ab1b82ac07cdea8e2c9a3432 Mon Sep 17 00:00:00 2001 From: Martin Kojtal <0xc0170@gmail.com> Date: Wed, 20 Sep 2017 09:32:13 +0100 Subject: [PATCH 055/108] Test: deepsleep() API replacement Use sleep() as entry function + check to be certain we are entering deepsleep when required by test (should be allowed) --- TESTS/mbed_drivers/lp_timeout/main.cpp | 7 ++++++- TESTS/mbed_hal/lp_ticker/main.cpp | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/TESTS/mbed_drivers/lp_timeout/main.cpp b/TESTS/mbed_drivers/lp_timeout/main.cpp index df56388dc5b..9a16d6bdfbd 100644 --- a/TESTS/mbed_drivers/lp_timeout/main.cpp +++ b/TESTS/mbed_drivers/lp_timeout/main.cpp @@ -59,7 +59,10 @@ void lp_timeout_1s_deepsleep(void) */ timer.start(); lpt.attach(&cb_done, 1); - deepsleep(); + /* Make sure deepsleep is allowed, to go to deepsleep */ + bool deep_sleep_allowed = sleep_manager_can_deep_sleep(); + TEST_ASSERT_TRUE_MESSAGE(deep_sleep_allowed, "Deep sleep should be allowed"); + sleep(); while (!complete); /* It takes longer to wake up from deep sleep */ @@ -75,6 +78,8 @@ void lp_timeout_1s_sleep(void) sleep_manager_lock_deep_sleep(); lpt.attach(&cb_done, 1); + bool deep_sleep_allowed = sleep_manager_can_deep_sleep(); + TEST_ASSERT_FALSE_MESSAGE(deep_sleep_allowed, "Deep sleep should be disallowed"); sleep(); while (!complete); sleep_manager_unlock_deep_sleep(); diff --git a/TESTS/mbed_hal/lp_ticker/main.cpp b/TESTS/mbed_hal/lp_ticker/main.cpp index c609c57b8a6..5802644c580 100644 --- a/TESTS/mbed_hal/lp_ticker/main.cpp +++ b/TESTS/mbed_hal/lp_ticker/main.cpp @@ -104,7 +104,10 @@ void lp_ticker_1s_deepsleep() lp_timer.reset(); lp_timer.start(); ticker_insert_event(lp_ticker_data, &delay_event, delay_ts, (uint32_t)&delay_event); - deepsleep(); + /* Make sure deepsleep is allowed, to go to deepsleep */ + bool deep_sleep_allowed = sleep_manager_can_deep_sleep(); + TEST_ASSERT_TRUE_MESSAGE(deep_sleep_allowed, "Deep sleep should be allowed"); + sleep(); while (!complete); lp_timer.stop(); @@ -124,6 +127,8 @@ void lp_ticker_1s_sleep() sleep_manager_lock_deep_sleep(); timer.reset(); timer.start(); + bool deep_sleep_allowed = sleep_manager_can_deep_sleep(); + TEST_ASSERT_FALSE_MESSAGE(deep_sleep_allowed, "Deep sleep should be disallowed"); ticker_insert_event(lp_ticker_data, &delay_event, delay_ts, (uint32_t)&delay_event); sleep(); while (!complete); From 075993e009d1b277e79270b0c0b6e573806fc490 Mon Sep 17 00:00:00 2001 From: Andrzej Puzdrowski Date: Mon, 25 Sep 2017 11:32:42 +0200 Subject: [PATCH 056/108] fix bug: I2C timeout due the clos strething by slave on nRFx SoC Change implementation of timeout to one that is using us_ticker hal. Timeout is now configurable by I2C_TIMEOUT_VALUE_US macro and this value will be imported if will be defined externaly. --- targets/TARGET_NORDIC/TARGET_NRF5/i2c_api.c | 46 +++++++++++++++------ 1 file changed, 33 insertions(+), 13 deletions(-) diff --git a/targets/TARGET_NORDIC/TARGET_NRF5/i2c_api.c b/targets/TARGET_NORDIC/TARGET_NRF5/i2c_api.c index e8d07601fcd..c6629680174 100644 --- a/targets/TARGET_NORDIC/TARGET_NRF5/i2c_api.c +++ b/targets/TARGET_NORDIC/TARGET_NRF5/i2c_api.c @@ -50,10 +50,14 @@ #include "nrf_gpio.h" #include "nrf_delay.h" -// An arbitrary value used as the counter in loops waiting for given event -// (e.g. STOPPED), needed to avoid infinite loops (and not involve any timers -// or tickers). -#define TIMEOUT_VALUE 1000 +#include "us_ticker_api.h" + +// An arbitrary value used as the timeout in loops waiting for given event +// (e.g. STOPPED), needed to avoid infinite loops. +// This value might be defined externally. +#ifndef I2C_TIMEOUT_VALUE_US + #define I2C_TIMEOUT_VALUE_US 1000000 +#endif #if DEVICE_I2C_ASYNCH #define TWI_IDX(obj) ((obj)->i2c.twi_idx) @@ -371,17 +375,20 @@ int i2c_start(i2c_t *obj) int i2c_stop(i2c_t *obj) { NRF_TWI_Type *twi = m_twi_instances[TWI_IDX(obj)]; + uint32_t t0; // The current transfer may be suspended (if it is RX), so it must be // resumed before the STOP task is triggered. nrf_twi_task_trigger(twi, NRF_TWI_TASK_RESUME); nrf_twi_task_trigger(twi, NRF_TWI_TASK_STOP); - uint32_t remaining_time = TIMEOUT_VALUE; + + t0 = ticker_read(get_us_ticker_data()); + do { if (nrf_twi_event_check(twi, NRF_TWI_EVENT_STOPPED)) { return 0; } - } while (--remaining_time); + } while (((uint32_t)ticker_read(get_us_ticker_data()) - t0) < I2C_TIMEOUT_VALUE_US); return 1; } @@ -464,11 +471,15 @@ int i2c_read(i2c_t *obj, int address, char *data, int length, int stop) static uint8_t twi_byte_write(NRF_TWI_Type *twi, uint8_t data) { + uint32_t t0; + nrf_twi_event_clear(twi, NRF_TWI_EVENT_TXDSENT); nrf_twi_event_clear(twi, NRF_TWI_EVENT_ERROR); nrf_twi_txd_set(twi, data); - uint32_t remaining_time = TIMEOUT_VALUE; + + t0 = ticker_read(get_us_ticker_data()); + do { if (nrf_twi_event_check(twi, NRF_TWI_EVENT_TXDSENT)) { nrf_twi_event_clear(twi, NRF_TWI_EVENT_TXDSENT); @@ -478,7 +489,7 @@ static uint8_t twi_byte_write(NRF_TWI_Type *twi, uint8_t data) nrf_twi_event_clear(twi, NRF_TWI_EVENT_ERROR); return 0; // some error occurred } - } while (--remaining_time); + } while (((uint32_t)ticker_read(get_us_ticker_data()) - t0) < I2C_TIMEOUT_VALUE_US); return 2; // timeout; } @@ -500,6 +511,9 @@ static void start_twi_write(NRF_TWI_Type *twi, int address) int i2c_write(i2c_t *obj, int address, const char *data, int length, int stop) { twi_info_t *twi_info = TWI_INFO(obj); + bool timeout = false; + uint32_t t0, t1; + #if DEVICE_I2C_ASYNCH if (twi_info->active) { return I2C_ERROR_BUS_BUSY; @@ -522,12 +536,16 @@ int i2c_write(i2c_t *obj, int address, const char *data, int length, int stop) nrf_twi_event_clear(twi, event); nrf_twi_task_trigger(twi, NRF_TWI_TASK_SUSPEND); } - uint32_t remaining_time = TIMEOUT_VALUE; + + t0 = ticker_read(get_us_ticker_data()); + do { if (nrf_twi_event_check(twi, event)) { break; } - } while (--remaining_time); + t1 = ticker_read(get_us_ticker_data()); + timeout = (t1 - t0) >= I2C_TIMEOUT_VALUE_US; + } while (!timeout); uint32_t errorsrc = nrf_twi_errorsrc_get_and_clear(twi); if (errorsrc & NRF_TWI_ERROR_ADDRESS_NACK) { @@ -537,7 +555,7 @@ int i2c_write(i2c_t *obj, int address, const char *data, int length, int stop) return I2C_ERROR_NO_SLAVE; } - return (remaining_time ? 0 : I2C_ERROR_BUS_BUSY); + return (timeout ? I2C_ERROR_BUS_BUSY : 0); } int result = length; @@ -574,13 +592,15 @@ int i2c_write(i2c_t *obj, int address, const char *data, int length, int stop) int i2c_byte_read(i2c_t *obj, int last) { NRF_TWI_Type *twi = m_twi_instances[TWI_IDX(obj)]; + uint32_t t0; if (last) { nrf_twi_shorts_set(twi, NRF_TWI_SHORT_BB_STOP_MASK); } nrf_twi_task_trigger(twi, NRF_TWI_TASK_RESUME); - uint32_t remaining_time = TIMEOUT_VALUE; + t0 = ticker_read(get_us_ticker_data()); + do { if (nrf_twi_event_check(twi, NRF_TWI_EVENT_RXDREADY)) { nrf_twi_event_clear(twi, NRF_TWI_EVENT_RXDREADY); @@ -590,7 +610,7 @@ int i2c_byte_read(i2c_t *obj, int last) nrf_twi_event_clear(twi, NRF_TWI_EVENT_ERROR); return I2C_ERROR_NO_SLAVE; } - } while (--remaining_time); + } while (((uint32_t)ticker_read(get_us_ticker_data()) - t0) < I2C_TIMEOUT_VALUE_US); return I2C_ERROR_BUS_BUSY; } From 25400d573028e1b8dea1aee65eda7d5f399e2d26 Mon Sep 17 00:00:00 2001 From: Kevin Bracey Date: Thu, 28 Sep 2017 10:44:43 +0300 Subject: [PATCH 057/108] Avoid wait_ms() spin System's wait_ms() spins to achieve a precise delay - we don't want this. Call Thread::wait directly. --- drivers/UARTSerial.cpp | 16 ++++++++++++++++ drivers/UARTSerial.h | 2 ++ 2 files changed, 18 insertions(+) diff --git a/drivers/UARTSerial.cpp b/drivers/UARTSerial.cpp index 96cdc831d84..5cad4ffc827 100644 --- a/drivers/UARTSerial.cpp +++ b/drivers/UARTSerial.cpp @@ -19,7 +19,12 @@ #include #include "UARTSerial.h" #include "platform/mbed_poll.h" + +#if MBED_CONF_RTOS_PRESENT +#include "rtos/Thread.h" +#else #include "platform/mbed_wait_api.h" +#endif namespace mbed { @@ -277,6 +282,17 @@ void UARTSerial::tx_irq(void) } } +void UARTSerial::wait_ms(uint32_t millisec) +{ + /* wait_ms implementation for RTOS spins until exact microseconds - we + * want to just sleep until next tick. + */ +#if MBED_CONF_RTOS_PRESENT + rtos::Thread::wait(millisec); +#else + ::wait_ms(millisec); +#endif +} } //namespace mbed #endif //(DEVICE_SERIAL && DEVICE_INTERRUPTIN) diff --git a/drivers/UARTSerial.h b/drivers/UARTSerial.h index a269dea2855..c0069adcb75 100644 --- a/drivers/UARTSerial.h +++ b/drivers/UARTSerial.h @@ -166,6 +166,8 @@ class UARTSerial : private SerialBase, public FileHandle, private NonCopyable Date: Mon, 2 Oct 2017 09:59:24 +0300 Subject: [PATCH 058/108] Make poll() use wait(1) rather than yield() Spinning while polling is overly CPU intensive, and inconsistent with the current blocking behaviour of UARTSerial. Change to use Thread::wait(1) to match UARTSerial. --- platform/mbed_poll.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/mbed_poll.cpp b/platform/mbed_poll.cpp index 28492010d42..c2a08fa3ddb 100644 --- a/platform/mbed_poll.cpp +++ b/platform/mbed_poll.cpp @@ -66,7 +66,7 @@ int poll(pollfh fhs[], unsigned nfhs, int timeout) #ifdef MBED_CONF_RTOS_PRESENT // TODO - proper blocking // wait for condition variable, wait queue whatever here - rtos::Thread::yield(); + rtos::Thread::wait(1); #endif } return count; From 6e0cd31525659a270386c40c2c7bba15a81faca7 Mon Sep 17 00:00:00 2001 From: Przemyslaw Stekiel Date: Tue, 12 Sep 2017 08:06:41 +0200 Subject: [PATCH 059/108] Add Low Power Timer test. --- TESTS/mbed_drivers/lp_timer/main.cpp | 345 +++++++++++++++++++++++++++ 1 file changed, 345 insertions(+) create mode 100644 TESTS/mbed_drivers/lp_timer/main.cpp diff --git a/TESTS/mbed_drivers/lp_timer/main.cpp b/TESTS/mbed_drivers/lp_timer/main.cpp new file mode 100644 index 00000000000..33b1e6cef95 --- /dev/null +++ b/TESTS/mbed_drivers/lp_timer/main.cpp @@ -0,0 +1,345 @@ +/* + * Copyright (c) 2017, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "mbed.h" +#include "greentea-client/test_env.h" +#include "unity.h" +#include "utest.h" +#include "rtos.h" +#include "hal/us_ticker_api.h" + +#if !DEVICE_LOWPOWERTIMER +#error [NOT_SUPPORTED] test not supported +#endif + +using namespace utest::v1; + +extern uint32_t SystemCoreClock; + +/* This test is created based on the test for Timer class. + * Since low power timer is less accurate than regular + * timer we need to adjust delta. + */ + +/* Macro to define delta based on CPU clock frequency. + * + * Note that some extra time is counted by the timer. + * Additional time is caused by the function calls and + * additional operations performed by wait and + * stop functions before in fact timer is stopped. This may + * add additional time to the counted result. + * + * To take in to account this extra time we introduce DELTA + * value based on CPU clock (speed): + * DELTA = TOLERANCE_FACTOR / SystemCoreClock * US_FACTOR + * + * e.g. + * For K64F DELTA = (40000 / 120000000) * 1000000 = 333[us] + * For NUCLEO_F070RB DELTA = (40000 / 48000000) * 1000000 = 833[us] + * For NRF51_DK DELTA = (40000 / 16000000) * 1000000 = 2500[us] + */ +#define US_PER_SEC 1000000 +#define TOLERANCE_FACTOR 40000.0f +#define US_FACTOR 1000000.0f + +static const int delta_sys_clk_us = ((int) (TOLERANCE_FACTOR / (float) SystemCoreClock * US_FACTOR)); + +#define DELTA_US delta_sys_clk_us +#define DELTA_S ((float)delta_sys_clk_us/US_PER_SEC) +#define DELTA_MS 1 + +/* This test verifies if low power timer is stopped after + * creation. + * + * Given Timer has been successfully created. + * When read of timer elapsed time is requested. + * Then result is always 0. + */ +void test_lptimer_creation() +{ + LowPowerTimer lp_timer; + + /* Check results. */ + TEST_ASSERT_EQUAL_FLOAT(0, lp_timer.read()); + TEST_ASSERT_EQUAL(0, lp_timer.read_ms()); + TEST_ASSERT_EQUAL(0, lp_timer.read_us()); + TEST_ASSERT_EQUAL(0, lp_timer.read_high_resolution_us()); + + /* Wait 10 ms. + * After that operation timer read routines should still return 0. */ + wait_ms(10); + + /* Check results. */ + TEST_ASSERT_EQUAL_FLOAT(0, lp_timer.read()); + TEST_ASSERT_EQUAL(0, lp_timer.read_ms()); + TEST_ASSERT_EQUAL(0, lp_timer.read_us()); + TEST_ASSERT_EQUAL(0, lp_timer.read_high_resolution_us()); +} + +/* This test verifies if read(), read_us(), read_ms(), + * read_high_resolution_us() + * functions return time accumulated between + * low power timer starts and stops. + * + * Given Timer has been successfully created and + * few times started and stopped after a specified period of time. + * When timer read request is performed. + * Then read functions return accumulated time elapsed between starts + * and stops. + */ +void test_lptimer_time_accumulation() +{ + LowPowerTimer lp_timer; + + /* Start the timer. */ + lp_timer.start(); + + /* Wait 10 ms. */ + wait_ms(10); + + /* Stop the timer. */ + lp_timer.stop(); + + /* Check results - totally 10 ms have elapsed. */ + TEST_ASSERT_FLOAT_WITHIN(DELTA_S, 0.010f, lp_timer.read()); + TEST_ASSERT_INT32_WITHIN(DELTA_MS, 10, lp_timer.read_ms()); + TEST_ASSERT_INT32_WITHIN(DELTA_US, 10000, lp_timer.read_us()); + TEST_ASSERT_UINT64_WITHIN(DELTA_US, 10000, lp_timer.read_high_resolution_us()); + + /* Wait 50 ms - this is done to show that time elapsed when + * the timer is stopped does not have influence on the + * timer counted time. */ + wait_ms(50); + + /* ------ */ + + /* Start the timer. */ + lp_timer.start(); + + /* Wait 20 ms. */ + wait_ms(20); + + /* Stop the timer. */ + lp_timer.stop(); + + /* Check results - totally 30 ms have elapsed. */ + TEST_ASSERT_FLOAT_WITHIN(2 * DELTA_S, 0.030f, lp_timer.read()); + TEST_ASSERT_INT32_WITHIN(DELTA_MS, 30, lp_timer.read_ms()); + TEST_ASSERT_INT32_WITHIN(2 * DELTA_US, 30000, lp_timer.read_us()); + TEST_ASSERT_UINT64_WITHIN(2 * DELTA_US, 30000, lp_timer.read_high_resolution_us()); + + /* Wait 50 ms - this is done to show that time elapsed when + * the timer is stopped does not have influence on the + * timer counted time. */ + + /* ------ */ + + /* Start the timer. */ + lp_timer.start(); + + /* Wait 30 ms. */ + wait_ms(30); + + /* Stop the timer. */ + lp_timer.stop(); + + /* Check results - totally 60 ms have elapsed. */ + TEST_ASSERT_FLOAT_WITHIN(3 * DELTA_S, 0.060f, lp_timer.read()); + TEST_ASSERT_INT32_WITHIN(DELTA_MS, 60, lp_timer.read_ms()); + TEST_ASSERT_INT32_WITHIN(3 * DELTA_US, 60000, lp_timer.read_us()); + TEST_ASSERT_UINT64_WITHIN(3 * DELTA_US, 60000, lp_timer.read_high_resolution_us()); + + /* Wait 50 ms - this is done to show that time elapsed when + * the timer is stopped does not have influence on the + * timer time. */ + wait_ms(50); + + /* ------ */ + + /* Start the timer. */ + lp_timer.start(); + + /* Wait 1 sec. */ + wait_ms(1000); + + /* Stop the timer. */ + lp_timer.stop(); + + /* Check results - totally 5060 ms have elapsed. */ + TEST_ASSERT_FLOAT_WITHIN(4 * DELTA_S, 1.060f, lp_timer.read()); + TEST_ASSERT_INT32_WITHIN(DELTA_MS, 1060, lp_timer.read_ms()); + TEST_ASSERT_INT32_WITHIN(4 * DELTA_US, 1060000, lp_timer.read_us()); + TEST_ASSERT_UINT64_WITHIN(4 * DELTA_US, 1060000, lp_timer.read_high_resolution_us()); +} + +/* This test verifies if reset() function resets the + * low power timer counted time. + * + * Given timer has been started and stopped once, then reset + * operation was performed. + * When timer is started and stopped next time. + * Then timer read functions returns only the the second + * measured time. + */ +void test_lptimer_reset() +{ + LowPowerTimer lp_timer; + + /* First measure 10 ms delay. */ + lp_timer.start(); + + /* Wait 10 ms. */ + wait_ms(10); + + /* Stop the timer. */ + lp_timer.stop(); + + /* Check results - totally 10 ms elapsed. */ + TEST_ASSERT_FLOAT_WITHIN(DELTA_S, 0.010f, lp_timer.read()); + TEST_ASSERT_INT32_WITHIN(DELTA_MS, 10, lp_timer.read_ms()); + TEST_ASSERT_INT32_WITHIN(DELTA_US, 10000, lp_timer.read_us()); + TEST_ASSERT_UINT64_WITHIN(DELTA_US, 10000, lp_timer.read_high_resolution_us()); + + /* Reset the timer - previous measured time should be lost now. */ + lp_timer.reset(); + + /* Now measure 20 ms delay. */ + lp_timer.start(); + + /* Wait 20 ms. */ + wait_ms(20); + + /* Stop the timer. */ + lp_timer.stop(); + + /* Check results - 20 ms elapsed since the reset. */ + TEST_ASSERT_FLOAT_WITHIN(DELTA_S, 0.020f, lp_timer.read()); + TEST_ASSERT_INT32_WITHIN(DELTA_MS, 20, lp_timer.read_ms()); + TEST_ASSERT_INT32_WITHIN(DELTA_US, 20000, lp_timer.read_us()); + TEST_ASSERT_UINT64_WITHIN(DELTA_US, 20000, lp_timer.read_high_resolution_us()); +} + +/* This test verifies if calling start() for already + * started low power timer does nothing. + * + * Given timer is already started. + * When timer is started again. + * Then second start operation is ignored. + */ +void test_lptimer_start_started_timer() +{ + LowPowerTimer lp_timer; + + /* Start the timer. */ + lp_timer.start(); + + /* Wait 10 ms. */ + wait_ms(10); + + /* Now start timer again. */ + lp_timer.start(); + + /* Wait 20 ms. */ + wait_ms(20); + + /* Stop the timer. */ + lp_timer.stop(); + + /* Check results - 30 ms have elapsed since the first start. */ + TEST_ASSERT_FLOAT_WITHIN(2 * DELTA_S, 0.030f, lp_timer.read()); + TEST_ASSERT_INT32_WITHIN(DELTA_MS, 30, lp_timer.read_ms()); + TEST_ASSERT_INT32_WITHIN(2 * DELTA_US, 30000, lp_timer.read_us()); + TEST_ASSERT_UINT64_WITHIN(2 * DELTA_US, 30000, lp_timer.read_high_resolution_us()); +} + +/* This test verifies low power timer float operator. + * + * Given timer is created and a time period time is counted. + * When timer object is casted on float type. + * Then counted type in seconds is returned by means of + * read() function. + */ +void test_lptimer_float_operator() +{ + LowPowerTimer lp_timer; + + /* Start the timer. */ + lp_timer.start(); + + /* Wait 10 ms. */ + wait_ms(10); + + /* Stop the timer. */ + lp_timer.stop(); + + /* Check result - 10 ms elapsed. */ + TEST_ASSERT_FLOAT_WITHIN(DELTA_S, 0.010f, (float )(lp_timer)); +} + +/* This test verifies if time counted by the low power timer is + * valid. + * + * Given timer is created. + * When timer is used to measure 1ms/10ms/100ms/1s + * delays. + * Then the results are valid (within acceptable range). + */ +template +void test_lptimer_time_measurement() +{ + LowPowerTimer lp_timer; + + /* Start the timer. */ + lp_timer.start(); + + /* Wait us. */ + wait_us(wait_val_us); + + /* Stop the timer. */ + lp_timer.stop(); + + /* Check results - wait_val_us us have elapsed. */ + TEST_ASSERT_FLOAT_WITHIN(DELTA_S, (float )wait_val_us / 1000000, lp_timer.read()); + TEST_ASSERT_INT32_WITHIN(DELTA_MS, wait_val_us / 1000, lp_timer.read_ms()); + TEST_ASSERT_INT32_WITHIN(DELTA_US, wait_val_us, lp_timer.read_us()); + TEST_ASSERT_UINT64_WITHIN(DELTA_US, wait_val_us, lp_timer.read_high_resolution_us()); +} + +utest::v1::status_t test_setup(const size_t number_of_cases) +{ + GREENTEA_SETUP(15, "default_auto"); + return verbose_test_setup_handler(number_of_cases); +} + +Case cases[] = { + Case("Test: LowPowerTimer - stopped after creation.", test_lptimer_creation), + Case("Test: LowPowerTimer - measure time accumulation.", test_lptimer_time_accumulation), + Case("Test: LowPowerTimer - reset.", test_lptimer_reset), + Case("Test: LowPowerTimer - start started timer.", test_lptimer_start_started_timer), + Case("Test: LowPowerTimer - float operator.", test_lptimer_float_operator), + Case("Test: LowPowerTimer - time measurement 1 ms.", test_lptimer_time_measurement<1000>), + Case("Test: LowPowerTimer - time measurement 10 ms.", test_lptimer_time_measurement<10000>), + Case("Test: LowPowerTimer - time measurement 100 ms.", test_lptimer_time_measurement<100000>), + Case("Test: LowPowerTimer - time measurement 1 s.", test_lptimer_time_measurement<1000000>) +}; + +Specification specification(test_setup, cases); + +int main() +{ + return !Harness::run(specification); +} From 575c0645e7f10625d73340a87e27651153a33129 Mon Sep 17 00:00:00 2001 From: Seppe Stas Date: Fri, 29 Sep 2017 14:39:29 +0200 Subject: [PATCH 060/108] Fix analogin scaling for EFM32 target Fixes #5115. `analogin_read_u16` returns a value in the range `0x0000 - 0xFFF0` since the resolution of the ADC is 12 bits. However, in `analogin_read` this value gets divided by `0xFFFF` assuming the range is `0x0000-0xFFFF`. This causes a small error in the value returned by `AnalogIn::read` for the EFM32 target. --- targets/TARGET_Silicon_Labs/TARGET_EFM32/analogin_api.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/targets/TARGET_Silicon_Labs/TARGET_EFM32/analogin_api.c b/targets/TARGET_Silicon_Labs/TARGET_EFM32/analogin_api.c index c690cb499a1..0de7a2a8bf8 100644 --- a/targets/TARGET_Silicon_Labs/TARGET_EFM32/analogin_api.c +++ b/targets/TARGET_Silicon_Labs/TARGET_EFM32/analogin_api.c @@ -99,8 +99,8 @@ uint16_t analogin_read_u16(analogin_t *obj) float analogin_read(analogin_t *obj) { - /* Convert from a uint16 to a float between 0 and 1 by division by 0xFFFF */ - return analogin_read_u16(obj) / (float) 0xFFFF; + /* Convert from a uint16 to a float between 0 and 1 by division by 0xFFF0 */ + return analogin_read_u16(obj) / (float) 0xFFF0; } #endif From 4c40c248c08d1914e467cd2a6dda9bdae2f3f5d8 Mon Sep 17 00:00:00 2001 From: adbridge Date: Wed, 27 Sep 2017 17:59:19 +0100 Subject: [PATCH 061/108] Fix the prepare_branch function Currently when checking if the destination branch already exists the command 'git branch' is used. This only returns local branches. What is actually required is the list of remote branches. This can be obtained by the command 'git branch -r' and filtering the result. --- tools/test/examples/update.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tools/test/examples/update.py b/tools/test/examples/update.py index 64b6a66fc73..3ad6c36434d 100644 --- a/tools/test/examples/update.py +++ b/tools/test/examples/update.py @@ -268,10 +268,19 @@ def prepare_branch(src, dst): update_log.debug("Preparing branch: %s", dst) # Check if branch already exists or not. - cmd = ['git', 'branch'] + # We can use the 'git branch -r' command. This returns all the remote branches for + # the current repo. + # The output consists of a list of lines of the form: + # origin/ + # From these we need to extract just the branch names to a list and then check if + # the specified dst exists in that list + branches = [] + cmd = "git branch -r" _, output = run_cmd_with_output(cmd, exit_on_failure=True) - if not dst in output: + branches = [line.split('/')[1] for line in output.split('\n') if 'origin' in line and not '->' in line] + + if not dst in branches: # OOB branch does not exist thus create it, first ensuring we are on # the src branch and then check it out From 4892b5476eebd65ef2be04eb258f7aa1dde5017f Mon Sep 17 00:00:00 2001 From: adbridge Date: Fri, 29 Sep 2017 16:17:33 +0100 Subject: [PATCH 062/108] Move to using command strings rather than command lists. Previously the script used cmd =['git','checkout', branch] syntax. This does not work well cross platform. The solution it to actually use strings. E.g. cmd = "git checkout " + branch --- tools/test/examples/update.py | 145 ++++++++++++++++------------------ 1 file changed, 69 insertions(+), 76 deletions(-) diff --git a/tools/test/examples/update.py b/tools/test/examples/update.py index 3ad6c36434d..75c215e4e1d 100644 --- a/tools/test/examples/update.py +++ b/tools/test/examples/update.py @@ -42,9 +42,6 @@ # -c - Optional path to an examples file. # If not proved the default is 'examples.json' # -T - GitHub token for secure access (required) -# -l - Optional Level for providing logging output. Can be one of, -# CRITICAL, ERROR, WARNING, INFO, DEBUG -# If not provided the default is 'INFO' # -f - Update forked repos. This will use the 'github-user' parameter in # the 'via-fork' section. # -b - Update branched repos. This will use the "src-branch" and @@ -75,16 +72,34 @@ import examples_lib as lib from examples_lib import SUPPORTED_TOOLCHAINS +userlog = logging.getLogger("Update") + +# Set logging level +userlog.setLevel(logging.DEBUG) + +# Everything is output to the log file +logfile = os.path.join(os.getcwd(), 'update.log') +fh = logging.FileHandler(logfile) +fh.setLevel(logging.DEBUG) + +# create console handler with a higher log level +ch = logging.StreamHandler() +ch.setLevel(logging.INFO) + +formatter = logging.Formatter('%(name)s: %(levelname)s - %(message)s') +ch.setFormatter(formatter) +fh.setFormatter(formatter) + +# add the handlers to the logger +userlog.addHandler(fh) +userlog.addHandler(ch) + def run_cmd(command, exit_on_failure=False): - """ Run a system command and return the result status + """ Run a system command returning a status result - Description: + This is just a wrapper for the run_cmd_with_output() function, but + only returns the status of the call. - Passes a command to the system and returns a True/False result, once the - command has been executed, indicating success/failure. Commands are passed - as a list of tokens. - E.g. The command 'git remote -v' would be passed in as ['git', 'remote', '-v'] - Args: command - system command as a list of tokens exit_on_failure - If True exit the program on failure (default = False) @@ -92,49 +107,41 @@ def run_cmd(command, exit_on_failure=False): Returns: return_code - True/False indicating the success/failure of the command """ - update_log.debug('[Exec] %s', ' '.join(command)) - return_code = subprocess.call(command, shell=True) - - if return_code: - update_log.warning("Command '%s' failed with return code: %s", - ' '.join(command), return_code) - if exit_on_failure: - sys.exit(1) - + return_code, _ = run_cmd_with_output(command, exit_on_failure) return return_code def run_cmd_with_output(command, exit_on_failure=False): - """ Run a system command and return the result status plus output + """ Run a system command returning a status result and any command output - Description: - Passes a command to the system and returns a True/False result once the command has been executed, indicating success/failure. If the command was successful then the output from the command is returned to the caller. - Commands are passed as a list of tokens. - E.g. The command 'git remote -v' would be passed in as ['git', 'remote', '-v'] + Commands are passed as a string. + E.g. The command 'git remote -v' would be passed in as "git remote -v" Args: - command - system command as a list of tokens + command - system command as a string exit_on_failure - If True exit the program on failure (default = False) Returns: - returncode - True/False indicating the success/failure of the command + return_code - True/False indicating the success/failure of the command output - The output of the command if it was successful, else empty string """ - update_log.debug('[Exec] %s', ' '.join(command)) + text = '[Exec] ' + command + userlog.debug(text) returncode = 0 output = "" try: output = subprocess.check_output(command, shell=True) except subprocess.CalledProcessError as e: - update_log.warning("Command '%s' failed with return code: %s", - ' '.join(command), e.returncode) + text = "The command " + str(command) + "failed with return code: " + str(e.returncode) + userlog.warning(text) returncode = e.returncode if exit_on_failure: sys.exit(1) return returncode, output + def rmtree_readonly(directory): """ Deletes a readonly directory tree. @@ -198,7 +205,7 @@ def upgrade_single_example(example, tag, directory, ref): os.rename("mbed-os.lib", "mbed-os.lib_bak") else: - update_log.error("Failed to backup mbed-os.lib prior to updating.") + userlog.error("Failed to backup mbed-os.lib prior to updating.") return False # mbed-os.lib file contains one line with the following format @@ -221,7 +228,7 @@ def upgrade_single_example(example, tag, directory, ref): if updated: # Setup and run the git add command - cmd = ['git', 'add', 'mbed-os.lib'] + cmd = "git add mbed-os.lib" return_code = run_cmd(cmd) os.chdir(cwd) @@ -242,12 +249,12 @@ def prepare_fork(arm_example): """ logstr = "In: " + os.getcwd() - update_log.debug(logstr) + userlog.debug(logstr) - for cmd in [['git', 'remote', 'add', 'armmbed', arm_example], - ['git', 'fetch', 'armmbed'], - ['git', 'reset', '--hard', 'armmbed/master'], - ['git', 'push', '-f', 'origin']]: + for cmd in ["git remote add armmbed " + str(arm_example), + "git fetch armmbed", + "git reset --hard armmbed/master", + "git push -f origin"]: run_cmd(cmd, exit_on_failure=True) def prepare_branch(src, dst): @@ -265,7 +272,7 @@ def prepare_branch(src, dst): """ - update_log.debug("Preparing branch: %s", dst) + userlog.debug("Preparing branch: %s", dst) # Check if branch already exists or not. # We can use the 'git branch -r' command. This returns all the remote branches for @@ -285,14 +292,14 @@ def prepare_branch(src, dst): # OOB branch does not exist thus create it, first ensuring we are on # the src branch and then check it out - for cmd in [['git', 'checkout', src], - ['git', 'checkout', '-b', dst], - ['git', 'push', '-u', 'origin', dst]]: + for cmd in ["git checkout " + str(src), + "git checkout -b " + str(dst), + "git push -u origin " + str(dst)]: run_cmd(cmd, exit_on_failure=True) else: - cmd = ['git', 'checkout', dst] + cmd = "git checkout " + str(dst) run_cmd(cmd, exit_on_failure=True) def upgrade_example(github, example, tag, ref, user, src, dst, template): @@ -330,18 +337,18 @@ def upgrade_example(github, example, tag, ref, user, src, dst, template): user = 'ARMmbed' ret = False - update_log.info("Updating example '%s'", example['name']) - update_log.debug("User: %s", user) - update_log.debug("Src branch: %s", (src or "None")) - update_log.debug("Dst branch: %s", (dst or "None")) + userlog.info("Updating example '%s'", example['name']) + userlog.debug("User: %s", user) + userlog.debug("Src branch: %s", (src or "None")) + userlog.debug("Dst branch: %s", (dst or "None")) cwd = os.getcwd() update_repo = "https://github.com/" + user + '/' + example['name'] - update_log.debug("Update repository: %s", update_repo) + userlog.debug("Update repository: %s", update_repo) # Clone the example repo - clone_cmd = ['git', 'clone', update_repo] + clone_cmd = "git clone " + str(update_repo) return_code = run_cmd(clone_cmd) if not return_code: @@ -362,16 +369,13 @@ def upgrade_example(github, example, tag, ref, user, src, dst, template): os.chdir(cwd) return False - # Setup the default commit message - commit_message = 'Updating mbed-os to ' + tag - # Setup and run the commit command - commit_cmd = ['git', 'commit', '-m', commit_message] + commit_cmd = "git commit -m \"Updating mbed-os to " + tag + "\"" return_code = run_cmd(commit_cmd) if not return_code: # Setup and run the push command - push_cmd = ['git', 'push', 'origin'] + push_cmd = "git push origin" return_code = run_cmd(push_cmd) if not return_code: @@ -379,13 +383,13 @@ def upgrade_example(github, example, tag, ref, user, src, dst, template): if user != 'ARMmbed': upstream_repo = 'ARMmbed/'+ example['name'] - update_log.debug("Upstream repository: %s", upstream_repo) + userlog.debug("Upstream repository: %s", upstream_repo) # Check access to mbed-os repo try: repo = github.get_repo(upstream_repo, False) except: - update_log.error("Upstream repo: %s, does not exist - skipping", upstream_repo) + userlog.error("Upstream repo: %s, does not exist - skipping", upstream_repo) return False jinja_loader = FileSystemLoader(template) @@ -400,15 +404,15 @@ def upgrade_example(github, example, tag, ref, user, src, dst, template): ret = True except GithubException as e: # Default to False - update_log.error("Pull request creation failed with error: %s", e) + userlog.error("Pull request creation failed with error: %s", e) else: ret = True else: - update_log.error("Git push command failed.") + userlog.error("Git push command failed.") else: - update_log.error("Git commit command failed.") + userlog.error("Git commit command failed.") else: - update_log.error("Git clone %s failed", update_repo) + userlog.error("Git clone %s failed", update_repo) os.chdir(cwd) return ret @@ -422,7 +426,7 @@ def create_work_directory(path): """ if os.path.exists(path): - update_log.info("'%s' directory already exists. Deleting...", path) + userlog.info("'%s' directory already exists. Deleting...", path) rmtree_readonly(path) os.makedirs(path) @@ -433,9 +437,6 @@ def create_work_directory(path): formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument('-c', '--config_file', help="Path to the configuration file (default is 'examples.json')", default='examples.json') parser.add_argument('-T', '--github_token', help="GitHub token for secure access") - parser.add_argument('-l', '--log-level', - help="Level for providing logging output", - default='INFO') exclusive = parser.add_mutually_exclusive_group(required=True) exclusive.add_argument('-f', '--fork', help="Update a fork", action='store_true') @@ -443,18 +444,10 @@ def create_work_directory(path): args = parser.parse_args() - default = getattr(logging, 'INFO') - level = getattr(logging, args.log_level.upper(), default) - - # Set logging level - logging.basicConfig(level=level) - - update_log = logging.getLogger("Update") - # Load the config file with open(os.path.join(os.path.dirname(__file__), args.config_file)) as config: if not config: - update_log.error("Failed to load config file '%s'", args.config_file) + userlog.error("Failed to load config file '%s'", args.config_file) sys.exit(1) json_data = json.load(config) @@ -479,11 +472,11 @@ def create_work_directory(path): exit(1) # Get the github sha corresponding to the specified mbed-os tag - cmd = ['git', 'rev-list', '-1', tag] + cmd = "git rev-list -1 " + tag return_code, ref = run_cmd_with_output(cmd) if return_code: - update_log.error("Could not obtain SHA for tag: %s", tag) + userlog.error("Could not obtain SHA for tag: %s", tag) sys.exit(1) # Loop through the examples @@ -508,11 +501,11 @@ def create_work_directory(path): os.chdir('../') # Finish the script and report the results - update_log.info("Finished updating examples") + userlog.info("Finished updating examples") if successes: for success in successes: - update_log.info(" SUCCEEDED: %s", success) + userlog.info(" SUCCEEDED: %s", success) if failures: for fail in failures: - update_log.info(" FAILED: %s", fail) + userlog.info(" FAILED: %s", fail) From 0b5043ea5bf67640bf652ec32f61bc96b979a2de Mon Sep 17 00:00:00 2001 From: Pavel Sorejs Date: Sat, 30 Sep 2017 20:07:38 +0200 Subject: [PATCH 063/108] Add bootloaderd support to NUCLEO_F446RE target --- .../TARGET_NUCLEO_F446RE/system_clock.c | 14 -------------- .../device/TOOLCHAIN_GCC_ARM/STM32F446XE.ld | 14 +++++++++++--- targets/targets.json | 3 ++- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F446xE/TARGET_NUCLEO_F446RE/system_clock.c b/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F446xE/TARGET_NUCLEO_F446RE/system_clock.c index 48acec0abe1..4c2293602a8 100644 --- a/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F446xE/TARGET_NUCLEO_F446RE/system_clock.c +++ b/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F446xE/TARGET_NUCLEO_F446RE/system_clock.c @@ -37,13 +37,6 @@ #include "stm32f4xx.h" #include "mbed_assert.h" -/*!< Uncomment the following line if you need to relocate your vector Table in - Internal SRAM. */ -/* #define VECT_TAB_SRAM */ -#define VECT_TAB_OFFSET 0x00 /*!< Vector Table base offset field. - This value must be a multiple of 0x200. */ - - // clock source is selected with CLOCK_SOURCE in json config #define USE_PLL_HSE_EXTC 0x8 // Use external clock (ST Link MCO) #define USE_PLL_HSE_XTAL 0x4 // Use external xtal (X3 on board - not provided by default) @@ -97,13 +90,6 @@ void SystemInit(void) SystemInit_ExtMemCtl(); #endif /* DATA_IN_ExtSRAM || DATA_IN_ExtSDRAM */ - /* Configure the Vector Table location add offset address ------------------*/ -#ifdef VECT_TAB_SRAM - SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */ -#else - SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */ -#endif - } diff --git a/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F446xE/device/TOOLCHAIN_GCC_ARM/STM32F446XE.ld b/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F446xE/device/TOOLCHAIN_GCC_ARM/STM32F446XE.ld index 5453f9629e6..e8fea5d8b20 100644 --- a/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F446xE/device/TOOLCHAIN_GCC_ARM/STM32F446XE.ld +++ b/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F446xE/device/TOOLCHAIN_GCC_ARM/STM32F446XE.ld @@ -1,7 +1,15 @@ +#if !defined(MBED_APP_START) + #define MBED_APP_START 0x08000000 +#endif + +#if !defined(MBED_APP_SIZE) + #define MBED_APP_SIZE 512K +#endif + /* Linker script to configure memory regions. */ MEMORY -{ - FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K +{ + FLASH (rx) : ORIGIN = MBED_APP_START, LENGTH = MBED_APP_SIZE RAM (rwx) : ORIGIN = 0x200001C4, LENGTH = 128k - 0x1C4 } @@ -9,7 +17,7 @@ MEMORY * with other linker script that defines memory regions FLASH and RAM. * It references following symbols, which must be defined in code: * Reset_Handler : Entry of reset handler - * + * * It defines following symbols, which code can use without definition: * __exidx_start * __exidx_end diff --git a/targets/targets.json b/targets/targets.json index e2d1364b5bc..e7775acd8e6 100644 --- a/targets/targets.json +++ b/targets/targets.json @@ -1138,7 +1138,8 @@ "macros_add": ["USB_STM_HAL", "USBHOST_OTHER"], "device_has_add": ["ANALOGOUT", "CAN", "LOWPOWERTIMER", "SERIAL_ASYNCH", "SERIAL_FC", "FLASH"], "release_versions": ["2", "5"], - "device_name": "STM32F446RE" + "device_name": "STM32F446RE", + "bootloader_supported": true }, "NUCLEO_F446ZE": { "inherits": ["FAMILY_STM32"], From 3c3e2800b86d18d6d81c393774c74a6f46e28cbb Mon Sep 17 00:00:00 2001 From: Kevin Gilbert Date: Fri, 1 Sep 2017 11:25:39 -0500 Subject: [PATCH 064/108] Add profile argument to mbed-os example build tools to allow non-default build profiles to be passed in --- tools/test/examples/examples.py | 7 ++++++- tools/test/examples/examples_lib.py | 12 +++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/tools/test/examples/examples.py b/tools/test/examples/examples.py index 4a6adcd6474..c163250e54e 100644 --- a/tools/test/examples/examples.py +++ b/tools/test/examples/examples.py @@ -54,6 +54,11 @@ def main(): argparse_force_uppercase_type( official_target_names, "MCU")), default=official_target_names) + + compile_cmd.add_argument("-p", "--profile", + help=("build profile file"), + metavar="profile") + export_cmd = subparsers.add_parser("export") export_cmd.set_defaults(fn=do_export), export_cmd.add_argument( @@ -111,7 +116,7 @@ def do_deploy(_, config, examples): def do_compile(args, config, examples): """Do the compile step""" results = {} - results = lib.compile_repos(config, args.toolchains, args.mcu, examples) + results = lib.compile_repos(config, args.toolchains, args.mcu, args.profile, examples) lib.print_summary(results) failures = lib.get_num_failures(results) diff --git a/tools/test/examples/examples_lib.py b/tools/test/examples/examples_lib.py index e87d88e5e0f..d57aa197e6c 100644 --- a/tools/test/examples/examples_lib.py +++ b/tools/test/examples/examples_lib.py @@ -314,7 +314,7 @@ def status(message): return results -def compile_repos(config, toolchains, targets, examples): +def compile_repos(config, toolchains, targets, profile, examples): """Compiles combinations of example programs, targets and compile chains. The results are returned in a [key: value] dictionary format: @@ -358,8 +358,14 @@ def compile_repos(config, toolchains, targets, examples): valid_choices(example['toolchains'], toolchains), example['features']): print("Compiling %s for %s, %s" % (name, target, toolchain)) - proc = subprocess.Popen(["mbed-cli", "compile", "-t", toolchain, - "-m", target, "-v"]) + build_command = ["mbed-cli", "compile", "-t", toolchain, "-m", target, "-v"] + + if profile: + build_command.append("--profile") + build_command.append(profile) + + proc = subprocess.Popen(build_command) + proc.wait() example_summary = "{} {} {}".format(name, target, toolchain) if proc.returncode: From 10b7613b03500c799d9012ff27aba3560e1236cb Mon Sep 17 00:00:00 2001 From: Kevin Gilbert Date: Tue, 3 Oct 2017 16:14:07 -0500 Subject: [PATCH 065/108] Remove -p as an argument flag for profile --- tools/test/examples/examples.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/test/examples/examples.py b/tools/test/examples/examples.py index c163250e54e..fcc3485baf2 100644 --- a/tools/test/examples/examples.py +++ b/tools/test/examples/examples.py @@ -55,7 +55,7 @@ def main(): official_target_names, "MCU")), default=official_target_names) - compile_cmd.add_argument("-p", "--profile", + compile_cmd.add_argument("--profile", help=("build profile file"), metavar="profile") From 62b5b443b082e4303ebe5cd09cda0222752352b7 Mon Sep 17 00:00:00 2001 From: Kevin Bracey Date: Tue, 10 Oct 2017 11:34:21 +0300 Subject: [PATCH 066/108] lwIP: Add memory configs to JSON We currently set the lwIP pbuf pool size small - to 5 x 576-byte buffers. This is insufficient to hold a single DTLS handshake flight, so can cause cloud client connections to fail. STM-based platforms are failing handshake because of this. (K64F works because it doesn't use the pbuf pool for reception, but lwIP does recommend drivers use the pbuf pool). Not changing the default memory sizes here, as intended for a patch release, but adding mbed configuration options to allow the numbers to be adjusted for memory tuning in an application. In a future minor revision, I would recommend increasing the default PBUF_POOL_SIZE - we are well below lwIP's out-of-the-box default - and offsetting by a reduction in MEM_SIZE for the drivers that don't use PBUF_RAM. --- features/FEATURE_LWIP/lwip-interface/lwipopts.h | 17 ++++++++++++++++- .../FEATURE_LWIP/lwip-interface/mbed_lib.json | 12 ++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/features/FEATURE_LWIP/lwip-interface/lwipopts.h b/features/FEATURE_LWIP/lwip-interface/lwipopts.h index 0b422627c9f..608cc994e78 100644 --- a/features/FEATURE_LWIP/lwip-interface/lwipopts.h +++ b/features/FEATURE_LWIP/lwip-interface/lwipopts.h @@ -137,10 +137,25 @@ #define LWIP_RAM_HEAP_POINTER lwip_ram_heap // Number of pool pbufs. -// Each requires 684 bytes of RAM. +// Each requires 684 bytes of RAM (if MSS=536 and PBUF_POOL_BUFSIZE defaulting to be based on MSS) +#ifdef MBED_CONF_LWIP_PBUF_POOL_SIZE +#undef PBUF_POOL_SIZE +#define PBUF_POOL_SIZE MBED_CONF_LWIP_PBUF_POOL_SIZE +#else #ifndef PBUF_POOL_SIZE #define PBUF_POOL_SIZE 5 #endif +#endif + +#ifdef MBED_CONF_LWIP_PBUF_POOL_BUFSIZE +#undef PBUF_POOL_BUFSIZE +#define PBUF_POOL_BUFSIZE MBED_CONF_LWIP_PBUF_POOL_BUFSIZE +#endif + +#ifdef MBED_CONF_LWIP_MEM_SIZE +#undef MEM_SIZE +#define MEM_SIZE MBED_CONF_LWIP_MEM_SIZE +#endif // One tcp_pcb_listen is needed for each TCPServer. // Each requires 72 bytes of RAM. diff --git a/features/FEATURE_LWIP/lwip-interface/mbed_lib.json b/features/FEATURE_LWIP/lwip-interface/mbed_lib.json index d1e4feff039..6d9def2aa17 100644 --- a/features/FEATURE_LWIP/lwip-interface/mbed_lib.json +++ b/features/FEATURE_LWIP/lwip-interface/mbed_lib.json @@ -72,6 +72,18 @@ "help": "Maximum number of open UDPSocket instances allowed, including one used internally for DNS. Each requires 84 bytes of pre-allocated RAM", "value": 4 }, + "pbuf-pool-size": { + "help": "Number of pbufs in pool - usually used for received packets, so this determines how much data can be buffered between reception and the application reading. If a driver uses PBUF_RAM for reception, less pool may be needed. Current default (used if null here) is set to 5 in lwipopts.h, unless overridden by target Ethernet drivers.", + "value": null + }, + "pbuf-pool-bufsize": { + "help": "Size of pbufs in pool. If set to null, lwIP will base the size on the TCP MSS, which is 536 unless overridden by the target", + "value": null + }, + "mem-size": { + "help": "Size of heap (bytes) - used for outgoing packets, and also used by some drivers for reception. Current default (used if null here) is set to 1600 in opt.h, unless overridden by target Ethernet drivers.", + "value": null + }, "tcpip-thread-stacksize": { "help": "Stack size for lwip TCPIP thread", "value": 1200 From d3f9dd3913fd113dbf16bd50f1fcc5264dd84153 Mon Sep 17 00:00:00 2001 From: Seppo Takalo Date: Wed, 4 Oct 2017 14:57:55 +0300 Subject: [PATCH 067/108] Enable MPL by default for 6LoWPAN-ND. In Thread network, MPL is already enabled so this causes both to behave similarly. --- .../FEATURE_NANOSTACK/mbed-mesh-api/source/nd_tasklet.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/features/nanostack/FEATURE_NANOSTACK/mbed-mesh-api/source/nd_tasklet.c b/features/nanostack/FEATURE_NANOSTACK/mbed-mesh-api/source/nd_tasklet.c index 5b589d8842c..e3eab47677e 100644 --- a/features/nanostack/FEATURE_NANOSTACK/mbed-mesh-api/source/nd_tasklet.c +++ b/features/nanostack/FEATURE_NANOSTACK/mbed-mesh-api/source/nd_tasklet.c @@ -23,6 +23,7 @@ #include "include/nd_tasklet.h" #include "include/mesh_system.h" #include "ns_event_loop.h" +#include "multicast_api.h" // For tracing we need to define flag, have include and define group #define HAVE_DEBUG 1 @@ -265,6 +266,13 @@ void nd_tasklet_configure_and_connect_to_network(void) tasklet_data_ptr->network_interface_id, MBED_CONF_MBED_MESH_API_6LOWPAN_ND_PANID_FILTER); + // Enable MPL by default + const uint8_t all_mpl_forwarders[16] = {0xff, 0x03, [15]=0xfc}; + multicast_mpl_domain_subscribe(tasklet_data_ptr->network_interface_id, + all_mpl_forwarders, + MULTICAST_MPL_SEED_ID_DEFAULT, + NULL); + status = arm_nwk_interface_up(tasklet_data_ptr->network_interface_id); if (status >= 0) { tasklet_data_ptr->tasklet_state = TASKLET_STATE_BOOTSTRAP_STARTED; From 215eddcf39591717cd0d2cdb5324c3c496d2dd90 Mon Sep 17 00:00:00 2001 From: bcostm Date: Thu, 5 Oct 2017 16:35:05 +0200 Subject: [PATCH 068/108] fix init struct analogout --- targets/TARGET_STM/TARGET_STM32F0/analogout_device.c | 4 +++- targets/TARGET_STM/TARGET_STM32F3/analogout_device.c | 4 +++- targets/TARGET_STM/TARGET_STM32F4/analogout_device.c | 4 +++- targets/TARGET_STM/TARGET_STM32F7/analogout_device.c | 4 +++- targets/TARGET_STM/TARGET_STM32L0/analogout_device.c | 4 +++- targets/TARGET_STM/TARGET_STM32L1/analogout_device.c | 4 +++- targets/TARGET_STM/TARGET_STM32L4/analogout_device.c | 2 ++ 7 files changed, 20 insertions(+), 6 deletions(-) diff --git a/targets/TARGET_STM/TARGET_STM32F0/analogout_device.c b/targets/TARGET_STM/TARGET_STM32F0/analogout_device.c index c8891f85d8a..da73e70b309 100644 --- a/targets/TARGET_STM/TARGET_STM32F0/analogout_device.c +++ b/targets/TARGET_STM/TARGET_STM32F0/analogout_device.c @@ -36,7 +36,7 @@ #include "PeripheralPins.h" void analogout_init(dac_t *obj, PinName pin) { - DAC_ChannelConfTypeDef sConfig; + DAC_ChannelConfTypeDef sConfig = {0}; // Get the peripheral name from the pin and assign it to the object obj->dac = (DACName)pinmap_peripheral(pin, PinMap_DAC); @@ -71,6 +71,8 @@ void analogout_init(dac_t *obj, PinName pin) { // Configure DAC obj->handle.Instance = (DAC_TypeDef *)(obj->dac); + obj->handle.State = HAL_DAC_STATE_RESET; + if (HAL_DAC_Init(&obj->handle) != HAL_OK ) { error("HAL_DAC_Init failed"); } diff --git a/targets/TARGET_STM/TARGET_STM32F3/analogout_device.c b/targets/TARGET_STM/TARGET_STM32F3/analogout_device.c index 6bc7da1e5b0..4b17b6e5f2f 100644 --- a/targets/TARGET_STM/TARGET_STM32F3/analogout_device.c +++ b/targets/TARGET_STM/TARGET_STM32F3/analogout_device.c @@ -40,7 +40,7 @@ static int pa4_used = 0; static int pa5_used = 0; void analogout_init(dac_t *obj, PinName pin) { - DAC_ChannelConfTypeDef sConfig; + DAC_ChannelConfTypeDef sConfig = {0}; // Get the peripheral name from the pin and assign it to the object obj->dac = (DACName)pinmap_peripheral(pin, PinMap_DAC); @@ -83,6 +83,8 @@ void analogout_init(dac_t *obj, PinName pin) { // Configure DAC obj->handle.Instance = (DAC_TypeDef *)(obj->dac); + obj->handle.State = HAL_DAC_STATE_RESET; + if (HAL_DAC_Init(&obj->handle) != HAL_OK ) { error("HAL_DAC_Init failed"); } diff --git a/targets/TARGET_STM/TARGET_STM32F4/analogout_device.c b/targets/TARGET_STM/TARGET_STM32F4/analogout_device.c index 802fad6bbb1..da07ad678bc 100644 --- a/targets/TARGET_STM/TARGET_STM32F4/analogout_device.c +++ b/targets/TARGET_STM/TARGET_STM32F4/analogout_device.c @@ -36,7 +36,7 @@ #include "PeripheralPins.h" void analogout_init(dac_t *obj, PinName pin) { - DAC_ChannelConfTypeDef sConfig; + DAC_ChannelConfTypeDef sConfig = {0}; // Get the peripheral name (DAC_1, ...) from the pin and assign it to the object obj->dac = (DACName)pinmap_peripheral(pin, PinMap_DAC); @@ -71,6 +71,8 @@ void analogout_init(dac_t *obj, PinName pin) { __HAL_RCC_DAC_CLK_ENABLE(); obj->handle.Instance = DAC; + obj->handle.State = HAL_DAC_STATE_RESET; + if (HAL_DAC_Init(&obj->handle) != HAL_OK ) { error("HAL_DAC_Init failed"); } diff --git a/targets/TARGET_STM/TARGET_STM32F7/analogout_device.c b/targets/TARGET_STM/TARGET_STM32F7/analogout_device.c index 8003d35a51c..d817d3d2808 100644 --- a/targets/TARGET_STM/TARGET_STM32F7/analogout_device.c +++ b/targets/TARGET_STM/TARGET_STM32F7/analogout_device.c @@ -36,7 +36,7 @@ #include "PeripheralPins.h" void analogout_init(dac_t *obj, PinName pin) { - DAC_ChannelConfTypeDef sConfig; + DAC_ChannelConfTypeDef sConfig = {0}; // Get the peripheral name (DAC_1, ...) from the pin and assign it to the object obj->dac = (DACName)pinmap_peripheral(pin, PinMap_DAC); @@ -71,6 +71,8 @@ void analogout_init(dac_t *obj, PinName pin) { __DAC_CLK_ENABLE(); obj->handle.Instance = DAC; + obj->handle.State = HAL_DAC_STATE_RESET; + if (HAL_DAC_Init(&obj->handle) != HAL_OK ) { error("HAL_DAC_Init failed"); } diff --git a/targets/TARGET_STM/TARGET_STM32L0/analogout_device.c b/targets/TARGET_STM/TARGET_STM32L0/analogout_device.c index dbf8f9cab12..499008b73a8 100644 --- a/targets/TARGET_STM/TARGET_STM32L0/analogout_device.c +++ b/targets/TARGET_STM/TARGET_STM32L0/analogout_device.c @@ -40,7 +40,7 @@ static int channel1_used = 0; static int channel2_used = 0; void analogout_init(dac_t *obj, PinName pin) { - DAC_ChannelConfTypeDef sConfig; + DAC_ChannelConfTypeDef sConfig = {0}; // Get the peripheral name from the pin and assign it to the object obj->dac = (DACName)pinmap_peripheral(pin, PinMap_DAC); @@ -74,6 +74,8 @@ void analogout_init(dac_t *obj, PinName pin) { // Configure DAC obj->handle.Instance = DAC; + obj->handle.State = HAL_DAC_STATE_RESET; + if (HAL_DAC_Init(&obj->handle) != HAL_OK ) { error("HAL_DAC_Init failed"); } diff --git a/targets/TARGET_STM/TARGET_STM32L1/analogout_device.c b/targets/TARGET_STM/TARGET_STM32L1/analogout_device.c index 7dd2cb7eac5..2220b7d592e 100644 --- a/targets/TARGET_STM/TARGET_STM32L1/analogout_device.c +++ b/targets/TARGET_STM/TARGET_STM32L1/analogout_device.c @@ -40,7 +40,7 @@ static int pa4_used = 0; static int pa5_used = 0; void analogout_init(dac_t *obj, PinName pin) { - DAC_ChannelConfTypeDef sConfig; + DAC_ChannelConfTypeDef sConfig = {0}; // Get the peripheral name (DAC_1, ...) from the pin and assign it to the object obj->dac = (DACName)pinmap_peripheral(pin, PinMap_DAC); @@ -68,6 +68,8 @@ void analogout_init(dac_t *obj, PinName pin) { obj->pin = pin; obj->handle.Instance = DAC; + obj->handle.State = HAL_DAC_STATE_RESET; + if (HAL_DAC_Init(&obj->handle) != HAL_OK ) { error("HAL_DAC_Init failed"); } diff --git a/targets/TARGET_STM/TARGET_STM32L4/analogout_device.c b/targets/TARGET_STM/TARGET_STM32L4/analogout_device.c index bd5bafbd92b..92386ab594b 100644 --- a/targets/TARGET_STM/TARGET_STM32L4/analogout_device.c +++ b/targets/TARGET_STM/TARGET_STM32L4/analogout_device.c @@ -75,6 +75,8 @@ void analogout_init(dac_t *obj, PinName pin) { // Configure DAC obj->handle.Instance = DAC; + obj->handle.State = HAL_DAC_STATE_RESET; + if (HAL_DAC_Init(&obj->handle) != HAL_OK ) { error("HAL_DAC_Init failed"); } From 9583fff8a79d497b6ddf7f0b56a7bba49c779cd5 Mon Sep 17 00:00:00 2001 From: Russ Butler Date: Thu, 5 Oct 2017 16:31:14 -0500 Subject: [PATCH 069/108] Add error if OS tickrate is changed The current mbed-os drivers rely on a tickrate of 1ms for timing. This means that if OS_TICK_FREQ is set to any value other than 1000 then mbed-os driver will no longer delay for the correct amount of time. To prevent this from happening this patch triggers a compile time error if a tickrate other than 1m is used. --- rtos/TARGET_CORTEX/mbed_rtx_conf.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rtos/TARGET_CORTEX/mbed_rtx_conf.h b/rtos/TARGET_CORTEX/mbed_rtx_conf.h index 48a4456340c..a6cd655d9f3 100644 --- a/rtos/TARGET_CORTEX/mbed_rtx_conf.h +++ b/rtos/TARGET_CORTEX/mbed_rtx_conf.h @@ -41,6 +41,10 @@ #define OS_DYNAMIC_MEM_SIZE 0 +#if defined(OS_TICK_FREQ) && (OS_TICK_FREQ != 1000) +#error "OS Tickrate must be 1000 for system timing" +#endif + #if defined (__CC_ARM) || (defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)) /* ARM toolchain uses up to 8 static mutexes, any further mutexes will be allocated on the heap. */ #define OS_MUTEX_OBJ_MEM 1 From 7f31c76b2b4ae09d820c198325279ebd9444ae9c Mon Sep 17 00:00:00 2001 From: bcostm Date: Fri, 6 Oct 2017 15:44:16 +0200 Subject: [PATCH 070/108] STM32 RTC: initializes structures --- targets/TARGET_STM/rtc_api.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/targets/TARGET_STM/rtc_api.c b/targets/TARGET_STM/rtc_api.c index c9e9341cf8d..3be15602c6b 100644 --- a/targets/TARGET_STM/rtc_api.c +++ b/targets/TARGET_STM/rtc_api.c @@ -57,8 +57,8 @@ static void RTC_IRQHandler(void); void rtc_init(void) { - RCC_OscInitTypeDef RCC_OscInitStruct; - RCC_PeriphCLKInitTypeDef PeriphClkInitStruct; + RCC_OscInitTypeDef RCC_OscInitStruct = {0}; + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; // Enable access to Backup domain HAL_PWR_EnableBkUpAccess(); @@ -162,7 +162,7 @@ void rtc_free(void) #endif // Disable LSI and LSE clocks - RCC_OscInitTypeDef RCC_OscInitStruct; + RCC_OscInitTypeDef RCC_OscInitStruct = {0}; RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI | RCC_OSCILLATORTYPE_LSE; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; RCC_OscInitStruct.LSIState = RCC_LSI_OFF; @@ -217,8 +217,8 @@ It is then not a problem to not use shifts. time_t rtc_read(void) { - RTC_DateTypeDef dateStruct; - RTC_TimeTypeDef timeStruct; + RTC_DateTypeDef dateStruct = {0}; + RTC_TimeTypeDef timeStruct = {0}; struct tm timeinfo; RtcHandle.Instance = RTC; @@ -247,8 +247,8 @@ time_t rtc_read(void) void rtc_write(time_t t) { - RTC_DateTypeDef dateStruct; - RTC_TimeTypeDef timeStruct; + RTC_DateTypeDef dateStruct = {0}; + RTC_TimeTypeDef timeStruct = {0}; RtcHandle.Instance = RTC; From 817cead74d8b08a9722f77fd693af9197b615631 Mon Sep 17 00:00:00 2001 From: bcostm Date: Tue, 10 Oct 2017 16:42:08 +0200 Subject: [PATCH 071/108] Initialize State variable --- targets/TARGET_STM/rtc_api.c | 1 + 1 file changed, 1 insertion(+) diff --git a/targets/TARGET_STM/rtc_api.c b/targets/TARGET_STM/rtc_api.c index 3be15602c6b..fe6239177ee 100644 --- a/targets/TARGET_STM/rtc_api.c +++ b/targets/TARGET_STM/rtc_api.c @@ -64,6 +64,7 @@ void rtc_init(void) HAL_PWR_EnableBkUpAccess(); RtcHandle.Instance = RTC; + RtcHandle.State = HAL_RTC_STATE_RESET; #if !RTC_LSI RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSE; From b33ad2714dcc9a5637385a139dced367cba95a3b Mon Sep 17 00:00:00 2001 From: "andreas.larsson" Date: Wed, 4 Oct 2017 16:41:59 +0200 Subject: [PATCH 072/108] Updated u-blox ODIN-W2 binaries to 2.2 rc1 --- .../TOOLCHAIN_ARM/libublox-odin-w2-driver.ar | Bin 5538002 -> 6132180 bytes .../libublox-odin-w2-driver.a | Bin 1902510 -> 1967628 bytes .../TOOLCHAIN_IAR/libublox-odin-w2-driver.a | Bin 5261428 -> 5848736 bytes 3 files changed, 0 insertions(+), 0 deletions(-) diff --git a/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F439xI/TARGET_UBLOX_EVK_ODIN_W2/sdk/TOOLCHAIN_ARM/libublox-odin-w2-driver.ar b/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F439xI/TARGET_UBLOX_EVK_ODIN_W2/sdk/TOOLCHAIN_ARM/libublox-odin-w2-driver.ar index 4273207630a5227a218e1db7809ebe7227fff9fd..9fd6e5015abc6c63fe7731c8738727acea0b4f1e 100644 GIT binary patch literal 6132180 zcmeFa33yz`btYP9fB?9Nq^QMOC<&w>30g=1jfJ2r*=zvaM4MPz=mtUCN?MKX3!ueD zcdHi?bex#9wNSQ`XeOSF96Nb-;`hdRFJH!1>?BI;See+4oXM9FW6w-BKf^Owl*sc% z(&r@1mrV5jbE@jzy0>qGASE^!KY-t5-#X`1)u~gbPMunA)t(1ZrS#%Ewsd#6|9Xs| zd^i8^=omQA-!CDLY!RaETSENLW3H!Z^jWc%C$K9aF8lKfkBGp=QzL_x!uv&|o=uCL z;&MH$&wW)~%+q%FABl^4{t_zwCZG1>-x6>3*?j$d!uR>e%VP7Jc(#;_qUQPbt740K zwnmnP>-mkG*m{LM+kT--tmkvp`Q5_r*?!`4V&nP2mcfp1b&0q7*}3#p@q_eS{lE+2 zvORy%A+Bz~bIsMyip%v}+maD)>iO_T#kFtpx$eL-V%6uffah)D_lu3^%8|hh zztJ!Jo*VD#5U%Hw&x#x0;^(IMAyN1Fr;NC%&U5omeo3tM?A|WKs?U$VD0W}qxn<{9 zMI)YDZx*8NbN2n>R(ig7_L865mcArh&wo2BZd>ECC-$Pa=;!s1i9Hv1_I^DlF7(`f za7C>8eC_we?H71D55`2@XXOFWd6CZ@508mepZ|2NxWn_@IrKfTuFv0IEACvU=dO=@ zRlJ#}tN){7)#vA55?ve54}=Wvx$j$|=J`K`xM!8;-d*n({G5!5d*7<(wH|Tr1)lqU zzF%C8o<(I|&EAZ+5`KH+@^ zCpyFhpWn)e!Ap1!j2;sge17e$IIxCiXy3!)qMlz~7DGPI!5dx>7ybOZ&xnKc{NpF> z=l;~I;w^bzJ1y?_dERdQy13})?}x+#@BZ9HJr7>}`@()c@=M}D@AHojhzHg4j^xYY z2km+1H~v{%>T_tIUA*b%3pa>ESHKfWJS!UY4FAp{;eAH>&x&<@{+UeFN^p7KOeK7hfj=( zn&+=G;^F#FdTw?+G?_eMmCD&dUZ~(wAyds+lc^<3Lli;0Qp)BRe1V6v6~Kol!?9?2 zES1mXtVqeC_ymeum5J2ycs75$tRTtsQf4$;P8afdE3IQDvw1s}WXW2{mMd0CN6_K8 zRRT8-^sy0l8YSzo(Nra66O@Zyf^u=vT5y0P6Uq5PDQ$(SmBp$2q_td$XE+X$0B*sm zL<=LSVrnj%%T`X=z=;%b7tf_mSg}Gbn|3gspv%C>3fAOXvzI zXtS*gGF?!HNS46RuG)+hvJB-~1v%)0)7pg^LlcLNL5WkjT0&FRJlJf;%2%isjQX`r zC792;lqOpybB!3;bgE)WBS=K$a6Vl+Rdj*IE$Vr6-MrFkzZZ+g@+jWrLBU zrqil%svf~OG&NJQ%H?URT*%2Tj4Mf}plwlY0*;;M3^}?=EJ{+-T??>f)zwT|R>l!a z*~(GPNDCnQTh1C5kh&04odFuZp zdRvbTtd8l%N&RLr?X}1xbx8FeE(+>VCBX1s2;g`xGGsd?GDx=I2>cBhGW-}D;E4c| znmFW(aD`~6#*R!F?b1kK9a;}zytYCB@~sfS%?d$Ki&dlx`En&WJ*QsYW0eXbJ`qc% zOBOUUo?XbN$mx(U)eRF~_p9_Sdr)*Fg}gLX)bfrR*QbQymJkXrGJH2d_LtFYTZuSK}n7>SS(cL&LWO9*?F4uKBZ1f}eW zRQi;=gs77YM~9sz8|^i+lrlGd!zO5HB+Jz~@?(psOoj$Y<)vbhs!6dqeJnXL9UhG) z;>nSz2{H&%6E%Y%hH*PbC5@n;&r0J0Quq@QI4!8d_pv3GAdITKP~B&O!0B1kkcraA z_(-);#e_3pVzkqIB#$NUa0zLYVO_1I6tc=M3|HqRPlcsyvRFa0oG$V>W|+n?l;p^w zl|DYbtjoh7*XU0{BDumzjv#FcVrrv8HW6b!qJuTn?5iOAr~K})u7YOkMqIR%8n%hj z;eTW?lv&E=L*)9R4WUFDLItz(+@~7gNR|d*27p3u8TtcZd@Wdk(AABqP!p|gwC^6 zQE!E!prLSnz5r>AhL0wrlaVPBd#xmGtP-Xjw&fX0Bv6%0#Z*bEmnR&=qJoQ{&kN{R zfINA)q=LcWQ}7@va3q!(g>h(s$7+<4wVY;ub)r&*ftGj!gl<|=VRTZl*j07N449&u zhgBUul{i(jj;3-|OOtxR26YrtGs!rt@L&wHk(|;5;DY~nW*L}*<#L> zoDDPR%h0zDg;S3G0I2jjC8ebnAY7ccPn;FgM$f#;!iV}rM#nhWs!t8Q3J!+NH zrEIZMC^<>hqb*O(dy0{9NMoh!QmS-H5%?vB($ZMFK8-tx;Zw@+a{);Aqxp2M3J=7a z2hDK6H`9dW-@4=Jay5*+Rs>QhZCj59I zzfeE6*35boauqoh%s5fD@=MH>ZJ-Yn`AWRybebX;1uIP?j`)by%T^ z2?rM|m|}!u7S9zbeuARuJU@6WwP4Zw__S3d61OZKD#YVfrAkX<9xhCbn+ITyW(zqs zHq_HPoKMH&(VF5YpgRo`X=r|t_|03niIfimz9hA&=sGGF6ULGUm8X`LCnKf1hdJBY zGE{M(mzS~?_+f5(j7ni;!Y8O|Qe|4TQ8@r1i)xJ(%6e_VL8}?N!_+MmFmpyj zUWHBP3N*jK2_Y3}_+pryl0AuoarGY#IJ}&##Piwtd9?~c3?UueW0>BOLMcPzB%!+u zy%w+N9x9aCq&kGtZc}F>Y-3~skucl_ZWp|MYvPQ~!30lZdBzMUR8=^Ozy_9=6t#`< z!pVI2!PIoUEpbe;T3RI_I5HKs6>;MGR6B@$1TW2uTHaBTOk|<(m2AFRsFtV6;qied zT=3E97{+BT#uC|aIMNkTNUCbNd}F4ilxEqT1ER#zOXGz?k+yEg#$m<+9{r$R6g4rF z6E7ry^BTrINH_Nq>CX>06Y|*7WCXGc!-=SwsTUn4au)Oo%T+}TUby43*#Y&q!5#6283^pEN$2FmH}yfn2E%n(f*&Jm#sSl0A<>L* zKSpn|0oZj)AlhwLn=HCRHDyUO2u&5!Fbtd=LNce>Y-KT#l6i1Jh<1upfL^o>@D^lR z4c_2z6*1xgC0Z-|hpB1>OJta0$S(jWbHK0!cs43V;f%0mK`K|aJhGGtFVn;zQsKA& zz?kt~K}rfi?m=7--687;WP&EEOLG>s(`c_y30E?NRM6^aET^N`9kR;A@r5-73dwaG z$>w0Xy-;>pR9sLJ2Us7&o*iyy8o}+=j%s@r3Qe+b`g%WLh^9v?vKCPWj^GpaA&W0! z*+J(_@fc8#5b(MYbVN4+^$ztdzb*@w&M_2})i_&HtHIG!dOTHhz>Z0`DcPQK2r5U+ zom3H|0}7XKl=qS)3bTuF_s22A$LUG5(jU0TGrUj3M3rcH+#xVfYNgkJjAI$vdJIG4 zoKzc`x&dXs8l_Wiaf-&hP7of|2}|-xvoC&}LUZKK5;77-TpO-D6DL)zmA3xLyp;-$ zEOHm@PD!rblbei@kQ+taj9(T6hs#vNCIjA|XvXsFlyO+o?xpth9SpbsahE$!Ncgj^ z4MGY=9R=;%P(cXUj|zKK$@9@vSkSk3V^Bm}V>oY@y$u4-(fm=`LcyeG1pR0C8)GA* zacR~O9k0CancrYxiEHlI8GxnCG8=r5X}d~w>`n{Xr7M1vY&MLl+lXi=FAPZ(*WjqJ zx`fh<%FQ|a22Fr^tKP~;O^%zD=F^Z_0w{kYMAO`CY8_Z4S1m6(!6^*<<}rolKxl$Q zX5@yATV7~lIRv*Ed8;K9c)Ir6xJAOYJJcfePqwtE!;Q{+g0Akm=#p-6WXT~OSsKU8 zh;nL*aG?b6R&I5XABoa3A=TRWRSJ?{NA0yESJ@fIjgsHk!;x=gj+_x3Qf-spO&PNxls$&cxQnPZ zGaa2blIcN^Ry9{#TBr0+Rj*8VvAp}m;7KwsXBXK$Qt3+*Vg{HSo7`}pG*LLcSWtK@ zvBMBxx;2zeTg8e4GCCaytF;wHq|lH-a`#5M|kNUXdh z*|6iK=0XpqB%4Y3o_5IZ4r?+kG#!`yi>GuU{eNAD6nZ9S?wJR8qb(zM${ zR+px$(J>c7?(ufga5RZl6m3%0CKcix8-`x^gTbJVF1L7?YHmg$JvZ_y7kybM7u_sS zThrS$Woir5De{nueTMX0Xe2pL{hD<9$Kbi;cu5Oz(5f|7Ie$pQ5tImC)B?>H_)*CC z5}B2|UO-l22hb-6_+j2WjMU3CtLYPq;eMQnx%3h}at)KFP=>J|6~>fY618TefZho? zB6NT0L69^o!h-G>A$~cMQ?nLK;5)afFisVzOy%SR9AT;#RRAvvo1>zb4(44_xFco1sN~WPK7!#Y1Iq9{64!|Fumh{95F`NM&}T0-39Ct9 z%0{Usy_S^4&|R9EQ;{gP3TSyKFuXF!d&%C7>4@KfIZ}6Ej<8LbmZt+#tHmm7r2}z` zjuDoFrzlMw`l4+`Kx(dtuDo3sGdFvC8Hyy=I5-y@Y?R7|A!R?(c#+ra6rVOV<>rv1 z)emErQ>9R-Eb1v8ym`e=`r4_-gA&8?9wuS&!qajt_FBWJYBt~JxVlKyC zF)ISzH6!GeXyt&d$WRj*#%5(DR5{#4vFqWa0x`BWN}Bfz)2wAEhXp07<_YgtVmg70 z`{OZk>DA|sh{KKWgz{vTFjv4SNhqnf8K&(EWjHB%njYd?70us5syxiaX*&{qSVJw| zFTom|k($PhV@4v+UzN&S7;eu~$cbSGLskMqin15ZmIkY#yuHaGr;)s7%*8PwX5rpo zC$<(AP1ZQ?JPfQ?E@k0dXrpKb+FLq}@-3i3`jt_ke2S?sz9ltqHHGB@()xm0JCH(C zF*IDOA9M*AHLN}=zoM4gVr-Fd$A{6ej#?LCq#41t#VSXeoM1XF`o2=~b)iqLBo%g{ zV9m{rM1nL|i{ZK#sfVPv6yB_Q`DJJ!C&a9p$ zmOc&Psl-|-&E{8!!cZ(Xg;%!>tgm`Gcs~tuu+!FKK6>WheO1kk_GlZ$fT4BSBCK_! zkNc>S?xv~3mUGrDK@~8~Ue;xX^(cTB_)v2t^D9wTSSuhp3QRwG&8CFbHIsGFx{?T8 zYbF8J=B}pV{cuKVI-aYtb)4F2R+yR!R`A-YGZ1E_0c_htey?v2>!6J?s3uN7-ePE! zZ%Gu=uP_SbTOI>fQzRd&=kTvhm!Tl?D|x7iqq{_3#c*V)Myr8QOS|mXl*gT=btoWV z)jnFCku)1V2!n$f8wqkB8%fX$e3mMCSj{LR5s&=?q>lY#%(9X-PYH561=ukKg!NPS zIuwS=xGB6^V_vR2gv#C%N{pjU4_dk<&7zOrN~VTuv@KnhEJFfH%QT ztW~4f-+S7b==nkIrGR@a8@y`CXg^)&4xv!)D%VoEXn*S}69xneE51NlN`c;*=Xj7j zWejtj#ZIYyj9PLu4^J5Z@hKxg`GZqZU@Qksp2(EtNH88w&Kn;{4kHX%Ps>#ZE^s)B z84S$m(0V#CiQ@v~tPH)XEf4gHrb8w!jv-rQW1yg;||wuI~UHotUij`kpfDn}sb&A%Rj%=4PPs$kMwz^G1~H@Q3> zq7OZIcRL7l^^70E(x+_XOmBxY7Xa9NsP}rD0Ihhb@WDl#w#^B!tSOjN&Xi1E6ar2+ zuK{^bl2MGMiM{a=n(fChP2`Z3lT1~-7a@#bY3rc{{hdFE*@EQ)t zt{MAx<%mpjFcCVI42_H@$D@-+;=&ce76U9e+5=F#(&LHH$dP0bdTkFSz@~ya^lFp= z)bRLBI59Pq7)usQg*0sl(Bx(QLXr37;4?ou*aeGm{B;0GuuMna{!v?2FhFQ?4sXZA z^!Vu90<0}94r8g7SJyRC?bU=yv7?0LwqktgFsBwIJSaVxc{FR`ydozeyMpjGl-3X9 z>o*69jB`{k_Ld+2U7mJUhCQ=kacGmn7EM??>Bn=HRV2{;hMpRq{FFd29o354|-kM*yx5vgpGo<(2fji@isz_7>%eYwNB0v zYw=NYRem9vnv;Ce(!Hf|JY7ftCs`M2WNI>=G?dvr1ZM0K?=CA=D{M6IZ8c)x>vt?W zx?!+DXn4M0A8ND`?1`fGt0wH(Len{LPATN(K4<42fB#agX7%zff6p!|4nlI^@QTpCF02AT#;051r->Ia5o8 zEth6Pty&_5nqtI{XN!t&s4b2>2v2JlgNJQ1q3MJRP~(Zn(Vgv|m==vuv#}{p5`3iT zbR_IfcP5dTnskAt;v3i9g<#vXn2q9UbprL{*IR5_&=kM{*>QfIBXc_QXdtu>-9TQ;92HrG_N z0mUW9!9h`L&C7__J4o>=l{Mw33y1tDUUq4%5p{<6I0xd)zwaW;hiJ$T(bmSM&Mk-W z7!8SHu@h@5o+}>tR)H62NMpOgapmTf`CxUp2jwW2=*v?)Fp48d#GwvEyieWGTCyGzV-2-bw=8Hac?B;b_oT~#*U;P zrNaBlwzqG-n&&N7IPEo;(-Mvyp`0%iBZG}gc8s+|p#AYqgjF&b>BY&?z0ga49!7!+ ztxRx`O)$>ysojak09=rsm zHJ!kk(x~kYE+U%QF{~-t+PjF!cre-9zhqSw3mH1`tO5r(Iyq>afO}o;?Qv{pcp^TS z=~Db{&MLhSdA}n^;Qr1|hhj1O;;h$H8txuaDpd;Q!Nej>C&Q@q1`B1J1ysP8 z{#3H^XlxP2xrQuQm&~Uay@R@2prh_lOq|45&un^){Uyq36}#=tL3P+`i^1K=rSi0v zLSI^cb;%s9t<Y$q7t0#rqK?ZSYeZZ_h8= z!U^&tFBCxv(ut6s!;Fdfh5^d0d!O=;e$1YFA9axs;&`Q-J zX883{AFenh9B!1V;PfCDlwG$vF|ca^Gmq}X>`^3Gm@>XRDhdQl71#8S78sXE!F#E>7 zIT97pI$0@P!+JPiZ()p^pJ04u2RkD!V5IJ>B z$zs=3EQnb#_OIlIMt$rlFW}e9kn3noYIs1EDUD&Am07*&hip-uOl2!jfYnN(h?!Dr zWL?P~^rj3yu)dHEn)SdHw;CfZYRyTkx1TFch3nQ`u%{+3VlCD?z|pnVtP)>V1(XFX zOV{11l{!~Pje@;WNG#Dc*tB5KE!0fu#OhTR44P$KQx0W(6rE&A;KNToQiC<<(Rvmt zC@mCB2lmOD0tsSnS1LK9uxU%3-b-pO2WmboGT3JqaXyvJB`>U&Mhq!O7RqYc7VKA2 zkrgR9N4;0;w_@KYYG7Eea^uAsnKAgs~ zinRLrrM7CDJ5a!sL$botu*vx} zxhTG)kjY+Gydc-FVUg`gm~iaGYA%Qrg*&Z5)d-yq&rEGqQy=f)r7+K^2O^geau2d> z!Fj-1XdbXiV{@&owRKu4VSw zr>S5}R(I|>67NgKus~0f(A0ogvwC|b@Nr`4R17J$r@q}@EoXY2y4v=W=vMt8uQQ%jng0Cg?Ya+^oGNIu%Tf#{%fGcWDXbiQD>!S z)x=$FuTE(;>QyPVDZMbe+Ol4Na_}OAK(rSn1VmV)5Qvh5fE}}PcNm7&P5`xJAHyKg zYHD8*I}`f~pr^BG>m417iloNEp;&T`Pk;=afSW-dIBM`bKIq1mMEo%v(=h&*6Cxb8HtSPcDRspZr{In(Lvgs>S^n50JgSMu@rtf~q>#gwM0?J?hqtI@^C|cC zhy$tqxuI0LZ`JJ)Yl*98n~}47|5@;2V%JW%uO+sgC-$Fjzl0P#)9q_XL6^T~wtX#; z^(?jTWcx)XP&?PYmISm2{ioX3l7cRS-%R^O#;=)ZznJ*G^XwO$K=}zrhMbKDMLL?Bd|ukkjK24>ulr6O#d(+ZH+e>g*Y-}N=<`5^;*<RM$u7gfs@P%`=K@CV6$>OsK`->-l zz-5X~*Pz#InZHLTgD4>wgW~&0%mibCg?I)LPfZxFLG_MrqTGaJ=v|q^oU5ZET?~+K zz}rw{LI|o@yxAE!0usm65qB>LDk~Gc zfB6%~UH0m`XTVhiyy*hj%AKAwp!yp%>JY1Zw@`ZS*u>Om7)P72B7h?m&frVfQi1e9 z0klMQUy0QdZ0DZGsa%W6bP|W>V-xpW4|+(s{nhSMSEY-Ot%Yv-7}$u6hvH+pq%xqI zgbZMX0^2OZs`*HmRDI3y0b+RZB)AQx`UVEAV5*kex-^)PK4w~DR@VseKG*&YSwP9 z^eUSxT%>4;F5GrNY-MP_h#RV@^tb&^JPGkcQ$QycX=AC7sq)5HebKcKc0^;tE-%o?J);k{V?~P|xyM zZh07liQ>A`#TuegWrMIh$peD}R?m=MYpzdZ6r>&zTb*bSpI)oWbLd^^5521666lp{ z3_6jqtr;hpD;B`s0R9eQcXh3}>l1m|^GQjWn_ft0JT?V0P=Ns)FVbZh6jqGVE9TQm zgb6QIbMll^mk^hhNQl-@AGQ_s2J3L?OXTI!hX`E8N2628==4KQXE`x3k{p>B#VR-5 zimjG@z_*4|)ARvTpNely72zCx5x_E+5ji|dAAu?YU2T-Ak_Nr1YNJ=QQEL5stOAG0 zWU1Kb{cz2ziDZD8!AWlOxa}O@8es8rzDhTgB~SDw;hA%xX+szc9KL{d>qVhbgv4=T z;6Tq%Kipw&Gi1H+CGtw#hltg73dhN)GSe%G3gx0#l!_e_yt3B1IV)yKV+VtMnFFcd zd>zhwiM*Wo5P`Gsu|%}TR0aaT62VC@G=za(K+p?7C+H{@Md|kf4kiao5E;zFF(@Mu zCk?Aku+Vrys|E$N^3b~yB)^t%x<20v0>26}-P&dR@$3USv2qxbrc6AAT?D#_Of3y@M1A9;Ie{_O zpb>ndNnIOLD~a&C5&^%f!t%Q;nak3YPqIBcFm!NWuBV=*@g?$Vmk$x^eSCHb-#21m zNu5BbvzJaNEiK}Em*l|UeD6@-V7gYnSEVzUScQ)HkY9PG=HVbgW-^3PS=yp8lMGte zf==$W3_;Rb!V;iFECYI;O&8}Nb$(S?buuIU2M!DcGd_)V6)K}Bb*WI0MarXB{=l!z zETynqPoQLJ*%hpq!Jr!(Oae>A!S)(bNO=z_JlY`c{)WaZ^_q>;fV*0}0UxYGf53!O zW9Khx!!+o#8>J0)d*n;qK9#fMuw*0UU5Hm$t>FlH(yh_hcn`8Wht* zXZflv-bEMKnXVWnN>{1V7eN}CX<2p)jp znFxAfoOrF?pf_hR?Y!T9{uLM&XNUyaT zXG5jJQIK^7e9D2cJWI_7Oao!Xxr`xGpkCXVo8gc%GsD4o3+^XkIsx)R^s)^@v$(8? zKbDZ8vTlAV7^$-KIh3EnO<_?~0kuMg6fKK<#|WJbs6MP!K_w`{WXnDeD~%CtD&aVKt4wKGc(Bqe>cJagLe+A^yIsl z9z#6r%M|2{n9aWg8U=6x+$E@knk`_mf-KWROrXms12s&!N|_wPSq{B}h|6z%LH#z^ zPj8cnsWFMAH;JV;#?qk;f9|D=g>~Sed zJ$<6ht264O$QrA?N`EZA{L5GTQM0L19){SBtQ6o#sQjy0le3eO9JmRr6V78x2{#Ou zhYLct8>l%6SQ5;8xx)Gq3Pk~Bi(A~1;|cnRu|Su}(rX%Xee@AkszjAa5L2!cCKePb zTbAM`a5>L1q)yWe9!>EDZW?&PP2>($N;$rc%0T`M|jD;uh327)XHJzNurq!;s8dS!@)g6nNilbei^raYImEujnN}<~ct7B;7 z6uUbIC_)^*fIOq7CKJWHJBpel$D;JqxP2Ctn*_=;g^MNSynw!T#>*RsViQMd@&tI= zs^C05ITou)Sf3Vpfy8M(NG++%Vk3l9OV?HQ|MH7Gfl|^`#iath0+KmgMqN zcTp*2=c<^Nw`UooJ3`fyJXuV^9l=~f&s;D_OY7drNcNTLlh(K+^+?%QLi3084kuWs znENQEM(b$_V;u{Fn4pf*$N&;h0j$c{p+qUWuwa#t_Ox~CxOGaZu%v{UP1CHKW#$a~ zP`1>qia47w8dg`%K?!wz&|&n`X`W&Zh2zO;o=$7PVXx6VR&L3-5R_oHWO>r4SemCH z;ow}RKixZ5E7ST!hBWIDL5{KMNM7h;MvhGuXuS*fk@P3aIOIs+g&rC3Y75m4zUO`) zGw*82@RNk#{;BkJBC04B~>s;z#J))7b2& z2B+w_$`YFg4`?`Hjb1n)&)<(xvpxJQD3vp%Oj0DMeR?E6G z*O457X$T6)$E#ZE%zV{vF(1JBL!H$erqkWQI303bNLRRLp@8-pq>?zb=w(aO`7^DS z$T=%lZ7PT#lVz$8T}Jw1h2C*zOL3HU*2~o%1|UzkMYMn01GG(}7vr*