Skip to content

Commit 517365a

Browse files
authored
Merge branch 'master' into scsi
2 parents 1d814fb + c055261 commit 517365a

File tree

586 files changed

+253556
-3081
lines changed

Some content is hidden

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

586 files changed

+253556
-3081
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,5 @@ The following content must not be changed in the submitted PR message. Otherwise
6161
- [ ] 所有变更均有原因及合理的,并且不会影响到其他软件组件代码或BSP All modifications are justified and not affect other components or BSP
6262
- [ ] 对难懂代码均提供对应的注释 I've commented appropriately where code is tricky
6363
- [ ] 代码是高质量的 Code in this PR is of high quality
64-
- [ ] 已经使用[formatting](https://github.com/mysterywolf/formatting) 等源码格式化工具确保格式符合[RT-Thread代码规范](https://github.com/RT-Thread/rt-thread/blob/master/documentation/contribution_guide/coding_style_cn.md) This PR complies with [RT-Thread code specification](https://github.com/RT-Thread/rt-thread/blob/master/documentation/contribution_guide/coding_style_en.md)
64+
- [ ] 已经使用[formatting](https://github.com/mysterywolf/formatting) 等源码格式化工具确保格式符合[RT-Thread代码规范](https://github.com/RT-Thread/rt-thread/blob/master/documentation/contribution_guide/coding_style_cn.md) This PR complies with [RT-Thread code specification](https://github.com/RT-Thread/rt-thread/blob/master/documentation/contribution_guide/coding_style_en.md)
65+
- [ ] 如果是新增bsp, 已经添加ci检查到[.github/workflows/bsp_buildings.yml](workflows/bsp_buildings.yml) 详细请参考链接[BSP自查](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/development-guide/bsp-selfcheck/bsp_selfcheck)

.github/workflows/bsp_buildings.yml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ jobs:
235235
- "renesas/ra6m4-iot"
236236
- "renesas/ra6m3-ek"
237237
- "renesas/ra6m3-hmi-board"
238+
- "renesas/ra6e2-fpb"
238239
- "renesas/ra4m2-eco"
239240
- "renesas/ra2l1-cpk"
240241
- "renesas/ra8m1-ek"
@@ -277,6 +278,7 @@ jobs:
277278
- "gd32/arm/gd32450z-eval"
278279
- "gd32/arm/gd32470z-lckfb"
279280
- "gd32/arm/gd32h759i-start"
281+
- "gd32/arm/gd32e503v-eval"
280282
- "n32/n32g43xcl-stb"
281283
- "n32/n32g45xcl-stb"
282284
- "n32/n32g45xml-stb"
@@ -301,14 +303,9 @@ jobs:
301303
- "apm32/apm32e103ze-evalboard"
302304
- "apm32/apm32e103ze-tinyboard"
303305
- "apm32/apm32s103vb-miniboard"
304-
- RTT_BSP: "nordic_Infineon_TI_microchip"
306+
- RTT_BSP: "Infineon_TI_microchip"
305307
RTT_TOOL_CHAIN: "sourcery-arm"
306308
SUB_RTT_BSP:
307-
- "nrf5x/nrf51822"
308-
- "nrf5x/nrf52832"
309-
- "nrf5x/nrf52833"
310-
- "nrf5x/nrf52840"
311-
- "nrf5x/nrf5340"
312309
- "Infineon/psoc6-cy8ckit-062S2-43012"
313310
- "Infineon/psoc6-cy8ckit-062-BLE"
314311
- "Infineon/psoc6-cy8ckit-062s4"
@@ -345,7 +342,7 @@ jobs:
345342
- "qemu-virt64-aarch64"
346343
- "raspberry-pi/raspi3-64"
347344
- "raspberry-pi/raspi4-64"
348-
- "rockchip/rk3568"
345+
#- "rockchip/rk3568" too long
349346
- "phytium/aarch64"
350347
- RTT_BSP: "riscv-none"
351348
RTT_TOOL_CHAIN: "sourcery-riscv-none-embed"
@@ -385,10 +382,18 @@ jobs:
385382
RTT_TOOL_CHAIN: "sourcery-i386-unknown-elf"
386383
SUB_RTT_BSP:
387384
- "x86"
385+
- RTT_BSP: "nordic(yml)"
386+
RTT_TOOL_CHAIN: "sourcery-arm"
387+
SUB_RTT_BSP:
388+
- "nrf5x/nrf51822"
389+
- "nrf5x/nrf52832"
390+
- "nrf5x/nrf52833"
391+
- "nrf5x/nrf52840"
392+
- "nrf5x/nrf5340"
388393
steps:
389394
- uses: actions/checkout@v4
390395
- name: Set up Python
391-
uses: actions/setup-python@v3
396+
uses: actions/setup-python@main
392397
with:
393398
python-version: 3.8
394399

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
scons.args: &scons
2+
scons_arg:
3+
- '--strict'
4+
devices.gpio:
5+
<<: *scons
6+
kconfig:
7+
- CONFIG_RT_USING_PIN=y
8+
- CONFIG_BSP_USING_GPIO=y
9+
devices.uart:
10+
kconfig:
11+
- CONFIG_RT_USING_SERIAL=y
12+
- CONFIG_RT_USING_SERIAL_V1=y
13+
- CONFIG_BSP_USING_UART=y
14+
devices.i2c:
15+
kconfig:
16+
- CONFIG_RT_USING_I2C=y
17+
- CONFIG_BSP_USING_I2C=y
18+
- CONFIG_BSP_USING_I2C0=y
19+
devices.spi:
20+
kconfig:
21+
- CONFIG_RT_USING_SPI=y
22+
- CONFIG_BSP_USING_SPI=y
23+
- CONFIG_BSP_USING_SPI2=y
24+
devices.hwtimer:
25+
kconfig:
26+
- CONFIG_RT_USING_HWTIMER=y
27+
- CONFIG_BSP_USING_HWTIMER=y
28+
- CONFIG_BSP_USING_TIMER0=y
29+
devices.adc:
30+
kconfig:
31+
- CONFIG_RT_USING_ADC=y
32+
- CONFIG_BSP_USING_ADC=y
33+
- CONFIG_BSP_USING_ADC1=y
34+
devices.pwm:
35+
kconfig:
36+
- CONFIG_RT_USING_PWM=y
37+
- CONFIG_BSP_USING_PWM=y
38+
- CONFIG_BSP_USING_PWM0=y
39+
devices.ble:
40+
kconfig:
41+
- CONFIG_BSP_USING_BLE=y
42+
devices.wifi:
43+
kconfig:
44+
- CONFIG_BSP_USING_WIFI=y
45+
- CONFIG_RT_USING_WIFI=y
46+
- CONFIG_RT_USING_LWIP=y
47+
- CONFIG_RT_USING_NETDEV=y

bsp/ESP32_C3/drivers/drv_spi.c

Lines changed: 90 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66
* Change Logs:
77
* Date Author Notes
88
* 2024-10-08 wumingzi first implementation
9+
* 2024-10-08 wumingzi add custom configuration and support muti spi obj
910
*/
1011

1112
#include <rtthread.h>
1213
#include <rtdevice.h>
14+
#include <time.h>
1315

1416
#include "rtdef.h"
1517
#include "rttypes.h"
@@ -20,6 +22,7 @@
2022
#include "driver/spi_master.h"
2123

2224
#include "drv_spi.h"
25+
#include "drivers/dev_spi.h"
2326

2427
#ifdef RT_USING_SPI
2528
#ifdef BSP_USING_SPI2
@@ -29,7 +32,6 @@
2932
static struct rt_spi_bus spi_bus2;
3033

3134
static spi_device_handle_t spi;
32-
3335
static spi_bus_config_t buscfg;
3436

3537
static struct esp32_spi spi_bus_obj[] = {
@@ -62,20 +64,9 @@ static void esp32_spi_init(struct esp32_spi *esp32_spi)
6264
spi_configure(NULL,NULL);
6365
}
6466

65-
static void spi_pin_mode(rt_base_t pin)
66-
{
67-
gpio_config_t io_conf;
68-
io_conf.intr_type = GPIO_INTR_DISABLE;
69-
io_conf.mode = GPIO_MODE_OUTPUT;
70-
io_conf.pin_bit_mask = (1ULL << pin);
71-
io_conf.pull_down_en = 0;
72-
io_conf.pull_up_en = 1;
73-
}
74-
7567
static rt_err_t spi_configure(struct rt_spi_device* device,
7668
struct rt_spi_configuration* configuration)
7769
{
78-
/* spi_pin_mode(RT_BSP_SPI_CS_PIN);*/
7970
static spi_bus_config_t buscfg =
8071
{
8172
.miso_io_num=SPI2_IOMUX_PIN_NUM_MISO, /*MISO*/
@@ -89,19 +80,87 @@ static rt_err_t spi_configure(struct rt_spi_device* device,
8980
esp_err_t err = spi_bus_initialize(SPI2_HOST, &buscfg, SPI_DMA_CH_AUTO);
9081
ESP_ERROR_CHECK(err);
9182

92-
static spi_device_interface_config_t devcfg={
93-
.clock_speed_hz = SPI_MASTER_FREQ_8M,
94-
.mode = 0,
95-
.spics_io_num = RT_BSP_SPI_CS_PIN,
96-
.queue_size = 7,
97-
};
83+
static spi_device_interface_config_t devcfg;
84+
if(configuration->data_width == 8)
85+
{
86+
size_t length; /*/< Total data length, in bits*/
87+
size_t rxlength; /*/< Total data length received, should be not greater than ``length`` in full-duplex mode (0 defaults this to the value of ``length``)*/
88+
}
89+
90+
LOG_W("configuration->max_hz = %d \n",configuration->max_hz);
91+
if(configuration->max_hz >= SPI_MASTER_FREQ_80M)
92+
{
93+
devcfg.clock_speed_hz = SPI_MASTER_FREQ_80M; /*/< 80MHz*/
94+
}
95+
else if(configuration->max_hz >= SPI_MASTER_FREQ_40M)
96+
{
97+
devcfg.clock_speed_hz = SPI_MASTER_FREQ_40M; /*/< 40MHz*/
98+
}
99+
else if(configuration->max_hz >= SPI_MASTER_FREQ_26M)
100+
{
101+
devcfg.clock_speed_hz = SPI_MASTER_FREQ_26M; /*/< 26.67MHz*/
102+
}
103+
else if(configuration->max_hz >= SPI_MASTER_FREQ_20M)
104+
{
105+
devcfg.clock_speed_hz = SPI_MASTER_FREQ_20M; /*/< 20MHz*/
106+
}
107+
else if(configuration->max_hz >= SPI_MASTER_FREQ_16M)
108+
{
109+
devcfg.clock_speed_hz = SPI_MASTER_FREQ_16M; /*/< 16MHz*/
110+
}
111+
else if(configuration->max_hz >= SPI_MASTER_FREQ_13M)
112+
{
113+
devcfg.clock_speed_hz = SPI_MASTER_FREQ_13M; /*/< 13.33MHz*/
114+
}
115+
else if(configuration->max_hz >= SPI_MASTER_FREQ_11M)
116+
{
117+
devcfg.clock_speed_hz = SPI_MASTER_FREQ_11M; /*/< 11.43MHz*/
118+
}
119+
else if(configuration->max_hz >= SPI_MASTER_FREQ_10M)
120+
{
121+
devcfg.clock_speed_hz = SPI_MASTER_FREQ_10M; /*/< 10MHz*/
122+
}
123+
else if(configuration->max_hz >= SPI_MASTER_FREQ_9M)
124+
{
125+
devcfg.clock_speed_hz = SPI_MASTER_FREQ_9M ; /*/< 8.89MHz*/
126+
}
127+
else
128+
{
129+
devcfg.clock_speed_hz = SPI_MASTER_FREQ_8M ;
130+
}
131+
132+
switch (configuration->mode)
133+
{
134+
case RT_SPI_MODE_0: /*!< CPOL = 0, CPHA = 0 */
135+
devcfg.mode = 0;
136+
case RT_SPI_MODE_1: /*!< CPOL = 0, CPHA = 1 */
137+
devcfg.mode = 1;
138+
case RT_SPI_MODE_2: /*!< CPOL = 1, CPHA = 0 */
139+
devcfg.mode = 2;
140+
case RT_SPI_MODE_3: /*!< CPOL = 1, CPHA = 1 */
141+
devcfg.mode = 3;
142+
default:
143+
devcfg.mode = 0;
144+
}
145+
146+
/* todo: support changing cs_pin,queue_size or specifing spi_device_interface_config_t and
147+
* spi_transaction_t by resever data.Meanwhile finish the initialization of interrupt
148+
* callback function and dma.
149+
*/
150+
151+
devcfg.spics_io_num = RT_BSP_SPI_CS_PIN;
152+
devcfg.queue_size = 7;
98153

99154
err = spi_bus_add_device(SPI2_HOST, &devcfg, &spi);
100155
ESP_ERROR_CHECK(err);
101156

102-
spi_bus_obj[0].bus_name = "spi2";
103-
spi_bus_obj[0].spi_bus = &spi_bus2;
104-
spi_bus_obj[0].esp32_spi_bus_cfg = &buscfg;
157+
/* Although there is only one spi bus object, it will be a template for other bsps of ESP32 series */
158+
for(int i = 0; i < sizeof(spi_bus_obj)/sizeof(spi_bus_obj[0]); i++)
159+
{
160+
spi_bus_obj[i].bus_name = "spi2";
161+
spi_bus_obj[i].spi_bus = &spi_bus2;
162+
spi_bus_obj[i].esp32_spi_bus_cfg = &buscfg;
163+
}
105164

106165
return RT_EOK;
107166
};
@@ -116,8 +175,8 @@ static rt_ssize_t spixfer(struct rt_spi_device* device, struct rt_spi_message* m
116175

117176
trans.tx_buffer = message->send_buf;
118177
trans.rx_buffer = message->recv_buf;
119-
trans.length = message->length;
120-
trans.rxlength = message->length;
178+
trans.length = (message->length)*8;
179+
trans.rxlength = (message->length)*8;
121180

122181
spi_device_acquire_bus(spi, portMAX_DELAY);
123182
esp_err_t err = spi_device_polling_transmit(spi, &trans);
@@ -161,17 +220,20 @@ int rt_hw_spi_init(void)
161220
{
162221
int result = 0;
163222

164-
spi_bus_obj[0].spi_bus->parent.user_data = (void *)&spi_bus_obj[0];
165-
result = rt_spi_bus_register(spi_bus_obj[0].spi_bus, spi_bus_obj[0].bus_name, &esp32_spi_ops);
223+
for(int i = 0; i < sizeof(spi_bus_obj)/sizeof(spi_bus_obj[0]); i++)
224+
{
225+
spi_bus_obj[i].spi_bus->parent.user_data = (void *)&spi_bus_obj[i];
226+
result = rt_spi_bus_register(spi_bus_obj[i].spi_bus, spi_bus_obj[i].bus_name, &esp32_spi_ops);
166227

167-
RT_ASSERT(result == RT_EOK);
228+
RT_ASSERT(result == RT_EOK);
168229

169-
LOG_D("%s bus init done", spi_bus_obj[i].bus_name);
230+
LOG_D("%s bus init done", spi_bus_obj[i].bus_name);
231+
}
170232

171233
return result;
172234
}
173235

174236
INIT_BOARD_EXPORT(rt_hw_spi_init);
175237

176238
#endif /* BSP_USING_SPI0 || BSP_USING_SPI1 || BSP_USING_SPI2 || BSP_USING_SPI3 || BSP_USING_SPI4*/
177-
#endif /* RT_USING_SPI */
239+
#endif /* RT_USING_SPI */

bsp/ESP32_C3/main/main.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@
1414
#include <rtdevice.h>
1515
#include <board.h>
1616

17+
#ifdef BSP_USING_BLE
18+
void app_main()
19+
{
20+
while(1)
21+
{
22+
23+
}
24+
}
25+
#endif /* BSP_USING_BLE */
26+
1727
int main(void)
1828
{
1929
rt_kprintf("Hello!RT-THREAD!\r\n");

0 commit comments

Comments
 (0)