Forking https://os.mbed.com/users/cam/code/Modbus/ to work for NUCLEO 64 boards

Fork of Cam's original FreeModbus port (https://os.mbed.com/users/cam/code/Modbus/)

Change: - Serial implementation to work for NUCLEO 64 boards and receive interrupts instead of timer. (see `portserial.cpp`)

Added: - Custom RTU mode. Allows for external implementation of packet receiving and sending. Sends and receives packets as whole frames (address + PDU) (i.e. this was added for a custom LoRa implementation). implement `xMBRTUCustGetPDU` and `xMBRTUCustSendResponse` (see `mbport.h`) and call `eMBRTUCustomInit( address )`. implementations need to be fully initialised as `eMBRTUCustomInit` only sets the address and nothing else.

Revision:
3:4cda95d7b6c5
Parent:
0:0453a0a7e500
--- a/mb.cpp	Tue Dec 03 09:13:22 2019 +0000
+++ b/mb.cpp	Mon Jan 06 01:17:26 2020 +0000
@@ -42,9 +42,13 @@
 #include "mbproto.h"
 #include "mbfunc.h"
 #include "mbport.h"
+
 #if MB_RTU_ENABLED == 1
 #include "mbrtu.h"
 #endif
+#if MB_RTU_CUSTOM_ENABLED == 1
+#include "mbrtucustom.h"
+#endif
 #if MB_ASCII_ENABLED == 1
 #include "mbascii.h"
 #endif
@@ -182,6 +186,33 @@
     return eStatus;
 }
 
+#if MB_RTU_CUSTOM_ENABLED > 0
+eMBErrorCode
+eMBRTUCustomInit( UCHAR ucSlaveAddress ) {
+    eMBErrorCode    eStatus = MB_ENOERR;
+    ucMBAddress = ucSlaveAddress;
+    eStatus = eMBRTUCustInit( ucSlaveAddress );
+    // if ( ( eStatus = eMBRTUCustInit( ucMBAddress ) ) != MB_ENOERR ) {
+        eMBState = STATE_DISABLED;
+    // } else 
+    if ( !xMBPortEventInit(  ) ) {
+        /* Port dependent event module initalization failed. */
+        eStatus = MB_EPORTERR;
+    }
+     else {
+        pvMBFrameStartCur = eMBRTUCustStart;
+        pvMBFrameStopCur = eMBRTUCustStop;
+        peMBFrameSendCur = eMBRTUCustSend;
+        peMBFrameReceiveCur = eMBRTUCustReceive;
+        pvMBFrameCloseCur = MB_PORT_HAS_CLOSE ? vMBPortClose : NULL;
+
+        eMBCurrentMode = MB_RTU_CUSTOM;
+        eMBState = STATE_DISABLED;
+    }
+    return eStatus;
+}
+#endif
+
 #if MB_TCP_ENABLED > 0
 eMBErrorCode
 eMBTCPInit( USHORT ucTCPPort ) {
@@ -354,4 +385,4 @@
         }
     }
     return MB_ENOERR;
-}
+}
\ No newline at end of file