Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AP_Hal_ChibiOS: Matek F765-Wing new alt configs for extra GPIOs #18873

Merged
merged 2 commits into from
Oct 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion libraries/AP_HAL_ChibiOS/hwdef/MatekF765-Wing/hwdef.dat
Original file line number Diff line number Diff line change
Expand Up @@ -119,17 +119,29 @@ PB8 UART5_RX UART5 NODMA
PC7 TIM3_CH2 TIM3 RCININT PULLDOWN LOW
PC6 USART6_TX USART6 NODMA

# as an alternative config setup the RX6 pin as a uart. This allows
# as an alternative config setup the RX6 pin as an uart. This allows
# for bi-directional UART based receiver protocols such as FPort
# without any extra hardware
PC7 USART6_RX USART6 NODMA ALT(1)
PC7 USART6_RX USART6 NODMA ALT(3)

# UART7 (telem1)
PE7 UART7_RX UART7
PE8 UART7_TX UART7
PE10 UART7_CTS UART7
PE9 UART7_RTS UART7

# telem1-UART7 RTS and CTS as GPIO in alternative configs
PE10 EXTERN_GPIO1 OUTPUT GPIO(1) ALT(2) # Cts7 pin as GPIO 1 (set RELAY_PINx = 1 to use it)
PE9 EXTERN_GPIO2 OUTPUT GPIO(2) ALT(2) # Rts7 pin as GPIO 2 (set RELAY_PINx = 2 to use it)
PE10 EXTERN_GPIO1 OUTPUT GPIO(1) ALT(3) # Cts7 pin as GPIO 1 (set RELAY_PINx = 1 to use it)
PE9 EXTERN_GPIO2 OUTPUT GPIO(2) ALT(3) # Rts7 pin as GPIO 2 (set RELAY_PINx = 2 to use it)

# alternative configs:
# 1: bidirectional receiver protocol on RX6 pin
# 2: extra GPIOs instead of Cts/Rts on UART7_CTS
# 3: both 1 and 2 combined, GPIO numbers differ to avoid "Duplicate GPIO value" error while generating hwdef.h

# UART8 (spare)
PE0 UART8_RX UART8 NODMA
PE1 UART8_TX UART8 NODMA
Expand Down
7 changes: 6 additions & 1 deletion libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py
Original file line number Diff line number Diff line change
Expand Up @@ -1846,7 +1846,12 @@ def write_GPIO_config(f):
if gpio is None:
continue
if gpio in gpioset:
error("Duplicate GPIO value %u" % gpio)
# check existing entry
existing_gpio = [item for item in gpios if item[0] == gpio]
if (existing_gpio[0][4].label == p.label) and (existing_gpio[0][3] == p.pin) and (existing_gpio[0][2] == p.port):
# alt item is identical to exiting, do not add again
continue
error("Duplicate GPIO value %u, %s != %s" % (gpio, p, existing_gpio[0][4]))
pwm = p.extra_value('PWM', type=int, default=0)
if pwm != 0:
error("PWM not supported for alt config: %s" % p)
Expand Down