1#ifndef PFLIB_lpGBT_H_INCLUDED
2#define PFLIB_lpGBT_H_INCLUDED
8#include "pflib/Exception.h"
9#include "pflib/lpgbt/GPIO.h"
24 virtual void write_reg(uint16_t reg, uint8_t value) = 0;
56 void write(uint16_t reg, uint8_t value) { tport_.
write_reg(reg, value); }
57 uint8_t read(uint16_t reg) {
return tport_.
read_reg(reg); }
70 void bit_set(uint16_t reg,
int ibit);
71 void bit_clr(uint16_t reg,
int ibit);
93 static const int GPIO_IS_OUTPUT = 0x01;
94 static const int GPIO_IS_PULLUP = 0x02;
95 static const int GPIO_IS_PULLDOWN = 0x04;
96 static const int GPIO_IS_STRONG = 0x08;
109 uint16_t
adc_read(
int ipos,
int ineg,
int gain = 1);
123 void setup_eclk(
int ieclk,
int rate,
bool polarity =
true,
int strength = 4);
137 void setup_erx(
int ierx,
int align,
int alignphase = 0,
int speed = 3,
138 bool invert =
false,
bool term =
true,
int equalization = 0,
139 bool acbias =
false);
151 int data_rate_code = 3,
152 uint8_t bert_time_code = 4);
161 void setup_etx(
int ietx,
bool enable,
bool invert =
false,
int drive = 4,
162 int pe_mode = 0,
int pe_strength = 0,
int pe_width = 0);
174 void setup_ec(
bool invert_tx =
false,
int drive = 4,
bool fixed =
false,
175 int alignphase = 0,
bool invert_rx =
false,
bool term =
true,
176 bool acbias =
false,
bool pullup =
false);
178 uint32_t read_efuse(uint16_t addr);
189 void setup_i2c(
int ibus,
int speed_khz,
bool scl_drive =
false,
190 bool strong_scl =
true,
bool strong_sda =
true,
191 bool pull_up_scl =
false,
bool pull_up_sda =
false);
197 void i2c_write(
int ibus, uint8_t i2c_addr, uint8_t value);
200 void i2c_write(
int ibus, uint8_t i2c_addr,
Representation of GPIO controller.
Definition GPIO.h:12
virtual void write_regs(uint16_t reg, const std::vector< uint8_t > &value)
Write the given values to a sequence of registers beginning with the listed one.
Definition lpGBT.cxx:15
virtual uint8_t read_reg(uint16_t reg)=0
Read the contents of the identified single register.
virtual void write_reg(uint16_t reg, uint8_t value)=0
Write the given value to the identified single register.
virtual std::vector< uint8_t > read_regs(uint16_t reg, int n)
Read the contents of several registers beginning with the listed one.
Definition lpGBT.cxx:10
Class which provides an interface with an lpGBT ASIC as mounted on an LDMX mezzanine.
Definition lpGBT.h:52
uint32_t serial_number()
Get the serial number (somewhat complex)
Definition lpGBT.cxx:172
void setup_eclk(int ieclk, int rate, bool polarity=true, int strength=4)
Setup the given eclk.
Definition lpGBT.cxx:543
void i2c_write(int ibus, uint8_t i2c_addr, uint8_t value)
Start an I2C write of a single byte.
Definition lpGBT.cxx:623
int status()
Get the lpGBT status (power up state machine)
Definition lpGBT.cxx:694
std::vector< uint8_t > i2c_read_data(int ibus)
Get back the data from the read.
Definition lpGBT.cxx:677
void setup_etx(int ietx, bool enable, bool invert=false, int drive=4, int pe_mode=0, int pe_strength=0, int pe_width=0)
Setup the given elink-tx.
Definition lpGBT.cxx:491
uint16_t gpio_get()
Get the full GPIO array.
Definition lpGBT.cxx:232
int gpio_cfg_get(int ibit)
Get the GPIO pin configuration.
Definition lpGBT.cxx:239
bool i2c_transaction_check(int ibus, bool wait=false)
Check for transaction completion optionally waiting for completion, throws exception on failure.
Definition lpGBT.cxx:651
void check_prbs_errors_erx(int group, int channel, bool lpgbt_only=false, int data_rate_code=3, uint8_t bert_time_code=4)
Check for PRBS errors on given eRx group and channel.
Definition lpGBT.cxx:367
void gpio_cfg_set(int ibit, int cfg, const std::string &name="")
Set the GPIO pin configuration.
Definition lpGBT.cxx:261
void finalize_setup()
finalize the configuration
Definition lpGBT.cxx:692
uint16_t adc_read(int ipos, int ineg, int gain=1)
Carry out an ADC read for the given pair of channels Valid gain values are 1 or 2,...
Definition lpGBT.cxx:310
uint16_t adc_resistance_read(int ipos, int current, int gain=1)
Carry out an ADC read for the given channel, using the internal reference voltage for the other side ...
Definition lpGBT.cxx:291
void setup_erx(int ierx, int align, int alignphase=0, int speed=3, bool invert=false, bool term=true, int equalization=0, bool acbias=false)
Setup the given elink-rx.
Definition lpGBT.cxx:353
void gpio_set(int ibit, bool high)
Set the given gpio bit.
Definition lpGBT.cxx:199
void setup_i2c(int ibus, int speed_khz, bool scl_drive=false, bool strong_scl=true, bool strong_sda=true, bool pull_up_scl=false, bool pull_up_sda=false)
Setup an I2C bus.
Definition lpGBT.cxx:578
void start_i2c_read(int ibus, uint8_t i2c_addr, int len=1)
Start an I2C read.
Definition lpGBT.cxx:607
GPIO & gpio_interface()
Get the pflib GPIO object.
Definition lpGBT.h:103
void setup_ec(bool invert_tx=false, int drive=4, bool fixed=false, int alignphase=0, bool invert_rx=false, bool term=true, bool acbias=false, bool pullup=false)
Setup the EC port.
Definition lpGBT.cxx:529
This version of the fast control code interfaces with the CMS Fast control library which can be contr...
Definition Backend.cxx:3