summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhathach <[email protected]>2021-04-28 19:30:23 +0700
committerhathach <[email protected]>2021-04-28 19:30:23 +0700
commit810057bdb2b0b2d62a7f4ae9f394f46f58862be2 (patch)
tree29acb7cf60d5fba3aad83fc98184acbd29ca50dc
parentaf0db342df37932511521a1a4b45c7bc31de03f2 (diff)
fix build with imxrt
-rw-r--r--hw/bsp/imxrt/family.c13
-rw-r--r--hw/bsp/imxrt/family.mk16
2 files changed, 22 insertions, 7 deletions
diff --git a/hw/bsp/imxrt/family.c b/hw/bsp/imxrt/family.c
index c6b1a3159..77a224a5e 100644
--- a/hw/bsp/imxrt/family.c
+++ b/hw/bsp/imxrt/family.c
@@ -79,7 +79,18 @@ void board_init(void)
uart_config.baudRate_Bps = CFG_BOARD_UART_BAUDRATE;
uart_config.enableTx = true;
uart_config.enableRx = true;
- LPUART_Init(UART_PORT, &uart_config, (CLOCK_GetPllFreq(kCLOCK_PllUsb1) / 6U) / (CLOCK_GetDiv(kCLOCK_UartDiv) + 1U));
+
+ uint32_t freq;
+ if (CLOCK_GetMux(kCLOCK_UartMux) == 0) /* PLL3 div6 80M */
+ {
+ freq = (CLOCK_GetPllFreq(kCLOCK_PllUsb1) / 6U) / (CLOCK_GetDiv(kCLOCK_UartDiv) + 1U);
+ }
+ else
+ {
+ freq = CLOCK_GetOscFreq() / (CLOCK_GetDiv(kCLOCK_UartDiv) + 1U);
+ }
+
+ LPUART_Init(UART_PORT, &uart_config, freq);
//------------- USB0 -------------//
diff --git a/hw/bsp/imxrt/family.mk b/hw/bsp/imxrt/family.mk
index 6ebc0e260..a919d3698 100644
--- a/hw/bsp/imxrt/family.mk
+++ b/hw/bsp/imxrt/family.mk
@@ -1,5 +1,6 @@
UF2_FAMILY_ID = 0x4fb2d5bd
-DEPS_SUBMODULES += hw/mcu/nxp/mcux-sdk
+SDK_DIR = hw/mcu/nxp/mcux-sdk
+DEPS_SUBMODULES += $(SDK_DIR)
include $(TOP)/$(BOARD_PATH)/board.mk
@@ -17,7 +18,7 @@ CFLAGS += \
# mcu driver cause following warnings
CFLAGS += -Wno-error=unused-parameter -Wno-error=implicit-fallthrough=
-MCU_DIR = hw/mcu/nxp/mcux-sdk/devices/$(MCU_VARIANT)
+MCU_DIR = $(SDK_DIR)/devices/$(MCU_VARIANT)
# All source paths should be relative to the top level.
LD_FILE = $(MCU_DIR)/gcc/$(MCU_VARIANT)xxxxx_flexspi_nor.ld
@@ -32,16 +33,19 @@ SRC_C += \
$(MCU_DIR)/xip/fsl_flexspi_nor_boot.c \
$(MCU_DIR)/project_template/clock_config.c \
$(MCU_DIR)/drivers/fsl_clock.c \
- $(MCU_DIR)/drivers/fsl_gpio.c \
- $(MCU_DIR)/drivers/fsl_common.c \
- $(MCU_DIR)/drivers/fsl_lpuart.c
+ $(SDK_DIR)/drivers/common/fsl_common.c \
+ $(SDK_DIR)/drivers/igpio/fsl_gpio.c \
+ $(SDK_DIR)/drivers/lpuart/fsl_lpuart.c
INC += \
$(TOP)/$(BOARD_PATH) \
$(TOP)/$(MCU_DIR)/../../CMSIS/Include \
$(TOP)/$(MCU_DIR) \
- $(TOP)/$(MCU_DIR)/drivers \
$(TOP)/$(MCU_DIR)/project_template \
+ $(TOP)/$(MCU_DIR)/drivers \
+ $(TOP)/$(SDK_DIR)/drivers/common \
+ $(TOP)/$(SDK_DIR)/drivers/igpio \
+ $(TOP)/$(SDK_DIR)/drivers/lpuart
SRC_S += $(MCU_DIR)/gcc/startup_$(MCU_VARIANT).S