Skip to content

Commit 95cb82e

Browse files
drivers: input: sbus remote controller support
Add support SBUS RC controller connected through UART Signed-off-by: Peter van der Perk <[email protected]>
1 parent be682e2 commit 95cb82e

File tree

8 files changed

+542
-0
lines changed

8 files changed

+542
-0
lines changed

boards/nxp/vmu_rt1170/doc/index.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ Hardware
6161

6262
- CAN bus JST-GH connectors
6363

64+
- RC IN
65+
66+
- RC input connector for SBUS compatible RC receivers
67+
6468
For more information about the MIMXRT1176 SoC and VMU RT1170 board, see
6569
these references:
6670

boards/nxp/vmu_rt1170/vmu_rt1170_mimxrt1176_cm7.dts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,41 @@
170170
current-speed = <115200>;
171171
};
172172

173+
&lpuart6 {
174+
status = "okay";
175+
single-wire;
176+
rx-invert;
177+
178+
sbus {
179+
compatible = "futaba,sbus";
180+
right_stick_x {
181+
channel = <1>;
182+
type = <INPUT_EV_ABS>;
183+
zephyr,code = <INPUT_ABS_RX>;
184+
};
185+
right_stick_y {
186+
channel = <2>;
187+
type = <INPUT_EV_ABS>;
188+
zephyr,code = <INPUT_ABS_RY>;
189+
};
190+
left_stick_y {
191+
channel = <3>;
192+
type = <INPUT_EV_ABS>;
193+
zephyr,code = <INPUT_ABS_Y>;
194+
};
195+
left_stick_x {
196+
channel = <4>;
197+
type = <INPUT_EV_ABS>;
198+
zephyr,code = <INPUT_ABS_X>;
199+
};
200+
kill_switch {
201+
channel = <5>;
202+
type = <INPUT_EV_KEY>;
203+
zephyr,code = <INPUT_KEY_0>;
204+
};
205+
};
206+
};
207+
173208

174209
&flexcan1 {
175210
status = "okay";

drivers/input/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ zephyr_library_sources_ifdef(CONFIG_INPUT_PAT912X input_pat912x.c)
2424
zephyr_library_sources_ifdef(CONFIG_INPUT_PAW32XX input_paw32xx.c)
2525
zephyr_library_sources_ifdef(CONFIG_INPUT_PINNACLE input_pinnacle.c)
2626
zephyr_library_sources_ifdef(CONFIG_INPUT_PMW3610 input_pmw3610.c)
27+
zephyr_library_sources_ifdef(CONFIG_INPUT_SBUS input_sbus.c)
2728
zephyr_library_sources_ifdef(CONFIG_INPUT_STMPE811 input_stmpe811.c)
2829
zephyr_library_sources_ifdef(CONFIG_INPUT_XEC_KBD input_xec_kbd.c)
2930
zephyr_library_sources_ifdef(CONFIG_INPUT_XPT2046 input_xpt2046.c)

drivers/input/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ source "drivers/input/Kconfig.pat912x"
2626
source "drivers/input/Kconfig.paw32xx"
2727
source "drivers/input/Kconfig.pinnacle"
2828
source "drivers/input/Kconfig.pmw3610"
29+
source "drivers/input/Kconfig.sbus"
2930
source "drivers/input/Kconfig.sdl"
3031
source "drivers/input/Kconfig.stmpe811"
3132
source "drivers/input/Kconfig.xec"

drivers/input/Kconfig.sbus

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Copyright (c) 2024 NXP Semiconductors
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
config INPUT_SBUS
5+
bool "SBUS driver"
6+
default y
7+
depends on DT_HAS_FUTABA_SBUS_ENABLED
8+
depends on UART_INTERRUPT_DRIVEN
9+
select UART_USE_RUNTIME_CONFIGURE
10+
help
11+
Enable driver for SBUS Remote controller.
12+
13+
if INPUT_SBUS
14+
15+
config INPUT_SBUS_THREAD_STACK_SIZE
16+
int "Stack size for the sbus thread"
17+
default 1024
18+
help
19+
Size of the stack used for the sbus thread.
20+
21+
config INPUT_SBUS_THREAD_PRIORITY
22+
int "Priority for the sbus thread"
23+
default 0
24+
help
25+
Priority level of the sbus thread.
26+
27+
config INPUT_SBUS_REPORT_FILTER
28+
int "Minimal change in signal to report"
29+
default 1
30+
help
31+
SBUS tends to be a bit noisy you can increase the threshold to
32+
to lower the amounts of input events. Set to 0 for no filtering
33+
34+
config INPUT_SBUS_SEND_SYNC
35+
bool "Send Sync to input subsys on each SBUS frame"
36+
default y
37+
help
38+
Sends sync message to input subsys with sync bit.
39+
40+
config INPUT_SBUS_CHANNEL_VALUE_ONE
41+
int "Threshold value > for INPUT_EV_KEY value 1"
42+
default 1800
43+
help
44+
SBUS sends analogue values for digital switches. This config value
45+
sets the threshold to interperted the analogue value as an logic 1
46+
47+
config INPUT_SBUS_CHANNEL_VALUE_ZERO
48+
int "Threshold value < for INPUT_EV_KEY value 0"
49+
default 1200
50+
help
51+
SBUS sends analogue values for digital switches. This config value
52+
sets the threshold to interperted the analogue value as an logic 0
53+
54+
endif # INPUT_SBUS

0 commit comments

Comments
 (0)