|
C example it
is all you have to do ! |
#include "NEXOR.HPP"
// ===================================================
// 1 - Module (and Bus) structure instantiation
// ===================================================
// We need always an ITF module
NXR_MDL itf=0;
NXR_CFG_ITF itfCfg;
// We use a DIO module (16 input + 16 output) in this example
NXR_MDL dio=0;
NXR_INP_DIO dioInp;
NXR_OUT_DIO dioOut;
// The bus
NXR_BUS bus=0;
NXR_BUS_INFO busInf;
// ===================================================
// 2 - Create The Bus
// 3 - Add Modules
// 4 - Init the bus
// ===================================================
void BeginNxr()
{
bus=NEXOR_BUS_Create( 0x278, 0, &busInf);
itf=NEXOR_BUS_ADD( bus, NXR_MDL_TYP_ITF, 0x15, &itfCfg,0,0,0);
dio=NEXOR_BUS_ADD( bus, NXR_MDL_TYP_DIO, 0x01, 0,&dioInp,&dioOut,0);
NEXOR_BUS_Init( bus);
}
// ===================================================
// 5 - Read Or Write Operation
// ===================================================
void ScanNxr()
{
BeginNxr();
LOOP:
NEXOR_BUS_Read(bus); // Read Module
DoSomething(); // Do some work
Nexor_Bus_Write(bus); // Write Output
goto LOOP;
}
|