IoT Supervisor 0.0
Loading...
Searching...
No Matches
PetitModbusUserPort.h
Go to the documentation of this file.
1
13#ifndef INC_PETITMODBUSUSERPORT_H_
14#define INC_PETITMODBUSUSERPORT_H_
15#include <stdint.h>
16#include <stdbool.h>
17#include <SI_EFM8BB1_Register_Enums.h> // SFR declarations
18#include "hardware.h"
19#include "IoT_Supervisor.h"
20#include "ModbusMiddleWare.h"
21#define NUMBER_OF_COILS ( 1 )
22#define NUMBER_OF_DISCRETE_INPUTS ( 0 )
23// Petit Modbus RTU Slave Output Register Number
24// Have to put a number of registers here
25// It has to be bigger than 0 (zero)!!
26#define NUMBER_OF_PETITREGISTERS ( eMMW_HR_NUM )
27#define NUMBER_OF_INPUT_PETITREGISTERS ( 1 )
28#define NUMBER_OF_REGISTERS_IN_BUFFER ( 3 )
29
30#define PETITMODBUS_READ_COILS_ENABLED ( 1 )
31#define PETITMODBUS_READ_HOLDING_REGISTERS_ENABLED ( 1 )
32#define PETITMODBUS_WRITE_SINGLE_COIL_ENABLED ( 1 )
33#define PETITMODBUS_WRITE_SINGLE_REGISTER_ENABLED ( 1 )
34#define PETITMODBUS_WRITE_MULTIPLE_COILS_ENABLED ( 1 )
35#define PETITMODBUS_WRITE_MULTIPLE_REGISTERS_ENABLED ( 1 )
36#define PETITMODBUS_READ_INPUT_REGISTERS_ENABLED ( 1 )
37// Where to process our modbus message
38// 0 for processing in its own cycle
39// 1 for processing in the same cycle as TX CRC calculation
40#define PETITMODBUS_PROCESS_POSITION ( 0 )
41// Cycles to delay TX once the CRC finishes calculation
42// this can either be a define as stated here or an integer changed by the
43// application code
44// #define PETITMODBUS_DLY_TOP (0)
45// Address of this device
46// this can either be a define as stated here or an integer changed by the
47// application code
48// #define PETITMODBUS_SLAVE_ADDRESS (1)
49// Allow LED functions to be specified by the user
50// 0 to leave blank functions
51// 1 to allow user-defined functions
52#define PETIT_USER_LED PETIT_USER_LED_DEF
53
54// how to process the CRC
55// PETIT_CRC_TABULAR takes up code space but is the fastest.
56// this should probably be your default choice
57// PETIT_CRC_BITWISE takes up cycles but is space efficient
58// PETIT_CRC_EXTERNAL requires you to define PetitPortCRC16Calc.
59// it is possible to use hardware CRC calculation with this.
60#define PETIT_CRC PETIT_CRC_EXTERNAL
61
62#define PETIT_COIL PETIT_EXTERNAL
63
64#define PETIT_REG PETIT_EXTERNAL
65
66#define PETIT_INPUT_REG PETIT_INTERNAL
67
69// define this to let the CRC table reside in code memory rather than RAM
70#define PETIT_CODE code
71// define this for booleans
72#define pb_t bool
73// define this for unsigned octets
74#define pu8_t uint8_t
75// define this for 16-bit unsigned
76#define pu16_t uint16_t
77// substitute the PetitPortCRC16Calc function call for our own
78#define PetitPortCRC16Calc(a, d) KirisakiCRC16Calc(a, d)
79// Cycles to delay TX once the CRC finishes calculation
80extern uint8_t PETITMODBUS_DLY_TOP;
81// Address of this device
82extern uint8_t PETITMODBUS_SLAVE_ADDRESS;
83// Defines for LEDs
84#define PetitLedSuc() nMB_LED = 0;
85#define PetitLedErrFail()
86#define PetitLedCrcFail()
87#define PetitLedOff() nMB_LED = 1;
88#endif /* INC_PETITMODBUSUSERPORT_H_ */
89
90// addtogroup IoT_SV_EFM8BB1LCK_Petit_Modbus_Port
uint8_t PETITMODBUS_SLAVE_ADDRESS
uint8_t PETITMODBUS_DLY_TOP