|
4 | 4 | * SPDX-License-Identifier: Apache-2.0 |
5 | 5 | * |
6 | 6 | * Change Logs: |
7 | | - * Date Author Notes |
8 | | - * 2018-11-27 zylx first version |
| 7 | + * Date Author Notes |
| 8 | + * 2018-11-27 zylx first version |
| 9 | + * 2025-12-14 LinuxMint-User resolve QSPI compilation error |
9 | 10 | */ |
10 | 11 |
|
11 | 12 | #include <board.h> |
|
19 | 20 | #include "dev_spi_flash.h" |
20 | 21 | #include "dev_spi_flash_sfud.h" |
21 | 22 |
|
| 23 | +#define QSPI_BUS_NAME "qspi1" |
| 24 | +#define QSPI_DEVICE_NAME "qspi10" |
| 25 | + |
22 | 26 | char w25qxx_read_status_register2(struct rt_qspi_device *device) |
23 | 27 | { |
24 | 28 | /* 0x35 read status register2 */ |
@@ -60,26 +64,14 @@ void w25qxx_enter_qspi_mode(struct rt_qspi_device *device) |
60 | 64 | } |
61 | 65 | } |
62 | 66 |
|
63 | | -/* Adapter function to bridge the signature mismatch between driver layer |
64 | | - * expectation (void (*)()) and framework requirement (void (*)(struct rt_qspi_device *)). |
65 | | - */ |
66 | | -void w25qxx_enter_qspi_mode_adapter(void) |
67 | | -{ |
68 | | - struct rt_qspi_device *device = (struct rt_qspi_device *)rt_device_find("qspi10"); |
69 | | - if (device == RT_NULL) |
70 | | - { |
71 | | - rt_kprintf("QSPI device not found!\n"); |
72 | | - return; |
73 | | - } |
74 | | - w25qxx_enter_qspi_mode(device); |
75 | | -} |
76 | | - |
77 | 67 | static int rt_hw_qspi_flash_with_sfud_init(void) |
78 | 68 | { |
79 | | - rt_hw_qspi_device_attach("qspi1", "qspi10", RT_NULL, 4, w25qxx_enter_qspi_mode_adapter, RT_NULL); |
| 69 | + /* 直接使用类型转换,避免单独的适配器函数 */ |
| 70 | + rt_hw_qspi_device_attach(QSPI_BUS_NAME, QSPI_DEVICE_NAME, RT_NULL, 4, |
| 71 | + (void (*)(void))w25qxx_enter_qspi_mode, RT_NULL); |
80 | 72 |
|
81 | 73 | /* init w25q128 */ |
82 | | - if (RT_NULL == rt_sfud_flash_probe("W25Q128", "qspi10")) |
| 74 | + if (RT_NULL == rt_sfud_flash_probe("W25Q128", QSPI_DEVICE_NAME)) |
83 | 75 | { |
84 | 76 | return -RT_ERROR; |
85 | 77 | } |
|
0 commit comments