Skip to content

Commit 3d949d0

Browse files
committed
Merge branch 'master' of https://github.com/RT-Thread/rt-thread
2 parents 9c3b874 + 66dd03f commit 3d949d0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+8428
-416
lines changed

.github/workflows/manual_dist.yml

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# Change Logs:
77
# Date Author Notes
88
# 2023-07-01 Supperthomas the first version
9+
# 2024-09-06 Supperthomas add debug for action and add cppcheck for project
910
#
1011
name: manual_scons_dist_trigger_only_one
1112

@@ -43,6 +44,11 @@ on:
4344
required: true
4445
type: boolean
4546
default: false
47+
debug_flag:
48+
description: 'True to debug action, False not debug'
49+
required: true
50+
type: boolean
51+
default: false
4652

4753
permissions:
4854
contents: read # to fetch code (actions/checkout)
@@ -68,6 +74,7 @@ jobs:
6874
git config --global http.postBuffer 524288000
6975
echo "RTT_ROOT=${{ github.workspace }}" >> $GITHUB_ENV
7076
echo "RTT_CC=gcc" >> $GITHUB_ENV
77+
sudo apt-get -qq install cppcheck
7178
7279
- name: Install Arm ToolChains
7380
if: ${{ github.event.inputs.bsp_tool_chain == 'sourcery-arm' && success() }}
@@ -144,22 +151,28 @@ jobs:
144151
RTT_BSP: ${{ github.event.inputs.bsp_options }}
145152
RTT_TOOL_CHAIN: ${{ github.event.inputs.bsp_tool_chain}}
146153
run: |
147-
# source ~/.env/env.sh
154+
source ~/.env/env.sh
148155
echo $RTT_BSP
149156
ls bsp/$RTT_BSP/Kconfig && scons -C bsp/$RTT_BSP --pyconfig-silent
150157
config=${{ github.event.inputs.bsp_config}}
151158
echo "$config"
152159
echo "$config" >> bsp/$RTT_BSP/.config
160+
insert_code="env.Tool('compilation_db')\nenv.CompilationDatabase()\n"
161+
sed -i "/DoBuilding(TARGET, objs)/i $insert_code" bsp/$RTT_BSP/SConstruct
153162
scons -C bsp/$RTT_BSP --pyconfig-silent
154163
pushd bsp/$RTT_BSP && pkgs --update && popd
155164
cat bsp/$RTT_BSP/.config
156165
scons -C bsp/$RTT_BSP -j$(nproc)
157-
mkdir -p ${{ github.workspace }}/$RTT_BSP
158-
cp -r bsp/$RTT_BSP ${{ github.workspace }}/$RTT_BSP/
159-
scons --dist -C bsp/$RTT_BSP
160-
cp bsp/$RTT_BSP/dist/project.zip ${{ github.workspace }}/$RTT_BSP/
161-
ls bsp/$RTT_BSP/dist
166+
ls bsp/$RTT_BSP
167+
cppcheck --project=bsp/$RTT_BSP/compile_commands.json
162168
pwd
169+
170+
171+
172+
- name: Setup Debug Session
173+
if: ${{ github.event.inputs.debug_flag }}
174+
uses: csexton/debugger-action@master
175+
163176
- uses: actions/upload-artifact@v3
164177
if: ${{ github.event.inputs.dist_flag }}
165178
with:

.github/workflows/static_code_analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
cd build
4747
cmake ..
4848
make
49-
sudo make install
49+
sudo make install FILESDIR=/usr/local/share/Cppcheck CFGDIR=/usr/share/Cppcheck/cfg
5050
cppcheck --version
5151
cd ../../
5252
git remote -v

bsp/cvitek/cv18xx_risc-v/SConstruct

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ env['ASCOM'] = env['ASPPCOM']
2121

2222
Export('RTT_ROOT')
2323
Export('rtconfig')
24-
rtconfig.CPU='virt64'
25-
rtconfig.ARCH='risc-v'
2624

2725
SDK_ROOT = os.path.abspath('./')
2826

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
/*
2+
* Copyright (c) 2006-2024 RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Change Logs:
7+
* Date Author Notes
8+
* 2024-09-03 Yilin Sun Initial version
9+
*/
10+
11+
#include <rtdevice.h>
12+
13+
#include "fsl_i2c.h"
14+
15+
#ifdef RT_USING_I2C
16+
17+
#define BSP_DEFAULT_I2C_FREQ (100000)
18+
19+
typedef struct
20+
{
21+
struct rt_i2c_bus_device parent;
22+
I2C_Type *instance;
23+
uint32_t input_frequency;
24+
} mcx_i2c_obj_t;
25+
26+
typedef struct
27+
{
28+
I2C_Type *instance;
29+
uint8_t id;
30+
} mcx_i2c_instance_t;
31+
32+
static const mcx_i2c_instance_t mcx_i2c_instances[] =
33+
{
34+
#ifdef BSP_USING_I2C0
35+
{I2C0, 0},
36+
#endif
37+
38+
#ifdef BSP_USING_I2C1
39+
{I2C1, 1},
40+
#endif
41+
};
42+
43+
static mcx_i2c_obj_t mcx_i2c_list[ARRAY_SIZE(mcx_i2c_instances)];
44+
45+
static int mcx_i2c_master_xfer(struct rt_i2c_bus_device *bus, struct rt_i2c_msg msgs[], rt_uint32_t num)
46+
{
47+
struct rt_i2c_msg *msg;
48+
i2c_master_transfer_t xfer = {0};
49+
rt_uint32_t i;
50+
rt_ssize_t ret = 0;
51+
52+
mcx_i2c_obj_t *i2c = (mcx_i2c_obj_t *)bus;
53+
54+
for (i = 0; i < num; i++)
55+
{
56+
msg = &msgs[i];
57+
58+
if (msg->flags & RT_I2C_RD)
59+
{
60+
xfer.slaveAddress = msg->addr;
61+
xfer.direction = kI2C_Read;
62+
xfer.subaddress = 0;
63+
xfer.subaddressSize = 0;
64+
xfer.data = msg->buf;
65+
xfer.dataSize = msg->len;
66+
67+
xfer.flags = kI2C_TransferDefaultFlag;
68+
69+
if (i != 0)
70+
{
71+
xfer.flags |= kI2C_TransferRepeatedStartFlag;
72+
}
73+
74+
if (i != num - 1)
75+
{
76+
xfer.flags |= kI2C_TransferNoStopFlag;
77+
}
78+
79+
80+
if (I2C_MasterTransferBlocking(i2c->instance, &xfer) != kStatus_Success)
81+
{
82+
return i;
83+
}
84+
}
85+
else
86+
{
87+
xfer.slaveAddress = msg->addr;
88+
xfer.direction = kI2C_Write;
89+
xfer.subaddress = 0;
90+
xfer.subaddressSize = 0;
91+
xfer.data = msg->buf;
92+
xfer.dataSize = msg->len;
93+
94+
xfer.flags = kI2C_TransferDefaultFlag;
95+
96+
if (i != 0)
97+
{
98+
xfer.flags |= kI2C_TransferRepeatedStartFlag;
99+
}
100+
101+
if (i != num - 1)
102+
{
103+
xfer.flags |= kI2C_TransferNoStopFlag;
104+
}
105+
106+
if (I2C_MasterTransferBlocking(i2c->instance, &xfer) != kStatus_Success)
107+
{
108+
return i;
109+
}
110+
}
111+
}
112+
113+
ret = num;
114+
115+
return ret;
116+
}
117+
118+
static const struct rt_i2c_bus_device_ops mcx_i2c_ops =
119+
{
120+
mcx_i2c_master_xfer,
121+
RT_NULL,
122+
RT_NULL,
123+
};
124+
125+
static int rt_hw_i2c_init(void)
126+
{
127+
i2c_master_config_t master_cfg;
128+
char name_buf[16];
129+
130+
for (size_t i = 0; i < ARRAY_SIZE(mcx_i2c_instances); i++)
131+
{
132+
mcx_i2c_list[i].input_frequency = CLOCK_GetCoreSysClkFreq();
133+
mcx_i2c_list[i].instance = mcx_i2c_instances[i].instance;
134+
mcx_i2c_list[i].parent.ops = &mcx_i2c_ops;
135+
136+
I2C_MasterGetDefaultConfig(&master_cfg);
137+
138+
master_cfg.baudRate_Bps = BSP_DEFAULT_I2C_FREQ;
139+
140+
I2C_MasterInit(mcx_i2c_list[i].instance, &master_cfg, mcx_i2c_list[i].input_frequency);
141+
142+
rt_snprintf(name_buf, 16, "i2c%d", mcx_i2c_instances[i].id);
143+
144+
rt_i2c_bus_device_register(&mcx_i2c_list[i].parent, name_buf);
145+
}
146+
147+
return RT_EOK;
148+
}
149+
150+
INIT_DEVICE_EXPORT(rt_hw_i2c_init);
151+
152+
#endif
Lines changed: 93 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,93 @@
1-
FRDM-MCXC444 support
1+
# NXP FRDM-MCXC444 Introduction
2+
3+
## Overview
4+
The FRDM-MCXC444 is NXP's official low-cost evaluation board based on the MCX C444 MCU. It is designed for rapid prototyping and features a compact and scalable form factor. The board provides industry-standard headers for easy access to the MCU's I/O pins and supports the MCUXpresso development environment.
5+
6+
Key features of the FRDM-MCXC444 include:
7+
8+
- SLCD functionality
9+
- Arduino-compatible expansion headers
10+
- MCUXpresso IDE support
11+
12+
The appearance of the board is shown in the figure below:
13+
14+
![img](figures/board.png)
15+
16+
The common on-board resources for this board are listed below:
17+
18+
![board_block_diagram](figures/board_block_diagram.png)
19+
20+
For more details on the development board, please refer to [NXP official website](https://www.nxp.com/products/processors-and-microcontrollers/arm-microcontrollers/general-purpose-mcus/mcx-arm-cortex-m/mcx-c-series-microcontrollers:MCX-C-SERIES)
21+
22+
## Preparation
23+
24+
To run sample programs on the FRDM-MCXC444 board, you need to make the following preparations:
25+
26+
1. Development Environment
27+
28+
Keil V5 with MCXC444 package installed.
29+
30+
2. Source Code Acquisition
31+
32+
Visit https://github.com/RT-Thread/rt-thread and download the latest stable release zip package from the Assets section.
33+
34+
3. Hardware Connection
35+
36+
Use a USB cable to connect the USB port of the development board to your PC.
37+
38+
> NXP's official hands-on tutorial for the FRDM-MCXC444 can be found at [here](https://www.nxp.com/design/design-center/development-boards-and-designs/general-purpose-mcus/frdm-development-board-for-mcx-c444-mcus:FRDM-MCXC444)
39+
40+
41+
![img](figures/usb_pc.png)
42+
43+
## Run the First Sample Program
44+
45+
### Compile and Download
46+
47+
1. Navigate to the `rt-thread\bsp\nxp\mcxc\frdm-mcxc444` folder.
48+
2. Open the project file in Keil.
49+
3. Compile the project.
50+
4. Click the download button to flash the firmware to the development board.
51+
52+
![dir](figures/dir.png)
53+
54+
Execute the compilation. After it, click the download button to download the firmware to the development board. Then, the program will start running automatically, observe the program running status.
55+
56+
> Tip: The default configuration of the project uses CMSIS-DAP to download the program. And then click the Download button to download the program to the development board.
57+
58+
![project](figures/project.png)
59+
60+
### Run
61+
62+
If it does not run automatically, press the reset button to restart the board and observe the actual effect of the LEDs on the board. After normal operation, the LEDs will blink periodically, as shown in the following figure:
63+
64+
![run](figures/run.gif)
65+
66+
After downloading the program, it should start running automatically. If not, press the reset button on the board.
67+
68+
Connect the board's serial port to your PC and open a serial terminal with the following settings:
69+
70+
- Baud rate: 115200
71+
- Data bits: 8
72+
- Stop bits: 1
73+
- Parity: None
74+
75+
Reset the device, and you should see the RT-Thread startup information in the serial terminal:
76+
77+
```bash
78+
\ | /
79+
- RT - Thread Operating System
80+
/ | \ 5.2.0 build Sep 4 2024 10:46:13
81+
2006 - 2024 Copyright by RT-Thread team
82+
using armclang, version: 6190004
83+
NXP MCXC444
84+
msh >
85+
```
86+
87+
## Keep Learning
88+
89+
Completed RT-Thread Quickstart! Click here for [Kernel Learning](../../kernel/kernel-video.md) .
90+
91+
## Additional Information
92+
93+
[NXP FRDM-MCXC444](https://www.nxp.com/design/design-center/development-boards-and-designs/general-purpose-mcus/frdm-development-board-for-mcx-c444-mcus:FRDM-MCXC444)

bsp/nxp/mcx/mcxc/frdm-mcxc444/applications/main.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#define LED_PIN ((4*32)+31)
2020
#define BUTTON_PIN ((2*32)+3)
2121

22-
static void sw_pin_cb(void *args);
22+
static void sw2_pin_cb(void *args);
2323

2424
int main(void)
2525
{
@@ -36,10 +36,10 @@ int main(void)
3636
rt_pin_mode(LED_PIN, PIN_MODE_OUTPUT); /* Set GPIO as Output */
3737

3838
rt_pin_mode(BUTTON_PIN, PIN_MODE_INPUT_PULLUP);
39-
rt_pin_attach_irq(BUTTON_PIN, PIN_IRQ_MODE_FALLING, sw_pin_cb, RT_NULL);
39+
rt_pin_attach_irq(BUTTON_PIN, PIN_IRQ_MODE_FALLING, sw2_pin_cb, RT_NULL);
4040
rt_pin_irq_enable(BUTTON_PIN, 1);
4141

42-
rt_kprintf("MCXC444 HelloWorld\r\n");
42+
rt_kprintf("NXP MCXC444\r\n");
4343

4444
while (1)
4545
{
@@ -50,9 +50,9 @@ int main(void)
5050
}
5151
}
5252

53-
static void sw_pin_cb(void *args)
53+
static void sw2_pin_cb(void *args)
5454
{
55-
rt_kprintf("sw pressed\r\n");
55+
rt_kprintf("sw2 pressed\r\n");
5656
}
5757

5858
// end file

bsp/nxp/mcx/mcxc/frdm-mcxc444/board/Kconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ menu "On-chip Peripheral Drivers"
3939

4040
if BSP_USING_I2C
4141
config BSP_USING_I2C0
42-
bool "Enable Flexcomm0 I2C"
42+
bool "Enable I2C0"
4343
default y
4444
config BSP_USING_I2C1
45-
bool "Enable Flexcomm1 I2C"
45+
bool "Enable I2C1"
4646
default y
4747
endif
4848

bsp/nxp/mcx/mcxc/frdm-mcxc444/board/MCUX_Config/board/pin_mux.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,14 @@ void BOARD_InitPins(void)
2727
CLOCK_EnableClock(kCLOCK_PortC);
2828
CLOCK_EnableClock(kCLOCK_PortD);
2929
CLOCK_EnableClock(kCLOCK_PortE);
30-
31-
PORT_SetPinMux(PORTA, 1U, kPORT_MuxAlt2); /* LPUART0_RX */
32-
PORT_SetPinMux(PORTA, 2U, kPORT_MuxAlt2); /* LPUART0_TX */
33-
34-
PORT_SetPinMux(PORTE, 0U, kPORT_MuxAlt3); /* LPUART1_TX */
35-
PORT_SetPinMux(PORTE, 1U, kPORT_MuxAlt3); /* LPUART1_RX */
30+
31+
PORT_SetPinMux(PORTA, 4, kPORT_MuxAsGpio); /* NMI */
32+
33+
PORT_SetPinMux(PORTA, 1, kPORT_MuxAlt2); /* LPUART0_RX */
34+
PORT_SetPinMux(PORTA, 2, kPORT_MuxAlt2); /* LPUART0_TX */
35+
36+
PORT_SetPinMux(PORTE, 0, kPORT_MuxAlt3); /* LPUART1_TX */
37+
PORT_SetPinMux(PORTE, 1, kPORT_MuxAlt3); /* LPUART1_RX */
3638

3739
SIM->SOPT5 = 0;
3840
}
1.53 MB
Loading
22.1 KB
Loading

0 commit comments

Comments
 (0)