frdm k64f usb work well, add kinetis_k to ci cmake

This commit is contained in:
hathach 2024-02-24 00:36:07 +07:00
parent a1bfde83fb
commit 3d3bf45102
No known key found for this signature in database
GPG Key ID: F5D50C6D51D17CBA
8 changed files with 60 additions and 19 deletions

View File

@ -38,7 +38,7 @@ jobs:
family:
# Alphabetical order
- 'imxrt'
- 'kinetis_kl'
- 'kinetis_k kinetis_kl'
- 'lpc17 lpc18 lpc40 lpc43'
- 'lpc54 lpc55'
- 'mcx'

View File

@ -732,15 +732,27 @@
</dcdx>
<periphs name="Peripherals" version="13.0" enabled="true" update_project_code="true">
<dependencies>
<dependency resourceType="Tool" resourceId="Clocks" description="The Clocks tool is required by the Peripherals tool, but it is disabled." problem_level="2" source="Peripherals">
<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">
<feature name="enabled" evaluation="equal">
<data>true</data>
<data type="Boolean">true</data>
</feature>
</dependency>
<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">
<feature name="version" evaluation="compatible">
<data type="Version">2.8.0</data>
</feature>
</dependency>
</dependencies>
<generated_project_files>
<file path="board/peripherals.c" update_enabled="true"/>
<file path="board/peripherals.h" update_enabled="true"/>
<file path="source/generated/usb_device_composite.c" update_enabled="true"/>
<file path="source/generated/usb_device_composite.h" update_enabled="true"/>
<file path="source/generated/usb_device_config.h" update_enabled="true"/>
<file path="source/generated/usb_device_descriptor.c" update_enabled="true"/>
<file path="source/generated/usb_device_descriptor.h" update_enabled="true"/>
<file path="source/usb_device_interface_0_cic_vcom.c" update_enabled="true"/>
<file path="source/usb_device_interface_0_cic_vcom.h" update_enabled="true"/>
</generated_project_files>
<peripherals_profile>
<processor_version>14.0.0</processor_version>
@ -755,6 +767,31 @@
<data type="Boolean">true</data>
</feature>
</dependency>
<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">
<feature name="enabled" evaluation="equal">
<data type="Boolean">true</data>
</feature>
</dependency>
<dependency resourceType="SWComponent" resourceId="platform.drivers.common" description="&quot;Common&quot; driver is missing in the project." problem_level="2" source="Peripherals:BOARD_InitPeripherals">
<feature name="enabled" evaluation="equal">
<data type="Boolean">true</data>
</feature>
</dependency>
<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">
<feature name="frequency" evaluation="greaterThan">
<data type="Frequency" unit="Hz">0</data>
</feature>
</dependency>
<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">
<feature name="enabled" evaluation="equal">
<data type="Boolean">true</data>
</feature>
</dependency>
<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">
<feature name="enabled" evaluation="equal">
<data type="Boolean">true</data>
</feature>
</dependency>
</dependencies>
<instances>
<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 @@
<setting name="mpuInit" value="disabled"/>
</config_set>
</instance>
<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">
<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">
<config_set name="deviceSetting" quick_selection="QS_DEVICE_CDC_VCOM">
<setting name="vendor_id" value="0x1FC9"/>
<setting name="product_id" value="0x0094"/>

View File

@ -30,6 +30,7 @@
#include "fsl_port.h"
#include "fsl_clock.h"
#include "fsl_uart.h"
#include "fsl_sysmpu.h"
#include "board/clock_config.h"
#include "board/pin_mux.h"
@ -50,6 +51,7 @@ void board_init(void) {
BOARD_InitBootPins();
BOARD_BootClockRUN();
SystemCoreClockUpdate();
SYSMPU_Enable(SYSMPU, 0);
#if CFG_TUSB_OS == OPT_OS_NONE
// 1ms tick timer
@ -84,7 +86,7 @@ void board_init(void) {
#endif
// USB
CLOCK_EnableUsbfs0Clock(kCLOCK_UsbSrcPll0, CLOCK_GetFreq(kCLOCK_PllFllSelClk));
// USB clock is configured in BOARD_BootClockRUN()
}
//--------------------------------------------------------------------+

View File

@ -40,6 +40,7 @@ function(add_board_target BOARD_TARGET)
${SDK_DIR}/drivers/gpio
${SDK_DIR}/drivers/port
${SDK_DIR}/drivers/smc
${SDK_DIR}/drivers/sysmpu
${SDK_DIR}/drivers/uart
)

View File

@ -29,6 +29,7 @@ INC += \
$(TOP)/$(SDK_DIR)/drivers/gpio \
$(TOP)/$(SDK_DIR)/drivers/port \
$(TOP)/$(SDK_DIR)/drivers/smc \
$(TOP)/$(SDK_DIR)/drivers/sysmpu \
$(TOP)/$(SDK_DIR)/drivers/uart \
SRC_S += ${SDK_DIR}/devices/${MCU_VARIANT}/gcc/startup_${MCU_VARIANT}.S

View File

@ -36,14 +36,12 @@
#define CI_FS_REG(_port) ((ci_fs_regs_t*) USB0_BASE)
#define CI_REG CI_FS_REG(0)
void dcd_int_enable(uint8_t rhport)
{
void dcd_int_enable(uint8_t rhport) {
(void) rhport;
NVIC_EnableIRQ(USB0_IRQn);
}
void dcd_int_disable(uint8_t rhport)
{
void dcd_int_disable(uint8_t rhport) {
(void) rhport;
NVIC_DisableIRQ(USB0_IRQn);
}

View File

@ -271,9 +271,17 @@ void dcd_init(uint8_t rhport)
{
(void) rhport;
// save crystal-less setting (recovery clock)
uint32_t clk_recover_irc_en = CI_REG->CLK_RECOVER_IRC_EN;
uint32_t clk_recover_ctrl = CI_REG->CLK_RECOVER_CTRL;;
CI_REG->USBTRC0 |= USB_USBTRC0_USBRESET_MASK;
while (CI_REG->USBTRC0 & USB_USBTRC0_USBRESET_MASK);
// restore crystal-less setting
CI_REG->CLK_RECOVER_IRC_EN = clk_recover_irc_en;
CI_REG->CLK_RECOVER_CTRL |= clk_recover_ctrl;
tu_memclr(&_dcd, sizeof(_dcd));
CI_REG->USBTRC0 |= TU_BIT(6); /* software must set this bit to 1 */
CI_REG->BDT_PAGE1 = (uint8_t)((uintptr_t)_dcd.bdt >> 8);

View File

@ -269,22 +269,16 @@ void dcd_init(uint8_t rhport)
{
(void) rhport;
#if (CFG_TUSB_MCU == OPT_MCU_KINETIS_K)
uint32_t clk_recover_irc_en;
uint32_t clk_recover_ctrl;
clk_recover_irc_en = KHCI->CLK_RECOVER_IRC_EN;
clk_recover_ctrl = KHCI->CLK_RECOVER_CTRL;
// save crystal-less setting (recovery clock)
uint32_t clk_recover_irc_en = KHCI->CLK_RECOVER_IRC_EN;
uint32_t clk_recover_ctrl = KHCI->CLK_RECOVER_CTRL;
KHCI->USBTRC0 |= USB_USBTRC0_USBRESET_MASK;
while (KHCI->USBTRC0 & USB_USBTRC0_USBRESET_MASK);
// restore crystal-less setting
KHCI->CLK_RECOVER_IRC_EN = clk_recover_irc_en;
KHCI->CLK_RECOVER_CTRL |= clk_recover_ctrl;
#else
KHCI->USBTRC0 |= USB_USBTRC0_USBRESET_MASK;
while (KHCI->USBTRC0 & USB_USBTRC0_USBRESET_MASK);
#endif
tu_memclr(&_dcd, sizeof(_dcd));
KHCI->USBTRC0 |= TU_BIT(6); /* software must set this bit to 1 */