?? lin_master.h
字號:
/****************************************************************/
/* 項目名稱 : R8C/23 CAN/LIN Demo Board */
/* : 樣例程序3 */
/* : LIN主機 */
/* 硬件環境 : R0K521237C000BB */
/* MCU型號 : R5F21237JFP */
/* C編譯器 : NC30WA,版本5.30.r02及以上 */
/* 文件名 : lin_master.h */
/* 版本 : 1.0 */
/* 作者 : wangsy */
/* 修訂歷史 : */
/* 修訂者 時間 版本 說明 */
/* wangsy 2006/9/11 1.0 初版發行 */
/* */
/****************************************************************/
/* Copyright, 2006 RENESAS TECHNOLOGY CORPORATION & */
/* RENESAS SOLUTIONS CORPORATION */
/****************************************************************/
#ifndef _LIN_MASTER_H_
#define _LIN_MASTER_H_
/* lin_status */
#define lin_SLEEP 0 // 休眠態
#define lin_RESET 1 // 初始化
#define lin_RUN 2 // 運行態
#define lin_IDLE 3 // IDLE態
#define lin_ERROR 4 // 錯誤態
/* lin command */
#define CMD_NO_COMMAND 0 // 無命令
#define CMD_SLEEP 1 // 休眠命令
#define CMD_RESET 2 // 初始化命令
#define CMD_RUN 3 // 運行命令
#define CMD_IDLE 4 // IDLE命令
#define CMD_ERROR 5 // 錯誤命令
#define CMD_WAKEUP 6 // 喚醒命令
//error_code
#define NO_ERROR 0 // 無錯
#define UART_OVERRUN_ERROR 1 // UART 過載錯誤
#define UART_PARITY_ERROR 2 // UART 奇偶校驗錯誤
#define UART_FRAMING_ERROR 3 // UART 傳輸錯誤
#define LINRX_CHECKSUM_ERROR 4 // 校驗和錯誤
#define SHORT_MESSAGE_ERROR 5 // 消息不全錯誤
// sleep_status
#define SLEEP_RCV_WAKEUP 0 // sleep接收wakeup
#define SLEEP_SND_WAKEUP 1 // sleep發送wakeup
//run_status
#define RUN_IDLE 0 // 運行期IDLE態
#define RUN_SND_BREAK 1 // 發送break狀態
#define RUN_TX_SYNC 2 // 發送同步段狀態
#define RUN_TX_PID 3 // 發送PID狀態
#define RUN_RX_DATA 4 // 接收數據狀態
#define RUN_TX_DATA 5 // 發送數據狀態
#define RUN_TX_CHECKSUM 6 // 發送校驗和狀態
#define SYNC_TIME 0x55 // 同步段字節
#define TOTAL_SCH 4 // schedule總數
#define SCHEDULE_0 0 // schedule0
#define SCHEDULE_1 1 // schedule1
#define SCHEDULE_2 2 // schedule2
#define SCHEDULE_3 3 // schedule3
#define TIMERRB_INT_PRIORITY 3 // timerRB中斷優先級
#define INIT_UART0_BITRATE 130 // 初始uart波特率
typedef struct
{
union
{
uchar8 byte;
struct
{
uchar8 cmd0:1;
uchar8 cmd1:1;
uchar8 cmd2:1;
uchar8 cmd3:1;
uchar8 dummy:4;
} bit;
} cmd; // ID
union
{
uchar8 byte;
struct
{
uchar8 dlc0:1;
uchar8 dlc1:1;
uchar8 dummy:6;
} bit;
} dlc; // 數據段數據字節數
uchar8 data[8]; // 數據
}lin_std_frm_def;
/*--------------LIN 緩沖器--------------*/
typedef struct
{
union
{
struct
{
uchar8 ID0:1; //cmd0
uchar8 ID1:1; //cmd1
uchar8 ID2:1; //cmd2
uchar8 ID3:1; //cmd3
uchar8 ID4:1; //dlc0
uchar8 ID5:1; //dlc1
uchar8 P0:1; //parity0
uchar8 P1:1; //parity1
} bit;
struct
{
uchar8 cmd:4;
uchar8 dlc:2;
uchar8 parity:2;
} pid_str;
uchar8 byte;
} pid; // PID
uchar8 data[8]; // 數據
uchar8 checksum; // 校驗和
} lin_slot_def;
typedef struct
{
lin_slot_def lin_slot[3];
} lin_buffer_def;
typedef union{
struct{
uchar8 complete:1; //0: 進度表正在執行中/1: 進度表結束
uchar8 loop:1; //0: 非循環執行/1:循環執行
uchar8 total_sch:2; //總進度表數 00: 1sch / 01: 2sch / 10:3sch / 11:4sch
uchar8 cur_sch:2; //當前正在執行的進度表 00: sch1 / 01: sch2 / 10:sch3 / 11:sch4
uchar8 dummy:2;
} bit;
uchar8 byte;
}sch_flg; // 進度表狀態
typedef union{
struct{
uchar8 complete:1; //0: 幀正在傳輸中/1: 幀傳輸完畢
uchar8 total_frm:2; //總幀數 00: 1frm / 01: 2frm / 10: 3frm /11: reserved
uchar8 cur_frm:2; //當前正在執行的幀 00: frm1 / 01: frm2 / 10: frm3 /11: reserved
uchar8 dummy:3;
} bit;
uchar8 byte;
}frm_flg; // 幀狀態
/*-----------------函數聲明-----------------*/
//UART0初始化
void uart_init(void);
//timerRA 初始化
void timerRA_rcv_wakeup_config(void);
//lin 狀態轉換函數
void lin_sts_convert(uchar8 lin_in_cur_sch, uchar8 app_event);
/*-----------------外部引用變量聲明-----------------*/
extern uchar8 lin_cmd; // lin 命令
extern uchar8 lin_sts; // lin 狀態
extern uchar8 linM[7][5]; // 命令狀態轉換table
#endif
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -