Browse Source

refactor(app): replace Zephyr integer types with C99 integer types

u8_t → uint8_t
u16_t → uint16_t
u32_t → uint32_t
u64_t → uint64_t
s8_t → int8_t
s16_t → int16_t
s32_t → int32_t
s64_t → int64_t

Prerequisite for #223
See: https://github.com/zephyrproject-rtos/zephyr/releases/tag/zephyr-v2.4.0
PR: #467
xmkb
innovaker 4 years ago committed by Pete Johanson
parent
commit
bac1f17cf6
  1. 6
      app/drivers/kscan/kscan_composite.c
  2. 4
      app/drivers/kscan/kscan_gpio_demux.c
  3. 12
      app/drivers/kscan/kscan_gpio_direct.c
  4. 4
      app/drivers/kscan/kscan_gpio_matrix.c
  5. 8
      app/drivers/kscan/kscan_mock.c
  6. 4
      app/drivers/sensor/ec11/ec11.c
  7. 18
      app/drivers/sensor/ec11/ec11.h
  8. 4
      app/drivers/sensor/ec11/ec11_trigger.c
  9. 6
      app/include/drivers/behavior.h
  10. 8
      app/include/zmk/behavior.h
  11. 2
      app/include/zmk/ble.h
  12. 2
      app/include/zmk/endpoints.h
  13. 2
      app/include/zmk/event-manager.h
  14. 2
      app/include/zmk/events/battery-state-changed.h
  15. 2
      app/include/zmk/events/ble-active-profile-changed.h
  16. 14
      app/include/zmk/events/keycode-state-changed.h
  17. 6
      app/include/zmk/events/layer-state-changed.h
  18. 4
      app/include/zmk/events/position-state-changed.h
  19. 4
      app/include/zmk/events/sensor-event.h
  20. 18
      app/include/zmk/hid.h
  21. 16
      app/include/zmk/keymap.h
  22. 12
      app/include/zmk/keys.h
  23. 2
      app/include/zmk/matrix_transform.h
  24. 4
      app/include/zmk/split/bluetooth/service.h
  25. 2
      app/include/zmk/usb.h
  26. 18
      app/src/behaviors/behavior_hold_tap.c
  27. 4
      app/src/behaviors/behavior_sensor_rotate_key_press.c
  28. 26
      app/src/behaviors/behavior_sticky_key.c
  29. 20
      app/src/ble.c
  30. 2
      app/src/display/widgets/battery_status.c
  31. 2
      app/src/display/widgets/output_status.c
  32. 6
      app/src/endpoints.c
  33. 8
      app/src/event_manager.c
  34. 4
      app/src/ext_power_generic.c
  35. 4
      app/src/hid_listener.c
  36. 34
      app/src/hog.c
  37. 28
      app/src/keymap.c
  38. 10
      app/src/kscan.c
  39. 6
      app/src/matrix_transform.c
  40. 6
      app/src/power.c
  41. 20
      app/src/rgb_underglow.c
  42. 4
      app/src/sensors.c
  43. 23
      app/src/split/bluetooth/central.c
  44. 16
      app/src/split/bluetooth/service.c
  45. 4
      app/src/usb.c

6
app/drivers/kscan/kscan_composite.c

@ -17,8 +17,8 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
struct kscan_composite_child_config { struct kscan_composite_child_config {
char *label; char *label;
u8_t row_offset; uint8_t row_offset;
u8_t column_offset; uint8_t column_offset;
}; };
#define CHILD_CONFIG(inst) \ #define CHILD_CONFIG(inst) \
@ -55,7 +55,7 @@ static int kscan_composite_disable_callback(struct device *dev) {
return 0; return 0;
} }
static void kscan_composite_child_callback(struct device *child_dev, u32_t row, u32_t column, static void kscan_composite_child_callback(struct device *child_dev, uint32_t row, uint32_t column,
bool pressed) { bool pressed) {
// TODO: Ideally we can get this passed into our callback! // TODO: Ideally we can get this passed into our callback!
struct device *dev = device_get_binding(DT_INST_LABEL(0)); struct device *dev = device_get_binding(DT_INST_LABEL(0));

4
app/drivers/kscan/kscan_gpio_demux.c

@ -105,8 +105,8 @@ struct kscan_gpio_item_config {
static bool read_state[INST_MATRIX_INPUTS(n)][INST_MATRIX_OUTPUTS(n)]; \ static bool read_state[INST_MATRIX_INPUTS(n)][INST_MATRIX_OUTPUTS(n)]; \
for (int o = 0; o < INST_MATRIX_OUTPUTS(n); o++) { \ for (int o = 0; o < INST_MATRIX_OUTPUTS(n); o++) { \
/* Iterate over bits and set GPIOs accordingly */ \ /* Iterate over bits and set GPIOs accordingly */ \
for (u8_t bit = 0; bit < INST_DEMUX_GPIOS(n); bit++) { \ for (uint8_t bit = 0; bit < INST_DEMUX_GPIOS(n); bit++) { \
u8_t state = (o & (0b1 << bit)) >> bit; \ uint8_t state = (o & (0b1 << bit)) >> bit; \
struct device *out_dev = kscan_gpio_output_devices_##n(dev)[bit]; \ struct device *out_dev = kscan_gpio_output_devices_##n(dev)[bit]; \
const struct kscan_gpio_item_config *out_cfg = \ const struct kscan_gpio_item_config *out_cfg = \
&kscan_gpio_output_configs_##n(dev)[bit]; \ &kscan_gpio_output_configs_##n(dev)[bit]; \

12
app/drivers/kscan/kscan_gpio_direct.c

@ -27,8 +27,8 @@ union work_reference {
}; };
struct kscan_gpio_config { struct kscan_gpio_config {
u8_t num_of_inputs; uint8_t num_of_inputs;
u8_t debounce_period; uint8_t debounce_period;
struct kscan_gpio_item_config inputs[]; struct kscan_gpio_item_config inputs[];
}; };
@ -39,7 +39,7 @@ struct kscan_gpio_data {
kscan_callback_t callback; kscan_callback_t callback;
union work_reference work; union work_reference work;
struct device *dev; struct device *dev;
u32_t pin_state; uint32_t pin_state;
struct device *inputs[]; struct device *inputs[];
}; };
@ -53,7 +53,7 @@ static const struct kscan_gpio_item_config *kscan_gpio_input_configs(struct devi
return cfg->inputs; return cfg->inputs;
} }
static void kscan_gpio_direct_queue_read(union work_reference *work, u8_t debounce_period) { static void kscan_gpio_direct_queue_read(union work_reference *work, uint8_t debounce_period) {
if (debounce_period > 0) { if (debounce_period > 0) {
k_delayed_work_cancel(&work->delayed); k_delayed_work_cancel(&work->delayed);
k_delayed_work_submit(&work->delayed, K_MSEC(debounce_period)); k_delayed_work_submit(&work->delayed, K_MSEC(debounce_period));
@ -67,7 +67,7 @@ static void kscan_gpio_direct_queue_read(union work_reference *work, u8_t deboun
struct kscan_gpio_irq_callback { struct kscan_gpio_irq_callback {
struct device *dev; struct device *dev;
union work_reference *work; union work_reference *work;
u8_t debounce_period; uint8_t debounce_period;
struct gpio_callback callback; struct gpio_callback callback;
}; };
@ -140,7 +140,7 @@ static int kscan_gpio_direct_configure(struct device *dev, kscan_callback_t call
static int kscan_gpio_read(struct device *dev) { static int kscan_gpio_read(struct device *dev) {
struct kscan_gpio_data *data = dev->driver_data; struct kscan_gpio_data *data = dev->driver_data;
const struct kscan_gpio_config *cfg = dev->config_info; const struct kscan_gpio_config *cfg = dev->config_info;
u32_t read_state = data->pin_state; uint32_t read_state = data->pin_state;
bool submit_follow_up_read = false; bool submit_follow_up_read = false;
for (int i = 0; i < cfg->num_of_inputs; i++) { for (int i = 0; i < cfg->num_of_inputs; i++) {
struct device *in_dev = kscan_gpio_input_devices(dev)[i]; struct device *in_dev = kscan_gpio_input_devices(dev)[i];

4
app/drivers/kscan/kscan_gpio_matrix.c

@ -123,8 +123,8 @@ static int kscan_gpio_config_interrupts(struct device **devices,
} \ } \
} \ } \
static void kscan_gpio_set_matrix_state_##n( \ static void kscan_gpio_set_matrix_state_##n( \
bool state[INST_MATRIX_ROWS(n)][INST_MATRIX_COLS(n)], u32_t input_index, \ bool state[INST_MATRIX_ROWS(n)][INST_MATRIX_COLS(n)], uint32_t input_index, \
u32_t output_index, bool value) { \ uint32_t output_index, bool value) { \
state[COND_CODE_0(DT_ENUM_IDX(DT_DRV_INST(n), diode_direction), (output_index), \ state[COND_CODE_0(DT_ENUM_IDX(DT_DRV_INST(n), diode_direction), (output_index), \
(input_index))] \ (input_index))] \
[COND_CODE_0(DT_ENUM_IDX(DT_DRV_INST(n), diode_direction), (input_index), \ [COND_CODE_0(DT_ENUM_IDX(DT_DRV_INST(n), diode_direction), (input_index), \

8
app/drivers/kscan/kscan_mock.c

@ -18,7 +18,7 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
struct kscan_mock_data { struct kscan_mock_data {
kscan_callback_t callback; kscan_callback_t callback;
u32_t event_index; uint32_t event_index;
struct k_delayed_work work; struct k_delayed_work work;
struct device *dev; struct device *dev;
}; };
@ -45,14 +45,14 @@ static int kscan_mock_configure(struct device *dev, kscan_callback_t callback) {
#define MOCK_INST_INIT(n) \ #define MOCK_INST_INIT(n) \
struct kscan_mock_config_##n { \ struct kscan_mock_config_##n { \
u32_t events[DT_INST_PROP_LEN(n, events)]; \ uint32_t events[DT_INST_PROP_LEN(n, events)]; \
bool exit_after; \ bool exit_after; \
}; \ }; \
static void kscan_mock_schedule_next_event_##n(struct device *dev) { \ static void kscan_mock_schedule_next_event_##n(struct device *dev) { \
struct kscan_mock_data *data = dev->driver_data; \ struct kscan_mock_data *data = dev->driver_data; \
const struct kscan_mock_config_##n *cfg = dev->config_info; \ const struct kscan_mock_config_##n *cfg = dev->config_info; \
if (data->event_index < DT_INST_PROP_LEN(n, events)) { \ if (data->event_index < DT_INST_PROP_LEN(n, events)) { \
u32_t ev = cfg->events[data->event_index]; \ uint32_t ev = cfg->events[data->event_index]; \
LOG_DBG("delaying next keypress: %d", ZMK_MOCK_MSEC(ev)); \ LOG_DBG("delaying next keypress: %d", ZMK_MOCK_MSEC(ev)); \
k_delayed_work_submit(&data->work, K_MSEC(ZMK_MOCK_MSEC(ev))); \ k_delayed_work_submit(&data->work, K_MSEC(ZMK_MOCK_MSEC(ev))); \
} else if (cfg->exit_after) { \ } else if (cfg->exit_after) { \
@ -63,7 +63,7 @@ static int kscan_mock_configure(struct device *dev, kscan_callback_t callback) {
static void kscan_mock_work_handler_##n(struct k_work *work) { \ static void kscan_mock_work_handler_##n(struct k_work *work) { \
struct kscan_mock_data *data = CONTAINER_OF(work, struct kscan_mock_data, work); \ struct kscan_mock_data *data = CONTAINER_OF(work, struct kscan_mock_data, work); \
const struct kscan_mock_config_##n *cfg = data->dev->config_info; \ const struct kscan_mock_config_##n *cfg = data->dev->config_info; \
u32_t ev = cfg->events[data->event_index]; \ uint32_t ev = cfg->events[data->event_index]; \
LOG_DBG("ev %u row %d column %d state %d\n", ev, ZMK_MOCK_ROW(ev), ZMK_MOCK_COL(ev), \ LOG_DBG("ev %u row %d column %d state %d\n", ev, ZMK_MOCK_ROW(ev), ZMK_MOCK_COL(ev), \
ZMK_MOCK_IS_PRESS(ev)); \ ZMK_MOCK_IS_PRESS(ev)); \
data->callback(data->dev, ZMK_MOCK_ROW(ev), ZMK_MOCK_COL(ev), ZMK_MOCK_IS_PRESS(ev)); \ data->callback(data->dev, ZMK_MOCK_ROW(ev), ZMK_MOCK_COL(ev), ZMK_MOCK_IS_PRESS(ev)); \

4
app/drivers/sensor/ec11/ec11.c

@ -29,8 +29,8 @@ static int ec11_get_ab_state(struct device *dev) {
static int ec11_sample_fetch(struct device *dev, enum sensor_channel chan) { static int ec11_sample_fetch(struct device *dev, enum sensor_channel chan) {
struct ec11_data *drv_data = dev->driver_data; struct ec11_data *drv_data = dev->driver_data;
const struct ec11_config *drv_cfg = dev->config_info; const struct ec11_config *drv_cfg = dev->config_info;
u8_t val; uint8_t val;
s8_t delta; int8_t delta;
__ASSERT_NO_MSG(chan == SENSOR_CHAN_ALL || chan == SENSOR_CHAN_ROTATION); __ASSERT_NO_MSG(chan == SENSOR_CHAN_ALL || chan == SENSOR_CHAN_ROTATION);

18
app/drivers/sensor/ec11/ec11.h

@ -12,23 +12,23 @@
struct ec11_config { struct ec11_config {
const char *a_label; const char *a_label;
const u8_t a_pin; const uint8_t a_pin;
const u8_t a_flags; const uint8_t a_flags;
const char *b_label; const char *b_label;
const u8_t b_pin; const uint8_t b_pin;
const u8_t b_flags; const uint8_t b_flags;
const u8_t resolution; const uint8_t resolution;
}; };
struct ec11_data { struct ec11_data {
struct device *a; struct device *a;
struct device *b; struct device *b;
u8_t ab_state; uint8_t ab_state;
s8_t pulses; int8_t pulses;
s8_t ticks; int8_t ticks;
s8_t delta; int8_t delta;
#ifdef CONFIG_EC11_TRIGGER #ifdef CONFIG_EC11_TRIGGER
struct gpio_callback a_gpio_cb; struct gpio_callback a_gpio_cb;

4
app/drivers/sensor/ec11/ec11_trigger.c

@ -36,7 +36,7 @@ static inline void setup_int(struct device *dev, bool enable) {
} }
} }
static void ec11_a_gpio_callback(struct device *dev, struct gpio_callback *cb, u32_t pins) { static void ec11_a_gpio_callback(struct device *dev, struct gpio_callback *cb, uint32_t pins) {
struct ec11_data *drv_data = CONTAINER_OF(cb, struct ec11_data, a_gpio_cb); struct ec11_data *drv_data = CONTAINER_OF(cb, struct ec11_data, a_gpio_cb);
LOG_DBG(""); LOG_DBG("");
@ -50,7 +50,7 @@ static void ec11_a_gpio_callback(struct device *dev, struct gpio_callback *cb, u
#endif #endif
} }
static void ec11_b_gpio_callback(struct device *dev, struct gpio_callback *cb, u32_t pins) { static void ec11_b_gpio_callback(struct device *dev, struct gpio_callback *cb, uint32_t pins) {
struct ec11_data *drv_data = CONTAINER_OF(cb, struct ec11_data, b_gpio_cb); struct ec11_data *drv_data = CONTAINER_OF(cb, struct ec11_data, b_gpio_cb);
LOG_DBG(""); LOG_DBG("");

6
app/include/drivers/behavior.h

@ -23,7 +23,7 @@
typedef int (*behavior_keymap_binding_callback_t)(struct zmk_behavior_binding *binding, typedef int (*behavior_keymap_binding_callback_t)(struct zmk_behavior_binding *binding,
struct zmk_behavior_binding_event event); struct zmk_behavior_binding_event event);
typedef int (*behavior_sensor_keymap_binding_callback_t)(struct zmk_behavior_binding *binding, typedef int (*behavior_sensor_keymap_binding_callback_t)(struct zmk_behavior_binding *binding,
struct device *sensor, s64_t timestamp); struct device *sensor, int64_t timestamp);
__subsystem struct behavior_driver_api { __subsystem struct behavior_driver_api {
behavior_keymap_binding_callback_t binding_pressed; behavior_keymap_binding_callback_t binding_pressed;
@ -92,11 +92,11 @@ static inline int z_impl_behavior_keymap_binding_released(struct zmk_behavior_bi
* @retval Negative errno code if failure. * @retval Negative errno code if failure.
*/ */
__syscall int behavior_sensor_keymap_binding_triggered(struct zmk_behavior_binding *binding, __syscall int behavior_sensor_keymap_binding_triggered(struct zmk_behavior_binding *binding,
struct device *sensor, s64_t timestamp); struct device *sensor, int64_t timestamp);
static inline int static inline int
z_impl_behavior_sensor_keymap_binding_triggered(struct zmk_behavior_binding *binding, z_impl_behavior_sensor_keymap_binding_triggered(struct zmk_behavior_binding *binding,
struct device *sensor, s64_t timestamp) { struct device *sensor, int64_t timestamp) {
struct device *dev = device_get_binding(binding->behavior_dev); struct device *dev = device_get_binding(binding->behavior_dev);
const struct behavior_driver_api *api = (const struct behavior_driver_api *)dev->driver_api; const struct behavior_driver_api *api = (const struct behavior_driver_api *)dev->driver_api;

8
app/include/zmk/behavior.h

@ -8,12 +8,12 @@
struct zmk_behavior_binding { struct zmk_behavior_binding {
char *behavior_dev; char *behavior_dev;
u32_t param1; uint32_t param1;
u32_t param2; uint32_t param2;
}; };
struct zmk_behavior_binding_event { struct zmk_behavior_binding_event {
int layer; int layer;
u32_t position; uint32_t position;
s64_t timestamp; int64_t timestamp;
}; };

2
app/include/zmk/ble.h

@ -12,7 +12,7 @@
int zmk_ble_clear_bonds(); int zmk_ble_clear_bonds();
int zmk_ble_prof_next(); int zmk_ble_prof_next();
int zmk_ble_prof_prev(); int zmk_ble_prof_prev();
int zmk_ble_prof_select(u8_t index); int zmk_ble_prof_select(uint8_t index);
int zmk_ble_active_profile_index(); int zmk_ble_active_profile_index();
bt_addr_le_t *zmk_ble_active_profile_addr(); bt_addr_le_t *zmk_ble_active_profile_addr();

2
app/include/zmk/endpoints.h

@ -18,4 +18,4 @@ int zmk_endpoints_select(enum zmk_endpoint endpoint);
int zmk_endpoints_toggle(); int zmk_endpoints_toggle();
enum zmk_endpoint zmk_endpoints_selected(); enum zmk_endpoint zmk_endpoints_selected();
int zmk_endpoints_send_report(u8_t usage_report); int zmk_endpoints_send_report(uint8_t usage_report);

2
app/include/zmk/event-manager.h

@ -16,7 +16,7 @@ struct zmk_event_type {
struct zmk_event_header { struct zmk_event_header {
const struct zmk_event_type *event; const struct zmk_event_type *event;
u8_t last_listener_index; uint8_t last_listener_index;
}; };
#define ZMK_EV_EVENT_HANDLED 1 #define ZMK_EV_EVENT_HANDLED 1

2
app/include/zmk/events/battery-state-changed.h

@ -12,7 +12,7 @@
struct battery_state_changed { struct battery_state_changed {
struct zmk_event_header header; struct zmk_event_header header;
// TODO: Other battery channels // TODO: Other battery channels
u8_t state_of_charge; uint8_t state_of_charge;
}; };
ZMK_EVENT_DECLARE(battery_state_changed); ZMK_EVENT_DECLARE(battery_state_changed);

2
app/include/zmk/events/ble-active-profile-changed.h

@ -14,7 +14,7 @@
struct ble_active_profile_changed { struct ble_active_profile_changed {
struct zmk_event_header header; struct zmk_event_header header;
u8_t index; uint8_t index;
struct zmk_ble_profile *profile; struct zmk_ble_profile *profile;
}; };

14
app/include/zmk/events/keycode-state-changed.h

@ -14,19 +14,19 @@
struct keycode_state_changed { struct keycode_state_changed {
struct zmk_event_header header; struct zmk_event_header header;
u8_t usage_page; uint8_t usage_page;
u32_t keycode; uint32_t keycode;
u8_t implicit_modifiers; uint8_t implicit_modifiers;
bool state; bool state;
s64_t timestamp; int64_t timestamp;
}; };
ZMK_EVENT_DECLARE(keycode_state_changed); ZMK_EVENT_DECLARE(keycode_state_changed);
static inline struct keycode_state_changed * static inline struct keycode_state_changed *
keycode_state_changed_from_encoded(u32_t encoded, bool pressed, s64_t timestamp) { keycode_state_changed_from_encoded(uint32_t encoded, bool pressed, int64_t timestamp) {
u16_t page = HID_USAGE_PAGE(encoded) & 0xFF; uint16_t page = HID_USAGE_PAGE(encoded) & 0xFF;
u16_t id = HID_USAGE_ID(encoded); uint16_t id = HID_USAGE_ID(encoded);
zmk_mod_flags implicit_mods = SELECT_MODS(encoded); zmk_mod_flags implicit_mods = SELECT_MODS(encoded);
if (!page) { if (!page) {

6
app/include/zmk/events/layer-state-changed.h

@ -11,14 +11,14 @@
struct layer_state_changed { struct layer_state_changed {
struct zmk_event_header header; struct zmk_event_header header;
u8_t layer; uint8_t layer;
bool state; bool state;
s64_t timestamp; int64_t timestamp;
}; };
ZMK_EVENT_DECLARE(layer_state_changed); ZMK_EVENT_DECLARE(layer_state_changed);
static inline struct layer_state_changed *create_layer_state_changed(u8_t layer, bool state) { static inline struct layer_state_changed *create_layer_state_changed(uint8_t layer, bool state) {
struct layer_state_changed *ev = new_layer_state_changed(); struct layer_state_changed *ev = new_layer_state_changed();
ev->layer = layer; ev->layer = layer;
ev->state = state; ev->state = state;

4
app/include/zmk/events/position-state-changed.h

@ -11,9 +11,9 @@
struct position_state_changed { struct position_state_changed {
struct zmk_event_header header; struct zmk_event_header header;
u32_t position; uint32_t position;
bool state; bool state;
s64_t timestamp; int64_t timestamp;
}; };
ZMK_EVENT_DECLARE(position_state_changed); ZMK_EVENT_DECLARE(position_state_changed);

4
app/include/zmk/events/sensor-event.h

@ -12,9 +12,9 @@
struct sensor_event { struct sensor_event {
struct zmk_event_header header; struct zmk_event_header header;
u8_t sensor_number; uint8_t sensor_number;
struct device *sensor; struct device *sensor;
s64_t timestamp; int64_t timestamp;
}; };
ZMK_EVENT_DECLARE(sensor_event); ZMK_EVENT_DECLARE(sensor_event);

18
app/include/zmk/hid.h

@ -19,7 +19,7 @@
#define ZMK_HID_CONSUMER_NKRO_SIZE 6 #define ZMK_HID_CONSUMER_NKRO_SIZE 6
static const u8_t zmk_hid_report_desc[] = { static const uint8_t zmk_hid_report_desc[] = {
/* USAGE_PAGE (Generic Desktop) */ /* USAGE_PAGE (Generic Desktop) */
HID_GI_USAGE_PAGE, HID_GI_USAGE_PAGE,
HID_USAGE_GD, HID_USAGE_GD,
@ -141,28 +141,28 @@ static const u8_t zmk_hid_report_desc[] = {
// struct zmk_hid_boot_report // struct zmk_hid_boot_report
// { // {
// u8_t modifiers; // uint8_t modifiers;
// u8_t _unused; // uint8_t _unused;
// u8_t keys[6]; // uint8_t keys[6];
// } __packed; // } __packed;
struct zmk_hid_keyboard_report_body { struct zmk_hid_keyboard_report_body {
zmk_mod_flags modifiers; zmk_mod_flags modifiers;
u8_t _reserved; uint8_t _reserved;
u8_t keys[ZMK_HID_KEYBOARD_NKRO_SIZE]; uint8_t keys[ZMK_HID_KEYBOARD_NKRO_SIZE];
} __packed; } __packed;
struct zmk_hid_keyboard_report { struct zmk_hid_keyboard_report {
u8_t report_id; uint8_t report_id;
struct zmk_hid_keyboard_report_body body; struct zmk_hid_keyboard_report_body body;
} __packed; } __packed;
struct zmk_hid_consumer_report_body { struct zmk_hid_consumer_report_body {
u16_t keys[ZMK_HID_CONSUMER_NKRO_SIZE]; uint16_t keys[ZMK_HID_CONSUMER_NKRO_SIZE];
} __packed; } __packed;
struct zmk_hid_consumer_report { struct zmk_hid_consumer_report {
u8_t report_id; uint8_t report_id;
struct zmk_hid_consumer_report_body body; struct zmk_hid_consumer_report_body body;
} __packed; } __packed;

16
app/include/zmk/keymap.h

@ -6,14 +6,14 @@
#pragma once #pragma once
typedef u32_t zmk_keymap_layers_state; typedef uint32_t zmk_keymap_layers_state;
u8_t zmk_keymap_layer_default(); uint8_t zmk_keymap_layer_default();
zmk_keymap_layers_state zmk_keymap_layer_state(); zmk_keymap_layers_state zmk_keymap_layer_state();
bool zmk_keymap_layer_active(u8_t layer); bool zmk_keymap_layer_active(uint8_t layer);
u8_t zmk_keymap_highest_layer_active(); uint8_t zmk_keymap_highest_layer_active();
int zmk_keymap_layer_activate(u8_t layer); int zmk_keymap_layer_activate(uint8_t layer);
int zmk_keymap_layer_deactivate(u8_t layer); int zmk_keymap_layer_deactivate(uint8_t layer);
int zmk_keymap_layer_toggle(u8_t layer); int zmk_keymap_layer_toggle(uint8_t layer);
int zmk_keymap_position_state_changed(u32_t position, bool pressed, s64_t timestamp); int zmk_keymap_position_state_changed(uint32_t position, bool pressed, int64_t timestamp);

12
app/include/zmk/keys.h

@ -9,14 +9,14 @@
#include <zephyr.h> #include <zephyr.h>
#include <dt-bindings/zmk/keys.h> #include <dt-bindings/zmk/keys.h>
typedef u32_t zmk_key; typedef uint32_t zmk_key;
typedef u8_t zmk_action; typedef uint8_t zmk_action;
typedef u8_t zmk_mod; typedef uint8_t zmk_mod;
typedef u8_t zmk_mod_flags; typedef uint8_t zmk_mod_flags;
struct zmk_key_event { struct zmk_key_event {
u32_t column; uint32_t column;
u32_t row; uint32_t row;
zmk_key key; zmk_key key;
bool pressed; bool pressed;
}; };

2
app/include/zmk/matrix_transform.h

@ -6,4 +6,4 @@
#pragma once #pragma once
u32_t zmk_matrix_transform_row_column_to_position(u32_t row, u32_t column); uint32_t zmk_matrix_transform_row_column_to_position(uint32_t row, uint32_t column);

4
app/include/zmk/split/bluetooth/service.h

@ -6,5 +6,5 @@
#pragma once #pragma once
int zmk_split_bt_position_pressed(u8_t position); int zmk_split_bt_position_pressed(uint8_t position);
int zmk_split_bt_position_released(u8_t position); int zmk_split_bt_position_released(uint8_t position);

2
app/include/zmk/usb.h

@ -25,5 +25,5 @@ static inline bool zmk_usb_is_powered() { return zmk_usb_get_conn_state() != ZMK
static inline bool zmk_usb_is_hid_ready() { return zmk_usb_get_conn_state() == ZMK_USB_CONN_HID; } static inline bool zmk_usb_is_hid_ready() { return zmk_usb_get_conn_state() == ZMK_USB_CONN_HID; }
#ifdef CONFIG_ZMK_USB #ifdef CONFIG_ZMK_USB
int zmk_usb_hid_send_report(const u8_t *report, size_t len); int zmk_usb_hid_send_report(const uint8_t *report, size_t len);
#endif /* CONFIG_ZMK_USB */ #endif /* CONFIG_ZMK_USB */

18
app/src/behaviors/behavior_hold_tap.c

@ -49,11 +49,11 @@ struct behavior_hold_tap_config {
// this data is specific for each hold-tap // this data is specific for each hold-tap
struct active_hold_tap { struct active_hold_tap {
s32_t position; int32_t position;
// todo: move these params into the config->behaviors->tap and // todo: move these params into the config->behaviors->tap and
u32_t param_hold; uint32_t param_hold;
u32_t param_tap; uint32_t param_tap;
s64_t timestamp; int64_t timestamp;
bool is_decided; bool is_decided;
bool is_hold; bool is_hold;
const struct behavior_hold_tap_config *config; const struct behavior_hold_tap_config *config;
@ -81,7 +81,7 @@ static int capture_event(const struct zmk_event_header *event) {
return -ENOMEM; return -ENOMEM;
} }
static struct position_state_changed *find_captured_keydown_event(u32_t position) { static struct position_state_changed *find_captured_keydown_event(uint32_t position) {
struct position_state_changed *last_match = NULL; struct position_state_changed *last_match = NULL;
for (int i = 0; i < ZMK_BHV_HOLD_TAP_MAX_CAPTURED_EVENTS; i++) { for (int i = 0; i < ZMK_BHV_HOLD_TAP_MAX_CAPTURED_EVENTS; i++) {
const struct zmk_event_header *eh = captured_events[i]; const struct zmk_event_header *eh = captured_events[i];
@ -155,7 +155,7 @@ static void release_captured_events() {
} }
} }
static struct active_hold_tap *find_hold_tap(u32_t position) { static struct active_hold_tap *find_hold_tap(uint32_t position) {
for (int i = 0; i < ZMK_BHV_HOLD_TAP_MAX_HELD; i++) { for (int i = 0; i < ZMK_BHV_HOLD_TAP_MAX_HELD; i++) {
if (active_hold_taps[i].position == position) { if (active_hold_taps[i].position == position) {
return &active_hold_taps[i]; return &active_hold_taps[i];
@ -164,8 +164,8 @@ static struct active_hold_tap *find_hold_tap(u32_t position) {
return NULL; return NULL;
} }
static struct active_hold_tap *store_hold_tap(u32_t position, u32_t param_hold, u32_t param_tap, static struct active_hold_tap *store_hold_tap(uint32_t position, uint32_t param_hold,
s64_t timestamp, uint32_t param_tap, int64_t timestamp,
const struct behavior_hold_tap_config *config) { const struct behavior_hold_tap_config *config) {
for (int i = 0; i < ZMK_BHV_HOLD_TAP_MAX_HELD; i++) { for (int i = 0; i < ZMK_BHV_HOLD_TAP_MAX_HELD; i++) {
if (active_hold_taps[i].position != ZMK_BHV_HOLD_TAP_POSITION_NOT_USED) { if (active_hold_taps[i].position != ZMK_BHV_HOLD_TAP_POSITION_NOT_USED) {
@ -326,7 +326,7 @@ static int on_hold_tap_binding_pressed(struct zmk_behavior_binding *binding,
// if this behavior was queued we have to adjust the timer to only // if this behavior was queued we have to adjust the timer to only
// wait for the remaining time. // wait for the remaining time.
s32_t tapping_term_ms_left = (hold_tap->timestamp + cfg->tapping_term_ms) - k_uptime_get(); int32_t tapping_term_ms_left = (hold_tap->timestamp + cfg->tapping_term_ms) - k_uptime_get();
if (tapping_term_ms_left > 0) { if (tapping_term_ms_left > 0) {
k_delayed_work_submit(&hold_tap->work, K_MSEC(tapping_term_ms_left)); k_delayed_work_submit(&hold_tap->work, K_MSEC(tapping_term_ms_left));
} }

4
app/src/behaviors/behavior_sensor_rotate_key_press.c

@ -19,10 +19,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(struct device *dev) { return 0; };
static int on_sensor_binding_triggered(struct zmk_behavior_binding *binding, struct device *sensor, static int on_sensor_binding_triggered(struct zmk_behavior_binding *binding, struct device *sensor,
s64_t timestamp) { int64_t timestamp) {
struct sensor_value value; struct sensor_value value;
int err; int err;
u32_t keycode; uint32_t keycode;
LOG_DBG("inc keycode 0x%02X dec keycode 0x%02X", binding->param1, binding->param2); LOG_DBG("inc keycode 0x%02X dec keycode 0x%02X", binding->param1, binding->param2);
err = sensor_channel_get(sensor, SENSOR_CHAN_ROTATION, &value); err = sensor_channel_get(sensor, SENSOR_CHAN_ROTATION, &value);

26
app/src/behaviors/behavior_sticky_key.c

@ -29,28 +29,29 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
#define ZMK_BHV_STICKY_KEY_POSITION_NOT_USED ULONG_MAX #define ZMK_BHV_STICKY_KEY_POSITION_NOT_USED ULONG_MAX
struct behavior_sticky_key_config { struct behavior_sticky_key_config {
u32_t release_after_ms; uint32_t release_after_ms;
struct zmk_behavior_binding behavior; struct zmk_behavior_binding behavior;
}; };
struct active_sticky_key { struct active_sticky_key {
u32_t position; uint32_t position;
u32_t param1; uint32_t param1;
u32_t param2; uint32_t param2;
const struct behavior_sticky_key_config *config; const struct behavior_sticky_key_config *config;
// timer data. // timer data.
bool timer_started; bool timer_started;
s64_t release_at; int64_t release_at;
struct k_delayed_work release_timer; struct k_delayed_work release_timer;
bool timer_is_cancelled; bool timer_is_cancelled;
// usage page and keycode for the key that is being modified by this sticky key // usage page and keycode for the key that is being modified by this sticky key
u8_t modified_key_usage_page; uint8_t modified_key_usage_page;
u32_t modified_key_keycode; uint32_t modified_key_keycode;
}; };
struct active_sticky_key active_sticky_keys[ZMK_BHV_STICKY_KEY_MAX_HELD] = {}; struct active_sticky_key active_sticky_keys[ZMK_BHV_STICKY_KEY_MAX_HELD] = {};
static struct active_sticky_key *store_sticky_key(u32_t position, u32_t param1, u32_t param2, static struct active_sticky_key *store_sticky_key(uint32_t position, uint32_t param1,
uint32_t param2,
const struct behavior_sticky_key_config *config) { const struct behavior_sticky_key_config *config) {
for (int i = 0; i < ZMK_BHV_STICKY_KEY_MAX_HELD; i++) { for (int i = 0; i < ZMK_BHV_STICKY_KEY_MAX_HELD; i++) {
if (active_sticky_keys[i].position != ZMK_BHV_STICKY_KEY_POSITION_NOT_USED || if (active_sticky_keys[i].position != ZMK_BHV_STICKY_KEY_POSITION_NOT_USED ||
@ -75,7 +76,7 @@ static void clear_sticky_key(struct active_sticky_key *sticky_key) {
sticky_key->position = ZMK_BHV_STICKY_KEY_POSITION_NOT_USED; sticky_key->position = ZMK_BHV_STICKY_KEY_POSITION_NOT_USED;
} }
static struct active_sticky_key *find_sticky_key(u32_t position) { static struct active_sticky_key *find_sticky_key(uint32_t position) {
for (int i = 0; i < ZMK_BHV_STICKY_KEY_MAX_HELD; i++) { for (int i = 0; i < ZMK_BHV_STICKY_KEY_MAX_HELD; i++) {
if (active_sticky_keys[i].position == position && if (active_sticky_keys[i].position == position &&
!active_sticky_keys[i].timer_is_cancelled) { !active_sticky_keys[i].timer_is_cancelled) {
@ -85,7 +86,8 @@ static struct active_sticky_key *find_sticky_key(u32_t position) {
return NULL; return NULL;
} }
static inline int press_sticky_key_behavior(struct active_sticky_key *sticky_key, s64_t timestamp) { static inline int press_sticky_key_behavior(struct active_sticky_key *sticky_key,
int64_t timestamp) {
struct zmk_behavior_binding binding = { struct zmk_behavior_binding binding = {
.behavior_dev = sticky_key->config->behavior.behavior_dev, .behavior_dev = sticky_key->config->behavior.behavior_dev,
.param1 = sticky_key->param1, .param1 = sticky_key->param1,
@ -99,7 +101,7 @@ static inline int press_sticky_key_behavior(struct active_sticky_key *sticky_key
} }
static inline int release_sticky_key_behavior(struct active_sticky_key *sticky_key, static inline int release_sticky_key_behavior(struct active_sticky_key *sticky_key,
s64_t timestamp) { int64_t timestamp) {
struct zmk_behavior_binding binding = { struct zmk_behavior_binding binding = {
.behavior_dev = sticky_key->config->behavior.behavior_dev, .behavior_dev = sticky_key->config->behavior.behavior_dev,
.param1 = sticky_key->param1, .param1 = sticky_key->param1,
@ -162,7 +164,7 @@ static int on_sticky_key_binding_released(struct zmk_behavior_binding *binding,
sticky_key->timer_started = true; sticky_key->timer_started = true;
sticky_key->release_at = event.timestamp + sticky_key->config->release_after_ms; sticky_key->release_at = event.timestamp + sticky_key->config->release_after_ms;
// adjust timer in case this behavior was queued by a hold-tap // adjust timer in case this behavior was queued by a hold-tap
s32_t ms_left = sticky_key->release_at - k_uptime_get(); int32_t ms_left = sticky_key->release_at - k_uptime_get();
if (ms_left > 0) { if (ms_left > 0) {
k_delayed_work_submit(&sticky_key->release_timer, K_MSEC(ms_left)); k_delayed_work_submit(&sticky_key->release_timer, K_MSEC(ms_left));
} }

20
app/src/ble.c

@ -36,8 +36,8 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
#include <zmk/events/ble-active-profile-changed.h> #include <zmk/events/ble-active-profile-changed.h>
static struct bt_conn *auth_passkey_entry_conn; static struct bt_conn *auth_passkey_entry_conn;
static u8_t passkey_entries[6] = {0, 0, 0, 0, 0, 0}; static uint8_t passkey_entries[6] = {0, 0, 0, 0, 0, 0};
static u8_t passkey_digit = 0; static uint8_t passkey_digit = 0;
#if IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL) #if IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL)
#define PROFILE_COUNT (CONFIG_BT_MAX_PAIRED - 1) #define PROFILE_COUNT (CONFIG_BT_MAX_PAIRED - 1)
@ -58,7 +58,7 @@ enum advertising_type {
BT_GAP_ADV_FAST_INT_MAX_2, NULL) BT_GAP_ADV_FAST_INT_MAX_2, NULL)
static struct zmk_ble_profile profiles[PROFILE_COUNT]; static struct zmk_ble_profile profiles[PROFILE_COUNT];
static u8_t active_profile; static uint8_t active_profile;
#define DEVICE_NAME CONFIG_BT_DEVICE_NAME #define DEVICE_NAME CONFIG_BT_DEVICE_NAME
#define DEVICE_NAME_LEN (sizeof(DEVICE_NAME) - 1) #define DEVICE_NAME_LEN (sizeof(DEVICE_NAME) - 1)
@ -104,7 +104,7 @@ bool zmk_ble_active_profile_is_open() {
return !bt_addr_le_cmp(&profiles[active_profile].peer, BT_ADDR_LE_ANY); return !bt_addr_le_cmp(&profiles[active_profile].peer, BT_ADDR_LE_ANY);
} }
void set_profile_address(u8_t index, const bt_addr_le_t *addr) { void set_profile_address(uint8_t index, const bt_addr_le_t *addr) {
char setting_name[15]; char setting_name[15];
char addr_str[BT_ADDR_LE_STR_LEN]; char addr_str[BT_ADDR_LE_STR_LEN];
@ -228,7 +228,7 @@ int zmk_ble_clear_bonds() {
int zmk_ble_active_profile_index() { return active_profile; } int zmk_ble_active_profile_index() { return active_profile; }
int zmk_ble_prof_select(u8_t index) { int zmk_ble_prof_select(uint8_t index) {
LOG_DBG("profile %d", index); LOG_DBG("profile %d", index);
if (active_profile == index) { if (active_profile == index) {
return 0; return 0;
@ -277,7 +277,7 @@ static int ble_profiles_handle_set(const char *name, size_t len, settings_read_c
if (settings_name_steq(name, "profiles", &next) && next) { if (settings_name_steq(name, "profiles", &next) && next) {
char *endptr; char *endptr;
u8_t idx = strtoul(next, &endptr, 10); uint8_t idx = strtoul(next, &endptr, 10);
if (*endptr != '\0') { if (*endptr != '\0') {
LOG_WRN("Invalid profile index: %s", log_strdup(next)); LOG_WRN("Invalid profile index: %s", log_strdup(next));
return -EINVAL; return -EINVAL;
@ -339,7 +339,7 @@ static bool is_conn_active_profile(const struct bt_conn *conn) {
return bt_addr_le_cmp(bt_conn_get_dst(conn), &profiles[active_profile].peer) == 0; return bt_addr_le_cmp(bt_conn_get_dst(conn), &profiles[active_profile].peer) == 0;
} }
static void connected(struct bt_conn *conn, u8_t err) { static void connected(struct bt_conn *conn, uint8_t err) {
char addr[BT_ADDR_LE_STR_LEN]; char addr[BT_ADDR_LE_STR_LEN];
bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr)); bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));
LOG_DBG("Connected thread: %p", k_current_get()); LOG_DBG("Connected thread: %p", k_current_get());
@ -372,7 +372,7 @@ static void connected(struct bt_conn *conn, u8_t err) {
} }
} }
static void disconnected(struct bt_conn *conn, u8_t reason) { static void disconnected(struct bt_conn *conn, uint8_t reason) {
char addr[BT_ADDR_LE_STR_LEN]; char addr[BT_ADDR_LE_STR_LEN];
bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr)); bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));
@ -581,12 +581,12 @@ bool zmk_ble_handle_key_user(struct zmk_key_event *key_event) {
return true; return true;
} }
u32_t val = (key == NUMBER_0) ? 0 : (key - NUMBER_1 + 1); uint32_t val = (key == NUMBER_0) ? 0 : (key - NUMBER_1 + 1);
passkey_entries[passkey_digit++] = val; passkey_entries[passkey_digit++] = val;
if (passkey_digit == 6) { if (passkey_digit == 6) {
u32_t passkey = 0; uint32_t passkey = 0;
for (int i = 5; i >= 0; i--) { for (int i = 5; i >= 0; i--) {
passkey = (passkey * 10) + val; passkey = (passkey * 10) + val;
} }

2
app/src/display/widgets/battery_status.c

@ -32,7 +32,7 @@ void battery_status_init() {
void set_battery_symbol(lv_obj_t *label) { void set_battery_symbol(lv_obj_t *label) {
char text[2] = " "; char text[2] = " ";
u8_t level = bt_gatt_bas_get_battery_level(); uint8_t level = bt_gatt_bas_get_battery_level();
#if IS_ENABLED(CONFIG_USB) #if IS_ENABLED(CONFIG_USB)
if (zmk_usb_is_powered()) { if (zmk_usb_is_powered()) {

2
app/src/display/widgets/output_status.c

@ -36,7 +36,7 @@ void set_status_symbol(lv_obj_t *label) {
enum zmk_endpoint selected_endpoint = zmk_endpoints_selected(); enum zmk_endpoint selected_endpoint = zmk_endpoints_selected();
bool active_profile_connected = zmk_ble_active_profile_is_connected(); bool active_profile_connected = zmk_ble_active_profile_is_connected();
bool active_profie_bonded = !zmk_ble_active_profile_is_open(); bool active_profie_bonded = !zmk_ble_active_profile_is_open();
u8_t active_profile_index = zmk_ble_active_profile_index(); uint8_t active_profile_index = zmk_ble_active_profile_index();
char text[6] = {}; char text[6] = {};
switch (selected_endpoint) { switch (selected_endpoint) {

6
app/src/endpoints.c

@ -61,7 +61,7 @@ static int send_keyboard_report() {
switch (current_endpoint) { switch (current_endpoint) {
#if IS_ENABLED(CONFIG_ZMK_USB) #if IS_ENABLED(CONFIG_ZMK_USB)
case ZMK_ENDPOINT_USB: { case ZMK_ENDPOINT_USB: {
int err = zmk_usb_hid_send_report((u8_t *)keyboard_report, sizeof(*keyboard_report)); int err = zmk_usb_hid_send_report((uint8_t *)keyboard_report, sizeof(*keyboard_report));
if (err) { if (err) {
LOG_ERR("FAILED TO SEND OVER USB: %d", err); LOG_ERR("FAILED TO SEND OVER USB: %d", err);
} }
@ -91,7 +91,7 @@ static int send_consumer_report() {
switch (current_endpoint) { switch (current_endpoint) {
#if IS_ENABLED(CONFIG_ZMK_USB) #if IS_ENABLED(CONFIG_ZMK_USB)
case ZMK_ENDPOINT_USB: { case ZMK_ENDPOINT_USB: {
int err = zmk_usb_hid_send_report((u8_t *)consumer_report, sizeof(*consumer_report)); int err = zmk_usb_hid_send_report((uint8_t *)consumer_report, sizeof(*consumer_report));
if (err) { if (err) {
LOG_ERR("FAILED TO SEND OVER USB: %d", err); LOG_ERR("FAILED TO SEND OVER USB: %d", err);
} }
@ -115,7 +115,7 @@ static int send_consumer_report() {
} }
} }
int zmk_endpoints_send_report(u8_t usage_page) { int zmk_endpoints_send_report(uint8_t usage_page) {
LOG_DBG("usage page 0x%02X", usage_page); LOG_DBG("usage page 0x%02X", usage_page);
switch (usage_page) { switch (usage_page) {

8
app/src/event_manager.c

@ -17,9 +17,9 @@ extern struct zmk_event_type *__event_type_end[];
extern struct zmk_event_subscription __event_subscriptions_start[]; extern struct zmk_event_subscription __event_subscriptions_start[];
extern struct zmk_event_subscription __event_subscriptions_end[]; extern struct zmk_event_subscription __event_subscriptions_end[];
int zmk_event_manager_handle_from(struct zmk_event_header *event, u8_t start_index) { int zmk_event_manager_handle_from(struct zmk_event_header *event, uint8_t start_index) {
int ret = 0; int ret = 0;
u8_t len = __event_subscriptions_end - __event_subscriptions_start; uint8_t len = __event_subscriptions_end - __event_subscriptions_start;
for (int i = start_index; i < len; i++) { for (int i = start_index; i < len; i++) {
struct zmk_event_subscription *ev_sub = __event_subscriptions_start + i; struct zmk_event_subscription *ev_sub = __event_subscriptions_start + i;
if (ev_sub->event_type == event->event) { if (ev_sub->event_type == event->event) {
@ -54,7 +54,7 @@ int zmk_event_manager_raise(struct zmk_event_header *event) {
int zmk_event_manager_raise_after(struct zmk_event_header *event, int zmk_event_manager_raise_after(struct zmk_event_header *event,
const struct zmk_listener *listener) { const struct zmk_listener *listener) {
u8_t len = __event_subscriptions_end - __event_subscriptions_start; uint8_t len = __event_subscriptions_end - __event_subscriptions_start;
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
struct zmk_event_subscription *ev_sub = __event_subscriptions_start + i; struct zmk_event_subscription *ev_sub = __event_subscriptions_start + i;
@ -70,7 +70,7 @@ int zmk_event_manager_raise_after(struct zmk_event_header *event,
int zmk_event_manager_raise_at(struct zmk_event_header *event, int zmk_event_manager_raise_at(struct zmk_event_header *event,
const struct zmk_listener *listener) { const struct zmk_listener *listener) {
u8_t len = __event_subscriptions_end - __event_subscriptions_start; uint8_t len = __event_subscriptions_end - __event_subscriptions_start;
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
struct zmk_event_subscription *ev_sub = __event_subscriptions_start + i; struct zmk_event_subscription *ev_sub = __event_subscriptions_start + i;

4
app/src/ext_power_generic.c

@ -21,8 +21,8 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
struct ext_power_generic_config { struct ext_power_generic_config {
const char *label; const char *label;
const u8_t pin; const uint8_t pin;
const u8_t flags; const uint8_t flags;
}; };
struct ext_power_generic_data { struct ext_power_generic_data {

4
app/src/hid_listener.c

@ -16,7 +16,7 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
#include <dt-bindings/zmk/hid_usage_pages.h> #include <dt-bindings/zmk/hid_usage_pages.h>
#include <zmk/endpoints.h> #include <zmk/endpoints.h>
static int hid_listener_keycode_pressed(u8_t usage_page, u32_t keycode, static int hid_listener_keycode_pressed(uint8_t usage_page, uint32_t keycode,
zmk_mod_flags implicit_modifiers) { zmk_mod_flags implicit_modifiers) {
int err; int err;
LOG_DBG("usage_page 0x%02X keycode 0x%02X mods 0x%02X", usage_page, keycode, LOG_DBG("usage_page 0x%02X keycode 0x%02X mods 0x%02X", usage_page, keycode,
@ -41,7 +41,7 @@ static int hid_listener_keycode_pressed(u8_t usage_page, u32_t keycode,
return zmk_endpoints_send_report(usage_page); return zmk_endpoints_send_report(usage_page);
} }
static int hid_listener_keycode_released(u8_t usage_page, u32_t keycode, static int hid_listener_keycode_released(uint8_t usage_page, uint32_t keycode,
zmk_mod_flags implicit_modifiers) { zmk_mod_flags implicit_modifiers) {
int err; int err;
LOG_DBG("usage_page 0x%02X keycode 0x%02X mods 0x%02X", usage_page, keycode, LOG_DBG("usage_page 0x%02X keycode 0x%02X mods 0x%02X", usage_page, keycode,

34
app/src/hog.c

@ -23,14 +23,14 @@ enum {
}; };
struct hids_info { struct hids_info {
u16_t version; /* version number of base USB HID Specification */ uint16_t version; /* version number of base USB HID Specification */
u8_t code; /* country HID Device hardware is localized for. */ uint8_t code; /* country HID Device hardware is localized for. */
u8_t flags; uint8_t flags;
} __packed; } __packed;
struct hids_report { struct hids_report {
u8_t id; /* report id */ uint8_t id; /* report id */
u8_t type; /* report type */ uint8_t type; /* report type */
} __packed; } __packed;
static struct hids_info info = { static struct hids_info info = {
@ -56,29 +56,29 @@ static struct hids_report consumer_input = {
}; };
static bool host_requests_notification = false; static bool host_requests_notification = false;
static u8_t ctrl_point; static uint8_t ctrl_point;
// static u8_t proto_mode; // static uint8_t proto_mode;
static ssize_t read_hids_info(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, static ssize_t read_hids_info(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf,
u16_t len, u16_t offset) { uint16_t len, uint16_t offset) {
return bt_gatt_attr_read(conn, attr, buf, len, offset, attr->user_data, return bt_gatt_attr_read(conn, attr, buf, len, offset, attr->user_data,
sizeof(struct hids_info)); sizeof(struct hids_info));
} }
static ssize_t read_hids_report_ref(struct bt_conn *conn, const struct bt_gatt_attr *attr, static ssize_t read_hids_report_ref(struct bt_conn *conn, const struct bt_gatt_attr *attr,
void *buf, u16_t len, u16_t offset) { void *buf, uint16_t len, uint16_t offset) {
return bt_gatt_attr_read(conn, attr, buf, len, offset, attr->user_data, return bt_gatt_attr_read(conn, attr, buf, len, offset, attr->user_data,
sizeof(struct hids_report)); sizeof(struct hids_report));
} }
static ssize_t read_hids_report_map(struct bt_conn *conn, const struct bt_gatt_attr *attr, static ssize_t read_hids_report_map(struct bt_conn *conn, const struct bt_gatt_attr *attr,
void *buf, u16_t len, u16_t offset) { void *buf, uint16_t len, uint16_t offset) {
return bt_gatt_attr_read(conn, attr, buf, len, offset, zmk_hid_report_desc, return bt_gatt_attr_read(conn, attr, buf, len, offset, zmk_hid_report_desc,
sizeof(zmk_hid_report_desc)); sizeof(zmk_hid_report_desc));
} }
static ssize_t read_hids_input_report(struct bt_conn *conn, const struct bt_gatt_attr *attr, static ssize_t read_hids_input_report(struct bt_conn *conn, const struct bt_gatt_attr *attr,
void *buf, u16_t len, u16_t offset) { void *buf, uint16_t len, uint16_t offset) {
struct zmk_hid_keyboard_report_body *report_body = &zmk_hid_get_keyboard_report()->body; struct zmk_hid_keyboard_report_body *report_body = &zmk_hid_get_keyboard_report()->body;
return bt_gatt_attr_read(conn, attr, buf, len, offset, report_body, return bt_gatt_attr_read(conn, attr, buf, len, offset, report_body,
sizeof(struct zmk_hid_keyboard_report_body)); sizeof(struct zmk_hid_keyboard_report_body));
@ -86,7 +86,7 @@ static ssize_t read_hids_input_report(struct bt_conn *conn, const struct bt_gatt
static ssize_t read_hids_consumer_input_report(struct bt_conn *conn, static ssize_t read_hids_consumer_input_report(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf, const struct bt_gatt_attr *attr, void *buf,
u16_t len, u16_t offset) { uint16_t len, uint16_t offset) {
struct zmk_hid_consumer_report_body *report_body = &zmk_hid_get_consumer_report()->body; struct zmk_hid_consumer_report_body *report_body = &zmk_hid_get_consumer_report()->body;
return bt_gatt_attr_read(conn, attr, buf, len, offset, report_body, return bt_gatt_attr_read(conn, attr, buf, len, offset, report_body,
sizeof(struct zmk_hid_consumer_report_body)); sizeof(struct zmk_hid_consumer_report_body));
@ -94,20 +94,20 @@ static ssize_t read_hids_consumer_input_report(struct bt_conn *conn,
// static ssize_t write_proto_mode(struct bt_conn *conn, // static ssize_t write_proto_mode(struct bt_conn *conn,
// const struct bt_gatt_attr *attr, // const struct bt_gatt_attr *attr,
// const void *buf, u16_t len, u16_t offset, // const void *buf, uint16_t len, uint16_t offset,
// u8_t flags) // uint8_t flags)
// { // {
// printk("PROTO CHANGED\n"); // printk("PROTO CHANGED\n");
// return 0; // return 0;
// } // }
static void input_ccc_changed(const struct bt_gatt_attr *attr, u16_t value) { static void input_ccc_changed(const struct bt_gatt_attr *attr, uint16_t value) {
host_requests_notification = (value == BT_GATT_CCC_NOTIFY) ? 1 : 0; host_requests_notification = (value == BT_GATT_CCC_NOTIFY) ? 1 : 0;
} }
static ssize_t write_ctrl_point(struct bt_conn *conn, const struct bt_gatt_attr *attr, static ssize_t write_ctrl_point(struct bt_conn *conn, const struct bt_gatt_attr *attr,
const void *buf, u16_t len, u16_t offset, u8_t flags) { const void *buf, uint16_t len, uint16_t offset, uint8_t flags) {
u8_t *value = attr->user_data; uint8_t *value = attr->user_data;
if (offset + len > sizeof(ctrl_point)) { if (offset + len > sizeof(ctrl_point)) {
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);

28
app/src/keymap.c

@ -20,7 +20,7 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
#include <zmk/events/sensor-event.h> #include <zmk/events/sensor-event.h>
static zmk_keymap_layers_state _zmk_keymap_layer_state = 0; static zmk_keymap_layers_state _zmk_keymap_layer_state = 0;
static u8_t _zmk_keymap_layer_default = 0; static uint8_t _zmk_keymap_layer_default = 0;
#define DT_DRV_COMPAT zmk_keymap #define DT_DRV_COMPAT zmk_keymap
@ -64,7 +64,7 @@ static u8_t _zmk_keymap_layer_default = 0;
// When a behavior handles a key position "down" event, we record the layer state // When a behavior handles a key position "down" event, we record the layer state
// here so that even if that layer is deactivated before the "up", event, we // here so that even if that layer is deactivated before the "up", event, we
// still send the release event to the behavior in that layer also. // still send the release event to the behavior in that layer also.
static u32_t zmk_keymap_active_behavior_layer[ZMK_KEYMAP_LEN]; static uint32_t zmk_keymap_active_behavior_layer[ZMK_KEYMAP_LEN];
static struct zmk_behavior_binding zmk_keymap[ZMK_KEYMAP_LAYERS_LEN][ZMK_KEYMAP_LEN] = { static struct zmk_behavior_binding zmk_keymap[ZMK_KEYMAP_LAYERS_LEN][ZMK_KEYMAP_LEN] = {
DT_INST_FOREACH_CHILD(0, TRANSFORMED_LAYER)}; DT_INST_FOREACH_CHILD(0, TRANSFORMED_LAYER)};
@ -77,7 +77,7 @@ static struct zmk_behavior_binding zmk_sensor_keymap[ZMK_KEYMAP_LAYERS_LEN]
#endif /* ZMK_KEYMAP_HAS_SENSORS */ #endif /* ZMK_KEYMAP_HAS_SENSORS */
static inline int set_layer_state(u8_t layer, bool state) { static inline int set_layer_state(uint8_t layer, bool state) {
if (layer >= 32) { if (layer >= 32) {
return -EINVAL; return -EINVAL;
} }
@ -86,16 +86,16 @@ static inline int set_layer_state(u8_t layer, bool state) {
return 0; return 0;
} }
u8_t zmk_keymap_layer_default() { return _zmk_keymap_layer_default; } uint8_t zmk_keymap_layer_default() { return _zmk_keymap_layer_default; }
zmk_keymap_layers_state zmk_keymap_layer_state() { return _zmk_keymap_layer_state; } zmk_keymap_layers_state zmk_keymap_layer_state() { return _zmk_keymap_layer_state; }
bool zmk_keymap_layer_active(u8_t layer) { bool zmk_keymap_layer_active(uint8_t layer) {
return (_zmk_keymap_layer_state & (BIT(layer))) == (BIT(layer)); return (_zmk_keymap_layer_state & (BIT(layer))) == (BIT(layer));
}; };
u8_t zmk_keymap_highest_layer_active() { uint8_t zmk_keymap_highest_layer_active() {
for (u8_t layer = 31; layer > 0; layer--) { for (uint8_t layer = 31; layer > 0; layer--) {
if (zmk_keymap_layer_active(layer)) { if (zmk_keymap_layer_active(layer)) {
return layer; return layer;
} }
@ -103,11 +103,11 @@ u8_t zmk_keymap_highest_layer_active() {
return zmk_keymap_layer_default(); return zmk_keymap_layer_default();
} }
int zmk_keymap_layer_activate(u8_t layer) { return set_layer_state(layer, true); }; int zmk_keymap_layer_activate(uint8_t layer) { return set_layer_state(layer, true); };
int zmk_keymap_layer_deactivate(u8_t layer) { return set_layer_state(layer, false); }; int zmk_keymap_layer_deactivate(uint8_t layer) { return set_layer_state(layer, false); };
int zmk_keymap_layer_toggle(u8_t layer) { int zmk_keymap_layer_toggle(uint8_t layer) {
if (zmk_keymap_layer_active(layer)) { if (zmk_keymap_layer_active(layer)) {
return zmk_keymap_layer_deactivate(layer); return zmk_keymap_layer_deactivate(layer);
} }
@ -115,11 +115,11 @@ int zmk_keymap_layer_toggle(u8_t layer) {
return zmk_keymap_layer_activate(layer); return zmk_keymap_layer_activate(layer);
}; };
bool is_active_layer(u8_t layer, zmk_keymap_layers_state layer_state) { bool is_active_layer(uint8_t layer, zmk_keymap_layers_state layer_state) {
return (layer_state & BIT(layer)) == BIT(layer) || layer == _zmk_keymap_layer_default; return (layer_state & BIT(layer)) == BIT(layer) || layer == _zmk_keymap_layer_default;
} }
int zmk_keymap_apply_position_state(int layer, u32_t position, bool pressed, s64_t timestamp) { 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 zmk_behavior_binding *binding = &zmk_keymap[layer][position];
struct device *behavior; struct device *behavior;
struct zmk_behavior_binding_event event = { struct zmk_behavior_binding_event event = {
@ -145,7 +145,7 @@ int zmk_keymap_apply_position_state(int layer, u32_t position, bool pressed, s64
} }
} }
int zmk_keymap_position_state_changed(u32_t position, bool pressed, s64_t timestamp) { int zmk_keymap_position_state_changed(uint32_t position, bool pressed, int64_t timestamp) {
if (pressed) { if (pressed) {
zmk_keymap_active_behavior_layer[position] = _zmk_keymap_layer_state; zmk_keymap_active_behavior_layer[position] = _zmk_keymap_layer_state;
} }
@ -168,7 +168,7 @@ int zmk_keymap_position_state_changed(u32_t position, bool pressed, s64_t timest
} }
#if ZMK_KEYMAP_HAS_SENSORS #if ZMK_KEYMAP_HAS_SENSORS
int zmk_keymap_sensor_triggered(u8_t sensor_number, struct device *sensor, s64_t timestamp) { int zmk_keymap_sensor_triggered(uint8_t sensor_number, struct device *sensor, int64_t timestamp) {
for (int layer = ZMK_KEYMAP_LAYERS_LEN - 1; layer >= _zmk_keymap_layer_default; layer--) { for (int layer = ZMK_KEYMAP_LAYERS_LEN - 1; layer >= _zmk_keymap_layer_default; layer--) {
if (((_zmk_keymap_layer_state & BIT(layer)) == BIT(layer) || if (((_zmk_keymap_layer_state & BIT(layer)) == BIT(layer) ||
layer == _zmk_keymap_layer_default) && layer == _zmk_keymap_layer_default) &&

10
app/src/kscan.c

@ -19,9 +19,9 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
#define ZMK_KSCAN_EVENT_STATE_RELEASED 1 #define ZMK_KSCAN_EVENT_STATE_RELEASED 1
struct zmk_kscan_event { struct zmk_kscan_event {
u32_t row; uint32_t row;
u32_t column; uint32_t column;
u32_t state; uint32_t state;
}; };
struct zmk_kscan_msg_processor { struct zmk_kscan_msg_processor {
@ -30,7 +30,7 @@ struct zmk_kscan_msg_processor {
K_MSGQ_DEFINE(zmk_kscan_msgq, sizeof(struct zmk_kscan_event), CONFIG_ZMK_KSCAN_EVENT_QUEUE_SIZE, 4); 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, u32_t row, u32_t column, bool pressed) { static void zmk_kscan_callback(struct device *dev, uint32_t row, uint32_t column, bool pressed) {
struct zmk_kscan_event ev = { struct zmk_kscan_event ev = {
.row = row, .row = row,
.column = column, .column = column,
@ -45,7 +45,7 @@ void zmk_kscan_process_msgq(struct k_work *item) {
while (k_msgq_get(&zmk_kscan_msgq, &ev, K_NO_WAIT) == 0) { while (k_msgq_get(&zmk_kscan_msgq, &ev, K_NO_WAIT) == 0) {
bool pressed = (ev.state == ZMK_KSCAN_EVENT_STATE_PRESSED); bool pressed = (ev.state == ZMK_KSCAN_EVENT_STATE_PRESSED);
u32_t position = zmk_matrix_transform_row_column_to_position(ev.row, ev.column); uint32_t position = zmk_matrix_transform_row_column_to_position(ev.row, ev.column);
struct position_state_changed *pos_ev; struct position_state_changed *pos_ev;
LOG_DBG("Row: %d, col: %d, position: %d, pressed: %s\n", ev.row, ev.column, position, LOG_DBG("Row: %d, col: %d, position: %d, pressed: %s\n", ev.row, ev.column, position,
(pressed ? "true" : "false")); (pressed ? "true" : "false"));

6
app/src/matrix_transform.c

@ -15,12 +15,12 @@
[(KT_ROW(DT_PROP_BY_IDX(ZMK_KEYMAP_TRANSFORM_NODE, map, i)) * ZMK_MATRIX_COLS) + \ [(KT_ROW(DT_PROP_BY_IDX(ZMK_KEYMAP_TRANSFORM_NODE, map, i)) * ZMK_MATRIX_COLS) + \
KT_COL(DT_PROP_BY_IDX(ZMK_KEYMAP_TRANSFORM_NODE, map, i))] = i, KT_COL(DT_PROP_BY_IDX(ZMK_KEYMAP_TRANSFORM_NODE, map, i))] = i,
static u32_t transform[] = {UTIL_LISTIFY(ZMK_KEYMAP_LEN, _TRANSFORM_ENTRY, 0)}; static uint32_t transform[] = {UTIL_LISTIFY(ZMK_KEYMAP_LEN, _TRANSFORM_ENTRY, 0)};
#endif #endif
u32_t zmk_matrix_transform_row_column_to_position(u32_t row, u32_t column) { uint32_t zmk_matrix_transform_row_column_to_position(uint32_t row, uint32_t column) {
u32_t matrix_index; uint32_t matrix_index;
#if DT_NODE_HAS_PROP(ZMK_KEYMAP_TRANSFORM_NODE, col_offset) #if DT_NODE_HAS_PROP(ZMK_KEYMAP_TRANSFORM_NODE, col_offset)
column += DT_PROP(ZMK_KEYMAP_TRANSFORM_NODE, col_offset); column += DT_PROP(ZMK_KEYMAP_TRANSFORM_NODE, col_offset);

6
app/src/power.c

@ -17,7 +17,7 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
#include <zmk/events/position-state-changed.h> #include <zmk/events/position-state-changed.h>
#include <zmk/events/sensor-event.h> #include <zmk/events/sensor-event.h>
static u32_t power_last_uptime; static uint32_t power_last_uptime;
#define MAX_IDLE_MS CONFIG_ZMK_IDLE_SLEEP_TIMEOUT #define MAX_IDLE_MS CONFIG_ZMK_IDLE_SLEEP_TIMEOUT
@ -29,10 +29,10 @@ bool is_usb_power_present() {
#endif /* CONFIG_USB */ #endif /* CONFIG_USB */
} }
enum power_states sys_pm_policy_next_state(s32_t ticks) { enum power_states sys_pm_policy_next_state(int32_t ticks) {
#ifdef CONFIG_SYS_POWER_DEEP_SLEEP_STATES #ifdef CONFIG_SYS_POWER_DEEP_SLEEP_STATES
#ifdef CONFIG_HAS_SYS_POWER_STATE_DEEP_SLEEP_1 #ifdef CONFIG_HAS_SYS_POWER_STATE_DEEP_SLEEP_1
s32_t current = k_uptime_get(); int32_t current = k_uptime_get();
if (power_last_uptime > 0 && !is_usb_power_present() && if (power_last_uptime > 0 && !is_usb_power_present() &&
current - power_last_uptime > MAX_IDLE_MS) { current - power_last_uptime > MAX_IDLE_MS) {
return SYS_POWER_STATE_DEEP_SLEEP_1; return SYS_POWER_STATE_DEEP_SLEEP_1;

20
app/src/rgb_underglow.c

@ -31,18 +31,18 @@ enum rgb_underglow_effect {
}; };
struct led_hsb { struct led_hsb {
u16_t h; uint16_t h;
u8_t s; uint8_t s;
u8_t b; uint8_t b;
}; };
struct rgb_underglow_state { struct rgb_underglow_state {
u16_t hue; uint16_t hue;
u8_t saturation; uint8_t saturation;
u8_t brightness; uint8_t brightness;
u8_t animation_speed; uint8_t animation_speed;
u8_t current_effect; uint8_t current_effect;
u16_t animation_step; uint16_t animation_step;
bool on; bool on;
}; };
@ -59,7 +59,7 @@ static struct device *ext_power;
static struct led_rgb hsb_to_rgb(struct led_hsb hsb) { static struct led_rgb hsb_to_rgb(struct led_hsb hsb) {
double r, g, b; double r, g, b;
u8_t i = hsb.h / 60; uint8_t i = hsb.h / 60;
double v = hsb.b / 100.0; double v = hsb.b / 100.0;
double s = hsb.s / 100.0; double s = hsb.s / 100.0;
double f = hsb.h / 360.0 * 6 - i; double f = hsb.h / 360.0 * 6 - i;

4
app/src/sensors.c

@ -19,7 +19,7 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
#if ZMK_KEYMAP_HAS_SENSORS #if ZMK_KEYMAP_HAS_SENSORS
struct sensors_data_item { struct sensors_data_item {
u8_t sensor_number; uint8_t sensor_number;
struct device *dev; struct device *dev;
struct sensor_trigger trigger; struct sensor_trigger trigger;
}; };
@ -53,7 +53,7 @@ static void zmk_sensors_trigger_handler(struct device *dev, struct sensor_trigge
ZMK_EVENT_RAISE(event); ZMK_EVENT_RAISE(event);
} }
static void zmk_sensors_init_item(const char *node, u8_t i, u8_t abs_i) { static void zmk_sensors_init_item(const char *node, uint8_t i, uint8_t abs_i) {
LOG_DBG("Init %s at index %d with sensor_number %d", node, i, abs_i); LOG_DBG("Init %s at index %d with sensor_number %d", node, i, abs_i);
sensors[i].dev = device_get_binding(node); sensors[i].dev = device_get_binding(node);

23
app/src/split/bluetooth/central.c

@ -33,11 +33,12 @@ static struct bt_uuid_128 uuid = BT_UUID_INIT_128(ZMK_SPLIT_BT_SERVICE_UUID);
static struct bt_gatt_discover_params discover_params; static struct bt_gatt_discover_params discover_params;
static struct bt_gatt_subscribe_params subscribe_params; static struct bt_gatt_subscribe_params subscribe_params;
static u8_t split_central_notify_func(struct bt_conn *conn, struct bt_gatt_subscribe_params *params, static uint8_t split_central_notify_func(struct bt_conn *conn,
const void *data, u16_t length) { struct bt_gatt_subscribe_params *params, const void *data,
static u8_t position_state[POSITION_STATE_DATA_LEN]; uint16_t length) {
static uint8_t position_state[POSITION_STATE_DATA_LEN];
u8_t changed_positions[POSITION_STATE_DATA_LEN]; uint8_t changed_positions[POSITION_STATE_DATA_LEN];
if (!data) { if (!data) {
LOG_DBG("[UNSUBSCRIBED]"); LOG_DBG("[UNSUBSCRIBED]");
@ -48,14 +49,14 @@ static u8_t split_central_notify_func(struct bt_conn *conn, struct bt_gatt_subsc
LOG_DBG("[NOTIFICATION] data %p length %u", data, length); LOG_DBG("[NOTIFICATION] data %p length %u", data, length);
for (int i = 0; i < POSITION_STATE_DATA_LEN; i++) { for (int i = 0; i < POSITION_STATE_DATA_LEN; i++) {
changed_positions[i] = ((u8_t *)data)[i] ^ position_state[i]; changed_positions[i] = ((uint8_t *)data)[i] ^ position_state[i];
position_state[i] = ((u8_t *)data)[i]; position_state[i] = ((uint8_t *)data)[i];
} }
for (int i = 0; i < POSITION_STATE_DATA_LEN; i++) { for (int i = 0; i < POSITION_STATE_DATA_LEN; i++) {
for (int j = 0; j < 8; j++) { for (int j = 0; j < 8; j++) {
if (changed_positions[i] & BIT(j)) { if (changed_positions[i] & BIT(j)) {
u32_t position = (i * 8) + j; uint32_t position = (i * 8) + j;
bool pressed = position_state[i] & BIT(j); bool pressed = position_state[i] & BIT(j);
struct position_state_changed *pos_ev = new_position_state_changed(); struct position_state_changed *pos_ev = new_position_state_changed();
pos_ev->position = position; pos_ev->position = position;
@ -91,7 +92,7 @@ static int split_central_subscribe(struct bt_conn *conn) {
return 0; return 0;
} }
static u8_t split_central_discovery_func(struct bt_conn *conn, const struct bt_gatt_attr *attr, static uint8_t split_central_discovery_func(struct bt_conn *conn, const struct bt_gatt_attr *attr,
struct bt_gatt_discover_params *params) { struct bt_gatt_discover_params *params) {
int err; int err;
@ -245,7 +246,7 @@ static bool split_central_eir_found(struct bt_data *data, void *user_data) {
return true; return true;
} }
static void split_central_device_found(const bt_addr_le_t *addr, s8_t rssi, u8_t type, static void split_central_device_found(const bt_addr_le_t *addr, int8_t rssi, uint8_t type,
struct net_buf_simple *ad) { struct net_buf_simple *ad) {
char dev[BT_ADDR_LE_STR_LEN]; char dev[BT_ADDR_LE_STR_LEN];
@ -272,7 +273,7 @@ static int start_scan(void) {
return 0; return 0;
} }
static void split_central_connected(struct bt_conn *conn, u8_t conn_err) { static void split_central_connected(struct bt_conn *conn, uint8_t conn_err) {
char addr[BT_ADDR_LE_STR_LEN]; char addr[BT_ADDR_LE_STR_LEN];
bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr)); bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));
@ -292,7 +293,7 @@ static void split_central_connected(struct bt_conn *conn, u8_t conn_err) {
split_central_process_connection(conn); split_central_process_connection(conn);
} }
static void split_central_disconnected(struct bt_conn *conn, u8_t reason) { static void split_central_disconnected(struct bt_conn *conn, uint8_t reason) {
char addr[BT_ADDR_LE_STR_LEN]; char addr[BT_ADDR_LE_STR_LEN];
bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr)); bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));

16
app/src/split/bluetooth/service.c

@ -18,21 +18,21 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
#include <zmk/split/bluetooth/uuid.h> #include <zmk/split/bluetooth/uuid.h>
#include <zmk/split/bluetooth/service.h> #include <zmk/split/bluetooth/service.h>
static u8_t num_of_positions = ZMK_KEYMAP_LEN; static uint8_t num_of_positions = ZMK_KEYMAP_LEN;
static u8_t position_state[16]; static uint8_t position_state[16];
static ssize_t split_svc_pos_state(struct bt_conn *conn, const struct bt_gatt_attr *attrs, static ssize_t split_svc_pos_state(struct bt_conn *conn, const struct bt_gatt_attr *attrs,
void *buf, u16_t len, u16_t offset) { void *buf, uint16_t len, uint16_t offset) {
return bt_gatt_attr_read(conn, attrs, buf, len, offset, &position_state, return bt_gatt_attr_read(conn, attrs, buf, len, offset, &position_state,
sizeof(position_state)); sizeof(position_state));
} }
static ssize_t split_svc_num_of_positions(struct bt_conn *conn, const struct bt_gatt_attr *attrs, static ssize_t split_svc_num_of_positions(struct bt_conn *conn, const struct bt_gatt_attr *attrs,
void *buf, u16_t len, u16_t offset) { void *buf, uint16_t len, uint16_t offset) {
return bt_gatt_attr_read(conn, attrs, buf, len, offset, attrs->user_data, sizeof(u8_t)); return bt_gatt_attr_read(conn, attrs, buf, len, offset, attrs->user_data, sizeof(uint8_t));
} }
static void split_svc_pos_state_ccc(const struct bt_gatt_attr *attr, u16_t value) { static void split_svc_pos_state_ccc(const struct bt_gatt_attr *attr, uint16_t value) {
LOG_DBG("value %d", value); LOG_DBG("value %d", value);
} }
@ -45,12 +45,12 @@ BT_GATT_SERVICE_DEFINE(
BT_GATT_DESCRIPTOR(BT_UUID_NUM_OF_DIGITALS, BT_GATT_PERM_READ, split_svc_num_of_positions, NULL, BT_GATT_DESCRIPTOR(BT_UUID_NUM_OF_DIGITALS, BT_GATT_PERM_READ, split_svc_num_of_positions, NULL,
&num_of_positions), ); &num_of_positions), );
int zmk_split_bt_position_pressed(u8_t position) { int zmk_split_bt_position_pressed(uint8_t position) {
WRITE_BIT(position_state[position / 8], position % 8, true); WRITE_BIT(position_state[position / 8], position % 8, true);
return bt_gatt_notify(NULL, &split_svc.attrs[1], &position_state, sizeof(position_state)); return bt_gatt_notify(NULL, &split_svc.attrs[1], &position_state, sizeof(position_state));
} }
int zmk_split_bt_position_released(u8_t position) { int zmk_split_bt_position_released(uint8_t position) {
WRITE_BIT(position_state[position / 8], position % 8, false); WRITE_BIT(position_state[position / 8], position % 8, false);
return bt_gatt_notify(NULL, &split_svc.attrs[1], &position_state, sizeof(position_state)); return bt_gatt_notify(NULL, &split_svc.attrs[1], &position_state, sizeof(position_state));
} }

4
app/src/usb.c

@ -31,7 +31,7 @@ static const struct hid_ops ops = {
.int_in_ready = in_ready_cb, .int_in_ready = in_ready_cb,
}; };
int zmk_usb_hid_send_report(const u8_t *report, size_t len) { int zmk_usb_hid_send_report(const uint8_t *report, size_t len) {
switch (usb_status) { switch (usb_status) {
case USB_DC_SUSPEND: case USB_DC_SUSPEND:
return usb_wakeup_request(); return usb_wakeup_request();
@ -78,7 +78,7 @@ enum zmk_usb_conn_state zmk_usb_get_conn_state() {
} }
} }
void usb_status_cb(enum usb_dc_status_code status, const u8_t *params) { void usb_status_cb(enum usb_dc_status_code status, const uint8_t *params) {
usb_status = status; usb_status = status;
raise_usb_status_changed_event(); raise_usb_status_changed_event();
}; };

Loading…
Cancel
Save