96 static constexpr auto name =
"ControllerHub";
101 static tl::expected<State, ControllerHubError>
getData();
111 static constexpr size_t DBUS_FRAME_LEN = 18;
112 static constexpr size_t DBUS_CHANNEL_COUNT = 28;
113 static constexpr uint32_t DBUS_INTERFRAME_SPACING_MS = 20;
116 static const uint32_t input_channels_full[DBUS_CHANNEL_COUNT];
119 struct ControllerHubDataInternal
125 uint8_t rd_data[DBUS_FRAME_LEN];
126 uint8_t dbus_frame[DBUS_FRAME_LEN];
128 uint32_t last_rx_time;
131 uint8_t async_rx_buf[2][DBUS_FRAME_LEN];
132 uint8_t next_async_buf;
134 uint16_t last_reported_value[DBUS_CHANNEL_COUNT];
135 int8_t channel_mapping[DBUS_CHANNEL_COUNT];
138 uint8_t invalid_frames;
140 K_KERNEL_STACK_MEMBER(thread_stack, 1024);
143 static ControllerHubDataInternal s_data;
144 static const device* s_uart_dev;
147 static int dbus_enable_rx();
148 static void dbus_restart_rx();
149 static void dbus_append_rx_bytes(
const uint8_t* buf,
size_t len);
150 static void dbus_supply_rx_buffer();
151 static bool dbus_frame_valid(
const uint8_t* buf);
152 static void dbus_uart_event_handler(
struct uart_event* evt);
153 static void dbus_uart_isr_handler();
154 static void input_dbus_input_report_thread();