?? tpc.c
字號(hào):
//---------------------------------------------------------------------
// 関數(shù)名: HALF get_int
// 引値 : BYTE *reg [OUT]IntRegister値
// 返値 : 正常終了= 0
// エラー時(shí)= SYSTEM_ERROR 予想外のエラー
// PROTOCOL_ERROR Retry失敗/不可能
//---------------------------------------------------------------------
HALF get_int(BYTE *reg)
{
BYTE stat;
short i;
i = PROTOCOL_RETRY;
while(1) {
stat = read_protocol(TPC_GET_INT,1,reg,&protocol_status);
if (stat != 0) {
return(SYSTEM_ERROR);
} else if ((protocol_status & (PROTOCOL_STAT_TOE|PROTOCOL_STAT_CRC)) == 0) {
return(0);
}
/* TOE,CRC -> Retry */
if (--i <= 0) {
return(PROTOCOL_ERROR);
}
}
}
//---------------------------------------------------------------------
// 関數(shù)名: HALF write_reg
// 引數(shù) : BYTE *data [IN]データバッファ先頭アドレス
// 返値 : 正常終了 = 0
// エラー時(shí) = SYSTEM_ERROR 予想外のエラー
// PROTOCOL_ERROR Retry失敗/不可能
//---------------------------------------------------------------------
HALF write_reg(BYTE *data)
{
short i;
i = PROTOCOL_RETRY;
while(1) {
stat = write_protocol(TPC_WRITE_REG,MSREG_WRITE_SIZE,data,&protocol_status);
if (stat != 0) {
return(SYSTEM_ERROR);
} else if ((protocol_status & PROTOCOL_STAT_TOE) == 0) {
return(0);
}
/* TOE -> Retry */
if (--i <= 0) {
return(PROTOCOL_ERROR);
}
}
}
//---------------------------------------------------------------------
// 関數(shù)名: HALF read_reg
// 引數(shù) : BYTE *data [OUT]データバッファ先頭アドレス
// 返値 : 正常終了 = 0
// エラー時(shí) = SYSTEM_ERROR 予想外のエラー
// PROTOCOL_ERROR Retry失敗/不可能
//---------------------------------------------------------------------
HALF read_reg(BYTE *data)
{
short i;
i = PROTOCOL_RETRY;
while(1) {
stat = read_protocol(TPC_READ_REG,MSREG_READ_SIZE,data,&protocol_status);
if (stat != 0) {
return(SYSTEM_ERROR);
} else if ((protocol_status & (PROTOCOL_STAT_TOE|PROTOCOL_STAT_CRC)) == 0) {
return(0);
}
/* TOE,CRC -> Retry */
if (--i <= 0) {
return(PROTOCOL_ERROR);
}
}
}
//---------------------------------------------------------------------
// 関數(shù)名: HALF set_cmd
// 引數(shù) : BYTE command [IN]コマンド値
// 返値 : 正常終了 = 0
// エラー時(shí) = SYSTEM_ERROR 予想外のエラー
// PROTOCOL_ERROR Retry失敗/不可能
//---------------------------------------------------------------------
HALF set_cmd(BYTE cmd)
{
short i;
i = PROTOCOL_RETRY;
while(1) {
stat = write_protocol(TPC_SET_CMD,1,&cmd,&protocol_status);
if (stat != 0) {
return(SYSTEM_ERROR);
} else if ((protocol_status & PROTOCOL_STAT_TOE) == 0) {
return(0);
}
/* TOE -> Retry */
if (--i <= 0) {
return(PROTOCOL_ERROR);
}
}
}
//---------------------------------------------------------------------
// 関數(shù)名: HALF read_page_data
// 引數(shù) : BYTE *data [OUT]データバッファ先頭アドレス
// 返値 : 正常終了= 0
// エラー時(shí)= SYSTEM_ERROR 予想外のエラー
// PROTOCOL_ERROR Retry失敗/不可能
//---------------------------------------------------------------------
HALF read_page_data(BYTE *data)
{
short i;
i = PROTOCOL_RETRY;
while(1) {
stat = read_protocol(TPC_READ_PAGE_DATA,PAGE_SIZE,data,&protocol_status);
if (stat != 0) {
return(SYSTEM_ERROR);
} else if ((protocol_status & (PROTOCOL_STAT_TOE|PROTOCOL_STAT_CRC)) == 0) {
return(0);
} else if (protocol_status & PROTOCOL_STAT_CRC) {
return(PROTOCOL_ERROR);
}
/* TOE -> Retry */
if (--i <= 0) {
return(PROTOCOL_ERROR);
}
}
}
//---------------------------------------------------------------------
// 関數(shù)名: HALF write_page_data
// 引數(shù) : BYTE *data [IN]データバッファ先頭アドレス
// 返値 : 正常終了 = 0
// エラー時(shí) = SYSTEM_ERROR 予想外のエラー
// PROTOCOL_ERROR Retry失敗/不可能
//---------------------------------------------------------------------
HALF write_page_data(BYTE *data)
{
short i;
i = PROTOCOL_RETRY;
while(1) {
stat = write_protocol(TPC_WRITE_PAGE_DATA,PAGE_SIZE,data,&protocol_status);
if (stat != 0) {
return(SYSTEM_ERROR);
} else if ((protocol_status & PROTOCOL_STAT_TOE) == 0) {
return(0);
}
/* TOE -> Retry */
if (--i <= 0) {
return(PROTOCOL_ERROR);
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -