You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

104 lines
2.0 KiB
C

/*
* RUBUS.h
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#ifndef MODBUSRTU_RUBUS_H_
#define MODBUSRTU_RUBUS_H_
#include <math.h>
#include <stdint.h>
#include "framework.h"
#include "SYSCTRL/SystemEnvironment.h"
#include "MODBUSRTU/RUBUSRegister.h"
#include "MODBUSRTU/RUBUSTypes.h"
namespace MODBUSRTU
{
struct RUBUS_ACCEPTED_DATA
{
RUBUS_REGISTER_16 command_start;
RUBUS_REGISTER_16 command_end;
uint16_t index;
RUBUS_REGISTER_16 id;
RUBUS_REGISTER_16 com;
RUBUS_REGISTER_32 data;
RUBUS_ACCEPTED_DATA():
command_start(0),
command_end(0),
index(0),
id(0),
com(0),
data(0)
{}
};//RUBUS_ACCEPTED_DATA
struct RUBUS_MASK
{
RUBUS_REGISTER_16 error_response;
RUBUS_REGISTER_16 rubus_bool;
RUBUS_REGISTER_16 rubus_float;
RUBUS_REGISTER_16 rubus_uint8;
RUBUS_REGISTER_16 rubus_uint16;
RUBUS_REGISTER_16 rubus_uint32;
RUBUS_REGISTER_16 rubus_int8;
RUBUS_REGISTER_16 rubus_int16;
RUBUS_REGISTER_16 rubus_int32;
RUBUS_MASK():
error_response(0x80),
rubus_bool(0x0000),
rubus_float(0x0002),
rubus_uint8(0x0004),
rubus_uint16(0x0006),
rubus_uint32(0x0008),
rubus_int8(0x000A),
rubus_int16(0x00C),
rubus_int32(0x000E)
{}
};//RUBUS_MASK
struct RUBUS_RESPONSE
{
RUBUS_REGISTER_16 command;
uint16_t index;
RUBUS_REGISTER_32 data;
RUBUS_RESPONSE():
command(0),
index(0),
data(0)
{}
};//RUBUS_RESPONSE
struct RUBUS
{
enum mode_rubus_t {RUBUS_RESET, RUBUS_READ, RUBUS_WRITE, RUBUS_ERROR};
mode_rubus_t mode;
uint16_t size;
RUBUS_ACCEPTED_DATA accepted;
RUBUS_RESPONSE response_shadow;
RUBUS_RESPONSE response;
const RUBUS_MASK mask;
MODBUSRTU::RUBUSRegister m_cell;
RUBUS_REGISTER_32 cell_data;
RUBUS(uint16_t size);
};
} /* namespace MODBUSRTU */
#endif /* MODBUSRTU_RUBUS_H_ */