4
//--------------------- IO Module specific stuff ---------------------------
5
typedef struct _IOMOD {
6
short int inbits; //input bits
7
byte ad1; //A/D input bytes
10
unsigned long timer; //timer value
11
short int inbits_s; //synchronized input bytes
12
unsigned long timer_s; //synchronized timer value
13
//The following data is stored locally for reference
14
byte pwm1; //current PWM output values
16
byte timermode; //current timer mode
17
short int bitdir; //current bit direction values
18
short int outbits; //current output byte values
21
//IO Module Command set:
22
#define SET_IO_DIR 0x00 //Set direction of IO bits (2 data bytes)
23
#define SET_ADDR 0x01 //Set address and group address (2 bytes)
24
#define DEF_STAT 0x02 //Define status items to return (1 byte)
25
#define READ_STAT 0x03 //Read value of current status items
26
#define SET_PWM 0x04 //Immediatley set PWM1 and PWM2 (2 bytes)
27
#define SYNCH_OUT 0x05 //Output prev. stored PWM & output bytes (0 bytes)
28
#define SET_OUTPUT 0x06 //Immediately set output bytes
29
#define SET_SYNCH_OUT 0x07 //Store PWM & outputs for synch'd output (4 bytes)
30
#define SET_TMR_MODE 0x08 //Set the counter/timer mode (1 byte)
32
#define SET_BAUD 0x0A //Set the baud rate (1 byte)
34
#define SYNCH_INPUT 0x0C //Store the input bytes and timer val (0 bytes)
36
#define NOP 0x0E //No operation - returns prev. defined status (0 bytes)
37
#define HARD_RESET 0x0F //RESET - no status is returned
39
//IO Module STATUSITEMS bit definitions
40
#define SEND_INPUTS 0x01 //2 bytes data
41
#define SEND_AD1 0x02 //1 byte
42
#define SEND_AD2 0x04 //1 byte
43
#define SEND_AD3 0x08 //1 byte
44
#define SEND_TIMER 0x10 //4 bytes
45
#define SEND_ID 0x20 //2 bytes
46
#define SEND_SYNC_IN 0x40 //2 bytes
47
#define SEND_SYNC_TMR 0x80 //4 bytes
49
//IO Module Timer mode definitions
50
//Timer mode and resolution may be OR'd together
52
#define COUNTERMODE 0x03
53
#define TIMERMODE 0x01
1
//---------------------------------------------------------------------------
4
//---------------------------------------------------------------------------
6
//--------------------- IO Module specific stuff ---------------------------
8
typedef unsigned char byte;
9
typedef int BOOL; //0=false, <>0 true
11
typedef struct _IOMOD {
12
short int inbits; //input bits
13
byte ad1; //A/D input bytes
16
unsigned long timer; //timer value
17
short int inbits_s; //synchronized input bytes
18
unsigned long timer_s; //synchronized timer value
19
//The following data is stored locally for reference
20
byte pwm1; //current PWM output values
22
byte timermode; //current timer mode
23
short int bitdir; //current bit direction values
24
short int outbits; //current output byte values
27
//IO Module Command set:
28
#define SET_IO_DIR 0x00 //Set direction of IO bits (2 data bytes)
29
#define SET_ADDR 0x01 //Set address and group address (2 bytes)
30
#define DEF_STAT 0x02 //Define status items to return (1 byte)
31
#define READ_STAT 0x03 //Read value of current status items
32
#define SET_PWM 0x04 //Immediatley set PWM1 and PWM2 (2 bytes)
33
#define SYNCH_OUT 0x05 //Output prev. stored PWM & output bytes (0 bytes)
34
#define SET_OUTPUT 0x06 //Immediately set output bytes
35
#define SET_SYNCH_OUT 0x07 //Store PWM & outputs for synch'd output (4 bytes)
36
#define SET_TMR_MODE 0x08 //Set the counter/timer mode (1 byte)
38
#define SET_BAUD 0x0A //Set the baud rate (1 byte)
40
#define SYNCH_INPUT 0x0C //Store the input bytes and timer val (0 bytes)
42
#define NOP 0x0E //No operation - returns prev. defined status (0 bytes)
43
#define HARD_RESET 0x0F //RESET - no status is returned
45
//IO Module STATUSITEMS bit definitions
46
#define SEND_INPUTS 0x01 //2 bytes data
47
#define SEND_AD1 0x02 //1 byte
48
#define SEND_AD2 0x04 //1 byte
49
#define SEND_AD3 0x08 //1 byte
50
#define SEND_TIMER 0x10 //4 bytes
51
#define SEND_ID 0x20 //2 bytes
52
#define SEND_SYNC_IN 0x40 //2 bytes
53
#define SEND_SYNC_TMR 0x80 //4 bytes
55
//IO Module Timer mode definitions
56
//Timer mode and resolution may be OR'd together
58
#define COUNTERMODE 0x03
59
#define TIMERMODE 0x01
64
//--------------------- END IO Module specific stuff ------------------------
66
extern "C" IOMOD * IoNewMod();
67
extern "C" BOOL IoGetStat(byte addr);
68
extern "C" BOOL IoInBitVal(byte addr, int bitnum);
69
extern "C" BOOL IoInBitSVal(byte addr, int bitnum);
70
extern "C" BOOL IoOutBitVal(byte addr, int bitnum);
71
extern "C" BOOL IoGetBitDir(byte addr, int bitnum);
72
extern "C" byte IoGetADCVal(byte addr, int channel);
73
extern "C" byte IoGetPWMVal(byte addr, int channel);
74
extern "C" unsigned long IoGetTimerVal(byte addr);
75
extern "C" unsigned long IoGetTimerSVal(byte addr);
76
extern "C" byte IoGetTimerMode(byte addr);
78
extern "C" BOOL IoSetOutBit(byte addr, int bitnum);
79
extern "C" BOOL IoClrOutBit(byte addr, int bitnum);
80
extern "C" BOOL IoBitDirIn(byte addr, int bitnum);
81
extern "C" BOOL IoBitDirOut(byte addr, int bitnum);
82
extern "C" BOOL IoSetPWMVal(byte addr, byte pwm1, byte pwm2);
83
extern "C" BOOL IoSetTimerMode(byte addr, byte tmrmode);
84
extern "C" BOOL IoSetSynchOutput(byte addr, short int outbits, byte pwm1, byte pwm2);