UCANS32K146-01 Add CAN tranceiver self test

This commit is contained in:
Peter van der Perk 2021-09-16 13:49:13 +02:00 committed by David Sidrane
parent c39a21aa54
commit 360c3781f3
3 changed files with 32 additions and 2 deletions

View File

@ -159,8 +159,12 @@
#define PIN_CAN0_TX PIN_CAN0_TX_4 /* PTE5 */
#define PIN_CAN0_RX PIN_CAN0_RX_4 /* PTE4 */
#define PIN_CAN0_STB (GPIO_OUTPUT | PIN_PORTE | PIN11 )
#define PIN_CAN0_ERRN (GPIO_INPUT | PIN_PORTA | PIN11 )
#define PIN_CAN0_EN (GPIO_HIGHDRIVE | PIN_PORTA | PIN10 )
#define PIN_CAN1_TX PIN_CAN1_TX_1 /* PTA13 */
#define PIN_CAN1_RX PIN_CAN1_RX_1 /* PTA12 */
#define PIN_CAN1_STB (GPIO_OUTPUT | PIN_PORTE | PIN10 )
#define PIN_CAN1_ERRN (GPIO_PULLDOWN | PIN_PORTE | PIN6 )
#define PIN_CAN1_EN (GPIO_OUTPUT | PIN_PORTE | PIN2 )
#endif /* __BOARDS_ARM_RDDRONE_UAVCAN146_INCLUDE_BOARD_H */

View File

@ -75,8 +75,32 @@ __EXPORT void s32k1xx_board_initialize(void)
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);
/* Config Pins to do CAN tranceiver HW selftest */
s32k1xx_pinconfig(PIN_CAN0_ERRN);
s32k1xx_pinconfig(PIN_CAN0_STB);
s32k1xx_pinconfig(PIN_CAN0_EN);
/* EN high & STB high -> normal mode */
s32k1xx_gpiowrite(PIN_CAN0_STB, 1);
s32k1xx_gpiowrite(PIN_CAN0_EN, 1);
up_udelay(3000); // Wait for startup to normal mode
/* EN low & STB high -> listen only mode */
s32k1xx_gpiowrite(PIN_CAN0_STB, 1);
s32k1xx_gpiowrite(PIN_CAN0_EN, 0);
up_udelay(100); // t moch ERRN_N
/* Check for HW err and wait untill ERR has been cleared */
while (!s32k1xx_gpioread(PIN_CAN0_ERRN)) {
board_indicate(hardware_failure);
s32k1xx_gpiowrite(PIN_CAN0_EN, 1);
up_udelay(50);
s32k1xx_gpiowrite(PIN_CAN0_EN, 0);
up_udelay(50);
}
/* Enter normal-mode */
s32k1xx_gpiowrite(PIN_CAN0_EN, 1);
} else {
/* STB low -> active CAN phy */
@ -208,6 +232,7 @@ static const led_t i2l[] = {
led(9, fw_update_timeout, 31, 0, 0, 2),
led(a, fw_update_invalid_crc, 31, 0, 0, 4),
led(b, jump_to_app, 0, 63, 0, 10),
led(c, hardware_failure, 31, 0, 0, 10),
};

View File

@ -57,6 +57,7 @@ typedef enum {
fw_update_timeout,
fw_update_invalid_crc,
jump_to_app,
hardware_failure,
} uiindication_t;
#ifndef __ASSEMBLY__