~jil26/fabinterpreter/Qt_version

« back to all changes in this revision

Viewing changes to software/Common/JrKerr/picio.h

  • Committer: Jeremy Cohen
  • Date: 2010-07-12 18:50:09 UTC
  • Revision ID: jeremyrcohen@gmail.com-20100712185009-fni5l679atvcfru0
added new Nmccom classes

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#ifndef PICIO_H
2
 
#define PICIO_H
3
 
 
4
 
//--------------------- IO Module specific stuff ---------------------------
5
 
typedef struct _IOMOD {
6
 
    short int   inbits;                 //input bits
7
 
    byte                ad1;                    //A/D input bytes
8
 
    byte                ad2;
9
 
    byte                ad3;
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
15
 
    byte                pwm2;
16
 
    byte                timermode;              //current timer mode
17
 
    short int   bitdir;                 //current bit direction values
18
 
    short int   outbits;                //current output byte values
19
 
    } IOMOD;
20
 
 
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)
31
 
//Not used                        0x09
32
 
#define SET_BAUD          0x0A  //Set the baud rate (1 byte)
33
 
//Not used                        0x0B
34
 
#define SYNCH_INPUT       0x0C  //Store the input bytes and timer val (0 bytes)
35
 
//Not used                        0x0D
36
 
#define NOP                       0x0E  //No operation - returns prev. defined status (0 bytes)
37
 
#define HARD_RESET        0x0F  //RESET - no status is returned
38
 
 
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
48
 
 
49
 
//IO Module Timer mode definitions
50
 
//Timer mode and resolution may be OR'd together
51
 
#define OFFMODE           0x00
52
 
#define COUNTERMODE       0x03
53
 
#define TIMERMODE         0x01
54
 
#define RESx1             0x00
55
 
#define RESx2             0x10
56
 
#define RESx4             0x20
57
 
#define RESx8             0x30
58
 
 
59
 
 
60
 
 
61
 
#endif //ndef PICIO_H
 
1
//---------------------------------------------------------------------------
 
2
#ifndef picioH
 
3
#define picioH
 
4
//---------------------------------------------------------------------------
 
5
#endif
 
6
//--------------------- IO Module specific stuff ---------------------------
 
7
 
 
8
typedef unsigned char byte;
 
9
typedef int BOOL;  //0=false, <>0 true
 
10
 
 
11
typedef struct _IOMOD {
 
12
    short int   inbits;                 //input bits
 
13
    byte                ad1;                    //A/D input bytes
 
14
    byte                ad2;
 
15
    byte                ad3;
 
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
 
21
    byte                pwm2;
 
22
    byte                timermode;              //current timer mode
 
23
    short int   bitdir;                 //current bit direction values
 
24
    short int   outbits;                //current output byte values
 
25
    } IOMOD;
 
26
 
 
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)
 
37
//Not used                        0x09
 
38
#define SET_BAUD          0x0A  //Set the baud rate (1 byte)
 
39
//Not used                        0x0B
 
40
#define SYNCH_INPUT       0x0C  //Store the input bytes and timer val (0 bytes)
 
41
//Not used                        0x0D
 
42
#define NOP                       0x0E  //No operation - returns prev. defined status (0 bytes)
 
43
#define HARD_RESET        0x0F  //RESET - no status is returned
 
44
 
 
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
 
54
 
 
55
//IO Module Timer mode definitions
 
56
//Timer mode and resolution may be OR'd together
 
57
#define OFFMODE           0x00
 
58
#define COUNTERMODE       0x03
 
59
#define TIMERMODE         0x01
 
60
#define RESx1             0x00
 
61
#define RESx2             0x10
 
62
#define RESx4             0x20
 
63
#define RESx8             0x30
 
64
//--------------------- END IO Module specific stuff ------------------------
 
65
 
 
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);
 
77
 
 
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);
 
85