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_* 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 committed Dec 30, 2021
1 parent f2da887 commit 6304cb4
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 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)

#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)

#define GS_CAN_FLAG_OVERFLOW 1
#define GS_CAN_FLAG_OVERFLOW (1<<0)
#define GS_CAN_FLAG_FD (1<<1)
#define GS_CAN_FLAG_BRS (1<<2)
#define GS_CAN_FLAG_ESI (1<<3)

#define CAN_EFF_FLAG 0x80000000U /* EFF/SFF is set in the MSB */
#define CAN_RTR_FLAG 0x40000000U /* remote transmission request */
Expand Down Expand Up @@ -229,6 +233,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 6304cb4

Please sign in to comment.