29 lines
779 B
C++
29 lines
779 B
C++
#include "pip.h"
|
|
#include "pispi.h"
|
|
|
|
|
|
int main(int argc, char *argv[]) {
|
|
PICLI cli(argc, argv);
|
|
cli.setOptionalArgumentsCount(1);
|
|
cli.addArgument("dev", true);
|
|
cli.addArgument("speed", true);
|
|
if (!cli.hasArgument("dev")) {
|
|
piCout << "no device";
|
|
return 0;
|
|
}
|
|
PIString path = cli.argumentValue("dev");
|
|
PISPI spi(path, 1000000);
|
|
piCout << "SPI" << path;
|
|
//spi.setDebug(true);
|
|
if (cli.hasArgument("speed")) spi.setSpeed(cli.argumentValue("speed").toInt());
|
|
piCout << "try opening..";
|
|
bool ok = spi.open();
|
|
piCout << "open" << ok;
|
|
int r = spi.write(PIByteArray::fromHex("0000000000000000000000000000000000000000000000000000000000000000"));
|
|
piCout << "write" << r;
|
|
r = spi.readForTime(10).toHex();
|
|
piCout << "read" << r;
|
|
return 0;
|
|
}
|
|
|