2015-04-07 20:16:15 +02:00
|
|
|
/****************************************************************************
|
2015-04-07 23:01:39 +02:00
|
|
|
* apps/modbus/nuttx/port.h
|
2015-04-07 20:16:15 +02:00
|
|
|
*
|
2015-04-07 23:01:39 +02:00
|
|
|
* FreeModbus Library: NuttX Port
|
2015-04-07 23:57:52 +02:00
|
|
|
* Copyright (c) 2006 Christian Walter <wolti@sil.at>
|
|
|
|
* All rights reserved.
|
2012-07-21 18:18:16 +02:00
|
|
|
*
|
2015-04-07 23:57:52 +02:00
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
2012-07-21 16:56:21 +02:00
|
|
|
*
|
2015-04-07 23:57:52 +02:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
2012-07-21 16:56:21 +02:00
|
|
|
*
|
2015-04-07 20:16:15 +02:00
|
|
|
****************************************************************************/
|
2012-07-21 16:56:21 +02:00
|
|
|
|
2012-07-21 18:18:16 +02:00
|
|
|
#ifndef __APPS_MODBUS_NUTTX_PORT_H
|
|
|
|
#define __APPS_MODBUS_NUTTX_PORT_H
|
2012-07-21 16:56:21 +02:00
|
|
|
|
2015-04-07 20:16:15 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
2012-07-21 18:18:16 +02:00
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdint.h>
|
2012-07-21 16:56:21 +02:00
|
|
|
#include <assert.h>
|
|
|
|
|
2015-04-07 20:16:15 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Pre-processor Definitions
|
|
|
|
****************************************************************************/
|
2012-07-21 18:18:16 +02:00
|
|
|
|
2012-07-21 16:56:21 +02:00
|
|
|
#ifdef __cplusplus
|
2015-09-03 15:00:39 +02:00
|
|
|
extern "C"
|
|
|
|
{
|
2012-07-21 16:56:21 +02:00
|
|
|
#endif
|
2012-07-21 18:18:16 +02:00
|
|
|
|
2015-09-03 15:00:39 +02:00
|
|
|
#define INLINE
|
|
|
|
|
2012-07-21 16:56:21 +02:00
|
|
|
#define ENTER_CRITICAL_SECTION( ) vMBPortEnterCritical()
|
|
|
|
#define EXIT_CRITICAL_SECTION( ) vMBPortExitCritical()
|
2012-07-21 18:18:16 +02:00
|
|
|
|
2012-07-21 23:23:18 +02:00
|
|
|
#ifndef true
|
|
|
|
# define true true
|
2012-07-21 16:56:21 +02:00
|
|
|
#endif
|
2012-07-21 18:18:16 +02:00
|
|
|
|
2012-07-21 23:23:18 +02:00
|
|
|
#ifndef false
|
|
|
|
# define false false
|
2012-07-21 16:56:21 +02:00
|
|
|
#endif
|
2012-07-21 18:18:16 +02:00
|
|
|
|
2015-04-07 20:16:15 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Public Types
|
|
|
|
****************************************************************************/
|
2012-07-21 18:18:16 +02:00
|
|
|
|
|
|
|
typedef enum
|
2012-07-21 16:56:21 +02:00
|
|
|
{
|
2012-07-21 18:18:16 +02:00
|
|
|
MB_LOG_ERROR = 0,
|
|
|
|
MB_LOG_WARN = 1,
|
|
|
|
MB_LOG_INFO = 2,
|
|
|
|
MB_LOG_DEBUG = 3
|
2012-07-21 16:56:21 +02:00
|
|
|
} eMBPortLogLevel;
|
|
|
|
|
2015-04-07 20:16:15 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Public Function Prototypes
|
|
|
|
****************************************************************************/
|
2012-07-21 16:56:21 +02:00
|
|
|
|
2012-07-21 18:18:16 +02:00
|
|
|
void vMBPortEnterCritical(void);
|
|
|
|
void vMBPortExitCritical(void);
|
2015-04-07 23:01:39 +02:00
|
|
|
void vMBPortLog(eMBPortLogLevel eLevel, const char *szModule,
|
2022-12-12 20:06:32 +01:00
|
|
|
const char *szFmt, ...) printf_like(3, 4);
|
2012-07-21 18:18:16 +02:00
|
|
|
void vMBPortTimerPoll(void);
|
2012-07-21 23:23:18 +02:00
|
|
|
bool xMBPortSerialPoll(void);
|
|
|
|
bool xMBPortSerialSetTimeout(uint32_t dwTimeoutMs);
|
2012-07-21 16:56:21 +02:00
|
|
|
|
2016-11-03 14:54:32 +01:00
|
|
|
#if defined(CONFIG_MB_RTU_MASTER) || defined(CONFIG_MB_ASCII_MASTER)
|
|
|
|
void vMBMasterPortEnterCritical(void);
|
|
|
|
void vMBMasterPortExitCritical(void);
|
|
|
|
void vMBMasterPortLog(eMBPortLogLevel eLevel, const char *szModule,
|
2022-12-12 20:06:32 +01:00
|
|
|
const char *szFmt, ...) printf_like(3, 4);
|
2016-11-03 14:54:32 +01:00
|
|
|
void vMBMasterPortTimerPoll(void);
|
|
|
|
bool xMBMasterPortSerialPoll(void);
|
|
|
|
bool xMBMasterPortSerialSetTimeout(uint32_t dwTimeoutMs);
|
|
|
|
#endif
|
|
|
|
|
2012-07-21 16:56:21 +02:00
|
|
|
#ifdef __cplusplus
|
2015-09-03 15:00:39 +02:00
|
|
|
}
|
2012-07-21 16:56:21 +02:00
|
|
|
#endif
|
2015-04-07 20:16:15 +02:00
|
|
|
|
|
|
|
#endif /* __APPS_MODBUS_NUTTX_PORT_H */
|