Skip to content

Commit

Permalink
fmuv6x: Add GPIO expander to check overcurrent pins
Browse files Browse the repository at this point in the history
  • Loading branch information
niklaut authored and dagar committed Aug 8, 2024
1 parent a91aa40 commit cd231d0
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 3 deletions.
1 change: 1 addition & 0 deletions boards/px4/fmu-v6x/default.px4board
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ CONFIG_DRIVERS_CDCACM_AUTOSTART=y
CONFIG_COMMON_DIFFERENTIAL_PRESSURE=y
CONFIG_COMMON_DISTANCE_SENSOR=y
CONFIG_DRIVERS_DSHOT=y
CONFIG_DRIVERS_GPIO_MCP23009=y
CONFIG_DRIVERS_GPS=y
CONFIG_DRIVERS_HEATER=y
CONFIG_DRIVERS_IMU_ANALOG_DEVICES_ADIS16470=y
Expand Down
11 changes: 11 additions & 0 deletions boards/px4/fmu-v6x/init/rc.board_defaults
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,14 @@ else
fi

safety_button start

# GPIO Expander driver on external I2C3
if ver hwbasecmp 009
then
# No USB
mcp23009 start -b 3 -X -D 0xf0 -O 0xf0 -P 0x0f -U 10
fi
if ver hwbasecmp 00a 008
then
mcp23009 start -b 3 -X -D 0xf1 -O 0xf0 -P 0x0f -U 10
fi
1 change: 1 addition & 0 deletions boards/px4/fmu-v6x/nuttx-config/nsh/defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ CONFIG_DEBUG_SYMBOLS=y
CONFIG_DEBUG_TCBINFO=y
CONFIG_DEFAULT_SMALL=y
CONFIG_DEV_FIFO_SIZE=0
CONFIG_DEV_GPIO=y
CONFIG_DEV_PIPE_MAXSIZE=1024
CONFIG_DEV_PIPE_SIZE=70
CONFIG_DEV_URANDOM=y
Expand Down
5 changes: 3 additions & 2 deletions boards/px4/fmu-v6x/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ if("${PX4_BOARD_LABEL}" STREQUAL "bootloader")
add_compile_definitions(BOOTLOADER)
add_library(drivers_board
bootloader_main.c
init.c
init.cpp
usb.c
timer_config.cpp
)
Expand All @@ -52,7 +52,7 @@ else()
add_library(drivers_board
can.c
i2c.cpp
init.c
init.cpp
led.c
mtd.cpp
sdio.c
Expand All @@ -71,5 +71,6 @@ else()
nuttx_arch # sdio
nuttx_drivers # sdio
px4_layer
platform_gpio_mcp23009
)
endif()
5 changes: 5 additions & 0 deletions boards/px4/fmu-v6x/src/board_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,11 @@
#define GPIO_VDD_3V3_SPEKTRUM_POWER_EN /* PH2 */ (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTH|GPIO_PIN2)
#define GPIO_VDD_3V3_SD_CARD_EN /* PC13 */ (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTC|GPIO_PIN13)

/* MCP23009 GPIO expander */
#define BOARD_GPIO_VDD_5V_COMP_VALID "/dev/gpio4"
#define BOARD_GPIO_VDD_5V_CAN1_GPS1_VALID "/dev/gpio5"


/* Spare GPIO */

#define GPIO_PG6 /* PG6 */ (GPIO_INPUT|GPIO_PULLUP|GPIO_PORTG|GPIO_PIN6)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
#include <px4_platform/gpio.h>
#include <px4_platform/board_determine_hw_info.h>
#include <px4_platform/board_dma_alloc.h>
#include <px4_platform/gpio/mcp23009.hpp>

/****************************************************************************
* Pre-Processor Definitions
Expand Down Expand Up @@ -159,7 +160,7 @@ __EXPORT void board_on_reset(int status)
*
************************************************************************************/

__EXPORT void
extern "C" __EXPORT void
stm32_boardinitialize(void)
{
board_on_reset(-1); /* Reset PWM first thing */
Expand Down Expand Up @@ -280,6 +281,13 @@ __EXPORT int board_app_initialize(uintptr_t arg)

# endif /* CONFIG_MMCSD */

ret = mcp23009_register_gpios(3, 0x25);

if (ret != OK) {
led_on(LED_RED);
return ret;
}

#endif /* !defined(BOOTLOADER) */

return OK;
Expand Down

0 comments on commit cd231d0

Please sign in to comment.