Logo Borst Automation

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 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/.

----------

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 software is free of charge.