diff --git a/boards/arm/s32k1xx/rddrone-uavcan146/include/board.h b/boards/arm/s32k1xx/rddrone-uavcan146/include/board.h index ed0236dbfc..631684b133 100644 --- a/boards/arm/s32k1xx/rddrone-uavcan146/include/board.h +++ b/boards/arm/s32k1xx/rddrone-uavcan146/include/board.h @@ -73,6 +73,12 @@ #define BOARD_LED_G_BIT (1 << BOARD_LED_G) #define BOARD_LED_B_BIT (1 << BOARD_LED_B) +/* Board revision detection pin + * 0 equals UCANS32K146-01 + * 1 equals UCANS32K146B + */ +#define BOARD_REVISION_DETECT_PIN (GPIO_INPUT | PIN_PORTA | PIN10 ) + /* If CONFIG_ARCH_LEDs is defined, then NuttX will control the LEDs on board * the RDDRONE-UAVCAN146. The following definitions describe how NuttX * controls the LEDs: @@ -138,11 +144,9 @@ /* CAN selections ***********************************************************/ #define PIN_CAN0_TX PIN_CAN0_TX_4 /* PTE5 */ #define PIN_CAN0_RX PIN_CAN0_RX_4 /* PTE4 */ -#define PIN_CAN0_ENABLE (GPIO_OUTPUT | PIN_PORTE | PIN11 ) -#define CAN0_ENABLE_OUT 0 +#define PIN_CAN0_STB (GPIO_OUTPUT | PIN_PORTE | PIN11 ) #define PIN_CAN1_TX PIN_CAN1_TX_1 /* PTA13 */ #define PIN_CAN1_RX PIN_CAN1_RX_1 /* PTA12 */ -#define PIN_CAN1_ENABLE (GPIO_OUTPUT | PIN_PORTE | PIN10 ) -#define CAN1_ENABLE_OUT 0 +#define PIN_CAN1_STB (GPIO_OUTPUT | PIN_PORTE | PIN10 ) #endif /* __BOARDS_ARM_RDDRONE_UAVCAN146_INCLUDE_BOARD_H */ diff --git a/boards/arm/s32k1xx/rddrone-uavcan146/src/s32k1xx_bringup.c b/boards/arm/s32k1xx/rddrone-uavcan146/src/s32k1xx_bringup.c index 24485d16fd..e449d5c071 100644 --- a/boards/arm/s32k1xx/rddrone-uavcan146/src/s32k1xx_bringup.c +++ b/boards/arm/s32k1xx/rddrone-uavcan146/src/s32k1xx_bringup.c @@ -23,7 +23,7 @@ ****************************************************************************/ #include - +#include #include #include @@ -147,5 +147,23 @@ int s32k1xx_bringup(void) s32k1xx_eeeprom_register(0, 4096); #endif +#ifdef CONFIG_S32K1XX_FLEXCAN + s32k1xx_pinconfig(BOARD_REVISION_DETECT_PIN); + + if (s32k1xx_gpioread(BOARD_REVISION_DETECT_PIN)) + { + /* STB high -> active CAN phy */ + + s32k1xx_pinconfig(PIN_CAN0_STB | GPIO_OUTPUT_ONE); + } + else + { + /* STB low -> active CAN phy */ + + s32k1xx_pinconfig(PIN_CAN0_STB | GPIO_OUTPUT_ZERO); + } + +#endif + return ret; }