Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: azonenberg/openfpga
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 9da41dc34449
Choose a base ref
...
head repository: azonenberg/openfpga
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 0bdfb959df26
Choose a head ref
  • 3 commits
  • 4 files changed
  • 1 contributor

Commits on Apr 11, 2017

  1. Updated to latest logtools

    azonenberg committed Apr 11, 2017
    Copy the full SHA
    930681c View commit details
  2. Copy the full SHA
    06bd916 View commit details
  3. Copy the full SHA
    0bdfb95 View commit details
Showing with 157 additions and 1 deletion.
  1. +1 −0 src/CMakeLists.txt
  2. +11 −0 src/gp4tchar/CMakeLists.txt
  3. +144 −0 src/gp4tchar/main.cpp
  4. +1 −1 src/log
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@ add_subdirectory(gpdevboard)
add_subdirectory(greenpak4)
add_subdirectory(gp4prog)
add_subdirectory(gp4par)
add_subdirectory(gp4tchar)
add_subdirectory(xbpar)
add_subdirectory(log)
add_subdirectory(gpcosim)
11 changes: 11 additions & 0 deletions src/gp4tchar/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
add_executable(gp4tchar
main.cpp)

target_link_libraries(gp4tchar
gpdevboard)

#Don't install, this is a development tool only
#install(TARGETS gp4tchar
# RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})


144 changes: 144 additions & 0 deletions src/gp4tchar/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
/***********************************************************************************************************************
* Copyright (C) 2016 Andrew Zonenberg and contributors *
* *
* This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General *
* Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) *
* any later version. *
* *
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for *
* more details. *
* *
* You should have received a copy of the GNU Lesser General Public License along with this program; if not, you may *
* find one here: *
* https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt *
* or you may search the http://www.gnu.org website for the version 2.1 license, or you may write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA *
**********************************************************************************************************************/

#include <cstdlib>
#include <cstring>
#include <cmath>
#include <unistd.h>
#include <log.h>
#include <gpdevboard.h>
#ifndef _WIN32
#include <termios.h>
#else
#include <conio.h>
#endif

using namespace std;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Entry point

int main(int argc, char* argv[])
{
Severity console_verbosity = Severity::NOTICE;
unsigned int nboard = 0;

//Parse command-line arguments
for(int i=1; i<argc; i++)
{
string s(argv[i]);

//Let the logger eat its args first
if(ParseLoggerArguments(i, argc, argv, console_verbosity))
continue;

else if(s == "--device")
{
if(i+1 < argc)
nboard = atoi(argv[++i]);

else
{
printf("--device requires an argument\n");
return 1;
}
}

else
{
printf("Unrecognized command-line argument \"%s\", use --help\n", s.c_str());
return 1;
}
}

//Set up logging
g_log_sinks.emplace(g_log_sinks.begin(), new STDLogSink(console_verbosity));

//Print status message
LogNotice("GreenPAK timing characterization helper\n");
LogNotice("Right now, just enables pins used by pmod-gpdevboard and sets up IO\n");

//Open the dev board
hdevice hdev = OpenBoard(nboard);
if(!hdev)
return 1;

//Light up the status LED
if(!SetStatusLED(hdev, 1))
return 1;

//DO NOT do anything that might make the IO voltage change, or send Vpp!

//Reset all signal generators we may have used during setup
if(!ResetAllSiggens(hdev))
return 1;

//Reset I/O config
IOConfig ioConfig;
for(size_t i = 2; i <= 20; i++)
ioConfig.driverConfigs[i] = TP_RESET;
if(!SetIOConfig(hdev, ioConfig))
return false;

unsigned int pins[] =
{
2, 3, 4, 5, 12, 13, 14, 15
};

//Configure I/O voltage
IOConfig config;
for(auto npin : pins)
{
config.driverConfigs[npin] = TP_FLOAT;
config.ledEnabled[npin] = true;
config.expansionEnabled[npin] = true;
}
if(!SetIOConfig(hdev, config))
return 1;

//Do not change this voltage! This is what the FPGA uses
float voltage = 3.3;
if(!ConfigureSiggen(hdev, 1, voltage))
return 1;

//Hold the lock until something happens
bool lock = true;
if(lock)
{
LogNotice("Holding lock on board, press any key to exit...\n");
SetStatusLED(hdev, 1);

#ifndef _WIN32
struct termios oldt, newt;
tcgetattr ( STDIN_FILENO, &oldt );
newt = oldt;
newt.c_lflag &= ~( ICANON | ECHO );
tcsetattr ( STDIN_FILENO, TCSANOW, &newt );
getchar();
tcsetattr ( STDIN_FILENO, TCSANOW, &oldt );
#else
_getch();
#endif
}

//Done
LogNotice("Done, resetting board\n");
SetStatusLED(hdev, 0);
Reset(hdev);
USBCleanup(hdev);
}
2 changes: 1 addition & 1 deletion src/log
Submodule log updated from 8015d9 to a0efde