#ifndef _GPIB_CMD_H
#define _GPIB_CMD_H
#include <linux/types.h>
enum {
gpib_command_mask = 0x7f,
};
enum cmd_byte {
GTL = 0x1,
SDC = 0x4,
PP_CONFIG = 0x5,
GET = 0x8,
TCT = 0x9,
LLO = 0x11,
DCL = 0x14,
PPU = 0x15,
SPE = 0x18,
SPD = 0x19,
CFE = 0x1f,
LAD = 0x20,
UNL = 0x3F,
TAD = 0x40,
UNT = 0x5F,
SAD = 0x60,
PPE = 0x60,
PPD = 0x70
};
static inline unsigned int gpib_address_restrict(u32 addr)
{
addr &= 0x1f;
if (addr == 0x1f)
addr = 0;
return addr;
}
static inline u8 MLA(u32 addr)
{
return gpib_address_restrict(addr) | LAD;
}
static inline u8 MTA(u32 addr)
{
return gpib_address_restrict(addr) | TAD;
}
static inline u8 MSA(u32 addr)
{
return (addr & 0x1f) | SAD;
}
static inline s32 gpib_address_equal(u32 pad1, s32 sad1, u32 pad2, s32 sad2)
{
if (pad1 == pad2) {
if (sad1 == sad2)
return 1;
if (sad1 < 0 && sad2 < 0)
return 1;
}
return 0;
}
static inline s32 is_PPE(u8 command)
{
return (command & 0x70) == 0x60;
}
static inline s32 is_PPD(u8 command)
{
return (command & 0x70) == 0x70;
}
static inline s32 in_addressed_command_group(u8 command)
{
return (command & 0x70) == 0x0;
}
static inline s32 in_universal_command_group(u8 command)
{
return (command & 0x70) == 0x10;
}
static inline s32 in_listen_address_group(u8 command)
{
return (command & 0x60) == 0x20;
}
static inline s32 in_talk_address_group(u8 command)
{
return (command & 0x60) == 0x40;
}
static inline s32 in_primary_command_group(u8 command)
{
return in_addressed_command_group(command) ||
in_universal_command_group(command) ||
in_listen_address_group(command) ||
in_talk_address_group(command);
}
#endif