From 046f3cdb26a9a5882d40177522c1557ff7439ddf Mon Sep 17 00:00:00 2001 From: Mahadevan Mahesh Date: Thu, 13 Oct 2016 10:03:23 -0500 Subject: [PATCH 1/4] Update USB driver for devices with Kinetis SDK support 1. Fix build issues with IAR and GCC toolchain 2. Update clock initialization code Signed-off-by: Mahadevan Mahesh --- .../USBDevice/USBDevice/USBHAL_KL25Z.cpp | 25 ++++++------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/features/unsupported/USBDevice/USBDevice/USBHAL_KL25Z.cpp b/features/unsupported/USBDevice/USBDevice/USBHAL_KL25Z.cpp index 4948fe44a9..853f1cc433 100644 --- a/features/unsupported/USBDevice/USBDevice/USBHAL_KL25Z.cpp +++ b/features/unsupported/USBDevice/USBDevice/USBHAL_KL25Z.cpp @@ -18,6 +18,9 @@ #if defined(TARGET_KL25Z) | defined(TARGET_KL43Z) | defined(TARGET_KL46Z) | defined(TARGET_K20D50M) | defined(TARGET_K64F) | defined(TARGET_K22F) | defined(TARGET_TEENSY3_1) +#if defined(TARGET_KSDK2_MCUS) +#include "fsl_common.h" +#endif #include "USBHAL.h" USBHAL * USBHAL::instance; @@ -65,7 +68,8 @@ typedef struct BDT { // there are: // * 16 bidirectionnal endpt -> 32 physical endpt // * as there are ODD and EVEN buffer -> 32*2 bdt -__attribute__((__aligned__(512))) BDT bdt[NUMBER_OF_PHYSICAL_ENDPOINTS * 2]; +MBED_ALIGN(512) BDT bdt[NUMBER_OF_PHYSICAL_ENDPOINTS * 2]; // 512 bytes aligned! + uint8_t * endpoint_buffer[(NUMBER_OF_PHYSICAL_ENDPOINTS - 2) * 2]; uint8_t * endpoint_buffer_iso[2*2]; @@ -86,7 +90,7 @@ USBHAL::USBHAL(void) { // Disable IRQ NVIC_DisableIRQ(USB0_IRQn); -#if defined(TARGET_K64F) +#if (defined(FSL_FEATURE_SOC_MPU_COUNT) && (FSL_FEATURE_SOC_MPU_COUNT > 0U)) MPU->CESR=0; #endif // fill in callback array @@ -121,18 +125,9 @@ USBHAL::USBHAL(void) { epCallback[28] = &USBHAL::EP15_OUT_callback; epCallback[29] = &USBHAL::EP15_IN_callback; -#if defined(TARGET_KL43Z) +#if defined(TARGET_KL43Z) || defined(TARGET_K22F) || defined(TARGET_K64F) // enable USBFS clock - SIM->SCGC4 |= SIM_SCGC4_USBFS_MASK; - - // enable the IRC48M clock - USB0->CLK_RECOVER_IRC_EN |= USB_CLK_RECOVER_IRC_EN_IRC_EN_MASK; - - // enable the USB clock recovery tuning - USB0->CLK_RECOVER_CTRL |= USB_CLK_RECOVER_CTRL_CLOCK_RECOVER_EN_MASK; - - // choose usb src clock - SIM->SOPT2 |= SIM_SOPT2_USBSRC_MASK; + CLOCK_EnableUsbfs0Clock(kCLOCK_UsbSrcIrc48M, 48000000U); #else // choose usb src as PLL SIM->SOPT2 &= ~SIM_SOPT2_PLLFLLSEL_MASK; @@ -148,10 +143,6 @@ USBHAL::USBHAL(void) { NVIC_EnableIRQ(USB0_IRQn); // USB Module Configuration - // Reset USB Module - USB0->USBTRC0 |= USB_USBTRC0_USBRESET_MASK; - while(USB0->USBTRC0 & USB_USBTRC0_USBRESET_MASK); - // Set BDT Base Register USB0->BDTPAGE1 = (uint8_t)((uint32_t)bdt>>8); USB0->BDTPAGE2 = (uint8_t)((uint32_t)bdt>>16); From ef56b3d712e64c28795d3d0da47d06a3cde085b3 Mon Sep 17 00:00:00 2001 From: Mahadevan Mahesh Date: Fri, 28 Oct 2016 12:10:50 -0500 Subject: [PATCH 2/4] FAT tests: Add support for KL43Z Signed-off-by: Mahadevan Mahesh --- features/unsupported/tests/mbed/sd/main.cpp | 2 +- features/unsupported/tests/mbed/sd_perf_fatfs/main.cpp | 2 +- features/unsupported/tests/mbed/sd_perf_fhandle/main.cpp | 2 +- features/unsupported/tests/mbed/sd_perf_stdio/main.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/features/unsupported/tests/mbed/sd/main.cpp b/features/unsupported/tests/mbed/sd/main.cpp index 246be53424..7edf69853f 100644 --- a/features/unsupported/tests/mbed/sd/main.cpp +++ b/features/unsupported/tests/mbed/sd/main.cpp @@ -5,7 +5,7 @@ #if defined(TARGET_KL25Z) SDFileSystem sd(PTD2, PTD3, PTD1, PTD0, "sd"); -#elif defined(TARGET_KL46Z) +#elif defined(TARGET_KL46Z) || defined(TARGET_KL43Z) SDFileSystem sd(PTD6, PTD7, PTD5, PTD4, "sd"); #elif defined(TARGET_K64F) || defined(TARGET_K66F) diff --git a/features/unsupported/tests/mbed/sd_perf_fatfs/main.cpp b/features/unsupported/tests/mbed/sd_perf_fatfs/main.cpp index d71c3e2b85..d4eee731af 100644 --- a/features/unsupported/tests/mbed/sd_perf_fatfs/main.cpp +++ b/features/unsupported/tests/mbed/sd_perf_fatfs/main.cpp @@ -7,7 +7,7 @@ #if defined(TARGET_KL25Z) SDFileSystem sd(PTD2, PTD3, PTD1, PTD0, "sd"); -#elif defined(TARGET_KL46Z) +#elif defined(TARGET_KL46Z) || defined(TARGET_KL43Z) SDFileSystem sd(PTD6, PTD7, PTD5, PTD4, "sd"); #elif defined(TARGET_K64F) || defined(TARGET_K66F) diff --git a/features/unsupported/tests/mbed/sd_perf_fhandle/main.cpp b/features/unsupported/tests/mbed/sd_perf_fhandle/main.cpp index 50dd6f356d..c9c8bc8277 100644 --- a/features/unsupported/tests/mbed/sd_perf_fhandle/main.cpp +++ b/features/unsupported/tests/mbed/sd_perf_fhandle/main.cpp @@ -7,7 +7,7 @@ #if defined(TARGET_KL25Z) SDFileSystem sd(PTD2, PTD3, PTD1, PTD0, "sd"); -#elif defined(TARGET_KL46Z) +#elif defined(TARGET_KL46Z) || defined(TARGET_KL43Z) SDFileSystem sd(PTD6, PTD7, PTD5, PTD4, "sd"); #elif defined(TARGET_K64F) || defined(TARGET_K66F) diff --git a/features/unsupported/tests/mbed/sd_perf_stdio/main.cpp b/features/unsupported/tests/mbed/sd_perf_stdio/main.cpp index 74e35b063a..10855ee595 100644 --- a/features/unsupported/tests/mbed/sd_perf_stdio/main.cpp +++ b/features/unsupported/tests/mbed/sd_perf_stdio/main.cpp @@ -7,7 +7,7 @@ #if defined(TARGET_KL25Z) SDFileSystem sd(PTD2, PTD3, PTD1, PTD0, "sd"); -#elif defined(TARGET_KL46Z) +#elif defined(TARGET_KL46Z) || defined(TARGET_KL43Z) SDFileSystem sd(PTD6, PTD7, PTD5, PTD4, "sd"); #elif defined(TARGET_K64F) || defined(TARGET_K66F) From 6750f488ed0416dd67f84746d15bdc844a5ee4f1 Mon Sep 17 00:00:00 2001 From: Mahadevan Mahesh Date: Thu, 27 Oct 2016 16:28:31 -0500 Subject: [PATCH 3/4] Add K64F, K22F and KL43Z to travis build Signed-off-by: Mahadevan Mahesh --- tools/build_travis.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tools/build_travis.py b/tools/build_travis.py index f4b3f01fc7..55b26d1ba9 100644 --- a/tools/build_travis.py +++ b/tools/build_travis.py @@ -137,6 +137,30 @@ linking_list = [ "rtos" : ["RTOS_1", "RTOS_2", "RTOS_3"], "usb" : ["USB_1", "USB_2" ,"USB_3"], } + }, + {"target": "K64F", + "toolchains": "GCC_ARM", + "tests": {"" : ["MBED_2", "MBED_10", "MBED_11", "MBED_15", "MBED_16", "MBED_17"], + "fat" : ["MBED_A12", "PERF_1", "PERF_2", "PERF_3"], + "rtos" : ["RTOS_1", "RTOS_2", "RTOS_3"], + "usb" : ["USB_1", "USB_2" ,"USB_3"], + } + }, + {"target": "K22F", + "toolchains": "GCC_ARM", + "tests": {"" : ["MBED_2", "MBED_10", "MBED_11", "MBED_15", "MBED_16", "MBED_17"], + "fat" : ["MBED_A12", "PERF_1", "PERF_2", "PERF_3"], + "rtos" : ["RTOS_1", "RTOS_2", "RTOS_3"], + "usb" : ["USB_1", "USB_2" ,"USB_3"], + } + }, + {"target": "KL43Z", + "toolchains": "GCC_ARM", + "tests": {"" : ["MBED_2", "MBED_10", "MBED_11", "MBED_15", "MBED_16", "MBED_17"], + "fat" : ["MBED_A12", "PERF_1", "PERF_2", "PERF_3"], + "rtos" : ["RTOS_1", "RTOS_2", "RTOS_3"], + "usb" : ["USB_1", "USB_2" ,"USB_3"], + } } ] From edd6cac71826f791c9ea9ef13e8b3e43d04ff3ff Mon Sep 17 00:00:00 2001 From: Brian Daniels Date: Mon, 31 Oct 2016 12:42:15 -0500 Subject: [PATCH 4/4] Adding Kinetis devices to mbed 2 tests and updating build_travis script --- tools/build_travis.py | 7 ++++--- tools/tests.py | 16 ++++++++-------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/tools/build_travis.py b/tools/build_travis.py index 55b26d1ba9..13a3d6f0c8 100644 --- a/tools/build_travis.py +++ b/tools/build_travis.py @@ -98,6 +98,7 @@ build_list = ( { "target": "K20D50M", "toolchains": "GCC_ARM", "libs": ["dsp", "fat"] }, { "target": "TEENSY3_1", "toolchains": "GCC_ARM", "libs": ["dsp", "fat"] }, { "target": "K64F", "toolchains": "GCC_ARM", "libs": ["dsp", "rtos", "usb", "fat"] }, + { "target": "K22F", "toolchains": "GCC_ARM", "libs": ["dsp", "rtos", "usb", "fat"] }, { "target": "LPC4088", "toolchains": "GCC_ARM", "libs": ["dsp", "rtos", "usb", "fat"] }, { "target": "ARCH_PRO", "toolchains": "GCC_ARM", "libs": ["dsp", "rtos", "fat"] }, { "target": "LPC1549", "toolchains": "GCC_ARM", "libs": ["dsp", "rtos", "fat"] }, @@ -140,7 +141,7 @@ linking_list = [ }, {"target": "K64F", "toolchains": "GCC_ARM", - "tests": {"" : ["MBED_2", "MBED_10", "MBED_11", "MBED_15", "MBED_16", "MBED_17"], + "tests": {"" : ["MBED_2", "MBED_10", "MBED_11", "MBED_16"], "fat" : ["MBED_A12", "PERF_1", "PERF_2", "PERF_3"], "rtos" : ["RTOS_1", "RTOS_2", "RTOS_3"], "usb" : ["USB_1", "USB_2" ,"USB_3"], @@ -148,7 +149,7 @@ linking_list = [ }, {"target": "K22F", "toolchains": "GCC_ARM", - "tests": {"" : ["MBED_2", "MBED_10", "MBED_11", "MBED_15", "MBED_16", "MBED_17"], + "tests": {"" : ["MBED_2", "MBED_10", "MBED_11", "MBED_16"], "fat" : ["MBED_A12", "PERF_1", "PERF_2", "PERF_3"], "rtos" : ["RTOS_1", "RTOS_2", "RTOS_3"], "usb" : ["USB_1", "USB_2" ,"USB_3"], @@ -156,7 +157,7 @@ linking_list = [ }, {"target": "KL43Z", "toolchains": "GCC_ARM", - "tests": {"" : ["MBED_2", "MBED_10", "MBED_11", "MBED_15", "MBED_16", "MBED_17"], + "tests": {"" : ["MBED_2", "MBED_10", "MBED_11", "MBED_16"], "fat" : ["MBED_A12", "PERF_1", "PERF_2", "PERF_3"], "rtos" : ["RTOS_1", "RTOS_2", "RTOS_3"], "usb" : ["USB_1", "USB_2" ,"USB_3"], diff --git a/tools/tests.py b/tools/tests.py index b4103f02c9..0c82bcf936 100644 --- a/tools/tests.py +++ b/tools/tests.py @@ -730,7 +730,7 @@ TESTS = [ "automated": True, #"host_test": "wait_us_auto", "mcu": ["LPC1768", "LPC1549", "LPC11U24", "LPC812", "LPC2460", "LPC824", "SSCI824", - "KL25Z", "KL05Z", "K64F", "K66F", "KL46Z", "HEXIWEAR", + "KL25Z", "KL05Z", "K22F", "K64F", "K66F", "KL43Z", "KL46Z", "HEXIWEAR", "RZ_A1H", "VK_RZ_A1H", "DISCO_F407VG", "DISCO_F429ZI", "NUCLEO_F411RE", "DISCO_F469NI", "NUCLEO_F410RB", "NUCLEO_F429ZI", "NUCLEO_F401RE", "NUCLEO_F334R8", "DISCO_F334C8", "NUCLEO_F302R8", "NUCLEO_F070RB", "NUCLEO_F207ZG", "NUCLEO_L073RZ", "NUCLEO_F072RB", "NUCLEO_F091RC", "NUCLEO_L432KC", "DISCO_L476VG", "NUCLEO_L476RG", @@ -744,7 +744,7 @@ TESTS = [ "dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, TEST_MBED_LIB], "automated": True, "mcu": ["LPC1768", "LPC1549", "LPC11U24", "LPC812", "LPC2460", "LPC824", "SSCI824", - "KL25Z", "KL05Z", "K64F", "K66F", "KL46Z", "HEXIWEAR", + "KL25Z", "KL05Z", "K22F", "K64F", "K66F", "KL43Z", "KL46Z", "HEXIWEAR", "RZ_A1H", "VK_RZ_A1H", "DISCO_F407VG", "DISCO_F429ZI", "NUCLEO_F411RE", "DISCO_F469NI", "NUCLEO_F410RB", "NUCLEO_F429ZI", "NUCLEO_F401RE", "NUCLEO_F334R8", "DISCO_F334C8", "NUCLEO_F302R8", "NUCLEO_F303ZE", "NUCLEO_F070RB", "NUCLEO_F207ZG", "NUCLEO_L073RZ", "NUCLEO_F072RB", "NUCLEO_F091RC", "NUCLEO_L432KC", "DISCO_L476VG", "NUCLEO_L476RG", @@ -759,7 +759,7 @@ TESTS = [ "dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, TEST_MBED_LIB], "automated": True, "mcu": ["LPC1768", "LPC1549", "LPC11U24", "LPC812", "LPC2460", "LPC824", "SSCI824", - "KL25Z", "KL05Z", "K64F", "K66F", "KL46Z", "HEXIWEAR", + "KL25Z", "KL05Z", "K22F", "K64F", "K66F", "KL43Z", "KL46Z", "HEXIWEAR", "RZ_A1H", "VK_RZ_A1H", "DISCO_F407VG", "DISCO_F429ZI", "NUCLEO_F411RE", "DISCO_F469NI", "NUCLEO_F410RB", "NUCLEO_F429ZI", "NUCLEO_F401RE", "NUCLEO_F334R8", "DISCO_F334C8", "NUCLEO_F302R8", "NUCLEO_F303ZE", "NUCLEO_F070RB", "NUCLEO_F207ZG", "NUCLEO_L073RZ", "NUCLEO_F072RB", "NUCLEO_F091RC", "NUCLEO_L432KC", "DISCO_L476VG", "NUCLEO_L476RG", @@ -775,7 +775,7 @@ TESTS = [ "dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, TEST_MBED_LIB], "automated": True, "mcu": ["LPC1768", "LPC1549", "LPC11U24", "LPC812", "LPC2460", "LPC824", "SSCI824", - "KL25Z", "KL05Z", "K64F", "K66F", "KL46Z", "HEXIWEAR", + "KL25Z", "KL05Z", "K22F", "K64F", "K66F", "KL43Z", "KL46Z", "HEXIWEAR", "RZ_A1H", "VK_RZ_A1H", "DISCO_F407VG", "DISCO_F429ZI", "NUCLEO_F411RE", "DISCO_F469NI", "NUCLEO_F410RB", "NUCLEO_F429ZI", "NUCLEO_F401RE", "NUCLEO_F334R8", "DISCO_F334C8", "NUCLEO_F302R8", "NUCLEO_F303ZE", "NUCLEO_F070RB", "NUCLEO_F207ZG", "NUCLEO_L073RZ", "NUCLEO_F072RB", "NUCLEO_F091RC", "NUCLEO_L432KC", "DISCO_L476VG", "NUCLEO_L476RG", @@ -791,7 +791,7 @@ TESTS = [ "dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, TEST_MBED_LIB], "automated": True, "mcu": ["LPC1768", "LPC1549", "LPC11U24", "LPC812", "LPC2460", "LPC824", "SSCI824", - "KL25Z", "KL05Z", "K64F", "K66F", "KL46Z", "HEXIWEAR", + "KL25Z", "KL05Z", "K22F", "K64F", "K66F", "KL43Z", "KL46Z", "HEXIWEAR", "RZ_A1H", "VK_RZ_A1H", "DISCO_F407VG", "DISCO_F429ZI", "NUCLEO_F411RE", "DISCO_F469NI", "NUCLEO_F410RB", "NUCLEO_F429ZI", "NUCLEO_F401RE", "NUCLEO_F334R8", "DISCO_F334C8", "NUCLEO_F302R8", "NUCLEO_F303ZE", "NUCLEO_F070RB", "NUCLEO_F207ZG", "NUCLEO_L073RZ", "NUCLEO_F072RB", "NUCLEO_F091RC", "NUCLEO_L432KC", "DISCO_L476VG", "NUCLEO_L476RG", @@ -806,7 +806,7 @@ TESTS = [ "dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, TEST_MBED_LIB], "automated": True, "mcu": ["LPC1768", "LPC1549", "LPC11U24", "LPC812", "LPC2460", "LPC824", "SSCI824", - "KL25Z", "KL05Z", "K64F", "K66F", "KL46Z", "HEXIWEAR", + "KL25Z", "KL05Z", "K22F", "K64F", "K66F", "KL43Z", "KL46Z", "HEXIWEAR", "RZ_A1H", "VK_RZ_A1H", "DISCO_F407VG", "DISCO_F429ZI", "NUCLEO_F411RE", "DISCO_F469NI", "NUCLEO_F410RB", "NUCLEO_F429ZI", "NUCLEO_F401RE", "NUCLEO_F334R8", "DISCO_F334C8", "NUCLEO_F302R8", "NUCLEO_F303ZE", "NUCLEO_F070RB", "NUCLEO_F207ZG", "NUCLEO_L073RZ", "NUCLEO_F072RB", "NUCLEO_F091RC", "NUCLEO_L432KC", "DISCO_L476VG", "NUCLEO_L476RG", @@ -822,7 +822,7 @@ TESTS = [ "automated": True, #"host_test": "wait_us_auto", "mcu": ["LPC1768", "LPC1549", "LPC11U24", "LPC812", "LPC2460", "LPC824", "SSCI824", - "KL25Z", "KL05Z", "K64F", "K66F", "KL46Z", "HEXIWEAR", + "KL25Z", "KL05Z", "K22F", "K64F", "K66F", "KL43Z", "KL46Z", "HEXIWEAR", "RZ_A1H", "VK_RZ_A1H", "DISCO_F407VG", "DISCO_F429ZI", "NUCLEO_F411RE", "DISCO_F469NI", "NUCLEO_F410RB", "NUCLEO_F429ZI", "NUCLEO_F401RE", "NUCLEO_F334R8", "DISCO_F334C8", "NUCLEO_F302R8", "NUCLEO_F303ZE", "NUCLEO_F070RB", "NUCLEO_F207ZG", "NUCLEO_L073RZ", "NUCLEO_F072RB", "NUCLEO_F091RC", "NUCLEO_L432KC", "DISCO_L476VG", "NUCLEO_L476RG", @@ -837,7 +837,7 @@ TESTS = [ "dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, TEST_MBED_LIB], "automated": True, "mcu": ["LPC1768", "LPC1549", "LPC11U24", "LPC812", "LPC2460", "LPC824", "SSCI824", - "KL25Z", "KL05Z", "K64F", "K66F", "KL46Z", "HEXIWEAR", + "KL25Z", "KL05Z", "K22F", "K64F", "K66F", "KL43Z", "KL46Z", "HEXIWEAR", "RZ_A1H", "VK_RZ_A1H", "DISCO_F407VG", "DISCO_F429ZI", "NUCLEO_F411RE", "DISCO_F469NI", "NUCLEO_F410RB", "NUCLEO_F429ZI", "NUCLEO_F401RE", "NUCLEO_F334R8", "DISCO_F334C8", "NUCLEO_F302R8", "NUCLEO_F303ZE", "NUCLEO_F070RB", "NUCLEO_F207ZG", "NUCLEO_L073RZ", "NUCLEO_F072RB", "NUCLEO_F091RC", "NUCLEO_L432KC", "DISCO_L476VG", "NUCLEO_L476RG",