GPIB_AVR
|
#include "defs.h"
Go to the source code of this file.
Defines | |
#define | GPIB_H |
#define | DEFAULT_PARTNER_ADDRESS 0x01 |
default address to be used as partner device | |
#define | G_DAV PD2 |
Handshake lines: DAV, NRFD and NDAC on Port D. | |
#define | G_NRFD PD3 |
#define | G_NDAC PD5 |
#define | G_EOI PD4 |
management lines: EOI, SRQ and ATN on Port D, IFC and REN on Port B | |
#define | G_SRQ PD6 |
#define | G_ATN PD7 |
#define | G_IFC PB0 |
#define | G_REN PB1 |
#define | G_CMD_UNL 0x3f |
GPIB command codes. | |
#define | G_CMD_UNT 0x5f |
#define | G_CMD_SPE 0x18 |
#define | G_CMD_SPD 0x19 |
#define | G_CMD_DCL 0x14 |
#define | address2ListenerAddress(adr) (adr+0x20) |
GPIB Address scheme: physical addresses are 0,1,2,3,... | |
#define | address2TalkerAddress(adr) (adr+0x40) |
calculate talker address from physical device address | |
#define | listenerAddress2Address(adr) (adr-0x20) |
calculate physical address from listener address | |
#define | TalkerAddress2Address(adr) (adr-0x40) |
calculate physical address from talker address | |
#define | MAX_PARTNER 5 |
maximum size of active partner list | |
Functions | |
void | gpib_init (void) |
Init GPIB pins and variables. | |
void | gpib_controller_assign (uchar address) |
Assign bus to me. | |
void | gpib_controller_release (void) |
Release bus. | |
uchar | gpib_cmd (uchar *bytes, int length) |
Write GPIB command to bus. | |
uchar | gpib_serial_poll (void) |
execute serial polling | |
void | gpib_set_partner (uchar address) |
Set device to be controlled. | |
uchar | gpib_get_partner (void) |
Get device currently controlled. | |
uchar | gpib_get_address (void) |
Get controller address. | |
uchar | gpib_receive (uchar *byte) |
Receive a character from GPIB Bus. | |
uchar | gpib_write (uchar *bytes, int length) |
Write GPIB string to bus. | |
void | gpib_info (void) |
print some useful info about bus state (for example value of handshake pins) |
#define address2ListenerAddress | ( | adr | ) | (adr+0x20) |
GPIB Address scheme: physical addresses are 0,1,2,3,...
Listener addresses are physical address + 0x20 Talker address is physical address + 0x40 calculate listener address from physical device address
Referenced by main().
#define address2TalkerAddress | ( | adr | ) | (adr+0x40) |
calculate talker address from physical device address
Referenced by gpib_serial_poll(), and main().
#define DEFAULT_PARTNER_ADDRESS 0x01 |
default address to be used as partner device
Referenced by gpib_controller_assign().
#define G_ATN PD7 |
Referenced by _gpib_write(), gpib_info(), and gpib_init().
#define G_CMD_DCL 0x14 |
Referenced by gpib_controller_assign().
#define G_CMD_SPD 0x19 |
Referenced by gpib_serial_poll().
#define G_CMD_SPE 0x18 |
Referenced by gpib_serial_poll().
#define G_CMD_UNL 0x3f |
GPIB command codes.
Referenced by gpib_serial_poll(), and main().
#define G_CMD_UNT 0x5f |
Referenced by gpib_serial_poll(), and main().
#define G_DAV PD2 |
Handshake lines: DAV, NRFD and NDAC on Port D.
Referenced by _gpib_write(), gpib_info(), gpib_init(), and gpib_receive().
#define G_EOI PD4 |
management lines: EOI, SRQ and ATN on Port D, IFC and REN on Port B
Referenced by _gpib_write(), gpib_info(), gpib_init(), and gpib_receive().
#define G_IFC PB0 |
Referenced by gpib_controller_assign(), gpib_controller_release(), gpib_info(), and gpib_init().
#define G_NDAC PD5 |
Referenced by _gpib_write(), gpib_info(), gpib_init(), and gpib_receive().
#define G_NRFD PD3 |
Referenced by _gpib_write(), gpib_info(), gpib_init(), and gpib_receive().
#define G_REN PB1 |
Referenced by gpib_controller_assign(), gpib_controller_release(), gpib_info(), and gpib_init().
#define G_SRQ PD6 |
Referenced by gpib_info(), gpib_init(), and main().
#define GPIB_H |
#define listenerAddress2Address | ( | adr | ) | (adr-0x20) |
calculate physical address from listener address
#define MAX_PARTNER 5 |
maximum size of active partner list
#define TalkerAddress2Address | ( | adr | ) | (adr-0x40) |
calculate physical address from talker address
Referenced by gpib_serial_poll(), and main().
Write GPIB command to bus.
See _gpib_write() for further information.
References _gpib_write().
Referenced by gpib_controller_assign(), gpib_serial_poll(), and main().
void gpib_controller_assign | ( | uchar | address | ) |
Assign bus to me.
Initialization of the controller part.
address | the address to be used by the controller. Usually 0x00. |
get all partners on bus by querying them
References assign_bit, cmd_buf, DEFAULT_PARTNER_ADDRESS, delay_ms(), G_CMD_DCL, G_IFC, G_REN, gpib_cmd(), gpib_controller_t::myaddress, gpib_controller_t::partneraddress, queryPartners(), release_bit, and gpib_controller_t::talks.
Referenced by main().
void gpib_controller_release | ( | void | ) |
Release bus.
References assign_bit, delay_ms(), G_IFC, G_REN, and release_bit.
uchar gpib_get_address | ( | void | ) |
Get controller address.
References gpib_controller_t::myaddress.
Referenced by main().
uchar gpib_get_partner | ( | void | ) |
Get device currently controlled.
References gpib_controller_t::partneraddress.
Referenced by main().
void gpib_info | ( | void | ) |
void gpib_init | ( | void | ) |
Init GPIB pins and variables.
All signal lines not related to the controller part are initialized with useful values. (The controller part initialization is done on gpib_controller_assert())
References assign_bit, G_ATN, G_DAV, G_EOI, G_IFC, G_NDAC, G_NRFD, G_REN, G_SRQ, and release_bit.
Referenced by main().
Receive a character from GPIB Bus.
Does busy waiting until timeout value is reached. Then, the debugshell function is entered for user handling of the problem.
_byte | Pointer to single character; the function stores herein the character read. When errors occur during the function, the content of the parameter (i.e. *_byte) is undefined. |
References assign_bit, debugshell(), G_DAV, G_EOI, G_NDAC, G_NRFD, release_bit, s, gpib_controller_t::talks, and uart_puts().
Referenced by gpib_serial_poll(), and main().
uchar gpib_serial_poll | ( | void | ) |
execute serial polling
We return the talker address of the device that created the SRQ.
References address2TalkerAddress, cmd_buf, G_CMD_SPD, G_CMD_SPE, G_CMD_UNL, G_CMD_UNT, gpib_cmd(), gpib_receive(), gpib_controller_t::partners, TalkerAddress2Address, and uart_puts().
Referenced by main().
void gpib_set_partner | ( | uchar | address | ) |
Set device to be controlled.
address | Address of device. |
References gpib_controller_t::partneraddress.
Referenced by main().
Write GPIB string to bus.
See _gpib_write() for further information.
References _gpib_write().
Referenced by main().