92 lines
3.2 KiB
C
92 lines
3.2 KiB
C
#ifndef GPIB_DEFS_H
|
|
#define GPIB_DEFS_H
|
|
|
|
#include "ch32fun.h"
|
|
|
|
// #define GPIB_DEBUG 1
|
|
|
|
// Control Lines (Active LOW)
|
|
#define PIN_EOI PB3
|
|
#define PIN_REN PB11
|
|
#define PIN_ATN PA8
|
|
#define PIN_SRQ PA9
|
|
#define PIN_IFC PA10
|
|
#define PIN_NDAC PA11 // Handshake: Not Data Accepted
|
|
#define PIN_NRFD PA12 // Handshake: Not Ready For Data
|
|
#define PIN_DAV PA15 // Handshake: Data Valid
|
|
|
|
// GPIB Commands
|
|
|
|
// enum cmd_byte {
|
|
// GTL = 0x1, /* go to local */
|
|
// SDC = 0x4, /* selected device clear */
|
|
// PP_CONFIG = 0x5,
|
|
// GET = 0x8, /* group execute trigger */
|
|
// TCT = 0x9, /* take control */
|
|
// LLO = 0x11, /* local lockout */
|
|
// DCL = 0x14, /* device clear */
|
|
// PPU = 0x15, /* parallel poll unconfigure */
|
|
// SPE = 0x18, /* serial poll enable */
|
|
// SPD = 0x19, /* serial poll disable */
|
|
// CFE = 0x1f, /* configure enable */
|
|
// LAD = 0x20, /* value to be 'ored' in to obtain listen address */
|
|
// UNL = 0x3F, /* unlisten */
|
|
// TAD = 0x40, /* value to be 'ored' in to obtain talk address */
|
|
// UNT = 0x5F, /* untalk */
|
|
// SAD = 0x60, /* my secondary address (base) */
|
|
// PPE = 0x60, /* parallel poll enable (base) */
|
|
// PPD = 0x70 /* parallel poll disable */
|
|
// };
|
|
|
|
#define GPIB_CMD_GTL 0x01 /* go to local */
|
|
#define GPIB_CMD_SDC 0x04 /* selected device clear */
|
|
#define GPIB_CMD_PP_CONFIG 0x05 /* parallel poll configure */
|
|
#define GPIB_CMD_GET 0x08 /* group execute trigger */
|
|
#define GPIB_CMD_TCT 0x09 /* take control */
|
|
#define GPIB_CMD_LLO 0x11 /* local lockout */
|
|
#define GPIB_CMD_DCL 0x14 /* device clear */
|
|
#define GPIB_CMD_PPU 0x15 /* parallel poll unconfigure */
|
|
#define GPIB_CMD_SPE 0x18 /* serial poll enable */
|
|
#define GPIB_CMD_SPD 0x19 /* serial poll disable */
|
|
#define GPIB_CMD_CFE 0x1F /* configure enable */
|
|
#define GPIB_CMD_LAD 0x20 /* listen address (OR with addr) */
|
|
#define GPIB_CMD_UNL 0x3F /* unlisten */
|
|
#define GPIB_CMD_TAD 0x40 /* talk address (OR with addr) */
|
|
#define GPIB_CMD_UNT 0x5F /* untalk */
|
|
#define GPIB_CMD_SAD 0x60 /* secondary address base */
|
|
#define GPIB_CMD_PPE 0x60 /* parallel poll enable */
|
|
#define GPIB_CMD_PPD 0x70 /* parallel poll disable */
|
|
|
|
// Address Groups
|
|
#define GPIB_LAG_BASE 0x20 // Listen Address Group base
|
|
#define GPIB_TAG_BASE 0x40 // Talk Address Group base
|
|
#define GPIB_SCG_BASE 0x60 // Secondary Command Group base
|
|
|
|
#define GPIB_ASSERT(pin) funDigitalWrite(pin, 0)
|
|
#define GPIB_RELEASE(pin) funDigitalWrite(pin, 1)
|
|
#define GPIB_READ(pin) funDigitalRead(pin)
|
|
|
|
// Data Lines (DIO1-DIO8)
|
|
#define PIN_DIO1 PB9
|
|
#define PIN_DIO2 PB8
|
|
#define PIN_DIO3 PB5
|
|
#define PIN_DIO4 PB4
|
|
#define PIN_DIO5 PB15
|
|
#define PIN_DIO6 PB14
|
|
#define PIN_DIO7 PB13
|
|
#define PIN_DIO8 PB12
|
|
|
|
#define MASK_DIO1 (1U << 9)
|
|
#define MASK_DIO2 (1U << 8)
|
|
#define MASK_DIO3 (1U << 5)
|
|
#define MASK_DIO4 (1U << 4)
|
|
#define MASK_DIO5 (1U << 15)
|
|
#define MASK_DIO6 (1U << 14)
|
|
#define MASK_DIO7 (1U << 13)
|
|
#define MASK_DIO8 (1U << 12)
|
|
|
|
static const int DIO_PINS[] = {PIN_DIO1, PIN_DIO2, PIN_DIO3, PIN_DIO4,
|
|
PIN_DIO5, PIN_DIO6, PIN_DIO7, PIN_DIO8};
|
|
|
|
#endif
|