1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
|
menuconfig RT_USING_SPI
bool "Using SPI Bus/Device device drivers"
default n
help
Enable the SPI framework so hardware controllers and client drivers can
register SPI buses/devices through RT-Thread. This brings in the SPI core,
the DM glue, and the optional software backend. Turn it on for any board
that connects SPI flashes, sensors, RF chips, or display panels; disable
only when SPI is unused to save footprint.
if RT_USING_SPI
menuconfig RT_USING_SPI_ISR
bool "Enable interrupt-safe SPI operations (using spinlocks in ISR context)"
default y
help
Allow SPI APIs to be invoked from interrupt context by guarding
transfer state with spinlocks instead of mutexes. Enable it when
DMA completion or GPIO IRQ handlers need to queue SPI work; leave
it off if every transfer happens in thread context to slightly
reduce locking overhead.
config RT_USING_SPI_BITOPS
bool "Enable SPI bit-bang operation functions"
default n
menuconfig RT_USING_SOFT_SPI
bool "Use GPIO to simulate SPI"
default n
select RT_USING_PIN
select RT_USING_SPI_BITOPS
help
Build software (bit-banged) SPI masters that toggle GPIO pins in
software. Each bus selected below lets you pick SCK/MISO/MOSI pins
and an exported bus name, ideal for simple sensors or when all
hardware SPI controllers are in use.
if RT_USING_SOFT_SPI
menuconfig RT_USING_SOFT_SPI0
bool "Enable SPI0 Bus (software simulation)"
default y
help
Instantiate the first software SPI bus using the pins
configured below. Disable it if your board does not need a
bit-banged SPI0 instance.
if RT_USING_SOFT_SPI0
config RT_SOFT_SPI0_SCK_PIN
int "SCK pin number"
range 0 32767
default 1
config RT_SOFT_SPI0_MISO_PIN
int "MISO pin number"
range 0 32767
default 2
config RT_SOFT_SPI0_MOSI_PIN
int "MOSI pin number"
range 0 32767
default 3
config RT_SOFT_SPI0_BUS_NAME
string "Bus name"
default "spi0"
config RT_SOFT_SPI0_TIMING_DELAY
int "Timing delay (us)"
range 0 32767
default 1
endif
menuconfig RT_USING_SOFT_SPI1
bool "Enable SPI1 Bus (software simulation)"
default y
help
Enable a second software SPI channel for additional
low-speed peripherals when dedicated controllers run out.
if RT_USING_SOFT_SPI1
config RT_SOFT_SPI1_SCK_PIN
int "SCK pin number"
range 0 32767
default 4
config RT_SOFT_SPI1_MISO_PIN
int "MISO pin number"
range 0 32767
default 5
config RT_SOFT_SPI1_MOSI_PIN
int "MOSI pin number"
range 0 32767
default 6
config RT_SOFT_SPI1_BUS_NAME
string "Bus name"
default "spi1"
config RT_SOFT_SPI1_TIMING_DELAY
int "Timing delay (us)"
range 0 32767
default 1
endif
menuconfig RT_USING_SOFT_SPI2
bool "Enable SPI2 Bus (software simulation)"
default n
help
Optional third soft SPI bus. Only enable when the PCB
routes the corresponding GPIO pins.
if RT_USING_SOFT_SPI2
config RT_SOFT_SPI2_SCK_PIN
int "SCK pin number"
range 0 32767
default 7
config RT_SOFT_SPI2_MISO_PIN
int "MISO pin number"
range 0 32767
default 8
config RT_SOFT_SPI2_MOSI_PIN
int "MOSI pin number"
range 0 32767
default 9
config RT_SOFT_SPI2_BUS_NAME
string "Bus name"
default "spi2"
config RT_SOFT_SPI2_TIMING_DELAY
int "Timing delay (us)"
range 0 32767
default 1
endif
menuconfig RT_USING_SOFT_SPI3
bool "Enable SPI3 Bus (software simulation)"
default n
help
Fourth bit-banged SPI bus entry. Leave disabled to save
resources if not wired.
if RT_USING_SOFT_SPI3
config RT_SOFT_SPI3_SCK_PIN
int "SCK pin number"
range 0 32767
default 10
config RT_SOFT_SPI3_MISO_PIN
int "MISO pin number"
range 0 32767
default 11
config RT_SOFT_SPI3_MOSI_PIN
int "MOSI pin number"
range 0 32767
default 12
config RT_SOFT_SPI3_BUS_NAME
string "Bus name"
default "spi3"
config RT_SOFT_SPI3_TIMING_DELAY
int "Timing delay (us)"
range 0 32767
default 1
endif
menuconfig RT_USING_SOFT_SPI4
bool "Enable SPI4 Bus (software simulation)"
default n
help
Provide a fifth software SPI bus; adds static data for the
pin descriptors even when unused.
if RT_USING_SOFT_SPI4
config RT_SOFT_SPI4_SCK_PIN
int "SCK pin number"
range 0 32767
default 13
config RT_SOFT_SPI4_MISO_PIN
int "MISO pin number"
range 0 32767
default 14
config RT_SOFT_SPI4_MOSI_PIN
int "MOSI pin number"
range 0 32767
default 15
config RT_SOFT_SPI4_BUS_NAME
string "Bus name"
default "spi4"
config RT_SOFT_SPI4_TIMING_DELAY
int "Timing delay (us)"
range 0 32767
default 1
endif
menuconfig RT_USING_SOFT_SPI5
bool "Enable SPI5 Bus (software simulation)"
default n
help
Optional sixth software bus for complex designs with many
discrete chips.
if RT_USING_SOFT_SPI5
config RT_SOFT_SPI5_SCK_PIN
int "SCK pin number"
range 0 32767
default 16
config RT_SOFT_SPI5_MISO_PIN
int "MISO pin number"
range 0 32767
default 17
config RT_SOFT_SPI5_MOSI_PIN
int "MOSI pin number"
range 0 32767
default 18
config RT_SOFT_SPI5_BUS_NAME
string "Bus name"
default "spi5"
config RT_SOFT_SPI5_TIMING_DELAY
int "Timing delay (us)"
range 0 32767
default 1
endif
menuconfig RT_USING_SOFT_SPI6
bool "Enable SPI6 Bus (software simulation)"
default n
help
Enable a seventh software SPI controller if more GPIO-only
buses are necessary.
if RT_USING_SOFT_SPI6
config RT_SOFT_SPI6_SCK_PIN
int "SCK pin number"
range 0 32767
default 19
config RT_SOFT_SPI6_MISO_PIN
int "MISO pin number"
range 0 32767
default 20
config RT_SOFT_SPI6_MOSI_PIN
int "MOSI pin number"
range 0 32767
default 21
config RT_SOFT_SPI6_BUS_NAME
string "Bus name"
default "spi6"
config RT_SOFT_SPI6_TIMING_DELAY
int "Timing delay (us)"
range 0 32767
default 1
endif
endif
config RT_SPI_BITOPS_DEBUG
bool "Use simulate SPI debug message"
depends on RT_USING_SOFT_SPI
default n
help
Print the edge-level toggling performed by the software SPI
backend. Useful when verifying custom wiring, but it slows down
transfers considerably.
config RT_USING_QSPI
bool "Enable QSPI mode"
default n
help
Adds Quad-SPI support to the SPI core so flash drivers can switch
MISO/MOSI pins into quad data mode and use controller-specific
QSPI ops. Enable this when your SoC exposes a QSPI controller or
you plan to run SFUD in quad mode.
config RT_USING_SPI_MSD
bool "Using SD/TF card driver with spi"
select RT_USING_DFS
default n
help
Build the SPI-based block driver for SD/TF cards (Mass Storage
Device). Select this when your design wires SD cards to an SPI
bus instead of a dedicated SDIO host; it pulls in DFS for the
filesystem layer.
config RT_USING_SFUD
bool "Using Serial Flash Universal Driver"
default n
help
Pull in the Serial Flash Universal Driver which speaks the JEDEC
SFDP standard, auto-detects parameters, and exposes SPI NOR chips
through the RT-Thread MTD interface. Enable this for off-chip SPI
NOR/QSPI flash storage; disable it if you rely on SoC-specific
flash drivers instead.
if RT_USING_SFUD
config RT_SFUD_USING_SFDP
bool "Using auto probe flash JEDEC SFDP parameter"
default y
help
Parse the flash SFDP tables at runtime for sizing, erase
commands, and quad support. Disable only if your flash lacks
SFDP and you prefer hard-coded settings.
config RT_SFUD_USING_FLASH_INFO_TABLE
bool "Using defined supported flash chip information table"
default y
help
Keep the built-in flash info table so chips without valid SFDP
headers can still be recognized. You can turn it off to reduce
the binary when you know SFDP probing always succeeds.
config RT_SFUD_USING_QSPI
bool "Using QSPI mode support"
select RT_USING_QSPI
default n
help
Allow SFUD to drive flashes via Quad-SPI instructions. Requires
a QSPI-capable controller and board routing.
config RT_SFUD_SPI_MAX_HZ
int "Default spi maximum speed(HZ)"
range 0 50000000
default 50000000
help
Default maximum bus frequency SFUD will request when
probing flashes. Keep it at or below 50 MHz for SFDP per
the JEDEC spec; runtime drivers may still lower it with
`rt_spi_configure()`.
config RT_DEBUG_SFUD
bool "Show more SFUD debug information"
default n
help
Verbosely log SFUD operations (probe, erase, write). Enable
when bringing up new flash parts; keep disabled in production.
endif
config RT_USING_ENC28J60
bool "Using ENC28J60 SPI Ethernet network interface"
select RT_USING_LWIP
default n
help
Build the ENC28J60 Ethernet driver which talks to Microchip's SPI
MAC+PHY and registers a netif on top of lwIP. Enable it when your
board uses the ENC28J60; otherwise it adds dead code.
config RT_USING_SPI_WIFI
bool "Using RW009/007 SPI Wi-Fi wireless interface"
select RT_USING_LWIP
default n
help
Include the RW009/RW007 Wi-Fi driver that exchanges frames via
SPI. Requires lwIP and a matching module connected to the bus.
endif
if RT_USING_DM && RT_USING_SPI
osource "$(SOC_DM_SPI_DIR)/Kconfig"
endif
|