Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update USB driver for devices with Kinetis SDK support #3014

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 8 additions & 17 deletions features/unsupported/USBDevice/USBDevice/USBHAL_KL25Z.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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];

Expand All @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion features/unsupported/tests/mbed/sd/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion features/unsupported/tests/mbed/sd_perf_fatfs/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion features/unsupported/tests/mbed/sd_perf_fhandle/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion features/unsupported/tests/mbed/sd_perf_stdio/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
24 changes: 24 additions & 0 deletions tools/build_travis.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,30 @@
"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"],
}
}
]

Expand Down