mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-31 05:52:55 +08:00
enable CFG_TUD/THU_MEM_DCACHE_ENABLE for imxrt with M7 by default
This commit is contained in:
parent
a39e30db92
commit
22a6777c2d
@ -11,11 +11,11 @@
|
||||
|
||||
/* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
|
||||
!!GlobalInfo
|
||||
product: Clocks v12.0
|
||||
product: Clocks v14.0
|
||||
processor: MIMXRT1176xxxxx
|
||||
package_id: MIMXRT1176DVMAA
|
||||
mcu_data: ksdk2_0
|
||||
processor_version: 14.0.1
|
||||
processor_version: 16.3.0
|
||||
board: MIMXRT1170-EVKB
|
||||
* BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/
|
||||
|
||||
@ -335,7 +335,6 @@ void BOARD_BootClockRUN(void)
|
||||
|
||||
/* Init OSC RC 400M */
|
||||
CLOCK_OSC_EnableOscRc400M();
|
||||
CLOCK_OSC_GateOscRc400M(false);
|
||||
|
||||
/* Init OSC RC 48M */
|
||||
CLOCK_OSC_EnableOsc48M(true);
|
||||
@ -349,22 +348,29 @@ void BOARD_BootClockRUN(void)
|
||||
{
|
||||
}
|
||||
|
||||
/* Switch both core, M7 Systick and Bus_Lpsr to OscRC48MDiv2 first */
|
||||
/* Switch core M7 clock root to OscRC48MDiv2 first */
|
||||
#if __CORTEX_M == 7
|
||||
rootCfg.mux = kCLOCK_M7_ClockRoot_MuxOscRc48MDiv2;
|
||||
rootCfg.div = 1;
|
||||
CLOCK_SetRootClock(kCLOCK_Root_M7, &rootCfg);
|
||||
#endif
|
||||
|
||||
/* Switch core M7 systick clock root to OscRC48MDiv2 first */
|
||||
#if __CORTEX_M == 7
|
||||
rootCfg.mux = kCLOCK_M7_SYSTICK_ClockRoot_MuxOscRc48MDiv2;
|
||||
rootCfg.div = 1;
|
||||
CLOCK_SetRootClock(kCLOCK_Root_M7_Systick, &rootCfg);
|
||||
#endif
|
||||
|
||||
/* Switch core M4 clock root to OscRC48MDiv2 first */
|
||||
#if __CORTEX_M == 4
|
||||
rootCfg.mux = kCLOCK_M4_ClockRoot_MuxOscRc48MDiv2;
|
||||
rootCfg.div = 1;
|
||||
CLOCK_SetRootClock(kCLOCK_Root_M4, &rootCfg);
|
||||
#endif
|
||||
|
||||
/* Switch the Bus_Lpsr clock root to OscRC48MDiv2 first */
|
||||
#if __CORTEX_M == 4
|
||||
rootCfg.mux = kCLOCK_BUS_LPSR_ClockRoot_MuxOscRc48MDiv2;
|
||||
rootCfg.div = 1;
|
||||
CLOCK_SetRootClock(kCLOCK_Root_Bus_Lpsr, &rootCfg);
|
||||
|
@ -48,7 +48,7 @@ void BOARD_InitBootClocks(void);
|
||||
#define BOARD_BOOTCLOCKRUN_ARM_PLL_CLK 996000000UL /* Clock consumers of ARM_PLL_CLK output : N/A */
|
||||
#define BOARD_BOOTCLOCKRUN_ASRC_CLK_ROOT 24000000UL /* Clock consumers of ASRC_CLK_ROOT output : ASRC */
|
||||
#define BOARD_BOOTCLOCKRUN_AXI_CLK_ROOT 996000000UL /* Clock consumers of AXI_CLK_ROOT output : FLEXRAM */
|
||||
#define BOARD_BOOTCLOCKRUN_BUS_CLK_ROOT 240000000UL /* Clock consumers of BUS_CLK_ROOT output : ADC_ETC, AOI1, AOI2, CAAM, CAN1, CAN2, CM7_GPIO2, CM7_GPIO3, CMP1, CMP2, CMP3, CMP4, CSI, DAC, DMA0, DMAMUX0, DSI_HOST, EMVSIM1, EMVSIM2, ENC1, ENC2, ENC3, ENC4, ENET, ENET_1G, ENET_QOS, EWM, FLEXIO1, FLEXIO2, FLEXSPI1, FLEXSPI2, GPIO1, GPIO2, GPIO3, GPIO4, GPIO5, GPIO6, IEE_APC, IOMUXC, IOMUXC_GPR, KPP, LCDIF, LCDIFV2, LPADC1, LPADC2, LPI2C1, LPI2C2, LPI2C3, LPI2C4, LPSPI1, LPSPI2, LPSPI3, LPSPI4, LPUART1, LPUART10, LPUART2, LPUART3, LPUART4, LPUART5, LPUART6, LPUART7, LPUART8, LPUART9, MECC1, MECC2, MIPI_CSI2RX, PIT1, PWM1, PWM2, PWM3, PWM4, PXP, RTWDOG3, SAI1, SAI2, SAI3, SPDIF, TMR1, TMR2, TMR3, TMR4, USBPHY1, USBPHY2, USB_OTG1, USB_OTG2, USDHC1, USDHC2, WDOG1, WDOG2, XBARA1, XBARB2, XBARB3, XECC_FLEXSPI1, XECC_FLEXSPI2, XECC_SEMC, XRDC2_D0, XRDC2_D1 */
|
||||
#define BOARD_BOOTCLOCKRUN_BUS_CLK_ROOT 240000000UL /* Clock consumers of BUS_CLK_ROOT output : ADC_ETC, AOI1, AOI2, CAAM, CAN1, CAN2, CM7_GPIO2, CM7_GPIO3, CMP1, CMP2, CMP3, CMP4, CSI, DAC, DMA0, DMAMUX0, DSI_HOST, EMVSIM1, EMVSIM2, ENC1, ENC2, ENC3, ENC4, ENET, ENET_1G, ENET_QOS, EWM, FLEXIO1, FLEXIO2, FLEXSPI1, FLEXSPI2, GPIO1, GPIO2, GPIO3, GPIO4, GPIO5, GPIO6, IEE_APC, IEE__IEE_RT1170, IOMUXC, IOMUXC_GPR, KPP, LCDIF, LCDIFV2, LPADC1, LPADC2, LPI2C1, LPI2C2, LPI2C3, LPI2C4, LPSPI1, LPSPI2, LPSPI3, LPSPI4, LPUART1, LPUART10, LPUART2, LPUART3, LPUART4, LPUART5, LPUART6, LPUART7, LPUART8, LPUART9, MECC1, MECC2, MIPI_CSI2RX, PIT1, PWM1, PWM2, PWM3, PWM4, PXP, RTWDOG3, SAI1, SAI2, SAI3, SPDIF, TMR1, TMR2, TMR3, TMR4, USBPHY1, USBPHY2, USB_OTG1, USB_OTG2, USDHC1, USDHC2, WDOG1, WDOG2, XBARA1, XBARB2, XBARB3, XECC_FLEXSPI1, XECC_FLEXSPI2, XECC_SEMC, XRDC2_D0, XRDC2_D1 */
|
||||
#define BOARD_BOOTCLOCKRUN_BUS_LPSR_CLK_ROOT 160000000UL /* Clock consumers of BUS_LPSR_CLK_ROOT output : CAN3, GPIO10, GPIO11, GPIO12, GPIO7, GPIO8, GPIO9, IOMUXC_LPSR, LPI2C5, LPI2C6, LPSPI5, LPSPI6, LPUART11, LPUART12, MUA, MUB, PDM, PIT2, RDC, RTWDOG4, SAI4, SNVS, XRDC2_D0, XRDC2_D1 */
|
||||
#define BOARD_BOOTCLOCKRUN_CAN1_CLK_ROOT 24000000UL /* Clock consumers of CAN1_CLK_ROOT output : CAN1 */
|
||||
#define BOARD_BOOTCLOCKRUN_CAN2_CLK_ROOT 24000000UL /* Clock consumers of CAN2_CLK_ROOT output : CAN2 */
|
||||
|
@ -6,11 +6,11 @@
|
||||
/*
|
||||
* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
|
||||
!!GlobalInfo
|
||||
product: Pins v14.0
|
||||
product: Pins v16.0
|
||||
processor: MIMXRT1176xxxxx
|
||||
package_id: MIMXRT1176DVMAA
|
||||
mcu_data: ksdk2_0
|
||||
processor_version: 14.0.1
|
||||
processor_version: 16.3.0
|
||||
board: MIMXRT1170-EVKB
|
||||
external_user_signals: {}
|
||||
pin_labels:
|
||||
@ -90,7 +90,7 @@ void BOARD_InitPins(void) {
|
||||
IOMUXC_GPIO_AD_04_GPIO9_IO03, /* GPIO_AD_04 PAD functional properties : */
|
||||
0x02U); /* Slew Rate Field: Slow Slew Rate
|
||||
Drive Strength Field: high drive strength
|
||||
Pull / Keep Select Field: Pull Disable, Highz
|
||||
Pull / Keep Select Field: Pull Disable
|
||||
Pull Up / Down Config. Field: Weak pull down
|
||||
Open Drain Field: Disabled
|
||||
Domain write protection: Both cores are allowed
|
||||
@ -99,7 +99,7 @@ void BOARD_InitPins(void) {
|
||||
IOMUXC_GPIO_AD_24_LPUART1_TXD, /* GPIO_AD_24 PAD functional properties : */
|
||||
0x02U); /* Slew Rate Field: Slow Slew Rate
|
||||
Drive Strength Field: high drive strength
|
||||
Pull / Keep Select Field: Pull Disable, Highz
|
||||
Pull / Keep Select Field: Pull Disable
|
||||
Pull Up / Down Config. Field: Weak pull down
|
||||
Open Drain Field: Disabled
|
||||
Domain write protection: Both cores are allowed
|
||||
@ -108,22 +108,19 @@ void BOARD_InitPins(void) {
|
||||
IOMUXC_GPIO_AD_25_LPUART1_RXD, /* GPIO_AD_25 PAD functional properties : */
|
||||
0x02U); /* Slew Rate Field: Slow Slew Rate
|
||||
Drive Strength Field: high drive strength
|
||||
Pull / Keep Select Field: Pull Disable, Highz
|
||||
Pull / Keep Select Field: Pull Disable
|
||||
Pull Up / Down Config. Field: Weak pull down
|
||||
Open Drain Field: Disabled
|
||||
Domain write protection: Both cores are allowed
|
||||
Domain write protection lock: Neither of DWP bits is locked */
|
||||
IOMUXC_SetPinConfig(
|
||||
IOMUXC_WAKEUP_DIG_GPIO13_IO00, /* WAKEUP_DIG PAD functional properties : */
|
||||
0x0EU); /* Slew Rate Field: Slow Slew Rate
|
||||
Drive Strength Field: high driver
|
||||
Pull / Keep Select Field: Pull Enable
|
||||
0x0EU); /* Pull / Keep Select Field: Pull Enable
|
||||
Pull Up / Down Config. Field: Weak pull up
|
||||
Open Drain SNVS Field: Disabled
|
||||
Domain write protection: Both cores are allowed
|
||||
Domain write protection lock: Neither of DWP bits is locked */
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************
|
||||
* EOF
|
||||
**********************************************************************************************************************/
|
||||
|
@ -46,7 +46,7 @@ void BOARD_InitBootPins(void);
|
||||
#define BOARD_INITPINS_USER_LED_GPIO_PIN 3U /*!< GPIO pin number */
|
||||
#define BOARD_INITPINS_USER_LED_GPIO_PIN_MASK (1U << 3U) /*!< GPIO pin mask */
|
||||
|
||||
/* WAKEUP (coord T8), USER_BUTTON */
|
||||
/* WAKEUP (coord T8), USER_BUTTON/SW7 */
|
||||
/* Routed pin properties */
|
||||
#define BOARD_INITPINS_USER_BUTTON_PERIPHERAL GPIO13 /*!< Peripheral name */
|
||||
#define BOARD_INITPINS_USER_BUTTON_SIGNAL gpio_io /*!< Signal name */
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding= "UTF-8" ?>
|
||||
<configuration name="MIMXRT1176xxxxx" xsi:schemaLocation="http://mcuxpresso.nxp.com/XSD/mex_configuration_14 http://mcuxpresso.nxp.com/XSD/mex_configuration_14.xsd" uuid="060646c1-2247-47a8-b52d-03c1968b4426" version="14" xmlns="http://mcuxpresso.nxp.com/XSD/mex_configuration_14" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<configuration name="MIMXRT1176xxxxx" xsi:schemaLocation="http://mcuxpresso.nxp.com/XSD/mex_configuration_16 http://mcuxpresso.nxp.com/XSD/mex_configuration_16.xsd" uuid="060646c1-2247-47a8-b52d-03c1968b4426" version="16" xmlns="http://mcuxpresso.nxp.com/XSD/mex_configuration_16" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<common>
|
||||
<processor>MIMXRT1176xxxxx</processor>
|
||||
<package>MIMXRT1176DVMAA</package>
|
||||
@ -19,18 +19,17 @@
|
||||
<generate_registers_defines>false</generate_registers_defines>
|
||||
</preferences>
|
||||
<tools>
|
||||
<pins name="Pins" version="14.0" enabled="true" update_project_code="true">
|
||||
<pins name="Pins" version="16.0" enabled="true" update_project_code="true">
|
||||
<generated_project_files>
|
||||
<file path="board/pin_mux.c" update_enabled="true"/>
|
||||
<file path="board/pin_mux.h" update_enabled="true"/>
|
||||
</generated_project_files>
|
||||
<pins_profile>
|
||||
<processor_version>14.0.1</processor_version>
|
||||
<processor_version>16.3.0</processor_version>
|
||||
<pin_labels>
|
||||
<pin_label pin_num="M13" pin_signal="GPIO_AD_04" label="SIM1_PD/J44[C8]/USER_LED_CTL1/J9[8]/J25[7]" identifier="SIM1_PD;LED;USER_LED"/>
|
||||
</pin_labels>
|
||||
<external_user_signals>
|
||||
<routingDetailsColumns/>
|
||||
<properties/>
|
||||
</external_user_signals>
|
||||
<power_domains/>
|
||||
@ -44,7 +43,7 @@
|
||||
<enableClock>true</enableClock>
|
||||
</options>
|
||||
<dependencies>
|
||||
<dependency resourceType="Peripheral" resourceId="LPUART1" description="Peripheral LPUART1 is not initialized" problem_level="1" source="Pins:BOARD_InitPins">
|
||||
<dependency resourceType="Peripheral" resourceId="LPUART1" description="Peripheral LPUART1 signals are routed in the Pins Tool, but the peripheral is not initialized in the Peripherals Tool." problem_level="1" source="Pins:BOARD_InitPins">
|
||||
<feature name="initialized" evaluation="equal">
|
||||
<data>true</data>
|
||||
</feature>
|
||||
@ -104,13 +103,13 @@
|
||||
</function>
|
||||
</functions_list>
|
||||
</pins>
|
||||
<clocks name="Clocks" version="12.0" enabled="true" update_project_code="true">
|
||||
<clocks name="Clocks" version="14.0" enabled="true" update_project_code="true">
|
||||
<generated_project_files>
|
||||
<file path="board/clock_config.c" update_enabled="true"/>
|
||||
<file path="board/clock_config.h" update_enabled="true"/>
|
||||
</generated_project_files>
|
||||
<clocks_profile>
|
||||
<processor_version>14.0.1</processor_version>
|
||||
<processor_version>16.3.0</processor_version>
|
||||
</clocks_profile>
|
||||
<clock_configurations>
|
||||
<clock_configuration name="BOARD_BootClockRUN" id_prefix="" prefix_user_defined="false">
|
||||
|
@ -24,10 +24,10 @@
|
||||
* This file is part of the TinyUSB stack.
|
||||
*/
|
||||
|
||||
#include "board.h"
|
||||
#include "bsp/board_api.h"
|
||||
#include "board/clock_config.h"
|
||||
#include "board/pin_mux.h"
|
||||
#include "bsp/board_api.h"
|
||||
#include "board.h"
|
||||
|
||||
// Suppress warning caused by mcu driver
|
||||
#ifdef __GNUC__
|
||||
@ -47,14 +47,14 @@
|
||||
#endif
|
||||
|
||||
/* --- Note about USB buffer RAM ---
|
||||
For M7 core it's recommended to put USB buffer in DTCM for better performance (flexspi_nor linker default)
|
||||
Otherwise you have to put the buffer in a non-cacheable section by configurate MPU manually or using BOARD_ConfigMPU():
|
||||
- Define CFG_TUSB_MEM_SECTION=__attribute__((section("NonCacheable")))
|
||||
- (IAR only) Change __NCACHE_REGION_SIZE in linker script to cover the size of non-cacheable section, multiple of 2^N
|
||||
For M7 core it's recommended to put USB buffer in DTCM for better performance (flexspi_nor linker default)
|
||||
Otherwise you have to put the buffer in a non-cacheable section by configurate MPU manually or using BOARD_ConfigMPU():
|
||||
- Define CFG_TUSB_MEM_SECTION=__attribute__((section("NonCacheable")))
|
||||
- (IAR only) Change __NCACHE_REGION_SIZE in linker script to cover the size of non-cacheable section, multiple of 2^N
|
||||
|
||||
For secondary M4 core, the USB controller doesn't support transfer from DTCM so OCRAM must be used:
|
||||
- __NCACHE_REGION_SIZE is defined by the linker script by default
|
||||
- Define CFG_TUSB_MEM_SECTION=__attribute__((section("NonCacheable")))
|
||||
For secondary M4 core, the USB controller doesn't support transfer from DTCM so OCRAM must be used:
|
||||
- __NCACHE_REGION_SIZE is defined by the linker script by default
|
||||
- Define CFG_TUSB_MEM_SECTION=__attribute__((section("NonCacheable")))
|
||||
*/
|
||||
|
||||
static void BOARD_ConfigMPU(void);
|
||||
@ -148,7 +148,112 @@ void board_init(void) {
|
||||
#endif
|
||||
}
|
||||
|
||||
/* MPU configuration. */
|
||||
//--------------------------------------------------------------------+
|
||||
// USB Interrupt Handler
|
||||
//--------------------------------------------------------------------+
|
||||
void USB_OTG1_IRQHandler(void) {
|
||||
tusb_int_handler(0, true);
|
||||
}
|
||||
|
||||
void USB_OTG2_IRQHandler(void) {
|
||||
tusb_int_handler(1, true);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Board porting API
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
void board_led_write(bool state) {
|
||||
GPIO_PinWrite(LED_PORT, LED_PIN, state ? LED_STATE_ON : (1 - LED_STATE_ON));
|
||||
}
|
||||
|
||||
uint32_t board_button_read(void) {
|
||||
return BUTTON_STATE_ACTIVE == GPIO_PinRead(BUTTON_PORT, BUTTON_PIN);
|
||||
}
|
||||
|
||||
size_t board_get_unique_id(uint8_t id[], size_t max_len) {
|
||||
(void) max_len;
|
||||
|
||||
#if FSL_FEATURE_OCOTP_HAS_TIMING_CTRL
|
||||
OCOTP_Init(OCOTP, CLOCK_GetFreq(kCLOCK_IpgClk));
|
||||
#else
|
||||
OCOTP_Init(OCOTP, 0u);
|
||||
#endif
|
||||
|
||||
// Reads shadow registers 0x01 - 0x04 (Configuration and Manufacturing Info)
|
||||
// into 8 bit wide destination, avoiding punning.
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
uint32_t wr = OCOTP_ReadFuseShadowRegister(OCOTP, i + 1);
|
||||
for (int j = 0; j < 4; j++) {
|
||||
id[i * 4 + j] = wr & 0xff;
|
||||
wr >>= 8;
|
||||
}
|
||||
}
|
||||
OCOTP_Deinit(OCOTP);
|
||||
|
||||
return 16;
|
||||
}
|
||||
|
||||
int board_uart_read(uint8_t *buf, int len) {
|
||||
int count = 0;
|
||||
|
||||
while (count < len) {
|
||||
uint8_t const rx_count = LPUART_GetRxFifoCount(UART_PORT);
|
||||
if (!rx_count) {
|
||||
// clear all error flag if any
|
||||
uint32_t status_flags = LPUART_GetStatusFlags(UART_PORT);
|
||||
status_flags &= (kLPUART_RxOverrunFlag | kLPUART_ParityErrorFlag | kLPUART_FramingErrorFlag |
|
||||
kLPUART_NoiseErrorFlag);
|
||||
LPUART_ClearStatusFlags(UART_PORT, status_flags);
|
||||
break;
|
||||
}
|
||||
|
||||
for (int i = 0; i < rx_count; i++) {
|
||||
buf[count] = LPUART_ReadByte(UART_PORT);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
int board_uart_write(void const *buf, int len) {
|
||||
LPUART_WriteBlocking(UART_PORT, (uint8_t const *) buf, len);
|
||||
return len;
|
||||
}
|
||||
|
||||
#if CFG_TUSB_OS == OPT_OS_NONE
|
||||
volatile uint32_t system_ticks = 0;
|
||||
void SysTick_Handler(void) {
|
||||
system_ticks++;
|
||||
}
|
||||
|
||||
uint32_t board_millis(void) {
|
||||
return system_ticks;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef __ICCARM__
|
||||
// Implement _start() since we use linker flag '-nostartfiles'.
|
||||
// Requires defined __STARTUP_CLEAR_BSS,
|
||||
extern int main(void);
|
||||
TU_ATTR_UNUSED void _start(void) {
|
||||
// called by startup code
|
||||
main();
|
||||
while (1) {}
|
||||
}
|
||||
|
||||
#ifdef __clang__
|
||||
void _exit(int __status) {
|
||||
while (1) {}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// MPU configuration
|
||||
//--------------------------------------------------------------------
|
||||
#if __CORTEX_M == 7
|
||||
static void BOARD_ConfigMPU(void) {
|
||||
#if defined(__CC_ARM) || defined(__ARMCC_VERSION)
|
||||
@ -343,7 +448,9 @@ static void BOARD_ConfigMPU(void) {
|
||||
SCB_EnableICache();
|
||||
#endif
|
||||
}
|
||||
|
||||
#elif __CORTEX_M == 4
|
||||
|
||||
void BOARD_ConfigMPU(void) {
|
||||
#if defined(__CC_ARM) || defined(__ARMCC_VERSION)
|
||||
extern uint32_t Image$$RW_m_ncache$$Base[];
|
||||
@ -525,107 +632,3 @@ void BOARD_ConfigMPU(void) {
|
||||
LMEM->PCCCR |= LMEM_PCCCR_ENCACHE_MASK;
|
||||
}
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USB Interrupt Handler
|
||||
//--------------------------------------------------------------------+
|
||||
void USB_OTG1_IRQHandler(void) {
|
||||
tusb_int_handler(0, true);
|
||||
}
|
||||
|
||||
void USB_OTG2_IRQHandler(void) {
|
||||
tusb_int_handler(1, true);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Board porting API
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
void board_led_write(bool state) {
|
||||
GPIO_PinWrite(LED_PORT, LED_PIN, state ? LED_STATE_ON : (1 - LED_STATE_ON));
|
||||
}
|
||||
|
||||
uint32_t board_button_read(void) {
|
||||
return BUTTON_STATE_ACTIVE == GPIO_PinRead(BUTTON_PORT, BUTTON_PIN);
|
||||
}
|
||||
|
||||
size_t board_get_unique_id(uint8_t id[], size_t max_len) {
|
||||
(void) max_len;
|
||||
|
||||
#if FSL_FEATURE_OCOTP_HAS_TIMING_CTRL
|
||||
OCOTP_Init(OCOTP, CLOCK_GetFreq(kCLOCK_IpgClk));
|
||||
#else
|
||||
OCOTP_Init(OCOTP, 0u);
|
||||
#endif
|
||||
|
||||
// Reads shadow registers 0x01 - 0x04 (Configuration and Manufacturing Info)
|
||||
// into 8 bit wide destination, avoiding punning.
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
uint32_t wr = OCOTP_ReadFuseShadowRegister(OCOTP, i + 1);
|
||||
for (int j = 0; j < 4; j++) {
|
||||
id[i * 4 + j] = wr & 0xff;
|
||||
wr >>= 8;
|
||||
}
|
||||
}
|
||||
OCOTP_Deinit(OCOTP);
|
||||
|
||||
return 16;
|
||||
}
|
||||
|
||||
int board_uart_read(uint8_t *buf, int len) {
|
||||
int count = 0;
|
||||
|
||||
while (count < len) {
|
||||
uint8_t const rx_count = LPUART_GetRxFifoCount(UART_PORT);
|
||||
if (!rx_count) {
|
||||
// clear all error flag if any
|
||||
uint32_t status_flags = LPUART_GetStatusFlags(UART_PORT);
|
||||
status_flags &= (kLPUART_RxOverrunFlag | kLPUART_ParityErrorFlag | kLPUART_FramingErrorFlag |
|
||||
kLPUART_NoiseErrorFlag);
|
||||
LPUART_ClearStatusFlags(UART_PORT, status_flags);
|
||||
break;
|
||||
}
|
||||
|
||||
for (int i = 0; i < rx_count; i++) {
|
||||
buf[count] = LPUART_ReadByte(UART_PORT);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
int board_uart_write(void const *buf, int len) {
|
||||
LPUART_WriteBlocking(UART_PORT, (uint8_t const *) buf, len);
|
||||
return len;
|
||||
}
|
||||
|
||||
#if CFG_TUSB_OS == OPT_OS_NONE
|
||||
volatile uint32_t system_ticks = 0;
|
||||
void SysTick_Handler(void) {
|
||||
system_ticks++;
|
||||
}
|
||||
|
||||
uint32_t board_millis(void) {
|
||||
return system_ticks;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef __ICCARM__
|
||||
// Implement _start() since we use linker flag '-nostartfiles'.
|
||||
// Requires defined __STARTUP_CLEAR_BSS,
|
||||
extern int main(void);
|
||||
TU_ATTR_UNUSED void _start(void) {
|
||||
// called by startup code
|
||||
main();
|
||||
while (1) {}
|
||||
}
|
||||
|
||||
#ifdef __clang__
|
||||
void _exit(int __status) {
|
||||
while (1) {}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -108,12 +108,20 @@
|
||||
#define TUP_DCD_ENDPOINT_MAX 16
|
||||
|
||||
#elif TU_CHECK_MCU(OPT_MCU_MIMXRT1XXX)
|
||||
#include "fsl_device_registers.h"
|
||||
|
||||
#define TUP_USBIP_CHIPIDEA_HS
|
||||
#define TUP_USBIP_EHCI
|
||||
|
||||
#define TUP_DCD_ENDPOINT_MAX 8
|
||||
#define TUP_RHPORT_HIGHSPEED 1
|
||||
|
||||
#if __CORTEX_M == 7
|
||||
#define CFG_TUD_MEM_DCACHE_ENABLE_DEFAULT 1
|
||||
#define CFG_TUH_MEM_DCACHE_ENABLE_DEFAULT 1
|
||||
#define CFG_TUSB_MEM_DCACHE_LINE_SIZE 32
|
||||
#endif
|
||||
|
||||
#elif TU_CHECK_MCU(OPT_MCU_KINETIS_KL, OPT_MCU_KINETIS_K32L, OPT_MCU_KINETIS_K)
|
||||
#define TUP_USBIP_CHIPIDEA_FS
|
||||
#define TUP_USBIP_CHIPIDEA_FS_KINETIS
|
||||
|
Loading…
x
Reference in New Issue
Block a user