📄 pc_m1.c
字号:
memCopy(((sReadMemEx *)(PCMasterComm->p_dataBuff))->addrByte,
(unsigned char *)&varaddr, POINT32_LEN);
/* copy data */
memCopy( varaddr,(((sReturnData *)(PCMasterComm->p_dataBuff))->data),(Int8) length);
respPrepare(PCMDRV_STC_OK,(UInt8)(length+1)); /* OK */
}
else {
/* response greater than buffer */
/* response buffer overflow */
respPrepare(PCMDRV_STC_RSPBUFFOVF,1);
}
}break;
case PCMDRV_CMD_WRITEMEMEX: { /* write block of memory */
/* read length of memory block from the message */
memCopy(&(((sWriteMemEx *)(PCMasterComm->p_dataBuff))->size),
(unsigned char *)&length, BYTE_LEN);
/* read address */
memCopy((((sWriteMemEx *)(PCMasterComm->p_dataBuff))->addrByte),
(unsigned char *)&varaddr, POINT32_LEN);
/* copy data */
memCopy((((sWriteMemEx *)(PCMasterComm->p_dataBuff))->data),
varaddr, (Int8)length);
respPrepare(PCMDRV_STC_OK,1);
}break;
case PCMDRV_CMD_WRITEMEMMASKEX: { /* write to memory with mask */
unsigned char i, tmpData;
/* read length of memory block from the message */
memCopy(&(((sWriteMemEx *)(PCMasterComm->p_dataBuff))->size),
(unsigned char *)&length, BYTE_LEN);
/* read address */
memCopy((((sWriteMemEx *)(PCMasterComm->p_dataBuff))->addrByte),
(unsigned char *)&varaddr, POINT32_LEN);
for (i=0; i<length; i++) {
/* read data */
tmpData = ((sWriteMemEx *)(PCMasterComm->p_dataBuff))->data[i]; /* read data */
tmpData &= ((sWriteMemEx *)(PCMasterComm->p_dataBuff))->data[i + length]; /* read mask */
archDisableInt();
tmpData |= (*varaddr) & ~(((sWriteMemEx *)(PCMasterComm->p_dataBuff))->data[i + length]);
*varaddr = tmpData; /* write back modified data */
// archEnableInt();
}
respPrepare(PCMDRV_STC_OK,1); /* OK */
}break;
#ifdef PCMDRV_INCLUDE_CMD_APPCMD
case PCMDRV_CMD_CALLAPPCMD: { /* call user application command */
if (PCMasterComm->appCmdSize == 0) { /* buffer is not initialized (zero length) */
respPrepare(PCMDRV_STC_INVCMD,1); /* invalid command */
break;
}
memCopy( (unsigned char *)&(((sCallAppCmd *)(PCMasterComm->p_dataBuff))->cmdLen),
(unsigned char *)&length, BYTE_LEN);
if ( length > PCMasterComm->appCmdSize) { /* check Application Command length */
respPrepare(PCMDRV_STC_INVBUFF,1); /* invalid buffer size */
}
else {
if (pcmdrvAppCmdSts == PCMDRV_APPCMD_RUNNING) { /* Application Command already called */
respPrepare(PCMDRV_STC_SERVBUSY,1); /* service is busy */
}
else { /* no Application Command was called */
/* copy Application Command data to Application Command buffer */
memCopy( (((sCallAppCmd *)(PCMasterComm->p_dataBuff))->appCmdData),
PCMasterComm->p_appCmdBuff,(Int8) length);
pcmdrvAppCmdSts = PCMDRV_APPCMD_RUNNING;
respPrepare(PCMDRV_STC_OK,1); /* OK */
}
}
}break;
#endif
default: { /* invalid command */
respPrepare(PCMDRV_STC_INVCMD,1); /* invalid command */
}break;
}
}
/*
** ===================================================================
** Method : messageData (bean PC_Master)
**
** Description :
** This method is internal. It is used by Processor Expert only.
** ===================================================================
*/
static void messageData(UWord16 startOfMessage)
{
if (startOfMessage == 0) { /* no start of message */
if (status & ST_STARTED) { /* start of message already detected */
if (pos != length) { /* read byte, accumulate checksum */
(PCMasterComm)->p_dataBuff[pos] = (UInt8)inChar;
checkSum += inChar; /* checksum accumulation */
pos++; /* next position in buffer */
if (status & ST_STD_CMD) { /* inChar contains length of standard format message */
length = (UInt8)(inChar + 2); /* read length of message */
bitClear(ST_STD_CMD,status); /* clear flag */
if (length > ((PCMasterComm)->dataBuffSize)) { /* command is greater than input buffer */
/* clear flag */
bitClear(ST_STARTED | ST_ST_CHAR_REC,status);
/* input buffer overflow */
respPrepare(PCMDRV_STC_CMDBUFFOVF,1);
/* send response to PC */
sendResponse(&response);
}
}
}
else { /* end of message */
checkSum += inChar; /* accumulate checksum */
if ((checkSum & 0x00FF) == 0) { /* correct checksum */
messageDecode();
}
else { /* checksum error */
/* checksum error response */
respPrepare(PCMDRV_STC_CMDSERR,1);
}
/* clear flag */
bitClear(ST_STARTED | ST_ST_CHAR_REC,status);
sendResponse(&response); /* send response to PC */
}
}
}
else { /* start of message */
/* reset receiver, read first byte of message */
bitSet(ST_STARTED,status); /* message receiving */
/* read byte, start of checksum accumulating */
checkSum = (PCMasterComm)->p_dataBuff[0] = (UInt8)inChar;
/* next position in buffer */
pos = 1;
/* value sufficient for standard format commands */
length = 2;
if (inChar >= 0xC0) { /* special format command */
length=(UInt8)(((inChar & 0x30) >> 3) + 1); /* length decoding */
}
else { /* standard format command (next byte will be length of the message) */
bitSet(ST_STD_CMD,status); /* wait for next character */
}
}
}
/*
** ===================================================================
** Method : readRecSample (bean PC_Master)
**
** Description :
** This method is internal. It is used by Processor Expert only.
** ===================================================================
*/
static UWord16 readRecSample(UWord16 position)
{
Word16 i;
for (i=0 ; i < (((pcmdrv_sRecorder *)(PCMasterComm->p_recorder))->varCnt) ; i++) { /* read each variable */
/* read each variable */
memCopy((UInt8*)(((sSetupRec *)(PCMasterComm->p_recorder))->varDef[i].varAddr[0]),
(UInt8*)((PCMasterComm->p_recBuff)+position),
(Int8)(((sSetupRec *)(PCMasterComm->p_recorder))->varDef[i].varSize));
position += ((sSetupRec *)(PCMasterComm->p_recorder))->varDef[i].varSize;
}
return(position);
}
void Inhr1_OnError(void)
{
Inhr1_TError Err;
Inhr1_TComData c;
Inhr1_GetError(&Err);
if (Err.errName.OverRun)
(void)Inhr1_RecvChar(&c);
}
void Inhr1_OnRxChar(void)
{
if (PC_M1_SCIRxFullInt) PC_M1_pcmasterdrvIsr();
}
void Inhr1_OnTxChar(void)
{
if (PC_M1_SCITxEmptyInt) PC_M1_pcmasterdrvIsr();
}
/*
** ===================================================================
** Method : PC_M1_PE_Init (bean PC_Master)
**
** Description :
** This method is internal. It is used by Processor Expert only.
** ===================================================================
*/
void PC_M1_PE_Init(void)
{
#if !defined(PCMDRV_BUFFER_SIZE)
#define PCMDRV_BUFFER_SIZE 60
#endif
#if !defined(PC_MASTER_REC_BUFF_LEN)
/* Recorder buffer length */
#define PC_MASTER_REC_BUFF_LEN 40
#endif
#if !defined(PC_MASTER_APPCMD_BUFF_LEN)
/* Application Command buffer length */
#define PC_MASTER_APPCMD_BUFF_LEN 5
#endif
static word pcmdrvDataBuff[(PCMDRV_BUFFER_SIZE / 2) + 1];
static sPCMasterComm PCMSettings; /* initialization structure */
static pcmdrv_sScope pcmdrvScope; /* scope config data */
#if (PC_MASTER_REC_BUFF_LEN != 0)
/* recorder buffer */
static UWord16 PCMasterCommRecorderBuffer[PC_MASTER_REC_BUFF_LEN];
static pcmdrv_sRecorder pcmdrvRecorder; /* recorder config and temp data */
#endif
#if (PC_MASTER_APPCMD_BUFF_LEN != 0)
/* application command data buffer */
static unsigned char PCMasterAppCmdBuff[PC_MASTER_APPCMD_BUFF_LEN];
#endif
#if (PC_MASTER_REC_BUFF_LEN != 0)
/* address of buffer */
PCMSettings.p_recBuff = (unsigned char *)PCMasterCommRecorderBuffer;
PCMSettings.p_recorder = (unsigned char *)&pcmdrvRecorder;
#endif
/* address of input/output buffer */
PCMSettings.p_dataBuff = (unsigned char *)pcmdrvDataBuff;
PCMSettings.dataBuffSize = PCMDRV_BUFFER_SIZE;
/* buffer length */
PCMSettings.recSize = PC_MASTER_REC_BUFF_LEN;
/* recorder time base */
PCMSettings.timeBase = PC_MASTER_RECORDER_TIME_BASE ;
#if (PC_MASTER_APPCMD_BUFF_LEN != 0)
/* address of buffer */
PCMSettings.p_appCmdBuff = PCMasterAppCmdBuff;
#endif
PCMSettings.p_scope = (unsigned char *)&pcmdrvScope;
/* buffer length */
PCMSettings.appCmdSize = PC_MASTER_APPCMD_BUFF_LEN;
/* board firmware version major number */
PCMSettings.globVerMajor = PC_MASTER_GLOB_VERSION_MAJOR;
/* board firmware version minor number */
PCMSettings.globVerMinor = PC_MASTER_GLOB_VERSION_MINOR;
/* device identification string */
strcpy((char *)PCMSettings.idtString,PC_MASTER_IDT_STRING);
/* SCI communication initialization */
SCItxEmptyIsr(INT_DISABLE); /* disable SCI Tx Empty Interrupt */
SCIrxFullIsr(INT_ENABLE);
pcmasterdrvInit(&PCMSettings);
}
/* END PC_M1. */
/*
** ###################################################################
**
** This file was created by UNIS Processor Expert 2.97 [03.74]
** for the Freescale 56800 series of microcontrollers.
**
** ###################################################################
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -