Skip to content

Commit e017006

Browse files
PetervdPerk-NXPdleach02
authored andcommitted
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 1b47a1b commit e017006

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
@@ -178,6 +178,41 @@
178178
current-speed = <115200>;
179179
};
180180

181+
&lpuart6 {
182+
status = "okay";
183+
single-wire;
184+
rx-invert;
185+
186+
sbus {
187+
compatible = "futaba,sbus";
188+
right_stick_x {
189+
channel = <1>;
190+
type = <INPUT_EV_ABS>;
191+
zephyr,code = <INPUT_ABS_RX>;
192+
};
193+
right_stick_y {
194+
channel = <2>;
195+
type = <INPUT_EV_ABS>;
196+
zephyr,code = <INPUT_ABS_RY>;
197+
};
198+
left_stick_y {
199+
channel = <3>;
200+
type = <INPUT_EV_ABS>;
201+
zephyr,code = <INPUT_ABS_Y>;
202+
};
203+
left_stick_x {
204+
channel = <4>;
205+
type = <INPUT_EV_ABS>;
206+
zephyr,code = <INPUT_ABS_X>;
207+
};
208+
kill_switch {
209+
channel = <5>;
210+
type = <INPUT_EV_KEY>;
211+
zephyr,code = <INPUT_KEY_0>;
212+
};
213+
};
214+
};
215+
181216

182217
&flexcan1 {
183218
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)