Skip to content

Commit 3d3bf45

Browse files
committed
frdm k64f usb work well, add kinetis_k to ci cmake
1 parent a1bfde8 commit 3d3bf45

File tree

8 files changed

+60
-19
lines changed

8 files changed

+60
-19
lines changed

.github/workflows/cmake_arm.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
family:
3939
# Alphabetical order
4040
- 'imxrt'
41-
- 'kinetis_kl'
41+
- 'kinetis_k kinetis_kl'
4242
- 'lpc17 lpc18 lpc40 lpc43'
4343
- 'lpc54 lpc55'
4444
- 'mcx'

hw/bsp/kinetis_k/boards/frdm_k64f/frdm_k64f.mex

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -732,15 +732,27 @@
732732
</dcdx>
733733
<periphs name="Peripherals" version="13.0" enabled="true" update_project_code="true">
734734
<dependencies>
735-
<dependency resourceType="Tool" resourceId="Clocks" description="The Clocks tool is required by the Peripherals tool, but it is disabled." problem_level="2" source="Peripherals">
735+
<dependency resourceType="SWComponent" resourceId="middleware.usb.common_header" description="USB Common Header is not found in the toolchain/IDE project. The project will not compile!" problem_level="2" source="Peripherals">
736736
<feature name="enabled" evaluation="equal">
737-
<data>true</data>
737+
<data type="Boolean">true</data>
738+
</feature>
739+
</dependency>
740+
<dependency resourceType="SWComponent" resourceId="middleware.usb.common_header" description="An unsupported version of the USB Common Header in the toolchain/IDE project. Required: ${required_value}, actual: ${actual_value}. The project might not compile correctly." problem_level="1" source="Peripherals">
741+
<feature name="version" evaluation="compatible">
742+
<data type="Version">2.8.0</data>
738743
</feature>
739744
</dependency>
740745
</dependencies>
741746
<generated_project_files>
742747
<file path="board/peripherals.c" update_enabled="true"/>
743748
<file path="board/peripherals.h" update_enabled="true"/>
749+
<file path="source/generated/usb_device_composite.c" update_enabled="true"/>
750+
<file path="source/generated/usb_device_composite.h" update_enabled="true"/>
751+
<file path="source/generated/usb_device_config.h" update_enabled="true"/>
752+
<file path="source/generated/usb_device_descriptor.c" update_enabled="true"/>
753+
<file path="source/generated/usb_device_descriptor.h" update_enabled="true"/>
754+
<file path="source/usb_device_interface_0_cic_vcom.c" update_enabled="true"/>
755+
<file path="source/usb_device_interface_0_cic_vcom.h" update_enabled="true"/>
744756
</generated_project_files>
745757
<peripherals_profile>
746758
<processor_version>14.0.0</processor_version>
@@ -755,6 +767,31 @@
755767
<data type="Boolean">true</data>
756768
</feature>
757769
</dependency>
770+
<dependency resourceType="SWComponent" resourceId="middleware.usb.device_controller_khci" description="&quot;USB Device KHCI Controller Driver(FS)&quot; component is missing in the project." problem_level="2" source="Peripherals:BOARD_InitPeripherals">
771+
<feature name="enabled" evaluation="equal">
772+
<data type="Boolean">true</data>
773+
</feature>
774+
</dependency>
775+
<dependency resourceType="SWComponent" resourceId="platform.drivers.common" description="&quot;Common&quot; driver is missing in the project." problem_level="2" source="Peripherals:BOARD_InitPeripherals">
776+
<feature name="enabled" evaluation="equal">
777+
<data type="Boolean">true</data>
778+
</feature>
779+
</dependency>
780+
<dependency resourceType="ClockOutput" resourceId="USB48MCLK" description="USB Function Clock (USB48MCLK) is inactive and USB module will not work." problem_level="2" source="Peripherals:BOARD_InitPeripherals">
781+
<feature name="frequency" evaluation="greaterThan">
782+
<data type="Frequency" unit="Hz">0</data>
783+
</feature>
784+
</dependency>
785+
<dependency resourceType="SWComponent" resourceId="middleware.usb.device.cdc.external" description="&quot;USB device CDC&quot; driver is missing in the project." problem_level="2" source="Peripherals:BOARD_InitPeripherals">
786+
<feature name="enabled" evaluation="equal">
787+
<data type="Boolean">true</data>
788+
</feature>
789+
</dependency>
790+
<dependency resourceType="SWComponent" resourceId="middleware.usb.device.cdc.external" description="&quot;USB device CDC&quot; driver is missing in the project." problem_level="2" source="Peripherals:BOARD_InitPeripherals">
791+
<feature name="enabled" evaluation="equal">
792+
<data type="Boolean">true</data>
793+
</feature>
794+
</dependency>
758795
</dependencies>
759796
<instances>
760797
<instance name="NVIC" uuid="e1a88231-4d9e-46a3-b134-d2c743110640" type="nvic" type_id="nvic_57b5eef3774cc60acaede6f5b8bddc67" mode="general" peripheral="NVIC" enabled="true" comment="" custom_name_enabled="false" editing_lock="false">
@@ -789,7 +826,7 @@
789826
<setting name="mpuInit" value="disabled"/>
790827
</config_set>
791828
</instance>
792-
<instance name="USB0" uuid="cc0eb411-8fed-4548-b79c-9a8340cc02fd" type="usb" type_id="usb_cbf31fb9a3cef21890d93e737c3d2690" mode="device" peripheral="USB0" enabled="false" comment="" custom_name_enabled="false" editing_lock="false">
829+
<instance name="USB0" uuid="cc0eb411-8fed-4548-b79c-9a8340cc02fd" type="usb" type_id="usb_cbf31fb9a3cef21890d93e737c3d2690" mode="device" peripheral="USB0" enabled="true" comment="" custom_name_enabled="false" editing_lock="false">
793830
<config_set name="deviceSetting" quick_selection="QS_DEVICE_CDC_VCOM">
794831
<setting name="vendor_id" value="0x1FC9"/>
795832
<setting name="product_id" value="0x0094"/>

hw/bsp/kinetis_k/family.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "fsl_port.h"
3131
#include "fsl_clock.h"
3232
#include "fsl_uart.h"
33+
#include "fsl_sysmpu.h"
3334

3435
#include "board/clock_config.h"
3536
#include "board/pin_mux.h"
@@ -50,6 +51,7 @@ void board_init(void) {
5051
BOARD_InitBootPins();
5152
BOARD_BootClockRUN();
5253
SystemCoreClockUpdate();
54+
SYSMPU_Enable(SYSMPU, 0);
5355

5456
#if CFG_TUSB_OS == OPT_OS_NONE
5557
// 1ms tick timer
@@ -84,7 +86,7 @@ void board_init(void) {
8486
#endif
8587

8688
// USB
87-
CLOCK_EnableUsbfs0Clock(kCLOCK_UsbSrcPll0, CLOCK_GetFreq(kCLOCK_PllFllSelClk));
89+
// USB clock is configured in BOARD_BootClockRUN()
8890
}
8991

9092
//--------------------------------------------------------------------+

hw/bsp/kinetis_k/family.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ function(add_board_target BOARD_TARGET)
4040
${SDK_DIR}/drivers/gpio
4141
${SDK_DIR}/drivers/port
4242
${SDK_DIR}/drivers/smc
43+
${SDK_DIR}/drivers/sysmpu
4344
${SDK_DIR}/drivers/uart
4445
)
4546

hw/bsp/kinetis_k/family.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ INC += \
2929
$(TOP)/$(SDK_DIR)/drivers/gpio \
3030
$(TOP)/$(SDK_DIR)/drivers/port \
3131
$(TOP)/$(SDK_DIR)/drivers/smc \
32+
$(TOP)/$(SDK_DIR)/drivers/sysmpu \
3233
$(TOP)/$(SDK_DIR)/drivers/uart \
3334

3435
SRC_S += ${SDK_DIR}/devices/${MCU_VARIANT}/gcc/startup_${MCU_VARIANT}.S

src/portable/chipidea/ci_fs/ci_fs_kinetis.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,12 @@
3636
#define CI_FS_REG(_port) ((ci_fs_regs_t*) USB0_BASE)
3737
#define CI_REG CI_FS_REG(0)
3838

39-
void dcd_int_enable(uint8_t rhport)
40-
{
39+
void dcd_int_enable(uint8_t rhport) {
4140
(void) rhport;
4241
NVIC_EnableIRQ(USB0_IRQn);
4342
}
4443

45-
void dcd_int_disable(uint8_t rhport)
46-
{
44+
void dcd_int_disable(uint8_t rhport) {
4745
(void) rhport;
4846
NVIC_DisableIRQ(USB0_IRQn);
4947
}

src/portable/chipidea/ci_fs/dcd_ci_fs.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,17 @@ void dcd_init(uint8_t rhport)
271271
{
272272
(void) rhport;
273273

274+
// save crystal-less setting (recovery clock)
275+
uint32_t clk_recover_irc_en = CI_REG->CLK_RECOVER_IRC_EN;
276+
uint32_t clk_recover_ctrl = CI_REG->CLK_RECOVER_CTRL;;
277+
274278
CI_REG->USBTRC0 |= USB_USBTRC0_USBRESET_MASK;
275279
while (CI_REG->USBTRC0 & USB_USBTRC0_USBRESET_MASK);
276280

281+
// restore crystal-less setting
282+
CI_REG->CLK_RECOVER_IRC_EN = clk_recover_irc_en;
283+
CI_REG->CLK_RECOVER_CTRL |= clk_recover_ctrl;
284+
277285
tu_memclr(&_dcd, sizeof(_dcd));
278286
CI_REG->USBTRC0 |= TU_BIT(6); /* software must set this bit to 1 */
279287
CI_REG->BDT_PAGE1 = (uint8_t)((uintptr_t)_dcd.bdt >> 8);

src/portable/nxp/khci/dcd_khci.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -269,22 +269,16 @@ void dcd_init(uint8_t rhport)
269269
{
270270
(void) rhport;
271271

272-
#if (CFG_TUSB_MCU == OPT_MCU_KINETIS_K)
273-
uint32_t clk_recover_irc_en;
274-
uint32_t clk_recover_ctrl;
275-
276-
clk_recover_irc_en = KHCI->CLK_RECOVER_IRC_EN;
277-
clk_recover_ctrl = KHCI->CLK_RECOVER_CTRL;
272+
// save crystal-less setting (recovery clock)
273+
uint32_t clk_recover_irc_en = KHCI->CLK_RECOVER_IRC_EN;
274+
uint32_t clk_recover_ctrl = KHCI->CLK_RECOVER_CTRL;
278275

279276
KHCI->USBTRC0 |= USB_USBTRC0_USBRESET_MASK;
280277
while (KHCI->USBTRC0 & USB_USBTRC0_USBRESET_MASK);
281278

279+
// restore crystal-less setting
282280
KHCI->CLK_RECOVER_IRC_EN = clk_recover_irc_en;
283281
KHCI->CLK_RECOVER_CTRL |= clk_recover_ctrl;
284-
#else
285-
KHCI->USBTRC0 |= USB_USBTRC0_USBRESET_MASK;
286-
while (KHCI->USBTRC0 & USB_USBTRC0_USBRESET_MASK);
287-
#endif
288282

289283
tu_memclr(&_dcd, sizeof(_dcd));
290284
KHCI->USBTRC0 |= TU_BIT(6); /* software must set this bit to 1 */

0 commit comments

Comments
 (0)