Page 1 of 1

CAN Hal STM32 Typedefinition in can_lld.h

Posted: Fri Jun 10, 2016 9:33 am
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

Re: CAN Hal STM32 Typedefinition in can_lld.h

Posted: Fri Jun 10, 2016 1:21 pm
by neums
That whould be useful.

Re: CAN Hal STM32 Typedefinition in can_lld.h

Posted: Sat Jun 11, 2016 8:55 am
by Giovanni
Hi,

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

Giovanni

Re: CAN Hal STM32 Typedefinition in can_lld.h

Posted: Tue Jun 14, 2016 1:02 pm
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

Re: CAN Hal STM32 Typedefinition in can_lld.h

Posted: Tue Jun 14, 2016 1:05 pm
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?

Re: CAN Hal STM32 Typedefinition in can_lld.h

Posted: Tue Jun 14, 2016 1:28 pm
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