diff options
Diffstat (limited to 'app/src')
25 files changed, 49 insertions, 47 deletions
diff --git a/app/src/battery.c b/app/src/battery.c index e78b2fb..777dbdb 100644 --- a/app/src/battery.c +++ b/app/src/battery.c @@ -17,9 +17,9 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); #include <zmk/event-manager.h> #include <zmk/events/battery-state-changed.h> -struct device *battery; +const struct device *battery; -static int zmk_battery_update(struct device *battery) { +static int zmk_battery_update(const struct device *battery) { struct sensor_value state_of_charge; int rc = sensor_sample_fetch_chan(battery, SENSOR_CHAN_GAUGE_STATE_OF_CHARGE); @@ -64,7 +64,7 @@ static void zmk_battery_timer(struct k_timer *timer) { k_work_submit(&battery_wo K_TIMER_DEFINE(battery_timer, zmk_battery_timer, NULL); -static int zmk_battery_init(struct device *_arg) { +static int zmk_battery_init(const struct device *_arg) { battery = device_get_binding("BATTERY"); if (battery == NULL) { diff --git a/app/src/behaviors/behavior_bt.c b/app/src/behaviors/behavior_bt.c index 066c437..bfafc4b 100644 --- a/app/src/behaviors/behavior_bt.c +++ b/app/src/behaviors/behavior_bt.c @@ -35,7 +35,7 @@ static int on_keymap_binding_pressed(struct zmk_behavior_binding *binding, return -ENOTSUP; } -static int behavior_bt_init(struct device *dev) { return 0; }; +static int behavior_bt_init(const struct device *dev) { return 0; }; static int on_keymap_binding_released(struct zmk_behavior_binding *binding, struct zmk_behavior_binding_event event) { diff --git a/app/src/behaviors/behavior_ext_power.c b/app/src/behaviors/behavior_ext_power.c index 825f983..dbc6fd9 100644 --- a/app/src/behaviors/behavior_ext_power.c +++ b/app/src/behaviors/behavior_ext_power.c @@ -18,7 +18,7 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); static int on_keymap_binding_pressed(struct zmk_behavior_binding *binding, struct zmk_behavior_binding_event event) { - struct device *ext_power = device_get_binding("EXT_POWER"); + const struct device *ext_power = device_get_binding("EXT_POWER"); if (ext_power == NULL) { LOG_ERR("Unable to retrieve ext_power device: %d", binding->param1); return -EIO; @@ -46,7 +46,7 @@ static int on_keymap_binding_released(struct zmk_behavior_binding *binding, return 0; } -static int behavior_ext_power_init(struct device *dev) { return 0; }; +static int behavior_ext_power_init(const struct device *dev) { return 0; }; static const struct behavior_driver_api behavior_ext_power_driver_api = { .binding_pressed = on_keymap_binding_pressed, diff --git a/app/src/behaviors/behavior_hold_tap.c b/app/src/behaviors/behavior_hold_tap.c index 44a5117..556273e 100644 --- a/app/src/behaviors/behavior_hold_tap.c +++ b/app/src/behaviors/behavior_hold_tap.c @@ -304,7 +304,7 @@ static void decide_hold_tap(struct active_hold_tap *hold_tap, enum decision_mome static int on_hold_tap_binding_pressed(struct zmk_behavior_binding *binding, struct zmk_behavior_binding_event event) { - struct device *dev = device_get_binding(binding->behavior_dev); + const struct device *dev = device_get_binding(binding->behavior_dev); const struct behavior_hold_tap_config *cfg = dev->config; if (undecided_hold_tap != NULL) { @@ -479,7 +479,7 @@ void behavior_hold_tap_timer_work_handler(struct k_work *item) { } } -static int behavior_hold_tap_init(struct device *dev) { +static int behavior_hold_tap_init(const struct device *dev) { static bool init_first_run = true; if (init_first_run) { diff --git a/app/src/behaviors/behavior_key_press.c b/app/src/behaviors/behavior_key_press.c index 8559a51..aa19ca9 100644 --- a/app/src/behaviors/behavior_key_press.c +++ b/app/src/behaviors/behavior_key_press.c @@ -16,7 +16,7 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); -static int behavior_key_press_init(struct device *dev) { return 0; }; +static int behavior_key_press_init(const struct device *dev) { return 0; }; static int on_keymap_binding_pressed(struct zmk_behavior_binding *binding, struct zmk_behavior_binding_event event) { diff --git a/app/src/behaviors/behavior_momentary_layer.c b/app/src/behaviors/behavior_momentary_layer.c index b1fb14b..2b0206d 100644 --- a/app/src/behaviors/behavior_momentary_layer.c +++ b/app/src/behaviors/behavior_momentary_layer.c @@ -18,7 +18,7 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); struct behavior_mo_config {}; struct behavior_mo_data {}; -static int behavior_mo_init(struct device *dev) { return 0; }; +static int behavior_mo_init(const struct device *dev) { return 0; }; static int mo_keymap_binding_pressed(struct zmk_behavior_binding *binding, struct zmk_behavior_binding_event event) { diff --git a/app/src/behaviors/behavior_none.c b/app/src/behaviors/behavior_none.c index 96ea9d5..12542f0 100644 --- a/app/src/behaviors/behavior_none.c +++ b/app/src/behaviors/behavior_none.c @@ -18,7 +18,7 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); struct behavior_none_config {}; struct behavior_none_data {}; -static int behavior_none_init(struct device *dev) { return 0; }; +static int behavior_none_init(const struct device *dev) { return 0; }; static int on_keymap_binding_pressed(struct zmk_behavior_binding *binding, struct zmk_behavior_binding_event event) { diff --git a/app/src/behaviors/behavior_outputs.c b/app/src/behaviors/behavior_outputs.c index e5182bd..3a45b7f 100644 --- a/app/src/behaviors/behavior_outputs.c +++ b/app/src/behaviors/behavior_outputs.c @@ -34,7 +34,7 @@ static int on_keymap_binding_pressed(struct zmk_behavior_binding *binding, return -ENOTSUP; } -static int behavior_out_init(struct device *dev) { return 0; } +static int behavior_out_init(const struct device *dev) { return 0; } static const struct behavior_driver_api behavior_outputs_driver_api = { .binding_pressed = on_keymap_binding_pressed, diff --git a/app/src/behaviors/behavior_reset.c b/app/src/behaviors/behavior_reset.c index 97d0a1d..cb77a83 100644 --- a/app/src/behaviors/behavior_reset.c +++ b/app/src/behaviors/behavior_reset.c @@ -19,11 +19,11 @@ struct behavior_reset_config { int type; }; -static int behavior_reset_init(struct device *dev) { return 0; }; +static int behavior_reset_init(const struct device *dev) { return 0; }; static int on_keymap_binding_pressed(struct zmk_behavior_binding *binding, struct zmk_behavior_binding_event event) { - struct device *dev = device_get_binding(binding->behavior_dev); + const struct device *dev = device_get_binding(binding->behavior_dev); const struct behavior_reset_config *cfg = dev->config; // TODO: Correct magic code for going into DFU? diff --git a/app/src/behaviors/behavior_rgb_underglow.c b/app/src/behaviors/behavior_rgb_underglow.c index 80839a7..a0db9a9 100644 --- a/app/src/behaviors/behavior_rgb_underglow.c +++ b/app/src/behaviors/behavior_rgb_underglow.c @@ -16,7 +16,7 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); -static int behavior_rgb_underglow_init(struct device *dev) { return 0; } +static int behavior_rgb_underglow_init(const struct device *dev) { return 0; } static int on_keymap_binding_pressed(struct zmk_behavior_binding *binding, struct zmk_behavior_binding_event event) { diff --git a/app/src/behaviors/behavior_sensor_rotate_key_press.c b/app/src/behaviors/behavior_sensor_rotate_key_press.c index 85af24a..a0e0acc 100644 --- a/app/src/behaviors/behavior_sensor_rotate_key_press.c +++ b/app/src/behaviors/behavior_sensor_rotate_key_press.c @@ -16,10 +16,10 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); -static int behavior_sensor_rotate_key_press_init(struct device *dev) { return 0; }; +static int behavior_sensor_rotate_key_press_init(const struct device *dev) { return 0; }; -static int on_sensor_binding_triggered(struct zmk_behavior_binding *binding, struct device *sensor, - int64_t timestamp) { +static int on_sensor_binding_triggered(struct zmk_behavior_binding *binding, + const struct device *sensor, int64_t timestamp) { struct sensor_value value; int err; uint32_t keycode; diff --git a/app/src/behaviors/behavior_sticky_key.c b/app/src/behaviors/behavior_sticky_key.c index 51c78ff..920f6f2 100644 --- a/app/src/behaviors/behavior_sticky_key.c +++ b/app/src/behaviors/behavior_sticky_key.c @@ -127,7 +127,7 @@ static int stop_timer(struct active_sticky_key *sticky_key) { static int on_sticky_key_binding_pressed(struct zmk_behavior_binding *binding, struct zmk_behavior_binding_event event) { - struct device *dev = device_get_binding(binding->behavior_dev); + const struct device *dev = device_get_binding(binding->behavior_dev); const struct behavior_sticky_key_config *cfg = dev->config; struct active_sticky_key *sticky_key; sticky_key = find_sticky_key(event.position); @@ -242,7 +242,7 @@ void behavior_sticky_key_timer_handler(struct k_work *item) { } } -static int behavior_sticky_key_init(struct device *dev) { +static int behavior_sticky_key_init(const struct device *dev) { static bool init_first_run = true; if (init_first_run) { for (int i = 0; i < ZMK_BHV_STICKY_KEY_MAX_HELD; i++) { diff --git a/app/src/behaviors/behavior_toggle_layer.c b/app/src/behaviors/behavior_toggle_layer.c index b3c6961..3283377 100644 --- a/app/src/behaviors/behavior_toggle_layer.c +++ b/app/src/behaviors/behavior_toggle_layer.c @@ -18,7 +18,7 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); struct behavior_tog_config {}; struct behavior_tog_data {}; -static int behavior_tog_init(struct device *dev) { return 0; }; +static int behavior_tog_init(const struct device *dev) { return 0; }; static int tog_keymap_binding_pressed(struct zmk_behavior_binding *binding, struct zmk_behavior_binding_event event) { diff --git a/app/src/behaviors/behavior_transparent.c b/app/src/behaviors/behavior_transparent.c index cede369..17a5e43 100644 --- a/app/src/behaviors/behavior_transparent.c +++ b/app/src/behaviors/behavior_transparent.c @@ -18,7 +18,7 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); struct behavior_transparent_config {}; struct behavior_transparent_data {}; -static int behavior_transparent_init(struct device *dev) { return 0; }; +static int behavior_transparent_init(const struct device *dev) { return 0; }; static int on_keymap_binding_pressed(struct zmk_behavior_binding *binding, struct zmk_behavior_binding_event event) { diff --git a/app/src/ble.c b/app/src/ble.c index 5f5f94a..d335f94 100644 --- a/app/src/ble.c +++ b/app/src/ble.c @@ -509,7 +509,7 @@ static void zmk_ble_ready(int err) { update_advertising(); } -static int zmk_ble_init(struct device *_arg) { +static int zmk_ble_init(const struct device *_arg) { int err = bt_enable(NULL); if (err) { diff --git a/app/src/display/main.c b/app/src/display/main.c index d64fb2a..3683897 100644 --- a/app/src/display/main.c +++ b/app/src/display/main.c @@ -18,7 +18,7 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); #define ZMK_DISPLAY_NAME CONFIG_LVGL_DISPLAY_DEV_NAME -static struct device *display; +static const struct device *display; static lv_obj_t *screen; diff --git a/app/src/endpoints.c b/app/src/endpoints.c index 030b27a..f432ac2 100644 --- a/app/src/endpoints.c +++ b/app/src/endpoints.c @@ -156,7 +156,7 @@ static int endpoints_handle_set(const char *name, size_t len, settings_read_cb r struct settings_handler endpoints_handler = {.name = "endpoints", .h_set = endpoints_handle_set}; #endif /* IS_ENABLED(CONFIG_SETTINGS) */ -static int zmk_endpoints_init(struct device *_arg) { +static int zmk_endpoints_init(const struct device *_arg) { #if IS_ENABLED(CONFIG_SETTINGS) settings_subsys_init(); diff --git a/app/src/ext_power_generic.c b/app/src/ext_power_generic.c index ca44d20..71d1209 100644 --- a/app/src/ext_power_generic.c +++ b/app/src/ext_power_generic.c @@ -26,7 +26,7 @@ struct ext_power_generic_config { }; struct ext_power_generic_data { - struct device *gpio; + const struct device *gpio; bool status; #if IS_ENABLED(CONFIG_SETTINGS) bool settings_init; @@ -36,7 +36,7 @@ struct ext_power_generic_data { #if IS_ENABLED(CONFIG_SETTINGS) static void ext_power_save_state_work(struct k_work *work) { char setting_path[40]; - struct device *ext_power = device_get_binding(DT_INST_LABEL(0)); + const struct device *ext_power = device_get_binding(DT_INST_LABEL(0)); struct ext_power_generic_data *data = ext_power->data; snprintf(setting_path, 40, "ext_power/state/%s", DT_INST_LABEL(0)); @@ -55,7 +55,7 @@ int ext_power_save_state() { #endif } -static int ext_power_generic_enable(struct device *dev) { +static int ext_power_generic_enable(const struct device *dev) { struct ext_power_generic_data *data = dev->data; const struct ext_power_generic_config *config = dev->config; @@ -67,7 +67,7 @@ static int ext_power_generic_enable(struct device *dev) { return ext_power_save_state(); } -static int ext_power_generic_disable(struct device *dev) { +static int ext_power_generic_disable(const struct device *dev) { struct ext_power_generic_data *data = dev->data; const struct ext_power_generic_config *config = dev->config; @@ -79,7 +79,7 @@ static int ext_power_generic_disable(struct device *dev) { return ext_power_save_state(); } -static int ext_power_generic_get(struct device *dev) { +static int ext_power_generic_get(const struct device *dev) { struct ext_power_generic_data *data = dev->data; return data->status; } @@ -91,7 +91,7 @@ static int ext_power_settings_set(const char *name, size_t len, settings_read_cb int rc; if (settings_name_steq(name, DT_INST_LABEL(0), &next) && !next) { - struct device *ext_power = device_get_binding(DT_INST_LABEL(0)); + const struct device *ext_power = device_get_binding(DT_INST_LABEL(0)); struct ext_power_generic_data *data = ext_power->data; if (len != sizeof(data->status)) { @@ -124,7 +124,7 @@ struct settings_handler ext_power_conf = {.name = "ext_power/state", .h_set = ext_power_settings_set}; #endif -static int ext_power_generic_init(struct device *dev) { +static int ext_power_generic_init(const struct device *dev) { struct ext_power_generic_data *data = dev->data; const struct ext_power_generic_config *config = dev->config; diff --git a/app/src/keymap.c b/app/src/keymap.c index 0dc7c1a..cab6d47 100644 --- a/app/src/keymap.c +++ b/app/src/keymap.c @@ -121,7 +121,7 @@ bool is_active_layer(uint8_t layer, zmk_keymap_layers_state layer_state) { int zmk_keymap_apply_position_state(int layer, uint32_t position, bool pressed, int64_t timestamp) { struct zmk_behavior_binding *binding = &zmk_keymap[layer][position]; - struct device *behavior; + const struct device *behavior; struct zmk_behavior_binding_event event = { .layer = layer, .position = position, @@ -168,13 +168,14 @@ int zmk_keymap_position_state_changed(uint32_t position, bool pressed, int64_t t } #if ZMK_KEYMAP_HAS_SENSORS -int zmk_keymap_sensor_triggered(uint8_t sensor_number, struct device *sensor, int64_t timestamp) { +int zmk_keymap_sensor_triggered(uint8_t sensor_number, const struct device *sensor, + int64_t timestamp) { for (int layer = ZMK_KEYMAP_LAYERS_LEN - 1; layer >= _zmk_keymap_layer_default; layer--) { if (((_zmk_keymap_layer_state & BIT(layer)) == BIT(layer) || layer == _zmk_keymap_layer_default) && zmk_sensor_keymap[layer] != NULL) { struct zmk_behavior_binding *binding = &zmk_sensor_keymap[layer][sensor_number]; - struct device *behavior; + const struct device *behavior; int ret; LOG_DBG("layer: %d sensor_number: %d, binding name: %s", layer, sensor_number, diff --git a/app/src/kscan.c b/app/src/kscan.c index b6ffc37..c22d71b 100644 --- a/app/src/kscan.c +++ b/app/src/kscan.c @@ -30,7 +30,8 @@ struct zmk_kscan_msg_processor { K_MSGQ_DEFINE(zmk_kscan_msgq, sizeof(struct zmk_kscan_event), CONFIG_ZMK_KSCAN_EVENT_QUEUE_SIZE, 4); -static void zmk_kscan_callback(struct device *dev, uint32_t row, uint32_t column, bool pressed) { +static void zmk_kscan_callback(const struct device *dev, uint32_t row, uint32_t column, + bool pressed) { struct zmk_kscan_event ev = { .row = row, .column = column, @@ -58,7 +59,7 @@ void zmk_kscan_process_msgq(struct k_work *item) { } int zmk_kscan_init(char *name) { - struct device *dev = device_get_binding(name); + const struct device *dev = device_get_binding(name); if (dev == NULL) { LOG_ERR("Failed to get the KSCAN device"); return -EINVAL; diff --git a/app/src/rgb_underglow.c b/app/src/rgb_underglow.c index b2943e6..f5ed9ce 100644 --- a/app/src/rgb_underglow.c +++ b/app/src/rgb_underglow.c @@ -46,14 +46,14 @@ struct rgb_underglow_state { bool on; }; -static struct device *led_strip; +static const struct device *led_strip; static struct led_rgb pixels[STRIP_NUM_PIXELS]; static struct rgb_underglow_state state; #if IS_ENABLED(CONFIG_ZMK_RGB_UNDERGLOW_EXT_POWER) -static struct device *ext_power; +static const struct device *ext_power; #endif static struct led_rgb hsb_to_rgb(struct led_hsb hsb) { @@ -238,7 +238,7 @@ static void zmk_rgb_underglow_save_state_work() { static struct k_delayed_work underglow_save_work; #endif -static int zmk_rgb_underglow_init(struct device *_arg) { +static int zmk_rgb_underglow_init(const struct device *_arg) { led_strip = device_get_binding(STRIP_LABEL); if (led_strip) { LOG_INF("Found LED strip device %s", STRIP_LABEL); diff --git a/app/src/sensors.c b/app/src/sensors.c index 5bccc85..5b4f683 100644 --- a/app/src/sensors.c +++ b/app/src/sensors.c @@ -20,7 +20,7 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); struct sensors_data_item { uint8_t sensor_number; - struct device *dev; + const struct device *dev; struct sensor_trigger trigger; }; @@ -32,7 +32,7 @@ struct sensors_data_item { static struct sensors_data_item sensors[] = {UTIL_LISTIFY(ZMK_KEYMAP_SENSORS_LEN, SENSOR_ITEM, 0)}; -static void zmk_sensors_trigger_handler(struct device *dev, struct sensor_trigger *trigger) { +static void zmk_sensors_trigger_handler(const struct device *dev, struct sensor_trigger *trigger) { int err; struct sensors_data_item *item = CONTAINER_OF(trigger, struct sensors_data_item, trigger); struct sensor_event *event; @@ -72,7 +72,7 @@ static void zmk_sensors_init_item(const char *node, uint8_t i, uint8_t abs_i) { COND_CODE_1(DT_NODE_HAS_STATUS(ZMK_KEYMAP_SENSORS_BY_IDX(idx), okay), \ (_SENSOR_INIT(ZMK_KEYMAP_SENSORS_BY_IDX(idx))), (absolute_index++;)) -static int zmk_sensors_init(struct device *_arg) { +static int zmk_sensors_init(const struct device *_arg) { int local_index = 0; int absolute_index = 0; diff --git a/app/src/settings.c b/app/src/settings.c index 8914ccc..9366dd2 100644 --- a/app/src/settings.c +++ b/app/src/settings.c @@ -3,6 +3,6 @@ #include <kernel.h> #include <settings/settings.h> -static int zmk_settings_init(struct device *_arg) { return settings_load(); } +static int zmk_settings_init(const struct device *_arg) { return settings_load(); } SYS_INIT(zmk_settings_init, APPLICATION, CONFIG_APPLICATION_INIT_PRIORITY); diff --git a/app/src/split/bluetooth/central.c b/app/src/split/bluetooth/central.c index f3c860f..c41894f 100644 --- a/app/src/split/bluetooth/central.c +++ b/app/src/split/bluetooth/central.c @@ -315,7 +315,7 @@ static struct bt_conn_cb conn_callbacks = { .disconnected = split_central_disconnected, }; -int zmk_split_bt_central_init(struct device *_arg) { +int zmk_split_bt_central_init(const struct device *_arg) { bt_conn_cb_register(&conn_callbacks); return start_scan(); diff --git a/app/src/usb.c b/app/src/usb.c index d0253b5..009d7af 100644 --- a/app/src/usb.c +++ b/app/src/usb.c @@ -21,7 +21,7 @@ static enum usb_dc_status_code usb_status = USB_DC_UNKNOWN; #ifdef CONFIG_ZMK_USB -static struct device *hid_dev; +static const struct device *hid_dev; static K_SEM_DEFINE(hid_sem, 1, 1); @@ -83,7 +83,7 @@ void usb_status_cb(enum usb_dc_status_code status, const uint8_t *params) { raise_usb_status_changed_event(); }; -static int zmk_usb_init(struct device *_arg) { +static int zmk_usb_init(const struct device *_arg) { int usb_enable_ret; #ifdef CONFIG_ZMK_USB |