From a65b746a863bbd8e07cf404b4249526f75b069a3 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Wed, 19 Aug 2020 23:34:34 -0400 Subject: fix(bluetooth): Add unpair combo if DT node exists --- app/src/ble_unpair_combo.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'app/src') diff --git a/app/src/ble_unpair_combo.c b/app/src/ble_unpair_combo.c index a33a8e2..f9d0551 100644 --- a/app/src/ble_unpair_combo.c +++ b/app/src/ble_unpair_combo.c @@ -7,10 +7,11 @@ #include #include -#include - #define DT_DRV_COMPAT zmk_bt_unpair_combo +#if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) + +#include LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); #include @@ -78,3 +79,5 @@ ZMK_SUBSCRIPTION(zmk_ble_unpair_combo, position_state_changed); SYS_INIT(zmk_ble_unpair_combo_init, APPLICATION, CONFIG_APPLICATION_INIT_PRIORITY); + +#endif DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) -- cgit v1.2.3 From 6ca8e673ac494b836ef692f11e90e8b8b6f28528 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Thu, 20 Aug 2020 00:01:59 -0400 Subject: fix(bluetooth): Typo for closed conditional. --- app/src/ble_unpair_combo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/src') diff --git a/app/src/ble_unpair_combo.c b/app/src/ble_unpair_combo.c index f9d0551..82fa834 100644 --- a/app/src/ble_unpair_combo.c +++ b/app/src/ble_unpair_combo.c @@ -80,4 +80,4 @@ SYS_INIT(zmk_ble_unpair_combo_init, APPLICATION, CONFIG_APPLICATION_INIT_PRIORITY); -#endif DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) +#endif /* DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) */ -- cgit v1.2.3 From 805ea770053269278fe0ed443b68f600021d82d1 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Fri, 21 Aug 2020 00:33:48 -0400 Subject: feat(behaviors): Add `&bootloader` behavior. * Allow reset behavior to have a type property. * Add `bootloader` node that triggers DFU UF2 bootloader mode using the AdaFruit nrf52 bootloader. --- app/src/behaviors/behavior_reset.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'app/src') diff --git a/app/src/behaviors/behavior_reset.c b/app/src/behaviors/behavior_reset.c index 44cbc21..30a96ea 100644 --- a/app/src/behaviors/behavior_reset.c +++ b/app/src/behaviors/behavior_reset.c @@ -13,8 +13,9 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); -struct behavior_reset_config { }; -struct behavior_reset_data { }; +struct behavior_reset_config { + int type; +}; static int behavior_reset_init(struct device *dev) { @@ -23,9 +24,11 @@ static int behavior_reset_init(struct device *dev) static int on_keymap_binding_pressed(struct device *dev, u32_t position, u32_t _param1, u32_t _param2) { + const struct behavior_reset_config *cfg = dev->config_info; + // TODO: Correct magic code for going into DFU? // See https://github.com/adafruit/Adafruit_nRF52_Bootloader/blob/d6b28e66053eea467166f44875e3c7ec741cb471/src/main.c#L107 - sys_reboot(0); + sys_reboot(cfg->type); return 0; } @@ -34,12 +37,14 @@ static const struct behavior_driver_api behavior_reset_driver_api = { }; -static const struct behavior_reset_config behavior_reset_config = {}; - -static struct behavior_reset_data behavior_reset_data; - -DEVICE_AND_API_INIT(behavior_reset, DT_INST_LABEL(0), behavior_reset_init, - &behavior_reset_data, - &behavior_reset_config, - APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, - &behavior_reset_driver_api); \ No newline at end of file +#define RST_INST(n) \ + static const struct behavior_reset_config behavior_reset_config_##n = { \ + .type = DT_INST_PROP(n, type) \ + }; \ + DEVICE_AND_API_INIT(behavior_reset_##n, DT_INST_LABEL(n), behavior_reset_init, \ + NULL, \ + &behavior_reset_config_##n, \ + APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, \ + &behavior_reset_driver_api); + +DT_INST_FOREACH_STATUS_OKAY(RST_INST) \ No newline at end of file -- cgit v1.2.3