The Hart Slave 1.0 is a HART communication protocol driver for embedded systems with 8 or 16 bit microcontrollers such as 8031 or M16C family. The driver is implementing the HART protocol communication layer 2, thus hiding the bit and byte details of the protocol from the programmer. The software is featuring the following.
The implementation is compatible to the HART Protocol Revision 6 and 7 which allows to implement HART Protocol Revision 6 and 7 features in the marshaling command interpreter.
Two masters are supported automatically by the driver. The cold start flag and the data changed flag are handled individually for each master.
A busy signal is automatically sent to the requesting master if the application is not providing the data within a certain time limit. The driver is saving the command number and responding automatically with the right data if the command is repeated.
The driver needs only a very view resources.
As an example an additional PC simulation of the HART protocol slave is included in the package!
The driver is not supporting burst mode.
The download is
available on the Borst Automation (Walter Borst) homepage at the download tab:
https://www.borst-automation.de/downloads/.
Goto to Borst Automation Home:
https://www.borst-automation.de/.
----------
The following shows the global get character function which is called by the receiver interrupt each time when a character is received by the UART.
void
g_HartLoL_getChar()
{ /* Any time a character is received */
/* the gap time out is tarted anew. */
startTimeOut(HRT_TO_GAP,
HRT_TO_STATE_GAP);
m_ucInChar = M_HRT_GET_RCV_CHAR;
m_ucInErr = M_HRT_GET_RCV_ERROR;
switch(strHrtComSM.ucState)
{ case HRT_IO_IDLE:
/* Clear character count in idle state */
strHrtComSM.ucCount = 0;
if(m_ucInChar ==
HRT_PREAMBLE)
{ /* Preamble received, wait for next */
strHrtComSM.ucState =
HRT_WAIT_NEXT_PREAMBLE;
}
break;
case
HRT_WAIT_NEXT_PREAMBLE:
if(m_ucInChar ==
HRT_PREAMBLE)
{ /* Two preambles received, wait for
delimiter */
strHrtComSM.ucState = HRT_RCV_WAIT_DEL;
}
else
{ strHrtComSM.ucState = HRT_IO_IDLE;
}
break;
case
HRT_RCV_WAIT_DEL:
if (isValidDel())
{ getFirstChar();
strHrtComSM.ucState = HRT_RCV_READING;
}
else
{ /* Waiting for the delimiter only
preambles are allowed */
if(m_ucInChar !=
HRT_PREAMBLE)
{ /* Clear state to idle */
strHrtComSM.ucState =
HRT_IO_IDLE;
}
}
break;
case
HRT_RCV_READING:
/* Ignore character if any error is flagged
*/
if(!(m_ucInErr &
0x20))
{ getNextChar();
}
break;
case
HRT_IO_LOCKED:
break;
}
}
The source code of this software is free of charge.