21 #include "DynamicPinList.h" 22 #include "platform/FileHandle.h" 23 #include "platform/Callback.h" 24 #include "drivers/DigitalInOut.h" 76 typedef uint8_t PhysicalIndex;
77 const PhysicalIndex physical_nc = 0xFF;
103 LogicalPinSPIMosi = 0,
104 LogicalPinSPIMiso = 1,
105 LogicalPinSPISclk = 2,
106 LogicalPinSPISsel = 3,
108 LogicalPinIOMetrics0 = 0,
109 LogicalPinIOMetrics1 = 1,
110 LogicalPinIOMetrics2 = 2,
111 LogicalPinIOMetrics3 = 3,
112 LogicalPinIOMetrics4 = 4,
113 LogicalPinIOMetrics5 = 5,
114 LogicalPinIOMetrics6 = 6,
115 LogicalPinIOMetrics7 = 7,
117 LogicalPinUARTTx = 0,
118 LogicalPinUARTRx = 1,
119 LogicalPinUARTCts = 2,
120 LogicalPinUARTRts = 3,
122 LogicalPinI2CSda = 0,
123 LogicalPinI2CScl = 1,
127 LogicalPinTotal = LogicalPinCount * LogicalPinBanks
139 PeripheralSPISlave = 6
243 void pin_map_set(PinName physical, LogicalPin logical);
319 void gpio_write(LogicalPin gpio,
int value,
bool drive);
593 int io_expander_i2c_read(uint8_t i2c_index, uint8_t dev_addr, uint8_t start_reg, uint8_t *data,
int length);
618 int io_expander_i2c_read_bb(SystemPin sda, SystemPin scl, uint8_t dev_addr, uint8_t start_reg, uint8_t *data,
int length);
776 void pin_map_index(PhysicalIndex physical_index, LogicalPin logical);
788 void write(uint32_t addr,
const uint8_t *data, uint32_t size);
797 void read(uint32_t addr, uint8_t *data, uint32_t size);
863 bool _find_control_indexes(PhysicalIndex &clk_out, PhysicalIndex &mosi_out, PhysicalIndex &miso_out, PhysicalIndex &aux_out);
870 void _setup_control_pins();
877 void _free_control_pins();
887 void _update_control_pins();
894 bool _update_needed();
903 PhysicalIndex _mapping[LogicalPinCount * (LogicalPinBanks + 1)];
908 PhysicalIndex _clk_index;
909 PhysicalIndex _mosi_index;
910 PhysicalIndex _miso_index;
911 PhysicalIndex _aux_index;
920 int _init_io_exp_rst_flag;
uint16_t get_anin_measurement(int index)
Similar to 'get_analogmuxin_measurement' but returns the current XADC measurement for ANIN0-3...
bool self_test_all()
Run all self tests.
bool self_test_control_miso()
Test that all allowed control miso lines can be used.
bool self_test_control_current()
Test that the current control channel works.
bool firmware_dump(mbed::FileHandle *dest, mbed::Callback< void(uint8_t)> progress=mbed::Callback< void(uint8_t)>())
Read FPGA CI Test Shield firmware.
void sys_pin_mode_spi_serial_flash(PhysicalIndex mosi, PhysicalIndex miso, PhysicalIndex clk, PhysicalIndex ssel)
Set the current system pin mode to serial flash.
int io_expander_i2c_read_bb(SystemPin sda, SystemPin scl, uint8_t dev_addr, uint8_t start_reg, uint8_t *data, int length)
I2C read on I2C system channels 0, 1, or 2 (bit banged version of function, bit banged over control c...
bool firmware_update(mbed::FileHandle *src, mbed::Callback< void(uint8_t)> progress=mbed::Callback< void(uint8_t)>())
Program new FPGA CI Test Shield firmware.
void reprogram()
Reprogram the FPGA.
bool sys_pin_read(SystemPin pin)
Read from the given system pin.
void get_anin_sum_samples_cycles(int index, uint64_t *sum, uint32_t *samples, uint64_t *cycles)
Gets (by reference) the sum of all ANIN ADC results for any of the 4 ANIN pins specified by the index...
void io_metrics_start()
Start recording metrics on all logical pins.
uint32_t version()
Get the running FPGA firmware version.
uint16_t get_analogmuxin_measurement()
Get the 12-bit analog to digital conversion result from the FPGA.
PullMode
FPGA Pullup mode.
void set_pwm_enable(bool val)
Turn on/off pwm output on FPGA to test Mbed AnalogIn.
uint32_t io_metrics_falling_edges(LogicalPin pin)
Get the number of falling edges.
void set_snapshot()
Allows safe reading of FPGA ADC related values while the FPGA ADC is on If snapshot is set then the A...
void gpio_write(LogicalPin gpio, int value, bool drive)
Set value and drive of a gpio pin.
int set_mux_addr_index(int index)
Set the AnalogMuxAddr pins on the FPGA via pin index.
A digital input/output, used for setting or reading a bi-directional pin.
void set_control_pins_auto()
Enable automatic selection and update of control pins.
void peripherals_reset()
Reset all peripherals.
int gpio_read(LogicalPin gpio)
Read a gpio pin.
void set_sample_adc(bool val)
Turn the FPGA ADC on and off (power management data will be collected while the ADC is on) ...
void write(uint32_t addr, const uint8_t *data, uint32_t size)
Write to tester memory.
void set_mux_enable(bool val)
Turn on/off the analog muxes.
void pin_map_set(PinName physical, LogicalPin logical)
Map a physical pin to the given logical pin.
void select_peripheral(Peripheral peripheral)
Select the currently active peripheral.
uint8_t io_expander_read_index(int index, IOExpanderReg reg_type)
Read a bit for a specific Mbed pin that is set in the input, output, or configuration registers insid...
void set_analog_out(bool enable, float voltage)
Create an analog voltage via the FPGA sys pwm in order to test Mbed AnalogIn.
MbedTester(const PinList *form_factor, const PinList *exclude_pins)
Construct a new MbedTester object.
void sys_pin_write(SystemPin pin, int value, bool drive)
Write to the given system pin.
void pin_map_reset()
Reset all pin mappings.
void set_control_pins_manual(PinName clk, PinName mosi, PinName miso, PinName aux)
Set the control pins to use for communication.
void reset()
Reset everything.
float get_analog_in()
Get the result of the analog to digital conversion computed on the FPGA in the form of a voltage read...
~MbedTester()
Destroy and cleanup resources associated with this object.
int pin_set_pull_index(int index, PullMode mode)
Configure an Mbed pin for a pulldown resistor, pullup resistor, or tristate mode via pin index...
int io_expander_i2c_read(uint8_t i2c_index, uint8_t dev_addr, uint8_t start_reg, uint8_t *data, int length)
I2C read on I2C system channels 0, 1, or 2.
bool get_pwm_enable()
Check if FPGA pwm out is on or off.
uint32_t io_metrics_max_pulse_low(LogicalPin pin)
Get the longest low pulse recorded.
void io_metrics_continue()
Continue recording metrics on all logical pins.
int io_expander_i2c_write_bb(SystemPin sda, SystemPin scl, uint8_t dev_addr, uint8_t *data, int length)
I2C write on I2C system channels 0, 1, or 2 (bit banged version of function, bit banged over control ...
uint8_t get_pwm_cycles_high()
Get the number of cycles that are high (duty cycle) from FPGA pwm.
void io_metrics_stop()
Stop recording metrics on all logical pins.
void sys_pin_mode_disabled()
Set the current system pin mode to disabled.
void read(uint32_t addr, uint8_t *data, uint32_t size)
Read from tester memory.
uint32_t get_pwm_period()
Get the pwm output period of the FPGA.
int set_mux_addr(PinName pin)
Set the AnalogMuxAddr pins on the FPGA via PinName.
int pin_set_pull_bb(PinName pin, PullMode mode)
Configure an Mbed pin for a pulldown resistor, pullup resistor, or tristate mode (this version of the...
void pin_map_index(PhysicalIndex physical_index, LogicalPin logical)
Map a physical pin index to the given logical pin.
uint32_t io_metrics_min_pulse_high(LogicalPin pin)
Get the shortest high pulse recorded.
uint32_t io_metrics_min_pulse_low(LogicalPin pin)
Get the shortest low pulse recorded.
float get_anin_voltage(int index)
Similar to 'get_analog_in' but returns a voltage reading from ANIN0-3.
void set_pwm_period_and_cycles_high(uint32_t period, uint32_t cycles_high)
Set the pwm output period and number of cycles high (duty cycle) on the FPGA.
void pin_pull_reset_all()
Reset the IO expander modules.
int io_expander_i2c_write(uint8_t i2c_index, uint8_t dev_addr, uint8_t *data, int length)
I2C write on I2C system channels 0, 1, or 2.
bool firmware_dump_all(mbed::FileHandle *dest, mbed::Callback< void(uint8_t)> progress=mbed::Callback< void(uint8_t)>())
Read FPGA CI Test Shield flash.
The base class for controlling the FPGA CI Test Shield.
uint32_t io_metrics_rising_edges(LogicalPin pin)
Get the number of rising edges.
bool self_test_control_channels()
Test that all allowed control channels can be used.
Callback class based on template specialization.
uint8_t io_expander_read_bb(PinName pin, IOExpanderReg reg_type)
Read a bit for a specific Mbed pin that is set in the input, output, or configuration registers insid...
int pin_set_pull(PinName pin, PullMode mode)
Configure an Mbed pin for a pulldown resistor, pullup resistor, or tristate mode via PinName...
uint8_t io_expander_read(PinName pin, IOExpanderReg reg_type)
Read a bit for a specific Mbed pin that is set in the input, output, or configuration registers insid...
void sys_pin_mode_i2c_io_expander(int index, PhysicalIndex sda_in, PhysicalIndex sda_val, PhysicalIndex scl_in, PhysicalIndex scl_val)
Set the current system pin mode to io expander I2C bus.
uint32_t io_metrics_max_pulse_high(LogicalPin pin)
Get the longest high pulse recorded.