Skip to content

CH32V003 microcontroller, BLE joystick example update#514

Merged
ducky64 merged 13 commits into
masterfrom
ch32v
Jun 6, 2026
Merged

CH32V003 microcontroller, BLE joystick example update#514
ducky64 merged 13 commits into
masterfrom
ch32v

Conversation

@ducky64

@ducky64 ducky64 commented Jun 6, 2026

Copy link
Copy Markdown
Collaborator

Adds the CH32V003 and uses it in the BLE joystick.

Modifies the BLE joystick example with lessons learned / new features:

  • use nRF52 low power BLE MCU
  • add top button sub-board with d-pad buttons and LEDs
  • use soft power gate to turn on / off
  • use INA219 for battery voltage and current sensing
  • add IMU
  • support power gating of joystick

This board has not been routed yet, that will happen later. Additional circuit modifications may be required during routing.

Other fixes:

  • fixes IoControllerWrapper classes
  • improve documentation for the sot power switch
  • make DigitalBidir as_voltage_source capable
  • removes TC2050 SWD header with no deprecation path, it was a bad idea
  • add PROG control to the MCP73831 to support charging disable

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR expands the EDG parts library and examples to support a new CH32V003 microcontroller and updates the BLE joystick reference design to incorporate a lower-power nRF52 module, additional sub-boards/features, and revised power/charging architecture. It also standardizes SWD connectivity away from the legacy TC2050-style header toward the TC2030 Tag-Connect style across affected examples.

Changes:

  • Add CH32V003 microcontroller support (including an SDI programming header abstraction) and integrate it into the BLE joystick button sub-board as an IO expander.
  • Update BLE joystick example hardware architecture: soft power gating, INA219 battery sensing, IMU/magnetometer on I2C, button sub-board + neopixels, and nRF52840 module usage.
  • Replace TC2050 SWD header usage with TC2030/Tag-Connect mappings in example PCB exports and example tests; remove the legacy SWD connector class.

Reviewed changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
examples/TofArray/TofArray.svgpcb.js Adjusts placement and updates SWD connector footprint/pin mapping to TC2030.
examples/TofArray/TofArray.net.ref Updates reference netlist to match TC2030 SWD footprint and pin remap.
examples/test_tofarray.py Updates SWD connector refinement to Tag-Connect style.
examples/test_multimeter.py Updates SWD connector refinement to Tag-Connect style.
examples/test_ble_joystick.py Major BLE joystick design update; adds ButtonSubboard; integrates CH32V003 + new power/I2C peripherals.
examples/Multimeter/Multimeter.svgpcb.js Placement changes and SWD connector update to TC2030 with netlist pin remap.
examples/Multimeter/Multimeter.net.ref Updates reference netlist to match TC2030 SWD footprint and pin remap.
examples/Keyboard/Keyboard.kicad_pro KiCad project settings updates (defaults/DRC/tuning/export sections).
examples/BleJoystick/BleJoystick.svgpcb.js Updates board export for new BLE joystick architecture and added peripherals/subconnectors.
examples/BleJoystick/BleJoystick.net.ref Updates reference netlist for revised joystick architecture and new components.
examples/BleJoystick/BleJoystick_stick.net.ref Updates stick sub-board connector footprint/pins and refdes changes.
examples/BleJoystick/BleJoystick_btns.net.ref Adds new reference netlist for the button sub-board.
edg/parts/power/BatteryCharger_Mcp73831.py Adds optional PROG-pin control (charge enable/disable) via generated FET; converts to GeneratorBlock.
edg/parts/microcontroller/nRF52840.py Fixes Holyiot footprint instantiation to correctly use external=True on the block wrapper.
edg/parts/microcontroller/Ch32v003.py New CH32V003 device + wrapper MCU block and SDI programming header abstractions.
edg/parts/microcontroller/init.py Exports new CH32V003-related blocks.
edg/parts/connector/SwdHeaders.py Removes the legacy TC2050-compatible SWD header implementation.
edg/parts/connector/init.py Stops exporting the removed SWD header class.
edg/electronics_interfaces/DigitalPorts.py Adds DigitalBidir.as_voltage_source() helper.
edg/circuits/PowerConditioning.py Improves SoftPowerGate button input documentation string.
edg/abstract_parts/IoControllerWrapper.py Marks wrapper/modelable base classes as non-library and guards generator_param usage.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread edg/parts/microcontroller/Ch32v003.py Outdated
Comment on lines +12 to +13
class Ch32vSdiHeader(ProgrammingConnector):
"""Abstract programming header for the CH32V using the one-pin SDI interface with SWIO pin.."""
Comment on lines +69 to 76
self.prog_ctl = self.Port(
DigitalBidir(),
optional=True,
doc="GPIO that controls a FET that enables charging, pull high to enable",
)

self.generator_param(self.prog_ctl.is_connected())

Comment on lines 199 to +204
(
["mcu", "pin_assigns"],
[
"led=_GPIO9_STRAP", # force using the strapping / boot mode pin
# note, only ADC pins are IO0/1/3/4/5 (pins 18/17/15/3/4)
"ax1=3",
"ax2=15",
"trig=17",
"vbat_sense=18",
# 'vbat_sense_gate=14',
# 'gate_ctl=5',
"i2c.scl=4",
"i2c.sda=14",
"sw=5", # joystick
"sw0=10", # membranes
"sw1=13",
"sw2=6",
# TODO pin this
],
),
Comment on lines +205 to 211
(
["btns", "ioe", "pin_assigns"],
[
"i2c.scl=12",
"i2c.sda=11",
# TODO pin the rest
],
@ducky64 ducky64 merged commit 9ab1083 into master Jun 6, 2026
12 checks passed
@ducky64 ducky64 deleted the ch32v branch June 6, 2026 06:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants