|
|
|
/*
|
|
|
|
* ModbusRTUTransceiverBase.h
|
|
|
|
*
|
|
|
|
* Author: Aleksey Gerasimenko
|
|
|
|
* gerasimenko.aleksey.n@gmail.com
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <math.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
#include "F28335/DSP28x_Project.h"
|
|
|
|
|
|
|
|
#include "DSP28335/GPIO.h"
|
|
|
|
#include "DSP28335/CPUTimers.h"
|
|
|
|
#include "DSP28335/SCIA.h"
|
|
|
|
#include "DSP28335/SCIB.h"
|
|
|
|
#include "DSP28335/SCIBase.h"
|
|
|
|
#include "DSP28335/SCIC.h"
|
|
|
|
|
|
|
|
#include "MODBUSRTU/ModbusRTUCRC.h"
|
|
|
|
#include "MODBUSRTU/ModbusRTUDefines.h"
|
|
|
|
#include "MODBUSRTU/ModbusRTUVariant.h"
|
|
|
|
|
|
|
|
#ifndef MODBUSRTU_MODBUSRTUTRANSCEIVERBASE_H_
|
|
|
|
#define MODBUSRTU_MODBUSRTUTRANSCEIVERBASE_H_
|
|
|
|
|
|
|
|
namespace MODBUSRTU
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
struct ModbusRTUTransceiverSetup
|
|
|
|
{
|
|
|
|
pGPIO_FUNCTION gpio_re_de_setup;
|
|
|
|
pGPIO_FUNCTION gpio_driver_enable;
|
|
|
|
pGPIO_FUNCTION gpio_receiver_enable;
|
|
|
|
ModbusRTUTransceiverSetup():
|
|
|
|
gpio_re_de_setup(0),
|
|
|
|
gpio_driver_enable(0),
|
|
|
|
gpio_receiver_enable(0)
|
|
|
|
{
|
|
|
|
//gpio_re_de_setup = &DSP28335::GPIO::gpio_scib_re_de_setup;
|
|
|
|
//gpio_driver_enable = &DSP28335::GPIO::gpio_scib_re_de_set;
|
|
|
|
//gpio_receiver_enable = &DSP28335::GPIO::gpio_scib_re_de_clear;
|
|
|
|
}
|
|
|
|
};//ModbusRTUTransceiverSetup
|
|
|
|
|
|
|
|
|
|
|
|
struct ModbusRTUTransceiverConfiguration
|
|
|
|
{
|
|
|
|
uint16_t node_id;
|
|
|
|
DSP28335::SCIConfiguration config;
|
|
|
|
ModbusRTUTransceiverConfiguration():
|
|
|
|
node_id(1234),
|
|
|
|
config()
|
|
|
|
{
|
|
|
|
//config.baudrate = SCIRS485_BAUDRATE_DEFAULT;
|
|
|
|
//config.parity = SCIRS485_PARITY_DEFAULT;
|
|
|
|
//config.stopbits = SCIRS485_STOPBITS_DEFAULT;
|
|
|
|
//config.lenght = SCIRS485_LENGHT_DEFAULT;
|
|
|
|
}
|
|
|
|
};//ModbusRTUTransceiverConfiguration
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ModbusRTUTransceiverBase
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
DSP28335::SCIBase& m_sci_port;
|
|
|
|
DSP28335::SCIConfiguration m_sci_config;
|
|
|
|
uint16_t m_node_id;
|
|
|
|
protected:
|
|
|
|
MODBUSRTU::transceiver_state_machine_t m_state_machine;
|
|
|
|
MODBUSRTU::transceiver_event_t m_event;
|
|
|
|
|
|
|
|
public:
|
|
|
|
ModbusRTUTransceiverBase(DSP28335::SCIBase& sciport, DSP28335::CPUTimers& cputimer, MODBUSRTU::ModbusRTUCRC& crc);
|
|
|
|
};
|
|
|
|
|
|
|
|
} /* namespace MODBUSRTU */
|
|
|
|
|
|
|
|
#endif /* MODBUSRTU_MODBUSRTUTRANSCEIVERBASE_H_ */
|