IoT Supervisor 0.0
Loading...
Searching...
No Matches
Modbus MiddleWare

Enumerations

enum  mmw_speeds_t {
  eMMW_B_NULL = 0 , eMMW_B_38400 , eMMW_B_19200 , eMMW_B_9600 ,
  eMMW_B_4800 , eMMW_B_2400 , eMMW_B_1200 , eMMW_B_NUM
}
 
enum  mmw_cl_i_t {
  eMMW_CL_T1_PRE = 0 , eMMW_CL_TH1 , eMMW_CL_PETIT_TOP , eMMW_CL_TL0_TOP ,
  eMMW_CL_NUM
}
 
enum  mmw_hr_t {
  eMMW_HR_STA , eMMW_HR_CFG , eMMW_HR_MB , eMMW_HR_WDT ,
  eMMW_HR_PW , eMMW_HR_NUM
}
 

Functions

void mmw_init (uint8_t sid, uint8_t baud)
 

Variables

code const uint8_t mmw_ct [eMMW_B_NUM][eMMW_CL_NUM]
 
uint8_t PETITMODBUS_DLY_TOP = 0
 
uint8_t PETITMODBUS_SLAVE_ADDRESS = 0
 
uint8_t PETITMODBUS_DLY_TOP
 
uint8_t PETITMODBUS_SLAVE_ADDRESS
 

Detailed Description

This section contains the intersection between the petit modbus library and the application and the hardware. It exists because the modbus library does not handle sid switching or baud rate switching. The library also does not handle the hardware when the baud rate switches.

flowchart LR User MMW[Modbus
MiddleWare] subgraph PMUP [Petit Modbus
User Port] PMB[Petit Modbus] end subgraph App [Application] CSM[Config SM] end PMB <-- Modbus Comm --> User CSM -- Controls --> MMW CSM -- Start/Stop --> PMB PMUP -- Controls --> App PMUP -- Controls --> CSM MMW -.Hardware Control.-> PMUP

Enumeration Type Documentation

◆ mmw_cl_i_t

enum mmw_cl_i_t

This enumeration contains the number of entries across the MMW table.

CL in this context stands for Configuration List.

Enumerator
eMMW_CL_T1_PRE 

Timer 1 Prescale Control.

This flag controls the hardware prescale selection.

eMMW_CL_TH1 

Timer High 1 Value.

This is the timer reload value for determining the UART baud rate. Each BAUD is two timer overflow periods, probably.

eMMW_CL_PETIT_TOP 

Petit Modbus delay cycles.

The main application runs on a 1ms loop and it needs to be delayed to meet the T_3.5 character timing period for transmission line direction switch.

eMMW_CL_TL0_TOP 

Timer 0 Low Reload.

This value controls the T_1.5 character timing period for maximum intra-octet timing.

eMMW_CL_NUM 

total number of configuration table entries

Definition at line 45 of file ModbusMiddleWare.h.

◆ mmw_hr_t

enum mmw_hr_t

This is the enumeration for all Holding Registers

Note
These are not input registers. The input registers are read-only.
Enumerator
eMMW_HR_STA 

SV Status and MB Watchdog Control

eMMW_HR_CFG 

Password and Config SM Control

eMMW_HR_MB 

Modbus Control Register

eMMW_HR_WDT 

MB WDT Period Register

eMMW_HR_PW 

Password Set Register

eMMW_HR_NUM 

Number of holding registers

Definition at line 83 of file ModbusMiddleWare.h.

◆ mmw_speeds_t

This enumeration contains the speeds used by the Modbus MiddleWare.

Note that these are standard UART speeds.

Enumerator
eMMW_B_NULL 

The first modbus speed is null because of the mechanism used to set individual bitfields within the modbus register. eMMW_B_NULL

eMMW_B_38400 

eMMW_B_38400 eMMW_B_38400

eMMW_B_19200 

eMMW_B_19200 eMMW_B_19200

eMMW_B_9600 

eMMW_B_9600 eMMW_B_9600

eMMW_B_4800 

eMMW_B_4800 eMMW_B_4800

eMMW_B_2400 

eMMW_B_2400 eMMW_B_2400

eMMW_B_1200 

eMMW_B_1200 eMMW_B_1200

eMMW_B_NUM 

The total number of modbus speeds eMMW_B_NUM

Definition at line 24 of file ModbusMiddleWare.h.

Function Documentation

◆ mmw_init()

void mmw_init ( uint8_t  sid,
uint8_t  baud 
)

Modbus MiddleWare Init function takes an SID and a baud rate enumeration and applies it to device hardware and functions to support that selected baud.

Parameters
sidWhich ID this device should respond to
baudrate at which the device communicates on RS485. This is an enumeration that is set to one higher than the index in the mmw_ct table.

Definition at line 47 of file ModbusMiddleWare.c.

Variable Documentation

◆ mmw_ct

code const uint8_t mmw_ct[eMMW_B_NUM][eMMW_CL_NUM]
Initial value:
=
{
{0, 0xEC, 0, 0},
{0, 0xD8, 0, 0},
{0, 0xB0, 1, 0},
{0, 0x60, 4, 1},
{1, 0xE5, 10, 3},
{1, 0xCB, 22, 7}
}

Modbus configuration table containing variables for each standard modbus speed.

These constants were generated largely with aid from the device configurator and with simple pen and paper calculations.

Definition at line 25 of file ModbusMiddleWare.c.

◆ PETITMODBUS_DLY_TOP [1/2]

uint8_t PETITMODBUS_DLY_TOP
extern

Definition at line 35 of file ModbusMiddleWare.c.

◆ PETITMODBUS_DLY_TOP [2/2]

uint8_t PETITMODBUS_DLY_TOP = 0

Definition at line 35 of file ModbusMiddleWare.c.

◆ PETITMODBUS_SLAVE_ADDRESS [1/2]

uint8_t PETITMODBUS_SLAVE_ADDRESS
extern

Definition at line 36 of file ModbusMiddleWare.c.

◆ PETITMODBUS_SLAVE_ADDRESS [2/2]

uint8_t PETITMODBUS_SLAVE_ADDRESS = 0

Definition at line 36 of file ModbusMiddleWare.c.