Browse Source

AP_HAL: set CANFrame max data length based on CANFD availability

apm_2208
Siddharth Purohit 4 years ago committed by Andrew Tridgell
parent
commit
5bc65bb54e
  1. 9
      libraries/AP_HAL/CANIface.h
  2. 6
      libraries/AP_HAL/board/chibios.h

9
libraries/AP_HAL/CANIface.h

@ -19,6 +19,7 @@
#include <stdint.h> #include <stdint.h>
#include "AP_HAL_Namespace.h" #include "AP_HAL_Namespace.h"
#include "AP_HAL_Boards.h"
class ExpandingString; class ExpandingString;
@ -32,8 +33,13 @@ struct AP_HAL::CANFrame {
static const uint32_t FlagRTR = 1U << 30; ///< Remote transmission request static const uint32_t FlagRTR = 1U << 30; ///< Remote transmission request
static const uint32_t FlagERR = 1U << 29; ///< Error frame static const uint32_t FlagERR = 1U << 29; ///< Error frame
#if HAL_CANFD_SUPPORTED
static const uint8_t NonFDCANMaxDataLen = 8;
static const uint8_t MaxDataLen = 64; static const uint8_t MaxDataLen = 64;
#else
static const uint8_t NonFDCANMaxDataLen = 8;
static const uint8_t MaxDataLen = 8;
#endif
uint32_t id; ///< CAN ID with flags (above) uint32_t id; ///< CAN ID with flags (above)
union { union {
uint8_t data[MaxDataLen]; uint8_t data[MaxDataLen];
@ -138,6 +144,7 @@ struct AP_HAL::CANFrame {
} }
return 64; return 64;
} }
static uint8_t dataLengthToDlc(uint8_t data_length) { static uint8_t dataLengthToDlc(uint8_t data_length) {
if (data_length <= 8) { if (data_length <= 8) {
return data_length; return data_length;

6
libraries/AP_HAL/board/chibios.h

@ -128,9 +128,3 @@
#ifndef HAL_BOARD_STORAGE_DIRECTORY #ifndef HAL_BOARD_STORAGE_DIRECTORY
#define HAL_BOARD_STORAGE_DIRECTORY "/APM" #define HAL_BOARD_STORAGE_DIRECTORY "/APM"
#endif #endif
#if defined(STM32H7XX) || defined(STM32G4)
#define HAL_CANFD_SUPPORTED 1
# else
#define HAL_CANFD_SUPPORTED 0
#endif

Loading…
Cancel
Save