Closed hyx0329 closed 1 year ago
could you enable it in application instead ?
could you enable it in application instead ?
I did some experiments on ZMK and CircuitPython with no success. I think enabling battery power in most common applications is just too late.
I looked into the code written by Makerdiary members. They enable the battery in bootloader and preserve the pin state in application.
BTW currently both ZMK and CPY have some flaws supporting M60. Official CPY builds will also reset the battery pin after started. ZMK on M60 relies on the factory (or my patched) bootloader to work on battery.
I see, can you make an PR to add board_init2() and board_teardown2() as weak function, and implemen it in your board. Those 2 function will be invoked right after the normal function with
if (board_init2) board_init2();
if (board_teardown2) board_teardown2();
What happened
Current board config for Makerdiary M60 Keyboard has some flaws and I'm fixing them. The on-board power circuit requires an enable signal. By writing customized
board_init_extra()
, I enabled the pin, but it's reset byboard_teardown()
, and thus the keyboard powered off. I want to keep the power on.I believe the board
challenger_840_ble
suffers the same issue. I took it as an example forboard_init_extra()
.This can also be a feature request that asks for a method to retain the state of some specific pins. I know I can easily change the code to meet my need, but I want to discuss a little bit.
As for the fix for M60, I think I'll open a pr after resolving this issue.
How to reproduce
board_init_extra()
related code:
https://github.com/adafruit/Adafruit_nRF52_Bootloader/blob/80c3a8401bde50cd4795f4510a86149e118ed259/src/main.c#L178-L201
https://github.com/adafruit/Adafruit_nRF52_Bootloader/blob/80c3a8401bde50cd4795f4510a86149e118ed259/src/boards/boards.c#L156-L161
https://github.com/adafruit/Adafruit_nRF52_Bootloader/blob/80c3a8401bde50cd4795f4510a86149e118ed259/src/boards/challenger_840_ble/pinconfig.c#L22-L27