|





| |
Hart Slave 1.0
(Free C-Source, Hart Revision 5)
|
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 which allows to
implement HART Protocol Revision 6 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!
-
Also as an
example the access database file FbFactory.mdb is part of the
package. Using VBA this file is generating some of the C
source code files for the sample application. On of these files is
named HrtSrvIn.c.
-
The driver is
not supporting burst mode. Please ask for a separate quote
if this is required:
info@hart-profibus.com.
|
Example Source Code
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
driver including the access database and the PC-simulation is free of charge.
You may download the software at
http://www.hart-profibus.com/Hart_Slave_Download.htm.
If you like to get more
information about the software interface please have a look into the
interface description.
Diese
Dokumentation ist
auch in Deutsch erhältlich.
Note:
HART is a registered trademark of the HART Communication Foundation.
|
|