Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 117 additions & 0 deletions 0001-esb-nrf-fix.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
From 46e84d0dfcb21acde11d531eb40f91ee551942c6 Mon Sep 17 00:00:00 2001
From: william <43848894@qq.com>
Date: Mon, 13 Jan 2025 12:16:43 +0800
Subject: [PATCH] esb nrf fix

---
drivers/usb/device/usb_dc_nrfx.c | 4 ++-
.../controller/ll_sw/nordic/lll/lll.c | 29 ++++++++++++++++++-
subsys/bluetooth/services/bas.c | 14 +++++++++
3 files changed, 45 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/device/usb_dc_nrfx.c b/drivers/usb/device/usb_dc_nrfx.c
index c0b661007..c2014c3ba 100644
--- a/drivers/usb/device/usb_dc_nrfx.c
+++ b/drivers/usb/device/usb_dc_nrfx.c
@@ -1075,7 +1075,9 @@ static void usbd_event_handler(nrfx_usbd_evt_t const *const p_event)
case NRFX_USBD_EVT_SOF:
if (IS_ENABLED(CONFIG_USB_DEVICE_SOF)) {
evt.evt_type = USBD_EVT_SOF;
- put_evt = true;
+ // put_evt = true;
+ extern uint32_t usb_sof_count;
+ usb_sof_count ++;
}
break;

diff --git a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll.c b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll.c
index e3ce60282..5bfe7d38d 100644
--- a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll.c
+++ b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll.c
@@ -84,7 +84,11 @@ static void ticker_op_job_disable(uint32_t status, void *op_context);
#endif
#endif /* CONFIG_BT_CTLR_LOW_LAT */

+#if defined(CONFIG_DYNAMIC_DIRECT_INTERRUPTS)
+static void radio_nrf5_isr(const void *arg)
+#else /* !CONFIG_DYNAMIC_DIRECT_INTERRUPTS */
ISR_DIRECT_DECLARE(radio_nrf5_isr)
+#endif /* !CONFIG_DYNAMIC_DIRECT_INTERRUPTS */
{
DEBUG_RADIO_ISR(1);

@@ -97,7 +101,9 @@ ISR_DIRECT_DECLARE(radio_nrf5_isr)
lll_prof_exit_radio();

DEBUG_RADIO_ISR(0);
+#if !defined(CONFIG_DYNAMIC_DIRECT_INTERRUPTS)
return 1;
+#endif /* !CONFIG_DYNAMIC_DIRECT_INTERRUPTS */
}

static void rtc0_nrf5_isr(const void *arg)
@@ -183,7 +189,27 @@ int lll_init(void)

/* Initialize SW IRQ structure */
hal_swi_init();
+#if defined(CONFIG_DYNAMIC_INTERRUPTS)
+#if defined(CONFIG_DYNAMIC_DIRECT_INTERRUPTS)
+ ARM_IRQ_DIRECT_DYNAMIC_CONNECT(RADIO_IRQn, CONFIG_BT_CTLR_LLL_PRIO,
+ IRQ_CONNECT_FLAGS, no_reschedule);
+ irq_connect_dynamic(RADIO_IRQn, CONFIG_BT_CTLR_LLL_PRIO,
+ radio_nrf5_isr, NULL, IRQ_CONNECT_FLAGS);
+#else /* !CONFIG_DYNAMIC_DIRECT_INTERRUPTS */
+ IRQ_DIRECT_CONNECT(RADIO_IRQn, CONFIG_BT_CTLR_LLL_PRIO,
+ radio_nrf5_isr, IRQ_CONNECT_FLAGS);
+#endif /* !CONFIG_DYNAMIC_DIRECT_INTERRUPTS */
+ irq_connect_dynamic(RTC0_IRQn, CONFIG_BT_CTLR_ULL_HIGH_PRIO,
+ rtc0_nrf5_isr, NULL, 0U);
+ irq_connect_dynamic(HAL_SWI_RADIO_IRQ, CONFIG_BT_CTLR_LLL_PRIO,
+ swi_lll_nrf5_isr, NULL, IRQ_CONNECT_FLAGS);
+#if defined(CONFIG_BT_CTLR_LOW_LAT) || \
+ (CONFIG_BT_CTLR_ULL_HIGH_PRIO != CONFIG_BT_CTLR_ULL_LOW_PRIO)
+ irq_connect_dynamic(HAL_SWI_JOB_IRQ, CONFIG_BT_CTLR_ULL_LOW_PRIO,
+ swi_ull_low_nrf5_isr, NULL, 0U);
+#endif

+#else /* !CONFIG_DYNAMIC_INTERRUPTS */
/* Connect ISRs */
IRQ_DIRECT_CONNECT(RADIO_IRQn, CONFIG_BT_CTLR_LLL_PRIO,
radio_nrf5_isr, IRQ_CONNECT_FLAGS);
@@ -196,7 +222,8 @@ int lll_init(void)
IRQ_CONNECT(HAL_SWI_JOB_IRQ, CONFIG_BT_CTLR_ULL_LOW_PRIO,
swi_ull_low_nrf5_isr, NULL, 0);
#endif
-
+#endif /* !CONFIG_DYNAMIC_INTERRUPTS */
+
/* Enable IRQs */
irq_enable(RADIO_IRQn);
irq_enable(RTC0_IRQn);
diff --git a/subsys/bluetooth/services/bas.c b/subsys/bluetooth/services/bas.c
index cf6482d53..ead09c15a 100644
--- a/subsys/bluetooth/services/bas.c
+++ b/subsys/bluetooth/services/bas.c
@@ -95,5 +95,19 @@ int bt_bas_set_battery_level(uint8_t level)

return rc == -ENOTCONN ? 0 : rc;
}
+//add by cwl @2023/11/23
+int bt_bas_set_battery_level_fix(struct bt_conn *conn,uint8_t level)
+{
+ int rc;
+ battery_level = level;
+ if (level > 100U || conn ==NULL) {
+ if(level > 100U) battery_level =100;
+ return -EINVAL;
+ }
+
+ rc = bt_gatt_notify(conn, &bas.attrs[1], &level, sizeof(level));
+
+ return rc == -ENOTCONN ? 0 : rc;
+}

SYS_INIT(bas_init, APPLICATION, CONFIG_APPLICATION_INIT_PRIORITY);
--
2.42.0.windows.2

24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,27 @@ Check out the website to learn more: https://zmk.dev/.
You can also come join our [ZMK Discord Server](https://zmk.dev/community/discord/invite).

To review features, check out the [feature overview](https://zmk.dev/docs/). ZMK is under active development, and new features are listed with the [enhancement label](https://github.com/zmkfirmware/zmk/issues?q=is%3Aissue+is%3Aopen+label%3Aenhancement) in GitHub. Please feel free to add 👍 to the issue description of any requests to upvote the feature.

[Keychron](https://keychron.com/) use zmk source code for Bpro series keyboards ,have made big changes fro Bpro, also add proprietary 2.4g communication.

To build the firmware ,for example: keychorn b1 pro

prepare:
```
mkdir keychron
cd keychron
git clone -b keychron_bpro https://github.com/keychron/zmk.git
cd zmk
west init -l app/
west update
```
patch zephyr:
```
cd zephyr
git am ../001-esb-nrf-fix.patch
```
build firmware:
```
cd app
west build -b keychron -p -- -DSHIELD=keychron_b1_us
```
12 changes: 12 additions & 0 deletions app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ target_sources_ifdef(CONFIG_ZMK_BACKLIGHT app PRIVATE src/backlight.c)
target_sources_ifdef(CONFIG_ZMK_LOW_PRIORITY_WORK_QUEUE app PRIVATE src/workqueue.c)
target_sources(app PRIVATE src/main.c)

target_sources(app PRIVATE src/leds.c)
zephyr_library_include_directories(${ZEPHYR_BASE}/subsys/bluetooth/host)

add_subdirectory(src/display/)
add_subdirectory_ifdef(CONFIG_SETTINGS src/settings/)

Expand All @@ -133,4 +136,13 @@ if (CONFIG_ZMK_STUDIO_RPC)
add_subdirectory(src/studio)
endif()


add_subdirectory_ifdef(CONFIG_ZMK_NRF_24G_ECB src/24G)
zephyr_library_include_directories(src/24G)


add_subdirectory_ifdef(CONFIG_ZMK_LAUNCHER src/launcher)
add_subdirectory(src/dfu/)


zephyr_cc_option(-Wfatal-errors)
71 changes: 67 additions & 4 deletions app/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,12 @@ config ZMK_BLE_EXPERIMENTAL_CONN
Enables settings that are planned to be default in future versions of ZMK
to improve connection stability.

<<<<<<< HEAD
#choice BT_LL_SW_LLCP_IMPL
# default BT_LL_SW_LLCP_LEGACY

#endchoice
=======
config ZMK_BLE_EXPERIMENTAL_SEC
bool "Experimental BLE security changes"
imply BT_SMP_ALLOW_UNAUTH_OVERWRITE
Expand All @@ -189,6 +195,7 @@ config ZMK_BLE_EXPERIMENTAL_FEATURES
select ZMK_BLE_EXPERIMENTAL_SEC
help
Enables experimental connection changes and security features.
>>>>>>> ead91ca094c6cd778574f73b9ae011ddab611c66

config ZMK_BLE_PASSKEY_ENTRY
bool "Require passkey entry on the keyboard to complete pairing"
Expand All @@ -210,7 +217,7 @@ config ZMK_BLE_THREAD_PRIORITY

config ZMK_BLE_KEYBOARD_REPORT_QUEUE_SIZE
int "Max number of keyboard HID reports to queue for sending over BLE"
default 20
default 64

config ZMK_BLE_CONSUMER_REPORT_QUEUE_SIZE
int "Max number of consumer HID reports to queue for sending over BLE"
Expand Down Expand Up @@ -470,7 +477,7 @@ menu "Behavior Options"

config ZMK_BEHAVIORS_QUEUE_SIZE
int "Maximum number of behaviors to allow queueing from a macro or other complex behavior"
default 64
default 512

rsource "Kconfig.behaviors"

Expand Down Expand Up @@ -553,7 +560,7 @@ config ZMK_LOGGING_MINIMAL
if !ZMK_LOGGING_MINIMAL

config ZMK_LOG_LEVEL
default 4
default 1 #4

endif

Expand Down Expand Up @@ -599,14 +606,24 @@ config ZMK_RTT_LOGGING
select CONSOLE
select RTT_CONSOLE

config ZMK_UART_LOGGING
bool "Enable UART logging to help debug"
select LOG
select DEBUG
select ASSERT
select SERIAL
select SERIAL_HAS_DRIVER
select CONSOLE
select UART_CONSOLE

if ZMK_RTT_LOGGING

config SEGGER_RTT_BUFFER_SIZE_UP
default 8192

endif # ZMK_RTT_LOGGING

if ZMK_USB_LOGGING || ZMK_RTT_LOGGING
if ZMK_USB_LOGGING || ZMK_RTT_LOGGING || ZMK_UART_LOGGING

config LOG_BUFFER_SIZE
default 8192
Expand Down Expand Up @@ -643,11 +660,15 @@ endif # SETTINGS
config ZMK_BATTERY_REPORT_INTERVAL
depends on ZMK_BATTERY_REPORTING
int "Battery level report interval in seconds"
<<<<<<< HEAD
default 30
=======

config ZMK_LOW_PRIORITY_WORK_QUEUE
bool "Work queue for low priority items"

if ZMK_LOW_PRIORITY_WORK_QUEUE
>>>>>>> ead91ca094c6cd778574f73b9ae011ddab611c66

config ZMK_LOW_PRIORITY_THREAD_STACK_SIZE
int "Low priority thread stack size"
Expand Down Expand Up @@ -704,6 +725,48 @@ config ZMK_KEYMAP_SENSORS_DEFAULT_TRIGGERS_PER_ROTATION

endif # ZMK_KEYMAP_SENSORS

<<<<<<< HEAD
choice CBPRINTF_IMPLEMENTATION
default CBPRINTF_NANO

endchoice

config ZMK_LED_INIT_PRIORITY
int "LED Init Priority"
default 40

config ZMK_NRF_24G_ECB
bool "enabel nordic 24g ecb"
select NRFX_TIMER2
default n

if ZMK_NRF_24G_ECB
config ESB_PTX_APP_LOG_LEVEL
int
default 4
config ESB_DYNAMIC_INTERRUPTS
bool "enable dynamic interrupt"
default y
config ESB_MAX_PAYLOAD_LENGTH
int "max payload length"
default 40
endif



if ZMK_NRF_24G_ECB
config ZMK_NRF_24G
bool
default y
endif

config ZMK_LAUNCHER
bool "enable via dynamic setting"
default y


=======
>>>>>>> ead91ca094c6cd778574f73b9ae011ddab611c66
module = ZMK
module-str = zmk
source "subsys/logging/Kconfig.template.log_config"
Expand Down
10 changes: 9 additions & 1 deletion app/VERSION
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
<<<<<<< HEAD
VERSION_MAJOR = 1
VERSION_MINOR = 2
PATCHLEVEL = 3
VERSION_TWEAK = 0
EXTRAVERSION = ZMK
=======
# x-release-please-start-major
VERSION_MAJOR = 0
# x-release-please-end
Expand All @@ -10,4 +17,5 @@ VERSION_MINOR = 3
PATCHLEVEL = 0
# x-release-please-end

VERSION_TWEAK = 0
VERSION_TWEAK = 0
>>>>>>> ead91ca094c6cd778574f73b9ae011ddab611c66
8 changes: 8 additions & 0 deletions app/boards/arm/keychron/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copyright (c) 2023 The ZMK Contributors
# SPDX-License-Identifier: MIT

config BOARD_ENABLE_DCDC
bool "Enable DCDC mode"
select SOC_DCDC_NRF52X
default y
depends on BOARD_KEYCHRON
6 changes: 6 additions & 0 deletions app/boards/arm/keychron/Kconfig.board
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Copyright (c) 2023 The ZMK Contributors
# SPDX-License-Identifier: MIT

config BOARD_KEYCHRON
bool "keychron"
depends on SOC_NRF52840_QIAA
36 changes: 36 additions & 0 deletions app/boards/arm/keychron/Kconfig.defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Copyright (c) 2023 The ZMK Contributors
# SPDX-License-Identifier: MIT

if BOARD_KEYCHRON

config ZMK_KEYBOARD_NAME
default "Keychron B6 Pro"

if USB_DEVICE_STACK

config USB_NRFX
default y

endif # USB_DEVICE_STACK

config BT_CTLR
default BT

config ZMK_BLE
default y

config ZMK_USB
default y

config ZMK_LEDS_GPIO
bool "enable gpio leds"
default y
select LED

config ZMK_LEDS_PWM
bool "enable pwm leds"
default n
select PWM
select LED_PWM

endif # BOARD_KEYCHRON
Loading