Skip to content
This repository was archived by the owner on May 19, 2022. It is now read-only.

Commit d5595a9

Browse files
author
Marcelo Vicente
committed
Adds GPIO access from terminal for fallback image required for IO testings. Updated the test script to Python3.
1 parent a6a4f15 commit d5595a9

2 files changed

Lines changed: 41 additions & 4 deletions

File tree

Vivado/ipmc_zynq_vivado.sdk/IPMC/src/ipmc.cpp

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
#include "xscutimer.h"
4343
#include "xscugic.h"
4444
#include "xil_exception.h"
45-
#include "xgpiops.h"
4645

4746
/* Include drivers */
4847
#include <drivers/ad7689/ad7689.h>
@@ -106,6 +105,7 @@
106105
// Application specific variables
107106
std::vector<AD7689*> adc;
108107
PSXADC *xadc = nullptr;
108+
GPIO *gpio[6] = {nullptr};
109109

110110
Network *network = nullptr;
111111
TelnetServer *telnet = nullptr;
@@ -168,6 +168,36 @@ void driverInit() {
168168

169169
xadc = new PSXADC(XPAR_XADCPS_0_DEVICE_ID);
170170
if (!xadc) throw std::runtime_error("Failed to create xadc instance");
171+
172+
gpio[4] = new PSGPIO(XPAR_PS7_GPIO_0_DEVICE_ID, {10,11,12,13});
173+
gpio[5] = new PSGPIO(XPAR_PS7_GPIO_0_DEVICE_ID, {39,40,41,45,47,48,49,50});
174+
175+
for (int i = 0; i < 4; i++) {
176+
gpio[i] = new PLGPIO(PLGPIO::CHANNEL1, XPAR_AXI_GPIO_0_DEVICE_ID + i);
177+
}
178+
179+
class EnableIOTesting final : public CommandParser::Command {
180+
public:
181+
EnableIOTesting() {};
182+
183+
virtual std::string getHelpText(const std::string &command) const {
184+
return command + "\n\nExposes GPIO read/write/direction API for IO testing, USE WITH CARE.\n";
185+
}
186+
187+
virtual void execute(std::shared_ptr<ConsoleSvc> console, const CommandParser::CommandParameters &parameters) {
188+
static bool is_io_testing_enabled = false;
189+
190+
if (!is_io_testing_enabled) {
191+
for (int i = 0; i < 6; i++) {
192+
gpio[i]->registerConsoleCommands(console_command_parser, stdsprintf("gpio%d.", i));
193+
}
194+
195+
is_io_testing_enabled = true;
196+
}
197+
}
198+
};
199+
200+
console_command_parser.registerCommand("enable_io_testing", std::make_shared<EnableIOTesting>());
171201
}
172202

173203

test-suite.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,15 @@ def gpio_absn_to_interface(absn):
233233
(243, 243),
234234
}
235235

236+
def enable_io_testing(serial):
237+
serial.write("enable_io_testing\r".encode())
238+
serial.readline()
239+
236240
def gpio_get_direction(serial, gpio):
237241
t = "gpio" + str(gpio) + ".direction\r"
238242
serial.write(t.encode())
239243
serial.readline()
240-
r = serial.readline()
244+
r = serial.readline().decode('utf-8')
241245
hex = r.split("0x")[1].split("\r")[0]
242246
return int(hex, 16)
243247

@@ -258,15 +262,15 @@ def gpio_read(serial, gpio):
258262
t = "gpio" + str(gpio) + ".read\r"
259263
serial.write(t.encode())
260264
serial.readline()
261-
r = serial.readline()
265+
r = serial.readline().decode('utf-8')
262266
hex = r.split("0x")[1].split("\r")[0]
263267
return int(hex, 16)
264268

265269
def gpio_read_bit(serial, gpio, bit):
266270
t = "gpio" + str(gpio) + ".read\r"
267271
serial.write(t.encode())
268272
serial.readline()
269-
r = serial.readline()
273+
r = serial.readline().decode('utf-8')
270274
hex = r.split("0x")[1].split("\r")[0]
271275
return ((int(hex, 16) & (1 << bit)) != 0)
272276

@@ -489,6 +493,9 @@ def main():
489493

490494
results = [0, 0, []]
491495

496+
enable_io_testing(ipmc)
497+
enable_io_testing
498+
492499
test1 = run_hwaddr_test(ipmc)
493500
test2 = run_pinshort_test(ipmc)
494501
test3 = run_continuity_test(ipmc, ctrl)

0 commit comments

Comments
 (0)