📄 l_core.h
字号:
/* ************************************************************************ */
/* */
/* Volcano Communications Technologies AB */
/* All rights reserved */
/* */
/* ************************************************************************ */
/* ************************************************************************ *
* File: l_core.h *
* Description: Contains the LIN data structures and definitions of macros *
* for the master and slave behaviours. *
* *
* ************************************************************************ */
#ifndef __L_CORE_H__
#define __L_CORE_H__
#include <l_types.h>
/* ************************************************************************
* Common definitions
*/
#define L_MAX_BUFFER_SIZE 0x08
#define L_SYNC_CHAR 0x55
#define L_WAKE_CHAR 0xf0
#define L_NULL_SCHEDULE ((l_schedule_handle) 0)
/* interface error flags */
#define L_NO_ERROR 0x00
#define L_RESPONSE_ERROR 0x01
#define L_SUCCESSFUL_TRANSFER 0x02
#define L_OVERRUN_ERROR 0x04
#define L_SLEEP_REQUEST 0x08
#define L_WAKEUP_REQUEST 0x10
/* frame ID for unknown frames */
#define L_UNKNOWN_FRAME_ID ((l_u8)0x00)
/* common flags */
#define L_GOTO_SLEEP 0x01
#define L_MRF_ID 0x3c
#define L_SRF_ID 0x7d
/* IOCTL operations */
#define L_IOCTL_SET_SLEEP ((l_ioctl_op)0x11)
#define L_IOCTL_SET_WAKEUP ((l_ioctl_op)0x12)
#define L_IOCTL_RD_STATE ((l_ioctl_op)0x13)
#define L_IOCTL_RD_ACTIVE_SCHEDULE ((l_ioctl_op)0x14)
#define L_IOCTL_SET_GPIO_TX_OUT_RX_IN ((l_ioctl_op)0x15)
#define L_IOCTL_SET_GPIO_TX_PIN ((l_ioctl_op)0x16)
#define L_IOCTL_GET_GPIO_RX_PIN ((l_ioctl_op)0x17)
#define L_IOCTL_RD_BIT_TIME ((l_ioctl_op)0X18)
#define L_IOCTL_UNKNOWN_SERVICE 0xccccu
#define L_IOCTL_ERROR 0xffffu
#define L_INVALID_BITTIME 0x0
/* Types of interface states */
#define L_IDLE 0x00
#define L_BREAK 0x01
#define L_SYNC 0x02
#define L_ID 0x03
#define L_TRANSMIT 0x04
#define L_RECEIVE 0x05
#define L_MONITOR 0x06
#define L_CHECKSUM 0x07
#define L_ERROR 0x08
#define L_TRANSACTION_SUCCESS 0x09
#define L_SLEEP 0x0a
#define L_DISCONNECTED 0x0b
#define L_RE 0x0c
/* Types of frames */
#define L_TX 0x00
#define L_RX 0x01
#define L_MX 0x02
#define L_SX 0x03
#define L_EX 0x04
#define L_SREX 0x05
#define L_DTX 0x06
#define L_DRX 0x07
/* checksum type */
#define L_CLASSIC 0x00
#define L_ENHANCED 0x01
/* Schedule entry type */
/* Normal frame. */
#define L_SCH_ENT_FRM 0x0u
/* Fixed reconfiguration MRF frame. */
#define L_SCH_ENT_REC 0x1u
/* Free format MRF frame with fixed content. */
#define L_SCH_ENT_FFT 0x2u
/* Flag descriptor */
typedef const struct
{
l_u8ram_handle address;
l_u8 mask;
} l_flag, *l_flag_handle;
/* ************************************************************************
* Master definitions
*/
/* Master frame definition */
typedef const struct l_MF
{
l_u8ram_handle fg_buffer;
l_flag *flag_list;
const struct l_MF * *frame_list;
l_flag queued;
l_u8 type;
l_u8 checksum_type;
l_u8 id;
l_u8 size;
} l_master_frame, *l_master_frame_handle;
/* Schedule entry */
typedef const struct
{
l_u8 type;
l_u8 delay;
void *frame;
} l_schedule_entry, *l_schedule_handle;
/* ROM structure for the slave interface*/
typedef const struct
{
l_master_frame_handle mrf;
l_u8 mrf_delay;
} l_master_rom, *l_master_rom_handle;
/* Master interface descriptor */
typedef volatile struct
{
l_master_rom_handle rom;
void *uart_specific;
l_schedule_handle active_schedule;
l_master_frame_handle current_frame;
l_u8 state;
l_u8 bg_buffer[L_MAX_BUFFER_SIZE];
l_u8 next_schedule_entry;
l_u8 bg_buffer_index;
l_u8 checksum;
l_u8 time_to_next_schedule_event;
l_u8 status_flags;
l_u8 latched_frame_id;
l_u8 common_flags;
} l_ifc_master, *l_ifc_master_handle;
/* ************************************************************************
* Slave definitions
*/
/* Slave frame definition */
typedef const struct
{
l_u8ram_handle fg_buffer;
l_flag *flag_list;
l_u8 type;
l_u8 checksum_type;
l_u8 size;
} l_slave_frame, *l_slave_frame_handle;
/* ROM structure for the slave interface*/
typedef const struct
{
l_u8ram_handle response_error_signal;
l_slave_frame_handle response_error_frame;
l_u8 org_nad;
l_u8 response_error_mask;
} l_slave_rom, *l_slave_rom_handle;
/* Slave interface descriptor */
typedef volatile struct
{
void *uart_specific;
l_slave_frame_handle current_frame;
l_slave_rom_handle rom;
l_u8 state;
l_u16 bit_time;
l_u8 bg_buffer[L_MAX_BUFFER_SIZE];
l_u8 bg_buffer_index;
l_u8 checksum;
l_u8 status_flags;
l_u8 current_id;
l_u8 latched_frame_id;
l_u8 nad;
} l_ifc_slave, *l_ifc_slave_handle;
#endif /* __L_CORE_H__ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -