-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmodbus_slave.h
55 lines (46 loc) · 1.35 KB
/
modbus_slave.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
* modbus_slave.h
*
* Created on: 03/05/2017
* Author: andru
*/
#ifndef MODBUS_SLAVE_H_
#define MODBUS_SLAVE_H_
/* -----------------------Slave Defines -------------------------------------*/
#define MB_MODE MB_RTU // rtu mode only
#define MB_PORT 1 // 1 port only
#define S_DISCRETE_INPUT_START 0
#define S_DISCRETE_INPUT_NDISCRETES 6
#define S_COIL_START 0
#define S_COIL_NCOILS 6
#define S_REG_INPUT_START 0
#define S_REG_INPUT_NREGS 6
#define S_REG_HOLDING_START 0
#define S_REG_HOLDING_NREGS 6
#include "FreeModbus/port/port.h"
//Slave mode:DiscreteInputs variables
extern USHORT usSDiscInStart;
extern UCHAR ucSDiscInBuf[];
//Slave mode:Coils variables
extern USHORT usSCoilStart;
extern UCHAR ucSCoilBuf[];
//Slave mode:InputRegister variables
extern USHORT usSRegInStart;
extern SHORT usSRegInBuf[];
//Slave mode:HoldingRegister variables
extern USHORT usSRegHoldStart;
extern SHORT usSRegHoldBuf[];
typedef enum {
MB_BR_2400,
MB_BR_4800,
MB_BR_9600,
MB_BR_19200,
MB_BR_38400,
} mb_bitrate_t;
typedef enum {
MB_PARITY_NONE, /*!< No parity. */
MB_PARITY_ODD, /*!< Odd parity. */
MB_PARITY_EVEN /*!< Even parity. */
} mb_parity_t;
BOOL initModbus (UCHAR addr, mb_bitrate_t bitrate, mb_parity_t parity);
#endif /* MODBUS_SLAVE_H_ */