From 7c5fb7adb5a505ab5f89754370567b2357aa322a Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Tue, 7 Jul 2020 10:20:23 -0400 Subject: Use SYS_INIT for BLE and USB init. --- app/src/ble.c | 9 ++++++++- app/src/endpoints.c | 28 ---------------------------- app/src/hog.c | 5 ----- app/src/main.c | 5 ----- app/src/usb_hid.c | 7 ++++++- 5 files changed, 14 insertions(+), 40 deletions(-) (limited to 'app/src') diff --git a/app/src/ble.c b/app/src/ble.c index 0e6c5f2..c0e81a9 100644 --- a/app/src/ble.c +++ b/app/src/ble.c @@ -1,4 +1,7 @@ +#include +#include + #include #include @@ -139,7 +142,7 @@ static void zmk_ble_ready(int err) } } -int zmk_ble_init() +static int zmk_ble_init(struct device *_arg) { if (IS_ENABLED(CONFIG_SETTINGS)) { @@ -191,3 +194,7 @@ bool zmk_ble_handle_key_user(struct zmk_key_event *key_event) return false; } + +SYS_INIT(zmk_ble_init, + APPLICATION, + CONFIG_ZMK_BLE_INIT_PRIORITY); diff --git a/app/src/endpoints.c b/app/src/endpoints.c index 7823e95..48dc2ec 100644 --- a/app/src/endpoints.c +++ b/app/src/endpoints.c @@ -8,34 +8,6 @@ #include LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); -int zmk_endpoints_init() -{ - int err; - - LOG_DBG(""); - -#ifdef CONFIG_ZMK_USB - err = zmk_usb_hid_init(); - if (err) - { - LOG_ERR("USB HID Init Failed\n"); - return err; - } -#endif /* CONFIG_ZMK_USB */ - -#ifdef CONFIG_ZMK_BLE - err = zmk_hog_init(); - if (err) - { - LOG_ERR("HOG Init Failed\n"); - return err; - } - -#endif /* CONFIG_ZMK_BLE */ - - return 0; -} - int zmk_endpoints_send_report(u8_t usage_page) { int err; diff --git a/app/src/hog.c b/app/src/hog.c index 087af42..589c28f 100644 --- a/app/src/hog.c +++ b/app/src/hog.c @@ -7,11 +7,6 @@ #include #include -int zmk_hog_init() -{ - return zmk_ble_init(); -} - enum { HIDS_REMOTE_WAKE = BIT(0), diff --git a/app/src/main.c b/app/src/main.c index 1ced310..92ecc8b 100644 --- a/app/src/main.c +++ b/app/src/main.c @@ -27,11 +27,6 @@ void main(void) return; } - if (zmk_endpoints_init()) - { - printk("ENDPOINT INIT FAILED\n"); - return; - } #ifdef CONFIG_SETTINGS settings_load(); diff --git a/app/src/usb_hid.c b/app/src/usb_hid.c index 2862d56..4c6dd4b 100644 --- a/app/src/usb_hid.c +++ b/app/src/usb_hid.c @@ -1,5 +1,6 @@ #include +#include #include #include @@ -29,7 +30,7 @@ void usb_hid_status_cb(enum usb_dc_status_code status, const u8_t *params) usb_status = status; }; -int zmk_usb_hid_init() +static int zmk_usb_hid_init(struct device *_arg) { int usb_enable_ret; @@ -56,3 +57,7 @@ int zmk_usb_hid_init() return 0; } + +SYS_INIT(zmk_usb_hid_init, + APPLICATION, + CONFIG_ZMK_USB_INIT_PRIORITY); -- cgit v1.2.3