You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -170,19 +180,25 @@ This driver uses the ChibiOS-PWM system to produce a square-wave on specific out
170
180
The hardware directly toggles the pin via its alternate function. See your MCU's data-sheet for which pin can be driven by what timer - looking for TIMx_CHy and the corresponding alternate function.
171
181
172
182
A configuration example for the STM32F103C8 would be:
173
-
```c
174
-
//halconf.h:
175
-
#defineHAL_USE_PWM TRUE
176
-
#defineHAL_USE_PAL TRUE
183
+
184
+
::: code-group
185
+
```c [halconf.h]
186
+
#pragma once
187
+
188
+
#defineHAL_USE_PWM TRUE // [!code focus]
189
+
#define HAL_USE_PAL TRUE // [!code focus]
190
+
177
191
#include_next <halconf.h>
178
192
```
193
+
```c [mcuconf.h]
194
+
#pragma once
179
195
180
-
```c
181
-
// mcuconf.h:
182
196
#include_next <mcuconf.h>
183
-
#undef STM32_PWM_USE_TIM1
184
-
#defineSTM32_PWM_USE_TIM1 TRUE
197
+
198
+
#undef STM32_PWM_USE_TIM1 // [!code focus]
199
+
#defineSTM32_PWM_USE_TIM1 TRUE // [!code focus]
185
200
```
201
+
:::
186
202
187
203
If we now target pin A8, looking through the data-sheet of the STM32F103C8, for the timers and alternate functions
Copy file name to clipboardexpand all lines: docs/drivers/i2c.md
+14-7
Original file line number
Diff line number
Diff line change
@@ -54,18 +54,25 @@ The ATmega16/32U2 does not possess I2C functionality, and so cannot use this dri
54
54
55
55
You'll need to determine which pins can be used for I2C -- a an example, STM32 parts generally have multiple I2C peripherals, labeled I2C1, I2C2, I2C3 etc.
56
56
57
-
To enable I2C, modify your board's `halconf.h` to enable I2C:
57
+
To enable I2C, modify your board's `halconf.h` to enable I2C, then modify your board's `mcuconf.h` to enable the peripheral you've chosen:
58
58
59
-
```c
60
-
#define HAL_USE_I2C TRUE
59
+
::: code-group
60
+
```c [halconf.h]
61
+
#pragma once
62
+
63
+
#define HAL_USE_I2C TRUE // [!code focus]
64
+
65
+
#include_next <halconf.h>
61
66
```
67
+
```c [mcuconf.h]
68
+
#pragma once
62
69
63
-
Then, modify your board's `mcuconf.h` to enable the peripheral you've chosen, for example:
Copy file name to clipboardexpand all lines: docs/drivers/serial.md
+65-49
Original file line number
Diff line number
Diff line change
@@ -12,8 +12,6 @@ The Serial driver powers the [Split Keyboard](../features/split_keyboard) featur
12
12
Serial in this context should be read as **sending information one bit at a time**, rather than implementing UART/USART/RS485/RS232 standards.
13
13
:::
14
14
15
-
<hr>
16
-
17
15
## Bitbang
18
16
19
17
This is the Default driver, absence of configuration assumes this driver. It works by [bit banging](https://en.wikipedia.org/wiki/Bit_banging) a GPIO pin using the CPU. It is therefore not as efficient as a dedicated hardware peripheral, which the Half-duplex and Full-duplex drivers use.
@@ -53,11 +51,15 @@ SERIAL_DRIVER = bitbang
53
51
#defineSOFT_SERIAL_PIN D0 // or D1, D2, D3, E6
54
52
```
55
53
56
-
3. On ARM platforms you must turn on ChibiOS `PAL_USE_CALLBACKS` feature:
54
+
3. On ARM platforms you must turn on ChibiOS PAL callbacks:
57
55
58
-
* In `halconf.h` add the line `#define PAL_USE_CALLBACKS TRUE`.
56
+
```c
57
+
#pragma once
59
58
60
-
<hr>
59
+
#define PAL_USE_CALLBACKS TRUE // [!code focus]
60
+
61
+
#include_next <halconf.h>
62
+
```
61
63
62
64
## USART Half-duplex
63
65
@@ -117,8 +119,6 @@ For STM32 MCUs several GPIO configuration options can be changed as well. See th
117
119
118
120
4. Decide either for `SERIAL`, `SIO`, or `PIO` subsystem. See section ["Choosing a driver subsystem"](#choosing-a-driver-subsystem).
119
121
120
-
<hr>
121
-
122
122
## USART Full-duplex
123
123
124
124
Targeting ARM boards based on ChibiOS where communication is offloaded to an USART hardware device. The advantages over bitbanging are fast, accurate timings and reduced CPU usage; therefore it is advised to choose this driver over all others where possible. Due to its internal design Full-duplex is slightly more efficient than the Half-duplex driver, but Full-duplex should be primarily chosen if Half-duplex operation is not supported by the controller's USART peripheral.
@@ -179,70 +179,88 @@ For STM32 MCUs several GPIO configuration options, including the ability for `TX
179
179
180
180
4. Decide either for `SERIAL`, `SIO`, or `PIO` subsystem. See section ["Choosing a driver subsystem"](#choosing-a-driver-subsystem).
181
181
182
-
<hr>
183
-
184
182
## Choosing a driver subsystem
185
183
186
184
### The `SERIAL` driver
187
185
188
186
The `SERIAL` Subsystem is supported for the majority of ChibiOS MCUs and should be used whenever supported. Follow these steps in order to activate it:
189
187
190
-
1. In your keyboards `halconf.h` add:
188
+
1. Enable the SERIAL subsystem in the ChibiOS HAL.
191
189
192
-
```c
193
-
#define HAL_USE_SERIAL TRUE
194
-
```
190
+
Add the following to your keyboard's `halconf.h`, creating it if necessary:
195
191
196
-
2. In your keyboards `mcuconf.h`: activate the USART peripheral that is used on your MCU. The shown example is for an STM32 MCU, so this will not work on MCUs by other manufacturers. You can find the correct names in the `mcuconf.h` files of your MCU that ship with ChibiOS.
197
-
198
-
Just below `#include_next <mcuconf.h>` add:
192
+
```c
193
+
#pragma once
199
194
200
-
```c
201
-
#include_next <mcuconf.h>
195
+
#define HAL_USE_SERIAL TRUE // [!code focus]
202
196
203
-
#undef STM32_SERIAL_USE_USARTn
204
-
#define STM32_SERIAL_USE_USARTn TRUE
205
-
```
197
+
#include_next <halconf.h>
198
+
```
206
199
207
-
Where 'n' matches the peripheral number of your selected USART on the MCU.
200
+
2. Activate the USART peripheral that is used on your MCU. The shown example is for an STM32 MCU, so this will not work on MCUs by other manufacturers. You can find the correct names in the `mcuconf.h` files of your MCU that ship with ChibiOS.
208
201
209
-
3. In you keyboards `config.h`: override the default USART `SERIAL` driver if you use a USART peripheral that does not belong to the default selected `SD1` driver. For instance, if you selected `STM32_SERIAL_USE_USART3` the matching driver would be `SD3`.
202
+
Add the following to your keyboard's `mcuconf.h`, creating it ifnecessary:
Where *n* matches the peripheral number of your selected USART on the MCU.
214
+
215
+
3. Override the default USART `SERIAL` driver if you use a USART peripheral that does not belong to the default selected `SD1` driver. For instance, if you selected `STM32_SERIAL_USE_USART3` the matching driver would be `SD3`.
216
+
217
+
Add the following to your keyboard's `config.h`:
218
+
219
+
```c
220
+
#define SERIAL_USART_DRIVER SD3
221
+
```
214
222
215
223
### The `SIO` driver
216
224
217
225
The `SIO` Subsystem was added to ChibiOS with the 21.11 release and is only supported on selected MCUs. It should only be chosen when the `SERIAL` subsystem is not supported by your MCU.
218
226
219
227
Follow these steps in order to activate it:
220
228
221
-
1. In your keyboards `halconf.h` add:
229
+
1. Enable the SIO subsystem in the ChibiOS HAL.
222
230
223
-
```c
224
-
#define HAL_USE_SIO TRUE
225
-
```
231
+
Add the following to your keyboard's `halconf.h`, creating it if necessary:
226
232
227
-
2. In your keyboards `mcuconf.h:` activate the USART peripheral that is used on your MCU. The shown example is for an STM32 MCU, so this will not work on MCUs by other manufacturers. You can find the correct names in the `mcuconf.h` files of your MCU that ship with ChibiOS.
228
-
229
-
Just below `#include_next <mcuconf.h>` add:
233
+
```c
234
+
#pragma once
230
235
231
-
```c
232
-
#include_next <mcuconf.h>
236
+
#define HAL_USE_SIO TRUE // [!code focus]
233
237
234
-
#undef STM32_SIO_USE_USARTn
235
-
#define STM32_SIO_USE_USARTn TRUE
236
-
```
238
+
#include_next <halconf.h>
239
+
```
237
240
238
-
Where 'n' matches the peripheral number of your selected USART on the MCU.
241
+
2. Activate the USART peripheral that is used on your MCU. The shown example is for an STM32 MCU, so this will not work on MCUs by other manufacturers. You can find the correct names in the `mcuconf.h` files of your MCU that ship with ChibiOS.
239
242
240
-
3. In the keyboard's `config.h` file: override the default USART `SIO` driver if you use a USART peripheral that does not belong to the default selected `SIOD1` driver. For instance, if you selected `STM32_SERIAL_USE_USART3` the matching driver would be `SIOD3`.
243
+
Add the following to your keyboard's `mcuconf.h`, creating it if necessary:
244
+
245
+
```c
246
+
#pragma once
247
+
248
+
#include_next <mcuconf.h>
249
+
250
+
#undef STM32_SIO_USE_USARTn // [!code focus]
251
+
#defineSTM32_SIO_USE_USARTn TRUE // [!code focus]
252
+
```
253
+
254
+
Where *n* matches the peripheral number of your selected USART on the MCU.
255
+
256
+
3. Override the default USART `SIO` driver if you use a USART peripheral that does not belong to the default selected `SIOD1` driver. For instance, if you selected `STM32_SERIAL_USE_USART3` the matching driver would be `SIOD3`.
257
+
258
+
Add the following to your keyboard's `config.h`:
259
+
260
+
```c
261
+
#define SERIAL_USART_DRIVER SIOD3
262
+
```
241
263
242
-
```c
243
-
#defineSERIAL_USART_DRIVER SIOD3
244
-
```
245
-
246
264
### The `PIO` driver
247
265
248
266
The `PIO` subsystem is a Raspberry Pi RP2040 specific implementation, using an integrated PIO peripheral and is therefore only available on this MCU. Because of the flexible nature of PIO peripherals, **any** GPIO pin can be used as a `TX` or `RX` pin. Half-duplex and Full-duplex operation modes are fully supported with this driver. Half-duplex uses the built-in pull-ups and GPIO manipulation of the RP2040 to drive the line high by default, thus an external pull-up resistor **is not required**.
@@ -254,8 +272,6 @@ Optionally, the PIO peripheral utilized for split communication can be changed w
254
272
255
273
The Serial PIO program uses 2 state machines, 13 instructions and the complete interrupt handler of the PIO peripheral it is running on.
256
274
257
-
<hr>
258
-
259
275
## Advanced Configuration
260
276
261
277
There are several advanced configuration options that can be defined in your keyboards `config.h` file:
@@ -265,9 +281,11 @@ There are several advanced configuration options that can be defined in your key
265
281
If you're having issues or need a higher baudrate with serial communication, you can change the baudrate which in turn controls the communication speed for serial. You want to lower the baudrate if you experience failed transactions.
If you're having issues withe serial communication, you can enable debug messages that will give you insights which part of the communication failed. The enable these messages add to your keyboards `config.h` file:
Copy file name to clipboardexpand all lines: docs/drivers/spi.md
+16-9
Original file line number
Diff line number
Diff line change
@@ -32,20 +32,27 @@ You may use more than one slave select pin, not just the `SS` pin. This is usefu
32
32
33
33
You'll need to determine which pins can be used for SPI -- as an example, STM32 parts generally have multiple SPI peripherals, labeled SPI1, SPI2, SPI3 etc.
34
34
35
-
To enable SPI, modify your board's `halconf.h` to enable SPI:
35
+
To enable SPI, modify your board's `halconf.h` to enable SPI, then modify your board's `mcuconf.h` to enable the peripheral you've chosen:
0 commit comments