Skip to content
Open
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
13 changes: 13 additions & 0 deletions bsp/nxp/imx/imxrt/imxrt1180-nxp-evk/cm33/applications/main.c

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个文件不用修改添加用户代码

Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,22 @@
#include <drv_gpio.h>
#include <fsl_rgpio.h>

static rt_err_t _print_device(rt_object_t object, void *data)
{
rt_kprintf(" %s\r\n", object->name);
return RT_EOK;
}

static void print_devices(void)
{
rt_kprintf("device list:\r\n");
rt_object_for_each(RT_Object_Class_Device, _print_device, RT_NULL);
}

int main(void)
{
rt_kprintf("MIMXRT1180_CM33 Hello_World\r\n");
print_devices();

while (1)
{
Expand Down
38 changes: 37 additions & 1 deletion bsp/nxp/imx/imxrt/imxrt1180-nxp-evk/cm33/board/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ config SOC_MIMXRT1189CVM8C_CM33
default y
depends on SOC_MIMXRT1189CVM8C
select ARCH_ARM_CORTEX_M33
select ARCH_ARM_CORTEX_FPU
select ARCH_ARM_CORTEX_FPU
select ARCH_ARM_CORTEX_SECURE

menu "On-chip Peripheral Drivers"
Expand Down Expand Up @@ -128,6 +128,42 @@ menu "On-chip Peripheral Drivers"
default 1
endif

menuconfig BSP_USING_I2C
bool "Enable I2C"
select RT_USING_I2C
default n
if BSP_USING_I2C
config BSP_USING_I2C2
bool "Enable I2C2"
default y

config BSP_USING_I2C3
bool "Enable I2C3"
default n

choice
prompt "Select I2C2 badurate"
default HW_I2C2_BADURATE_100kHZ

config HW_I2C2_BADURATE_100kHZ
bool "Badurate 100kHZ"

config HW_I2C2_BADURATE_400kHZ
bool "Badurate 400kHZ"
endchoice

choice
prompt "Select I2C3 badurate"
default HW_I2C3_BADURATE_100kHZ

config HW_I2C3_BADURATE_100kHZ
bool "Badurate 100kHZ"

config HW_I2C3_BADURATE_400kHZ
bool "Badurate 400kHZ"
endchoice
endif

menuconfig BSP_USING_CAN
bool "Enable CAN"
select RT_USING_CAN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void BOARD_InitPins(void) {
0U); /* Software Input On Field: Input Path is determined by functionality */
IOMUXC_SetPinMux(
IOMUXC_GPIO_AON_09_LPUART1_RX, /* GPIO_AON_09 is configured as LPUART1_RX */
0U); /* Software Input On Field: Input Path is determined by functionality */
1U); /* Software Input On Field: Force input path of pad GPIO_AON_09 */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这边应该不需要修改

IOMUXC_SetPinConfig(
IOMUXC_GPIO_AON_08_LPUART1_TX, /* GPIO_AON_08 PAD functional properties : */
0x02U); /* Slew Rate Field: Fast Slew Rate
Expand All @@ -88,6 +88,25 @@ void BOARD_InitPins(void) {
Pull / Keep Select Field: Pull Disable, Highz
Pull Up / Down Config. Field: Weak pull down
Open Drain Field: Disabled */

IOMUXC_SetPinMux(
IOMUXC_GPIO_AON_16_LPI2C2_SCL, /* GPIO_AON_16 is configured as LPI2C2_SCL */
0U); /* Software Input On Field: Input Path is determined by functionality */
IOMUXC_SetPinMux(
IOMUXC_GPIO_AON_15_LPI2C2_SDA, /* GPIO_AON_15 is configured as LPI2C2_SDA */
0U); /* Software Input On Field: Input Path is determined by functionality */
IOMUXC_SetPinConfig(
IOMUXC_GPIO_AON_16_LPI2C2_SCL, /* GPIO_AON_16 PAD functional properties : */
0x1DU); /* Slew Rate Field: Slow Slew Rate
Pull Enable Field: Pull Enable
Pull Up / Down Config. Field: Weak pull up
Open Drain Field: Enabled */
IOMUXC_SetPinConfig(
IOMUXC_GPIO_AON_15_LPI2C2_SDA, /* GPIO_AON_15 PAD functional properties : */
0x1DU); /* Slew Rate Field: Slow Slew Rate
Pull Enable Field: Pull Enable
Pull Up / Down Config. Field: Weak pull up
Open Drain Field: Enabled */
}

void BOARD_InitLeds(void) {
Expand Down
4 changes: 4 additions & 0 deletions bsp/nxp/imx/imxrt/imxrt1180-nxp-evk/cm33/board/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ if rtconfig.PLATFORM in ['iccarm']:
CPPDEFINES += ['NDEBUG']
# CPPDEFINES += ['FSL_SDK_DRIVER_QUICK_ACCESS_ENABLE=1']

if GetDepend(['BSP_USING_I2C']):
src += ['../packages/nxp-imxrt-sdk-latest/MIMXRT1180/MIMXRT1189/drivers/fsl_lpi2c.c']
CPPPATH += [cwd + '/../packages/nxp-imxrt-sdk-latest/MIMXRT1180/MIMXRT1189/drivers']

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这边麻烦更新package对应的repo:https://github.com/RT-Thread-packages/nxp-imxrt-sdk

group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH, CPPDEFINES=CPPDEFINES)

Return('group')
50 changes: 43 additions & 7 deletions bsp/nxp/imx/imxrt/imxrt1180-nxp-evk/cm7/board/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ config SOC_MIMXRT1189CVM8C_CM7
default y
depends on SOC_MIMXRT1189CVM8C
select ARCH_ARM_CORTEX_M7
select ARCH_ARM_CORTEX_FPU
select ARCH_ARM_CORTEX_FPU

config BSP_USING_LCD_MIPI
bool
default n
Expand Down Expand Up @@ -131,6 +131,42 @@ menu "On-chip Peripheral Drivers"
default 1
endif

menuconfig BSP_USING_I2C
bool "Enable I2C"
select RT_USING_I2C
default n
if BSP_USING_I2C
config BSP_USING_I2C2
bool "Enable I2C2"
default y

config BSP_USING_I2C3
bool "Enable I2C3"
default n

choice
prompt "Select I2C2 badurate"
default HW_I2C2_BADURATE_100kHZ

config HW_I2C2_BADURATE_100kHZ
bool "Badurate 100kHZ"

config HW_I2C2_BADURATE_400kHZ
bool "Badurate 400kHZ"
endchoice

choice
prompt "Select I2C3 badurate"
default HW_I2C3_BADURATE_100kHZ

config HW_I2C3_BADURATE_100kHZ
bool "Badurate 100kHZ"

config HW_I2C3_BADURATE_400kHZ
bool "Badurate 400kHZ"
endchoice
endif

menuconfig BSP_USING_CAN
bool "Enable CAN"
select RT_USING_CAN
Expand Down Expand Up @@ -244,24 +280,24 @@ menu "Onboard Peripheral Drivers"
choice
prompt "Select display panel"
default DISPLAY_USING_RK055AHD091

config DISPLAY_USING_RK055AHD091
bool "RK055AHD091-CTG (RK055HDMIPI4M 720 * 1280)"

config DISPLAY_USING_RK055IQH091
bool "RK055IQH091-CTG (540 * 960)"

config DISPLAY_USING_RK055MHD091
bool "RK055MHD091A0-CTG (RK055HDMIPI4MA0 720 * 1280)"
endchoice

choice
prompt "Select display controller"
default BSP_USING_LCDIFV2

config BSP_USING_ELCDIF
bool "ELCDIF"

config BSP_USING_LCDIFV2
bool "LCDIFV2"
endchoice
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void BOARD_InitPins(void) {
0U); /* Software Input On Field: Input Path is determined by functionality */
IOMUXC_SetPinMux(
IOMUXC_GPIO_AON_09_LPUART1_RX, /* GPIO_AON_09 is configured as LPUART1_RX */
0U); /* Software Input On Field: Input Path is determined by functionality */
1U); /* Software Input On Field: Force input path of pad GPIO_AON_09 */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这边应该也不用改

IOMUXC_SetPinConfig(
IOMUXC_GPIO_AON_08_LPUART1_TX, /* GPIO_AON_08 PAD functional properties : */
0x02U); /* Slew Rate Field: Fast Slew Rate
Expand All @@ -75,6 +75,25 @@ void BOARD_InitPins(void) {
Pull / Keep Select Field: Pull Disable, Highz
Pull Up / Down Config. Field: Weak pull down
Open Drain Field: Disabled */

IOMUXC_SetPinMux(
IOMUXC_GPIO_AON_16_LPI2C2_SCL, /* GPIO_AON_16 is configured as LPI2C2_SCL */
0U); /* Software Input On Field: Input Path is determined by functionality */
IOMUXC_SetPinMux(
IOMUXC_GPIO_AON_15_LPI2C2_SDA, /* GPIO_AON_15 is configured as LPI2C2_SDA */
0U); /* Software Input On Field: Input Path is determined by functionality */
IOMUXC_SetPinConfig(
IOMUXC_GPIO_AON_16_LPI2C2_SCL, /* GPIO_AON_16 PAD functional properties : */
0x1DU); /* Slew Rate Field: Slow Slew Rate
Pull Enable Field: Pull Enable
Pull Up / Down Config. Field: Weak pull up
Open Drain Field: Enabled */
IOMUXC_SetPinConfig(
IOMUXC_GPIO_AON_15_LPI2C2_SDA, /* GPIO_AON_15 PAD functional properties : */
0x1DU); /* Slew Rate Field: Slow Slew Rate
Pull Enable Field: Pull Enable
Pull Up / Down Config. Field: Weak pull up
Open Drain Field: Enabled */
}

/***********************************************************************************************************************
Expand Down
4 changes: 4 additions & 0 deletions bsp/nxp/imx/imxrt/imxrt1180-nxp-evk/cm7/board/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ if rtconfig.PLATFORM in ['armcc', 'armclang']:
if rtconfig.PLATFORM in ['iccarm']:
CPPDEFINES += ['NDEBUG']

if GetDepend(['BSP_USING_I2C']):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这段不应该添加到这里,这部分是软件包去添加的,要添加也要给这提交PR:https://github.com/RT-Thread-packages/nxp-imxrt-sdk/blob/master/MIMXRT1180/SConscript

src += ['../packages/nxp-imxrt-sdk-latest/MIMXRT1180/MIMXRT1189/drivers/fsl_lpi2c.c']
CPPPATH += [cwd + '/../packages/nxp-imxrt-sdk-latest/MIMXRT1180/MIMXRT1189/drivers']

group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH, CPPDEFINES=CPPDEFINES)

Return('group')
43 changes: 32 additions & 11 deletions bsp/nxp/imx/imxrt/libraries/drivers/drv_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ struct imxrt_i2c_bus
volatile rt_uint32_t msg_ptr;
volatile rt_uint32_t dptr;
char *device_name;
#ifdef SOC_IMXRT1170_SERIES
#if defined(SOC_IMXRT1170_SERIES) || defined(SOC_IMXRT1180_SERIES)
clock_root_t clock_root;
#endif
};
Expand Down Expand Up @@ -164,6 +164,9 @@ static rt_err_t imxrt_lpi2c_configure(struct imxrt_i2c_bus *bus, lpi2c_master_co
CLOCK_SetRootClock(bus->clock_root, &rootCfg);
volatile uint32_t freq = CLOCK_GetRootClockFreq(bus->clock_root);
LPI2C_MasterInit(bus->I2C, cfg, freq);
#elif defined(SOC_IMXRT1180_SERIES)
volatile uint32_t freq = CLOCK_GetRootClockFreq(bus->clock_root);
LPI2C_MasterInit(bus->I2C, cfg, freq);
#else
CLOCK_SetMux(kCLOCK_Lpi2cMux, LPI2C_CLOCK_SOURCE_SELECT);
CLOCK_SetDiv(kCLOCK_Lpi2cDiv, LPI2C_CLOCK_SOURCE_DIVIDER);
Expand Down Expand Up @@ -298,16 +301,6 @@ static rt_ssize_t imxrt_i2c_mst_xfer(struct rt_i2c_bus_device *bus,
}
}

if (LPI2C_MasterStart(imxrt_i2c->I2C, imxrt_i2c->msg[i].addr, kLPI2C_Read) != kStatus_Success)
{
i = 0;
break;
}

while (LPI2C_MasterGetStatusFlags(imxrt_i2c->I2C) & kLPI2C_MasterNackDetectFlag)
{
}

if (LPI2C_MasterReceive(imxrt_i2c->I2C, imxrt_i2c->msg[i].buf, imxrt_i2c->msg[i].len) != kStatus_Success)
{
i = 0;
Expand Down Expand Up @@ -391,6 +384,11 @@ int rt_hw_i2c_init(void)
#elif defined(HW_I2C1_BADURATE_100kHZ)
masterConfig.baudRate_Hz = 100000U;
#endif /*HW_I2C1_BADURATE_400kHZ*/
#if defined(SOC_IMXRT1170_SERIES)
lpi2c1.clock_root = kCLOCK_Root_Lpi2c1;
#elif defined(SOC_IMXRT1180_SERIES)
lpi2c1.clock_root = kCLOCK_Root_Lpi2c0102;
#endif
imxrt_lpi2c_configure(&lpi2c1, &masterConfig);
rt_i2c_bus_device_register(&lpi2c1.parent, lpi2c1.device_name);
#endif /* BSP_USING_I2C1 */
Expand All @@ -402,6 +400,11 @@ int rt_hw_i2c_init(void)
#elif defined(HW_I2C2_BADURATE_100kHZ)
masterConfig.baudRate_Hz = 100000U;
#endif /* HW_I2C2_BADURATE_400kHZ */
#if defined(SOC_IMXRT1170_SERIES)
lpi2c2.clock_root = kCLOCK_Root_Lpi2c2;
#elif defined(SOC_IMXRT1180_SERIES)
lpi2c2.clock_root = kCLOCK_Root_Lpi2c0102;
#endif
imxrt_lpi2c_configure(&lpi2c2, &masterConfig);
rt_i2c_bus_device_register(&lpi2c2.parent, lpi2c2.device_name);
#endif /* BSP_USING_I2C2 */
Expand All @@ -415,6 +418,11 @@ int rt_hw_i2c_init(void)
#elif defined(HW_I2C3_BADURATE_100kHZ)
masterConfig.baudRate_Hz = 100000U;
#endif /* HW_I2C3_BADURATE_400kHZ */
#if defined(SOC_IMXRT1170_SERIES)
lpi2c3.clock_root = kCLOCK_Root_Lpi2c3;
#elif defined(SOC_IMXRT1180_SERIES)
lpi2c3.clock_root = kCLOCK_Root_Lpi2c0304;
#endif
imxrt_lpi2c_configure(&lpi2c3, &masterConfig);
rt_i2c_bus_device_register(&lpi2c3.parent, lpi2c3.device_name);
#endif /* BSP_USING_I2C3 */
Expand All @@ -426,6 +434,11 @@ int rt_hw_i2c_init(void)
#elif defined(HW_I2C4_BADURATE_100kHZ)
masterConfig.baudRate_Hz = 100000U;
#endif /* HW_I2C4_BADURATE_400kHZ */
#if defined(SOC_IMXRT1170_SERIES)
lpi2c4.clock_root = kCLOCK_Root_Lpi2c4;
#elif defined(SOC_IMXRT1180_SERIES)
lpi2c4.clock_root = kCLOCK_Root_Lpi2c0304;
#endif
imxrt_lpi2c_configure(&lpi2c4, &masterConfig);
rt_i2c_bus_device_register(&lpi2c4.parent, lpi2c4.device_name);
#endif /* BSP_USING_I2C4 */
Expand All @@ -437,7 +450,11 @@ int rt_hw_i2c_init(void)
#elif defined(HW_I2C5_BADURATE_100kHZ)
masterConfig.baudRate_Hz = 100000U;
#endif /* HW_I2C5_BADURATE_400kHZ */
#if defined(SOC_IMXRT1170_SERIES)
lpi2c5.clock_root = kCLOCK_Root_Lpi2c5;
#elif defined(SOC_IMXRT1180_SERIES)
lpi2c5.clock_root = kCLOCK_Root_Lpi2c0506;
#endif
imxrt_lpi2c_configure(&lpi2c5, &masterConfig);
rt_i2c_bus_device_register(&lpi2c5.parent, lpi2c5.device_name);
#endif /* BSP_USING_I2C5 */
Expand All @@ -449,7 +466,11 @@ int rt_hw_i2c_init(void)
#elif defined(HW_I2C6_BADURATE_100kHZ)
masterConfig.baudRate_Hz = 100000U;
#endif /* HW_I2C6_BADURATE_400kHZ */
#if defined(SOC_IMXRT1170_SERIES)
lpi2c6.clock_root = kCLOCK_Root_Lpi2c6;
#elif defined(SOC_IMXRT1180_SERIES)
lpi2c6.clock_root = kCLOCK_Root_Lpi2c0506;
#endif
imxrt_lpi2c_configure(&lpi2c6, &masterConfig);
rt_i2c_bus_device_register(&lpi2c6.parent, lpi2c6.device_name);
#endif /* BSP_USING_I2C6 */
Expand Down
Loading