CAN Hal STM32 Typedefinition in can_lld.h Topic is solved

Discussions and support about ChibiOS/HAL, the MCU Hardware Abstraction Layer.
Post Reply
User avatar
m-boy
Posts: 2
Joined: Fri Jun 10, 2016 8:04 am
Has thanked: 1 time

CAN Hal STM32 Typedefinition in can_lld.h

Post by m-boy »

Hi,
im wondering, why in the following CAN Message type
has no Union support for uint64 included.
Im working with 64 Bit CAN messages very often and splitting into
32 Bit is little bit fiddly.

There is the example including this Union:

Code: Select all

/*===========================================================================*/
/* Driver data structures and types.                                         */
/*===========================================================================*/

/**
 * @brief   Type of a transmission mailbox index.
 */
typedef uint32_t canmbx_t;

/**
 * @brief   CAN transmission frame.
 * @note    Accessing the frame data as word16 or word32 is not portable because
 *          machine data endianness, it can be still useful for a quick filling.
 */
typedef struct {
  struct {
    uint8_t                 DLC:4;          /**< @brief Data length.        */
    uint8_t                 RTR:1;          /**< @brief Frame type.         */
    uint8_t                 IDE:1;          /**< @brief Identifier type.    */
  };
  union {
    struct {
      uint32_t              SID:11;         /**< @brief Standard identifier.*/
    };
    struct {
      uint32_t              EID:29;         /**< @brief Extended identifier.*/
    };
  };
  union {
    uint8_t                 data8[8];       /**< @brief Frame data.         */
    uint16_t                data16[4];      /**< @brief Frame data.         */
    uint32_t                data32[2];      /**< @brief Frame data.         */
    uint64_t                data;
  };
} CANTxFrame;


Ist the same for RX Frame


Greetings mb
neums
Posts: 137
Joined: Fri May 08, 2015 1:09 pm
Has thanked: 10 times
Been thanked: 5 times

Re: CAN Hal STM32 Typedefinition in can_lld.h

Post by neums »

That whould be useful.
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: CAN Hal STM32 Typedefinition in can_lld.h

Post by Giovanni »

Hi,

I added 64 bit fields to the structures as an array because CAN FD will require larger frames.

Giovanni
User avatar
m-boy
Posts: 2
Joined: Fri Jun 10, 2016 8:04 am
Has thanked: 1 time

Re: CAN Hal STM32 Typedefinition in can_lld.h

Post by m-boy »

Hi,

had a look on Github, but i can´t see any 64 Bit Field in this CAN Frame Types.

https://github.com/ChibiOS/ChibiOS/tree/master/os/hal/ports/STM32/LLD/CANv1

m-boy
neums
Posts: 137
Joined: Fri May 08, 2015 1:09 pm
Has thanked: 10 times
Been thanked: 5 times

Re: CAN Hal STM32 Typedefinition in can_lld.h

Post by neums »

Hi,
but the length of a CAN FD Frame shall have a length up to 64 Bytes:
https://elearning.vector.com/index.php?&wbt_ls_seite_id=1266501&root=378422&seite=vl_can_introduction_en

Has than the type of the frame to be extended to 64 bytes?
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: CAN Hal STM32 Typedefinition in can_lld.h

Post by Giovanni »

Hi,

The update is on the subversion trunk, I don't know when github is updated.

CAN FD requires up to 64 bytes frames, the structure is defined in the LLD so FD implementations can extend it.

Giovanni
Post Reply