@ -17,15 +17,15 @@
# include "DSP28335/SCIB.h"
# include "DSP28335/SCIB.h"
# include "DSP28335/SCIBase.h"
# include "DSP28335/SCIBase.h"
# include "MODBUSRTU/ModbusRTUCRC.h"
// #include "MODBUSRTU/ModbusRTUCRC.h"
# include "MODBUSRTU/ModbusRTUDefines.h"
// #include "MODBUSRTU/ModbusRTUDefines.h"
# include "MODBUSRTU/ModbusRTUTransceiver.h"
// #include "MODBUSRTU/ModbusRTUTransceiver.h"
# include "MODBUSRTU/ModbusRTUVariant.h"
// #include "MODBUSRTU/ModbusRTUVariant.h"
# include "MODBUSRTU/ModbusRTUTransceiverBase.h"
// #include "MODBUSRTU/ModbusRTUTransceiverBase.h"
# include "DSP28335/MeasureTimeInterval.h"
// #include "DSP28335/MeasureTimeInterval.h"
# include "WEINBUS/HeaderWeinbus.h"
// #include "WEINBUS/HeaderWeinbus.h"
@ -37,32 +37,32 @@ interrupt void cpu_timer1_isr(void);
interrupt void canb_isr ( void ) ;
interrupt void canb_isr ( void ) ;
interrupt void canb_box_isr ( void ) ;
interrupt void canb_box_isr ( void ) ;
// Periphery periphery;
Periphery periphery ;
//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
DSP28335 : : SCISetup SCIbSetup ;
// DSP28335::SCISetup SCIbSetup;
DSP28335 : : SCIB scib ( ScibRegs ) ;
// DSP28335::SCIB scib(ScibRegs);
DSP28335 : : MeasureTimeInterval interval_measure ( CpuTimer2 ) ;
// DSP28335::MeasureTimeInterval interval_measure(CpuTimer2);
// MODBUS RTU - PORT & HMI
// MODBUS RTU - PORT & HMI
MODBUSRTU : : ModbusRTUTransceiverSetup modbus ;
// MODBUSRTU::ModbusRTUTransceiverSetup modbus;
MODBUSRTU : : ModbusRTUCRC crc ;
// MODBUSRTU::ModbusRTUCRC crc;
MODBUSRTU : : ModbusRTUTransceiver modbus_port ( scib , interval_measure , crc ) ;
// MODBUSRTU::ModbusRTUTransceiver modbus_port(scib, interval_measure, crc);
WEINBUS : : WeinbusSlave hmi ( crc ) ;
// WEINBUS::WeinbusSlave hmi(crc);
MODBUSRTU : : ModbusRTUTransceiverConfiguration modbus_port_configuration ;
// MODBUSRTU::ModbusRTUTransceiverConfiguration modbus_port_configuration;
// Registers to testing HMI interface
// // Registers to testing HMI interface
WEINBUS : : REGISTER_32 test_hmi_float_reg_400 = WEINBUS : : REGISTER_32 ( 0 ) ;
// WEINBUS::REGISTER_32 test_hmi_float_reg_400 = WEINBUS::REGISTER_32(0);
WEINBUS : : REGISTER_32 test_hmi_float_reg_401 = WEINBUS : : REGISTER_32 ( 0 ) ;
// WEINBUS::REGISTER_32 test_hmi_float_reg_401 = WEINBUS::REGISTER_32(0);
WEINBUS : : REGISTER_32 test_hmi_float_reg_402 = WEINBUS : : REGISTER_32 ( 0 ) ;
// WEINBUS::REGISTER_32 test_hmi_float_reg_402 = WEINBUS::REGISTER_32(0);
WEINBUS : : REGISTER_32 test_hmi_float_reg_403 = WEINBUS : : REGISTER_32 ( 0 ) ;
// WEINBUS::REGISTER_32 test_hmi_float_reg_403 = WEINBUS::REGISTER_32(0);
WEINBUS : : REGISTER_32 test_hmi_float_reg_404 = WEINBUS : : REGISTER_32 ( 0 ) ;
// WEINBUS::REGISTER_32 test_hmi_float_reg_404 = WEINBUS::REGISTER_32(0);
// <>
// // <>
void test_init_hmi_buffers ( ) ;
// void test_init_hmi_buffers();
void clear_array ( uint16_t * pointer , uint16_t sizearray ) ;
void clear_array ( uint16_t * pointer , uint16_t sizearray ) ;
//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
@ -79,6 +79,8 @@ volatile bool sendRemote = false;
Uint16 modbusInit = 0 ;
Uint16 modbusInit = 0 ;
int32 testVar = 0 ;
int32 testVar = 0 ;
float test = 55 ;
void main ( )
void main ( )
{
{
ServiceDog ( ) ;
ServiceDog ( ) ;
@ -114,54 +116,57 @@ void main()
PieCtrlRegs . PIEIER9 . bit . INTx7 = 1 ; // from 5 to 8
PieCtrlRegs . PIEIER9 . bit . INTx7 = 1 ; // from 5 to 8
PieCtrlRegs . PIEIER9 . bit . INTx8 = 1 ;
PieCtrlRegs . PIEIER9 . bit . INTx8 = 1 ;
// periphery.config();
periphery . config ( ) ;
//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
SCIbSetup . config . baudrate = SCIB_BAUDRATE_DEFAULT ;
// SCIbSetup.config.baudrate = SCIB_BAUDRATE_DEFAULT;
SCIbSetup . config . parity = SCIB_PARITY_DEFAULT ;
// SCIbSetup.config.parity = SCIB_PARITY_DEFAULT;
SCIbSetup . config . stopbits = SCIB_STOPBITS_DEFAULT ;
// SCIbSetup.config.stopbits = SCIB_STOPBITS_DEFAULT;
SCIbSetup . config . lenght = SCIB_LENGHT_DEFAULT ;
// SCIbSetup.config.lenght = SCIB_LENGHT_DEFAULT;
SCIbSetup . gpio_setup = SCIB_GPIO_SETUP_DEFAULT ;
// SCIbSetup.gpio_setup = SCIB_GPIO_SETUP_DEFAULT;
modbus . gpio_re_de_setup = & DSP28335 : : GPIO : : gpio_scib_re_de_setup ;
// modbus.gpio_re_de_setup = &DSP28335::GPIO::gpio_scib_re_de_setup;
modbus . gpio_driver_enable = & DSP28335 : : GPIO : : gpio_scib_re_de_set ;
// modbus.gpio_driver_enable = &DSP28335::GPIO::gpio_scib_re_de_set;
modbus . gpio_receiver_enable = & DSP28335 : : GPIO : : gpio_scib_re_de_clear ;
// modbus.gpio_receiver_enable = &DSP28335::GPIO::gpio_scib_re_de_clear;
scib . setup ( SCIbSetup ) ;
// scib.setup(SCIbSetup);
interval_measure . set_magic ( ( Uint32 ) 0 ) ;
// interval_measure.set_magic((Uint32)0);
interval_measure . reset ( ) ;
// interval_measure.reset();
modbus_port . setup ( modbus ) ;
// modbus_port.setup(modbus);
//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
// Enable global Interrupts and higher priority real-time debug events:
// Enable global Interrupts and higher priority real-time debug events:
EINT ; // Enable Global interrupt INTM
EINT ; // Enable Global interrupt INTM
ERTM ; // Enable Global realtime interrupt DBGM
ERTM ; // Enable Global realtime interrupt DBGM
// periphery.updateVersionFPGA();
periphery . updateVersionFPGA ( ) ;
//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
// MODBUS RTU
// MODBUS RTU
//
//
modbus_port_configuration . node_id = 0x5 ;
// modbus_port_configuration.node_id = 0x5;
modbus_port_configuration . config . baudrate = DSP28335 : : BR9600 ;
// modbus_port_configuration.config.baudrate = DSP28335::BR9600;
modbus_port_configuration . config . parity = DSP28335 : : NO ;
// modbus_port_configuration.config.parity = DSP28335::NO;
modbus_port_configuration . config . stopbits = DSP28335 : : ONE ;
// modbus_port_configuration.config.stopbits = DSP28335::ONE;
modbus_port_configuration . config . lenght = DSP28335 : : LEN8 ;
// modbus_port_configuration.config.lenght = DSP28335::LEN8;
//
//
test_init_hmi_buffers ( ) ;
// test_init_hmi_buffers();
periphery . test_init_hmi_buffers ( ) ;
modbus_port . configure ( modbus_port_configuration ) ;
// modbus_port.configure(modbus_port_configuration);
clear_array ( ( uint16_t * ) hmi . rxStack , sizeof ( hmi . rxStack ) / sizeof ( uint16_t ) ) ;
// clear_array((uint16_t *)hmi.rxStack, sizeof(hmi.rxStack)/sizeof(uint16_t));
clear_array ( ( uint16_t * ) hmi . txStack , sizeof ( hmi . txStack ) / sizeof ( uint16_t ) ) ;
// clear_array((uint16_t *)hmi.txStack, sizeof(hmi.txStack)/sizeof(uint16_t));
modbus_port . setRXBuffer ( ( uint16_t * ) hmi . rxStack , & hmi . rxLength ) ;
// modbus_port.setRXBuffer((uint16_t*)hmi.rxStack, &hmi.rxLength);
modbus_port . setTXBuffer ( ( uint16_t * ) hmi . txStack , & hmi . txLength ) ;
// modbus_port.setTXBuffer((uint16_t*)hmi.txStack, &hmi.txLength);
periphery . setModbusBuffers ( ) ;
periphery . addInputRegFloat ( 5 , test ) ;
interval_measure . set_magic ( 19 ) ;
// interval_measure.set_magic(19);
//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
@ -180,24 +185,29 @@ void idle_loop()
{
{
infCounter + + ;
infCounter + + ;
// periphery.initExternalModbus();
if ( ! periphery . isModbusInit ( ) ) {
periphery . receiveModbusParameters ( ) ;
// modbus_port.configure(modbus_port_configuration);
}
//
//
// MODBUS RTU HMI Service
// MODBUS RTU HMI Service
//
//
if ( modbus_port . compare_state ( MODBUSRTU : : BREAK ) )
if ( periphery . isModbusInit ( ) ) {
{
periphery . modbusExecute ( ) ;
modbus_port . port_reset ( ) ;
// if(modbus_port.compare_state(MODBUSRTU::BREAK))
//
// {
// modbus_port.port_reset();
// //
// }
// else
// {
// modbus_port.execute();
// hmi.execute();
// //
// }//if else
}
}
else
{
modbus_port . execute ( ) ;
hmi . execute ( ) ;
//
} //if else
//<>
//<>
} //end while
} //end while
} //end idle_loop()
} //end idle_loop()
@ -205,7 +215,7 @@ void idle_loop()
interrupt void cpu_timer0_isr ( void )
interrupt void cpu_timer0_isr ( void )
{
{
// periphery.processDigitalOutput();
periphery . processDigitalOutput ( ) ;
PieCtrlRegs . PIEACK . all | = PIEACK_GROUP1 ;
PieCtrlRegs . PIEACK . all | = PIEACK_GROUP1 ;
} //end
} //end
@ -214,7 +224,7 @@ interrupt void cpu_timer0_isr(void)
interrupt void cpu_timer1_isr ( ) {
interrupt void cpu_timer1_isr ( ) {
CpuTimer1 . InterruptCount + + ;
CpuTimer1 . InterruptCount + + ;
// periphery.processDigitalInput();
periphery . processDigitalInput ( ) ;
}
}
@ -267,28 +277,27 @@ interrupt void canb_box_isr(void){
PieCtrlRegs . PIEACK . all | = PIEACK_GROUP9 ;
PieCtrlRegs . PIEACK . all | = PIEACK_GROUP9 ;
}
}
// void test_init_hmi_buffers()
void test_init_hmi_buffers ( )
// {
{
// //
//
// // hmi writeable registers
// hmi writeable registers
// hmi.inputRegisters.set(WEINBUS::INPUTREGISTERS, 400);
hmi . inputRegisters . set ( WEINBUS : : INPUTREGISTERS , 400 ) ;
// hmi.inputRegisters.add( 0, &test_hmi_float_reg_400.f);
hmi . inputRegisters . add ( 0 , & ( float & ) test_hmi_float_reg_400 . f ) ;
// hmi.inputRegisters.add( 1, &(float&)test_hmi_float_reg_401.f);
hmi . inputRegisters . add ( 1 , & ( float & ) test_hmi_float_reg_401 . f ) ;
// hmi.inputRegisters.add( 2, &(float&)test_hmi_float_reg_402.f);
hmi . inputRegisters . add ( 2 , & ( float & ) test_hmi_float_reg_402 . f ) ;
// hmi.inputRegisters.add( 3, &(float&)test_hmi_float_reg_403.f);
hmi . inputRegisters . add ( 3 , & ( float & ) test_hmi_float_reg_403 . f ) ;
// hmi.inputRegisters.add( 4, &(float&)test_hmi_float_reg_404.f);
hmi . inputRegisters . add ( 4 , & ( float & ) test_hmi_float_reg_404 . f ) ;
// //
//
// // hmi readable registers
// hmi readable registers
// hmi.outputRegisters.set(WEINBUS::OUTPUTREGISTERS, 400);
hmi . outputRegisters . set ( WEINBUS : : OUTPUTREGISTERS , 400 ) ;
// hmi.outputRegisters.add( 0 , &(float&)test_hmi_float_reg_400.f);
hmi . outputRegisters . add ( 0 , & ( float & ) test_hmi_float_reg_400 . f ) ;
// hmi.outputRegisters.add( 1, &(float&)test_hmi_float_reg_401.f);
hmi . outputRegisters . add ( 1 , & ( float & ) test_hmi_float_reg_401 . f ) ;
// hmi.outputRegisters.add( 2, &(float&)test_hmi_float_reg_402.f);
hmi . outputRegisters . add ( 2 , & ( float & ) test_hmi_float_reg_402 . f ) ;
// hmi.outputRegisters.add( 3, &(float&)test_hmi_float_reg_403.f);
hmi . outputRegisters . add ( 3 , & ( float & ) test_hmi_float_reg_403 . f ) ;
// hmi.outputRegisters.add( 4, &(float&)test_hmi_float_reg_404.f);
hmi . outputRegisters . add ( 4 , & ( float & ) test_hmi_float_reg_404 . f ) ;
// //
//
// }//
} //
// //
//
void clear_array ( uint16_t * pointer , uint16_t sizearray )
void clear_array ( uint16_t * pointer , uint16_t sizearray )
{
{