/* SPDX-License-Identifier: (GPL-2.0)
 * This file is part of the CAN-CTRL IP Core driver for Linux
 *
 * Copyright (C) Fraunhofer-Institut for Photonic Microsystems (IPMS)
 * Maria-Reiche-Str. 2
 * 01109 Dresden
 *
 * This file is licensed under the terms of the GNU General Public
 * License version 2. This program is licensed "as is" without any
 * warranty of any kind, whether express or implied.
 *
 * @file   can_frame.h
 * @author BOG, SEP, SVT
 * @date   18/01/2024
 * @brief  Basic CAN frame types
 */

#ifndef CAN_FRAME_H
#define CAN_FRAME_H

/**
 * @brief CAN classic frame information structure
 *
 */
typedef struct {
	uint32_t id; /**< CAN frame identifier */
	bool use_ext_id; /**< CAN frame extended identifier: use 29 bit, otherwise 11 bit */
	bool is_remote_frame; /**< CAN remote frame: false - data frame, true remote frame */
	uint8_t len; /**< CAN frame length in byte (0 .. 8) */
} can_frame_info_t;

#define CAN_FD_FLAG_BRS ((uint8_t)1 << 0) /**< CAN FD bit rate switch */

/**
 * @brief CAN FD frame information structure
 *
 */
typedef struct {
	uint32_t id; /**< CAN FD frame identifier */
	bool use_ext_id; /**< CAN frame extended identifier: use 29 bit, otherwise 11 bit */
	uint8_t len; /**< CAN FD frame length in byte (0 .. 64) */
	uint8_t flags; /**< CAN FD flags (0 .. 64) */
} can_fd_frame_info_t;

/**
 * @brief CAN XL frame information structure
 *
 */
typedef struct {
	uint32_t prio; /**< CAN XL priority */
	uint32_t len; /**< CAN XL frame length in byte (1 .. 2048) */
	uint8_t sec; /**< CAN XL simple extended content: 0 - simple, otherwise extended */
	uint32_t acceptance_field; /**< CAN XL frame acceptance field */
	uint8_t sdu_type; /**< CAN XL frame Service Data Unit Type */
	uint8_t vcid; /**< CAN XL frame Virtual CAN Network ID */
} can_xl_frame_info_t;

#endif /* CAN_FRAME */
