Skip to content

Commit e665bac

Browse files
authored
Merge pull request #5567 from mysterywolf/nxp
#5564 format codes
2 parents 3000140 + 77b8db8 commit e665bac

File tree

17 files changed

+234
-125
lines changed

17 files changed

+234
-125
lines changed

bsp/imxrt/libraries/drivers/drv_can.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2006-2018, RT-Thread Development Team
2+
* Copyright (c) 2006-2021, RT-Thread Development Team
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*
@@ -375,7 +375,7 @@ static int can_send(struct rt_can_device *can_dev, const void *buf, rt_uint32_t
375375
ret = RT_EBUSY;
376376
break;
377377
}
378-
378+
379379
return ret;
380380
}
381381

bsp/imxrt/libraries/drivers/drv_can.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
/*
2-
* Copyright (c) 2006-2018, RT-Thread Development Team
2+
* Copyright (c) 2006-2021, RT-Thread Development Team
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*
66
* Change Logs:
77
* Date Author Notes
88
* 2019-06-28 misonyo the first version.
99
*/
10-
10+
1111
#ifndef DRV_CAN_H__
1212
#define DRV_CAN_H__
1313

bsp/imxrt/libraries/drivers/drv_eth.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2006-2019, RT-Thread Development Team
2+
* Copyright (c) 2006-2021, RT-Thread Development Team
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*
@@ -329,7 +329,7 @@ static status_t _ENET_SendFrame(ENET_Type *base, enet_handle_t *handle, const ui
329329
#endif /* FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET */
330330

331331
pbuf_copy_partial((const struct pbuf *)data, (void *)address, length, 0);
332-
332+
333333
/* Set data length. */
334334
curBuffDescrip->length = length;
335335
#ifdef ENET_ENHANCEDBUFFERDESCRIPTOR_MODE
@@ -434,7 +434,7 @@ static status_t _ENET_SendFrame(ENET_Type *base, enet_handle_t *handle, const ui
434434
address = (uint32_t)curBuffDescrip->buffer;
435435
#endif /* FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET */
436436
DCACHE_CleanByRange(address, handle->txBuffSizeAlign[0]);
437-
#endif /* FSL_SDK_ENABLE_DRIVER_CACHE_CONTROL */
437+
#endif /* FSL_SDK_ENABLE_DRIVER_CACHE_CONTROL */
438438
/* Active the transmit buffer descriptor. */
439439
_ENET_ActiveSend(base, 0);
440440

@@ -454,8 +454,8 @@ static status_t _ENET_SendFrame(ENET_Type *base, enet_handle_t *handle, const ui
454454
/* transmit packet. */
455455
rt_err_t rt_imxrt_eth_tx(rt_device_t dev, struct pbuf *p)
456456
{
457-
rt_err_t result = RT_EOK;
458-
enet_handle_t * enet_handle = &imxrt_eth_device.enet_handle;
457+
rt_err_t result = RT_EOK;
458+
enet_handle_t * enet_handle = &imxrt_eth_device.enet_handle;
459459

460460
RT_ASSERT(p != NULL);
461461
RT_ASSERT(enet_handle != RT_NULL);

bsp/imxrt/libraries/drivers/drv_gpio.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2006-2018, RT-Thread Development Team
2+
* Copyright (c) 2006-2021, RT-Thread Development Team
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*
@@ -70,7 +70,7 @@ const struct pin_mask mask_tab[5] =
7070
#endif
7171
};
7272

73-
const rt_int8_t reg_offset[] =
73+
const rt_int8_t reg_offset[] =
7474
{
7575
#if defined(SOC_IMXRT1015_SERIES)
7676
38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 64, 65, 66, 67, 68, 69,

bsp/imxrt/libraries/drivers/drv_gpio.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
/*
2-
* Copyright (c) 2006-2018, RT-Thread Development Team
2+
* Copyright (c) 2006-2021, RT-Thread Development Team
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*
66
* Change Logs:
77
* Date Author Notes
88
* 2018-4-30 misonyo the first version.
99
*/
10-
10+
1111
#ifndef DRV_GPIO_H__
1212
#define DRV_GPIO_H__
1313

14-
#include <rtthread.h>
15-
#include <rtdevice.h>
14+
#include <rtthread.h>
15+
#include <rtdevice.h>
1616

1717
#define GET_PIN(PORTx, PIN) (32 * (PORTx - 1) + (PIN & 31)) /* PORTx:1,2,3,4,5 */
1818

bsp/imxrt/libraries/drivers/drv_i2c.c

Lines changed: 121 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2006-2018, RT-Thread Development Team
2+
* Copyright (c) 2006-2021, RT-Thread Development Team
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*
@@ -18,7 +18,7 @@
1818
#define LOG_TAG "drv.i2c"
1919
#include <drv_log.h>
2020

21-
#if !defined(BSP_USING_I2C1) && !defined(BSP_USING_I2C2) && !defined(BSP_USING_I2C3) && !defined(BSP_USING_I2C4)
21+
#if !defined(BSP_USING_I2C1) && !defined(BSP_USING_I2C2) && !defined(BSP_USING_I2C3) && !defined(BSP_USING_I2C4) && !defined(BSP_USING_I2C5)&& !defined(BSP_USING_I2C6)
2222
#error "Please define at least one BSP_USING_I2Cx"
2323
#endif
2424

@@ -35,6 +35,9 @@ struct imxrt_i2c_bus
3535
volatile rt_uint32_t msg_ptr;
3636
volatile rt_uint32_t dptr;
3737
char *device_name;
38+
#ifdef SOC_IMXRT1170_SERIES
39+
clock_root_t clock_root;
40+
#endif
3841
};
3942

4043
#if defined (BSP_USING_I2C1)
@@ -55,13 +58,28 @@ struct imxrt_i2c_bus
5558
#define I2C4BUS_NAME "i2c4"
5659
#endif /*BSP_USING_I2C4*/
5760

61+
#if defined (BSP_USING_I2C5)
62+
#define I2C5BUS_NAME "i2c5"
63+
#endif /*BSP_USING_I2C5*/
64+
65+
#if defined (BSP_USING_I2C6)
66+
#define I2C6BUS_NAME "i2c6"
67+
#endif /*BSP_USING_I2C6*/
68+
5869
#endif /* MIMXRT1015_SERIES */
5970

60-
#define LPI2C_CLOCK_SOURCE_DIVIDER 4
71+
/* Select USB1 PLL (360 MHz) as master lpi2c clock source */
72+
#define LPI2C_CLOCK_SOURCE_SELECT (1U)
73+
#ifdef SOC_IMXRT1170_SERIES
74+
/* Clock divider for master lpi2c clock source */
75+
#define LPI2C_CLOCK_SOURCE_DIVIDER (12U)
76+
#else
77+
#define LPI2C_CLOCK_SOURCE_DIVIDER (0U)
6178

6279
/* Get frequency of lpi2c clock */
63-
#define LPI2C_CLOCK_FREQUENCY ((CLOCK_GetFreq(kCLOCK_Usb1PllClk) / 8) / (LPI2C_CLOCK_SOURCE_DIVIDER))
80+
#define LPI2C_CLOCK_FREQUENCY ((CLOCK_GetFreq(kCLOCK_Usb1PllClk) / 8) / (LPI2C_CLOCK_SOURCE_DIVIDER + 1U))
6481

82+
#endif
6583
#ifdef BSP_USING_I2C1
6684
static struct imxrt_i2c_bus lpi2c1 =
6785
{
@@ -96,9 +114,25 @@ static struct imxrt_i2c_bus lpi2c4 =
96114
};
97115
#endif /* RT_USING_HW_I2C4 */
98116

117+
#ifdef BSP_USING_I2C5
118+
static struct imxrt_i2c_bus lpi2c5 =
119+
{
120+
.I2C = LPI2C5,
121+
.device_name = I2C5BUS_NAME,
122+
};
123+
#endif /* RT_USING_HW_I2C5 */
124+
125+
#ifdef BSP_USING_I2C6
126+
static struct imxrt_i2c_bus lpi2c6 =
127+
{
128+
.I2C = LPI2C6,
129+
.device_name = I2C6BUS_NAME,
130+
};
131+
#endif /* RT_USING_HW_I2C6 */
132+
99133
#endif /* MIMXRT1015_SERIES */
100134

101-
#if (defined(BSP_USING_I2C1) || defined(BSP_USING_I2C2) || defined(BSP_USING_I2C3) || defined(BSP_USING_I2C4))
135+
#if (defined(BSP_USING_I2C1) || defined(BSP_USING_I2C2) || defined(BSP_USING_I2C3) || defined(BSP_USING_I2C4) ||defined(BSP_USING_I2C5) || defined(BSP_USING_I2C6))
102136

103137
static rt_size_t imxrt_i2c_mst_xfer(struct rt_i2c_bus_device *bus,
104138
struct rt_i2c_msg msgs[],
@@ -123,7 +157,19 @@ static rt_err_t imxrt_lpi2c_configure(struct imxrt_i2c_bus *bus, lpi2c_master_co
123157
RT_ASSERT(cfg != RT_NULL);
124158

125159
bus->parent.ops = &imxrt_i2c_ops;
160+
#ifdef SOC_IMXRT1170_SERIES
161+
clock_root_config_t rootCfg = {0};
162+
rootCfg.mux = LPI2C_CLOCK_SOURCE_SELECT;
163+
rootCfg.div = LPI2C_CLOCK_SOURCE_DIVIDER + 1;
164+
CLOCK_SetRootClock(bus->clock_root, &rootCfg);
165+
volatile uint32_t freq = CLOCK_GetRootClockFreq(bus->clock_root);
166+
LPI2C_MasterInit(bus->I2C, cfg, freq);
167+
#else
168+
CLOCK_SetMux(kCLOCK_Lpi2cMux, LPI2C_CLOCK_SOURCE_SELECT);
169+
CLOCK_SetDiv(kCLOCK_Lpi2cDiv, LPI2C_CLOCK_SOURCE_DIVIDER);
126170
LPI2C_MasterInit(bus->I2C, cfg, LPI2C_CLOCK_FREQUENCY);
171+
#endif
172+
127173
return RT_EOK;
128174
}
129175

@@ -221,6 +267,37 @@ static rt_size_t imxrt_i2c_mst_xfer(struct rt_i2c_bus_device *bus,
221267
{
222268
if (imxrt_i2c->msg[i].flags & RT_I2C_RD)
223269
{
270+
if ((imxrt_i2c->msg[i].flags & RT_I2C_NO_START) != RT_I2C_NO_START)
271+
{
272+
if (LPI2C_MasterStart(imxrt_i2c->I2C, imxrt_i2c->msg[i].addr, kLPI2C_Write) != kStatus_Success)
273+
{
274+
i = 0;
275+
break;
276+
}
277+
278+
while (LPI2C_MasterGetStatusFlags(imxrt_i2c->I2C) & kLPI2C_MasterNackDetectFlag)
279+
{
280+
}
281+
282+
if (LPI2C_MasterRepeatedStart(imxrt_i2c->I2C, imxrt_i2c->msg[i].addr, kLPI2C_Read) != kStatus_Success)
283+
{
284+
i = 0;
285+
break;
286+
}
287+
}
288+
else
289+
{
290+
if (LPI2C_MasterStart(imxrt_i2c->I2C, imxrt_i2c->msg[i].addr, kLPI2C_Read) != kStatus_Success)
291+
{
292+
i = 0;
293+
break;
294+
}
295+
296+
while (LPI2C_MasterGetStatusFlags(imxrt_i2c->I2C) & kLPI2C_MasterNackDetectFlag)
297+
{
298+
}
299+
}
300+
224301
if (LPI2C_MasterStart(imxrt_i2c->I2C, imxrt_i2c->msg[i].addr, kLPI2C_Read) != kStatus_Success)
225302
{
226303
i = 0;
@@ -245,8 +322,16 @@ static rt_size_t imxrt_i2c_mst_xfer(struct rt_i2c_bus_device *bus,
245322
break;
246323
}
247324

248-
while (LPI2C_MasterGetStatusFlags(imxrt_i2c->I2C) & kLPI2C_MasterNackDetectFlag)
325+
if(LPI2C_MasterWaitForTxFifoAllEmpty(imxrt_i2c->I2C) != kStatus_Success)
249326
{
327+
i = 0;
328+
break;
329+
}
330+
331+
if (LPI2C_MasterGetStatusFlags(imxrt_i2c->I2C) & kLPI2C_MasterNackDetectFlag)
332+
{
333+
i = 0;
334+
break;
250335
}
251336

252337
if (LPI2C_MasterSend(imxrt_i2c->I2C, imxrt_i2c->msg[i].buf, imxrt_i2c->msg[i].len) != kStatus_Success)
@@ -261,11 +346,12 @@ static rt_size_t imxrt_i2c_mst_xfer(struct rt_i2c_bus_device *bus,
261346
break;
262347
}
263348
}
264-
}
265349

266-
if (LPI2C_MasterStop(imxrt_i2c->I2C) != kStatus_Success)
267-
{
268-
i = 0;
350+
if (LPI2C_MasterStop(imxrt_i2c->I2C) != kStatus_Success)
351+
{
352+
i = 0;
353+
}
354+
269355
}
270356

271357
imxrt_i2c->msg = RT_NULL;
@@ -341,6 +427,31 @@ int rt_hw_i2c_init(void)
341427
rt_i2c_bus_device_register(&lpi2c4.parent, lpi2c4.device_name);
342428
#endif /* BSP_USING_I2C4 */
343429

430+
#if defined(BSP_USING_I2C5)
431+
LPI2C_MasterGetDefaultConfig(&masterConfig);
432+
#if defined(HW_I2C5_BADURATE_400kHZ)
433+
masterConfig.baudRate_Hz = 400000U;
434+
#elif defined(HW_I2C5_BADURATE_100kHZ)
435+
masterConfig.baudRate_Hz = 100000U;
436+
#endif /* HW_I2C5_BADURATE_400kHZ */
437+
lpi2c5.clock_root = kCLOCK_Root_Lpi2c5;
438+
imxrt_lpi2c_configure(&lpi2c5, &masterConfig);
439+
rt_i2c_bus_device_register(&lpi2c5.parent, lpi2c5.device_name);
440+
#endif /* BSP_USING_I2C5 */
441+
442+
#if defined(BSP_USING_I2C6)
443+
LPI2C_MasterGetDefaultConfig(&masterConfig);
444+
#if defined(HW_I2C6_BADURATE_400kHZ)
445+
masterConfig.baudRate_Hz = 400000U;
446+
#elif defined(HW_I2C6_BADURATE_100kHZ)
447+
masterConfig.baudRate_Hz = 100000U;
448+
#endif /* HW_I2C6_BADURATE_400kHZ */
449+
lpi2c6.clock_root = kCLOCK_Root_Lpi2c6;
450+
imxrt_lpi2c_configure(&lpi2c6, &masterConfig);
451+
rt_i2c_bus_device_register(&lpi2c6.parent, lpi2c6.device_name);
452+
#endif /* BSP_USING_I2C6 */
453+
454+
344455
#endif /* MIMXRT1015_SERIES */
345456

346457
return 0;

bsp/imxrt/libraries/drivers/drv_mdio.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
21
/*
3-
* Copyright (c) 2006-2020, RT-Thread Development Team
2+
* Copyright (c) 2006-2021, RT-Thread Development Team
43
*
54
* SPDX-License-Identifier: Apache-2.0
65
*

bsp/imxrt/libraries/drivers/drv_mdio.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
21
/*
3-
* Copyright (c) 2006-2020, RT-Thread Development Team
2+
* Copyright (c) 2006-2021, RT-Thread Development Team
43
*
54
* SPDX-License-Identifier: Apache-2.0
65
*

bsp/imxrt/libraries/drivers/drv_pulse_encoder.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2006-2018, RT-Thread Development Team
2+
* Copyright (c) 2006-2021, RT-Thread Development Team
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*
@@ -22,7 +22,7 @@
2222
#if !defined(BSP_USING_PULSE_ENCODER1) && !defined(BSP_USING_PULSE_ENCODER2) && !defined(BSP_USING_PULSE_ENCODER3) \
2323
&& !defined(BSP_USING_PULSE_ENCODER4)
2424
#error "Please define at least one BSP_USING_PULSE_ENCODERx"
25-
/* this driver can be disabled at menuconfig RT-Thread Components Device Drivers */
25+
/* this driver can be disabled at menuconfig -> RT-Thread Components -> Device Drivers */
2626
#elif (defined(BSP_USING_PULSE_ENCODER2) || defined(BSP_USING_PULSE_ENCODER3) || defined(BSP_USING_PULSE_ENCODER4)) || defined(SOC_IMXRT1015_SERIES)
2727
#error "IMXRT1015 had only one quadrature decoder module"
2828
#elif (defined(BSP_USING_PULSE_ENCODER3) || defined(BSP_USING_PULSE_ENCODER4)) || defined(SOC_IMXRT1020_SERIES)
@@ -157,4 +157,4 @@ int rt_hw_pulse_encoder_init(void)
157157
}
158158
INIT_BOARD_EXPORT(rt_hw_pulse_encoder_init);
159159

160-
#endif
160+
#endif

bsp/imxrt/libraries/drivers/drv_sai.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
/*
2-
* Copyright (c) 2006-2018, RT-Thread Development Team
2+
* Copyright (c) 2006-2021, RT-Thread Development Team
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*
66
* Change Logs:
77
* Date Author Notes
88
* 2018-4-30 misonyo the first version.
99
*/
10-
10+
1111
#include <rtthread.h>
1212
#include <rthw.h>
1313
#include <rtdef.h>

0 commit comments

Comments
 (0)