EDT PCD SDK Documentation 6.1.0
|
#include "edtinc.h"
Data Structures | |
struct | edt_two_wire |
struct | EdtRegisterDescriptor |
Macros | |
#define | TWO_WIRE_SFP 0x03 |
#define | TWO_WIRE_XFP 0x06 |
#define | TWO_WIRE_SERIAL_ID_DEVICE 0x50 |
Typedefs | |
typedef struct edt_two_wire | EdtTwoWire |
Enumerations | |
enum | EdtTwoWireOptions { TWO_WIRE_OPT_CLK_STRETCH = (1 << 0) } |
Two-Wire interface options, for use in EdtTwoWire config struct. More... | |
Functions | |
int | edt_two_wire_reset (EdtDev edt_p, const EdtTwoWire *tw_ptr) |
Reset two wire interface in FPGA. More... | |
uint16_t | edt_two_wire_read (EdtDev edt_p, const EdtTwoWire *tw_ptr, uint8_t chip_id, uint32_t address, uint16_t len_data, uint8_t *data) |
Block read transaction. More... | |
int | edt_two_wire_write_byte (EdtDev edt_p, const EdtTwoWire *tw_ptr, uint8_t chip_id, uint32_t address, uint8_t data) |
Write a single byte. More... | |
void | edt_serial_dev_reg_write (EdtDev edt_p, uint32_t base_desc, uint8_t device_id, uint8_t address, uint8_t value) |
Write to a two-wire I2C or SPI device. More... | |
uint8_t | edt_serial_dev_reg_read (EdtDev edt_p, uint32_t base_desc, uint8_t device_id, uint8_t address) |
Read from a two-wire I2C or SPI device. More... | |
uint16_t | edt_serial_dev_reg_read_block (EdtDev edt_p, uint32_t base_desc, uint8_t device_id, uint8_t address, uint16_t length, uint8_t *block) |
Block read from a two-wire I2C or SPI device. More... | |
uint16_t | edt_serial_dev_reg_write_block (EdtDev edt_p, uint32_t base_desc, uint8_t device_id, uint8_t address, uint16_t length, uint8_t *block) |
Block write to a two-wire I2C or SPI device. More... | |
uint8_t | edt_serial_dev_set_bits (EdtDev edt_p, uint32_t base_desc, uint8_t device_id, uint8_t address, uint8_t value, uint8_t offset, uint8_t mask) |
Read/modify/write bits in a data byte on target device. More... | |
uint32_t | edt_get_two_wire_value (EdtDev edt_p, const EdtRegisterDescriptor *map, uint32_t base_desc, uint8_t device) |
Read arbitrary value up to 32-bits wide from an 8-bit interface. More... | |
int | edt_set_two_wire_value (EdtDev edt_p, const EdtRegisterDescriptor *map, uint32_t base_desc, uint32_t device, uint32_t value) |
Write arbitrary value up to 32-bits wide. More... | |
int | edt_two_wire_reg_dump_raw (EdtDev edt_p, const EdtRegisterDescriptor *map, uint32_t base_desc, uint32_t device) |
Read all registers included in a given register map and print to STDOUT. More... | |
int | edt_two_wire_reg_dump (EdtDev edt_p, const EdtRegisterDescriptor *map, uint32_t base_desc, uint32_t device) |
Read register fields from a register map and print to STDOUT. More... | |
Library to read a 2 wire protocol device such as a serial EEPROM or a diagnostic port on a serial transceiver.
The port must be implemented as a register address like the PCISS/GS OCM
The OCM has three 2-wire device addresses:
Some two wire devices have 1 byte address others 2 etc. The EdtTwoWire::address_length field designates number of bytes.
The page write size varies from device to device. Setting to 1 will work on anything but writes will be slow.
#define TWO_WIRE_SFP 0x03 |
ID of SFP-type transceivers. Section 4.2 in [1]
#define TWO_WIRE_XFP 0x06 |
ID of XFP-type transceivers. Section 4.2 in [1]
#define TWO_WIRE_SERIAL_ID_DEVICE 0x50 |
I2C Chip ID of SFF transceiver devices.
typedef struct edt_two_wire EdtTwoWire |
Two-wire interface configuration.
enum EdtTwoWireOptions |
Two-Wire interface options, for use in EdtTwoWire config struct.
int edt_two_wire_reset | ( | EdtDev | edt_p, |
const EdtTwoWire * | tw_ptr | ||
) |
Reset two wire interface in FPGA.
Send up to 9 SCLKs while reading SDA until SDA is high. Then enable SDA and bring it low to make an I2C start condition.
edt_p | The open EDT device handle. |
tw_ptr | Two-wire configuration. |
uint16_t edt_two_wire_read | ( | EdtDev | edt_p, |
const EdtTwoWire * | tw_ptr, | ||
uint8_t | chip_id, | ||
uint32_t | address, | ||
uint16_t | len_data, | ||
uint8_t * | data | ||
) |
Block read transaction.
edt_p | The open EDT device handle. | |
tw_ptr | Two-wire configuration. | |
chip_id | I2C chip ID of the target device. | |
address | Address/command to send to target. Number of bits in address configured by EdtTwoWire::address_length. | |
len_data | Number of bytes to read from target device. | |
[out] | data | Data read from target device. Must be at least len_data bytes. |
int edt_two_wire_write_byte | ( | EdtDev | edt_p, |
const EdtTwoWire * | tw_ptr, | ||
uint8_t | chip_id, | ||
uint32_t | address, | ||
uint8_t | data | ||
) |
Write a single byte.
edt_p | The open EDT device handle. |
tw_ptr | Two-wire configuration. |
chip_id | I2C chip ID of the target device. |
address | Address/command to send to target. Number of bits in address configured by EdtTwoWire::address_length. |
data | Byte to send to target. |
void edt_serial_dev_reg_write | ( | EdtDev | edt_p, |
uint32_t | base_desc, | ||
uint8_t | device_id, | ||
uint8_t | address, | ||
uint8_t | value | ||
) |
Write to a two-wire I2C or SPI device.
edt_p | The open EDT device handle. |
base_desc | The base address of the FPGA two-wire interface. |
device_id | 7-bit I2C chip id, or address extension for SPI. |
address | Target address/command. |
value | Data to write to the target. |
uint8_t edt_serial_dev_reg_read | ( | EdtDev | edt_p, |
uint32_t | base_desc, | ||
uint8_t | device_id, | ||
uint8_t | address | ||
) |
Read from a two-wire I2C or SPI device.
edt_p | The open EDT device handle. |
base_desc | The base address of the FPGA two-wire interface. |
device_id | 7-bit I2C chip id, or address extension for SPI. |
address | Target address/command. |
uint16_t edt_serial_dev_reg_read_block | ( | EdtDev | edt_p, |
uint32_t | base_desc, | ||
uint8_t | device_id, | ||
uint8_t | address, | ||
uint16_t | length, | ||
uint8_t * | block | ||
) |
Block read from a two-wire I2C or SPI device.
edt_p | The open EDT device handle. | |
base_desc | The base address of the FPGA two-wire interface. | |
device_id | 7-bit I2C chip id, or address extension for SPI. | |
address | Target address/command. | |
length | Number of bytes to read from target device. | |
[out] | block | Array of data read from target. Must be at least length bytes. |
uint16_t edt_serial_dev_reg_write_block | ( | EdtDev | edt_p, |
uint32_t | base_desc, | ||
uint8_t | device_id, | ||
uint8_t | address, | ||
uint16_t | length, | ||
uint8_t * | block | ||
) |
Block write to a two-wire I2C or SPI device.
Address in address will be incremented and sent before each data byte.
edt_p | The open EDT device handle. |
base_desc | The base address of the FPGA two-wire interface. |
device_id | 7-bit I2C chip id, or address extension for SPI. |
address | Target address/command. |
length | Number of bytes to write to target device. |
block | Data to send. Must be at least length bytes. |
uint8_t edt_serial_dev_set_bits | ( | EdtDev | edt_p, |
uint32_t | base_desc, | ||
uint8_t | device_id, | ||
uint8_t | address, | ||
uint8_t | value, | ||
uint8_t | offset, | ||
uint8_t | mask | ||
) |
Read/modify/write bits in a data byte on target device.
Useful to set specific bits in a bitfield of a target device register. For example, to set a value of 3 to a 2-bit field with an offset of 4 bits, pass 3 to value, 4 to offset, and 0x3 to mask.
edt_p | The open EDT device handle. |
base_desc | The base address of the FPGA two-wire interface. |
device_id | 7-bit I2C chip id, or address extension for SPI. |
address | Target address/command. |
value | Data value to write in the bitfield. |
offset | Bit offset in the target register. value will be left-shifted by this amount. |
mask | Bit mask to clear in byte read from target. Typically indicates the width of the bitfield. The mask will be shifted by offset. |
uint32_t edt_get_two_wire_value | ( | EdtDev | edt_p, |
const EdtRegisterDescriptor * | map, | ||
uint32_t | base_desc, | ||
uint8_t | device | ||
) |
Read arbitrary value up to 32-bits wide from an 8-bit interface.
edt_p | The open EDT device handle. |
map | Descriptor of register to read from. |
base_desc | The base address of the FPGA two-wire interface. |
device | 7-bit I2C chip id, or address extension for SPI. |
int edt_set_two_wire_value | ( | EdtDev | edt_p, |
const EdtRegisterDescriptor * | map, | ||
uint32_t | base_desc, | ||
uint32_t | device, | ||
uint32_t | value | ||
) |
Write arbitrary value up to 32-bits wide.
edt_p | The open EDT device handle. |
map | Descriptor of register to read from. |
base_desc | The base address of the FPGA two-wire interface. |
device | 7-bit I2C chip id, or address extension for SPI. |
value | Data value to write to target. |
int edt_two_wire_reg_dump_raw | ( | EdtDev | edt_p, |
const EdtRegisterDescriptor * | map, | ||
uint32_t | base_desc, | ||
uint32_t | device | ||
) |
Read all registers included in a given register map and print to STDOUT.
The entire 8-bit data value read from the target registers is shown. The field offsets and shifts specified in the register map are ignored.
edt_p | The open EDT device handle. |
map | Array of register descriptors to read from. Last element in the map MUST be all zeros to indicate the end of the array. |
base_desc | The base address of the FPGA two-wire interface. |
device | 7-bit I2C chip id, or address extension for SPI. |
int edt_two_wire_reg_dump | ( | EdtDev | edt_p, |
const EdtRegisterDescriptor * | map, | ||
uint32_t | base_desc, | ||
uint32_t | device | ||
) |
Read register fields from a register map and print to STDOUT.
Only shows the values of the register fields defined in the provided register map.
edt_p | The open EDT device handle. |
map | Array of register descriptors to read from. Last element in the map MUST be all zeros to indicate the end of the array. |
base_desc | The base address of the FPGA two-wire interface. |
device | 7-bit I2C chip id, or address extension for SPI. |