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.

Committer:
danielmckinnell
Date:
Tue Aug 04 04:42:52 2020 +0000
Revision:
4:7621103c5a40
Parent:
0:0453a0a7e500
RTU Serial updates

Who changed what in which revision?

UserRevisionLine numberNew contents of line
cam 0:0453a0a7e500 1 /*
cam 0:0453a0a7e500 2 * FreeModbus Libary: BARE Port
cam 0:0453a0a7e500 3 * Copyright (C) 2006 Christian Walter <wolti@sil.at>
cam 0:0453a0a7e500 4 *
cam 0:0453a0a7e500 5 * This library is free software; you can redistribute it and/or
cam 0:0453a0a7e500 6 * modify it under the terms of the GNU Lesser General Public
cam 0:0453a0a7e500 7 * License as published by the Free Software Foundation; either
cam 0:0453a0a7e500 8 * version 2.1 of the License, or (at your option) any later version.
cam 0:0453a0a7e500 9 *
cam 0:0453a0a7e500 10 * This library is distributed in the hope that it will be useful,
cam 0:0453a0a7e500 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
cam 0:0453a0a7e500 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
cam 0:0453a0a7e500 13 * Lesser General Public License for more details.
cam 0:0453a0a7e500 14 *
cam 0:0453a0a7e500 15 * You should have received a copy of the GNU Lesser General Public
cam 0:0453a0a7e500 16 * License along with this library; if not, write to the Free Software
cam 0:0453a0a7e500 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
cam 0:0453a0a7e500 18 *
cam 0:0453a0a7e500 19 * File: $Id: portevent.c,v 1.1 2006/08/22 21:35:13 wolti Exp $
cam 0:0453a0a7e500 20 */
cam 0:0453a0a7e500 21
cam 0:0453a0a7e500 22 /* ----------------------- Modbus includes ----------------------------------*/
cam 0:0453a0a7e500 23 #include "mb.h"
cam 0:0453a0a7e500 24 #include "mbport.h"
cam 0:0453a0a7e500 25
cam 0:0453a0a7e500 26 /* ----------------------- Variables ----------------------------------------*/
cam 0:0453a0a7e500 27 static eMBEventType eQueuedEvent;
cam 0:0453a0a7e500 28 static BOOL xEventInQueue;
cam 0:0453a0a7e500 29
cam 0:0453a0a7e500 30 /* ----------------------- Start implementation -----------------------------*/
cam 0:0453a0a7e500 31 BOOL
cam 0:0453a0a7e500 32 xMBPortEventInit( void )
cam 0:0453a0a7e500 33 {
cam 0:0453a0a7e500 34 xEventInQueue = FALSE;
cam 0:0453a0a7e500 35 return TRUE;
cam 0:0453a0a7e500 36 }
cam 0:0453a0a7e500 37
cam 0:0453a0a7e500 38 BOOL
cam 0:0453a0a7e500 39 xMBPortEventPost( eMBEventType eEvent )
cam 0:0453a0a7e500 40 {
cam 0:0453a0a7e500 41 xEventInQueue = TRUE;
cam 0:0453a0a7e500 42 eQueuedEvent = eEvent;
cam 0:0453a0a7e500 43 return TRUE;
cam 0:0453a0a7e500 44 }
cam 0:0453a0a7e500 45
cam 0:0453a0a7e500 46 BOOL
cam 0:0453a0a7e500 47 xMBPortEventGet( eMBEventType * eEvent )
cam 0:0453a0a7e500 48 {
cam 0:0453a0a7e500 49 BOOL xEventHappened = FALSE;
cam 0:0453a0a7e500 50
cam 0:0453a0a7e500 51 if( xEventInQueue )
cam 0:0453a0a7e500 52 {
cam 0:0453a0a7e500 53 *eEvent = eQueuedEvent;
cam 0:0453a0a7e500 54 xEventInQueue = FALSE;
cam 0:0453a0a7e500 55 xEventHappened = TRUE;
cam 0:0453a0a7e500 56 }
cam 0:0453a0a7e500 57 return xEventHappened;
cam 0:0453a0a7e500 58 }