MustafaMulla29/wireless-mouse-pcb
A tscircuit package created by MustafaMulla29.
- Version
- 1.0.16
- License
- unset
- Stars
- 0
firmware/README.md
# PMW3610 BLE mouse firmware
This Zephyr application matches the GPIO assignments in the PMW3610
PCB. It implements:
- PMW3610 3-wire serial initialization and motion-burst reads
- 800/1200/1600/2400/3200 CPI selection from the DPI button
- left, right, middle, and optional side buttons
- quadrature scroll-wheel decoding
- Bluetooth LE HID mouse reports with bonding
- battery level reporting from the 1 MOhm / 1 MOhm divider on P0.02/AIN0
- dim WLED status: blue while starting/advertising, green while connected,
and red if initialization fails
The target is the nRF52810 variant of the Nordic DK because it has the same
SoC memory map and Zephyr support as the bare nRF52810-QFAA used on the PCB.
The board-specific overlay remaps every peripheral to the PCB pins.
Build with a Zephyr 4.x workspace and the Zephyr SDK:
```sh
west build -p always -b nrf52dk/nrf52810 firmware
```
Program `build/zephyr/zephyr.hex` through the board's SWDIO, SWCLK, 3V3, GND,
and RESET test points.
## Hardware mapping
| Function | nRF52810 pin |
| --- | --- |
| DPI | P0.00 |
| Battery ADC | P0.02 / AIN0 |
| Middle click | P0.03 |
| Encoder B | P0.05 |
| Encoder A | P0.07 |
| Right click | P0.08 |
| PMW3610 reset | P0.10 |
| PMW3610 SCLK | P0.12 |
| PMW3610 SDIO | P0.14 |
| PMW3610 NCS | P0.16 |
| PMW3610 MOTION | P0.17 |
| Left click | P0.18 |
| Hardware reset | P0.21 |
| WLED data | P0.25 |
| Optional side 1 | P0.27 |
| Optional side 2 | P0.29 |
The PMW3610 package is rotated 90 degrees on the PCB, so the default firmware
sets `SWAPXY` and `INV_Y` in `RES_STEP`. Cursor direction can be changed later
without changing the PCB by editing the three `CONFIG_PMW3610_*` options.
## Verification status
The source follows the PMW3610 R2.4 timing, power-up, required-register, burst,
and resolution sequences and Zephyr's official `peripheral_hids` service
pattern. It was compiled successfully with Zephyr 4.4.2 and Zephyr SDK 1.0.1
for `nrf52dk/nrf52810` after validating the devicetree, Kconfig, C sources,
flash layout, and final link:
- flash: 145,628 / 196,608 bytes (74.07%)
- RAM: 20,672 / 24,576 bytes (84.11%)
- output: `dist/firmware/pmw3610-ble-mouse.hex`
- SHA-256: `0e99a7345761db9819877059321a1a98d210cafad072b36cf2be642f8f6c2a7f`
The compile verifies the firmware image and pin configuration, not physical
optical direction. The 90-degree transform is the expected initial setting;
confirm cursor direction after assembly and adjust the three
`CONFIG_PMW3610_*` options if the enclosure/lens coordinate convention differs.