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

Commit

Permalink
Adds GPIO access from terminal for fallback image required for IO tes…
Browse files Browse the repository at this point in the history
…tings. Updated the test script to Python3.
  • Loading branch information
Marcelo Vicente committed Jan 17, 2020
1 parent a6a4f15 commit d5595a9
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 4 deletions.
32 changes: 31 additions & 1 deletion Vivado/ipmc_zynq_vivado.sdk/IPMC/src/ipmc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
#include "xscutimer.h"
#include "xscugic.h"
#include "xil_exception.h"
#include "xgpiops.h"

/* Include drivers */
#include <drivers/ad7689/ad7689.h>
Expand Down Expand Up @@ -106,6 +105,7 @@
// Application specific variables
std::vector<AD7689*> adc;
PSXADC *xadc = nullptr;
GPIO *gpio[6] = {nullptr};

Network *network = nullptr;
TelnetServer *telnet = nullptr;
Expand Down Expand Up @@ -168,6 +168,36 @@ void driverInit() {

xadc = new PSXADC(XPAR_XADCPS_0_DEVICE_ID);
if (!xadc) throw std::runtime_error("Failed to create xadc instance");

gpio[4] = new PSGPIO(XPAR_PS7_GPIO_0_DEVICE_ID, {10,11,12,13});
gpio[5] = new PSGPIO(XPAR_PS7_GPIO_0_DEVICE_ID, {39,40,41,45,47,48,49,50});

for (int i = 0; i < 4; i++) {
gpio[i] = new PLGPIO(PLGPIO::CHANNEL1, XPAR_AXI_GPIO_0_DEVICE_ID + i);
}

class EnableIOTesting final : public CommandParser::Command {
public:
EnableIOTesting() {};

virtual std::string getHelpText(const std::string &command) const {
return command + "\n\nExposes GPIO read/write/direction API for IO testing, USE WITH CARE.\n";
}

virtual void execute(std::shared_ptr<ConsoleSvc> console, const CommandParser::CommandParameters &parameters) {
static bool is_io_testing_enabled = false;

if (!is_io_testing_enabled) {
for (int i = 0; i < 6; i++) {
gpio[i]->registerConsoleCommands(console_command_parser, stdsprintf("gpio%d.", i));
}

is_io_testing_enabled = true;
}
}
};

console_command_parser.registerCommand("enable_io_testing", std::make_shared<EnableIOTesting>());
}


Expand Down
13 changes: 10 additions & 3 deletions test-suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,15 @@ def gpio_absn_to_interface(absn):
(243, 243),
}

def enable_io_testing(serial):
serial.write("enable_io_testing\r".encode())
serial.readline()

def gpio_get_direction(serial, gpio):
t = "gpio" + str(gpio) + ".direction\r"
serial.write(t.encode())
serial.readline()
r = serial.readline()
r = serial.readline().decode('utf-8')
hex = r.split("0x")[1].split("\r")[0]
return int(hex, 16)

Expand All @@ -258,15 +262,15 @@ def gpio_read(serial, gpio):
t = "gpio" + str(gpio) + ".read\r"
serial.write(t.encode())
serial.readline()
r = serial.readline()
r = serial.readline().decode('utf-8')
hex = r.split("0x")[1].split("\r")[0]
return int(hex, 16)

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

Expand Down Expand Up @@ -489,6 +493,9 @@ def main():

results = [0, 0, []]

enable_io_testing(ipmc)
enable_io_testing

test1 = run_hwaddr_test(ipmc)
test2 = run_pinshort_test(ipmc)
test3 = run_continuity_test(ipmc, ctrl)
Expand Down

0 comments on commit d5595a9

Please sign in to comment.