1
0
mirror of https://github.com/preble/libpinproc synced 2026-02-22 18:15:25 +01:00

Merge branch 'dev' of github.com:preble/libpinproc into dev

Conflicts:
	utils/pinprocfw/pinprocfw.cpp
This commit is contained in:
preble
2011-02-02 21:56:42 -05:00
11 changed files with 402 additions and 251 deletions

View File

@@ -1,11 +1,16 @@
###
### CMake policy settings
### CMake settings
###
## Due to Mac OSX we need to keep compatibility with CMake 2.6
# see http://www.cmake.org/Wiki/CMake_Policies
cmake_minimum_required(VERSION 2.6)
# see http://www.cmake.org/cmake/help/cmake-2-8-docs.html#policy:CMP0012
if(POLICY CMP0012)
cmake_policy(SET CMP0012 OLD)
endif()
# see http://www.cmake.org/cmake/help/cmake-2-8-docs.html#policy:CMP0015
if(POLICY CMP0015)
cmake_policy(SET CMP0015 NEW)
cmake_policy(SET CMP0015 OLD)
endif()
@@ -22,55 +27,141 @@ set(PINPROC_VERSION "${PINPROC_VERSION_MAJOR}.${PINPROC_VERSION_MINOR}")
###
### Project options
###
# General stuff
## Project stuff
option(PINPROC_BUILD_TOOLS "Enable testing and firmware tools" ON)
# Compilation options
## Build options
# --> General
# see http://www.cmake.org/cmake/help/cmake2.6docs.html#variable:BUILD_SHARED_LIBS
# http://www.cmake.org/cmake/help/cmake2.6docs.html#command:add_library
option(BUILD_SHARED_LIBS "Build Shared Libraries" OFF)
# see http://msdn.microsoft.com/en-us/library/aa278396(v=vs.60).aspx
# http://msdn.microsoft.com/en-us/library/2kzt1wy3%28v=VS.71%29.aspx
# --> Apple
option(APPLE_UNIVERSAL_BIN "Apple: Build universal binary" OFF)
# --> Microsoft Visual C++
# see http://msdn.microsoft.com/en-us/library/aa278396(v=VS.60).aspx
# http://msdn.microsoft.com/en-us/library/2kzt1wy3(v=VS.71).aspx
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)
###
### Source
### Sources, headers, directories and libs
###
# !!! file(GLOB) didn't work on Ubuntu 10.04 with cmake 2.8 !!!
#file(GLOB sources src/[a-z]*.cpp)
#file(GLOB public_headers include/[a-z]*.h)
#file(GLOB private_headers src/[a-z]*.h)
set(sources "src/pinproc.cpp;src/PRDevice.cpp;src/PRHardware.cpp")
set(public_headers "include/pinproc.h")
set(private_headers "src/PRCommon.h;src/PRDevice.h;src/PRHardware.h")
message(STATUS "sources is ${sources}")
message(STATUS "public_headers is ${public_headers}")
message(STATUS "private_headers is ${private_headers}")
file(GLOB sources "src/[a-zA-Z]*.cpp")
file(GLOB public_headers "include/[a-zA-Z]*.h")
file(GLOB private_headers "src/[a-zA-Z]*.h")
include_directories(${PINPROC_SOURCE_DIR}/include $ENV{EXTRA_INC} /usr/local/include)
link_directories($ENV{EXTRA_LINK} /usr/local/lib)
if(WIN32)
if(BUILD_SHARED_LIBS)
set(defs
src/pinproc.def
)
endif()
endif()
if(VERBOSE)
message(STATUS "sources: ${sources}")
message(STATUS "public_headers: ${public_headers}")
message(STATUS "private_headers: ${private_headers}")
message(STATUS "defs: ${defs}")
endif()
# use -DEXTRA_INC="<path>;<path>" and -DEXTRA_LINK="<path>;<path>"
include_directories(${PINPROC_SOURCE_DIR}/include ${EXTRA_INC} /usr/local/include)
link_directories(${EXTRA_LINK} /usr/local/lib)
set(YAML_CPP_LIB "yaml-cpp")
set(YAML_CPP_LIB_DBG "${YAML_CPP_LIB}")
###
### General compilation settings
###
if(BUILD_SHARED_LIBS)
set(LABEL_SUFFIX "shared")
else()
set(LABEL_SUFFIX "static")
endif()
if(APPLE)
# set(CMAKE_OSX_ARCHITECTURES ppc;i386) # Uncomment for universal binary
if(APPLE_UNIVERSAL_BIN)
set(CMAKE_OSX_ARCHITECTURES ppc;i386)
endif()
endif()
if(WIN32)
set(libraries ftd2xx)
set(lib_ftdi_usb ftd2xx)
if(BUILD_SHARED_LIBS)
add_definitions(-DPINPROC_DLL) # use or build Windows DLL
add_definitions(-D${PROJECT_NAME}_DLL) # use or build Windows DLL
endif()
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "C:/")
endif()
else()
set(libraries usb ftdi)
set(lib_ftdi_usb usb ftdi)
endif()
set(YAML_CPP_LIB "yaml-cpp")
set(YAML_CPP_LIB_DBG "${YAML_CPP_LIB}")
# GCC specialities
if(CMAKE_COMPILER_IS_GNUCC)
if(WIN32)
set(CMAKE_SHARED_LIBRARY_PREFIX "") # DLLs do not have a "lib" prefix
set(CMAKE_IMPORT_LIBRARY_PREFIX "") # same for DLL import libs
set(CMAKE_LINK_DEF_FILE_FLAG "") # CMake workaround (2.8.3)
endif()
endif()
# Microsoft VisualC++ specialities
if(MSVC)
### General stuff
# a) Change MSVC runtime library settings (/MD[d], /MT[d], /ML[d] (single-threaded until VS 2003))
# plus set lib suffix for later use and project label accordingly
# see http://msdn.microsoft.com/en-us/library/aa278396(v=VS.60).aspx
# http://msdn.microsoft.com/en-us/library/2kzt1wy3(v=VS.71).aspx
set(LIB_RT_SUFFIX "md") # CMake defaults to /MD for MSVC
set(LIB_RT_OPTION "/MD")
#
if(NOT MSVC_SHARED_RT) # User wants to have static runtime libraries (/MT, /ML)
if(MSVC_STHREADED_RT) # User wants to have old single-threaded static runtime libraries
set(LIB_RT_SUFFIX "ml")
set(LIB_RT_OPTION "/ML")
if(NOT ${MSVC_VERSION} LESS 1400)
message(FATAL_ERROR "Single-threaded static runtime libraries (/ML) only available until VS .NET 2003 (7.1).")
endif()
else()
set(LIB_RT_SUFFIX "mt")
set(LIB_RT_OPTION "/MT")
endif()
# correct linker options
foreach(flag_var CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
foreach(config_name "" DEBUG RELEASE MINSIZEREL RELWITHDEBINFO)
set(var_name "${flag_var}")
if(NOT "${config_name}" STREQUAL "")
set(var_name "${var_name}_${config_name}")
endif()
string(REPLACE "/MD" "${LIB_RT_OPTION}" ${var_name} "${${var_name}}")
endforeach()
endforeach()
endif()
#
set(LABEL_SUFFIX "${LABEL_SUFFIX} ${LIB_RT_OPTION}")
# b) Change prefix for static libraries
set(CMAKE_STATIC_LIBRARY_PREFIX "lib") # to distinguish static libraries from DLL import libs
# c) Correct suffixes for static libraries
if(NOT BUILD_SHARED_LIBS)
### General stuff
set(LIB_TARGET_SUFFIX "${LIB_SUFFIX}${LIB_RT_SUFFIX}")
### Project stuff
# correct external library names
set(YAML_CPP_LIB "${CMAKE_STATIC_LIBRARY_PREFIX}${YAML_CPP_LIB}${LIB_RT_SUFFIX}")
set(YAML_CPP_LIB_DBG "${YAML_CPP_LIB}d")
endif()
endif()
###
@@ -83,12 +174,12 @@ else()
endif()
set(INCLUDE_INSTALL_DIR include/p-roc)
set(LIB_INSTALL_DIR ${_library_dir}${LIB_SUFFIX})
set(LIB_INSTALL_DIR "${_library_dir}${LIB_SUFFIX}")
set(_INSTALL_DESTINATIONS
RUNTIME DESTINATION bin
LIBRARY DESTINATION ${LIB_INSTALL_DIR}
ARCHIVE DESTINATION lib${LIB_SUFFIX}
ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
)
@@ -99,50 +190,29 @@ add_library(pinproc
${sources}
${public_headers}
${private_headers}
${defs}
)
set_target_properties(pinproc PROPERTIES
VERSION "${PINPROC_VERSION}"
SOVERSION "${PINPROC_VERSION_MAJOR}.${PINPROC_VERSION_MINOR}"
PROJECT_LABEL "pinproc ${LABEL_SUFFIX}"
)
# Correct MSVC for static libraries (/MD[d], /MT[d], /ML[d] (single-threaded until VS 2003))
# see http://msdn.microsoft.com/en-us/library/aa278396(v=vs.60).aspx
# http://msdn.microsoft.com/en-us/library/2kzt1wy3%28v=VS.71%29.aspx
if((MSVC) AND (NOT BUILD_SHARED_LIBS))
set(TMP_SUFFIX "md") # CMake defaults to /MD for MSVC
target_link_libraries(pinproc
${lib_ftdi_usb}
)
if (NOT MSVC_SHARED_RT) # User wants to have static runtime libraries (/MT, /ML)
if (MSVC_STHREADED_RT) # User wants to have old single-threade runtime libraries
set(TMP_SUFFIX "ml")
set(TMP_OPTION "/ML")
if(NOT MSVC_VERSION LESS 1400)
message(FATAL_ERROR "Single-threaded runtime libraries (/ML) only availbe until VS .NET 2003 (7.1).")
endif()
else()
set(TMP_SUFFIX "mt")
set(TMP_OPTION "/MT")
endif()
# correct linker options
string(REPLACE "/MD" "${TMP_OPTION}" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
string(REPLACE "/MD" "${TMP_OPTION}" CMAKE_CXX_FLAGS_MINSIZEREL ${CMAKE_CXX_FLAGS_MINSIZEREL})
string(REPLACE "/MD" "${TMP_OPTION}" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
string(REPLACE "/MD" "${TMP_OPTION}" CMAKE_CXX_FLAGS_RELWITHDEBINFO ${CMAKE_CXX_FLAGS_RELWITHDEBINFO})
string(REPLACE "/MD" "${TMP_OPTION}" CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
string(REPLACE "/MD" "${TMP_OPTION}" CMAKE_C_FLAGS_MINSIZEREL ${CMAKE_C_FLAGS_MINSIZEREL})
string(REPLACE "/MD" "${TMP_OPTION}" CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE})
string(REPLACE "/MD" "${TMP_OPTION}" CMAKE_C_FLAGS_RELWITHDEBINFO ${CMAKE_C_FLAGS_RELWITHDEBINFO})
if(MSVC)
if(NOT BUILD_SHARED_LIBS)
# correct library names
set_target_properties(pinproc PROPERTIES
DEBUG_POSTFIX "${LIB_TARGET_SUFFIX}d"
RELEASE_POSTFIX "${LIB_TARGET_SUFFIX}"
MINSIZEREL_POSTFIX "${LIB_TARGET_SUFFIX}"
RELWITHDEBINFO_POSTFIX "${LIB_TARGET_SUFFIX}"
)
endif()
# correct library names
set_target_properties(pinproc PROPERTIES PREFIX "lib")
set_target_properties(pinproc PROPERTIES DEBUG_POSTFIX "${TMP_SUFFIX}d")
set_target_properties(pinproc PROPERTIES RELEASE_POSTFIX "${TMP_SUFFIX}")
set_target_properties(pinproc PROPERTIES MINSIZEREL_POSTFIX "${TMP_SUFFIX}")
set_target_properties(pinproc PROPERTIES RELWITHDEBINFO_POSTFIX "${TMP_SUFFIX}")
# correct external library names
set(YAML_CPP_LIB "lib${YAML_CPP_LIB}${TMP_SUFFIX}")
set(YAML_CPP_LIB_DBG "${YAML_CPP_LIB}d")
endif()
install(TARGETS pinproc ${_INSTALL_DESTINATIONS})
@@ -161,9 +231,10 @@ endif()
###
### Extras
###
#TODO: use add_subdirectory() and separate CMakeLists.txt
if(PINPROC_BUILD_TOOLS)
# Create a target for the test tool (see yaml-cpp)
# Create a target for the test tool
#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
add_executable(pinproctest
examples/pinproctest/pinproctest.cpp
examples/pinproctest/drivers.cpp
@@ -173,19 +244,18 @@ add_executable(pinproctest
)
target_link_libraries(pinproctest
pinproc
${libraries}
optimized ${YAML_CPP_LIB}
debug ${YAML_CPP_LIB_DBG}
)
# Create a target for the firmware tool (see yaml-cpp)
#TODO: use add_subdirectory() and separate CMakeLists.txt
# Create a target for the firmware tool
#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
add_executable(pinprocfw
utils/pinprocfw/pinprocfw.cpp
utils/pinprocfw/lenval.cpp
)
target_link_libraries(pinprocfw
pinproc
${libraries}
)
endif()

View File

@@ -27,6 +27,12 @@
* pinproctest.cpp
* libpinproc
*/
#ifndef PINPROCTEST_PINPROCTEST_H
#define PINPROCTEST_PINPROCTEST_H
#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4
#pragma once
#endif
#include <string.h>
#include <stdio.h>
#include <signal.h>
@@ -75,3 +81,5 @@ void ConfigureDMD(PRHandle proc);
void UpdateDots(unsigned char * dots, unsigned int dotOffset);
void UpdateAlphaDisplay(PRHandle, int);
#endif /* PINPROCTEST_PINPROCTEST_H */

View File

@@ -27,9 +27,11 @@
* @brief libpinproc, P-ROC Layer 1 API (Preliminary)
*
*/
#ifndef _PINPROC_H_
#define _PINPROC_H_
#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.
@@ -40,32 +42,35 @@
#include <stdint.h>
/** @cond */
#if defined(__WIN32__) || defined(_WIN32)
#undef PR_EXPORT
#if defined(PR_BUILDING_PR)
#define PR_EXPORT __declspec(dllexport) extern
// 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
// TODO: Decide what to do here:
//#define PR_EXPORT __declspec(dllimport) extern
#define PR_EXPORT
#define PINPROC_API __declspec(dllimport)
#endif
#endif
#if !defined(PR_EXPORT)
#define PR_EXPORT extern
// fallback for non-DLL usage and builds
#ifndef PINPROC_API
#define PINPROC_API
#endif
#if !defined(PR_EXTERN_C_BEGIN)
#if defined(__cplusplus)
#define PR_EXTERN_C_BEGIN extern "C" {
#define PR_EXTERN_C_END }
#else
#define PR_EXTERN_C_BEGIN
#define PR_EXTERN_C_END
#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
PR_EXTERN_C_BEGIN
PINPROC_EXTERN_C_BEGIN
/** @endcond */
// Types
@@ -87,13 +92,13 @@ typedef enum PRLogLevel {
} PRLogLevel;
typedef void (*PRLogCallback)(PRLogLevel level, const char *text); /**< Function pointer type for a custom logging callback. See: PRLogSetCallback(). */
PR_EXPORT void PRLogSetCallback(PRLogCallback callback); /**< Replaces the default logging handler with the given callback function. */
PINPROC_API void PRLogSetCallback(PRLogCallback callback); /**< Replaces the default logging handler with the given callback function. */
PR_EXPORT void PRLogSetLevel(PRLogLevel level);
PINPROC_API void PRLogSetLevel(PRLogLevel level);
PR_EXPORT const char *PRGetLastErrorText();
PINPROC_API const char *PRGetLastErrorText();
/**
/**
* @defgroup device Device Creation & Deletion
* @{
*/
@@ -110,30 +115,30 @@ typedef enum PRMachineType {
// PRHandle Creation and Deletion
PR_EXPORT 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. */
PR_EXPORT void PRDelete(PRHandle handle); /**< Destroys an existing P-ROC device handle. */
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.
* @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.
*/
PR_EXPORT PRResult PRReset(PRHandle handle, uint32_t resetFlags);
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. */
PR_EXPORT PRResult PRFlushWriteData(PRHandle handle);
PINPROC_API PRResult PRFlushWriteData(PRHandle handle);
/** Write data out to the P-ROC immediately (does not require a call to PRFlushWriteData). */
PR_EXPORT 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);
/** Read data from the P-ROC. */
PR_EXPORT 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);
// Manager
/** @defgroup Manager
@@ -146,7 +151,7 @@ typedef struct PRManagerConfig {
} PRManagerConfig;
/** Update Manager configuration */
PR_EXPORT PRResult PRManagerUpdateConfig(PRHandle handle, PRManagerConfig *managerConfig);
PINPROC_API PRResult PRManagerUpdateConfig(PRHandle handle, PRManagerConfig *managerConfig);
// Drivers
/** @defgroup drivers Driver Manipulation
@@ -156,9 +161,9 @@ PR_EXPORT PRResult PRManagerUpdateConfig(PRHandle handle, PRManagerConfig *manag
#define kPRDriverGroupsMax (26) /**< Number of available driver groups. */
#define kPRDriverCount (256) /**< Total number of drivers */
#define kPRDriverAuxCmdOutput (2)
#define kPRDriverAuxCmdDelay (1)
#define kPRDriverAuxCmdJump (0)
#define kPRDriverAuxCmdOutput (2)
#define kPRDriverAuxCmdDelay (1)
#define kPRDriverAuxCmdJump (0)
typedef struct PRDriverGlobalConfig {
bool_t enableOutputs; // Formerly enable_direct_outputs
@@ -212,138 +217,138 @@ typedef struct PRDriverAuxCommand {
} PRDriverAuxCommand;
/** Update registers for the global driver configuration. */
PR_EXPORT PRResult PRDriverUpdateGlobalConfig(PRHandle handle, PRDriverGlobalConfig *driverGlobalConfig);
PINPROC_API PRResult PRDriverUpdateGlobalConfig(PRHandle handle, PRDriverGlobalConfig *driverGlobalConfig);
PR_EXPORT PRResult PRDriverGetGroupConfig(PRHandle handle, uint8_t groupNum, PRDriverGroupConfig *driverGroupConfig);
PINPROC_API PRResult PRDriverGetGroupConfig(PRHandle handle, uint8_t groupNum, PRDriverGroupConfig *driverGroupConfig);
/** Update registers for the given driver group configuration. */
PR_EXPORT PRResult PRDriverUpdateGroupConfig(PRHandle handle, PRDriverGroupConfig *driverGroupConfig);
PINPROC_API PRResult PRDriverUpdateGroupConfig(PRHandle handle, PRDriverGroupConfig *driverGroupConfig);
PR_EXPORT PRResult PRDriverGetState(PRHandle handle, uint8_t driverNum, PRDriverState *driverState);
PINPROC_API PRResult PRDriverGetState(PRHandle handle, uint8_t driverNum, PRDriverState *driverState);
/**
* @brief Sets the state of the given driver (lamp or coil).
*/
PR_EXPORT PRResult PRDriverUpdateState(PRHandle handle, PRDriverState *driverState);
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.
*/
PR_EXPORT PRResult PRDriverLoadMachineTypeDefaults(PRHandle handle, PRMachineType machineType);
PINPROC_API PRResult PRDriverLoadMachineTypeDefaults(PRHandle handle, PRMachineType machineType);
// Driver Group Helper functions:
/**
* Disables (turns off) the given driver group.
/**
* Disables (turns off) the given driver group.
* This function is provided for convenience. See PRDriverGroupDisable() for a full description.
*/
PR_EXPORT PRResult PRDriverGroupDisable(PRHandle handle, uint8_t groupNum);
PINPROC_API PRResult PRDriverGroupDisable(PRHandle handle, uint8_t groupNum);
// Driver Helper functions:
/**
* Disables (turns off) the given driver.
/**
* Disables (turns off) the given driver.
* This function is provided for convenience. See PRDriverStateDisable() for a full description.
*/
PR_EXPORT PRResult PRDriverDisable(PRHandle handle, uint8_t driverNum);
/**
* Pulses the given driver for a number of milliseconds.
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.
*/
PR_EXPORT PRResult PRDriverPulse(PRHandle handle, uint8_t driverNum, uint8_t milliseconds);
/**
* Assigns a repeating schedule to the given driver.
PINPROC_API PRResult PRDriverPulse(PRHandle handle, uint8_t driverNum, uint8_t milliseconds);
/**
* Assigns a repeating schedule to the given driver.
* This function is provided for convenience. See PRDriverStateSchedule() for a full description.
*/
PR_EXPORT 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.
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.
*/
PR_EXPORT PRResult PRDriverPatter(PRHandle handle, uint8_t driverNum, uint8_t millisecondsOn, uint8_t millisecondsOff, uint8_t originalOnTime);
/**
* Assigns a pitter-patter schedule (repeating on/off) to the given driver on for the given duration.
PINPROC_API PRResult PRDriverPatter(PRHandle handle, uint8_t driverNum, uint8_t millisecondsOn, uint8_t millisecondsOff, uint8_t originalOnTime);
/**
* 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.
*/
PR_EXPORT PRResult PRDriverPulsedPatter(PRHandle handle, uint8_t driverNum, uint8_t millisecondsOn, uint8_t millisecondsOff, uint8_t originalOnTime);
/**
* Assigns a pitter-patter schedule (repeating on/off) to the given driver for the given duration.
PINPROC_API PRResult PRDriverPulsedPatter(PRHandle handle, uint8_t driverNum, uint8_t millisecondsOn, uint8_t millisecondsOff, uint8_t originalOnTime);
/**
* Assigns a pitter-patter schedule (repeating on/off) to the given driver for the given duration.
* This function is provided for convenience. See PRDriverStatePatter() for a full description.
*/
PR_EXPORT PRResult PRDriverPulsedPatter(PRHandle handle, uint8_t driverNum, uint8_t millisecondsOn, uint8_t millisecondsOff, uint8_t originalOnTime);
/**
PINPROC_API PRResult PRDriverPulsedPatter(PRHandle handle, uint8_t driverNum, uint8_t millisecondsOn, uint8_t millisecondsOff, uint8_t originalOnTime);
/**
* Prepares an Aux Command to drive the Aux bus.
* This function is provided for convenience.
* This function is provided for convenience.
*/
PR_EXPORT void PRDriverAuxPrepareOutput(PRDriverAuxCommand *auxCommand, uint8_t data, uint8_t extraData, uint8_t enables, bool_t muxEnables, uint16_t delayTime);
/**
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.
* This function is provided for convenience.
*/
PR_EXPORT void PRDriverAuxPrepareDelay(PRDriverAuxCommand *auxCommand, uint16_t delayTime);
/**
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.
* This function is provided for convenience.
*/
PR_EXPORT void PRDriverAuxPrepareJump(PRDriverAuxCommand *auxCommand, uint8_t jumpAddr);
/**
PINPROC_API void PRDriverAuxPrepareJump(PRDriverAuxCommand *auxCommand, uint8_t jumpAddr);
/**
* Prepares a disabled Aux Command.
* This function is provided for convenience.
* This function is provided for convenience.
*/
PR_EXPORT void PRDriverAuxPrepareDisable(PRDriverAuxCommand *auxCommand);
PINPROC_API void PRDriverAuxPrepareDisable(PRDriverAuxCommand *auxCommand);
/** Tickle the watchdog timer. */
PR_EXPORT PRResult PRDriverWatchdogTickle(PRHandle handle);
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.
*/
PR_EXPORT void PRDriverGroupStateDisable(PRDriverGroupConfig *driverGroup);
/**
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.
*/
PR_EXPORT void PRDriverStateDisable(PRDriverState *driverState);
/**
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.
*/
PR_EXPORT void PRDriverStatePulse(PRDriverState *driverState, uint8_t milliseconds);
/**
PINPROC_API void PRDriverStatePulse(PRDriverState *driverState, uint8_t milliseconds);
/**
* Changes the given #PRDriverState to reflect a scheduled state.
* Assigns a repeating schedule to the given driver.
* 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.
*/
PR_EXPORT void PRDriverStateSchedule(PRDriverState *driverState, uint32_t schedule, uint8_t cycleSeconds, bool_t now);
/**
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.
*/
PR_EXPORT void PRDriverStatePatter(PRDriverState *driverState, uint8_t millisecondsOn, uint8_t millisecondsOff, uint8_t originalOnTime);
PINPROC_API void PRDriverStatePatter(PRDriverState *driverState, uint8_t millisecondsOn, uint8_t millisecondsOff, uint8_t originalOnTime);
/**
/**
* @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.
*/
PR_EXPORT void PRDriverStatePulsedPatter(PRDriverState *driverState, uint8_t millisecondsOn, uint8_t millisecondsOff, uint8_t patterTime);
PINPROC_API void PRDriverStatePulsedPatter(PRDriverState *driverState, uint8_t millisecondsOn, uint8_t millisecondsOff, uint8_t patterTime);
/**
/**
* Write Aux Port commands into the Aux Port command memory.
*/
PR_EXPORT PRResult PRDriverAuxSendCommands(PRHandle handle, PRDriverAuxCommand * commands, uint8_t numCommands, uint8_t startingAddr);
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().
*/
PR_EXPORT uint16_t PRDecode(PRMachineType machineType, const char *str);
PINPROC_API uint16_t PRDecode(PRMachineType machineType, const char *str);
/** @} */ // End of Drivers
@@ -371,10 +376,10 @@ typedef struct PREvent {
uint32_t time; /**< Time (in milliseconds) that this event occurred. */
} PREvent;
/** Get all of the available events that have been received.
/** Get all of the available events that have been received.
* \return Number of events returned; -1 if an error occurred.
*/
PR_EXPORT int PRGetEvents(PRHandle handle, PREvent *eventsOut, int maxEvents);
PINPROC_API int PRGetEvents(PRHandle handle, PREvent *eventsOut, int maxEvents);
#define kPRSwitchPhysicalFirst (0) /**< Switch number of the first physical switch. */
@@ -402,35 +407,35 @@ typedef struct PRSwitchRule {
} PRSwitchRule;
/** Update the switch controller configurion registers */
PR_EXPORT PRResult PRSwitchUpdateConfig(PRHandle handle, PRSwitchConfig *switchConfig);
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.
*
* 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
* - #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:
@@ -441,14 +446,14 @@ PR_EXPORT PRResult PRSwitchUpdateConfig(PRHandle handle, PRSwitchConfig *switchC
* PRDriverGetState(handle, drvFlashLamp1, &drivers[1]);
* PRDriverStatePulse(&drivers[0], 50);
* PRDriverStatePulse(&drivers[1], 50);
* PRSwitchUpdateRule(handle, swPopBumper1, kPREventTypeSwitchClosedNondebounced,
* PRSwitchUpdateRule(handle, swPopBumper1, kPREventTypeSwitchClosedNondebounced,
* &rule, drivers, 2);
* // Now configure a switch rule to process scoring in software:
* rule.notifyHost = true;
* PRSwitchUpdateRule(handle, swPopBumper1, kPREventTypeSwitchClosedDebounced,
* 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.
@@ -456,10 +461,10 @@ PR_EXPORT PRResult PRSwitchUpdateConfig(PRHandle handle, PRSwitchConfig *switchC
* @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.
*/
PR_EXPORT PRResult PRSwitchUpdateRule(PRHandle handle, uint8_t switchNum, PREventType eventType, PRSwitchRule *rule, PRDriverState *linkedDrivers, int numDrivers);
PINPROC_API PRResult PRSwitchUpdateRule(PRHandle handle, uint8_t switchNum, PREventType eventType, PRSwitchRule *rule, PRDriverState *linkedDrivers, int numDrivers);
/** Returns a list of PREventTypes describing the states of the requested number of switches */
PR_EXPORT PRResult PRSwitchGetStates(PRHandle handle, PREventType * switchStates, uint16_t numSwitches);
PINPROC_API PRResult PRSwitchGetStates(PRHandle handle, PREventType * switchStates, uint16_t numSwitches);
/** @} */ // End of Switches & Events
@@ -484,9 +489,9 @@ typedef struct PRDMDConfig {
} PRDMDConfig;
/** Sets the configuration registers for the DMD driver. */
PR_EXPORT int32_t PRDMDUpdateConfig(PRHandle handle, PRDMDConfig *dmdConfig);
PINPROC_API int32_t PRDMDUpdateConfig(PRHandle handle, PRDMDConfig *dmdConfig);
/** Updates the DMD frame buffer with the given data. */
PR_EXPORT PRResult PRDMDDraw(PRHandle handle, uint8_t * dots);
PINPROC_API PRResult PRDMDDraw(PRHandle handle, uint8_t * dots);
/** @} */ // End of DMD
@@ -513,26 +518,26 @@ typedef struct PRJTAGOutputs {
} PRJTAGOutputs;
/** Force JTAG outputs (TCK, TDO, TMS) to specific values. Optionally toggle the clock when driving only TDO and/or TMS.*/
PR_EXPORT PRResult PRJTAGDriveOutputs(PRHandle handle, PRJTAGOutputs * jtagOutputs, bool_t toggleClk);
PINPROC_API PRResult PRJTAGDriveOutputs(PRHandle handle, PRJTAGOutputs * jtagOutputs, bool_t toggleClk);
/** Store data to be shifted out on TDO */
PR_EXPORT PRResult PRJTAGWriteTDOMemory(PRHandle handle, uint16_t tableOffset, uint16_t numWords, uint32_t * tdoData);
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. */
PR_EXPORT PRResult PRJTAGShiftTDOData(PRHandle handle, uint16_t numBits, bool_t dataBlockComplete);
PINPROC_API PRResult PRJTAGShiftTDOData(PRHandle handle, uint16_t numBits, bool_t dataBlockComplete);
/** Get the contents of the TDI memory. */
PR_EXPORT PRResult PRJTAGReadTDIMemory(PRHandle handle, uint16_t tableOffset, uint16_t numWords, uint32_t * tdiData);
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. */
PR_EXPORT PRResult PRJTAGGetStatus(PRHandle handle, PRJTAGStatus * status);
PINPROC_API PRResult PRJTAGGetStatus(PRHandle handle, PRJTAGStatus * status);
/** @} */ // End of DMD
/** @cond */
PR_EXTERN_C_END
PINPROC_EXTERN_C_END
/** @endcond */
/**
* @mainpage libpinproc API Documentation
*
*
* This is the documentation for libpinproc, the P-ROC Layer 1 API.
*/
#endif // _PINPROC_H_
#endif /* PINPROC_PINPROC_H */

View File

@@ -22,8 +22,11 @@
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef _PRCOMMON_H_
#define _PRCOMMON_H_
#ifndef PINPROC_PRCOMMON_H
#define PINPROC_PRCOMMON_H
#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4
#pragma once
#endif
#ifdef NDEBUG
# define DEBUG(block)
@@ -34,4 +37,4 @@
void PRLog(PRLogLevel level, const char *format, ...);
void PRSetLastErrorText(const char *format, ...);
#endif // _PRCOMMON_H_
#endif /* PINPROC_PRCOMMON_H */

View File

@@ -27,6 +27,11 @@
* PRDevice.h
* libpinproc
*/
#ifndef PINPROC_PRDEVICE_H
#define PINPROC_PRDEVICE_H
#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4
#pragma once
#endif
#include "pinproc.h"
#include "PRCommon.h"
@@ -167,3 +172,5 @@ protected:
queue<uint32_t> freeSwitchRuleIndexes; /**< Indexes of available switch rules. */
PRSwitchRuleInternal *GetSwitchRuleByIndex(uint16_t index);
};
#endif /* PINPROC_PRDEVICE_H */

View File

@@ -23,8 +23,11 @@
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef _PROC_HARDWARE_H_
#define _PROC_HARDWARE_H_
#ifndef PINPROC_PRHARDWARE_H
#define PINPROC_PRHARDWARE_H
#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4
#pragma once
#endif
#include <stdint.h>
#include "pinproc.h"
@@ -244,7 +247,7 @@ typedef struct PRSwitchRuleInternal {
} PRSwitchRuleInternal;
bool_t IsStern (uint32_t hardware_data);
bool_t IsStern (uint32_t hardware_data);
uint32_t CreateRegRequestWord( uint32_t select, uint32_t addr, uint32_t num_words);
uint32_t CreateBurstCommand ( uint32_t select, uint32_t addr, uint32_t num_words);
int32_t CreateManagerUpdateConfigBurst ( uint32_t * burst, PRManagerConfig *manager_config);
@@ -274,4 +277,4 @@ void PRHardwareClose();
int PRHardwareRead(uint8_t *buffer, int maxBytes);
int PRHardwareWrite(uint8_t *buffer, int bytes);
#endif // _PROC_HARDWARE_H_
#endif /* PINPROC_PRHARDWARE_H */

View File

@@ -81,7 +81,7 @@ void PRSetLastErrorText(const char *format, ...)
PRLog(kPRLogError, "%s\n", lastErrorText);
}
PR_EXPORT const char *PRGetLastErrorText()
const char *PRGetLastErrorText()
{
return lastErrorText;
}
@@ -89,7 +89,7 @@ PR_EXPORT const char *PRGetLastErrorText()
#define handleAsDevice ((PRDevice*)handle)
/** 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. */
PR_EXPORT PRHandle PRCreate(PRMachineType machineType)
PRHandle PRCreate(PRMachineType machineType)
{
PRDevice *device = PRDevice::Create(machineType);
if (device == NULL)
@@ -98,14 +98,14 @@ PR_EXPORT PRHandle PRCreate(PRMachineType machineType)
return device;
}
/** Destroys an existing P-ROC device handle. */
PR_EXPORT void PRDelete(PRHandle handle)
void PRDelete(PRHandle handle)
{
if (handle != kPRHandleInvalid)
delete (PRDevice*)handle;
}
/** Resets internally maintained driver and switch rule structures and optionally writes those to the P-ROC device. */
PR_EXPORT PRResult PRReset(PRHandle handle, uint32_t resetFlags)
PRResult PRReset(PRHandle handle, uint32_t resetFlags)
{
return handleAsDevice->Reset(resetFlags);
}
@@ -113,19 +113,19 @@ PR_EXPORT PRResult PRReset(PRHandle handle, uint32_t resetFlags)
// I/O
/** Flush all pending write data out to the P-ROC */
PR_EXPORT PRResult PRFlushWriteData(PRHandle handle)
PRResult PRFlushWriteData(PRHandle handle)
{
return handleAsDevice->FlushWriteData();
}
/** Write data out to the P-ROC immediately (does not require a call to PRFlushWriteData */
PR_EXPORT 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);
}
/** Read data from the P-ROC. */
PR_EXPORT 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)
{
return handleAsDevice->ReadDataRaw(moduleSelect, startingAddr, numReadWords, readBuffer);
}
@@ -133,45 +133,45 @@ PR_EXPORT PRResult PRReadData(PRHandle handle, uint32_t moduleSelect, uint32_t s
// Events
/** Get all of the available events that have been received. */
PR_EXPORT int PRGetEvents(PRHandle handle, PREvent *eventsOut, int maxEvents)
int PRGetEvents(PRHandle handle, PREvent *eventsOut, int maxEvents)
{
return handleAsDevice->GetEvents(eventsOut, maxEvents);
}
// Manager
PR_EXPORT PRResult PRManagerUpdateConfig(PRHandle handle, PRManagerConfig *managerConfig)
PRResult PRManagerUpdateConfig(PRHandle handle, PRManagerConfig *managerConfig)
{
return handleAsDevice->ManagerUpdateConfig(managerConfig);
}
// Drivers
PR_EXPORT PRResult PRDriverUpdateGlobalConfig(PRHandle handle, PRDriverGlobalConfig *driverGlobalConfig)
PRResult PRDriverUpdateGlobalConfig(PRHandle handle, PRDriverGlobalConfig *driverGlobalConfig)
{
return handleAsDevice->DriverUpdateGlobalConfig(driverGlobalConfig);
}
PR_EXPORT PRResult PRDriverGetGroupConfig(PRHandle handle, uint8_t groupNum, PRDriverGroupConfig *driverGroupConfig)
PRResult PRDriverGetGroupConfig(PRHandle handle, uint8_t groupNum, PRDriverGroupConfig *driverGroupConfig)
{
return handleAsDevice->DriverGetGroupConfig(groupNum, driverGroupConfig);
}
PR_EXPORT PRResult PRDriverUpdateGroupConfig(PRHandle handle, PRDriverGroupConfig *driverGroupConfig)
PRResult PRDriverUpdateGroupConfig(PRHandle handle, PRDriverGroupConfig *driverGroupConfig)
{
return handleAsDevice->DriverUpdateGroupConfig(driverGroupConfig);
}
PR_EXPORT PRResult PRDriverGetState(PRHandle handle, uint8_t driverNum, PRDriverState *driverState)
PRResult PRDriverGetState(PRHandle handle, uint8_t driverNum, PRDriverState *driverState)
{
return handleAsDevice->DriverGetState(driverNum, driverState);
}
PR_EXPORT PRResult PRDriverUpdateState(PRHandle handle, PRDriverState *driverState)
PRResult PRDriverUpdateState(PRHandle handle, PRDriverState *driverState)
{
return handleAsDevice->DriverUpdateState(driverState);
}
PR_EXPORT PRResult PRDriverLoadMachineTypeDefaults(PRHandle handle, PRMachineType machineType)
PRResult PRDriverLoadMachineTypeDefaults(PRHandle handle, PRMachineType machineType)
{
return handleAsDevice->DriverLoadMachineTypeDefaults(machineType);
}
// Driver Group Helper functions:
PR_EXPORT PRResult PRDriverGroupDisable(PRHandle handle, uint8_t groupNum)
PRResult PRDriverGroupDisable(PRHandle handle, uint8_t groupNum)
{
PRDriverGroupConfig driverGroup;
handleAsDevice->DriverGetGroupConfig(groupNum, &driverGroup);
@@ -179,47 +179,47 @@ PR_EXPORT PRResult PRDriverGroupDisable(PRHandle handle, uint8_t groupNum)
return handleAsDevice->DriverUpdateGroupConfig(&driverGroup);
}
// Driver Helper functions:
PR_EXPORT PRResult PRDriverDisable(PRHandle handle, uint8_t driverNum)
PRResult PRDriverDisable(PRHandle handle, uint8_t driverNum)
{
PRDriverState driver;
handleAsDevice->DriverGetState(driverNum, &driver);
PRDriverStateDisable(&driver);
return handleAsDevice->DriverUpdateState(&driver);
}
PR_EXPORT PRResult PRDriverPulse(PRHandle handle, uint8_t driverNum, uint8_t milliseconds)
PRResult PRDriverPulse(PRHandle handle, uint8_t driverNum, uint8_t milliseconds)
{
PRDriverState driver;
handleAsDevice->DriverGetState(driverNum, &driver);
PRDriverStatePulse(&driver, milliseconds);
return handleAsDevice->DriverUpdateState(&driver);
}
PR_EXPORT PRResult PRDriverSchedule(PRHandle handle, uint8_t driverNum, uint32_t schedule, uint8_t cycleSeconds, bool_t now)
PRResult PRDriverSchedule(PRHandle handle, uint8_t driverNum, uint32_t schedule, uint8_t cycleSeconds, bool_t now)
{
PRDriverState driver;
handleAsDevice->DriverGetState(driverNum, &driver);
PRDriverStateSchedule(&driver, schedule, cycleSeconds, now);
return handleAsDevice->DriverUpdateState(&driver);
}
PR_EXPORT PRResult PRDriverPatter(PRHandle handle, uint8_t driverNum, uint8_t millisecondsOn, uint8_t millisecondsOff, uint8_t originalOnTime)
PRResult PRDriverPatter(PRHandle handle, uint8_t driverNum, uint8_t millisecondsOn, uint8_t millisecondsOff, uint8_t originalOnTime)
{
PRDriverState driver;
handleAsDevice->DriverGetState(driverNum, &driver);
PRDriverStatePatter(&driver, millisecondsOn, millisecondsOff, originalOnTime);
return handleAsDevice->DriverUpdateState(&driver);
}
PR_EXPORT PRResult PRDriverPulsedPatter(PRHandle handle, uint8_t driverNum, uint8_t millisecondsOn, uint8_t millisecondsOff, uint8_t duration)
PRResult PRDriverPulsedPatter(PRHandle handle, uint8_t driverNum, uint8_t millisecondsOn, uint8_t millisecondsOff, uint8_t duration)
{
PRDriverState driver;
handleAsDevice->DriverGetState(driverNum, &driver);
PRDriverStatePulsedPatter(&driver, millisecondsOn, millisecondsOff, duration);
return handleAsDevice->DriverUpdateState(&driver);
}
PR_EXPORT PRResult PRDriverAuxSendCommands(PRHandle handle, PRDriverAuxCommand * commands, uint8_t numCommands, uint8_t startingAddr)
PRResult PRDriverAuxSendCommands(PRHandle handle, PRDriverAuxCommand * commands, uint8_t numCommands, uint8_t startingAddr)
{
return handleAsDevice->DriverAuxSendCommands(commands, numCommands, startingAddr);
}
PR_EXPORT void PRDriverAuxPrepareOutput(PRDriverAuxCommand *auxCommand, uint8_t data, uint8_t extraData, uint8_t enables, bool_t muxEnables, uint16_t delayTime)
void PRDriverAuxPrepareOutput(PRDriverAuxCommand *auxCommand, uint8_t data, uint8_t extraData, uint8_t enables, bool_t muxEnables, uint16_t delayTime)
{
auxCommand->active = true;
auxCommand->data = data;
@@ -230,7 +230,7 @@ PR_EXPORT void PRDriverAuxPrepareOutput(PRDriverAuxCommand *auxCommand, uint8_t
auxCommand->delayTime = delayTime;
}
PR_EXPORT void PRDriverAuxPrepareDelay(PRDriverAuxCommand *auxCommand, uint16_t delayTime)
void PRDriverAuxPrepareDelay(PRDriverAuxCommand *auxCommand, uint16_t delayTime)
{
auxCommand->active = true;
auxCommand->delayTime = delayTime;
@@ -241,7 +241,7 @@ PR_EXPORT void PRDriverAuxPrepareDelay(PRDriverAuxCommand *auxCommand, uint16_t
auxCommand->muxEnables = false;
}
PR_EXPORT void PRDriverAuxPrepareJump(PRDriverAuxCommand *auxCommand, uint8_t jumpAddr)
void PRDriverAuxPrepareJump(PRDriverAuxCommand *auxCommand, uint8_t jumpAddr)
{
auxCommand->active = true;
auxCommand->jumpAddr = jumpAddr;
@@ -252,7 +252,7 @@ PR_EXPORT void PRDriverAuxPrepareJump(PRDriverAuxCommand *auxCommand, uint8_t ju
auxCommand->muxEnables = false;
}
PR_EXPORT void PRDriverAuxPrepareDisable(PRDriverAuxCommand *auxCommand)
void PRDriverAuxPrepareDisable(PRDriverAuxCommand *auxCommand)
{
auxCommand->active = false;
auxCommand->data = 0;
@@ -261,16 +261,16 @@ PR_EXPORT void PRDriverAuxPrepareDisable(PRDriverAuxCommand *auxCommand)
auxCommand->muxEnables = false;
}
PR_EXPORT PRResult PRDriverWatchdogTickle(PRHandle handle)
PRResult PRDriverWatchdogTickle(PRHandle handle)
{
return handleAsDevice->DriverWatchdogTickle();
}
PR_EXPORT void PRDriverGroupStateDisable(PRDriverGroupConfig *driverGroup)
void PRDriverGroupStateDisable(PRDriverGroupConfig *driverGroup)
{
driverGroup->active = false;
}
PR_EXPORT void PRDriverStateDisable(PRDriverState *driver)
void PRDriverStateDisable(PRDriverState *driver)
{
driver->state = 0;
driver->timeslots = 0;
@@ -280,7 +280,7 @@ PR_EXPORT void PRDriverStateDisable(PRDriverState *driver)
driver->patterOffTime = 0;
driver->patterEnable = false;
}
PR_EXPORT void PRDriverStatePulse(PRDriverState *driver, uint8_t milliseconds)
void PRDriverStatePulse(PRDriverState *driver, uint8_t milliseconds)
{
driver->state = 1;
driver->timeslots = 0;
@@ -290,7 +290,7 @@ PR_EXPORT void PRDriverStatePulse(PRDriverState *driver, uint8_t milliseconds)
driver->patterOffTime = 0;
driver->patterEnable = false;
}
PR_EXPORT void PRDriverStateSchedule(PRDriverState *driver, uint32_t schedule, uint8_t cycleSeconds, bool_t now)
void PRDriverStateSchedule(PRDriverState *driver, uint32_t schedule, uint8_t cycleSeconds, bool_t now)
{
driver->state = 1;
driver->timeslots = schedule;
@@ -300,7 +300,7 @@ PR_EXPORT void PRDriverStateSchedule(PRDriverState *driver, uint32_t schedule, u
driver->patterOffTime = 0;
driver->patterEnable = false;
}
PR_EXPORT void PRDriverStatePatter(PRDriverState *driver, uint8_t millisecondsOn, uint8_t millisecondsOff, uint8_t originalOnTime)
void PRDriverStatePatter(PRDriverState *driver, uint8_t millisecondsOn, uint8_t millisecondsOff, uint8_t originalOnTime)
{
driver->state = true;
driver->timeslots = 0;
@@ -311,7 +311,7 @@ PR_EXPORT void PRDriverStatePatter(PRDriverState *driver, uint8_t millisecondsOn
driver->patterEnable = true;
}
PR_EXPORT void PRDriverStatePulsedPatter(PRDriverState *driver, uint8_t millisecondsOn, uint8_t millisecondsOff, uint8_t patterTime)
void PRDriverStatePulsedPatter(PRDriverState *driver, uint8_t millisecondsOn, uint8_t millisecondsOff, uint8_t patterTime)
{
driver->state = false;
driver->timeslots = 0;
@@ -322,7 +322,7 @@ PR_EXPORT void PRDriverStatePulsedPatter(PRDriverState *driver, uint8_t millisec
driver->patterEnable = true;
}
PR_EXPORT uint16_t PRDecode(PRMachineType machineType, const char *str)
uint16_t PRDecode(PRMachineType machineType, const char *str)
{
uint16_t x;
@@ -492,55 +492,55 @@ PR_EXPORT uint16_t PRDecode(PRMachineType machineType, const char *str)
// Switches
PR_EXPORT PRResult PRSwitchUpdateConfig(PRHandle handle, PRSwitchConfig *switchConfig)
PRResult PRSwitchUpdateConfig(PRHandle handle, PRSwitchConfig *switchConfig)
{
return handleAsDevice->SwitchUpdateConfig(switchConfig);
}
PR_EXPORT PRResult PRSwitchUpdateRule(PRHandle handle, uint8_t switchNum, PREventType eventType, PRSwitchRule *rule, PRDriverState *linkedDrivers, int numDrivers)
PRResult PRSwitchUpdateRule(PRHandle handle, uint8_t switchNum, PREventType eventType, PRSwitchRule *rule, PRDriverState *linkedDrivers, int numDrivers)
{
return handleAsDevice->SwitchUpdateRule(switchNum, eventType, rule, linkedDrivers, numDrivers);
}
PR_EXPORT PRResult PRSwitchGetStates(PRHandle handle, PREventType * switchStates, uint16_t numSwitches)
PRResult PRSwitchGetStates(PRHandle handle, PREventType * switchStates, uint16_t numSwitches)
{
return handleAsDevice->SwitchGetStates(switchStates, numSwitches);
}
// DMD
PR_EXPORT int32_t PRDMDUpdateConfig(PRHandle handle, PRDMDConfig *dmdConfig)
int32_t PRDMDUpdateConfig(PRHandle handle, PRDMDConfig *dmdConfig)
{
return handleAsDevice->DMDUpdateConfig(dmdConfig);
}
PR_EXPORT PRResult PRDMDDraw(PRHandle handle, uint8_t * dots)
PRResult PRDMDDraw(PRHandle handle, uint8_t * dots)
{
return handleAsDevice->DMDDraw(dots);
}
// JTAG
PR_EXPORT PRResult PRJTAGDriveOutputs(PRHandle handle, PRJTAGOutputs * jtagOutputs, bool_t toggleClk)
PRResult PRJTAGDriveOutputs(PRHandle handle, PRJTAGOutputs * jtagOutputs, bool_t toggleClk)
{
return handleAsDevice->PRJTAGDriveOutputs(jtagOutputs, toggleClk);
}
PR_EXPORT PRResult PRJTAGWriteTDOMemory(PRHandle handle, uint16_t tableOffset, uint16_t numWords, uint32_t * tdoData)
PRResult PRJTAGWriteTDOMemory(PRHandle handle, uint16_t tableOffset, uint16_t numWords, uint32_t * tdoData)
{
return handleAsDevice->PRJTAGWriteTDOMemory(tableOffset, numWords, tdoData);
}
PR_EXPORT PRResult PRJTAGShiftTDOData(PRHandle handle, uint16_t numBits, bool_t dataBlockComplete)
PRResult PRJTAGShiftTDOData(PRHandle handle, uint16_t numBits, bool_t dataBlockComplete)
{
return handleAsDevice->PRJTAGShiftTDOData(numBits, dataBlockComplete);
}
PR_EXPORT PRResult PRJTAGReadTDIMemory(PRHandle handle, uint16_t tableOffset, uint16_t numWords, uint32_t * tdiData)
PRResult PRJTAGReadTDIMemory(PRHandle handle, uint16_t tableOffset, uint16_t numWords, uint32_t * tdiData)
{
return handleAsDevice->PRJTAGReadTDIMemory(tableOffset, numWords, tdiData);
}
PR_EXPORT PRResult PRJTAGGetStatus(PRHandle handle, PRJTAGStatus * status)
PRResult PRJTAGGetStatus(PRHandle handle, PRJTAGStatus * status)
{
return handleAsDevice->PRJTAGGetStatus(status);
}

52
src/pinproc.def Normal file
View File

@@ -0,0 +1,52 @@
LIBRARY "pinproc.dll"
DESCRIPTION "PinPROC library. See http://www.pinballcontrollers.com/"
EXPORTS
; since API/SO version 0.9
PRCreate @1
PRDMDDraw @2
PRDMDUpdateConfig @3
PRDecode @4
PRDelete @5
PRDriverAuxPrepareDelay @6
PRDriverAuxPrepareDisable @7
PRDriverAuxPrepareJump @8
PRDriverAuxPrepareOutput @9
PRDriverAuxSendCommands @10
PRDriverDisable @11
PRDriverGetGroupConfig @12
PRDriverGetState @13
PRDriverGroupDisable @14
PRDriverGroupStateDisable @15
PRDriverLoadMachineTypeDefaults @16
PRDriverPatter @17
PRDriverPulse @18
PRDriverPulsedPatter @19
PRDriverSchedule @20
PRDriverStateDisable @21
PRDriverStatePatter @22
PRDriverStatePulse @23
PRDriverStatePulsedPatter @24
PRDriverStateSchedule @25
PRDriverUpdateGlobalConfig @26
PRDriverUpdateGroupConfig @27
PRDriverUpdateState @28
PRDriverWatchdogTickle @29
PRFlushWriteData @30
PRGetEvents @31
PRGetLastErrorText @32
PRJTAGDriveOutputs @33
PRJTAGGetStatus @34
PRJTAGReadTDIMemory @35
PRJTAGShiftTDOData @36
PRJTAGWriteTDOMemory @37
PRLogSetCallback @38
PRLogSetLevel @39
PRManagerUpdateConfig @40
PRReadData @41
PRReset @42
PRSwitchGetStates @43
PRSwitchUpdateConfig @44
PRSwitchUpdateRule @45
PRWriteData @46

View File

@@ -3,9 +3,11 @@
/* abstract: This file contains a description of the */
/* data structure "lenval". */
/*******************************************************/
#ifndef lenval_dot_h
#define lenval_dot_h
#ifndef PINPROCFW_LENVAL_H
#define PINPROCFW_LENVAL_H
#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4
#pragma once
#endif
/* the lenVal structure is a byte oriented type used to store an */
/* arbitrary length binary value. As an example, the hex value */
@@ -90,5 +92,4 @@ extern void SetBit(lenVal *lv, int byte, int bit, short val);
/* read from XSVF numBytes bytes of data into x */
extern void readVal(lenVal *x, short numBytes);
#endif
#endif /* PINPROCFW_LENVAL_H */

View File

@@ -1271,7 +1271,7 @@ int xsvfDoXSIR2( SXsvfInfo* pXsvfInfo )
readVal( &(pXsvfInfo->lvTdi), 2 );
lShiftIrBits = value( &(pXsvfInfo->lvTdi) );
sShiftIrBytes = xsvfGetAsNumBytes( lShiftIrBits );
XSVFDBG_PRINTF1( 3, " XSIR2 length = %d\n", (int)lShiftIrBits);
XSVFDBG_PRINTF1( 3, " XSIR2 length = %ld\n", lShiftIrBits);
if ( sShiftIrBytes > MAX_LEN )
{

View File

@@ -10,8 +10,11 @@
* in the readByte() function.
* FINALLY - Call xsvfExecute().
*****************************************************************************/
#ifndef PINPROCFW_H
#define PINPROCFW_H
#ifndef PINPROCFW_PINPROCFW_H
#define PINPROCFW_PINPROCFW_H
#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4
#pragma once
#endif
#if defined(__WIN32__) || defined(_WIN32)
#include <windows.h>
@@ -67,5 +70,4 @@ void readByte(unsigned char *data);
void waitTime(long microsec);
#endif /* PINPROCFW_H */
#endif /* PINPROCFW_PINPROCFW_H */