Skip to content

Commit

Permalink
Add data serial to bootcfg and rename console serial
Browse files Browse the repository at this point in the history
  • Loading branch information
xs5871 committed Feb 2, 2024
1 parent 5d4e787 commit e733c4d
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 13 deletions.
11 changes: 8 additions & 3 deletions docs/en/boot.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ bootcfg(
# optional:
source: Optional[microcontroller.Pin, digitalio.DigitalInOut] = None,
boot_device: int = 0,
cdc: bool = True,
cdc_console: bool = True,
cdc_data: bool = False,
consumer_control: bool = True,
keyboard: bool = True,
midi: bool = True,
Expand Down Expand Up @@ -70,10 +71,14 @@ Boot HID device configuration for `usb_hid`, see the [`usb_hid` documentation](h
for details.


#### `cdc`
#### `cdc_console`
This will enable or disable the USB endpoint for the serial console with REPL.


#### `cdc_data`
This will enable or disable the USB endpoint for the data serial.


#### `consumer_control`
Enable the HID endpoint for consumer control reports. Those are extra keys for
things like multimedia control and browser shortcuts.
Expand Down Expand Up @@ -180,7 +185,7 @@ sense = True

bootcfg(
sense=sense,
cdc=False,
cdc_console=False,
consumer_control=False,
keyboard=False,
midi=False,
Expand Down
14 changes: 11 additions & 3 deletions docs/en/serialace.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,19 @@ use for the CircuitPython debugger).

## Prerequisite

Enable the data serial in `boot.py`:
Enable the data serial in `boot.py`, for example by using KMK's builtin boot
configurator:
```python
import usb_cdc
usb_cdc.enable(data=True)
from kmk.bootcfg import bootcfg

bootcfg(
# ...excerpt
cdc_data=True,
# ...
)

```
Consult the [bootcfg documentation](boot.md) for more details.


## Example
Expand Down
19 changes: 13 additions & 6 deletions kmk/bootcfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ def bootcfg(
sense: [microcontroller.Pin, digitalio.DigitalInOut],
source: Optional[microcontroller.Pin, digitalio.DigitalInOut] = None,
boot_device: int = 0,
cdc: bool = True,
cdc_console: bool = True,
cdc_data: bool = False,
consumer_control: bool = True,
keyboard: bool = True,
midi: bool = True,
Expand Down Expand Up @@ -77,13 +78,19 @@ def bootcfg(
if hasattr(supervisor, 'set_usb_identification'):
supervisor.set_usb_identification(*usb_id)

# Entries for cdc (REPL) and storage are intentionally evaluated last to
# ensure the board is debuggable, mountable and rescueable, in case any of
# the previous code throws an exception.
if not cdc:
# configure data serial
if cdc_data:
import usb_cdc

usb_cdc.disable()
usb_cdc.enable(data=True)

# Entries for serial console (REPL) and storage are intentionally evaluated
# last to ensure the board is debuggable, mountable and rescueable, in case
# any of the previous code throws an exception.
if not cdc_console:
import usb_cdc

usb_cdc.enable(console=False)

if not storage:
import storage
Expand Down
3 changes: 2 additions & 1 deletion util/aspell.en.pws
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
personal_ws-1.1 en 348
personal_ws-1.1 en 349
ADNS
AMS
ANAVI
Expand Down Expand Up @@ -217,6 +217,7 @@ ble
bmp
bondings
boolean
bootcfg
bootloader
bootup
bytecode
Expand Down

0 comments on commit e733c4d

Please sign in to comment.