| 1 |
|
| 2 |
|
| 3 | #ifndef _GPIB_CMD_H
|
| 4 | #define _GPIB_CMD_H
|
| 5 |
|
| 6 | #include <linux/types.h>
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 | enum {
|
| 12 | gpib_command_mask = 0x7f,
|
| 13 | };
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 | enum cmd_byte {
|
| 18 | GTL = 0x1,
|
| 19 | SDC = 0x4,
|
| 20 | PP_CONFIG = 0x5,
|
| 21 | GET = 0x8,
|
| 22 | TCT = 0x9,
|
| 23 | LLO = 0x11,
|
| 24 | DCL = 0x14,
|
| 25 | PPU = 0x15,
|
| 26 | SPE = 0x18,
|
| 27 | SPD = 0x19,
|
| 28 | CFE = 0x1f,
|
| 29 | LAD = 0x20,
|
| 30 | UNL = 0x3F,
|
| 31 | TAD = 0x40,
|
| 32 | UNT = 0x5F,
|
| 33 | SAD = 0x60,
|
| 34 | PPE = 0x60,
|
| 35 | PPD = 0x70
|
| 36 | };
|
| 37 |
|
| 38 |
|
| 39 | static inline unsigned int gpib_address_restrict(u32 addr)
|
| 40 | {
|
| 41 | addr &= 0x1f;
|
| 42 | if (addr == 0x1f)
|
| 43 | addr = 0;
|
| 44 | return addr;
|
| 45 | }
|
| 46 |
|
| 47 | static inline u8 MLA(u32 addr)
|
| 48 | {
|
| 49 | return gpib_address_restrict(addr) | LAD;
|
| 50 | }
|
| 51 |
|
| 52 | static inline u8 MTA(u32 addr)
|
| 53 | {
|
| 54 | return gpib_address_restrict(addr) | TAD;
|
| 55 | }
|
| 56 |
|
| 57 | static inline u8 MSA(u32 addr)
|
| 58 | {
|
| 59 | return (addr & 0x1f) | SAD;
|
| 60 | }
|
| 61 |
|
| 62 | static inline s32 gpib_address_equal(u32 pad1, s32 sad1, u32 pad2, s32 sad2)
|
| 63 | {
|
| 64 | if (pad1 == pad2) {
|
| 65 | if (sad1 == sad2)
|
| 66 | return 1;
|
| 67 | if (sad1 < 0 && sad2 < 0)
|
| 68 | return 1;
|
| 69 | }
|
| 70 |
|
| 71 | return 0;
|
| 72 | }
|
| 73 |
|
| 74 | static inline s32 is_PPE(u8 command)
|
| 75 | {
|
| 76 | return (command & 0x70) == 0x60;
|
| 77 | }
|
| 78 |
|
| 79 | static inline s32 is_PPD(u8 command)
|
| 80 | {
|
| 81 | return (command & 0x70) == 0x70;
|
| 82 | }
|
| 83 |
|
| 84 | static inline s32 in_addressed_command_group(u8 command)
|
| 85 | {
|
| 86 | return (command & 0x70) == 0x0;
|
| 87 | }
|
| 88 |
|
| 89 | static inline s32 in_universal_command_group(u8 command)
|
| 90 | {
|
| 91 | return (command & 0x70) == 0x10;
|
| 92 | }
|
| 93 |
|
| 94 | static inline s32 in_listen_address_group(u8 command)
|
| 95 | {
|
| 96 | return (command & 0x60) == 0x20;
|
| 97 | }
|
| 98 |
|
| 99 | static inline s32 in_talk_address_group(u8 command)
|
| 100 | {
|
| 101 | return (command & 0x60) == 0x40;
|
| 102 | }
|
| 103 |
|
| 104 | static inline s32 in_primary_command_group(u8 command)
|
| 105 | {
|
| 106 | return in_addressed_command_group(command) ||
|
| 107 | in_universal_command_group(command) ||
|
| 108 | in_listen_address_group(command) ||
|
| 109 | in_talk_address_group(command);
|
| 110 | }
|
| 111 |
|
| 112 | #endif
|