Skip to content

Commit

Permalink
gs_usb.h: introduce CAN-FD support
Browse files Browse the repository at this point in the history
The CANtact FD and other devices implement a gs-usb compatible USB
protocol. The protocol has been extended to support CAN-FD and the
changes on the Linux gs_usb driver will be mainlined soon.

This patch adds the new GS_CAN_MODE_*, GS_CAN_FEATURE_*,
GS_USB_BREQ_DATA_BITTIMING, and GS_CAN_FLAG_* bits as well as struct
gs_host_frame_canfd to the candlelight driver.

This is mainly for documentation purpose, as the STM32F042 and
STM32F072 don't support CAN-FD. But there are some ports to CAN-FD
capable STM32 µC that can make use of these definitions.

[1] linklayer/gs_usb_fd#2
  • Loading branch information
marckleinebudde authored and fenugrec committed Jan 12, 2022
1 parent 335dc50 commit 41f9e7d
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions include/gs_usb.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ THE SOFTWARE.
/* #define GS_CAN_FEATURE_IDENTIFY (1<<5) */
/* #define GS_CAN_FEATURE_USER_ID (1<<6) */
#define GS_CAN_MODE_PAD_PKTS_TO_MAX_PKT_SIZE (1<<7)
#define GS_CAN_MODE_FD (1<<8) /* switch device to CAN-FD mode */

#define GS_CAN_FEATURE_LISTEN_ONLY (1<<0)
#define GS_CAN_FEATURE_LOOP_BACK (1<<1)
Expand All @@ -50,10 +51,13 @@ THE SOFTWARE.
#define GS_CAN_FEATURE_HW_TIMESTAMP (1<<4)
#define GS_CAN_FEATURE_IDENTIFY (1<<5)
#define GS_CAN_FEATURE_USER_ID (1<<6)

#define GS_CAN_FEATURE_PAD_PKTS_TO_MAX_PKT_SIZE (1<<7)
#define GS_CAN_FEATURE_FD (1<<8) /* device supports CAN-FD */

#define GS_CAN_FLAG_OVERFLOW 1
#define GS_CAN_FLAG_OVERFLOW (1<<0)
#define GS_CAN_FLAG_FD (1<<1) /* is a CAN-FD frame */
#define GS_CAN_FLAG_BRS (1<<2) /* bit rate switch (for CAN-FD frames) */
#define GS_CAN_FLAG_ESI (1<<3) /* error state indicator (for CAN-FD frames) */

#define CAN_EFF_FLAG 0x80000000U /* EFF/SFF is set in the MSB */
#define CAN_RTR_FLAG 0x40000000U /* remote transmission request */
Expand Down Expand Up @@ -146,6 +150,7 @@ enum gs_usb_breq {
GS_USB_BREQ_IDENTIFY,
GS_USB_BREQ_GET_USER_ID,
GS_USB_BREQ_SET_USER_ID,
GS_USB_BREQ_DATA_BITTIMING,
};

enum gs_can_mode {
Expand Down Expand Up @@ -229,6 +234,18 @@ struct gs_host_frame {

} __packed;

struct gs_host_frame_canfd {
u32 echo_id;
u32 can_id;

u8 can_dlc;
u8 channel;
u8 flags;
u8 reserved;

u8 data[64];
} __packed;

struct gs_tx_context {
struct gs_can *dev;
unsigned int echo_id;
Expand Down

0 comments on commit 41f9e7d

Please sign in to comment.