mirror of
https://github.com/preble/libpinproc
synced 2026-02-24 18:25:23 +01:00
Merge remote-tracking branch 'Compy/dev' into dev
# Conflicts: # CMakeLists.txt
This commit is contained in:
@@ -51,6 +51,7 @@ option(APPLE_UNIVERSAL_BIN "Apple: Build universal binary" OFF)
|
|||||||
option(MSVC_SHARED_RT "MSVC: Build with shared runtime libs (/MD)" ON)
|
option(MSVC_SHARED_RT "MSVC: Build with shared runtime libs (/MD)" ON)
|
||||||
option(MSVC_STHREADED_RT "MSVC: Build with single-threaded static runtime libs (/ML until VS .NET 2003)" OFF)
|
option(MSVC_STHREADED_RT "MSVC: Build with single-threaded static runtime libs (/ML until VS .NET 2003)" OFF)
|
||||||
|
|
||||||
|
option(CROSS_ROOT "Cross-compilation root path" OFF)
|
||||||
|
|
||||||
###
|
###
|
||||||
### Sources, headers, directories and libs
|
### Sources, headers, directories and libs
|
||||||
@@ -77,8 +78,13 @@ endif()
|
|||||||
# use -DEXTRA_INC="<path>;<path>" and -DEXTRA_LINK="<path>;<path>"
|
# use -DEXTRA_INC="<path>;<path>" and -DEXTRA_LINK="<path>;<path>"
|
||||||
set(EXTRA_INC "" CACHE STRING "Extra include directories separated by ;")
|
set(EXTRA_INC "" CACHE STRING "Extra include directories separated by ;")
|
||||||
set(EXTRA_LINK "" CACHE STRING "Extra link directories separated by ;")
|
set(EXTRA_LINK "" CACHE STRING "Extra link directories separated by ;")
|
||||||
|
if(CROSS_ROOT)
|
||||||
|
include_directories(${PINPROC_SOURCE_DIR}/include ${EXTRA_INC} ${CROSS_ROOT}/usr/local/include)
|
||||||
|
link_directories(${EXTRA_LINK} ${CROSS_ROOT}/usr/local/lib)
|
||||||
|
else()
|
||||||
include_directories(${PINPROC_SOURCE_DIR}/include ${EXTRA_INC} /usr/local/include)
|
include_directories(${PINPROC_SOURCE_DIR}/include ${EXTRA_INC} /usr/local/include)
|
||||||
link_directories(${EXTRA_LINK} /usr/local/lib)
|
link_directories(${EXTRA_LINK} /usr/local/lib)
|
||||||
|
endif()
|
||||||
|
|
||||||
set(YAML_CPP_LIB "yaml-cpp")
|
set(YAML_CPP_LIB "yaml-cpp")
|
||||||
set(YAML_CPP_LIB_DBG "${YAML_CPP_LIB}")
|
set(YAML_CPP_LIB_DBG "${YAML_CPP_LIB}")
|
||||||
@@ -246,18 +252,18 @@ if(PINPROC_BUILD_TOOLS)
|
|||||||
# Create a target for the test tool
|
# Create a target for the test tool
|
||||||
#TODO: use add_subdirectory() and separate CMakeLists.txt (like yaml-cpp)
|
#TODO: use add_subdirectory() and separate CMakeLists.txt (like yaml-cpp)
|
||||||
# see http://www.cmake.org/cmake/help/cmake-2-8-docs.html#command:add_subdirectory
|
# see http://www.cmake.org/cmake/help/cmake-2-8-docs.html#command:add_subdirectory
|
||||||
add_executable(pinproctest
|
#add_executable(pinproctest
|
||||||
examples/pinproctest/pinproctest.cpp
|
# examples/pinproctest/pinproctest.cpp
|
||||||
examples/pinproctest/drivers.cpp
|
# examples/pinproctest/drivers.cpp
|
||||||
examples/pinproctest/dmd.cpp
|
# examples/pinproctest/dmd.cpp
|
||||||
examples/pinproctest/switches.cpp
|
# examples/pinproctest/switches.cpp
|
||||||
examples/pinproctest/alphanumeric.cpp
|
# examples/pinproctest/alphanumeric.cpp
|
||||||
)
|
#)
|
||||||
target_link_libraries(pinproctest
|
#target_link_libraries(pinproctest
|
||||||
pinproc
|
# pinproc
|
||||||
optimized ${YAML_CPP_LIB}
|
# optimized ${YAML_CPP_LIB}
|
||||||
debug ${YAML_CPP_LIB_DBG}
|
# debug ${YAML_CPP_LIB_DBG}
|
||||||
)
|
#)
|
||||||
|
|
||||||
# Create a target for the firmware tool
|
# Create a target for the firmware tool
|
||||||
#TODO: use add_subdirectory() and separate CMakeLists.txt (like yaml-cpp)
|
#TODO: use add_subdirectory() and separate CMakeLists.txt (like yaml-cpp)
|
||||||
|
|||||||
3
Makefile
3
Makefile
@@ -10,7 +10,6 @@ LIBPINPROC_DYLIB = bin/libpinproc.dylib
|
|||||||
SRCS = src/pinproc.cpp src/PRDevice.cpp src/PRHardware.cpp
|
SRCS = src/pinproc.cpp src/PRDevice.cpp src/PRHardware.cpp
|
||||||
OBJS := $(SRCS:.cpp=.o)
|
OBJS := $(SRCS:.cpp=.o)
|
||||||
INCLUDES = include/pinproc.h src/PRCommon.h src/PRDevice.h src/PRHardware.h
|
INCLUDES = include/pinproc.h src/PRCommon.h src/PRDevice.h src/PRHardware.h
|
||||||
LIBS = usb ftdi
|
|
||||||
|
|
||||||
.PHONY: libpinproc
|
.PHONY: libpinproc
|
||||||
libpinproc: $(LIBPINPROC) $(LIBPINPROC_DYLIB)
|
libpinproc: $(LIBPINPROC) $(LIBPINPROC_DYLIB)
|
||||||
@@ -20,7 +19,7 @@ $(LIBPINPROC): $(OBJS)
|
|||||||
$(RANLIB) $@
|
$(RANLIB) $@
|
||||||
|
|
||||||
$(LIBPINPROC_DYLIB): $(OBJS)
|
$(LIBPINPROC_DYLIB): $(OBJS)
|
||||||
g++ -dynamiclib -o $@ /usr/local/lib/libftdi.dylib $(LDFLAGS) $(OBJS)
|
g++ -dynamiclib -o $@ `pkg-config --libs libftdi1` $(LDFLAGS) $(OBJS)
|
||||||
|
|
||||||
.cpp.o:
|
.cpp.o:
|
||||||
$(CC) $(LIBPINPROC_CFLAGS) $(CFLAGS) -o $@ $<
|
$(CC) $(LIBPINPROC_CFLAGS) $(CFLAGS) -o $@ $<
|
||||||
|
|||||||
5
debian/changelog
vendored
Normal file
5
debian/changelog
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
libpinproc (0.1.0-1) trusty; urgency=low
|
||||||
|
|
||||||
|
* Initial release
|
||||||
|
|
||||||
|
-- Jan Kantert <jan-mpf@kantert.net> Wed, 10 Feb 2016 20:21:33 +0100
|
||||||
1
debian/compat
vendored
Normal file
1
debian/compat
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
9
|
||||||
21
debian/control
vendored
Normal file
21
debian/control
vendored
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
Source: libpinproc
|
||||||
|
Priority: optional
|
||||||
|
Maintainer: Jan Kantert <jan-mpf@kantert.net>
|
||||||
|
Build-Depends: debhelper (>= 8.0.0)
|
||||||
|
Standards-Version: 3.9.4
|
||||||
|
Section: libs
|
||||||
|
Homepage: https://github.com/jabdoa2/libpinproc
|
||||||
|
|
||||||
|
Package: libpinproc-dev
|
||||||
|
Section: libdevel
|
||||||
|
Architecture: any
|
||||||
|
Depends: libpinproc (= ${binary:Version})
|
||||||
|
Description: Devel header for libpinproc
|
||||||
|
Lib to speak to the P-Roc and P3-Roc hardware from Multimorphic
|
||||||
|
|
||||||
|
Package: libpinproc
|
||||||
|
Section: libs
|
||||||
|
Architecture: any
|
||||||
|
Depends: ${shlibs:Depends}, ${misc:Depends}
|
||||||
|
Description: libpinproc
|
||||||
|
Lib to speak to the P-Roc and P3-Roc hardware from Multimorphic
|
||||||
13
debian/copyright
vendored
Normal file
13
debian/copyright
vendored
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
|
||||||
|
Upstream-Name: libpinproc
|
||||||
|
Source: README.markdown
|
||||||
|
|
||||||
|
Files: *
|
||||||
|
Copyright: 2009 Gerry Stellenberg
|
||||||
|
2009 Adam Preble
|
||||||
|
License: AS IS
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
.
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
.
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
0
debian/docs
vendored
Normal file
0
debian/docs
vendored
Normal file
2
debian/files
vendored
Normal file
2
debian/files
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
libpinproc-dev_0.1.0-1_amd64.deb libdevel optional
|
||||||
|
libpinproc_0.1.0-1_amd64.deb libs optional
|
||||||
24
debian/libpinproc-dev.debhelper.log
vendored
Normal file
24
debian/libpinproc-dev.debhelper.log
vendored
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
dh_auto_configure
|
||||||
|
dh_auto_build
|
||||||
|
dh_auto_test
|
||||||
|
dh_prep
|
||||||
|
dh_installdirs
|
||||||
|
override_dh_auto_install dh_auto_install
|
||||||
|
dh_auto_install
|
||||||
|
dh_install
|
||||||
|
dh_installdocs
|
||||||
|
dh_installchangelogs
|
||||||
|
dh_perl
|
||||||
|
dh_link
|
||||||
|
dh_compress
|
||||||
|
dh_fixperms
|
||||||
|
dh_strip
|
||||||
|
dh_makeshlibs
|
||||||
|
override_dh_shlibdeps dh_shlibdeps
|
||||||
|
dh_shlibdeps
|
||||||
|
dh_installdeb
|
||||||
|
dh_gencontrol
|
||||||
|
dh_md5sums
|
||||||
|
dh_builddeb
|
||||||
|
dh_builddeb
|
||||||
|
dh_builddeb
|
||||||
2
debian/libpinproc-dev.dirs
vendored
Normal file
2
debian/libpinproc-dev.dirs
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
usr/lib
|
||||||
|
usr/include
|
||||||
3
debian/libpinproc-dev.install
vendored
Normal file
3
debian/libpinproc-dev.install
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
usr/include/*
|
||||||
|
usr/lib/pkgconfig/*
|
||||||
|
usr/lib/lib*.so
|
||||||
1
debian/libpinproc-dev.substvars
vendored
Normal file
1
debian/libpinproc-dev.substvars
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
misc:Depends=
|
||||||
12
debian/libpinproc-dev/DEBIAN/control
vendored
Normal file
12
debian/libpinproc-dev/DEBIAN/control
vendored
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
Package: libpinproc-dev
|
||||||
|
Source: libpinproc
|
||||||
|
Version: 0.1.0-1
|
||||||
|
Architecture: amd64
|
||||||
|
Maintainer: Jan Kantert <jan-mpf@kantert.net>
|
||||||
|
Installed-Size: 68
|
||||||
|
Depends: libpinproc (= 0.1.0-1)
|
||||||
|
Section: libdevel
|
||||||
|
Priority: optional
|
||||||
|
Homepage: https://github.com/jabdoa2/libpinproc
|
||||||
|
Description: Devel header for libpinproc
|
||||||
|
Lib to speak to the P-Roc and P3-Roc hardware from Multimorphic
|
||||||
4
debian/libpinproc-dev/DEBIAN/md5sums
vendored
Normal file
4
debian/libpinproc-dev/DEBIAN/md5sums
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
675f72525b8aa87966c0b35e27cbf2d0 usr/include/p-roc/pinproc.h
|
||||||
|
d291de7e93c0d47be0f40e87c7dd93e8 usr/lib/pkgconfig/pinproc.pc
|
||||||
|
74322abf217a8f4e1d6f50d89a8a009c usr/share/doc/libpinproc-dev/changelog.Debian.gz
|
||||||
|
9b8881ce99456b7e1d090ab95820ff1f usr/share/doc/libpinproc-dev/copyright
|
||||||
598
debian/libpinproc-dev/usr/include/p-roc/pinproc.h
vendored
Normal file
598
debian/libpinproc-dev/usr/include/p-roc/pinproc.h
vendored
Normal file
@@ -0,0 +1,598 @@
|
|||||||
|
/*
|
||||||
|
* The MIT License
|
||||||
|
* Copyright (c) 2009 Gerry Stellenberg, Adam Preble
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person
|
||||||
|
* obtaining a copy of this software and associated documentation
|
||||||
|
* files (the "Software"), to deal in the Software without
|
||||||
|
* restriction, including without limitation the rights to use,
|
||||||
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the
|
||||||
|
* Software is furnished to do so, subject to the following
|
||||||
|
* conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
/** @file pinproc.h
|
||||||
|
* @brief libpinproc, P-ROC Layer 1 API (Preliminary)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#ifndef PINPROC_PINPROC_H
|
||||||
|
#define PINPROC_PINPROC_H
|
||||||
|
#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4
|
||||||
|
#pragma once
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 3rd party "stdint.h" replacement available for Visual C++ before version 2010.
|
||||||
|
* http://en.wikipedia.org/wiki/Stdint.h#External_links
|
||||||
|
* -> http://msinttypes.googlecode.com/svn/trunk/stdint.h
|
||||||
|
* Place inside the major include dir (e.g. %ProgramFiles%\Microsoft Visual Studio\VC98\INCLUDE)
|
||||||
|
*/
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
/** @cond */
|
||||||
|
// The following ifdef block is the standard way of creating macros which make exporting
|
||||||
|
// from a DLL simpler. All files within this DLL are compiled with the pinproc_EXPORTS
|
||||||
|
// symbol defined on the command line. This symbol should not be defined on any project
|
||||||
|
// that uses this DLL. This way any other project whose source files include this file see
|
||||||
|
// PINPROC_API functions as being imported from a DLL, whereas this DLL sees symbols
|
||||||
|
// defined with this macro as being exported.
|
||||||
|
#undef PINPROC_API
|
||||||
|
|
||||||
|
#ifdef PINPROC_DLL // Using or Building PinPROC DLL (definition defined manually)
|
||||||
|
#ifdef pinproc_EXPORTS // Building PinPROC DLL (definition created by CMake or defined manually)
|
||||||
|
#define PINPROC_API __declspec(dllexport)
|
||||||
|
#else
|
||||||
|
#define PINPROC_API __declspec(dllimport)
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
// fallback for non-DLL usage and builds
|
||||||
|
#ifndef PINPROC_API
|
||||||
|
#define PINPROC_API
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
#define PINPROC_EXTERN_C_BEGIN extern "C" {
|
||||||
|
#define PINPROC_EXTERN_C_END }
|
||||||
|
#else
|
||||||
|
#define PINPROC_EXTERN_C_BEGIN
|
||||||
|
#define PINPROC_EXTERN_C_END
|
||||||
|
#endif
|
||||||
|
|
||||||
|
PINPROC_EXTERN_C_BEGIN
|
||||||
|
/** @endcond */
|
||||||
|
|
||||||
|
// Types
|
||||||
|
|
||||||
|
typedef int32_t bool_t; // FIXME: This needs better platform independence.
|
||||||
|
|
||||||
|
typedef int32_t PRResult; /**< See: #kPRSuccess and #kPRFailure. */
|
||||||
|
#define kPRSuccess (1) /**< Success value for #PRResult. */
|
||||||
|
#define kPRFailure (0) /**< Failure value for #PRResult. */
|
||||||
|
|
||||||
|
typedef void * PRHandle; /**< Opaque type used to reference an individual P-ROC device. Created with PRCreate() and destroyed with PRDelete(). This value is used as the first parameter to all P-ROC API function calls. */
|
||||||
|
#define kPRHandleInvalid (0) /**< Value returned by PRCreate() on failure. Indicates an invalid #PRHandle. */
|
||||||
|
|
||||||
|
typedef enum PRLogLevel {
|
||||||
|
kPRLogVerbose,
|
||||||
|
kPRLogInfo,
|
||||||
|
kPRLogWarning,
|
||||||
|
kPRLogError
|
||||||
|
} PRLogLevel;
|
||||||
|
|
||||||
|
typedef void (*PRLogCallback)(PRLogLevel level, const char *text); /**< Function pointer type for a custom logging callback. See: PRLogSetCallback(). */
|
||||||
|
PINPROC_API void PRLogSetCallback(PRLogCallback callback); /**< Replaces the default logging handler with the given callback function. */
|
||||||
|
|
||||||
|
PINPROC_API void PRLogSetLevel(PRLogLevel level);
|
||||||
|
|
||||||
|
PINPROC_API const char *PRGetLastErrorText();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @defgroup device Device Creation & Deletion
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef enum PRMachineType {
|
||||||
|
kPRMachineInvalid = 0,
|
||||||
|
kPRMachineCustom = 1,
|
||||||
|
kPRMachineWPCAlphanumeric = 2,
|
||||||
|
kPRMachineWPC = 3,
|
||||||
|
kPRMachineWPC95 = 4,
|
||||||
|
kPRMachineSternWhitestar = 5,
|
||||||
|
kPRMachineSternSAM = 6,
|
||||||
|
kPRMachinePDB = 7,
|
||||||
|
} PRMachineType;
|
||||||
|
|
||||||
|
// PRHandle Creation and Deletion
|
||||||
|
|
||||||
|
PINPROC_API PRHandle PRCreate(PRMachineType machineType); /**< Create a new P-ROC device handle. Only one handle per device may be created. This handle must be destroyed with PRDelete() when it is no longer needed. Returns #kPRHandleInvalid if an error occurred. */
|
||||||
|
PINPROC_API void PRDelete(PRHandle handle); /**< Destroys an existing P-ROC device handle. */
|
||||||
|
|
||||||
|
#define kPRResetFlagDefault (0) /**< Only resets state in memory and does not write changes to the device. */
|
||||||
|
#define kPRResetFlagUpdateDevice (1) /**< Instructs PRReset() to update the device once it has reset the configuration to its defaults. */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Resets internally maintained driver and switch rule structures.
|
||||||
|
* @param resetFlags Specify #kPRResetFlagDefault to only reset the configuration in host memory. #kPRResetFlagUpdateDevice will write the default configuration to the device, effectively disabling all drivers and switch rules.
|
||||||
|
*/
|
||||||
|
PINPROC_API PRResult PRReset(PRHandle handle, uint32_t resetFlags);
|
||||||
|
|
||||||
|
/** @} */ // End of Device Creation & Deletion
|
||||||
|
|
||||||
|
// I/O
|
||||||
|
|
||||||
|
/** Flush all pending write data out to the P-ROC. */
|
||||||
|
PINPROC_API PRResult PRFlushWriteData(PRHandle handle);
|
||||||
|
|
||||||
|
/** Write data out to the P-ROC immediately (does not require a call to PRFlushWriteData). */
|
||||||
|
PINPROC_API PRResult PRWriteData(PRHandle handle, uint32_t moduleSelect, uint32_t startingAddr, int32_t numWriteWords, uint32_t * writeBuffer);
|
||||||
|
|
||||||
|
/** Read data from the P-ROC. */
|
||||||
|
PINPROC_API PRResult PRReadData(PRHandle handle, uint32_t moduleSelect, uint32_t startingAddr, int32_t numReadWords, uint32_t * readBuffer);
|
||||||
|
|
||||||
|
// Manager
|
||||||
|
/** @defgroup Manager
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef struct PRManagerConfig {
|
||||||
|
bool_t reuse_dmd_data_for_aux;
|
||||||
|
bool_t invert_dipswitch_1;
|
||||||
|
} PRManagerConfig;
|
||||||
|
|
||||||
|
/** Update Manager configuration */
|
||||||
|
PINPROC_API PRResult PRManagerUpdateConfig(PRHandle handle, PRManagerConfig *managerConfig);
|
||||||
|
|
||||||
|
// Drivers
|
||||||
|
/** @defgroup drivers Driver Manipulation
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define kPRDriverGroupsMax (26) /**< Number of available driver groups. */
|
||||||
|
#define kPRDriverCount (256) /**< Total number of drivers */
|
||||||
|
|
||||||
|
#define kPRDriverAuxCmdOutput (2)
|
||||||
|
#define kPRDriverAuxCmdDelay (1)
|
||||||
|
#define kPRDriverAuxCmdJump (0)
|
||||||
|
|
||||||
|
typedef struct PRDriverGlobalConfig {
|
||||||
|
bool_t enableOutputs; // Formerly enable_direct_outputs
|
||||||
|
bool_t globalPolarity;
|
||||||
|
bool_t useClear;
|
||||||
|
bool_t strobeStartSelect;
|
||||||
|
uint8_t startStrobeTime;
|
||||||
|
uint8_t matrixRowEnableIndex1;
|
||||||
|
uint8_t matrixRowEnableIndex0;
|
||||||
|
bool_t activeLowMatrixRows;
|
||||||
|
bool_t encodeEnables;
|
||||||
|
bool_t tickleSternWatchdog;
|
||||||
|
bool_t watchdogExpired;
|
||||||
|
bool_t watchdogEnable;
|
||||||
|
uint16_t watchdogResetTime;
|
||||||
|
} PRDriverGlobalConfig;
|
||||||
|
|
||||||
|
typedef struct PRDriverGroupConfig {
|
||||||
|
uint8_t groupNum;
|
||||||
|
uint16_t slowTime;
|
||||||
|
uint8_t enableIndex;
|
||||||
|
uint8_t rowActivateIndex;
|
||||||
|
uint8_t rowEnableSelect;
|
||||||
|
bool_t matrixed;
|
||||||
|
bool_t polarity;
|
||||||
|
bool_t active;
|
||||||
|
bool_t disableStrobeAfter;
|
||||||
|
} PRDriverGroupConfig;
|
||||||
|
|
||||||
|
typedef struct PRDriverState {
|
||||||
|
uint16_t driverNum;
|
||||||
|
uint8_t outputDriveTime;
|
||||||
|
bool_t polarity;
|
||||||
|
bool_t state;
|
||||||
|
bool_t waitForFirstTimeSlot;
|
||||||
|
uint32_t timeslots;
|
||||||
|
uint8_t patterOnTime;
|
||||||
|
uint8_t patterOffTime;
|
||||||
|
bool_t patterEnable;
|
||||||
|
bool_t futureEnable;
|
||||||
|
} PRDriverState;
|
||||||
|
|
||||||
|
typedef struct PRDriverAuxCommand {
|
||||||
|
bool_t active;
|
||||||
|
bool_t muxEnables;
|
||||||
|
uint8_t command;
|
||||||
|
uint8_t enables;
|
||||||
|
uint8_t extraData;
|
||||||
|
uint8_t data;
|
||||||
|
uint16_t delayTime;
|
||||||
|
uint8_t jumpAddr;
|
||||||
|
} PRDriverAuxCommand;
|
||||||
|
|
||||||
|
/** Update registers for the global driver configuration. */
|
||||||
|
PINPROC_API PRResult PRDriverUpdateGlobalConfig(PRHandle handle, PRDriverGlobalConfig *driverGlobalConfig);
|
||||||
|
|
||||||
|
PINPROC_API PRResult PRDriverGetGroupConfig(PRHandle handle, uint8_t groupNum, PRDriverGroupConfig *driverGroupConfig);
|
||||||
|
/** Update registers for the given driver group configuration. */
|
||||||
|
PINPROC_API PRResult PRDriverUpdateGroupConfig(PRHandle handle, PRDriverGroupConfig *driverGroupConfig);
|
||||||
|
|
||||||
|
PINPROC_API PRResult PRDriverGetState(PRHandle handle, uint8_t driverNum, PRDriverState *driverState);
|
||||||
|
/**
|
||||||
|
* @brief Sets the state of the given driver (lamp or coil).
|
||||||
|
*/
|
||||||
|
PINPROC_API PRResult PRDriverUpdateState(PRHandle handle, PRDriverState *driverState);
|
||||||
|
/**
|
||||||
|
* @brief Loads the driver defaults for the given machine type.
|
||||||
|
*
|
||||||
|
* PRReset() calls this function internally; this function is useful for basing custom driver settings off of the defaults for a particular machine.
|
||||||
|
* @note This function does not update the P-ROC hardware, only the internal data structures. Use PRDriverGetGlobalConfig() and PRDriverGetGroupConfig() to retrieve the settings.
|
||||||
|
*/
|
||||||
|
PINPROC_API PRResult PRDriverLoadMachineTypeDefaults(PRHandle handle, PRMachineType machineType);
|
||||||
|
|
||||||
|
// Driver Group Helper functions:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disables (turns off) the given driver group.
|
||||||
|
* This function is provided for convenience. See PRDriverGroupDisable() for a full description.
|
||||||
|
*/
|
||||||
|
PINPROC_API PRResult PRDriverGroupDisable(PRHandle handle, uint8_t groupNum);
|
||||||
|
// Driver Helper functions:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disables (turns off) the given driver.
|
||||||
|
* This function is provided for convenience. See PRDriverStateDisable() for a full description.
|
||||||
|
*/
|
||||||
|
PINPROC_API PRResult PRDriverDisable(PRHandle handle, uint8_t driverNum);
|
||||||
|
/**
|
||||||
|
* Pulses the given driver for a number of milliseconds.
|
||||||
|
* This function is provided for convenience. See PRDriverStatePulse() for a full description.
|
||||||
|
*/
|
||||||
|
PINPROC_API PRResult PRDriverPulse(PRHandle handle, uint8_t driverNum, uint8_t milliseconds);
|
||||||
|
/**
|
||||||
|
* Pulses the given driver for a number of milliseconds when the hardware reaches a specific timestamp.
|
||||||
|
* This function is provided for convenience. See PRDriverStatePulse() for a full description.
|
||||||
|
*/
|
||||||
|
PINPROC_API PRResult PRDriverFuturePulse(PRHandle handle, uint8_t driverNum, uint8_t milliseconds, uint32_t futureTime);
|
||||||
|
/**
|
||||||
|
* Assigns a repeating schedule to the given driver.
|
||||||
|
* This function is provided for convenience. See PRDriverStateSchedule() for a full description.
|
||||||
|
*/
|
||||||
|
PINPROC_API PRResult PRDriverSchedule(PRHandle handle, uint8_t driverNum, uint32_t schedule, uint8_t cycleSeconds, bool_t now);
|
||||||
|
/**
|
||||||
|
* Assigns a pitter-patter schedule (repeating on/off) to the given driver.
|
||||||
|
* This function is provided for convenience. See PRDriverStatePatter() for a full description.
|
||||||
|
*/
|
||||||
|
PINPROC_API PRResult PRDriverPatter(PRHandle handle, uint8_t driverNum, uint8_t millisecondsOn, uint8_t millisecondsOff, uint8_t originalOnTime, bool_t now);
|
||||||
|
/**
|
||||||
|
* Assigns a pitter-patter schedule (repeating on/off) to the given driver on for the given duration.
|
||||||
|
* This function is provided for convenience. See PRDriverStatePulsedPatter() for a full description.
|
||||||
|
*/
|
||||||
|
PINPROC_API PRResult PRDriverPulsedPatter(PRHandle handle, uint8_t driverNum, uint8_t millisecondsOn, uint8_t millisecondsOff, uint8_t originalOnTime, bool_t now);
|
||||||
|
/**
|
||||||
|
* Prepares an Aux Command to drive the Aux bus.
|
||||||
|
* This function is provided for convenience.
|
||||||
|
*/
|
||||||
|
PINPROC_API void PRDriverAuxPrepareOutput(PRDriverAuxCommand *auxCommand, uint8_t data, uint8_t extraData, uint8_t enables, bool_t muxEnables, uint16_t delayTime);
|
||||||
|
/**
|
||||||
|
* Prepares an Aux Command to delay the Aux logic.
|
||||||
|
* This function is provided for convenience.
|
||||||
|
*/
|
||||||
|
PINPROC_API void PRDriverAuxPrepareDelay(PRDriverAuxCommand *auxCommand, uint16_t delayTime);
|
||||||
|
/**
|
||||||
|
* Prepares an Aux Command to have the Aux memory pointer jump to a new address.
|
||||||
|
* This function is provided for convenience.
|
||||||
|
*/
|
||||||
|
PINPROC_API void PRDriverAuxPrepareJump(PRDriverAuxCommand *auxCommand, uint8_t jumpAddr);
|
||||||
|
/**
|
||||||
|
* Prepares a disabled Aux Command.
|
||||||
|
* This function is provided for convenience.
|
||||||
|
*/
|
||||||
|
PINPROC_API void PRDriverAuxPrepareDisable(PRDriverAuxCommand *auxCommand);
|
||||||
|
|
||||||
|
/** Tickle the watchdog timer. */
|
||||||
|
PINPROC_API PRResult PRDriverWatchdogTickle(PRHandle handle);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Changes the given #PRDriverGroupConfig to reflect a disabled group.
|
||||||
|
* @note The driver group config structure must be applied using PRDriverUpdateGroupConfig() to have any effect.
|
||||||
|
*/
|
||||||
|
PINPROC_API void PRDriverGroupStateDisable(PRDriverGroupConfig *driverGroup);
|
||||||
|
/**
|
||||||
|
* Changes the given #PRDriverState to reflect a disabled state.
|
||||||
|
* @note The driver state structure must be applied using PRDriverUpdateState() or linked to a switch rule using PRSwitchUpdateRule() to have any effect.
|
||||||
|
*/
|
||||||
|
PINPROC_API void PRDriverStateDisable(PRDriverState *driverState);
|
||||||
|
/**
|
||||||
|
* Changes the given #PRDriverState to reflect a pulse state.
|
||||||
|
* @param milliseconds Number of milliseconds to pulse the driver for.
|
||||||
|
* @note The driver state structure must be applied using PRDriverUpdateState() or linked to a switch rule using PRSwitchUpdateRule() to have any effect.
|
||||||
|
*/
|
||||||
|
PINPROC_API void PRDriverStatePulse(PRDriverState *driverState, uint8_t milliseconds);
|
||||||
|
/**
|
||||||
|
* Changes the given #PRDriverState to reflect a future scheduled pulse state.
|
||||||
|
* @param milliseconds Number of milliseconds to pulse the driver for.
|
||||||
|
* @param futureTime Value indicating at which HW timestamp the pulse should occur. Currently only the low 10-bits are used.
|
||||||
|
* @note The driver state structure must be applied using PRDriverUpdateState() or linked to a switch rule using PRSwitchUpdateRule() to have any effect.
|
||||||
|
*/
|
||||||
|
PINPROC_API void PRDriverStateFuturePulse(PRDriverState *driverState, uint8_t milliseconds, uint32_t futureTime);
|
||||||
|
/**
|
||||||
|
* Changes the given #PRDriverState to reflect a scheduled state.
|
||||||
|
* Assigns a repeating schedule to the given driver.
|
||||||
|
* @note The driver state structure must be applied using PRDriverUpdateState() or linked to a switch rule using PRSwitchUpdateRule() to have any effect.
|
||||||
|
*/
|
||||||
|
PINPROC_API void PRDriverStateSchedule(PRDriverState *driverState, uint32_t schedule, uint8_t cycleSeconds, bool_t now);
|
||||||
|
/**
|
||||||
|
* @brief Changes the given #PRDriverState to reflect a pitter-patter schedule state.
|
||||||
|
* Assigns a pitter-patter schedule (repeating on/off) to the given driver.
|
||||||
|
* @note The driver state structure must be applied using PRDriverUpdateState() or linked to a switch rule using PRSwitchUpdateRule() to have any effect.
|
||||||
|
*
|
||||||
|
* Use originalOnTime to pulse the driver for a number of milliseconds before the pitter-patter schedule begins.
|
||||||
|
*/
|
||||||
|
PINPROC_API void PRDriverStatePatter(PRDriverState *driverState, uint8_t millisecondsOn, uint8_t millisecondsOff, uint8_t originalOnTime, bool_t now);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Changes the given #PRDriverState to reflect a pitter-patter schedule state.
|
||||||
|
* Just like the regular Patter above, but PulsePatter only drives the patter
|
||||||
|
* scheduled for the given number of milliseconds before disabling the driver.
|
||||||
|
*/
|
||||||
|
PINPROC_API void PRDriverStatePulsedPatter(PRDriverState *driverState, uint8_t millisecondsOn, uint8_t millisecondsOff, uint8_t patterTime, bool_t now);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write Aux Port commands into the Aux Port command memory.
|
||||||
|
*/
|
||||||
|
|
||||||
|
PINPROC_API PRResult PRDriverAuxSendCommands(PRHandle handle, PRDriverAuxCommand * commands, uint8_t numCommands, uint8_t startingAddr);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Converts a coil, lamp, switch, or GI string into a P-ROC driver number.
|
||||||
|
* The following formats are accepted: Cxx (coil), Lxx (lamp), Sxx (matrix switch), SFx (flipper grounded switch), or SDx (dedicated grounded switch).
|
||||||
|
* If the string does not match this format it will be converted into an integer using atoi().
|
||||||
|
*/
|
||||||
|
PINPROC_API uint16_t PRDecode(PRMachineType machineType, const char *str);
|
||||||
|
|
||||||
|
/** @} */ // End of Drivers
|
||||||
|
|
||||||
|
// Switches
|
||||||
|
|
||||||
|
/** @defgroup switches Switches and Events
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Events
|
||||||
|
// Closed == 0, Open == 1
|
||||||
|
typedef enum PREventType {
|
||||||
|
kPREventTypeInvalid = 0,
|
||||||
|
kPREventTypeSwitchClosedDebounced = 1, /**< The switch has gone from open to closed and the signal has been debounced. */
|
||||||
|
kPREventTypeSwitchOpenDebounced = 2, /**< The switch has gone from closed to open and the signal has been debounced. */
|
||||||
|
kPREventTypeSwitchClosedNondebounced = 3, /**< The switch has gone from open to closed and the signal has not been debounced. */
|
||||||
|
kPREventTypeSwitchOpenNondebounced = 4, /**< The switch has gone from closed to open and the signal has not been debounced. */
|
||||||
|
kPREventTypeDMDFrameDisplayed = 5, /**< A DMD frame has been displayed. */
|
||||||
|
kPREventTypeBurstSwitchOpen = 6, /**< A burst switch has gone from closed to open. */
|
||||||
|
kPREventTypeBurstSwitchClosed = 7, /**< A burst switch has gone from open to closed. */
|
||||||
|
kPREventTypeAccelerometerX = 8, /**< New value from the accelerometer - X plane. */
|
||||||
|
kPREventTypeAccelerometerY = 9, /**< New value from the accelerometer - Y plane. */
|
||||||
|
kPREventTypeAccelerometerZ = 10, /**< New value from the accelerometer - Z plane. */
|
||||||
|
kPREventTypeAccelerometerIRQ = 11, /**< New interrupt from the accelerometer */
|
||||||
|
kPREventTypetLast = kPREventTypeSwitchOpenNondebounced
|
||||||
|
} PREventType;
|
||||||
|
|
||||||
|
typedef struct PREvent {
|
||||||
|
PREventType type; /**< The type of event that has occurred. Usually a switch event at this point. */
|
||||||
|
uint32_t value; /**< For switch events, the switch number that has changed. For DMD events, the frame buffer that was just displayed. */
|
||||||
|
uint32_t time; /**< Time (in milliseconds) that this event occurred. */
|
||||||
|
} PREvent;
|
||||||
|
|
||||||
|
/** Get all of the available events that have been received.
|
||||||
|
* \return Number of events returned; -1 if an error occurred.
|
||||||
|
*/
|
||||||
|
PINPROC_API int PRGetEvents(PRHandle handle, PREvent *eventsOut, int maxEvents);
|
||||||
|
|
||||||
|
|
||||||
|
#define kPRSwitchPhysicalFirst (0) /**< Switch number of the first physical switch. */
|
||||||
|
#define kPRSwitchPhysicalLast (255) /**< Switch number of the last physical switch. */
|
||||||
|
#define kPRSwitchNeverDebounceFirst (192) /**< Switch number of the first switch that doesn't need to debounced. */
|
||||||
|
#define kPRSwitchNeverDebounceLast (255) /**< Switch number of the last switch that doesn't need to be debounce. */
|
||||||
|
#define kPRSwitchCount (256)
|
||||||
|
#define kPRSwitchRulesCount (kPRSwitchCount << 2) /**< Total number of available switch rules. */
|
||||||
|
|
||||||
|
typedef struct PRSwitchConfig {
|
||||||
|
bool_t clear; // Drive the clear output
|
||||||
|
bool_t hostEventsEnable; // Drive the clear output
|
||||||
|
bool_t use_column_9; // Use switch matrix column 9
|
||||||
|
bool_t use_column_8; // Use switch matrix column 8
|
||||||
|
uint8_t directMatrixScanLoopTime; // milliseconds
|
||||||
|
uint8_t pulsesBeforeCheckingRX;
|
||||||
|
uint8_t inactivePulsesAfterBurst;
|
||||||
|
uint8_t pulsesPerBurst;
|
||||||
|
uint8_t pulseHalfPeriodTime; // milliseconds
|
||||||
|
} PRSwitchConfig;
|
||||||
|
|
||||||
|
typedef struct PRSwitchRule {
|
||||||
|
bool_t reloadActive; /**< If true, any associated driver changes resulting from this rule will only happen at most once every 256ms. */
|
||||||
|
bool_t notifyHost; /**< If true this switch change event will provided to the user via PRGetEvents(). */
|
||||||
|
} PRSwitchRule;
|
||||||
|
|
||||||
|
/** Update the switch controller configurion registers */
|
||||||
|
PINPROC_API PRResult PRSwitchUpdateConfig(PRHandle handle, PRSwitchConfig *switchConfig);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Configures the handling of switch rules within P-ROC.
|
||||||
|
*
|
||||||
|
* P-ROC's switch rule system allows the user to decide which switch events are returned to software,
|
||||||
|
* as well as optionally linking one or more driver state changes to rules to create immediate feedback (such as in pop bumpers).
|
||||||
|
*
|
||||||
|
* For instance, P-ROC can provide debounced switch events for a flipper button so software can apply lange change behavior.
|
||||||
|
* This is accomplished by configuring the P-ROC with a switch rule for the flipper button and then receiving the events via the PRGetEvents() call.
|
||||||
|
* The same switch can also be configured with a non-debounced rule to fire a flipper coil.
|
||||||
|
* Multiple driver changes can be tied to a single switch state transition to create more complicated effects: a slingshot
|
||||||
|
* switch that fires the slingshot coil, a flash lamp, and a score event.
|
||||||
|
*
|
||||||
|
* P-ROC holds four different switch rules for each switch: closed to open and open to closed, each with a debounced and non-debounced versions:
|
||||||
|
* - #kPREventTypeSwitchOpenDebounced
|
||||||
|
* - #kPREventTypeSwitchClosedDebounced
|
||||||
|
* - #kPREventTypeSwitchOpenNondebounced
|
||||||
|
* - #kPREventTypeSwitchClosedNondebounced
|
||||||
|
*
|
||||||
|
* @section Examples
|
||||||
|
*
|
||||||
|
* Configuring a basic switch rule to simply notify software via PRGetEvents() without affecting any coil/lamp drivers:
|
||||||
|
* @code
|
||||||
|
* PRSwitchRule rule;
|
||||||
|
* rule.notifyHost = true;
|
||||||
|
* PRSwitchUpdateRule(handle, switchNum, kPREventTypeSwitchOpenDebounced, &rule, NULL, 0);
|
||||||
|
* @endcode
|
||||||
|
*
|
||||||
|
* Configuring a pop bumper switch to pulse the coil and a flash lamp for 50ms each:
|
||||||
|
* @code
|
||||||
|
* // Configure a switch rule to fire the coil and flash lamp:
|
||||||
|
* PRSwitchRule rule;
|
||||||
|
* rule.notifyHost = false;
|
||||||
|
* PRDriverState drivers[2];
|
||||||
|
* PRDriverGetState(handle, drvCoilPopBumper1, &drivers[0]);
|
||||||
|
* PRDriverGetState(handle, drvFlashLamp1, &drivers[1]);
|
||||||
|
* PRDriverStatePulse(&drivers[0], 50);
|
||||||
|
* PRDriverStatePulse(&drivers[1], 50);
|
||||||
|
* PRSwitchUpdateRule(handle, swPopBumper1, kPREventTypeSwitchClosedNondebounced,
|
||||||
|
* &rule, drivers, 2);
|
||||||
|
* // Now configure a switch rule to process scoring in software:
|
||||||
|
* rule.notifyHost = true;
|
||||||
|
* PRSwitchUpdateRule(handle, swPopBumper1, kPREventTypeSwitchClosedDebounced,
|
||||||
|
* &rule, NULL, 0);
|
||||||
|
* @endcode
|
||||||
|
*
|
||||||
|
* @param handle The P-ROC device handle.
|
||||||
|
* @param switchNum The index of the switch this configuration affects.
|
||||||
|
* @param eventType The switch rule for the specified switchNum to be configured.
|
||||||
|
* @param rule A pointer to the #PRSwitchRule structure describing how this state change should be handled. May not be NULL.
|
||||||
|
* @param linkedDrivers An array of #PRDriverState structures describing the driver state changes to be made when this switch rule is triggered. May be NULL if numDrivers is 0.
|
||||||
|
* @param numDrivers Number of elements in the linkedDrivers array. May be zero or more.
|
||||||
|
*/
|
||||||
|
PINPROC_API PRResult PRSwitchUpdateRule(PRHandle handle, uint8_t switchNum, PREventType eventType, PRSwitchRule *rule, PRDriverState *linkedDrivers, int numDrivers, bool_t drive_outputs_now);
|
||||||
|
|
||||||
|
/** Returns a list of PREventTypes describing the states of the requested number of switches */
|
||||||
|
PINPROC_API PRResult PRSwitchGetStates(PRHandle handle, PREventType * switchStates, uint16_t numSwitches);
|
||||||
|
|
||||||
|
/** @} */ // End of Switches & Events
|
||||||
|
|
||||||
|
// DMD
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @defgroup dmd DMD Control
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
typedef struct PRDMDConfig {
|
||||||
|
uint8_t numRows;
|
||||||
|
uint16_t numColumns;
|
||||||
|
uint8_t numSubFrames;
|
||||||
|
uint8_t numFrameBuffers;
|
||||||
|
bool_t autoIncBufferWrPtr;
|
||||||
|
bool_t enableFrameEvents;
|
||||||
|
bool_t enable;
|
||||||
|
uint8_t rclkLowCycles[8];
|
||||||
|
uint8_t latchHighCycles[8];
|
||||||
|
uint16_t deHighCycles[8];
|
||||||
|
uint8_t dotclkHalfPeriod[8];
|
||||||
|
} PRDMDConfig;
|
||||||
|
|
||||||
|
/** Sets the configuration registers for the DMD driver. */
|
||||||
|
PINPROC_API int32_t PRDMDUpdateConfig(PRHandle handle, PRDMDConfig *dmdConfig);
|
||||||
|
/** Updates the DMD frame buffer with the given data. */
|
||||||
|
PINPROC_API PRResult PRDMDDraw(PRHandle handle, uint8_t * dots);
|
||||||
|
|
||||||
|
/** @} */ // End of DMD
|
||||||
|
|
||||||
|
|
||||||
|
// JTAG
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @defgroup jtag JTAG interface control
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef struct PRJTAGStatus {
|
||||||
|
bool_t commandComplete;
|
||||||
|
bool_t tdi;
|
||||||
|
} PRJTAGStatus;
|
||||||
|
|
||||||
|
typedef struct PRJTAGOutputs {
|
||||||
|
bool_t tckMask;
|
||||||
|
bool_t tmsMask;
|
||||||
|
bool_t tdoMask;
|
||||||
|
bool_t tck;
|
||||||
|
bool_t tms;
|
||||||
|
bool_t tdo;
|
||||||
|
} PRJTAGOutputs;
|
||||||
|
|
||||||
|
/** Force JTAG outputs (TCK, TDO, TMS) to specific values. Optionally toggle the clock when driving only TDO and/or TMS.*/
|
||||||
|
PINPROC_API PRResult PRJTAGDriveOutputs(PRHandle handle, PRJTAGOutputs * jtagOutputs, bool_t toggleClk);
|
||||||
|
/** Store data to be shifted out on TDO */
|
||||||
|
PINPROC_API PRResult PRJTAGWriteTDOMemory(PRHandle handle, uint16_t tableOffset, uint16_t numWords, uint32_t * tdoData);
|
||||||
|
/** Shift stored TDO data onto the TDO pin, toggling TCK on every bit. */
|
||||||
|
PINPROC_API PRResult PRJTAGShiftTDOData(PRHandle handle, uint16_t numBits, bool_t dataBlockComplete);
|
||||||
|
/** Get the contents of the TDI memory. */
|
||||||
|
PINPROC_API PRResult PRJTAGReadTDIMemory(PRHandle handle, uint16_t tableOffset, uint16_t numWords, uint32_t * tdiData);
|
||||||
|
/** Read the JTAG status register for the command complete bit and JTAG pin states. */
|
||||||
|
PINPROC_API PRResult PRJTAGGetStatus(PRHandle handle, PRJTAGStatus * status);
|
||||||
|
|
||||||
|
/** @} */ // End of JTAG
|
||||||
|
|
||||||
|
// PD-LED
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @defgroup pdled PD-LED Control
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct PRLED {
|
||||||
|
uint8_t boardAddr;
|
||||||
|
uint8_t LEDIndex;
|
||||||
|
} PRLED;
|
||||||
|
|
||||||
|
typedef struct PRLEDRGB {
|
||||||
|
PRLED* pRedLED;
|
||||||
|
PRLED* pGreenLED;
|
||||||
|
PRLED* pBlueLED;
|
||||||
|
} PRLEDRGB;
|
||||||
|
|
||||||
|
/** Sets the color of a given PRLED. */
|
||||||
|
PINPROC_API PRResult PRLEDColor(PRHandle handle, PRLED * pLED, uint8_t color);
|
||||||
|
/** Sets the fade color on a given PRLED. */
|
||||||
|
PINPROC_API PRResult PRLEDFadeColor(PRHandle handle, PRLED * pLED, uint8_t fadeColor);
|
||||||
|
/** Sets the fade color and rate on a given PRLED. Note: The rate will apply to any future PRLEDFadeColor or PRLEDRGBFadeColor calls on the same PD-LED board. */
|
||||||
|
PINPROC_API PRResult PRLEDFade(PRHandle handle, PRLED * pLED, uint8_t fadeColor, uint16_t fadeRate);
|
||||||
|
|
||||||
|
/** Sets the fade rate on a given board. Note: The rate will apply to any future PRLEDFadeColor or PRLEDRGBFadeColor calls on the same PD-LED board. */
|
||||||
|
PINPROC_API PRResult PRLEDFadeRate(PRHandle handle, uint8_t boardAddr, uint16_t fadeRate);
|
||||||
|
|
||||||
|
/** Sets the color of a given PRLEDRGB. */
|
||||||
|
PINPROC_API PRResult PRLEDRGBColor(PRHandle handle, PRLEDRGB * pLED, uint32_t color);
|
||||||
|
/** Sets the fade color and rate on a given PRLEDRGB. Note: The rate will apply to any future PRLEDFadeColor or PRLEDRGBFadeColor calls on any of the referenced PD-LED boards. */
|
||||||
|
PINPROC_API PRResult PRLEDRGBFade(PRHandle handle, PRLEDRGB * pLED, uint32_t fadeColor, uint16_t fadeRate);
|
||||||
|
/** Sets the fade color on a given PRLEDRGB. */
|
||||||
|
PINPROC_API PRResult PRLEDRGBFadeColor(PRHandle handle, PRLEDRGB * pLED, uint32_t fadeColor);
|
||||||
|
|
||||||
|
|
||||||
|
/** @} */ // End of PD-LED
|
||||||
|
|
||||||
|
|
||||||
|
/** @cond */
|
||||||
|
PINPROC_EXTERN_C_END
|
||||||
|
/** @endcond */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @mainpage libpinproc API Documentation
|
||||||
|
*
|
||||||
|
* This is the documentation for libpinproc, the P-ROC Layer 1 API.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#endif /* PINPROC_PINPROC_H */
|
||||||
1
debian/libpinproc-dev/usr/lib/libpinproc.so
vendored
Symbolic link
1
debian/libpinproc-dev/usr/lib/libpinproc.so
vendored
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
libpinproc.so.2.0
|
||||||
11
debian/libpinproc-dev/usr/lib/pkgconfig/pinproc.pc
vendored
Normal file
11
debian/libpinproc-dev/usr/lib/pkgconfig/pinproc.pc
vendored
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
prefix=/usr
|
||||||
|
exec_prefix=/usr
|
||||||
|
libdir=${prefix}/lib
|
||||||
|
includedir=${prefix}/include/p-roc
|
||||||
|
|
||||||
|
Name: Pinproc
|
||||||
|
Description: P-ROC interface library
|
||||||
|
Version: 2.0
|
||||||
|
Requires:
|
||||||
|
Libs: -L${libdir} -lpinproc
|
||||||
|
Cflags: -I${includedir}
|
||||||
BIN
debian/libpinproc-dev/usr/share/doc/libpinproc-dev/changelog.Debian.gz
vendored
Normal file
BIN
debian/libpinproc-dev/usr/share/doc/libpinproc-dev/changelog.Debian.gz
vendored
Normal file
Binary file not shown.
13
debian/libpinproc-dev/usr/share/doc/libpinproc-dev/copyright
vendored
Normal file
13
debian/libpinproc-dev/usr/share/doc/libpinproc-dev/copyright
vendored
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
|
||||||
|
Upstream-Name: libpinproc
|
||||||
|
Source: README.markdown
|
||||||
|
|
||||||
|
Files: *
|
||||||
|
Copyright: 2009 Gerry Stellenberg
|
||||||
|
2009 Adam Preble
|
||||||
|
License: AS IS
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
.
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
.
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
24
debian/libpinproc.debhelper.log
vendored
Normal file
24
debian/libpinproc.debhelper.log
vendored
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
dh_auto_configure
|
||||||
|
dh_auto_build
|
||||||
|
dh_auto_test
|
||||||
|
dh_prep
|
||||||
|
dh_installdirs
|
||||||
|
override_dh_auto_install dh_auto_install
|
||||||
|
dh_auto_install
|
||||||
|
dh_install
|
||||||
|
dh_installdocs
|
||||||
|
dh_installchangelogs
|
||||||
|
dh_perl
|
||||||
|
dh_link
|
||||||
|
dh_compress
|
||||||
|
dh_fixperms
|
||||||
|
dh_strip
|
||||||
|
dh_makeshlibs
|
||||||
|
override_dh_shlibdeps dh_shlibdeps
|
||||||
|
dh_shlibdeps
|
||||||
|
dh_installdeb
|
||||||
|
dh_gencontrol
|
||||||
|
dh_md5sums
|
||||||
|
dh_builddeb
|
||||||
|
dh_builddeb
|
||||||
|
dh_builddeb
|
||||||
1
debian/libpinproc.install
vendored
Normal file
1
debian/libpinproc.install
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
usr/lib/lib*.so.*
|
||||||
5
debian/libpinproc.postinst.debhelper
vendored
Normal file
5
debian/libpinproc.postinst.debhelper
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
# Automatically added by dh_makeshlibs
|
||||||
|
if [ "$1" = "configure" ]; then
|
||||||
|
ldconfig
|
||||||
|
fi
|
||||||
|
# End automatically added section
|
||||||
5
debian/libpinproc.postrm.debhelper
vendored
Normal file
5
debian/libpinproc.postrm.debhelper
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
# Automatically added by dh_makeshlibs
|
||||||
|
if [ "$1" = "remove" ]; then
|
||||||
|
ldconfig
|
||||||
|
fi
|
||||||
|
# End automatically added section
|
||||||
2
debian/libpinproc.substvars
vendored
Normal file
2
debian/libpinproc.substvars
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
shlibs:Depends=libc6 (>= 2.14), libgcc1 (>= 1:4.1.1), libstdc++6 (>= 4.1.1)
|
||||||
|
misc:Depends=
|
||||||
11
debian/libpinproc/DEBIAN/control
vendored
Normal file
11
debian/libpinproc/DEBIAN/control
vendored
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
Package: libpinproc
|
||||||
|
Version: 0.1.0-1
|
||||||
|
Architecture: amd64
|
||||||
|
Maintainer: Jan Kantert <jan-mpf@kantert.net>
|
||||||
|
Installed-Size: 80
|
||||||
|
Depends: libc6 (>= 2.14), libgcc1 (>= 1:4.1.1), libstdc++6 (>= 4.1.1)
|
||||||
|
Section: libs
|
||||||
|
Priority: optional
|
||||||
|
Homepage: https://github.com/jabdoa2/libpinproc
|
||||||
|
Description: libpinproc
|
||||||
|
Lib to speak to the P-Roc and P3-Roc hardware from Multimorphic
|
||||||
3
debian/libpinproc/DEBIAN/md5sums
vendored
Normal file
3
debian/libpinproc/DEBIAN/md5sums
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
8c3c18eda463e90bb2faffb8c2d1315b usr/lib/libpinproc.so.2.0
|
||||||
|
74322abf217a8f4e1d6f50d89a8a009c usr/share/doc/libpinproc/changelog.Debian.gz
|
||||||
|
9b8881ce99456b7e1d090ab95820ff1f usr/share/doc/libpinproc/copyright
|
||||||
7
debian/libpinproc/DEBIAN/postinst
vendored
Executable file
7
debian/libpinproc/DEBIAN/postinst
vendored
Executable file
@@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
# Automatically added by dh_makeshlibs
|
||||||
|
if [ "$1" = "configure" ]; then
|
||||||
|
ldconfig
|
||||||
|
fi
|
||||||
|
# End automatically added section
|
||||||
7
debian/libpinproc/DEBIAN/postrm
vendored
Executable file
7
debian/libpinproc/DEBIAN/postrm
vendored
Executable file
@@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
# Automatically added by dh_makeshlibs
|
||||||
|
if [ "$1" = "remove" ]; then
|
||||||
|
ldconfig
|
||||||
|
fi
|
||||||
|
# End automatically added section
|
||||||
1
debian/libpinproc/DEBIAN/shlibs
vendored
Normal file
1
debian/libpinproc/DEBIAN/shlibs
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
libpinproc 2.0 libpinproc
|
||||||
BIN
debian/libpinproc/usr/lib/libpinproc.so.2.0
vendored
Normal file
BIN
debian/libpinproc/usr/lib/libpinproc.so.2.0
vendored
Normal file
Binary file not shown.
BIN
debian/libpinproc/usr/share/doc/libpinproc/changelog.Debian.gz
vendored
Normal file
BIN
debian/libpinproc/usr/share/doc/libpinproc/changelog.Debian.gz
vendored
Normal file
Binary file not shown.
13
debian/libpinproc/usr/share/doc/libpinproc/copyright
vendored
Normal file
13
debian/libpinproc/usr/share/doc/libpinproc/copyright
vendored
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
|
||||||
|
Upstream-Name: libpinproc
|
||||||
|
Source: README.markdown
|
||||||
|
|
||||||
|
Files: *
|
||||||
|
Copyright: 2009 Gerry Stellenberg
|
||||||
|
2009 Adam Preble
|
||||||
|
License: AS IS
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
.
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
.
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
1
debian/libpinproc1.dirs
vendored
Normal file
1
debian/libpinproc1.dirs
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
usr/lib
|
||||||
27
debian/rules
vendored
Executable file
27
debian/rules
vendored
Executable file
@@ -0,0 +1,27 @@
|
|||||||
|
#!/usr/bin/make -f
|
||||||
|
# -*- makefile -*-
|
||||||
|
|
||||||
|
# Uncomment this to turn on verbose mode.
|
||||||
|
export DH_VERBOSE=1
|
||||||
|
|
||||||
|
%:
|
||||||
|
dh $@
|
||||||
|
|
||||||
|
override_dh_auto_clean:
|
||||||
|
dh_auto_clean
|
||||||
|
@rm -Rf $(CURDIR)/bin
|
||||||
|
|
||||||
|
override_dh_auto_configure:
|
||||||
|
mkdir $(CURDIR)/bin
|
||||||
|
cd $(CURDIR)/bin && cmake -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX="/usr/" ..
|
||||||
|
|
||||||
|
override_dh_auto_build:
|
||||||
|
cd $(CURDIR)/bin && make
|
||||||
|
|
||||||
|
override_dh_auto_install:
|
||||||
|
dh_auto_install
|
||||||
|
cd $(CURDIR)/bin && make install DESTDIR=$(CURDIR)/debian/tmp
|
||||||
|
|
||||||
|
# needed until 15.10 because of manual compile
|
||||||
|
override_dh_shlibdeps:
|
||||||
|
dh_shlibdeps --dpkg-shlibdeps-params=--ignore-missing-info
|
||||||
1
debian/source/format
vendored
Normal file
1
debian/source/format
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
3.0 (quilt)
|
||||||
@@ -138,6 +138,9 @@ PINPROC_API PRResult PRFlushWriteData(PRHandle handle);
|
|||||||
/** Write data out to the P-ROC immediately (does not require a call to PRFlushWriteData). */
|
/** Write data out to the P-ROC immediately (does not require a call to PRFlushWriteData). */
|
||||||
PINPROC_API PRResult PRWriteData(PRHandle handle, uint32_t moduleSelect, uint32_t startingAddr, int32_t numWriteWords, uint32_t * writeBuffer);
|
PINPROC_API PRResult PRWriteData(PRHandle handle, uint32_t moduleSelect, uint32_t startingAddr, int32_t numWriteWords, uint32_t * writeBuffer);
|
||||||
|
|
||||||
|
/** Write data buffered to P-ROC (does require a call to PRFlushWriteData). */
|
||||||
|
PINPROC_API PRResult PRWriteDataUnbuffered(PRHandle handle, uint32_t moduleSelect, uint32_t startingAddr, int32_t numWriteWords, uint32_t * writeBuffer);
|
||||||
|
|
||||||
/** Read data from the P-ROC. */
|
/** Read data from the P-ROC. */
|
||||||
PINPROC_API PRResult PRReadData(PRHandle handle, uint32_t moduleSelect, uint32_t startingAddr, int32_t numReadWords, uint32_t * readBuffer);
|
PINPROC_API PRResult PRReadData(PRHandle handle, uint32_t moduleSelect, uint32_t startingAddr, int32_t numReadWords, uint32_t * readBuffer);
|
||||||
|
|
||||||
|
|||||||
299
src/PRDevice.cpp
299
src/PRDevice.cpp
@@ -71,15 +71,15 @@ PRDevice* PRDevice::Create(PRMachineType machineType)
|
|||||||
if (machineType != kPRMachineCustom && machineType != kPRMachinePDB &&
|
if (machineType != kPRMachineCustom && machineType != kPRMachinePDB &&
|
||||||
|
|
||||||
// Don't accept if requested type is WPC/WPC95 but read machine is not.
|
// Don't accept if requested type is WPC/WPC95 but read machine is not.
|
||||||
( (((machineType == kPRMachineWPC) ||
|
( (((machineType == kPRMachineWPC) ||
|
||||||
(machineType == kPRMachineWPC95) ||
|
(machineType == kPRMachineWPC95) ||
|
||||||
(machineType == kPRMachineWPCAlphanumeric)) &&
|
(machineType == kPRMachineWPCAlphanumeric)) &&
|
||||||
(readMachineType != kPRMachineWPC &&
|
(readMachineType != kPRMachineWPC &&
|
||||||
readMachineType != kPRMachineWPC95 &&
|
readMachineType != kPRMachineWPC95 &&
|
||||||
readMachineType != kPRMachineWPCAlphanumeric)) ||
|
readMachineType != kPRMachineWPCAlphanumeric)) ||
|
||||||
// Also don't accept if the requested is not WPC/WPC95 but the P-ROC is.
|
// Also don't accept if the requested is not WPC/WPC95 but the P-ROC is.
|
||||||
(machineType != kPRMachineWPC &&
|
(machineType != kPRMachineWPC &&
|
||||||
machineType != kPRMachineWPC95 &&
|
machineType != kPRMachineWPC95 &&
|
||||||
machineType != kPRMachineWPCAlphanumeric &&
|
machineType != kPRMachineWPCAlphanumeric &&
|
||||||
readMachineType == kPRMachineWPC) ) )
|
readMachineType == kPRMachineWPC) ) )
|
||||||
{
|
{
|
||||||
@@ -95,7 +95,7 @@ PRDevice* PRDevice::Create(PRMachineType machineType)
|
|||||||
PRResult PRDevice::Reset(uint32_t resetFlags)
|
PRResult PRDevice::Reset(uint32_t resetFlags)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
// Initialize buffer pointers
|
// Initialize buffer pointers
|
||||||
collected_bytes_rd_addr = 0;
|
collected_bytes_rd_addr = 0;
|
||||||
collected_bytes_wr_addr = 0;
|
collected_bytes_wr_addr = 0;
|
||||||
@@ -106,12 +106,12 @@ PRResult PRDevice::Reset(uint32_t resetFlags)
|
|||||||
while (!requestedDataQueue.empty()) requestedDataQueue.pop();
|
while (!requestedDataQueue.empty()) requestedDataQueue.pop();
|
||||||
num_collected_bytes = 0;
|
num_collected_bytes = 0;
|
||||||
numPreparedWriteWords = 0;
|
numPreparedWriteWords = 0;
|
||||||
|
|
||||||
if (machineType != kPRMachineCustom && machineType != kPRMachinePDB) DriverLoadMachineTypeDefaults(machineType, resetFlags);
|
if (machineType != kPRMachineCustom && machineType != kPRMachinePDB) DriverLoadMachineTypeDefaults(machineType, resetFlags);
|
||||||
|
|
||||||
// Disable dmd events if updating the device.
|
// Disable dmd events if updating the device.
|
||||||
#if 0
|
#if 0
|
||||||
if (resetFlags & kPRResetFlagUpdateDevice)
|
if (resetFlags & kPRResetFlagUpdateDevice)
|
||||||
{
|
{
|
||||||
PRDMDConfig *dmdConfig = &(this->dmdConfig);
|
PRDMDConfig *dmdConfig = &(this->dmdConfig);
|
||||||
dmdConfig->enableFrameEvents = false;
|
dmdConfig->enableFrameEvents = false;
|
||||||
@@ -121,9 +121,9 @@ PRResult PRDevice::Reset(uint32_t resetFlags)
|
|||||||
|
|
||||||
// Make sure the free list is empty.
|
// Make sure the free list is empty.
|
||||||
while (!freeSwitchRuleIndexes.empty()) freeSwitchRuleIndexes.pop();
|
while (!freeSwitchRuleIndexes.empty()) freeSwitchRuleIndexes.pop();
|
||||||
|
|
||||||
memset(switchRules, 0x00, sizeof(PRSwitchRuleInternal) * maxSwitchRules);
|
memset(switchRules, 0x00, sizeof(PRSwitchRuleInternal) * maxSwitchRules);
|
||||||
|
|
||||||
for (i = 0; i < kPRSwitchRulesCount; i++)
|
for (i = 0; i < kPRSwitchRulesCount; i++)
|
||||||
{
|
{
|
||||||
PRSwitchRuleInternal *switchRule = &switchRules[i];
|
PRSwitchRuleInternal *switchRule = &switchRules[i];
|
||||||
@@ -137,15 +137,15 @@ PRResult PRDevice::Reset(uint32_t resetFlags)
|
|||||||
// However, some of the switches are always optos and don't need to be debounced.
|
// However, some of the switches are always optos and don't need to be debounced.
|
||||||
// So the debounced rule resources for those switches are available for linked rules.
|
// So the debounced rule resources for those switches are available for linked rules.
|
||||||
if (switchRule->switchNum >= kPRSwitchNeverDebounceFirst &&
|
if (switchRule->switchNum >= kPRSwitchNeverDebounceFirst &&
|
||||||
(switchRule->eventType == kPREventTypeSwitchClosedDebounced ||
|
(switchRule->eventType == kPREventTypeSwitchClosedDebounced ||
|
||||||
switchRule->eventType == kPREventTypeSwitchOpenDebounced))
|
switchRule->eventType == kPREventTypeSwitchOpenDebounced))
|
||||||
freeSwitchRuleIndexes.push(ruleIndex);
|
freeSwitchRuleIndexes.push(ruleIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create empty switch rule for clearing the rules in the device.
|
// Create empty switch rule for clearing the rules in the device.
|
||||||
PRSwitchRule emptySwitchRule;
|
PRSwitchRule emptySwitchRule;
|
||||||
memset(&emptySwitchRule, 0x00, sizeof(PRSwitchRule));
|
memset(&emptySwitchRule, 0x00, sizeof(PRSwitchRule));
|
||||||
|
|
||||||
for (i = 0; i < kPRSwitchCount; i++)
|
for (i = 0; i < kPRSwitchCount; i++)
|
||||||
{
|
{
|
||||||
// Send blank rule for each event type to Device if necessary
|
// Send blank rule for each event type to Device if necessary
|
||||||
@@ -166,7 +166,7 @@ int PRDevice::GetEvents(PREvent *events, int maxEvents)
|
|||||||
if (SortReturningData() != kPRSuccess)
|
if (SortReturningData() != kPRSuccess)
|
||||||
{
|
{
|
||||||
PRSetLastErrorText("GetEvents ERROR: Error in CollectReadData");
|
PRSetLastErrorText("GetEvents ERROR: Error in CollectReadData");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The unrequestedDataQueue only has unrequested switch event data. Pop
|
// The unrequestedDataQueue only has unrequested switch event data. Pop
|
||||||
@@ -177,7 +177,7 @@ int PRDevice::GetEvents(PREvent *events, int maxEvents)
|
|||||||
uint32_t event_data = unrequestedDataQueue.front();
|
uint32_t event_data = unrequestedDataQueue.front();
|
||||||
unrequestedDataQueue.pop();
|
unrequestedDataQueue.pop();
|
||||||
|
|
||||||
int type;
|
int type;
|
||||||
bool open, debounced;
|
bool open, debounced;
|
||||||
|
|
||||||
if (version >= 2) {
|
if (version >= 2) {
|
||||||
@@ -205,7 +205,7 @@ int PRDevice::GetEvents(PREvent *events, int maxEvents)
|
|||||||
events[i].type = debounced ? kPREventTypeSwitchOpenDebounced : kPREventTypeSwitchOpenNondebounced;
|
events[i].type = debounced ? kPREventTypeSwitchOpenDebounced : kPREventTypeSwitchOpenNondebounced;
|
||||||
else
|
else
|
||||||
events[i].type = debounced ? kPREventTypeSwitchClosedDebounced : kPREventTypeSwitchClosedNondebounced;
|
events[i].type = debounced ? kPREventTypeSwitchClosedDebounced : kPREventTypeSwitchClosedNondebounced;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case P_ROC_EVENT_TYPE_DMD:
|
case P_ROC_EVENT_TYPE_DMD:
|
||||||
@@ -219,7 +219,7 @@ int PRDevice::GetEvents(PREvent *events, int maxEvents)
|
|||||||
//fprintf(stderr, "\nBurst event");
|
//fprintf(stderr, "\nBurst event");
|
||||||
if (open) events[i].type = kPREventTypeBurstSwitchOpen;
|
if (open) events[i].type = kPREventTypeBurstSwitchOpen;
|
||||||
else events[i].type = kPREventTypeBurstSwitchClosed;
|
else events[i].type = kPREventTypeBurstSwitchClosed;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case P_ROC_EVENT_TYPE_ACCELEROMETER:
|
case P_ROC_EVENT_TYPE_ACCELEROMETER:
|
||||||
@@ -255,8 +255,8 @@ int PRDevice::GetEvents(PREvent *events, int maxEvents)
|
|||||||
}
|
}
|
||||||
|
|
||||||
default: events[i].type = kPREventTypeInvalid;
|
default: events[i].type = kPREventTypeInvalid;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
@@ -265,10 +265,9 @@ PRResult PRDevice::ManagerUpdateConfig(PRManagerConfig *managerConfig)
|
|||||||
{
|
{
|
||||||
const int burstWords = 2;
|
const int burstWords = 2;
|
||||||
uint32_t burst[burstWords];
|
uint32_t burst[burstWords];
|
||||||
int32_t rc;
|
|
||||||
DEBUG(PRLog(kPRLogInfo, "Setting Manager Config Register\n"));
|
DEBUG(PRLog(kPRLogInfo, "Setting Manager Config Register\n"));
|
||||||
this->managerConfig = *managerConfig;
|
this->managerConfig = *managerConfig;
|
||||||
rc = CreateManagerUpdateConfigBurst(burst, managerConfig);
|
CreateManagerUpdateConfigBurst(burst, managerConfig);
|
||||||
return PrepareWriteData(burst, burstWords);
|
return PrepareWriteData(burst, burstWords);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -276,15 +275,14 @@ PRResult PRDevice::DriverUpdateGlobalConfig(PRDriverGlobalConfig *driverGlobalCo
|
|||||||
{
|
{
|
||||||
const int burstWords = 4;
|
const int burstWords = 4;
|
||||||
uint32_t burst[burstWords];
|
uint32_t burst[burstWords];
|
||||||
int32_t rc;
|
|
||||||
|
|
||||||
DEBUG(PRLog(kPRLogInfo, "Installing driver globals\n"));
|
DEBUG(PRLog(kPRLogInfo, "Installing driver globals\n"));
|
||||||
|
|
||||||
this->driverGlobalConfig = *driverGlobalConfig;
|
this->driverGlobalConfig = *driverGlobalConfig;
|
||||||
rc = CreateDriverUpdateGlobalConfigBurst(burst, driverGlobalConfig);
|
CreateDriverUpdateGlobalConfigBurst(burst, driverGlobalConfig);
|
||||||
rc = CreateWatchdogConfigBurst(burst+2, driverGlobalConfig->watchdogExpired,
|
CreateWatchdogConfigBurst(burst+2, driverGlobalConfig->watchdogExpired,
|
||||||
driverGlobalConfig->watchdogEnable,
|
driverGlobalConfig->watchdogEnable,
|
||||||
driverGlobalConfig->watchdogResetTime);
|
driverGlobalConfig->watchdogResetTime);
|
||||||
|
|
||||||
DEBUG(PRLog(kPRLogVerbose, "Driver Global words: %x %x\n", burst[0], burst[1]));
|
DEBUG(PRLog(kPRLogVerbose, "Driver Global words: %x %x\n", burst[0], burst[1]));
|
||||||
DEBUG(PRLog(kPRLogVerbose, "Watchdog words: %x %x\n", burst[2], burst[3]));
|
DEBUG(PRLog(kPRLogVerbose, "Watchdog words: %x %x\n", burst[2], burst[3]));
|
||||||
@@ -301,11 +299,10 @@ PRResult PRDevice::DriverUpdateGroupConfig(PRDriverGroupConfig *driverGroupConfi
|
|||||||
{
|
{
|
||||||
const int burstWords = 2;
|
const int burstWords = 2;
|
||||||
uint32_t burst[burstWords];
|
uint32_t burst[burstWords];
|
||||||
int32_t rc;
|
|
||||||
|
|
||||||
driverGroups[driverGroupConfig->groupNum] = *driverGroupConfig;
|
driverGroups[driverGroupConfig->groupNum] = *driverGroupConfig;
|
||||||
DEBUG(PRLog(kPRLogInfo, "Installing driver group\n"));
|
DEBUG(PRLog(kPRLogInfo, "Installing driver group\n"));
|
||||||
rc = CreateDriverUpdateGroupConfigBurst(burst, driverGroupConfig);
|
CreateDriverUpdateGroupConfigBurst(burst, driverGroupConfig);
|
||||||
|
|
||||||
DEBUG(PRLog(kPRLogVerbose, "Words: %x %x\n", burst[0], burst[1]));
|
DEBUG(PRLog(kPRLogVerbose, "Words: %x %x\n", burst[0], burst[1]));
|
||||||
return PrepareWriteData(burst, burstWords);
|
return PrepareWriteData(burst, burstWords);
|
||||||
@@ -321,10 +318,9 @@ PRResult PRDevice::DriverUpdateState(PRDriverState *driverState)
|
|||||||
{
|
{
|
||||||
const int burstWords = 3;
|
const int burstWords = 3;
|
||||||
uint32_t burst[burstWords];
|
uint32_t burst[burstWords];
|
||||||
int32_t rc;
|
|
||||||
|
|
||||||
// Don't allow Constant Pulse (non-schedule with time = 0) for known high current drivers.
|
// Don't allow Constant Pulse (non-schedule with time = 0) for known high current drivers.
|
||||||
// Note, the driver numbers depend on the driver group settings from DriverLoadMachineTypeDefaults.
|
// Note, the driver numbers depend on the driver group settings from DriverLoadMachineTypeDefaults.
|
||||||
// TODO: Create some constants that are used both here and in DriverLoadMachineTypeDefaults.
|
// TODO: Create some constants that are used both here and in DriverLoadMachineTypeDefaults.
|
||||||
|
|
||||||
DEBUG(PRLog(kPRLogInfo, "Updating driver #%d\n", driverState->driverNum));
|
DEBUG(PRLog(kPRLogInfo, "Updating driver #%d\n", driverState->driverNum));
|
||||||
@@ -337,7 +333,7 @@ PRResult PRDevice::DriverUpdateState(PRDriverState *driverState)
|
|||||||
|
|
||||||
drivers[driverState->driverNum] = *driverState;
|
drivers[driverState->driverNum] = *driverState;
|
||||||
|
|
||||||
rc = CreateDriverUpdateBurst(burst, &drivers[driverState->driverNum]);
|
CreateDriverUpdateBurst(burst, &drivers[driverState->driverNum]);
|
||||||
DEBUG(PRLog(kPRLogVerbose, "Words: %x %x %x\n", burst[0], burst[1], burst[2]));
|
DEBUG(PRLog(kPRLogVerbose, "Words: %x %x %x\n", burst[0], burst[1], burst[2]));
|
||||||
|
|
||||||
return PrepareWriteData(burst, burstWords);
|
return PrepareWriteData(burst, burstWords);
|
||||||
@@ -347,10 +343,10 @@ PRResult PRDevice::DriverLoadMachineTypeDefaults(PRMachineType machineType, uint
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
PRResult res = kPRSuccess;
|
PRResult res = kPRSuccess;
|
||||||
|
|
||||||
//const int WPCDriverLoopTime = 4; // milliseconds
|
//const int WPCDriverLoopTime = 4; // milliseconds
|
||||||
//const int SternDriverLoopTime = 2; // milliseconds
|
//const int SternDriverLoopTime = 2; // milliseconds
|
||||||
|
|
||||||
const int mappedWPCDriverGroupEnableIndex[] = {0, 0, 0, 0, 0, 2, 4, 3, 1, 5, 7, 7, 7, 7, 7, 7, 7, 7, 8, 0, 0, 0, 0, 0, 0, 0};
|
const int mappedWPCDriverGroupEnableIndex[] = {0, 0, 0, 0, 0, 2, 4, 3, 1, 5, 7, 7, 7, 7, 7, 7, 7, 7, 8, 0, 0, 0, 0, 0, 0, 0};
|
||||||
const int mappedSternDriverGroupEnableIndex[] = {0, 0, 0, 0, 1, 0, 2, 3, 0, 0, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9};
|
const int mappedSternDriverGroupEnableIndex[] = {0, 0, 0, 0, 1, 0, 2, 3, 0, 0, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9};
|
||||||
const bool mappedWPCDriverGroupPolarity[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0};
|
const bool mappedWPCDriverGroupPolarity[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0};
|
||||||
@@ -361,9 +357,9 @@ PRResult PRDevice::DriverLoadMachineTypeDefaults(PRMachineType machineType, uint
|
|||||||
const int mappedSternDriverGroupSlowTime[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400};
|
const int mappedSternDriverGroupSlowTime[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400};
|
||||||
const int mappedWPCDriverGroupActivateIndex[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 0, 0, 0, 0, 0, 0, 0, 0};
|
const int mappedWPCDriverGroupActivateIndex[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||||
const int mappedSternDriverGroupActivateIndex[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7};
|
const int mappedSternDriverGroupActivateIndex[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7};
|
||||||
|
|
||||||
const int watchdogResetTime = 1000; // milliseconds
|
const int watchdogResetTime = 1000; // milliseconds
|
||||||
|
|
||||||
int mappedDriverGroupEnableIndex[kPRDriverGroupsMax];
|
int mappedDriverGroupEnableIndex[kPRDriverGroupsMax];
|
||||||
bool mappedDriverGroupPolarity[kPRDriverGroupsMax];
|
bool mappedDriverGroupPolarity[kPRDriverGroupsMax];
|
||||||
int mappedDriverGroupSlowTime[kPRDriverGroupsMax];
|
int mappedDriverGroupSlowTime[kPRDriverGroupsMax];
|
||||||
@@ -380,51 +376,51 @@ PRResult PRDevice::DriverLoadMachineTypeDefaults(PRMachineType machineType, uint
|
|||||||
int rowEnableSelect;
|
int rowEnableSelect;
|
||||||
int lastCoilDriverGroup;
|
int lastCoilDriverGroup;
|
||||||
|
|
||||||
|
|
||||||
switch (machineType)
|
switch (machineType)
|
||||||
{
|
{
|
||||||
case kPRMachineWPC:
|
case kPRMachineWPC:
|
||||||
case kPRMachineWPC95:
|
case kPRMachineWPC95:
|
||||||
case kPRMachineWPCAlphanumeric:
|
case kPRMachineWPCAlphanumeric:
|
||||||
{
|
{
|
||||||
memcpy(mappedDriverGroupEnableIndex,mappedWPCDriverGroupEnableIndex,
|
memcpy(mappedDriverGroupEnableIndex,mappedWPCDriverGroupEnableIndex,
|
||||||
sizeof(mappedDriverGroupEnableIndex));
|
sizeof(mappedDriverGroupEnableIndex));
|
||||||
memcpy(mappedDriverGroupPolarity,mappedWPCDriverGroupPolarity,
|
memcpy(mappedDriverGroupPolarity,mappedWPCDriverGroupPolarity,
|
||||||
sizeof(mappedDriverGroupPolarity));
|
sizeof(mappedDriverGroupPolarity));
|
||||||
rowEnableIndex1 = 6; // Unused in WPC
|
rowEnableIndex1 = 6; // Unused in WPC
|
||||||
rowEnableIndex0 = 6;
|
rowEnableIndex0 = 6;
|
||||||
tickleSternWatchdog = false;
|
tickleSternWatchdog = false;
|
||||||
globalPolarity = false;
|
globalPolarity = false;
|
||||||
activeLowMatrixRows = true;
|
activeLowMatrixRows = true;
|
||||||
driverLoopTime = 4; // milliseconds
|
driverLoopTime = 4; // milliseconds
|
||||||
memcpy(mappedDriverGroupSlowTime,mappedWPCDriverGroupSlowTime,
|
memcpy(mappedDriverGroupSlowTime,mappedWPCDriverGroupSlowTime,
|
||||||
sizeof(mappedDriverGroupSlowTime));
|
sizeof(mappedDriverGroupSlowTime));
|
||||||
memcpy(mappedDriverGroupActivateIndex,mappedWPCDriverGroupActivateIndex,
|
memcpy(mappedDriverGroupActivateIndex,mappedWPCDriverGroupActivateIndex,
|
||||||
sizeof(mappedDriverGroupActivateIndex));
|
sizeof(mappedDriverGroupActivateIndex));
|
||||||
numMatrixGroups = 8;
|
numMatrixGroups = 8;
|
||||||
encodeEnables = false;
|
encodeEnables = false;
|
||||||
rowEnableSelect = 0;
|
rowEnableSelect = 0;
|
||||||
lastCoilDriverGroup = lastWPCCoilDriverGroup;
|
lastCoilDriverGroup = lastWPCCoilDriverGroup;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case kPRMachineSternWhitestar:
|
case kPRMachineSternWhitestar:
|
||||||
case kPRMachineSternSAM:
|
case kPRMachineSternSAM:
|
||||||
{
|
{
|
||||||
memcpy(mappedDriverGroupEnableIndex,mappedSternDriverGroupEnableIndex,
|
memcpy(mappedDriverGroupEnableIndex,mappedSternDriverGroupEnableIndex,
|
||||||
sizeof(mappedDriverGroupEnableIndex));
|
sizeof(mappedDriverGroupEnableIndex));
|
||||||
memcpy(mappedDriverGroupPolarity,mappedSternDriverGroupPolarity,
|
memcpy(mappedDriverGroupPolarity,mappedSternDriverGroupPolarity,
|
||||||
sizeof(mappedDriverGroupPolarity));
|
sizeof(mappedDriverGroupPolarity));
|
||||||
rowEnableIndex1 = 6; // Unused in Stern
|
rowEnableIndex1 = 6; // Unused in Stern
|
||||||
rowEnableIndex0 = 10;
|
rowEnableIndex0 = 10;
|
||||||
tickleSternWatchdog = true;
|
tickleSternWatchdog = true;
|
||||||
globalPolarity = true;
|
globalPolarity = true;
|
||||||
activeLowMatrixRows = false;
|
activeLowMatrixRows = false;
|
||||||
driverLoopTime = 1; // milliseconds
|
driverLoopTime = 1; // milliseconds
|
||||||
memcpy(mappedDriverGroupSlowTime,mappedSternDriverGroupSlowTime,
|
memcpy(mappedDriverGroupSlowTime,mappedSternDriverGroupSlowTime,
|
||||||
sizeof(mappedDriverGroupSlowTime));
|
sizeof(mappedDriverGroupSlowTime));
|
||||||
memcpy(mappedDriverGroupActivateIndex,mappedSternDriverGroupActivateIndex,
|
memcpy(mappedDriverGroupActivateIndex,mappedSternDriverGroupActivateIndex,
|
||||||
sizeof(mappedDriverGroupActivateIndex));
|
sizeof(mappedDriverGroupActivateIndex));
|
||||||
numMatrixGroups = 16;
|
numMatrixGroups = 16;
|
||||||
encodeEnables = true;
|
encodeEnables = true;
|
||||||
rowEnableSelect = 0;
|
rowEnableSelect = 0;
|
||||||
@@ -439,7 +435,7 @@ PRResult PRDevice::DriverLoadMachineTypeDefaults(PRMachineType machineType, uint
|
|||||||
return kPRSuccess;
|
return kPRSuccess;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(&driverGlobalConfig, 0x00, sizeof(PRDriverGlobalConfig));
|
memset(&driverGlobalConfig, 0x00, sizeof(PRDriverGlobalConfig));
|
||||||
for (i = 0; i < kPRDriverCount; i++)
|
for (i = 0; i < kPRDriverCount; i++)
|
||||||
{
|
{
|
||||||
@@ -448,7 +444,7 @@ PRResult PRDevice::DriverLoadMachineTypeDefaults(PRMachineType machineType, uint
|
|||||||
driver->driverNum = i;
|
driver->driverNum = i;
|
||||||
driver->polarity = mappedDriverGroupPolarity[i/8];
|
driver->polarity = mappedDriverGroupPolarity[i/8];
|
||||||
DEBUG(PRLog(kPRLogInfo,"\nDriver Polarity for Driver: %d is %x.", i,driver->polarity));
|
DEBUG(PRLog(kPRLogInfo,"\nDriver Polarity for Driver: %d is %x.", i,driver->polarity));
|
||||||
if (resetFlags & kPRResetFlagUpdateDevice)
|
if (resetFlags & kPRResetFlagUpdateDevice)
|
||||||
res = DriverUpdateState(driver);
|
res = DriverUpdateState(driver);
|
||||||
}
|
}
|
||||||
for (i = 0; i < kPRDriverGroupsMax; i++)
|
for (i = 0; i < kPRDriverGroupsMax; i++)
|
||||||
@@ -458,11 +454,11 @@ PRResult PRDevice::DriverLoadMachineTypeDefaults(PRMachineType machineType, uint
|
|||||||
group->groupNum = i;
|
group->groupNum = i;
|
||||||
group->polarity = mappedDriverGroupPolarity[i];
|
group->polarity = mappedDriverGroupPolarity[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Configure the groups. Each group corresponds to 8 consecutive drivers, starting
|
// Configure the groups. Each group corresponds to 8 consecutive drivers, starting
|
||||||
// with driver #32. The following 6 groups are configured for coils/flashlamps.
|
// with driver #32. The following 6 groups are configured for coils/flashlamps.
|
||||||
|
|
||||||
PRDriverGroupConfig group;
|
PRDriverGroupConfig group;
|
||||||
for (i = 4; i <= lastCoilDriverGroup; i++)
|
for (i = 4; i <= lastCoilDriverGroup; i++)
|
||||||
{
|
{
|
||||||
@@ -475,7 +471,7 @@ PRResult PRDevice::DriverLoadMachineTypeDefaults(PRMachineType machineType, uint
|
|||||||
group.polarity = mappedDriverGroupPolarity[i];
|
group.polarity = mappedDriverGroupPolarity[i];
|
||||||
group.active = 1;
|
group.active = 1;
|
||||||
group.disableStrobeAfter = false;
|
group.disableStrobeAfter = false;
|
||||||
|
|
||||||
if (resetFlags & kPRResetFlagUpdateDevice) {
|
if (resetFlags & kPRResetFlagUpdateDevice) {
|
||||||
res = DriverUpdateGroupConfig(&group);
|
res = DriverUpdateGroupConfig(&group);
|
||||||
DEBUG(PRLog(kPRLogInfo,"\nDriver Polarity for Group: %d is %x.", i,group.polarity));
|
DEBUG(PRLog(kPRLogInfo,"\nDriver Polarity for Group: %d is %x.", i,group.polarity));
|
||||||
@@ -484,7 +480,7 @@ PRResult PRDevice::DriverLoadMachineTypeDefaults(PRMachineType machineType, uint
|
|||||||
driverGroups[i] = group;
|
driverGroups[i] = group;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// The following 8 groups are configured for the feature lamp matrix.
|
// The following 8 groups are configured for the feature lamp matrix.
|
||||||
for (i = 10; i < 10 + numMatrixGroups; i++) {
|
for (i = 10; i < 10 + numMatrixGroups; i++) {
|
||||||
DriverGetGroupConfig(i, &group);
|
DriverGetGroupConfig(i, &group);
|
||||||
@@ -496,7 +492,7 @@ PRResult PRDevice::DriverLoadMachineTypeDefaults(PRMachineType machineType, uint
|
|||||||
group.polarity = mappedDriverGroupPolarity[i];
|
group.polarity = mappedDriverGroupPolarity[i];
|
||||||
group.active = 1;
|
group.active = 1;
|
||||||
group.disableStrobeAfter = mappedDriverGroupSlowTime[i] != 0;
|
group.disableStrobeAfter = mappedDriverGroupSlowTime[i] != 0;
|
||||||
|
|
||||||
if (resetFlags & kPRResetFlagUpdateDevice) {
|
if (resetFlags & kPRResetFlagUpdateDevice) {
|
||||||
res = DriverUpdateGroupConfig(&group);
|
res = DriverUpdateGroupConfig(&group);
|
||||||
DEBUG(PRLog(kPRLogInfo,"\nDriver Polarity for Group: %d is %x.", i,group.polarity));
|
DEBUG(PRLog(kPRLogInfo,"\nDriver Polarity for Group: %d is %x.", i,group.polarity));
|
||||||
@@ -517,7 +513,7 @@ PRResult PRDevice::DriverLoadMachineTypeDefaults(PRMachineType machineType, uint
|
|||||||
group.polarity = mappedDriverGroupPolarity[i];
|
group.polarity = mappedDriverGroupPolarity[i];
|
||||||
group.active = 1;
|
group.active = 1;
|
||||||
group.disableStrobeAfter = false;
|
group.disableStrobeAfter = false;
|
||||||
|
|
||||||
if (resetFlags & kPRResetFlagUpdateDevice) {
|
if (resetFlags & kPRResetFlagUpdateDevice) {
|
||||||
res = DriverUpdateGroupConfig(&group);
|
res = DriverUpdateGroupConfig(&group);
|
||||||
DEBUG(PRLog(kPRLogInfo,"\nDriver Polarity for Group: %d is %x.\n", i,group.polarity));
|
DEBUG(PRLog(kPRLogInfo,"\nDriver Polarity for Group: %d is %x.\n", i,group.polarity));
|
||||||
@@ -540,16 +536,16 @@ PRResult PRDevice::DriverLoadMachineTypeDefaults(PRMachineType machineType, uint
|
|||||||
globals.watchdogExpired = false;
|
globals.watchdogExpired = false;
|
||||||
globals.watchdogEnable = true;
|
globals.watchdogEnable = true;
|
||||||
globals.watchdogResetTime = watchdogResetTime;
|
globals.watchdogResetTime = watchdogResetTime;
|
||||||
|
|
||||||
// We want to start up safely, so we'll update the global driver config twice.
|
// We want to start up safely, so we'll update the global driver config twice.
|
||||||
// When we toggle enableOutputs like this P-ROC will reset the polarity:
|
// When we toggle enableOutputs like this P-ROC will reset the polarity:
|
||||||
|
|
||||||
// Enable now without the outputs enabled:
|
// Enable now without the outputs enabled:
|
||||||
if (resetFlags & kPRResetFlagUpdateDevice)
|
if (resetFlags & kPRResetFlagUpdateDevice)
|
||||||
res = DriverUpdateGlobalConfig(&globals);
|
res = DriverUpdateGlobalConfig(&globals);
|
||||||
else
|
else
|
||||||
driverGlobalConfig = globals;
|
driverGlobalConfig = globals;
|
||||||
|
|
||||||
// Now enable the outputs to protect against the polarity being driven incorrectly:
|
// Now enable the outputs to protect against the polarity being driven incorrectly:
|
||||||
globals.enableOutputs = true;
|
globals.enableOutputs = true;
|
||||||
if (resetFlags & kPRResetFlagUpdateDevice)
|
if (resetFlags & kPRResetFlagUpdateDevice)
|
||||||
@@ -559,7 +555,7 @@ PRResult PRDevice::DriverLoadMachineTypeDefaults(PRMachineType machineType, uint
|
|||||||
|
|
||||||
// If WPCAlphanumeric, select Aux functionality for the dual-purpose Aux/DMD
|
// If WPCAlphanumeric, select Aux functionality for the dual-purpose Aux/DMD
|
||||||
// pins.
|
// pins.
|
||||||
|
|
||||||
managerConfig.reuse_dmd_data_for_aux = (machineType == kPRMachineWPCAlphanumeric);
|
managerConfig.reuse_dmd_data_for_aux = (machineType == kPRMachineWPCAlphanumeric);
|
||||||
managerConfig.invert_dipswitch_1 = false;
|
managerConfig.invert_dipswitch_1 = false;
|
||||||
ManagerUpdateConfig(&managerConfig);
|
ManagerUpdateConfig(&managerConfig);
|
||||||
@@ -598,12 +594,11 @@ PRResult PRDevice::DriverWatchdogTickle()
|
|||||||
{
|
{
|
||||||
const int burstWords = 2;
|
const int burstWords = 2;
|
||||||
uint32_t burst[burstWords];
|
uint32_t burst[burstWords];
|
||||||
int32_t rc;
|
|
||||||
|
CreateWatchdogConfigBurst(burst, driverGlobalConfig.watchdogExpired,
|
||||||
rc = CreateWatchdogConfigBurst(burst, driverGlobalConfig.watchdogExpired,
|
driverGlobalConfig.watchdogEnable,
|
||||||
driverGlobalConfig.watchdogEnable,
|
driverGlobalConfig.watchdogResetTime);
|
||||||
driverGlobalConfig.watchdogResetTime);
|
|
||||||
|
|
||||||
return PrepareWriteData(burst, burstWords);
|
return PrepareWriteData(burst, burstWords);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -635,8 +630,8 @@ PRResult PRDevice::SwitchUpdateRule(uint8_t switchNum, PREventType eventType, PR
|
|||||||
// Updates a single rule with the associated linked driver state changes.
|
// Updates a single rule with the associated linked driver state changes.
|
||||||
const int burstSize = 4;
|
const int burstSize = 4;
|
||||||
uint32_t burst[burstSize];
|
uint32_t burst[burstSize];
|
||||||
|
|
||||||
// If more the base rule will link to others, ensure free indexes exists for
|
// If more the base rule will link to others, ensure free indexes exists for
|
||||||
// the links.
|
// the links.
|
||||||
if (numDrivers > 0 && freeSwitchRuleIndexes.size() < (uint32_t)(numDrivers-1)) // -1 because the first switch rule holds the first driver.
|
if (numDrivers > 0 && freeSwitchRuleIndexes.size() < (uint32_t)(numDrivers-1)) // -1 because the first switch rule holds the first driver.
|
||||||
{
|
{
|
||||||
@@ -646,46 +641,46 @@ PRResult PRDevice::SwitchUpdateRule(uint8_t switchNum, PREventType eventType, PR
|
|||||||
|
|
||||||
PRResult res = kPRSuccess;
|
PRResult res = kPRSuccess;
|
||||||
uint32_t newRuleIndex = CreateSwitchRuleIndex(switchNum, eventType);
|
uint32_t newRuleIndex = CreateSwitchRuleIndex(switchNum, eventType);
|
||||||
|
|
||||||
// Because we're redefining the rule chain, we need to remove all previously existing links and return the indexes to the free list.
|
// Because we're redefining the rule chain, we need to remove all previously existing links and return the indexes to the free list.
|
||||||
PRSwitchRuleInternal *oldRule = GetSwitchRuleByIndex(newRuleIndex);
|
PRSwitchRuleInternal *oldRule = GetSwitchRuleByIndex(newRuleIndex);
|
||||||
|
|
||||||
uint16_t oldLinkIndex;
|
uint16_t oldLinkIndex;
|
||||||
while (oldRule->linkActive)
|
while (oldRule->linkActive)
|
||||||
{
|
{
|
||||||
// Save old link index so it can freed after the linked rule is retrieved.
|
// Save old link index so it can freed after the linked rule is retrieved.
|
||||||
oldLinkIndex = oldRule->linkIndex;
|
oldLinkIndex = oldRule->linkIndex;
|
||||||
oldRule = GetSwitchRuleByIndex(oldRule->linkIndex);
|
oldRule = GetSwitchRuleByIndex(oldRule->linkIndex);
|
||||||
freeSwitchRuleIndexes.push(oldLinkIndex);
|
freeSwitchRuleIndexes.push(oldLinkIndex);
|
||||||
|
|
||||||
if (freeSwitchRuleIndexes.size() > 128) // Detect a corrupted link-related values before it eats up all of the memory.
|
if (freeSwitchRuleIndexes.size() > 128) // Detect a corrupted link-related values before it eats up all of the memory.
|
||||||
{
|
{
|
||||||
PRSetLastErrorText("Too many free switch rule indicies!");
|
PRSetLastErrorText("Too many free switch rule indicies!");
|
||||||
return kPRFailure;
|
return kPRFailure;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a pointer for new rules.
|
// Create a pointer for new rules.
|
||||||
PRSwitchRuleInternal *newRule;
|
PRSwitchRuleInternal *newRule;
|
||||||
|
|
||||||
// Process each driver who's state should change in response to the switch event.
|
// Process each driver who's state should change in response to the switch event.
|
||||||
if (numDrivers > 0)
|
if (numDrivers > 0)
|
||||||
{
|
{
|
||||||
uint32_t ruleIndex, savedRuleIndex;
|
uint32_t ruleIndex, savedRuleIndex;
|
||||||
|
|
||||||
// Need to program the main rule last just in case drive_outputs_now is true.
|
// Need to program the main rule last just in case drive_outputs_now is true.
|
||||||
// Otherwise, the hardware could try to access the linked rules before they're
|
// Otherwise, the hardware could try to access the linked rules before they're
|
||||||
// programmed. So, program the rules in reverse order.
|
// programmed. So, program the rules in reverse order.
|
||||||
|
|
||||||
// Move to last driver
|
// Move to last driver
|
||||||
linkedDrivers += (numDrivers - 1);
|
linkedDrivers += (numDrivers - 1);
|
||||||
int totalNumDrivers = numDrivers;
|
int totalNumDrivers = numDrivers;
|
||||||
|
|
||||||
while (numDrivers > 0)
|
while (numDrivers > 0)
|
||||||
{
|
{
|
||||||
if (numDrivers > 1)
|
if (numDrivers > 1)
|
||||||
{
|
{
|
||||||
ruleIndex = freeSwitchRuleIndexes.front();
|
ruleIndex = freeSwitchRuleIndexes.front();
|
||||||
freeSwitchRuleIndexes.pop();
|
freeSwitchRuleIndexes.pop();
|
||||||
newRule = GetSwitchRuleByIndex(ruleIndex);
|
newRule = GetSwitchRuleByIndex(ruleIndex);
|
||||||
newRule->driver = linkedDrivers[0];
|
newRule->driver = linkedDrivers[0];
|
||||||
@@ -741,7 +736,7 @@ PRResult PRDevice::SwitchUpdateRule(uint8_t switchNum, PREventType eventType, PR
|
|||||||
DEBUG(PRLog(kPRLogError, "Failed to disable.\n"));
|
DEBUG(PRLog(kPRLogError, "Failed to disable.\n"));
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
linkedDrivers--;
|
linkedDrivers--;
|
||||||
numDrivers--;
|
numDrivers--;
|
||||||
}
|
}
|
||||||
@@ -762,20 +757,19 @@ PRResult PRDevice::SwitchUpdateRule(uint8_t switchNum, PREventType eventType, PR
|
|||||||
// Write the rule:
|
// Write the rule:
|
||||||
res = PrepareWriteData(burst, burstSize);
|
res = PrepareWriteData(burst, burstSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
PRResult PRDevice::SwitchGetStates( PREventType * switchStates, uint16_t numSwitches )
|
PRResult PRDevice::SwitchGetStates( PREventType * switchStates, uint16_t numSwitches )
|
||||||
{
|
{
|
||||||
uint32_t rc;
|
|
||||||
uint32_t stateWord, debounceWord;
|
uint32_t stateWord, debounceWord;
|
||||||
uint8_t i, j;
|
uint8_t i, j;
|
||||||
PREventType eventType;
|
PREventType eventType;
|
||||||
|
|
||||||
// Request one state word and one debounce word at a time. Could make more efficient
|
// Request one state word and one debounce word at a time. Could make more efficient
|
||||||
// use of the USB bus by requesting a burst of state words and then a burst of debounce
|
// use of the USB bus by requesting a burst of state words and then a burst of debounce
|
||||||
// words, but doing one word at a time makes it easier to process each switch when the
|
// words, but doing one word at a time makes it easier to process each switch when the
|
||||||
// data returns. Also, this function shouldn't be called during timing sensitive
|
// data returns. Also, this function shouldn't be called during timing sensitive
|
||||||
// situations; so the inefficiencies are acceptable.
|
// situations; so the inefficiencies are acceptable.
|
||||||
for (i = 0; i < numSwitches / 32; i++)
|
for (i = 0; i < numSwitches / 32; i++)
|
||||||
@@ -783,44 +777,46 @@ PRResult PRDevice::SwitchGetStates( PREventType * switchStates, uint16_t numSwit
|
|||||||
|
|
||||||
if (chip_id == P_ROC_CHIP_ID)
|
if (chip_id == P_ROC_CHIP_ID)
|
||||||
{
|
{
|
||||||
rc = RequestData(P_ROC_BUS_SWITCH_CTRL_SELECT,
|
RequestData(P_ROC_BUS_SWITCH_CTRL_SELECT,
|
||||||
P_ROC_SWITCH_CTRL_STATE_BASE_ADDR + i, 1);
|
P_ROC_SWITCH_CTRL_STATE_BASE_ADDR + i, 1);
|
||||||
|
|
||||||
if (combinedVersionRevision < P_ROC_VER_REV_FIXED_SWITCH_STATE_READS) {
|
if (combinedVersionRevision < P_ROC_VER_REV_FIXED_SWITCH_STATE_READS) {
|
||||||
rc = RequestData(P_ROC_BUS_SWITCH_CTRL_SELECT,
|
RequestData(P_ROC_BUS_SWITCH_CTRL_SELECT,
|
||||||
P_ROC_SWITCH_CTRL_OLD_DEBOUNCE_BASE_ADDR + i, 1);
|
P_ROC_SWITCH_CTRL_OLD_DEBOUNCE_BASE_ADDR + i, 1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
rc = RequestData(P_ROC_BUS_SWITCH_CTRL_SELECT,
|
RequestData(P_ROC_BUS_SWITCH_CTRL_SELECT,
|
||||||
P_ROC_SWITCH_CTRL_DEBOUNCE_BASE_ADDR + i, 1);
|
P_ROC_SWITCH_CTRL_DEBOUNCE_BASE_ADDR + i, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else // chip == P3_ROC_CHIP_ID)
|
else // chip == P3_ROC_CHIP_ID)
|
||||||
{
|
{
|
||||||
rc = RequestData(P_ROC_BUS_SWITCH_CTRL_SELECT,
|
RequestData(P_ROC_BUS_SWITCH_CTRL_SELECT,
|
||||||
P3_ROC_SWITCH_CTRL_STATE_BASE_ADDR + i, 1);
|
P3_ROC_SWITCH_CTRL_STATE_BASE_ADDR + i, 1);
|
||||||
|
|
||||||
rc = RequestData(P_ROC_BUS_SWITCH_CTRL_SELECT,
|
RequestData(P_ROC_BUS_SWITCH_CTRL_SELECT,
|
||||||
P3_ROC_SWITCH_CTRL_DEBOUNCE_BASE_ADDR + i, 1);
|
P3_ROC_SWITCH_CTRL_DEBOUNCE_BASE_ADDR + i, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Expect 4 words for each 32 switches. The state and debounce words,
|
// Expect 4 words for each 32 switches. The state and debounce words,
|
||||||
// and the address words for both.
|
// and the address words for both.
|
||||||
uint16_t numWords = 4 * (numSwitches / 32);
|
uint16_t numWords = 4 * (numSwitches / 32);
|
||||||
|
|
||||||
i = 0; // Reset i so it can be used to prevent an infinite loop below
|
i = 0; // Reset i so it can be used to prevent an infinite loop below
|
||||||
|
|
||||||
// Wait for data to return. Give it 10 loops before giving up.
|
// Wait for data to return. Give it 10 loops before giving up.
|
||||||
while (requestedDataQueue.size() < numWords && i++ < 10)
|
while (requestedDataQueue.size() < numWords && i++ < 10)
|
||||||
{
|
{
|
||||||
PRSleep (10); // 10 milliseconds should be plenty of time.
|
PRSleep (10); // 10 milliseconds should be plenty of time.
|
||||||
if (SortReturningData() != kPRSuccess)
|
if (SortReturningData() != kPRSuccess)
|
||||||
|
{
|
||||||
return kPRFailure;
|
return kPRFailure;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure all of the requested words are available before processing them.
|
// Make sure all of the requested words are available before processing them.
|
||||||
// Too many words is just as bad as not enough words.
|
// Too many words is just as bad as not enough words.
|
||||||
// If too many come back, can they be trusted?
|
// If too many come back, can they be trusted?
|
||||||
if (requestedDataQueue.size() == numWords)
|
if (requestedDataQueue.size() == numWords)
|
||||||
{
|
{
|
||||||
@@ -829,10 +825,10 @@ PRResult PRDevice::SwitchGetStates( PREventType * switchStates, uint16_t numSwit
|
|||||||
{
|
{
|
||||||
requestedDataQueue.pop(); // Ignore address word. TODO: Verify this address word.
|
requestedDataQueue.pop(); // Ignore address word. TODO: Verify this address word.
|
||||||
stateWord = requestedDataQueue.front(); // This is the switch state word.
|
stateWord = requestedDataQueue.front(); // This is the switch state word.
|
||||||
requestedDataQueue.pop();
|
requestedDataQueue.pop();
|
||||||
requestedDataQueue.pop(); // Ignore address word. TODO: Verify this address word.
|
requestedDataQueue.pop(); // Ignore address word. TODO: Verify this address word.
|
||||||
debounceWord = requestedDataQueue.front(); // This is the debounce word.
|
debounceWord = requestedDataQueue.front(); // This is the debounce word.
|
||||||
requestedDataQueue.pop();
|
requestedDataQueue.pop();
|
||||||
|
|
||||||
// Loop through each bit of the words, combining them into an eventType
|
// Loop through each bit of the words, combining them into an eventType
|
||||||
for (j = 0; j < 32; j++)
|
for (j = 0; j < 32; j++)
|
||||||
@@ -851,7 +847,11 @@ PRResult PRDevice::SwitchGetStates( PREventType * switchStates, uint16_t numSwit
|
|||||||
}
|
}
|
||||||
return kPRSuccess;
|
return kPRSuccess;
|
||||||
}
|
}
|
||||||
else return kPRFailure;
|
else
|
||||||
|
{
|
||||||
|
PRSetLastErrorText("Switch response length does not match.");
|
||||||
|
return kPRFailure;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t PRDevice::DMDUpdateConfig(PRDMDConfig *dmdConfig)
|
int32_t PRDevice::DMDUpdateConfig(PRDMDConfig *dmdConfig)
|
||||||
@@ -993,8 +993,8 @@ PRResult PRDevice::Open()
|
|||||||
|
|
||||||
// Attempt to turn off events. This is necessary if P-ROC wasn't shut down
|
// Attempt to turn off events. This is necessary if P-ROC wasn't shut down
|
||||||
// properly previously. If the P-ROC isn't initialized, this request will
|
// properly previously. If the P-ROC isn't initialized, this request will
|
||||||
// be ignored.
|
// be ignored.
|
||||||
|
|
||||||
PRDMDConfig dmdConfig;
|
PRDMDConfig dmdConfig;
|
||||||
dmdConfig.numRows = 32; // Doesn't matter.
|
dmdConfig.numRows = 32; // Doesn't matter.
|
||||||
dmdConfig.numColumns = 128; // Doesn't matter
|
dmdConfig.numColumns = 128; // Doesn't matter
|
||||||
@@ -1016,7 +1016,7 @@ PRResult PRDevice::Open()
|
|||||||
switchConfig.pulseHalfPeriodTime = 13; // milliseconds
|
switchConfig.pulseHalfPeriodTime = 13; // milliseconds
|
||||||
SwitchUpdateConfig(&switchConfig);
|
SwitchUpdateConfig(&switchConfig);
|
||||||
|
|
||||||
// Flush read data to ensure VerifyChipID starts with clean buffer.
|
// Flush read data to ensure VerifyChipID starts with clean buffer.
|
||||||
// It's possible the P-ROC has a lot of data stored up in internal buffers. So if
|
// It's possible the P-ROC has a lot of data stored up in internal buffers. So if
|
||||||
// the verify still fails, do a bunch of flushes.
|
// the verify still fails, do a bunch of flushes.
|
||||||
res = FlushReadBuffer();
|
res = FlushReadBuffer();
|
||||||
@@ -1074,7 +1074,7 @@ PRResult PRDevice::VerifyChipID()
|
|||||||
|
|
||||||
max_count = 0;
|
max_count = 0;
|
||||||
// Wait for data to return. Give it 10 loops before giving up.
|
// Wait for data to return. Give it 10 loops before giving up.
|
||||||
while (requestedDataQueue.size() < 5 && max_count++ < max_count_limit)
|
while (requestedDataQueue.size() < 5 && max_count++ < max_count_limit)
|
||||||
{
|
{
|
||||||
PRSleep (10); // 10 milliseconds should be plenty of time.
|
PRSleep (10); // 10 milliseconds should be plenty of time.
|
||||||
if (SortReturningData() != kPRSuccess)
|
if (SortReturningData() != kPRSuccess)
|
||||||
@@ -1088,11 +1088,12 @@ PRResult PRDevice::VerifyChipID()
|
|||||||
buffer[i] = requestedDataQueue.front();
|
buffer[i] = requestedDataQueue.front();
|
||||||
requestedDataQueue.pop(); // Ignore address word. TODO: Verify the address.
|
requestedDataQueue.pop(); // Ignore address word. TODO: Verify the address.
|
||||||
}
|
}
|
||||||
if (buffer[1] != P_ROC_CHIP_ID && buffer[1] != P3_ROC_CHIP_ID)
|
if (buffer[1] != P_ROC_CHIP_ID && buffer[1] != P3_ROC_CHIP_ID)
|
||||||
{
|
{
|
||||||
DEBUG(PRLog(kPRLogError, "Error in VerifyID(): Dumping buffer\n"));
|
DEBUG(PRLog(kPRLogError, "Error in VerifyID(): Dumping buffer\n"));
|
||||||
for (i = 0; i < bufferWords; i++)
|
for (i = 0; i < bufferWords; i++)
|
||||||
DEBUG(PRLog(kPRLogError, "buffer[%d]: 0x%x\n", i, buffer[i]));
|
DEBUG(PRLog(kPRLogError, "buffer[%d]: 0x%x\n", i, buffer[i]));
|
||||||
|
PRSetLastErrorText("Chip ID does not match.");
|
||||||
rc = kPRFailure;
|
rc = kPRFailure;
|
||||||
}
|
}
|
||||||
else rc = kPRSuccess;
|
else rc = kPRSuccess;
|
||||||
@@ -1110,14 +1111,16 @@ PRResult PRDevice::VerifyChipID()
|
|||||||
else readMachineType = kPRMachineWPC; // Choose WPC or WPC95, doesn't matter.
|
else readMachineType = kPRMachineWPC; // Choose WPC or WPC95, doesn't matter.
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DEBUG(PRLog(kPRLogError, "Error reading Chip IP and Version. Read %d words instead of 5. The first 2 were: 0x%x and 0x%x.\n", requestedDataQueue.size(), buffer[0], buffer[1]));
|
DEBUG(PRLog(kPRLogError, "Error reading Chip IP and Version. Read %d words instead of 5. The first 2 were: 0x%x and 0x%x.\n", requestedDataQueue.size(), buffer[0], buffer[1]));
|
||||||
|
PRSetLastErrorText("Error reading Chip IP and Version. Read %d words instead of 5. The first 2 were: 0x%x and 0x%x.", requestedDataQueue.size(), buffer[0], buffer[1]);
|
||||||
rc = kPRFailure;
|
rc = kPRFailure;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Return failure without logging; calling function must log.
|
// Return failure without logging; calling function must log.
|
||||||
DEBUG(PRLog(kPRLogError, "Verify Chip ID took too long to receive data\n"));
|
DEBUG(PRLog(kPRLogError, "Verify Chip ID took too long to receive data\n"));
|
||||||
|
PRSetLastErrorText("Verify Chip ID took too long to receive data");
|
||||||
rc = kPRFailure;
|
rc = kPRFailure;
|
||||||
}
|
}
|
||||||
return (rc);
|
return (rc);
|
||||||
@@ -1132,7 +1135,7 @@ PRResult PRDevice::RequestData(uint32_t module_select, uint32_t start_addr, int3
|
|||||||
PRResult PRDevice::PrepareWriteData(uint32_t * words, int32_t numWords)
|
PRResult PRDevice::PrepareWriteData(uint32_t * words, int32_t numWords)
|
||||||
{
|
{
|
||||||
if (numWords > maxWriteWords)
|
if (numWords > maxWriteWords)
|
||||||
{
|
{
|
||||||
PRSetLastErrorText("%d words Exceeds write capabilities. Restrict write requests to %d words.", numWords, maxWriteWords);
|
PRSetLastErrorText("%d words Exceeds write capabilities. Restrict write requests to %d words.", numWords, maxWriteWords);
|
||||||
return kPRFailure;
|
return kPRFailure;
|
||||||
}
|
}
|
||||||
@@ -1179,10 +1182,6 @@ PRResult PRDevice::WriteData(uint32_t * words, int32_t numWords)
|
|||||||
wr_buffer[(j*4)+k] = (uint8_t)(temp_word & 0x000000ff);
|
wr_buffer[(j*4)+k] = (uint8_t)(temp_word & 0x000000ff);
|
||||||
temp_word = temp_word >> 8;
|
temp_word = temp_word >> 8;
|
||||||
}
|
}
|
||||||
// for (k=0; k<4; k++)
|
|
||||||
// {
|
|
||||||
// item = wr_buffer[(j*4)+k];
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int bytesToWrite = numWords * 4;
|
int bytesToWrite = numWords * 4;
|
||||||
@@ -1199,6 +1198,19 @@ PRResult PRDevice::WriteData(uint32_t * words, int32_t numWords)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PRResult PRDevice::WriteDataRawUnbuffered(uint32_t moduleSelect, uint32_t startingAddr, int32_t numWriteWords, uint32_t * writeBuffer)
|
||||||
|
{
|
||||||
|
PRResult res;
|
||||||
|
uint32_t * buffer;
|
||||||
|
|
||||||
|
buffer = (uint32_t *)malloc((numWriteWords * 4) + 4);
|
||||||
|
buffer[0] = CreateBurstCommand(moduleSelect, startingAddr, numWriteWords);
|
||||||
|
memcpy(buffer+1, writeBuffer, numWriteWords * 4);
|
||||||
|
res = PrepareWriteData(buffer, numWriteWords + 1);
|
||||||
|
free (buffer);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
PRResult PRDevice::WriteDataRaw(uint32_t moduleSelect, uint32_t startingAddr, int32_t numWriteWords, uint32_t * writeBuffer)
|
PRResult PRDevice::WriteDataRaw(uint32_t moduleSelect, uint32_t startingAddr, int32_t numWriteWords, uint32_t * writeBuffer)
|
||||||
{
|
{
|
||||||
PRResult res;
|
PRResult res;
|
||||||
@@ -1214,17 +1226,16 @@ PRResult PRDevice::WriteDataRaw(uint32_t moduleSelect, uint32_t startingAddr, in
|
|||||||
|
|
||||||
PRResult PRDevice::ReadDataRaw(uint32_t moduleSelect, uint32_t startingAddr, int32_t numReadWords, uint32_t * readBuffer)
|
PRResult PRDevice::ReadDataRaw(uint32_t moduleSelect, uint32_t startingAddr, int32_t numReadWords, uint32_t * readBuffer)
|
||||||
{
|
{
|
||||||
uint32_t rc;
|
int32_t i;
|
||||||
uint32_t i;
|
|
||||||
|
|
||||||
// Send out the request.
|
// Send out the request.
|
||||||
rc = RequestData(moduleSelect, startingAddr, numReadWords);
|
RequestData(moduleSelect, startingAddr, numReadWords);
|
||||||
|
|
||||||
i = 0; // Reset i so it can be used to prevent an infinite loop below
|
i = 0; // Reset i so it can be used to prevent an infinite loop below
|
||||||
|
|
||||||
// Wait for data to return. Give it 10 loops before giving up.
|
// Wait for data to return. Give it 10 loops before giving up.
|
||||||
// Expect numReadWords + 1 word with the address.
|
// Expect numReadWords + 1 word with the address.
|
||||||
while (requestedDataQueue.size() < (uint32_t)((numReadWords + 1)) && i++ < 10)
|
while (requestedDataQueue.size() < (uint32_t)((numReadWords + 1)) && i++ < 10)
|
||||||
{
|
{
|
||||||
PRSleep (10); // 10 milliseconds should be plenty of time.
|
PRSleep (10); // 10 milliseconds should be plenty of time.
|
||||||
if (SortReturningData() != kPRSuccess)
|
if (SortReturningData() != kPRSuccess)
|
||||||
@@ -1232,19 +1243,23 @@ PRResult PRDevice::ReadDataRaw(uint32_t moduleSelect, uint32_t startingAddr, int
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Make sure all of the requested words are available before processing them.
|
// Make sure all of the requested words are available before processing them.
|
||||||
// Too many words is just as bad as not enough words.
|
// Too many words is just as bad as not enough words.
|
||||||
// If too many come back, can they be trusted?
|
// If too many come back, can they be trusted?
|
||||||
if (requestedDataQueue.size() == (uint32_t)(numReadWords + 1))
|
if (requestedDataQueue.size() == (uint32_t)(numReadWords + 1))
|
||||||
{
|
{
|
||||||
requestedDataQueue.pop(); // Ignore address word. TODO: Verify the address.
|
requestedDataQueue.pop(); // Ignore address word. TODO: Verify the address.
|
||||||
for (i = 0; i < numReadWords; i++)
|
for (i = 0; i < numReadWords; i++)
|
||||||
{
|
{
|
||||||
readBuffer[i] = requestedDataQueue.front();
|
readBuffer[i] = requestedDataQueue.front();
|
||||||
requestedDataQueue.pop();
|
requestedDataQueue.pop();
|
||||||
}
|
}
|
||||||
return kPRSuccess;
|
return kPRSuccess;
|
||||||
}
|
}
|
||||||
else return kPRFailure;
|
else
|
||||||
|
{
|
||||||
|
PRSetLastErrorText("Response length did not match.");
|
||||||
|
return kPRFailure;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1273,6 +1288,7 @@ int32_t PRDevice::ReadData(uint32_t *buffer, int32_t num_words)
|
|||||||
rc = num_words;
|
rc = num_words;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
PRSetLastErrorText("Read length did not match.");
|
||||||
rc = 0;
|
rc = 0;
|
||||||
}
|
}
|
||||||
DEBUG(PRLog(kPRLogVerbose, "Read num bytes: %d\n", rc));
|
DEBUG(PRLog(kPRLogVerbose, "Read num bytes: %d\n", rc));
|
||||||
@@ -1281,12 +1297,11 @@ int32_t PRDevice::ReadData(uint32_t *buffer, int32_t num_words)
|
|||||||
|
|
||||||
PRResult PRDevice::FlushReadBuffer()
|
PRResult PRDevice::FlushReadBuffer()
|
||||||
{
|
{
|
||||||
int32_t numBytes,rc=0,k;
|
int32_t numBytes,rc=0;
|
||||||
//uint32_t rd_buffer[3];
|
//uint32_t rd_buffer[3];
|
||||||
numBytes = CollectReadData();
|
numBytes = CollectReadData();
|
||||||
k = 0;
|
|
||||||
DEBUG(PRLog(kPRLogError, "Flushing Read Buffer: %d bytes trashed\n", numBytes));
|
DEBUG(PRLog(kPRLogError, "Flushing Read Buffer: %d bytes trashed\n", numBytes));
|
||||||
|
|
||||||
//while (k < numBytes) {
|
//while (k < numBytes) {
|
||||||
// rc = ReadData(rd_buffer, 1);
|
// rc = ReadData(rd_buffer, 1);
|
||||||
// k++;
|
// k++;
|
||||||
@@ -1320,7 +1335,7 @@ int32_t PRDevice::CollectReadData()
|
|||||||
|
|
||||||
PRResult PRDevice::SortReturningData()
|
PRResult PRDevice::SortReturningData()
|
||||||
{
|
{
|
||||||
int32_t num_bytes, num_words, rc;
|
int32_t num_bytes, num_words;
|
||||||
uint32_t rd_buffer[FTDI_BUFFER_SIZE/4];
|
uint32_t rd_buffer[FTDI_BUFFER_SIZE/4];
|
||||||
|
|
||||||
num_bytes = CollectReadData();
|
num_bytes = CollectReadData();
|
||||||
@@ -1332,7 +1347,7 @@ PRResult PRDevice::SortReturningData()
|
|||||||
num_words = num_collected_bytes/4;
|
num_words = num_collected_bytes/4;
|
||||||
|
|
||||||
while (num_words >= 2) {
|
while (num_words >= 2) {
|
||||||
rc = ReadData(rd_buffer, 1);
|
ReadData(rd_buffer, 1);
|
||||||
DEBUG(PRLog(kPRLogVerbose, "New returning word: 0x%x\n", rd_buffer[0]));
|
DEBUG(PRLog(kPRLogVerbose, "New returning word: 0x%x\n", rd_buffer[0]));
|
||||||
|
|
||||||
switch ( (rd_buffer[0] & P_ROC_COMMAND_MASK) >> P_ROC_COMMAND_SHIFT)
|
switch ( (rd_buffer[0] & P_ROC_COMMAND_MASK) >> P_ROC_COMMAND_SHIFT)
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ public:
|
|||||||
|
|
||||||
PRResult FlushWriteData();
|
PRResult FlushWriteData();
|
||||||
PRResult WriteDataRaw(uint32_t moduleSelect, uint32_t startingAddr, int32_t numWriteWords, uint32_t * buffer);
|
PRResult WriteDataRaw(uint32_t moduleSelect, uint32_t startingAddr, int32_t numWriteWords, uint32_t * buffer);
|
||||||
|
PRResult WriteDataRawUnbuffered(uint32_t moduleSelect, uint32_t startingAddr, int32_t numWriteWords, uint32_t * buffer);
|
||||||
PRResult ReadDataRaw(uint32_t moduleSelect, uint32_t startingAddr, int32_t numReadWords, uint32_t * readBuffer);
|
PRResult ReadDataRaw(uint32_t moduleSelect, uint32_t startingAddr, int32_t numReadWords, uint32_t * readBuffer);
|
||||||
|
|
||||||
PRResult ManagerUpdateConfig(PRManagerConfig *managerConfig);
|
PRResult ManagerUpdateConfig(PRManagerConfig *managerConfig);
|
||||||
@@ -108,7 +109,7 @@ protected:
|
|||||||
|
|
||||||
// Raw write and read methods
|
// Raw write and read methods
|
||||||
//
|
//
|
||||||
|
|
||||||
/** Schedules data to be written to the P-ROC. */
|
/** Schedules data to be written to the P-ROC. */
|
||||||
PRResult PrepareWriteData(uint32_t * buffer, int32_t numWords);
|
PRResult PrepareWriteData(uint32_t * buffer, int32_t numWords);
|
||||||
|
|
||||||
@@ -174,7 +175,7 @@ protected:
|
|||||||
PRDriverGroupConfig driverGroups[maxDriverGroups];
|
PRDriverGroupConfig driverGroups[maxDriverGroups];
|
||||||
PRDriverState drivers[maxDrivers];
|
PRDriverState drivers[maxDrivers];
|
||||||
PRDMDConfig dmdConfig;
|
PRDMDConfig dmdConfig;
|
||||||
|
|
||||||
PRSwitchConfig switchConfig;
|
PRSwitchConfig switchConfig;
|
||||||
PRSwitchRuleInternal switchRules[maxSwitchRules];
|
PRSwitchRuleInternal switchRules[maxSwitchRules];
|
||||||
queue<uint32_t> freeSwitchRuleIndexes; /**< Indexes of available switch rules. */
|
queue<uint32_t> freeSwitchRuleIndexes; /**< Indexes of available switch rules. */
|
||||||
|
|||||||
@@ -33,9 +33,9 @@
|
|||||||
#include "PRCommon.h"
|
#include "PRCommon.h"
|
||||||
|
|
||||||
bool_t IsStern (uint32_t hardware_data) {
|
bool_t IsStern (uint32_t hardware_data) {
|
||||||
// if ( ((hardware_data & P_ROC_BOARD_VERSION_MASK) >> P_ROC_BOARD_VERSION_SHIFT) == 0x1)
|
// if ( ((hardware_data & P_ROC_BOARD_VERSION_MASK) >> P_ROC_BOARD_VERSION_SHIFT) == 0x1)
|
||||||
// return ( ((hardware_data & P_ROC_AUTO_STERN_DETECT_MASK) >> P_ROC_AUTO_STERN_DETECT_SHIFT) == P_ROC_AUTO_STERN_DETECT_VALUE);
|
// return ( ((hardware_data & P_ROC_AUTO_STERN_DETECT_MASK) >> P_ROC_AUTO_STERN_DETECT_SHIFT) == P_ROC_AUTO_STERN_DETECT_VALUE);
|
||||||
// else
|
// else
|
||||||
return ( ((hardware_data & P_ROC_MANUAL_STERN_DETECT_MASK) >> P_ROC_MANUAL_STERN_DETECT_SHIFT) == P_ROC_MANUAL_STERN_DETECT_VALUE);
|
return ( ((hardware_data & P_ROC_MANUAL_STERN_DETECT_MASK) >> P_ROC_MANUAL_STERN_DETECT_SHIFT) == P_ROC_MANUAL_STERN_DETECT_VALUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,11 +59,11 @@ int32_t CreateManagerUpdateConfigBurst ( uint32_t * burst, PRManagerConfig *mana
|
|||||||
|
|
||||||
addr = P_ROC_REG_DIPSWITCH_ADDR;
|
addr = P_ROC_REG_DIPSWITCH_ADDR;
|
||||||
burst[0] = CreateBurstCommand (P_ROC_MANAGER_SELECT, addr, 1 );
|
burst[0] = CreateBurstCommand (P_ROC_MANAGER_SELECT, addr, 1 );
|
||||||
burst[1] = ( (manager_config->reuse_dmd_data_for_aux <<
|
burst[1] = ( (manager_config->reuse_dmd_data_for_aux <<
|
||||||
P_ROC_MANAGER_REUSE_DMD_DATA_FOR_AUX_SHIFT) |
|
P_ROC_MANAGER_REUSE_DMD_DATA_FOR_AUX_SHIFT) |
|
||||||
(manager_config->invert_dipswitch_1 <<
|
(manager_config->invert_dipswitch_1 <<
|
||||||
P_ROC_MANAGER_INVERT_DIPSWITCH_1_SHIFT) );
|
P_ROC_MANAGER_INVERT_DIPSWITCH_1_SHIFT) );
|
||||||
|
|
||||||
return kPRSuccess;
|
return kPRSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,7 +181,7 @@ uint32_t CreateDriverAuxCommand ( PRDriverAuxCommand command) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default : {
|
default : {
|
||||||
return (false << P_ROC_DRIVER_AUX_ENTRY_ACTIVE_SHIFT);
|
return (false << P_ROC_DRIVER_AUX_ENTRY_ACTIVE_SHIFT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -189,13 +189,13 @@ uint32_t CreateDriverAuxCommand ( PRDriverAuxCommand command) {
|
|||||||
int32_t CreateWatchdogConfigBurst ( uint32_t * burst, bool_t watchdogExpired,
|
int32_t CreateWatchdogConfigBurst ( uint32_t * burst, bool_t watchdogExpired,
|
||||||
bool_t watchdogEnable, uint16_t watchdogResetTime) {
|
bool_t watchdogEnable, uint16_t watchdogResetTime) {
|
||||||
uint32_t addr;
|
uint32_t addr;
|
||||||
|
|
||||||
addr = P_ROC_REG_WATCHDOG_ADDR;
|
addr = P_ROC_REG_WATCHDOG_ADDR;
|
||||||
burst[0] = CreateBurstCommand (P_ROC_MANAGER_SELECT, addr, 1 );
|
burst[0] = CreateBurstCommand (P_ROC_MANAGER_SELECT, addr, 1 );
|
||||||
burst[1] = ( (watchdogExpired << P_ROC_MANAGER_WATCHDOG_EXPIRED_SHIFT) |
|
burst[1] = ( (watchdogExpired << P_ROC_MANAGER_WATCHDOG_EXPIRED_SHIFT) |
|
||||||
(watchdogEnable << P_ROC_MANAGER_WATCHDOG_ENABLE_SHIFT) |
|
(watchdogEnable << P_ROC_MANAGER_WATCHDOG_ENABLE_SHIFT) |
|
||||||
(watchdogResetTime << P_ROC_MANAGER_WATCHDOG_RESET_TIME_SHIFT) );
|
(watchdogResetTime << P_ROC_MANAGER_WATCHDOG_RESET_TIME_SHIFT) );
|
||||||
|
|
||||||
return kPRSuccess;
|
return kPRSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -206,39 +206,39 @@ int32_t CreateSwitchUpdateConfigBurst ( uint32_t * burst, PRSwitchConfig *switch
|
|||||||
addr = 0;
|
addr = 0;
|
||||||
burst[0] = CreateBurstCommand (P_ROC_BUS_SWITCH_CTRL_SELECT, addr, 1 );
|
burst[0] = CreateBurstCommand (P_ROC_BUS_SWITCH_CTRL_SELECT, addr, 1 );
|
||||||
burst[1] = (switchConfig->clear << P_ROC_SWITCH_CONFIG_CLEAR_SHIFT) |
|
burst[1] = (switchConfig->clear << P_ROC_SWITCH_CONFIG_CLEAR_SHIFT) |
|
||||||
(switchConfig->directMatrixScanLoopTime <<
|
(switchConfig->directMatrixScanLoopTime <<
|
||||||
P_ROC_SWITCH_CONFIG_MS_PER_DM_SCAN_LOOP_SHIFT) |
|
P_ROC_SWITCH_CONFIG_MS_PER_DM_SCAN_LOOP_SHIFT) |
|
||||||
(switchConfig->pulsesBeforeCheckingRX <<
|
(switchConfig->pulsesBeforeCheckingRX <<
|
||||||
P_ROC_SWITCH_CONFIG_PULSES_BEFORE_CHECKING_RX_SHIFT) |
|
P_ROC_SWITCH_CONFIG_PULSES_BEFORE_CHECKING_RX_SHIFT) |
|
||||||
(switchConfig->inactivePulsesAfterBurst <<
|
(switchConfig->inactivePulsesAfterBurst <<
|
||||||
P_ROC_SWITCH_CONFIG_INACTIVE_PULSES_AFTER_BURST_SHIFT) |
|
P_ROC_SWITCH_CONFIG_INACTIVE_PULSES_AFTER_BURST_SHIFT) |
|
||||||
(switchConfig->pulsesPerBurst <<
|
(switchConfig->pulsesPerBurst <<
|
||||||
P_ROC_SWITCH_CONFIG_PULSES_PER_BURST_SHIFT) |
|
P_ROC_SWITCH_CONFIG_PULSES_PER_BURST_SHIFT) |
|
||||||
(switchConfig->pulseHalfPeriodTime <<
|
(switchConfig->pulseHalfPeriodTime <<
|
||||||
P_ROC_SWITCH_CONFIG_MS_PER_PULSE_HALF_PERIOD_SHIFT) |
|
P_ROC_SWITCH_CONFIG_MS_PER_PULSE_HALF_PERIOD_SHIFT) |
|
||||||
(switchConfig->use_column_8 <<
|
(switchConfig->use_column_8 <<
|
||||||
P_ROC_SWITCH_CONFIG_USE_COLUMN_8) |
|
P_ROC_SWITCH_CONFIG_USE_COLUMN_8) |
|
||||||
(switchConfig->use_column_9 <<
|
(switchConfig->use_column_9 <<
|
||||||
P_ROC_SWITCH_CONFIG_USE_COLUMN_9);
|
P_ROC_SWITCH_CONFIG_USE_COLUMN_9);
|
||||||
burst[2] = CreateBurstCommand (P_ROC_BUS_STATE_CHANGE_PROC_SELECT,
|
burst[2] = CreateBurstCommand (P_ROC_BUS_STATE_CHANGE_PROC_SELECT,
|
||||||
P_ROC_STATE_CHANGE_CONFIG_ADDR, 1 );
|
P_ROC_STATE_CHANGE_CONFIG_ADDR, 1 );
|
||||||
burst[3] = switchConfig->hostEventsEnable;
|
burst[3] = switchConfig->hostEventsEnable;
|
||||||
|
|
||||||
return kPRSuccess;
|
return kPRSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t CreateSwitchRuleIndex(uint8_t switchNum, PREventType eventType)
|
int16_t CreateSwitchRuleIndex(uint8_t switchNum, PREventType eventType)
|
||||||
{
|
{
|
||||||
uint32_t debounce = (eventType == kPREventTypeSwitchOpenDebounced) || (eventType == kPREventTypeSwitchClosedDebounced) ? 1 : 0;
|
uint32_t debounce = (eventType == kPREventTypeSwitchOpenDebounced) || (eventType == kPREventTypeSwitchClosedDebounced) ? 1 : 0;
|
||||||
uint32_t state = (eventType == kPREventTypeSwitchOpenDebounced) || (eventType == kPREventTypeSwitchOpenNondebounced) ? 1 : 0;
|
uint32_t state = (eventType == kPREventTypeSwitchOpenDebounced) || (eventType == kPREventTypeSwitchOpenNondebounced) ? 1 : 0;
|
||||||
|
|
||||||
uint32_t index = ((debounce << P_ROC_SWITCH_RULE_NUM_DEBOUNCE_SHIFT) |
|
uint32_t index = ((debounce << P_ROC_SWITCH_RULE_NUM_DEBOUNCE_SHIFT) |
|
||||||
(state << P_ROC_SWITCH_RULE_NUM_STATE_SHIFT) |
|
(state << P_ROC_SWITCH_RULE_NUM_STATE_SHIFT) |
|
||||||
(switchNum << P_ROC_SWITCH_RULE_NUM_SWITCH_NUM_SHIFT) );
|
(switchNum << P_ROC_SWITCH_RULE_NUM_SWITCH_NUM_SHIFT) );
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t CreateSwitchRuleAddr(uint8_t switchNum, PREventType eventType, bool_t drive_outputs_now)
|
int32_t CreateSwitchRuleAddr(uint8_t switchNum, PREventType eventType, bool_t drive_outputs_now)
|
||||||
{
|
{
|
||||||
uint16_t number = CreateSwitchRuleIndex( switchNum, eventType );
|
uint16_t number = CreateSwitchRuleIndex( switchNum, eventType );
|
||||||
uint32_t addr = (number << P_ROC_SWITCH_RULE_NUM_TO_ADDR_SHIFT) |
|
uint32_t addr = (number << P_ROC_SWITCH_RULE_NUM_TO_ADDR_SHIFT) |
|
||||||
@@ -291,7 +291,7 @@ int32_t CreateDMDUpdateConfigBurst ( uint32_t * burst, PRDMDConfig *dmd_config)
|
|||||||
(dmd_config->numFrameBuffers << P_ROC_DMD_NUM_FRAME_BUFFERS_SHIFT) |
|
(dmd_config->numFrameBuffers << P_ROC_DMD_NUM_FRAME_BUFFERS_SHIFT) |
|
||||||
(dmd_config->numSubFrames << P_ROC_DMD_NUM_SUB_FRAMES_SHIFT) |
|
(dmd_config->numSubFrames << P_ROC_DMD_NUM_SUB_FRAMES_SHIFT) |
|
||||||
(dmd_config->numRows << P_ROC_DMD_NUM_ROWS_SHIFT) |
|
(dmd_config->numRows << P_ROC_DMD_NUM_ROWS_SHIFT) |
|
||||||
(dmd_config->numColumns << P_ROC_DMD_NUM_COLUMNS_SHIFT);
|
(dmd_config->numColumns << P_ROC_DMD_NUM_COLUMNS_SHIFT);
|
||||||
|
|
||||||
addr = 8;
|
addr = 8;
|
||||||
burst[2] = CreateBurstCommand (P_ROC_BUS_DMD_SELECT, addr, 4 );
|
burst[2] = CreateBurstCommand (P_ROC_BUS_DMD_SELECT, addr, 4 );
|
||||||
@@ -311,12 +311,12 @@ int32_t CreateJTAGForceOutputsBurst ( uint32_t * burst, PRJTAGOutputs *jtagOutpu
|
|||||||
burst[1] = 1 << P_ROC_JTAG_CMD_START_SHIFT |
|
burst[1] = 1 << P_ROC_JTAG_CMD_START_SHIFT |
|
||||||
1 << P_ROC_JTAG_CMD_OE_SHIFT |
|
1 << P_ROC_JTAG_CMD_OE_SHIFT |
|
||||||
P_ROC_JTAG_CMD_SET_PORTS << P_ROC_JTAG_CMD_CMD_SHIFT |
|
P_ROC_JTAG_CMD_SET_PORTS << P_ROC_JTAG_CMD_CMD_SHIFT |
|
||||||
jtagOutputs->tckMask << P_ROC_JTAG_TRANSITION_TCK_MASK_SHIFT |
|
jtagOutputs->tckMask << P_ROC_JTAG_TRANSITION_TCK_MASK_SHIFT |
|
||||||
jtagOutputs->tdoMask << P_ROC_JTAG_TRANSITION_TDO_MASK_SHIFT |
|
jtagOutputs->tdoMask << P_ROC_JTAG_TRANSITION_TDO_MASK_SHIFT |
|
||||||
jtagOutputs->tmsMask << P_ROC_JTAG_TRANSITION_TMS_MASK_SHIFT |
|
jtagOutputs->tmsMask << P_ROC_JTAG_TRANSITION_TMS_MASK_SHIFT |
|
||||||
jtagOutputs->tck << P_ROC_JTAG_TRANSITION_TCK_SHIFT |
|
jtagOutputs->tck << P_ROC_JTAG_TRANSITION_TCK_SHIFT |
|
||||||
jtagOutputs->tdo << P_ROC_JTAG_TRANSITION_TCK_SHIFT |
|
jtagOutputs->tdo << P_ROC_JTAG_TRANSITION_TCK_SHIFT |
|
||||||
jtagOutputs->tms << P_ROC_JTAG_TRANSITION_TCK_SHIFT;
|
jtagOutputs->tms << P_ROC_JTAG_TRANSITION_TCK_SHIFT;
|
||||||
return kPRSuccess;
|
return kPRSuccess;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -326,10 +326,10 @@ int32_t CreateJTAGLatchOutputsBurst ( uint32_t * burst, PRJTAGOutputs *jtagOutpu
|
|||||||
burst[1] = 1 << P_ROC_JTAG_CMD_START_SHIFT |
|
burst[1] = 1 << P_ROC_JTAG_CMD_START_SHIFT |
|
||||||
1 << P_ROC_JTAG_CMD_OE_SHIFT |
|
1 << P_ROC_JTAG_CMD_OE_SHIFT |
|
||||||
P_ROC_JTAG_CMD_TRANSITION << P_ROC_JTAG_CMD_CMD_SHIFT |
|
P_ROC_JTAG_CMD_TRANSITION << P_ROC_JTAG_CMD_CMD_SHIFT |
|
||||||
jtagOutputs->tdoMask << P_ROC_JTAG_TRANSITION_TDO_MASK_SHIFT |
|
jtagOutputs->tdoMask << P_ROC_JTAG_TRANSITION_TDO_MASK_SHIFT |
|
||||||
jtagOutputs->tmsMask << P_ROC_JTAG_TRANSITION_TMS_MASK_SHIFT |
|
jtagOutputs->tmsMask << P_ROC_JTAG_TRANSITION_TMS_MASK_SHIFT |
|
||||||
jtagOutputs->tdo << P_ROC_JTAG_TRANSITION_TCK_SHIFT |
|
jtagOutputs->tdo << P_ROC_JTAG_TRANSITION_TCK_SHIFT |
|
||||||
jtagOutputs->tms << P_ROC_JTAG_TRANSITION_TMS_SHIFT;
|
jtagOutputs->tms << P_ROC_JTAG_TRANSITION_TMS_SHIFT;
|
||||||
return kPRSuccess;
|
return kPRSuccess;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -340,7 +340,7 @@ int32_t CreateJTAGShiftTDODataBurst ( uint32_t * burst, uint16_t numBits, bool_t
|
|||||||
1 << P_ROC_JTAG_CMD_OE_SHIFT |
|
1 << P_ROC_JTAG_CMD_OE_SHIFT |
|
||||||
P_ROC_JTAG_CMD_SHIFT << P_ROC_JTAG_CMD_CMD_SHIFT |
|
P_ROC_JTAG_CMD_SHIFT << P_ROC_JTAG_CMD_CMD_SHIFT |
|
||||||
dataBlockComplete << P_ROC_JTAG_SHIFT_EXIT_SHIFT |
|
dataBlockComplete << P_ROC_JTAG_SHIFT_EXIT_SHIFT |
|
||||||
numBits << P_ROC_JTAG_SHIFT_NUM_BITS_SHIFT;
|
numBits << P_ROC_JTAG_SHIFT_NUM_BITS_SHIFT;
|
||||||
return kPRSuccess;
|
return kPRSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -385,18 +385,19 @@ PRResult PRHardwareOpen()
|
|||||||
ftHandles[i] = NULL;
|
ftHandles[i] = NULL;
|
||||||
}
|
}
|
||||||
pcBufLD[MAX_DEVICES] = NULL;
|
pcBufLD[MAX_DEVICES] = NULL;
|
||||||
|
|
||||||
ftStatus = FT_ListDevices(pcBufLD, &iNumDevs, FT_LIST_ALL | FT_OPEN_BY_SERIAL_NUMBER);
|
ftStatus = FT_ListDevices(pcBufLD, &iNumDevs, FT_LIST_ALL | FT_OPEN_BY_SERIAL_NUMBER);
|
||||||
|
|
||||||
if(ftStatus != FT_OK) {
|
if(ftStatus != FT_OK) {
|
||||||
|
PRSetLastErrorText("FT_ListDevices(%d)\n", ftStatus);
|
||||||
DEBUG(PRLog(kPRLogInfo,"Error: FT_ListDevices(%d)\n", ftStatus));
|
DEBUG(PRLog(kPRLogInfo,"Error: FT_ListDevices(%d)\n", ftStatus));
|
||||||
return kPRFailure;
|
return kPRFailure;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(j = 0; j < BUF_SIZE; j++) {
|
for(j = 0; j < BUF_SIZE; j++) {
|
||||||
cBufWrite[j] = j;
|
cBufWrite[j] = j;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i = 0; ( (i <MAX_DEVICES) && (i < iNumDevs) ); i++) {
|
for(i = 0; ( (i <MAX_DEVICES) && (i < iNumDevs) ); i++) {
|
||||||
DEBUG(PRLog(kPRLogInfo,"Device %d Serial Number - %s\n", i, cBufLD[i]));
|
DEBUG(PRLog(kPRLogInfo,"Device %d Serial Number - %s\n", i, cBufLD[i]));
|
||||||
}
|
}
|
||||||
@@ -404,34 +405,39 @@ PRResult PRHardwareOpen()
|
|||||||
for(i = 0; ( (i <MAX_DEVICES) && (i < iNumDevs) ) ; i++) {
|
for(i = 0; ( (i <MAX_DEVICES) && (i < iNumDevs) ) ; i++) {
|
||||||
/* Setup */
|
/* Setup */
|
||||||
if((ftStatus = FT_OpenEx(cBufLD[i], FT_OPEN_BY_SERIAL_NUMBER, &ftHandles[i])) != FT_OK){
|
if((ftStatus = FT_OpenEx(cBufLD[i], FT_OPEN_BY_SERIAL_NUMBER, &ftHandles[i])) != FT_OK){
|
||||||
/*
|
/*
|
||||||
This can fail if the ftdi_sio driver is loaded
|
This can fail if the ftdi_sio driver is loaded
|
||||||
use lsmod to check this and rmmod ftdi_sio to remove
|
use lsmod to check this and rmmod ftdi_sio to remove
|
||||||
also rmmod usbserial
|
also rmmod usbserial
|
||||||
*/
|
*/
|
||||||
DEBUG(PRLog(kPRLogInfo,"Error FT_OpenEx(%d), device\n", ftStatus, i));
|
DEBUG(PRLog(kPRLogInfo,"Error FT_OpenEx(%d), device\n", ftStatus, i));
|
||||||
|
PRSetLastErrorText("Error FT_OpenEx(%d), device\n", ftStatus, i);
|
||||||
return kPRFailure;
|
return kPRFailure;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG(PRLog(kPRLogInfo,"Opened device %s\n", cBufLD[i]));
|
DEBUG(PRLog(kPRLogInfo,"Opened device %s\n", cBufLD[i]));
|
||||||
ftHandle = ftHandles[i];
|
ftHandle = ftHandles[i];
|
||||||
|
|
||||||
if((ftStatus = FT_SetBaudRate(ftHandles[i], 1228800)) != FT_OK) {
|
if((ftStatus = FT_SetBaudRate(ftHandles[i], 1228800)) != FT_OK) {
|
||||||
DEBUG(PRLog(kPRLogInfo,"Error FT_SetBaudRate(%d), cBufLD[i] = %s\n", ftStatus, cBufLD[i]));
|
DEBUG(PRLog(kPRLogInfo,"Error FT_SetBaudRate(%d), cBufLD[i] = %s\n", ftStatus, cBufLD[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
iDevicesOpen++;
|
iDevicesOpen++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (iDevicesOpen > 0)
|
if (iDevicesOpen > 0)
|
||||||
{
|
{
|
||||||
FT_ResetDevice(ftHandle);
|
FT_ResetDevice(ftHandle);
|
||||||
DEBUG(PRLog(kPRLogInfo,"FTDI Device Opened\n"));
|
DEBUG(PRLog(kPRLogInfo,"FTDI Device Opened\n"));
|
||||||
return kPRSuccess;
|
return kPRSuccess;
|
||||||
}
|
}
|
||||||
else return kPRFailure;
|
else
|
||||||
|
{
|
||||||
|
PRSetLastErrorText("No FTDI device found.");
|
||||||
|
return kPRFailure;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PRHardwareClose()
|
void PRHardwareClose()
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@@ -447,14 +453,14 @@ void PRHardwareClose()
|
|||||||
|
|
||||||
int PRHardwareRead(uint8_t *buffer, int maxBytes)
|
int PRHardwareRead(uint8_t *buffer, int maxBytes)
|
||||||
{
|
{
|
||||||
FT_STATUS ftStatus;
|
FT_STATUS ftStatus;
|
||||||
DWORD bytesToRead;
|
DWORD bytesToRead;
|
||||||
DWORD bytesRead;
|
DWORD bytesRead;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
ftStatus = FT_GetQueueStatus(ftHandle,&bytesToRead);
|
ftStatus = FT_GetQueueStatus(ftHandle,&bytesToRead);
|
||||||
if (ftStatus != FT_OK) return 0;
|
if (ftStatus != FT_OK) return 0;
|
||||||
|
|
||||||
if ((DWORD)maxBytes < bytesToRead) bytesToRead = maxBytes;
|
if ((DWORD)maxBytes < bytesToRead) bytesToRead = maxBytes;
|
||||||
ftStatus = FT_Read(ftHandle, buffer, bytesToRead, &bytesRead);
|
ftStatus = FT_Read(ftHandle, buffer, bytesToRead, &bytesRead);
|
||||||
if (ftStatus == FT_OK) {
|
if (ftStatus == FT_OK) {
|
||||||
@@ -469,13 +475,13 @@ int PRHardwareRead(uint8_t *buffer, int maxBytes)
|
|||||||
|
|
||||||
int PRHardwareWrite(uint8_t *buffer, int bytes)
|
int PRHardwareWrite(uint8_t *buffer, int bytes)
|
||||||
{
|
{
|
||||||
FT_STATUS ftStatus=0;
|
FT_STATUS ftStatus=0;
|
||||||
DWORD bytesWritten=0;
|
DWORD bytesWritten=0;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
DEBUG(PRLog(kPRLogVerbose,"Writing %d bytes:\n",bytes));
|
DEBUG(PRLog(kPRLogVerbose,"Writing %d bytes:\n",bytes));
|
||||||
ftStatus = FT_Write(ftHandle, buffer, (DWORD)bytes, &bytesWritten);
|
ftStatus = FT_Write(ftHandle, buffer, (DWORD)bytes, &bytesWritten);
|
||||||
if (ftStatus == FT_OK)
|
if (ftStatus == FT_OK)
|
||||||
{
|
{
|
||||||
DEBUG(PRLog(kPRLogVerbose,"Wrote %d bytes:\n",bytesWritten));
|
DEBUG(PRLog(kPRLogVerbose,"Wrote %d bytes:\n",bytesWritten));
|
||||||
if (bytesWritten != DWORD(bytes)) DEBUG(PRLog(kPRLogVerbose,"Wrote %d bytes, should have written %d bytes",bytesWritten,bytes));
|
if (bytesWritten != DWORD(bytes)) DEBUG(PRLog(kPRLogVerbose,"Wrote %d bytes, should have written %d bytes",bytesWritten,bytes));
|
||||||
@@ -503,23 +509,23 @@ PRResult PRHardwareOpen()
|
|||||||
PRResult rc;
|
PRResult rc;
|
||||||
struct ftdi_device_list *devlist, *curdev;
|
struct ftdi_device_list *devlist, *curdev;
|
||||||
char manufacturer[128], description[128];
|
char manufacturer[128], description[128];
|
||||||
|
|
||||||
ftdiInitialized = false;
|
ftdiInitialized = false;
|
||||||
|
|
||||||
// Open the FTDI device
|
// Open the FTDI device
|
||||||
if (ftdi_init(&ftdic) != 0)
|
if (ftdi_init(&ftdic) != 0)
|
||||||
{
|
{
|
||||||
PRSetLastErrorText("Failed to initialize FTDI.");
|
PRSetLastErrorText("Failed to initialize FTDI.");
|
||||||
return kPRFailure;
|
return kPRFailure;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find all FTDI devices
|
// Find all FTDI devices
|
||||||
// This is very basic and really only expects to see 1 device. It needs to be
|
// This is very basic and really only expects to see 1 device. It needs to be
|
||||||
// smarter. At the very least, it should check some register on the P-ROC versus
|
// smarter. At the very least, it should check some register on the P-ROC versus
|
||||||
// an input parameter to ensure the software is set up for the same architecture as
|
// an input parameter to ensure the software is set up for the same architecture as
|
||||||
// the P-ROC (Stern vs WPC). Otherwise, it's possible to drive the coils the wrong
|
// the P-ROC (Stern vs WPC). Otherwise, it's possible to drive the coils the wrong
|
||||||
// polarity and blow fuses or fry transistors and all other sorts of badness.
|
// polarity and blow fuses or fry transistors and all other sorts of badness.
|
||||||
|
|
||||||
// We first enumerate all of the devices:
|
// We first enumerate all of the devices:
|
||||||
int numDevices = ftdi_usb_find_all(&ftdic, &devlist, FTDI_VENDOR_ID, FTDI_FT245RL_PRODUCT_ID);
|
int numDevices = ftdi_usb_find_all(&ftdic, &devlist, FTDI_VENDOR_ID, FTDI_FT245RL_PRODUCT_ID);
|
||||||
if (numDevices <=0) numDevices = ftdi_usb_find_all(&ftdic, &devlist, FTDI_VENDOR_ID, FTDI_FT240X_PRODUCT_ID);
|
if (numDevices <=0) numDevices = ftdi_usb_find_all(&ftdic, &devlist, FTDI_VENDOR_ID, FTDI_FT240X_PRODUCT_ID);
|
||||||
@@ -530,7 +536,7 @@ PRResult PRHardwareOpen()
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DEBUG(PRLog(kPRLogInfo, "Number of FTDI devices found: %d\n", numDevices));
|
DEBUG(PRLog(kPRLogInfo, "Number of FTDI devices found: %d\n", numDevices));
|
||||||
|
|
||||||
for (curdev = devlist; curdev != NULL; i++) {
|
for (curdev = devlist; curdev != NULL; i++) {
|
||||||
DEBUG(PRLog(kPRLogInfo, "Checking device %d\n", i));
|
DEBUG(PRLog(kPRLogInfo, "Checking device %d\n", i));
|
||||||
if ((rc = (int32_t)ftdi_usb_get_strings(&ftdic, curdev->dev, manufacturer, 128, description, 128, NULL, 0)) < 0) {
|
if ((rc = (int32_t)ftdi_usb_get_strings(&ftdic, curdev->dev, manufacturer, 128, description, 128, NULL, 0)) < 0) {
|
||||||
@@ -543,12 +549,12 @@ PRResult PRHardwareOpen()
|
|||||||
}
|
}
|
||||||
curdev = curdev->next;
|
curdev = curdev->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't need the device list anymore
|
// Don't need the device list anymore
|
||||||
ftdi_list_free (&devlist);
|
ftdi_list_free (&devlist);
|
||||||
|
|
||||||
if (((rc = (int32_t)ftdi_usb_open(&ftdic, FTDI_VENDOR_ID, FTDI_FT245RL_PRODUCT_ID)) < 0) && ((rc = (int32_t)ftdi_usb_open(&ftdic, FTDI_VENDOR_ID, FTDI_FT240X_PRODUCT_ID)) < 0))
|
if (((rc = (int32_t)ftdi_usb_open(&ftdic, FTDI_VENDOR_ID, FTDI_FT245RL_PRODUCT_ID)) < 0) && ((rc = (int32_t)ftdi_usb_open(&ftdic, FTDI_VENDOR_ID, FTDI_FT240X_PRODUCT_ID)) < 0))
|
||||||
{
|
{
|
||||||
PRSetLastErrorText("Unable to open ftdi device: %d: %s", rc, ftdi_get_error_string(&ftdic));
|
PRSetLastErrorText("Unable to open ftdi device: %d: %s", rc, ftdi_get_error_string(&ftdic));
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ void PRLog(PRLogLevel level, const char *format, ...)
|
|||||||
{
|
{
|
||||||
if (level < logLevel)
|
if (level < logLevel)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
char line[MAX_TEXT];
|
char line[MAX_TEXT];
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
@@ -119,12 +119,18 @@ PRResult PRFlushWriteData(PRHandle handle)
|
|||||||
return handleAsDevice->FlushWriteData();
|
return handleAsDevice->FlushWriteData();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Write data out to the P-ROC immediately (does not require a call to PRFlushWriteData */
|
/** Write data out to the P-ROC immediately (does not require a call to PRFlushWriteData). */
|
||||||
PRResult PRWriteData(PRHandle handle, uint32_t moduleSelect, uint32_t startingAddr, int32_t numWriteWords, uint32_t * writeBuffer)
|
PRResult PRWriteData(PRHandle handle, uint32_t moduleSelect, uint32_t startingAddr, int32_t numWriteWords, uint32_t * writeBuffer)
|
||||||
{
|
{
|
||||||
return handleAsDevice->WriteDataRaw(moduleSelect, startingAddr, numWriteWords, writeBuffer);
|
return handleAsDevice->WriteDataRaw(moduleSelect, startingAddr, numWriteWords, writeBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Write data buffered to P-ROC (does require a call to PRFlushWriteData). */
|
||||||
|
PRResult PRWriteDataUnbuffered(PRHandle handle, uint32_t moduleSelect, uint32_t startingAddr, int32_t numWriteWords, uint32_t * writeBuffer)
|
||||||
|
{
|
||||||
|
return handleAsDevice->WriteDataRawUnbuffered(moduleSelect, startingAddr, numWriteWords, writeBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
/** Read data from the P-ROC. */
|
/** Read data from the P-ROC. */
|
||||||
PRResult PRReadData(PRHandle handle, uint32_t moduleSelect, uint32_t startingAddr, int32_t numReadWords, uint32_t * readBuffer)
|
PRResult PRReadData(PRHandle handle, uint32_t moduleSelect, uint32_t startingAddr, int32_t numReadWords, uint32_t * readBuffer)
|
||||||
{
|
{
|
||||||
@@ -358,8 +364,8 @@ uint16_t PRDecode(PRMachineType machineType, const char *str)
|
|||||||
else if ( strlen(str) == 4)
|
else if ( strlen(str) == 4)
|
||||||
x = (str[2]-'0') * 10 + (str[3]-'0');
|
x = (str[2]-'0') * 10 + (str[3]-'0');
|
||||||
else return atoi(str);
|
else return atoi(str);
|
||||||
|
|
||||||
if ((machineType == kPRMachineWPC) ||
|
if ((machineType == kPRMachineWPC) ||
|
||||||
(machineType == kPRMachineWPC95) ||
|
(machineType == kPRMachineWPC95) ||
|
||||||
(machineType == kPRMachineWPCAlphanumeric))
|
(machineType == kPRMachineWPCAlphanumeric))
|
||||||
{
|
{
|
||||||
@@ -381,7 +387,7 @@ uint16_t PRDecode(PRMachineType machineType, const char *str)
|
|||||||
case 'm':
|
case 'm':
|
||||||
return 32;
|
return 32;
|
||||||
default:
|
default:
|
||||||
return 33;
|
return 33;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
switch (str[3])
|
switch (str[3])
|
||||||
@@ -390,7 +396,7 @@ uint16_t PRDecode(PRMachineType machineType, const char *str)
|
|||||||
case 'm':
|
case 'm':
|
||||||
return 34;
|
return 34;
|
||||||
default:
|
default:
|
||||||
return 35;
|
return 35;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@@ -404,7 +410,7 @@ uint16_t PRDecode(PRMachineType machineType, const char *str)
|
|||||||
case 'm':
|
case 'm':
|
||||||
return 36;
|
return 36;
|
||||||
default:
|
default:
|
||||||
return 37;
|
return 37;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
switch (str[3])
|
switch (str[3])
|
||||||
@@ -413,7 +419,7 @@ uint16_t PRDecode(PRMachineType machineType, const char *str)
|
|||||||
case 'm':
|
case 'm':
|
||||||
return 38;
|
return 38;
|
||||||
default:
|
default:
|
||||||
return 39;
|
return 39;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -432,7 +438,7 @@ uint16_t PRDecode(PRMachineType machineType, const char *str)
|
|||||||
if (machineType == kPRMachineWPC95)
|
if (machineType == kPRMachineWPC95)
|
||||||
//return x + 7;
|
//return x + 7;
|
||||||
return x + 31;
|
return x + 31;
|
||||||
else
|
else
|
||||||
return x + 107; // WPC 37-44 use 8-driver board (mapped to drivers 144-151)
|
return x + 107; // WPC 37-44 use 8-driver board (mapped to drivers 144-151)
|
||||||
}
|
}
|
||||||
else return x + 108;
|
else return x + 108;
|
||||||
@@ -473,7 +479,7 @@ uint16_t PRDecode(PRMachineType machineType, const char *str)
|
|||||||
{
|
{
|
||||||
case 'D':
|
case 'D':
|
||||||
case 'd':
|
case 'd':
|
||||||
if (strlen(str) == 3)
|
if (strlen(str) == 3)
|
||||||
return (str[2]-'0') + 7;
|
return (str[2]-'0') + 7;
|
||||||
else return x + 7;
|
else return x + 7;
|
||||||
default:
|
default:
|
||||||
@@ -502,7 +508,7 @@ uint16_t PRDecode(PRMachineType machineType, const char *str)
|
|||||||
{
|
{
|
||||||
case 'D':
|
case 'D':
|
||||||
case 'd':
|
case 'd':
|
||||||
if (strlen(str) == 3)
|
if (strlen(str) == 3)
|
||||||
return (str[2]-'0') + 7;
|
return (str[2]-'0') + 7;
|
||||||
else return x + 7;
|
else return x + 7;
|
||||||
default:
|
default:
|
||||||
|
|||||||
Reference in New Issue
Block a user