px4_fmu-v5:Add Manifest Entries for UAVCAN interfaces

This commit is contained in:
David Sidrane 2020-03-10 15:50:30 -07:00 committed by Daniel Agar
parent 46a09b711f
commit 82ab1413fc
5 changed files with 143 additions and 8 deletions

View File

@ -327,6 +327,8 @@
#define GPIO_CAN2_SILENT_S1 /* PH3 */ (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTH|GPIO_PIN3)
#define GPIO_CAN3_SILENT_S2 /* PH4 */ (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTH|GPIO_PIN4)
#define UAVCAN_NUM_IFACES_RUNTIME 1
/* HEATER
* PWM in future
*/

View File

@ -32,12 +32,35 @@
****************************************************************************/
/**
* @file px4fmu_can.c
* @file can.c
*
* Board-specific CAN functions.
*/
#ifdef CONFIG_CAN
#if !defined(CONFIG_CAN)
#include <stdint.h>
#include "board_config.h"
__EXPORT
uint16_t board_get_can_interfaces(void)
{
uint16_t enabled_interfaces = 0x7;
if (!PX4_MFT_HW_SUPPORTED(PX4_MFT_CAN2)) {
enabled_interfaces &= ~(1 << 1);
}
if (!PX4_MFT_HW_SUPPORTED(PX4_MFT_CAN3)) {
enabled_interfaces &= ~(1 << 2);
}
return enabled_interfaces;
}
#else
#include <errno.h>
#include <debug.h>

View File

@ -77,6 +77,7 @@
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
#define _GPIO_PULL_DOWN_INPUT(def) (((def) & (GPIO_PORT_MASK | GPIO_PIN_MASK)) | (GPIO_INPUT|GPIO_PULLDOWN|GPIO_SPEED_2MHz))
/* Configuration ************************************************************/
@ -231,6 +232,18 @@ __EXPORT int board_app_initialize(uintptr_t arg)
stm32_spiinitialize();
/* Does this board have CAN 2 or CAN 3 if not decouple the RX
* from IP block Leave TX connected
*/
if (!PX4_MFT_HW_SUPPORTED(PX4_MFT_CAN2)) {
px4_arch_configgpio(_GPIO_PULL_DOWN_INPUT(GPIO_CAN2_RX));
}
if (!PX4_MFT_HW_SUPPORTED(PX4_MFT_CAN3)) {
px4_arch_configgpio(_GPIO_PULL_DOWN_INPUT(GPIO_CAN3_RX));
}
/* configure the DMA allocator */
if (board_dma_alloc_init() < 0) {

View File

@ -71,8 +71,28 @@ static const px4_hw_mft_item_t device_unsupported = {0, 0, 0};
// List of components on a specific board configuration
// The index of those components is given by the enum (px4_hw_mft_item_id_t)
// declared in board_common.h
static const px4_hw_mft_item_t hw_mft_list_v0500[] = {
{
// PX4_MFT_PX4IO
.present = 1,
.mandatory = 1,
.connection = px4_hw_con_onboard,
},
{
// PX4_MFT_USB
.present = 1,
.mandatory = 1,
.connection = px4_hw_con_onboard,
},
{
// PX4_MFT_CAN2
.present = 1,
.mandatory = 1,
.connection = px4_hw_con_onboard,
},
{
// PX4_MFT_CAN3
.present = 1,
.mandatory = 1,
.connection = px4_hw_con_onboard,
@ -81,21 +101,67 @@ static const px4_hw_mft_item_t hw_mft_list_v0500[] = {
static const px4_hw_mft_item_t hw_mft_list_v0540[] = {
{
// PX4_MFT_PX4IO
.present = 0,
.mandatory = 0,
.connection = px4_hw_con_unknown,
},
{
// PX4_MFT_USB
.present = 1,
.mandatory = 1,
.connection = px4_hw_con_onboard,
},
{
// PX4_MFT_CAN2
.present = 0,
.mandatory = 0,
.connection = px4_hw_con_unknown,
},
{
// PX4_MFT_CAN3
.present = 0,
.mandatory = 0,
.connection = px4_hw_con_unknown,
},
};
static px4_hw_mft_list_entry_t mft_lists[] = {
{0x0000, hw_mft_list_v0500, arraySize(hw_mft_list_v0500)},
{0x0105, hw_mft_list_v0500, arraySize(hw_mft_list_v0500)}, // Alias for CUAV V5 R:5 V:1
{0x0500, hw_mft_list_v0500, arraySize(hw_mft_list_v0500)}, // Alias for CUAV V5+ R:0 V:5
{0x0400, hw_mft_list_v0540, arraySize(hw_mft_list_v0540)},
{0x0600, hw_mft_list_v0540, arraySize(hw_mft_list_v0540)}, // Alias for CUAV V5nano R:0 V:6
static const px4_hw_mft_item_t hw_mft_list_v0600[] = {
{
// PX4_MFT_PX4IO
.present = 0,
.mandatory = 0,
.connection = px4_hw_con_unknown,
},
{
// PX4_MFT_USB
.present = 1,
.mandatory = 1,
.connection = px4_hw_con_onboard,
},
{
// PX4_MFT_CAN2
.present = 1,
.mandatory = 1,
.connection = px4_hw_con_onboard,
},
{
// PX4_MFT_CAN3
.present = 0,
.mandatory = 0,
.connection = px4_hw_con_unknown,
},
};
static px4_hw_mft_list_entry_t mft_lists[] = {
{0x0000, hw_mft_list_v0500, arraySize(hw_mft_list_v0500)},
{0x0105, hw_mft_list_v0500, arraySize(hw_mft_list_v0500)}, // Alias for CUAV V5 R:5 V:1
{0x0500, hw_mft_list_v0500, arraySize(hw_mft_list_v0500)}, // Alias for CUAV V5+ R:0 V:5
{0x0400, hw_mft_list_v0540, arraySize(hw_mft_list_v0540)}, // HolyBro mini no can 2,3
{0x0600, hw_mft_list_v0600, arraySize(hw_mft_list_v0600)}, // CUAV V5nano R:0 V:6 with can 2
};
/************************************************************************************
* Name: board_query_manifest
*

View File

@ -671,6 +671,8 @@ __EXPORT int board_set_bootload_mode(board_reset_e mode);
typedef enum {
PX4_MFT_PX4IO = 0,
PX4_MFT_USB = 1,
PX4_MFT_CAN2 = 2,
PX4_MFT_CAN3 = 3,
} px4_hw_mft_item_id_t;
typedef enum {
@ -716,6 +718,35 @@ __EXPORT px4_hw_mft_item board_query_manifest(px4_hw_mft_item_id_t id);
# define board_query_manifest(_na) px4_hw_mft_unsupported
#endif
/************************************************************************************
* Name: board_get_can_interfaces
*
* Description:
* Optional returns a bit mask of the enabled can interfaces, that are
* dependent on the on board CAN configuration.
*
* In UAVCAN the number of interfaces is a compile time setting. On some HW
* using the same binary, all the CAN interfaces are not present.
*
* The default is now 3 CAN interfaces and all active, the the build will set
* the actual max number of interfaces.
*
* Input Parameters:
* None
*
* Returned Value:
* A bit mask of the can interfaces enabled for this board.
* i.e CAN1 and CAN2 0x3
* CAN0 and CAN1 0x3
*
************************************************************************************/
#if defined(UAVCAN_NUM_IFACES_RUNTIME)
__EXPORT uint16_t board_get_can_interfaces(void);
#else
inline uint16_t board_get_can_interfaces(void) { return 0x7; }
#endif
/************************************************************************************
* Name: board_get_hw_type_name
*