lin_driver.h
来自「芯科原厂所有c8051fxx程序的例子。」· C头文件 代码 · 共 129 行
H
129 行
// Copyright (c) 2006 SILICON LABORATORIES, INC.
//
// FILE NAME : LIN_Driver.h
// TARGET MCU : C8051F52xA-53xA
// DESCRIPTION : Header file for LIN_Driver.c
//
#ifndef _LIN_DRIVER_H_
#define _LIN_DRIVER_H_
//-----------------------------------------------------------------------------
// Constant Definitions
//-----------------------------------------------------------------------------
// LINCTRL Bit Definitions
#define STOP 0x80
#define SLEEP 0x40
#define TXRX 0x20
#define DTACK 0x10
#define RSTINT 0x08
#define RSTERR 0x04
#define WUPREQ 0x02
#define STREQ 0x01
// LINST bits
#define ACTIVE 0x80
#define IDLTOUT 0x40
#define ABORT 0x20
#define DTREQ 0x10
#define LININT 0x08
#define ERROR 0x04
#define WAKEUP 0x02
#define DONE 0x01
// LINERR Bits
#define SYNCH 0x10
#define PRTY 0x08
#define TOUT 0x04
#define CHK 0x02
#define BITERR 0x01
// LINSIZE Bits
#define LINSIZE3_0 0x0F
#define ENCHK 0x80
// LIN Indirect Registers
#define LINDT1 0x00
#define LINDT2 0x01
#define LINDT3 0x02
#define LINDT4 0x03
#define LINDT5 0x04
#define LINDT6 0x05
#define LINDT7 0x06
#define LINDT8 0x07
#define LINCTRL 0x08
#define LINST 0x09
#define LINERR 0x0A
#define LINSIZE 0x0B
#define LINDIV 0x0C
#define LINMUL 0x0D
#define LINID 0x0E
// Return values for l_get_status ()
#define TX_SUCCESS 0x01
#define TX_FRAME_ERROR 0x02
#define TX_TIMEOUT 0x04
// Bitmasks for the frame PID.
#define FRAME_ID 0x3F
#define FRAME_PARITY 0xC0
//-----------------------------------------------------------------------------
// Typedefs
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Macros
//-----------------------------------------------------------------------------
#define _LIN_IREG_READ(addr, target) { LINADDR = addr; target = LINDATA; }
#define _LIN_IREG_WRITE(addr, target) { LINADDR = addr; LINDATA = target; }
#define _LIN_IREG_SET_BITS(addr, target) { LINADDR = addr; temp = LINDATA; LINDATA = (temp | target); }
#define _LIN_IREG_CLEAR_BITS(addr, target) { LINADDR = addr; temp = LINDATA; LINDATA = (temp & ~target); }
//-----------------------------------------------------------------------------
// Function Prototypes
//-----------------------------------------------------------------------------
void l_disable_global_interrupts (void);
void l_restore_global_interrupts (void);
l_u8 l_get_status (void);
void l_clear_status (void);
l_u8 l_read_frame_id (void);
l_u8 l_get_frame_pid (l_u8 frame_id);
l_u8 l_read_frame_data (l_u8 * rx_data);
l_bool l_get_bus_activity (void);
void l_write_frame_id (l_u8 frame_id);
l_bool l_test_parity (l_u8 frame_pid);
void l_write_frame_length (l_u8 frame_len);
void l_write_frame_checksum_type (l_u8 frame_checksum);
void l_write_frame_data (l_u8 frame_len, l_u8 * frame_data);
void l_master_transmit_frame (l_u8 frame_id,
l_u8 frame_len,
l_u8 * frame_data,
l_u8 frame_checksum,
l_u8 frame_direction);
void l_slave_transmit_frame (l_u8 frame_len,
l_u8 * frame_data,
l_u8 frame_checksum);
void l_slave_receive_frame (l_u8 frame_len, l_u8 frame_checksum);
void l_slave_ignore_frame (void);
void l_slave_go_to_sleep (void);
void l_transmit_wake_up (void);
//-----------------------------------------------------------------------------
// Extern Variable Declarations
//-----------------------------------------------------------------------------
extern l_u8 temp;
//-----------------------------------------------------------------------------
// Additional SFR Definitions
//-----------------------------------------------------------------------------
#endif // _LIN_DRIVER_H_
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?