diff --git a/hal/CMakeLists.txt b/hal/CMakeLists.txt index 2be3df3624..c783a8b20b 100644 --- a/hal/CMakeLists.txt +++ b/hal/CMakeLists.txt @@ -2,13 +2,12 @@ cmake_minimum_required(VERSION 2.8) project(HAL) file(GLOB_RECURSE SRC_FILES lib/Athena/*.cpp) -include_directories(lib/Athena include) +include_directories(lib/Athena lib/Athena/FRC_FPGA_ChipObject include) add_library(HALAthena STATIC ${SRC_FILES}) target_link_libraries(HALAthena ${NI_LIBS}) INSTALL(TARGETS HALAthena ARCHIVE DESTINATION lib COMPONENT lib) INSTALL(FILES ${NI_LIBS} DESTINATION lib COMPONENT ni_lib) INSTALL(DIRECTORY include DESTINATION ${CMAKE_INSTALL_PREFIX} COMPONENT headers) # lib/ c m gcc_s ld-linux -# usr/lib stdc++ +# usr/lib # FRC_NetworkCommunication FRC_FPGA_ChipObject RoboRIO_FRC_ChipObject - diff --git a/hal/include/HAL/HAL.hpp b/hal/include/HAL/HAL.hpp index cdbd5a1048..98456eeb4e 100644 --- a/hal/include/HAL/HAL.hpp +++ b/hal/include/HAL/HAL.hpp @@ -30,7 +30,6 @@ #define HAL_IO_CONFIG_DATA_SIZE 32 #define HAL_SYS_STATUS_DATA_SIZE 44 #define HAL_USER_STATUS_DATA_SIZE (984 - HAL_IO_CONFIG_DATA_SIZE - HAL_SYS_STATUS_DATA_SIZE) -#define HAL_USER_DS_LCD_DATA_SIZE 128 #define HALFRC_NetworkCommunication_DynamicType_DSEnhancedIO_Input 17 #define HALFRC_NetworkCommunication_DynamicType_DSEnhancedIO_Output 18 @@ -142,119 +141,32 @@ namespace HALUsageReporting }; } -struct HALCommonControlData -{ - uint16_t packetIndex; - union - { - uint8_t control; -#ifndef __vxworks - struct - { - uint8_t checkVersions :1; - uint8_t test :1; - uint8_t resync :1; - uint8_t fmsAttached :1; - uint8_t autonomous :1; - uint8_t enabled :1; - uint8_t notEStop :1; - uint8_t reset :1; - }; -#else - struct - { - uint8_t reset : 1; - uint8_t notEStop : 1; - uint8_t enabled : 1; - uint8_t autonomous : 1; - uint8_t fmsAttached:1; - uint8_t resync : 1; - uint8_t test :1; - uint8_t checkVersions :1; - }; -#endif - }; - uint8_t dsDigitalIn; - uint16_t teamID; - - char dsID_Alliance; - char dsID_Position; - - union - { - int8_t stick0Axes[6]; - struct - { // TODO: ??? - int8_t stick0Axis1; - int8_t stick0Axis2; - int8_t stick0Axis3; - int8_t stick0Axis4; - int8_t stick0Axis5; - int8_t stick0Axis6; - }; - }; - uint16_t stick0Buttons; // Left-most 4 bits are unused - - union - { - int8_t stick1Axes[6]; - struct - { // TODO: ??? - int8_t stick1Axis1; - int8_t stick1Axis2; - int8_t stick1Axis3; - int8_t stick1Axis4; - int8_t stick1Axis5; - int8_t stick1Axis6; - }; - }; - uint16_t stick1Buttons; // Left-most 4 bits are unused - - union - { - int8_t stick2Axes[6]; - struct - { // TODO: ??? - int8_t stick2Axis1; - int8_t stick2Axis2; - int8_t stick2Axis3; - int8_t stick2Axis4; - int8_t stick2Axis5; - int8_t stick2Axis6; - }; - }; - uint16_t stick2Buttons; // Left-most 4 bits are unused - - union - { - int8_t stick3Axes[6]; - struct - { // TODO: ??? - int8_t stick3Axis1; - int8_t stick3Axis2; - int8_t stick3Axis3; - int8_t stick3Axis4; - int8_t stick3Axis5; - int8_t stick3Axis6; - }; - }; - uint16_t stick3Buttons; // Left-most 4 bits are unused - - //Analog inputs are 10 bit right-justified - uint16_t analog1; - uint16_t analog2; - uint16_t analog3; - uint16_t analog4; - - uint64_t cRIOChecksum; - uint32_t FPGAChecksum0; - uint32_t FPGAChecksum1; - uint32_t FPGAChecksum2; - uint32_t FPGAChecksum3; - - char versionData[8]; +struct HALControlWord { + uint32_t enabled : 1; + uint32_t autonomous : 1; + uint32_t test :1; + uint32_t eStop : 1; + uint32_t fmsAttached:1; + uint32_t dsAttached:1; + uint32_t control_reserved : 26; }; +enum HALAllianceStationID { + kHALAllianceStationID_red1, + kHALAllianceStationID_red2, + kHALAllianceStationID_red3, + kHALAllianceStationID_blue1, + kHALAllianceStationID_blue2, + kHALAllianceStationID_blue3, +}; + +struct HALJoystickAxes { + uint16_t count; + int16_t axes[6]; +}; + +typedef uint32_t HALJoystickButtons; + inline float intToFloat(int value) { return (float)value; @@ -283,10 +195,12 @@ extern "C" bool getFPGAButton(int32_t *status); int HALSetErrorData(const char *errors, int errorsLength, int wait_ms); - int HALSetUserDsLcdData(const char *userDsLcdData, int userDsLcdDataLength, int wait_ms); - int HALOverrideIOConfig(const char *ioConfig, int wait_ms); - int HALGetDynamicControlData(uint8_t type, char *dynamicData, int32_t maxLength, int wait_ms); - int HALGetCommonControlData(HALCommonControlData *data, int wait_ms); + + int HALGetControlWord(HALControlWord *data); + int HALGetAllianceStation(enum HALAllianceStationID *allianceStation); + int HALGetJoystickAxes(uint8_t joystickNum, HALJoystickAxes *axes, uint8_t maxAxes); + int HALGetJoystickButtons(uint8_t joystickNum, HALJoystickButtons *buttons, uint8_t *count); + void HALSetNewDataSem(pthread_mutex_t *); int HALSetStatusData(float battery, uint8_t dsDigitalOut, uint8_t updateNumber, const char *userDataHigh, int userDataHighLength, const char *userDataLow, diff --git a/hal/lib/Athena/ChipObject.h b/hal/lib/Athena/ChipObject.h index a1a08fa122..67f998131f 100644 --- a/hal/lib/Athena/ChipObject.h +++ b/hal/lib/Athena/ChipObject.h @@ -4,33 +4,35 @@ /* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */ /*----------------------------------------------------------------------------*/ #pragma once +#pragma GCC diagnostic ignored "-Wignored-qualifiers" #include -#include "ChipObject/RoboRIO_FRC_ChipObject_Aliases.h" -#include "ChipObject/tDMAManager.h" -#include "ChipObject/tInterruptManager.h" -#include "ChipObject/tSystem.h" -#include "ChipObject/tSystemInterface.h" -#include "ChipObject/nInterfaceGlobals.h" -#include "ChipObject/tAccel.h" -#include "ChipObject/tAccumulator.h" -#include "ChipObject/tAI.h" -#include "ChipObject/tAlarm.h" -#include "ChipObject/tAnalogTrigger.h" -#include "ChipObject/tAO.h" -#include "ChipObject/tBIST.h" -#include "ChipObject/tCounter.h" -#include "ChipObject/tDIO.h" -#include "ChipObject/tDMA.h" -#include "ChipObject/tEncoder.h" -#include "ChipObject/tGlobal.h" -#include "ChipObject/tInterrupt.h" -#include "ChipObject/tPower.h" -#include "ChipObject/tPWM.h" -#include "ChipObject/tRelay.h" -#include "ChipObject/tSPI.h" -#include "ChipObject/tSysWatchdog.h" +#include "FRC_FPGA_ChipObject/RoboRIO_FRC_ChipObject_Aliases.h" +#include "FRC_FPGA_ChipObject/tDMAManager.h" +#include "FRC_FPGA_ChipObject/tInterruptManager.h" +#include "FRC_FPGA_ChipObject/tSystem.h" +#include "FRC_FPGA_ChipObject/tSystemInterface.h" + +#include "FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/nInterfaceGlobals.h" +#include "FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tAccel.h" +#include "FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tAccumulator.h" +#include "FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tAI.h" +#include "FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tAlarm.h" +#include "FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tAnalogTrigger.h" +#include "FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tAO.h" +#include "FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tBIST.h" +#include "FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tCounter.h" +#include "FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tDIO.h" +#include "FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tDMA.h" +#include "FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tEncoder.h" +#include "FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tGlobal.h" +#include "FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tInterrupt.h" +#include "FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tPower.h" +#include "FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tPWM.h" +#include "FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tRelay.h" +#include "FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tSPI.h" +#include "FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tSysWatchdog.h" // FIXME: these should not be here! using namespace nFPGA; diff --git a/hal/lib/Athena/ChipObject/nInterfaceGlobals.h b/hal/lib/Athena/ChipObject/nInterfaceGlobals.h deleted file mode 100644 index a10713dae5..0000000000 --- a/hal/lib/Athena/ChipObject/nInterfaceGlobals.h +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) National Instruments 2008. All Rights Reserved. -// Do Not Edit... this file is generated! - -#ifndef __nFRC_2015_1_0_5_nInterfaceGlobals_h__ -#define __nFRC_2015_1_0_5_nInterfaceGlobals_h__ - -namespace nFPGA -{ -namespace nFRC_2015_1_0_5 -{ - extern unsigned int g_currentTargetClass; -} -} - -#endif // __nFRC_2015_1_0_5_nInterfaceGlobals_h__ diff --git a/hal/lib/Athena/ChipObject/tPower.h b/hal/lib/Athena/ChipObject/tPower.h deleted file mode 100644 index ad859c9a6b..0000000000 --- a/hal/lib/Athena/ChipObject/tPower.h +++ /dev/null @@ -1,107 +0,0 @@ -// Copyright (c) National Instruments 2008. All Rights Reserved. -// Do Not Edit... this file is generated! - -#ifndef __nFRC_2015_1_0_5_Power_h__ -#define __nFRC_2015_1_0_5_Power_h__ - -#include "tSystemInterface.h" - -namespace nFPGA -{ -namespace nFRC_2015_1_0_5 -{ - -class tPower -{ -public: - tPower(){} - virtual ~tPower(){} - - virtual tSystemInterface* getSystemInterface() = 0; - static tPower* create(tRioStatusCode *status); - - typedef enum - { - kNumSystems = 1, - } tIfaceConstants; - - typedef - union{ - struct{ -#ifdef __vxworks - unsigned User3V3 : 8; - unsigned User5V : 8; - unsigned User6V : 8; -#else - unsigned User6V : 8; - unsigned User5V : 8; - unsigned User3V3 : 8; -#endif - }; - struct{ - unsigned value : 24; - }; - } tStatus; - typedef - union{ - struct{ -#ifdef __vxworks - unsigned User3V3 : 1; - unsigned User5V : 1; - unsigned User6V : 1; -#else - unsigned User6V : 1; - unsigned User5V : 1; - unsigned User3V3 : 1; -#endif - }; - struct{ - unsigned value : 3; - }; - } tDisable; - - - - typedef enum - { - } tStatus_IfaceConstants; - - virtual tStatus readStatus(tRioStatusCode *status) = 0; - virtual unsigned char readStatus_User3V3(tRioStatusCode *status) = 0; - virtual unsigned char readStatus_User5V(tRioStatusCode *status) = 0; - virtual unsigned char readStatus_User6V(tRioStatusCode *status) = 0; - - - typedef enum - { - } tDisable_IfaceConstants; - - virtual void writeDisable(tDisable value, tRioStatusCode *status) = 0; - virtual void writeDisable_User3V3(bool value, tRioStatusCode *status) = 0; - virtual void writeDisable_User5V(bool value, tRioStatusCode *status) = 0; - virtual void writeDisable_User6V(bool value, tRioStatusCode *status) = 0; - virtual tDisable readDisable(tRioStatusCode *status) = 0; - virtual bool readDisable_User3V3(tRioStatusCode *status) = 0; - virtual bool readDisable_User5V(tRioStatusCode *status) = 0; - virtual bool readDisable_User6V(tRioStatusCode *status) = 0; - - - typedef enum - { - } tIndicateOutOfRange_IfaceConstants; - - virtual void writeIndicateOutOfRange(bool value, tRioStatusCode *status) = 0; - virtual bool readIndicateOutOfRange(tRioStatusCode *status) = 0; - - - - -private: - tPower(const tPower&); - void operator=(const tPower&); -}; - -} -} - -#endif // __nFRC_2015_1_0_5_Power_h__ diff --git a/hal/lib/Athena/ChipObject/FRC_FPGA_ChipObject_Aliases.h b/hal/lib/Athena/FRC_FPGA_ChipObject/FRC_FPGA_ChipObject_Aliases.h similarity index 100% rename from hal/lib/Athena/ChipObject/FRC_FPGA_ChipObject_Aliases.h rename to hal/lib/Athena/FRC_FPGA_ChipObject/FRC_FPGA_ChipObject_Aliases.h diff --git a/hal/lib/Athena/ChipObject/RoboRIO_FRC_ChipObject_Aliases.h b/hal/lib/Athena/FRC_FPGA_ChipObject/RoboRIO_FRC_ChipObject_Aliases.h similarity index 81% rename from hal/lib/Athena/ChipObject/RoboRIO_FRC_ChipObject_Aliases.h rename to hal/lib/Athena/FRC_FPGA_ChipObject/RoboRIO_FRC_ChipObject_Aliases.h index be207c77f1..8ce42062f6 100644 --- a/hal/lib/Athena/ChipObject/RoboRIO_FRC_ChipObject_Aliases.h +++ b/hal/lib/Athena/FRC_FPGA_ChipObject/RoboRIO_FRC_ChipObject_Aliases.h @@ -4,6 +4,6 @@ #ifndef __RoboRIO_FRC_ChipObject_Aliases_h__ #define __RoboRIO_FRC_ChipObject_Aliases_h__ -#define nRoboRIO_FPGANamespace nFRC_2015_1_0_5 +#define nRoboRIO_FPGANamespace nFRC_2015_1_0_7 #endif // __RoboRIO_FRC_ChipObject_Aliases_h__ diff --git a/hal/lib/Athena/ChipObject/fpgainterfacecapi/NiFpga.h b/hal/lib/Athena/FRC_FPGA_ChipObject/fpgainterfacecapi/NiFpga.h similarity index 100% rename from hal/lib/Athena/ChipObject/fpgainterfacecapi/NiFpga.h rename to hal/lib/Athena/FRC_FPGA_ChipObject/fpgainterfacecapi/NiFpga.h diff --git a/hal/lib/Athena/FRC_FPGA_ChipObject/nInvariantFPGANamespace/tAI.h b/hal/lib/Athena/FRC_FPGA_ChipObject/nInvariantFPGANamespace/tAI.h new file mode 100644 index 0000000000..14121b5e60 --- /dev/null +++ b/hal/lib/Athena/FRC_FPGA_ChipObject/nInvariantFPGANamespace/tAI.h @@ -0,0 +1,73 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_C0EF_1_1_0_AI_h__ +#define __nFRC_C0EF_1_1_0_AI_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_C0EF_1_1_0 +{ + +class tAI +{ +public: + tAI(){} + virtual ~tAI(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tAI* create(unsigned char sys_index, tRioStatusCode *status); + virtual unsigned char getSystemIndex() = 0; + + + typedef enum + { + kNumSystems = 2, + } tIfaceConstants; + + + + typedef enum + { + } tCalOK_IfaceConstants; + + virtual bool readCalOK(tRioStatusCode *status) = 0; + + + typedef enum + { + } tDoneTime_IfaceConstants; + + virtual unsigned int readDoneTime(tRioStatusCode *status) = 0; + + + + + typedef enum + { + kNumOffsetRegisters = 8, + } tOffset_IfaceConstants; + + virtual signed int readOffset(unsigned char reg_index, tRioStatusCode *status) = 0; + + + typedef enum + { + kNumLSBWeightRegisters = 8, + } tLSBWeight_IfaceConstants; + + virtual unsigned int readLSBWeight(unsigned char reg_index, tRioStatusCode *status) = 0; + + + +private: + tAI(const tAI&); + void operator=(const tAI&); +}; + +} +} + +#endif // __nFRC_C0EF_1_1_0_AI_h__ diff --git a/hal/lib/Athena/FRC_FPGA_ChipObject/nInvariantFPGANamespace/tGlobal.h b/hal/lib/Athena/FRC_FPGA_ChipObject/nInvariantFPGANamespace/tGlobal.h new file mode 100644 index 0000000000..0b741172f5 --- /dev/null +++ b/hal/lib/Athena/FRC_FPGA_ChipObject/nInvariantFPGANamespace/tGlobal.h @@ -0,0 +1,69 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_C0EF_1_1_0_Global_h__ +#define __nFRC_C0EF_1_1_0_Global_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_C0EF_1_1_0 +{ + +class tGlobal +{ +public: + tGlobal(){} + virtual ~tGlobal(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tGlobal* create(tRioStatusCode *status); + + typedef enum + { + kNumSystems = 1, + } tIfaceConstants; + + + + + typedef enum + { + } tVersion_IfaceConstants; + + virtual unsigned short readVersion(tRioStatusCode *status) = 0; + + + typedef enum + { + } tLocalTime_IfaceConstants; + + virtual unsigned int readLocalTime(tRioStatusCode *status) = 0; + + + typedef enum + { + } tRevision_IfaceConstants; + + virtual unsigned int readRevision(tRioStatusCode *status) = 0; + + + typedef enum + { + } tReserved_IfaceConstants; + + virtual unsigned char readReserved(tRioStatusCode *status) = 0; + + + + +private: + tGlobal(const tGlobal&); + void operator=(const tGlobal&); +}; + +} +} + +#endif // __nFRC_C0EF_1_1_0_Global_h__ diff --git a/hal/lib/Athena/FRC_FPGA_ChipObject/nInvariantFPGANamespace/tLoadOut.h b/hal/lib/Athena/FRC_FPGA_ChipObject/nInvariantFPGANamespace/tLoadOut.h new file mode 100644 index 0000000000..a7c4ebbb02 --- /dev/null +++ b/hal/lib/Athena/FRC_FPGA_ChipObject/nInvariantFPGANamespace/tLoadOut.h @@ -0,0 +1,79 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_C0EF_1_1_0_LoadOut_h__ +#define __nFRC_C0EF_1_1_0_LoadOut_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_C0EF_1_1_0 +{ + +class tLoadOut +{ +public: + tLoadOut(){} + virtual ~tLoadOut(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tLoadOut* create(tRioStatusCode *status); + + typedef enum + { + kNumSystems = 1, + } tIfaceConstants; + + + + + typedef enum + { + } tReady_IfaceConstants; + + virtual bool readReady(tRioStatusCode *status) = 0; + + + typedef enum + { + } tDoneTime_IfaceConstants; + + virtual unsigned int readDoneTime(tRioStatusCode *status) = 0; + + + + + typedef enum + { + kNumVendorIDRegisters = 8, + } tVendorID_IfaceConstants; + + virtual unsigned short readVendorID(unsigned char reg_index, tRioStatusCode *status) = 0; + + + typedef enum + { + kNumSerialNumberRegisters = 8, + } tSerialNumber_IfaceConstants; + + virtual unsigned int readSerialNumber(unsigned char reg_index, tRioStatusCode *status) = 0; + + + typedef enum + { + kNumModuleIDRegisters = 8, + } tModuleID_IfaceConstants; + + virtual unsigned short readModuleID(unsigned char reg_index, tRioStatusCode *status) = 0; + + +private: + tLoadOut(const tLoadOut&); + void operator=(const tLoadOut&); +}; + +} +} + +#endif // __nFRC_C0EF_1_1_0_LoadOut_h__ diff --git a/hal/lib/Athena/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/nInterfaceGlobals.h b/hal/lib/Athena/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/nInterfaceGlobals.h new file mode 100644 index 0000000000..16e301e7e4 --- /dev/null +++ b/hal/lib/Athena/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/nInterfaceGlobals.h @@ -0,0 +1,15 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2015_1_0_7_nInterfaceGlobals_h__ +#define __nFRC_2015_1_0_7_nInterfaceGlobals_h__ + +namespace nFPGA +{ +namespace nFRC_2015_1_0_7 +{ + extern unsigned int g_currentTargetClass; +} +} + +#endif // __nFRC_2015_1_0_7_nInterfaceGlobals_h__ diff --git a/hal/lib/Athena/ChipObject/tAI.h b/hal/lib/Athena/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tAI.h similarity index 92% rename from hal/lib/Athena/ChipObject/tAI.h rename to hal/lib/Athena/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tAI.h index 5f953561f2..24fe35b8cb 100644 --- a/hal/lib/Athena/ChipObject/tAI.h +++ b/hal/lib/Athena/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tAI.h @@ -1,14 +1,14 @@ // Copyright (c) National Instruments 2008. All Rights Reserved. // Do Not Edit... this file is generated! -#ifndef __nFRC_2015_1_0_5_AI_h__ -#define __nFRC_2015_1_0_5_AI_h__ +#ifndef __nFRC_2015_1_0_7_AI_h__ +#define __nFRC_2015_1_0_7_AI_h__ #include "tSystemInterface.h" namespace nFPGA { -namespace nFRC_2015_1_0_5 +namespace nFRC_2015_1_0_7 { class tAI @@ -140,4 +140,4 @@ private: } } -#endif // __nFRC_2015_1_0_5_AI_h__ +#endif // __nFRC_2015_1_0_7_AI_h__ diff --git a/hal/lib/Athena/ChipObject/tAO.h b/hal/lib/Athena/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tAO.h similarity index 80% rename from hal/lib/Athena/ChipObject/tAO.h rename to hal/lib/Athena/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tAO.h index 98fe2832eb..9282e1f92e 100644 --- a/hal/lib/Athena/ChipObject/tAO.h +++ b/hal/lib/Athena/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tAO.h @@ -1,14 +1,14 @@ // Copyright (c) National Instruments 2008. All Rights Reserved. // Do Not Edit... this file is generated! -#ifndef __nFRC_2015_1_0_5_AO_h__ -#define __nFRC_2015_1_0_5_AO_h__ +#ifndef __nFRC_2015_1_0_7_AO_h__ +#define __nFRC_2015_1_0_7_AO_h__ #include "tSystemInterface.h" namespace nFPGA { -namespace nFRC_2015_1_0_5 +namespace nFRC_2015_1_0_7 { class tAO @@ -47,4 +47,4 @@ private: } } -#endif // __nFRC_2015_1_0_5_AO_h__ +#endif // __nFRC_2015_1_0_7_AO_h__ diff --git a/hal/lib/Athena/ChipObject/tAccel.h b/hal/lib/Athena/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tAccel.h similarity index 88% rename from hal/lib/Athena/ChipObject/tAccel.h rename to hal/lib/Athena/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tAccel.h index fe43ed4df6..6b554961d0 100644 --- a/hal/lib/Athena/ChipObject/tAccel.h +++ b/hal/lib/Athena/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tAccel.h @@ -1,14 +1,14 @@ // Copyright (c) National Instruments 2008. All Rights Reserved. // Do Not Edit... this file is generated! -#ifndef __nFRC_2015_1_0_5_Accel_h__ -#define __nFRC_2015_1_0_5_Accel_h__ +#ifndef __nFRC_2015_1_0_7_Accel_h__ +#define __nFRC_2015_1_0_7_Accel_h__ #include "tSystemInterface.h" namespace nFPGA { -namespace nFRC_2015_1_0_5 +namespace nFRC_2015_1_0_7 { class tAccel @@ -99,4 +99,4 @@ private: } } -#endif // __nFRC_2015_1_0_5_Accel_h__ +#endif // __nFRC_2015_1_0_7_Accel_h__ diff --git a/hal/lib/Athena/ChipObject/tAccumulator.h b/hal/lib/Athena/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tAccumulator.h similarity index 86% rename from hal/lib/Athena/ChipObject/tAccumulator.h rename to hal/lib/Athena/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tAccumulator.h index 04c755190b..690ee78e5c 100644 --- a/hal/lib/Athena/ChipObject/tAccumulator.h +++ b/hal/lib/Athena/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tAccumulator.h @@ -1,14 +1,14 @@ // Copyright (c) National Instruments 2008. All Rights Reserved. // Do Not Edit... this file is generated! -#ifndef __nFRC_2015_1_0_5_Accumulator_h__ -#define __nFRC_2015_1_0_5_Accumulator_h__ +#ifndef __nFRC_2015_1_0_7_Accumulator_h__ +#define __nFRC_2015_1_0_7_Accumulator_h__ #include "tSystemInterface.h" namespace nFPGA { -namespace nFRC_2015_1_0_5 +namespace nFRC_2015_1_0_7 { class tAccumulator @@ -84,4 +84,4 @@ private: } } -#endif // __nFRC_2015_1_0_5_Accumulator_h__ +#endif // __nFRC_2015_1_0_7_Accumulator_h__ diff --git a/hal/lib/Athena/ChipObject/tAlarm.h b/hal/lib/Athena/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tAlarm.h similarity index 81% rename from hal/lib/Athena/ChipObject/tAlarm.h rename to hal/lib/Athena/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tAlarm.h index 3620eb75ba..1e53558567 100644 --- a/hal/lib/Athena/ChipObject/tAlarm.h +++ b/hal/lib/Athena/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tAlarm.h @@ -1,14 +1,14 @@ // Copyright (c) National Instruments 2008. All Rights Reserved. // Do Not Edit... this file is generated! -#ifndef __nFRC_2015_1_0_5_Alarm_h__ -#define __nFRC_2015_1_0_5_Alarm_h__ +#ifndef __nFRC_2015_1_0_7_Alarm_h__ +#define __nFRC_2015_1_0_7_Alarm_h__ #include "tSystemInterface.h" namespace nFPGA { -namespace nFRC_2015_1_0_5 +namespace nFRC_2015_1_0_7 { class tAlarm @@ -54,4 +54,4 @@ private: } } -#endif // __nFRC_2015_1_0_5_Alarm_h__ +#endif // __nFRC_2015_1_0_7_Alarm_h__ diff --git a/hal/lib/Athena/ChipObject/tAnalogTrigger.h b/hal/lib/Athena/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tAnalogTrigger.h similarity index 92% rename from hal/lib/Athena/ChipObject/tAnalogTrigger.h rename to hal/lib/Athena/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tAnalogTrigger.h index fdd776cab8..e2ed9a87f2 100644 --- a/hal/lib/Athena/ChipObject/tAnalogTrigger.h +++ b/hal/lib/Athena/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tAnalogTrigger.h @@ -1,14 +1,14 @@ // Copyright (c) National Instruments 2008. All Rights Reserved. // Do Not Edit... this file is generated! -#ifndef __nFRC_2015_1_0_5_AnalogTrigger_h__ -#define __nFRC_2015_1_0_5_AnalogTrigger_h__ +#ifndef __nFRC_2015_1_0_7_AnalogTrigger_h__ +#define __nFRC_2015_1_0_7_AnalogTrigger_h__ #include "tSystemInterface.h" namespace nFPGA { -namespace nFRC_2015_1_0_5 +namespace nFRC_2015_1_0_7 { class tAnalogTrigger @@ -126,4 +126,4 @@ private: } } -#endif // __nFRC_2015_1_0_5_AnalogTrigger_h__ +#endif // __nFRC_2015_1_0_7_AnalogTrigger_h__ diff --git a/hal/lib/Athena/ChipObject/tBIST.h b/hal/lib/Athena/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tBIST.h similarity index 88% rename from hal/lib/Athena/ChipObject/tBIST.h rename to hal/lib/Athena/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tBIST.h index 6eff7bcfe2..d3a380e487 100644 --- a/hal/lib/Athena/ChipObject/tBIST.h +++ b/hal/lib/Athena/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tBIST.h @@ -1,14 +1,14 @@ // Copyright (c) National Instruments 2008. All Rights Reserved. // Do Not Edit... this file is generated! -#ifndef __nFRC_2015_1_0_5_BIST_h__ -#define __nFRC_2015_1_0_5_BIST_h__ +#ifndef __nFRC_2015_1_0_7_BIST_h__ +#define __nFRC_2015_1_0_7_BIST_h__ #include "tSystemInterface.h" namespace nFPGA { -namespace nFRC_2015_1_0_5 +namespace nFRC_2015_1_0_7 { class tBIST @@ -87,4 +87,4 @@ private: } } -#endif // __nFRC_2015_1_0_5_BIST_h__ +#endif // __nFRC_2015_1_0_7_BIST_h__ diff --git a/hal/lib/Athena/ChipObject/tCounter.h b/hal/lib/Athena/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tCounter.h similarity index 95% rename from hal/lib/Athena/ChipObject/tCounter.h rename to hal/lib/Athena/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tCounter.h index 72d1f97389..ae210ccfca 100644 --- a/hal/lib/Athena/ChipObject/tCounter.h +++ b/hal/lib/Athena/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tCounter.h @@ -1,14 +1,14 @@ // Copyright (c) National Instruments 2008. All Rights Reserved. // Do Not Edit... this file is generated! -#ifndef __nFRC_2015_1_0_5_Counter_h__ -#define __nFRC_2015_1_0_5_Counter_h__ +#ifndef __nFRC_2015_1_0_7_Counter_h__ +#define __nFRC_2015_1_0_7_Counter_h__ #include "tSystemInterface.h" namespace nFPGA { -namespace nFRC_2015_1_0_5 +namespace nFRC_2015_1_0_7 { class tCounter @@ -216,4 +216,4 @@ private: } } -#endif // __nFRC_2015_1_0_5_Counter_h__ +#endif // __nFRC_2015_1_0_7_Counter_h__ diff --git a/hal/lib/Athena/ChipObject/tDIO.h b/hal/lib/Athena/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tDIO.h similarity index 87% rename from hal/lib/Athena/ChipObject/tDIO.h rename to hal/lib/Athena/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tDIO.h index 7d85376de2..4bb0c1a38e 100644 --- a/hal/lib/Athena/ChipObject/tDIO.h +++ b/hal/lib/Athena/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tDIO.h @@ -1,14 +1,14 @@ // Copyright (c) National Instruments 2008. All Rights Reserved. // Do Not Edit... this file is generated! -#ifndef __nFRC_2015_1_0_5_DIO_h__ -#define __nFRC_2015_1_0_5_DIO_h__ +#ifndef __nFRC_2015_1_0_7_DIO_h__ +#define __nFRC_2015_1_0_7_DIO_h__ #include "tSystemInterface.h" namespace nFPGA { -namespace nFRC_2015_1_0_5 +namespace nFRC_2015_1_0_7 { class tDIO @@ -137,15 +137,6 @@ public: virtual unsigned char readFilterSelectHdr(unsigned char bitfield_index, tRioStatusCode *status) = 0; - typedef enum - { - kNumFilterPeriodMXPElements = 3, - } tFilterPeriodMXP_IfaceConstants; - - virtual void writeFilterPeriodMXP(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0; - virtual unsigned char readFilterPeriodMXP(unsigned char bitfield_index, tRioStatusCode *status) = 0; - - typedef enum { } tOutputEnable_IfaceConstants; @@ -218,15 +209,6 @@ public: virtual unsigned char readPulseLength(tRioStatusCode *status) = 0; - typedef enum - { - kNumFilterPeriodHdrElements = 3, - } tFilterPeriodHdr_IfaceConstants; - - virtual void writeFilterPeriodHdr(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0; - virtual unsigned char readFilterPeriodHdr(unsigned char bitfield_index, tRioStatusCode *status) = 0; - - typedef enum { } tPWMPeriodPower_IfaceConstants; @@ -237,6 +219,24 @@ public: + typedef enum + { + kNumFilterPeriodMXPRegisters = 3, + } tFilterPeriodMXP_IfaceConstants; + + virtual void writeFilterPeriodMXP(unsigned char reg_index, unsigned int value, tRioStatusCode *status) = 0; + virtual unsigned int readFilterPeriodMXP(unsigned char reg_index, tRioStatusCode *status) = 0; + + + typedef enum + { + kNumFilterPeriodHdrRegisters = 3, + } tFilterPeriodHdr_IfaceConstants; + + virtual void writeFilterPeriodHdr(unsigned char reg_index, unsigned int value, tRioStatusCode *status) = 0; + virtual unsigned int readFilterPeriodHdr(unsigned char reg_index, tRioStatusCode *status) = 0; + + private: tDIO(const tDIO&); void operator=(const tDIO&); @@ -245,4 +245,4 @@ private: } } -#endif // __nFRC_2015_1_0_5_DIO_h__ +#endif // __nFRC_2015_1_0_7_DIO_h__ diff --git a/hal/lib/Athena/ChipObject/tDMA.h b/hal/lib/Athena/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tDMA.h similarity index 96% rename from hal/lib/Athena/ChipObject/tDMA.h rename to hal/lib/Athena/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tDMA.h index 623c979f7e..a4969f3ac0 100644 --- a/hal/lib/Athena/ChipObject/tDMA.h +++ b/hal/lib/Athena/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tDMA.h @@ -1,14 +1,14 @@ // Copyright (c) National Instruments 2008. All Rights Reserved. // Do Not Edit... this file is generated! -#ifndef __nFRC_2015_1_0_5_DMA_h__ -#define __nFRC_2015_1_0_5_DMA_h__ +#ifndef __nFRC_2015_1_0_7_DMA_h__ +#define __nFRC_2015_1_0_7_DMA_h__ #include "tSystemInterface.h" namespace nFPGA { -namespace nFRC_2015_1_0_5 +namespace nFRC_2015_1_0_7 { class tDMA @@ -185,4 +185,4 @@ private: } } -#endif // __nFRC_2015_1_0_5_DMA_h__ +#endif // __nFRC_2015_1_0_7_DMA_h__ diff --git a/hal/lib/Athena/ChipObject/tEncoder.h b/hal/lib/Athena/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tEncoder.h similarity index 94% rename from hal/lib/Athena/ChipObject/tEncoder.h rename to hal/lib/Athena/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tEncoder.h index 8a0d806c09..43d7de22d6 100644 --- a/hal/lib/Athena/ChipObject/tEncoder.h +++ b/hal/lib/Athena/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tEncoder.h @@ -1,14 +1,14 @@ // Copyright (c) National Instruments 2008. All Rights Reserved. // Do Not Edit... this file is generated! -#ifndef __nFRC_2015_1_0_5_Encoder_h__ -#define __nFRC_2015_1_0_5_Encoder_h__ +#ifndef __nFRC_2015_1_0_7_Encoder_h__ +#define __nFRC_2015_1_0_7_Encoder_h__ #include "tSystemInterface.h" namespace nFPGA { -namespace nFRC_2015_1_0_5 +namespace nFRC_2015_1_0_7 { class tEncoder @@ -196,4 +196,4 @@ private: } } -#endif // __nFRC_2015_1_0_5_Encoder_h__ +#endif // __nFRC_2015_1_0_7_Encoder_h__ diff --git a/hal/lib/Athena/ChipObject/tGlobal.h b/hal/lib/Athena/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tGlobal.h similarity index 89% rename from hal/lib/Athena/ChipObject/tGlobal.h rename to hal/lib/Athena/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tGlobal.h index 990d4a30ad..a59ba1c844 100644 --- a/hal/lib/Athena/ChipObject/tGlobal.h +++ b/hal/lib/Athena/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tGlobal.h @@ -1,14 +1,14 @@ // Copyright (c) National Instruments 2008. All Rights Reserved. // Do Not Edit... this file is generated! -#ifndef __nFRC_2015_1_0_5_Global_h__ -#define __nFRC_2015_1_0_5_Global_h__ +#ifndef __nFRC_2015_1_0_7_Global_h__ +#define __nFRC_2015_1_0_7_Global_h__ #include "tSystemInterface.h" namespace nFPGA { -namespace nFRC_2015_1_0_5 +namespace nFRC_2015_1_0_7 { class tGlobal @@ -101,4 +101,4 @@ private: } } -#endif // __nFRC_2015_1_0_5_Global_h__ +#endif // __nFRC_2015_1_0_7_Global_h__ diff --git a/hal/lib/Athena/ChipObject/tInterrupt.h b/hal/lib/Athena/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tInterrupt.h similarity index 90% rename from hal/lib/Athena/ChipObject/tInterrupt.h rename to hal/lib/Athena/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tInterrupt.h index be319dd89d..d7712af256 100644 --- a/hal/lib/Athena/ChipObject/tInterrupt.h +++ b/hal/lib/Athena/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tInterrupt.h @@ -1,14 +1,14 @@ // Copyright (c) National Instruments 2008. All Rights Reserved. // Do Not Edit... this file is generated! -#ifndef __nFRC_2015_1_0_5_Interrupt_h__ -#define __nFRC_2015_1_0_5_Interrupt_h__ +#ifndef __nFRC_2015_1_0_7_Interrupt_h__ +#define __nFRC_2015_1_0_7_Interrupt_h__ #include "tSystemInterface.h" namespace nFPGA { -namespace nFRC_2015_1_0_5 +namespace nFRC_2015_1_0_7 { class tInterrupt @@ -90,4 +90,4 @@ private: } } -#endif // __nFRC_2015_1_0_5_Interrupt_h__ +#endif // __nFRC_2015_1_0_7_Interrupt_h__ diff --git a/hal/lib/Athena/ChipObject/tPWM.h b/hal/lib/Athena/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tPWM.h similarity index 91% rename from hal/lib/Athena/ChipObject/tPWM.h rename to hal/lib/Athena/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tPWM.h index 1362293a96..e19c0079ba 100644 --- a/hal/lib/Athena/ChipObject/tPWM.h +++ b/hal/lib/Athena/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tPWM.h @@ -1,14 +1,14 @@ // Copyright (c) National Instruments 2008. All Rights Reserved. // Do Not Edit... this file is generated! -#ifndef __nFRC_2015_1_0_5_PWM_h__ -#define __nFRC_2015_1_0_5_PWM_h__ +#ifndef __nFRC_2015_1_0_7_PWM_h__ +#define __nFRC_2015_1_0_7_PWM_h__ #include "tSystemInterface.h" namespace nFPGA { -namespace nFRC_2015_1_0_5 +namespace nFRC_2015_1_0_7 { class tPWM @@ -108,4 +108,4 @@ private: } } -#endif // __nFRC_2015_1_0_5_PWM_h__ +#endif // __nFRC_2015_1_0_7_PWM_h__ diff --git a/hal/lib/Athena/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tPower.h b/hal/lib/Athena/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tPower.h new file mode 100644 index 0000000000..da89316571 --- /dev/null +++ b/hal/lib/Athena/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tPower.h @@ -0,0 +1,217 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2015_1_0_7_Power_h__ +#define __nFRC_2015_1_0_7_Power_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_2015_1_0_7 +{ + +class tPower +{ +public: + tPower(){} + virtual ~tPower(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tPower* create(tRioStatusCode *status); + + typedef enum + { + kNumSystems = 1, + } tIfaceConstants; + + typedef + union{ + struct{ +#ifdef __vxworks + unsigned User3V3 : 8; + unsigned User5V : 8; + unsigned User6V : 8; +#else + unsigned User6V : 8; + unsigned User5V : 8; + unsigned User3V3 : 8; +#endif + }; + struct{ + unsigned value : 24; + }; + } tStatus; + typedef + union{ + struct{ +#ifdef __vxworks + unsigned OverCurrentFaultCount3V3 : 10; + unsigned OverCurrentFaultCount5V : 10; + unsigned OverCurrentFaultCount6V : 10; +#else + unsigned OverCurrentFaultCount6V : 10; + unsigned OverCurrentFaultCount5V : 10; + unsigned OverCurrentFaultCount3V3 : 10; +#endif + }; + struct{ + unsigned value : 30; + }; + } tOverCurrentFaultCounts; + typedef + union{ + struct{ +#ifdef __vxworks + unsigned User3V3 : 1; + unsigned User5V : 1; + unsigned User6V : 1; +#else + unsigned User6V : 1; + unsigned User5V : 1; + unsigned User3V3 : 1; +#endif + }; + struct{ + unsigned value : 3; + }; + } tDisable; + + + + typedef enum + { + } tUserVoltage3V3_IfaceConstants; + + virtual unsigned short readUserVoltage3V3(tRioStatusCode *status) = 0; + + + typedef enum + { + } tStatus_IfaceConstants; + + virtual tStatus readStatus(tRioStatusCode *status) = 0; + virtual unsigned char readStatus_User3V3(tRioStatusCode *status) = 0; + virtual unsigned char readStatus_User5V(tRioStatusCode *status) = 0; + virtual unsigned char readStatus_User6V(tRioStatusCode *status) = 0; + + + typedef enum + { + } tUserVoltage6V_IfaceConstants; + + virtual unsigned short readUserVoltage6V(tRioStatusCode *status) = 0; + + + typedef enum + { + } tOnChipTemperature_IfaceConstants; + + virtual unsigned short readOnChipTemperature(tRioStatusCode *status) = 0; + + + typedef enum + { + } tUserVoltage5V_IfaceConstants; + + virtual unsigned short readUserVoltage5V(tRioStatusCode *status) = 0; + + + typedef enum + { + } tResetFaultCounts_IfaceConstants; + + virtual void strobeResetFaultCounts(tRioStatusCode *status) = 0; + + + typedef enum + { + } tOverCurrentFaultCounts_IfaceConstants; + + virtual tOverCurrentFaultCounts readOverCurrentFaultCounts(tRioStatusCode *status) = 0; + virtual unsigned short readOverCurrentFaultCounts_OverCurrentFaultCount3V3(tRioStatusCode *status) = 0; + virtual unsigned short readOverCurrentFaultCounts_OverCurrentFaultCount5V(tRioStatusCode *status) = 0; + virtual unsigned short readOverCurrentFaultCounts_OverCurrentFaultCount6V(tRioStatusCode *status) = 0; + + + typedef enum + { + } tIntegratedIO_IfaceConstants; + + virtual unsigned short readIntegratedIO(tRioStatusCode *status) = 0; + + + typedef enum + { + } tMXP_DIOVoltage_IfaceConstants; + + virtual unsigned short readMXP_DIOVoltage(tRioStatusCode *status) = 0; + + + typedef enum + { + } tUserCurrent3V3_IfaceConstants; + + virtual unsigned short readUserCurrent3V3(tRioStatusCode *status) = 0; + + + typedef enum + { + } tVinVoltage_IfaceConstants; + + virtual unsigned short readVinVoltage(tRioStatusCode *status) = 0; + + + typedef enum + { + } tUserCurrent6V_IfaceConstants; + + virtual unsigned short readUserCurrent6V(tRioStatusCode *status) = 0; + + + typedef enum + { + } tUserCurrent5V_IfaceConstants; + + virtual unsigned short readUserCurrent5V(tRioStatusCode *status) = 0; + + + typedef enum + { + } tAOVoltage_IfaceConstants; + + virtual unsigned short readAOVoltage(tRioStatusCode *status) = 0; + + + typedef enum + { + } tVinCurrent_IfaceConstants; + + virtual unsigned short readVinCurrent(tRioStatusCode *status) = 0; + + + typedef enum + { + } tDisable_IfaceConstants; + + virtual void writeDisable(tDisable value, tRioStatusCode *status) = 0; + virtual void writeDisable_User3V3(bool value, tRioStatusCode *status) = 0; + virtual void writeDisable_User5V(bool value, tRioStatusCode *status) = 0; + virtual void writeDisable_User6V(bool value, tRioStatusCode *status) = 0; + virtual tDisable readDisable(tRioStatusCode *status) = 0; + virtual bool readDisable_User3V3(tRioStatusCode *status) = 0; + virtual bool readDisable_User5V(tRioStatusCode *status) = 0; + virtual bool readDisable_User6V(tRioStatusCode *status) = 0; + + + + +private: + tPower(const tPower&); + void operator=(const tPower&); +}; + +} +} + +#endif // __nFRC_2015_1_0_7_Power_h__ diff --git a/hal/lib/Athena/ChipObject/tRelay.h b/hal/lib/Athena/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tRelay.h similarity index 85% rename from hal/lib/Athena/ChipObject/tRelay.h rename to hal/lib/Athena/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tRelay.h index a2f72b7f54..57da78e771 100644 --- a/hal/lib/Athena/ChipObject/tRelay.h +++ b/hal/lib/Athena/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tRelay.h @@ -1,14 +1,14 @@ // Copyright (c) National Instruments 2008. All Rights Reserved. // Do Not Edit... this file is generated! -#ifndef __nFRC_2015_1_0_5_Relay_h__ -#define __nFRC_2015_1_0_5_Relay_h__ +#ifndef __nFRC_2015_1_0_7_Relay_h__ +#define __nFRC_2015_1_0_7_Relay_h__ #include "tSystemInterface.h" namespace nFPGA { -namespace nFRC_2015_1_0_5 +namespace nFRC_2015_1_0_7 { class tRelay @@ -65,4 +65,4 @@ private: } } -#endif // __nFRC_2015_1_0_5_Relay_h__ +#endif // __nFRC_2015_1_0_7_Relay_h__ diff --git a/hal/lib/Athena/ChipObject/tSPI.h b/hal/lib/Athena/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tSPI.h similarity index 87% rename from hal/lib/Athena/ChipObject/tSPI.h rename to hal/lib/Athena/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tSPI.h index ce45acfa9b..431001fde8 100644 --- a/hal/lib/Athena/ChipObject/tSPI.h +++ b/hal/lib/Athena/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tSPI.h @@ -1,14 +1,14 @@ // Copyright (c) National Instruments 2008. All Rights Reserved. // Do Not Edit... this file is generated! -#ifndef __nFRC_2015_1_0_5_SPI_h__ -#define __nFRC_2015_1_0_5_SPI_h__ +#ifndef __nFRC_2015_1_0_7_SPI_h__ +#define __nFRC_2015_1_0_7_SPI_h__ #include "tSystemInterface.h" namespace nFPGA { -namespace nFRC_2015_1_0_5 +namespace nFRC_2015_1_0_7 { class tSPI @@ -65,4 +65,4 @@ private: } } -#endif // __nFRC_2015_1_0_5_SPI_h__ +#endif // __nFRC_2015_1_0_7_SPI_h__ diff --git a/hal/lib/Athena/ChipObject/tSysWatchdog.h b/hal/lib/Athena/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tSysWatchdog.h similarity index 88% rename from hal/lib/Athena/ChipObject/tSysWatchdog.h rename to hal/lib/Athena/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tSysWatchdog.h index abb18158f9..b5b3aca44f 100644 --- a/hal/lib/Athena/ChipObject/tSysWatchdog.h +++ b/hal/lib/Athena/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tSysWatchdog.h @@ -1,14 +1,14 @@ // Copyright (c) National Instruments 2008. All Rights Reserved. // Do Not Edit... this file is generated! -#ifndef __nFRC_2015_1_0_5_SysWatchdog_h__ -#define __nFRC_2015_1_0_5_SysWatchdog_h__ +#ifndef __nFRC_2015_1_0_7_SysWatchdog_h__ +#define __nFRC_2015_1_0_7_SysWatchdog_h__ #include "tSystemInterface.h" namespace nFPGA { -namespace nFRC_2015_1_0_5 +namespace nFRC_2015_1_0_7 { class tSysWatchdog @@ -98,4 +98,4 @@ private: } } -#endif // __nFRC_2015_1_0_5_SysWatchdog_h__ +#endif // __nFRC_2015_1_0_7_SysWatchdog_h__ diff --git a/hal/lib/Athena/FRC_FPGA_ChipObject/nRuntimeFPGANamespace/tAI.h b/hal/lib/Athena/FRC_FPGA_ChipObject/nRuntimeFPGANamespace/tAI.h new file mode 100644 index 0000000000..78c423a019 --- /dev/null +++ b/hal/lib/Athena/FRC_FPGA_ChipObject/nRuntimeFPGANamespace/tAI.h @@ -0,0 +1,149 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2012_1_6_4_AI_h__ +#define __nFRC_2012_1_6_4_AI_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_2012_1_6_4 +{ + +class tAI +{ +public: + tAI(){} + virtual ~tAI(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tAI* create(unsigned char sys_index, tRioStatusCode *status); + virtual unsigned char getSystemIndex() = 0; + + + typedef enum + { + kNumSystems = 2, + } tIfaceConstants; + + typedef + union{ + struct{ +#ifdef __vxworks + unsigned Channel : 3; + unsigned Module : 1; + unsigned Averaged : 1; +#else + unsigned Averaged : 1; + unsigned Module : 1; + unsigned Channel : 3; +#endif + }; + struct{ + unsigned value : 5; + }; + } tReadSelect; + typedef + union{ + struct{ +#ifdef __vxworks + unsigned ScanSize : 3; + unsigned ConvertRate : 26; +#else + unsigned ConvertRate : 26; + unsigned ScanSize : 3; +#endif + }; + struct{ + unsigned value : 29; + }; + } tConfig; + + + typedef enum + { + } tConfig_IfaceConstants; + + virtual void writeConfig(tConfig value, tRioStatusCode *status) = 0; + virtual void writeConfig_ScanSize(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_ConvertRate(unsigned int value, tRioStatusCode *status) = 0; + virtual tConfig readConfig(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_ScanSize(tRioStatusCode *status) = 0; + virtual unsigned int readConfig_ConvertRate(tRioStatusCode *status) = 0; + + + typedef enum + { + } tLoopTiming_IfaceConstants; + + virtual unsigned int readLoopTiming(tRioStatusCode *status) = 0; + + + typedef enum + { + kNumOversampleBitsElements = 8, + } tOversampleBits_IfaceConstants; + + virtual void writeOversampleBits(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0; + virtual unsigned char readOversampleBits(unsigned char bitfield_index, tRioStatusCode *status) = 0; + + + typedef enum + { + kNumAverageBitsElements = 8, + } tAverageBits_IfaceConstants; + + virtual void writeAverageBits(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0; + virtual unsigned char readAverageBits(unsigned char bitfield_index, tRioStatusCode *status) = 0; + + + typedef enum + { + kNumScanListElements = 8, + } tScanList_IfaceConstants; + + virtual void writeScanList(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0; + virtual unsigned char readScanList(unsigned char bitfield_index, tRioStatusCode *status) = 0; + + + + typedef enum + { + } tOutput_IfaceConstants; + + virtual signed int readOutput(tRioStatusCode *status) = 0; + + + typedef enum + { + } tLatchOutput_IfaceConstants; + + virtual void strobeLatchOutput(tRioStatusCode *status) = 0; + + + typedef enum + { + } tReadSelect_IfaceConstants; + + virtual void writeReadSelect(tReadSelect value, tRioStatusCode *status) = 0; + virtual void writeReadSelect_Channel(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeReadSelect_Module(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeReadSelect_Averaged(bool value, tRioStatusCode *status) = 0; + virtual tReadSelect readReadSelect(tRioStatusCode *status) = 0; + virtual unsigned char readReadSelect_Channel(tRioStatusCode *status) = 0; + virtual unsigned char readReadSelect_Module(tRioStatusCode *status) = 0; + virtual bool readReadSelect_Averaged(tRioStatusCode *status) = 0; + + + + +private: + tAI(const tAI&); + void operator=(const tAI&); +}; + +} +} + +#endif // __nFRC_2012_1_6_4_AI_h__ diff --git a/hal/lib/Athena/FRC_FPGA_ChipObject/nRuntimeFPGANamespace/tAccumulator.h b/hal/lib/Athena/FRC_FPGA_ChipObject/nRuntimeFPGANamespace/tAccumulator.h new file mode 100644 index 0000000000..1a0972a7e0 --- /dev/null +++ b/hal/lib/Athena/FRC_FPGA_ChipObject/nRuntimeFPGANamespace/tAccumulator.h @@ -0,0 +1,87 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2012_1_6_4_Accumulator_h__ +#define __nFRC_2012_1_6_4_Accumulator_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_2012_1_6_4 +{ + +class tAccumulator +{ +public: + tAccumulator(){} + virtual ~tAccumulator(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tAccumulator* create(unsigned char sys_index, tRioStatusCode *status); + virtual unsigned char getSystemIndex() = 0; + + + typedef enum + { + kNumSystems = 2, + } tIfaceConstants; + + typedef + union{ + struct{ + signed long long Value; + unsigned Count : 32; + }; + struct{ + unsigned value : 32; + unsigned value2 : 32; + unsigned value3 : 32; + }; + } tOutput; + + + typedef enum + { + } tOutput_IfaceConstants; + + virtual tOutput readOutput(tRioStatusCode *status) = 0; + virtual signed long long readOutput_Value(tRioStatusCode *status) = 0; + virtual unsigned int readOutput_Count(tRioStatusCode *status) = 0; + + + typedef enum + { + } tCenter_IfaceConstants; + + virtual void writeCenter(signed int value, tRioStatusCode *status) = 0; + virtual signed int readCenter(tRioStatusCode *status) = 0; + + + typedef enum + { + } tDeadband_IfaceConstants; + + virtual void writeDeadband(signed int value, tRioStatusCode *status) = 0; + virtual signed int readDeadband(tRioStatusCode *status) = 0; + + + typedef enum + { + } tReset_IfaceConstants; + + virtual void strobeReset(tRioStatusCode *status) = 0; + + + + + +private: + tAccumulator(const tAccumulator&); + void operator=(const tAccumulator&); +}; + +} +} + +#endif // __nFRC_2012_1_6_4_Accumulator_h__ diff --git a/hal/lib/Athena/FRC_FPGA_ChipObject/nRuntimeFPGANamespace/tAlarm.h b/hal/lib/Athena/FRC_FPGA_ChipObject/nRuntimeFPGANamespace/tAlarm.h new file mode 100644 index 0000000000..f3eb33f1d2 --- /dev/null +++ b/hal/lib/Athena/FRC_FPGA_ChipObject/nRuntimeFPGANamespace/tAlarm.h @@ -0,0 +1,57 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2012_1_6_4_Alarm_h__ +#define __nFRC_2012_1_6_4_Alarm_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_2012_1_6_4 +{ + +class tAlarm +{ +public: + tAlarm(){} + virtual ~tAlarm(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tAlarm* create(tRioStatusCode *status); + + typedef enum + { + kNumSystems = 1, + } tIfaceConstants; + + + + + typedef enum + { + } tEnable_IfaceConstants; + + virtual void writeEnable(bool value, tRioStatusCode *status) = 0; + virtual bool readEnable(tRioStatusCode *status) = 0; + + + typedef enum + { + } tTriggerTime_IfaceConstants; + + virtual void writeTriggerTime(unsigned int value, tRioStatusCode *status) = 0; + virtual unsigned int readTriggerTime(tRioStatusCode *status) = 0; + + + + +private: + tAlarm(const tAlarm&); + void operator=(const tAlarm&); +}; + +} +} + +#endif // __nFRC_2012_1_6_4_Alarm_h__ diff --git a/hal/lib/Athena/FRC_FPGA_ChipObject/nRuntimeFPGANamespace/tAnalogTrigger.h b/hal/lib/Athena/FRC_FPGA_ChipObject/nRuntimeFPGANamespace/tAnalogTrigger.h new file mode 100644 index 0000000000..43150f7930 --- /dev/null +++ b/hal/lib/Athena/FRC_FPGA_ChipObject/nRuntimeFPGANamespace/tAnalogTrigger.h @@ -0,0 +1,133 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2012_1_6_4_AnalogTrigger_h__ +#define __nFRC_2012_1_6_4_AnalogTrigger_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_2012_1_6_4 +{ + +class tAnalogTrigger +{ +public: + tAnalogTrigger(){} + virtual ~tAnalogTrigger(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tAnalogTrigger* create(unsigned char sys_index, tRioStatusCode *status); + virtual unsigned char getSystemIndex() = 0; + + + typedef enum + { + kNumSystems = 8, + } tIfaceConstants; + + typedef + union{ + struct{ +#ifdef __vxworks + unsigned InHysteresis : 1; + unsigned OverLimit : 1; + unsigned Rising : 1; + unsigned Falling : 1; +#else + unsigned Falling : 1; + unsigned Rising : 1; + unsigned OverLimit : 1; + unsigned InHysteresis : 1; +#endif + }; + struct{ + unsigned value : 4; + }; + } tOutput; + typedef + union{ + struct{ +#ifdef __vxworks + unsigned Channel : 3; + unsigned Module : 1; + unsigned Averaged : 1; + unsigned Filter : 1; + unsigned FloatingRollover : 1; + signed RolloverLimit : 8; +#else + signed RolloverLimit : 8; + unsigned FloatingRollover : 1; + unsigned Filter : 1; + unsigned Averaged : 1; + unsigned Module : 1; + unsigned Channel : 3; +#endif + }; + struct{ + unsigned value : 15; + }; + } tSourceSelect; + + + typedef enum + { + } tSourceSelect_IfaceConstants; + + virtual void writeSourceSelect(tSourceSelect value, tRioStatusCode *status) = 0; + virtual void writeSourceSelect_Channel(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeSourceSelect_Module(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeSourceSelect_Averaged(bool value, tRioStatusCode *status) = 0; + virtual void writeSourceSelect_Filter(bool value, tRioStatusCode *status) = 0; + virtual void writeSourceSelect_FloatingRollover(bool value, tRioStatusCode *status) = 0; + virtual void writeSourceSelect_RolloverLimit(signed short value, tRioStatusCode *status) = 0; + virtual tSourceSelect readSourceSelect(tRioStatusCode *status) = 0; + virtual unsigned char readSourceSelect_Channel(tRioStatusCode *status) = 0; + virtual unsigned char readSourceSelect_Module(tRioStatusCode *status) = 0; + virtual bool readSourceSelect_Averaged(tRioStatusCode *status) = 0; + virtual bool readSourceSelect_Filter(tRioStatusCode *status) = 0; + virtual bool readSourceSelect_FloatingRollover(tRioStatusCode *status) = 0; + virtual signed short readSourceSelect_RolloverLimit(tRioStatusCode *status) = 0; + + + typedef enum + { + } tUpperLimit_IfaceConstants; + + virtual void writeUpperLimit(signed int value, tRioStatusCode *status) = 0; + virtual signed int readUpperLimit(tRioStatusCode *status) = 0; + + + typedef enum + { + } tLowerLimit_IfaceConstants; + + virtual void writeLowerLimit(signed int value, tRioStatusCode *status) = 0; + virtual signed int readLowerLimit(tRioStatusCode *status) = 0; + + + + typedef enum + { + kNumOutputElements = 8, + } tOutput_IfaceConstants; + + virtual tOutput readOutput(unsigned char bitfield_index, tRioStatusCode *status) = 0; + virtual bool readOutput_InHysteresis(unsigned char bitfield_index, tRioStatusCode *status) = 0; + virtual bool readOutput_OverLimit(unsigned char bitfield_index, tRioStatusCode *status) = 0; + virtual bool readOutput_Rising(unsigned char bitfield_index, tRioStatusCode *status) = 0; + virtual bool readOutput_Falling(unsigned char bitfield_index, tRioStatusCode *status) = 0; + + + + +private: + tAnalogTrigger(const tAnalogTrigger&); + void operator=(const tAnalogTrigger&); +}; + +} +} + +#endif // __nFRC_2012_1_6_4_AnalogTrigger_h__ diff --git a/hal/lib/Athena/FRC_FPGA_ChipObject/nRuntimeFPGANamespace/tCounter.h b/hal/lib/Athena/FRC_FPGA_ChipObject/nRuntimeFPGANamespace/tCounter.h new file mode 100644 index 0000000000..b23a7f06f2 --- /dev/null +++ b/hal/lib/Athena/FRC_FPGA_ChipObject/nRuntimeFPGANamespace/tCounter.h @@ -0,0 +1,219 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2012_1_6_4_Counter_h__ +#define __nFRC_2012_1_6_4_Counter_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_2012_1_6_4 +{ + +class tCounter +{ +public: + tCounter(){} + virtual ~tCounter(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tCounter* create(unsigned char sys_index, tRioStatusCode *status); + virtual unsigned char getSystemIndex() = 0; + + + typedef enum + { + kNumSystems = 8, + } tIfaceConstants; + + typedef + union{ + struct{ +#ifdef __vxworks + unsigned Direction : 1; + signed Value : 31; +#else + signed Value : 31; + unsigned Direction : 1; +#endif + }; + struct{ + unsigned value : 32; + }; + } tOutput; + typedef + union{ + struct{ +#ifdef __vxworks + unsigned UpSource_Channel : 4; + unsigned UpSource_Module : 1; + unsigned UpSource_AnalogTrigger : 1; + unsigned DownSource_Channel : 4; + unsigned DownSource_Module : 1; + unsigned DownSource_AnalogTrigger : 1; + unsigned IndexSource_Channel : 4; + unsigned IndexSource_Module : 1; + unsigned IndexSource_AnalogTrigger : 1; + unsigned IndexActiveHigh : 1; + unsigned UpRisingEdge : 1; + unsigned UpFallingEdge : 1; + unsigned DownRisingEdge : 1; + unsigned DownFallingEdge : 1; + unsigned Mode : 2; + unsigned PulseLengthThreshold : 6; + unsigned Enable : 1; +#else + unsigned Enable : 1; + unsigned PulseLengthThreshold : 6; + unsigned Mode : 2; + unsigned DownFallingEdge : 1; + unsigned DownRisingEdge : 1; + unsigned UpFallingEdge : 1; + unsigned UpRisingEdge : 1; + unsigned IndexActiveHigh : 1; + unsigned IndexSource_AnalogTrigger : 1; + unsigned IndexSource_Module : 1; + unsigned IndexSource_Channel : 4; + unsigned DownSource_AnalogTrigger : 1; + unsigned DownSource_Module : 1; + unsigned DownSource_Channel : 4; + unsigned UpSource_AnalogTrigger : 1; + unsigned UpSource_Module : 1; + unsigned UpSource_Channel : 4; +#endif + }; + struct{ + unsigned value : 32; + }; + } tConfig; + typedef + union{ + struct{ +#ifdef __vxworks + unsigned Period : 23; + signed Count : 8; + unsigned Stalled : 1; +#else + unsigned Stalled : 1; + signed Count : 8; + unsigned Period : 23; +#endif + }; + struct{ + unsigned value : 32; + }; + } tTimerOutput; + typedef + union{ + struct{ +#ifdef __vxworks + unsigned StallPeriod : 24; + unsigned AverageSize : 7; + unsigned UpdateWhenEmpty : 1; +#else + unsigned UpdateWhenEmpty : 1; + unsigned AverageSize : 7; + unsigned StallPeriod : 24; +#endif + }; + struct{ + unsigned value : 32; + }; + } tTimerConfig; + + + typedef enum + { + } tOutput_IfaceConstants; + + virtual tOutput readOutput(tRioStatusCode *status) = 0; + virtual bool readOutput_Direction(tRioStatusCode *status) = 0; + virtual signed int readOutput_Value(tRioStatusCode *status) = 0; + + + typedef enum + { + } tConfig_IfaceConstants; + + virtual void writeConfig(tConfig value, tRioStatusCode *status) = 0; + virtual void writeConfig_UpSource_Channel(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_UpSource_Module(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_UpSource_AnalogTrigger(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_DownSource_Channel(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_DownSource_Module(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_DownSource_AnalogTrigger(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_IndexSource_Channel(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_IndexSource_Module(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_IndexSource_AnalogTrigger(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_IndexActiveHigh(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_UpRisingEdge(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_UpFallingEdge(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_DownRisingEdge(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_DownFallingEdge(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Mode(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_PulseLengthThreshold(unsigned short value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable(bool value, tRioStatusCode *status) = 0; + virtual tConfig readConfig(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_UpSource_Channel(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_UpSource_Module(tRioStatusCode *status) = 0; + virtual bool readConfig_UpSource_AnalogTrigger(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_DownSource_Channel(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_DownSource_Module(tRioStatusCode *status) = 0; + virtual bool readConfig_DownSource_AnalogTrigger(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_IndexSource_Channel(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_IndexSource_Module(tRioStatusCode *status) = 0; + virtual bool readConfig_IndexSource_AnalogTrigger(tRioStatusCode *status) = 0; + virtual bool readConfig_IndexActiveHigh(tRioStatusCode *status) = 0; + virtual bool readConfig_UpRisingEdge(tRioStatusCode *status) = 0; + virtual bool readConfig_UpFallingEdge(tRioStatusCode *status) = 0; + virtual bool readConfig_DownRisingEdge(tRioStatusCode *status) = 0; + virtual bool readConfig_DownFallingEdge(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_Mode(tRioStatusCode *status) = 0; + virtual unsigned short readConfig_PulseLengthThreshold(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable(tRioStatusCode *status) = 0; + + + typedef enum + { + } tTimerOutput_IfaceConstants; + + virtual tTimerOutput readTimerOutput(tRioStatusCode *status) = 0; + virtual unsigned int readTimerOutput_Period(tRioStatusCode *status) = 0; + virtual signed char readTimerOutput_Count(tRioStatusCode *status) = 0; + virtual bool readTimerOutput_Stalled(tRioStatusCode *status) = 0; + + + typedef enum + { + } tReset_IfaceConstants; + + virtual void strobeReset(tRioStatusCode *status) = 0; + + + typedef enum + { + } tTimerConfig_IfaceConstants; + + virtual void writeTimerConfig(tTimerConfig value, tRioStatusCode *status) = 0; + virtual void writeTimerConfig_StallPeriod(unsigned int value, tRioStatusCode *status) = 0; + virtual void writeTimerConfig_AverageSize(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeTimerConfig_UpdateWhenEmpty(bool value, tRioStatusCode *status) = 0; + virtual tTimerConfig readTimerConfig(tRioStatusCode *status) = 0; + virtual unsigned int readTimerConfig_StallPeriod(tRioStatusCode *status) = 0; + virtual unsigned char readTimerConfig_AverageSize(tRioStatusCode *status) = 0; + virtual bool readTimerConfig_UpdateWhenEmpty(tRioStatusCode *status) = 0; + + + + + +private: + tCounter(const tCounter&); + void operator=(const tCounter&); +}; + +} +} + +#endif // __nFRC_2012_1_6_4_Counter_h__ diff --git a/hal/lib/Athena/FRC_FPGA_ChipObject/nRuntimeFPGANamespace/tDIO.h b/hal/lib/Athena/FRC_FPGA_ChipObject/nRuntimeFPGANamespace/tDIO.h new file mode 100644 index 0000000000..babb691e3b --- /dev/null +++ b/hal/lib/Athena/FRC_FPGA_ChipObject/nRuntimeFPGANamespace/tDIO.h @@ -0,0 +1,330 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2012_1_6_4_DIO_h__ +#define __nFRC_2012_1_6_4_DIO_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_2012_1_6_4 +{ + +class tDIO +{ +public: + tDIO(){} + virtual ~tDIO(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tDIO* create(unsigned char sys_index, tRioStatusCode *status); + virtual unsigned char getSystemIndex() = 0; + + + typedef enum + { + kNumSystems = 2, + } tIfaceConstants; + + typedef + union{ + struct{ +#ifdef __vxworks + unsigned Period : 16; + unsigned MinHigh : 16; +#else + unsigned MinHigh : 16; + unsigned Period : 16; +#endif + }; + struct{ + unsigned value : 32; + }; + } tPWMConfig; + typedef + union{ + struct{ +#ifdef __vxworks + unsigned RelayFwd : 8; + unsigned RelayRev : 8; + unsigned I2CHeader : 4; +#else + unsigned I2CHeader : 4; + unsigned RelayRev : 8; + unsigned RelayFwd : 8; +#endif + }; + struct{ + unsigned value : 20; + }; + } tSlowValue; + typedef + union{ + struct{ +#ifdef __vxworks + unsigned Transaction : 1; + unsigned Done : 1; + unsigned Aborted : 1; + unsigned DataReceivedHigh : 24; +#else + unsigned DataReceivedHigh : 24; + unsigned Aborted : 1; + unsigned Done : 1; + unsigned Transaction : 1; +#endif + }; + struct{ + unsigned value : 27; + }; + } tI2CStatus; + typedef + union{ + struct{ +#ifdef __vxworks + unsigned Address : 8; + unsigned BytesToRead : 3; + unsigned BytesToWrite : 3; + unsigned DataToSendHigh : 16; + unsigned BitwiseHandshake : 1; +#else + unsigned BitwiseHandshake : 1; + unsigned DataToSendHigh : 16; + unsigned BytesToWrite : 3; + unsigned BytesToRead : 3; + unsigned Address : 8; +#endif + }; + struct{ + unsigned value : 31; + }; + } tI2CConfig; + typedef + union{ + struct{ +#ifdef __vxworks + unsigned PeriodPower : 4; + unsigned OutputSelect_0 : 4; + unsigned OutputSelect_1 : 4; + unsigned OutputSelect_2 : 4; + unsigned OutputSelect_3 : 4; +#else + unsigned OutputSelect_3 : 4; + unsigned OutputSelect_2 : 4; + unsigned OutputSelect_1 : 4; + unsigned OutputSelect_0 : 4; + unsigned PeriodPower : 4; +#endif + }; + struct{ + unsigned value : 20; + }; + } tDO_PWMConfig; + + + typedef enum + { + kNumFilterSelectElements = 16, + } tFilterSelect_IfaceConstants; + + virtual void writeFilterSelect(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0; + virtual unsigned char readFilterSelect(unsigned char bitfield_index, tRioStatusCode *status) = 0; + + + typedef enum + { + } tI2CDataToSend_IfaceConstants; + + virtual void writeI2CDataToSend(unsigned int value, tRioStatusCode *status) = 0; + virtual unsigned int readI2CDataToSend(tRioStatusCode *status) = 0; + + + typedef enum + { + } tDO_IfaceConstants; + + virtual void writeDO(unsigned short value, tRioStatusCode *status) = 0; + virtual unsigned short readDO(tRioStatusCode *status) = 0; + + + typedef enum + { + kNumFilterPeriodElements = 3, + } tFilterPeriod_IfaceConstants; + + virtual void writeFilterPeriod(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0; + virtual unsigned char readFilterPeriod(unsigned char bitfield_index, tRioStatusCode *status) = 0; + + + typedef enum + { + } tOutputEnable_IfaceConstants; + + virtual void writeOutputEnable(unsigned short value, tRioStatusCode *status) = 0; + virtual unsigned short readOutputEnable(tRioStatusCode *status) = 0; + + + typedef enum + { + } tPulse_IfaceConstants; + + virtual void writePulse(unsigned short value, tRioStatusCode *status) = 0; + virtual unsigned short readPulse(tRioStatusCode *status) = 0; + + + typedef enum + { + } tSlowValue_IfaceConstants; + + virtual void writeSlowValue(tSlowValue value, tRioStatusCode *status) = 0; + virtual void writeSlowValue_RelayFwd(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeSlowValue_RelayRev(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeSlowValue_I2CHeader(unsigned char value, tRioStatusCode *status) = 0; + virtual tSlowValue readSlowValue(tRioStatusCode *status) = 0; + virtual unsigned char readSlowValue_RelayFwd(tRioStatusCode *status) = 0; + virtual unsigned char readSlowValue_RelayRev(tRioStatusCode *status) = 0; + virtual unsigned char readSlowValue_I2CHeader(tRioStatusCode *status) = 0; + + + typedef enum + { + } tI2CStatus_IfaceConstants; + + virtual tI2CStatus readI2CStatus(tRioStatusCode *status) = 0; + virtual unsigned char readI2CStatus_Transaction(tRioStatusCode *status) = 0; + virtual bool readI2CStatus_Done(tRioStatusCode *status) = 0; + virtual bool readI2CStatus_Aborted(tRioStatusCode *status) = 0; + virtual unsigned int readI2CStatus_DataReceivedHigh(tRioStatusCode *status) = 0; + + + typedef enum + { + } tI2CDataReceived_IfaceConstants; + + virtual unsigned int readI2CDataReceived(tRioStatusCode *status) = 0; + + + typedef enum + { + } tDI_IfaceConstants; + + virtual unsigned short readDI(tRioStatusCode *status) = 0; + + + typedef enum + { + } tPulseLength_IfaceConstants; + + virtual void writePulseLength(unsigned char value, tRioStatusCode *status) = 0; + virtual unsigned char readPulseLength(tRioStatusCode *status) = 0; + + + typedef enum + { + kNumPWMPeriodScaleElements = 10, + } tPWMPeriodScale_IfaceConstants; + + virtual void writePWMPeriodScale(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0; + virtual unsigned char readPWMPeriodScale(unsigned char bitfield_index, tRioStatusCode *status) = 0; + + + typedef enum + { + kNumDO_PWMDutyCycleElements = 4, + } tDO_PWMDutyCycle_IfaceConstants; + + virtual void writeDO_PWMDutyCycle(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0; + virtual unsigned char readDO_PWMDutyCycle(unsigned char bitfield_index, tRioStatusCode *status) = 0; + + + typedef enum + { + } tBFL_IfaceConstants; + + virtual void writeBFL(bool value, tRioStatusCode *status) = 0; + virtual bool readBFL(tRioStatusCode *status) = 0; + + + typedef enum + { + } tI2CConfig_IfaceConstants; + + virtual void writeI2CConfig(tI2CConfig value, tRioStatusCode *status) = 0; + virtual void writeI2CConfig_Address(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeI2CConfig_BytesToRead(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeI2CConfig_BytesToWrite(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeI2CConfig_DataToSendHigh(unsigned short value, tRioStatusCode *status) = 0; + virtual void writeI2CConfig_BitwiseHandshake(bool value, tRioStatusCode *status) = 0; + virtual tI2CConfig readI2CConfig(tRioStatusCode *status) = 0; + virtual unsigned char readI2CConfig_Address(tRioStatusCode *status) = 0; + virtual unsigned char readI2CConfig_BytesToRead(tRioStatusCode *status) = 0; + virtual unsigned char readI2CConfig_BytesToWrite(tRioStatusCode *status) = 0; + virtual unsigned short readI2CConfig_DataToSendHigh(tRioStatusCode *status) = 0; + virtual bool readI2CConfig_BitwiseHandshake(tRioStatusCode *status) = 0; + + + typedef enum + { + } tDO_PWMConfig_IfaceConstants; + + virtual void writeDO_PWMConfig(tDO_PWMConfig value, tRioStatusCode *status) = 0; + virtual void writeDO_PWMConfig_PeriodPower(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeDO_PWMConfig_OutputSelect_0(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeDO_PWMConfig_OutputSelect_1(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeDO_PWMConfig_OutputSelect_2(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeDO_PWMConfig_OutputSelect_3(unsigned char value, tRioStatusCode *status) = 0; + virtual tDO_PWMConfig readDO_PWMConfig(tRioStatusCode *status) = 0; + virtual unsigned char readDO_PWMConfig_PeriodPower(tRioStatusCode *status) = 0; + virtual unsigned char readDO_PWMConfig_OutputSelect_0(tRioStatusCode *status) = 0; + virtual unsigned char readDO_PWMConfig_OutputSelect_1(tRioStatusCode *status) = 0; + virtual unsigned char readDO_PWMConfig_OutputSelect_2(tRioStatusCode *status) = 0; + virtual unsigned char readDO_PWMConfig_OutputSelect_3(tRioStatusCode *status) = 0; + + + typedef enum + { + } tI2CStart_IfaceConstants; + + virtual void strobeI2CStart(tRioStatusCode *status) = 0; + + + + typedef enum + { + } tLoopTiming_IfaceConstants; + + virtual unsigned short readLoopTiming(tRioStatusCode *status) = 0; + + + typedef enum + { + } tPWMConfig_IfaceConstants; + + virtual void writePWMConfig(tPWMConfig value, tRioStatusCode *status) = 0; + virtual void writePWMConfig_Period(unsigned short value, tRioStatusCode *status) = 0; + virtual void writePWMConfig_MinHigh(unsigned short value, tRioStatusCode *status) = 0; + virtual tPWMConfig readPWMConfig(tRioStatusCode *status) = 0; + virtual unsigned short readPWMConfig_Period(tRioStatusCode *status) = 0; + virtual unsigned short readPWMConfig_MinHigh(tRioStatusCode *status) = 0; + + + + typedef enum + { + kNumPWMValueRegisters = 10, + } tPWMValue_IfaceConstants; + + virtual void writePWMValue(unsigned char reg_index, unsigned char value, tRioStatusCode *status) = 0; + virtual unsigned char readPWMValue(unsigned char reg_index, tRioStatusCode *status) = 0; + + + +private: + tDIO(const tDIO&); + void operator=(const tDIO&); +}; + +} +} + +#endif // __nFRC_2012_1_6_4_DIO_h__ diff --git a/hal/lib/Athena/FRC_FPGA_ChipObject/nRuntimeFPGANamespace/tDMA.h b/hal/lib/Athena/FRC_FPGA_ChipObject/nRuntimeFPGANamespace/tDMA.h new file mode 100644 index 0000000000..006ec60a9a --- /dev/null +++ b/hal/lib/Athena/FRC_FPGA_ChipObject/nRuntimeFPGANamespace/tDMA.h @@ -0,0 +1,188 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2012_1_6_4_DMA_h__ +#define __nFRC_2012_1_6_4_DMA_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_2012_1_6_4 +{ + +class tDMA +{ +public: + tDMA(){} + virtual ~tDMA(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tDMA* create(tRioStatusCode *status); + + typedef enum + { + kNumSystems = 1, + } tIfaceConstants; + + typedef + union{ + struct{ +#ifdef __vxworks + unsigned Pause : 1; + unsigned Enable_AI0_Low : 1; + unsigned Enable_AI0_High : 1; + unsigned Enable_AIAveraged0_Low : 1; + unsigned Enable_AIAveraged0_High : 1; + unsigned Enable_AI1_Low : 1; + unsigned Enable_AI1_High : 1; + unsigned Enable_AIAveraged1_Low : 1; + unsigned Enable_AIAveraged1_High : 1; + unsigned Enable_Accumulator0 : 1; + unsigned Enable_Accumulator1 : 1; + unsigned Enable_DI : 1; + unsigned Enable_AnalogTriggers : 1; + unsigned Enable_Counters_Low : 1; + unsigned Enable_Counters_High : 1; + unsigned Enable_CounterTimers_Low : 1; + unsigned Enable_CounterTimers_High : 1; + unsigned Enable_Encoders : 1; + unsigned Enable_EncoderTimers : 1; + unsigned ExternalClock : 1; +#else + unsigned ExternalClock : 1; + unsigned Enable_EncoderTimers : 1; + unsigned Enable_Encoders : 1; + unsigned Enable_CounterTimers_High : 1; + unsigned Enable_CounterTimers_Low : 1; + unsigned Enable_Counters_High : 1; + unsigned Enable_Counters_Low : 1; + unsigned Enable_AnalogTriggers : 1; + unsigned Enable_DI : 1; + unsigned Enable_Accumulator1 : 1; + unsigned Enable_Accumulator0 : 1; + unsigned Enable_AIAveraged1_High : 1; + unsigned Enable_AIAveraged1_Low : 1; + unsigned Enable_AI1_High : 1; + unsigned Enable_AI1_Low : 1; + unsigned Enable_AIAveraged0_High : 1; + unsigned Enable_AIAveraged0_Low : 1; + unsigned Enable_AI0_High : 1; + unsigned Enable_AI0_Low : 1; + unsigned Pause : 1; +#endif + }; + struct{ + unsigned value : 20; + }; + } tConfig; + typedef + union{ + struct{ +#ifdef __vxworks + unsigned ExternalClockSource_Channel : 4; + unsigned ExternalClockSource_Module : 1; + unsigned ExternalClockSource_AnalogTrigger : 1; + unsigned RisingEdge : 1; + unsigned FallingEdge : 1; +#else + unsigned FallingEdge : 1; + unsigned RisingEdge : 1; + unsigned ExternalClockSource_AnalogTrigger : 1; + unsigned ExternalClockSource_Module : 1; + unsigned ExternalClockSource_Channel : 4; +#endif + }; + struct{ + unsigned value : 8; + }; + } tExternalTriggers; + + + + typedef enum + { + } tRate_IfaceConstants; + + virtual void writeRate(unsigned int value, tRioStatusCode *status) = 0; + virtual unsigned int readRate(tRioStatusCode *status) = 0; + + + typedef enum + { + } tConfig_IfaceConstants; + + virtual void writeConfig(tConfig value, tRioStatusCode *status) = 0; + virtual void writeConfig_Pause(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_AI0_Low(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_AI0_High(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_AIAveraged0_Low(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_AIAveraged0_High(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_AI1_Low(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_AI1_High(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_AIAveraged1_Low(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_AIAveraged1_High(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_Accumulator0(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_Accumulator1(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_DI(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_AnalogTriggers(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_Counters_Low(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_Counters_High(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_CounterTimers_Low(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_CounterTimers_High(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_Encoders(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_EncoderTimers(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_ExternalClock(bool value, tRioStatusCode *status) = 0; + virtual tConfig readConfig(tRioStatusCode *status) = 0; + virtual bool readConfig_Pause(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_AI0_Low(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_AI0_High(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_AIAveraged0_Low(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_AIAveraged0_High(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_AI1_Low(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_AI1_High(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_AIAveraged1_Low(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_AIAveraged1_High(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_Accumulator0(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_Accumulator1(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_DI(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_AnalogTriggers(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_Counters_Low(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_Counters_High(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_CounterTimers_Low(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_CounterTimers_High(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_Encoders(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_EncoderTimers(tRioStatusCode *status) = 0; + virtual bool readConfig_ExternalClock(tRioStatusCode *status) = 0; + + + typedef enum + { + kNumExternalTriggersElements = 4, + } tExternalTriggers_IfaceConstants; + + virtual void writeExternalTriggers(unsigned char bitfield_index, tExternalTriggers value, tRioStatusCode *status) = 0; + virtual void writeExternalTriggers_ExternalClockSource_Channel(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0; + virtual void writeExternalTriggers_ExternalClockSource_Module(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0; + virtual void writeExternalTriggers_ExternalClockSource_AnalogTrigger(unsigned char bitfield_index, bool value, tRioStatusCode *status) = 0; + virtual void writeExternalTriggers_RisingEdge(unsigned char bitfield_index, bool value, tRioStatusCode *status) = 0; + virtual void writeExternalTriggers_FallingEdge(unsigned char bitfield_index, bool value, tRioStatusCode *status) = 0; + virtual tExternalTriggers readExternalTriggers(unsigned char bitfield_index, tRioStatusCode *status) = 0; + virtual unsigned char readExternalTriggers_ExternalClockSource_Channel(unsigned char bitfield_index, tRioStatusCode *status) = 0; + virtual unsigned char readExternalTriggers_ExternalClockSource_Module(unsigned char bitfield_index, tRioStatusCode *status) = 0; + virtual bool readExternalTriggers_ExternalClockSource_AnalogTrigger(unsigned char bitfield_index, tRioStatusCode *status) = 0; + virtual bool readExternalTriggers_RisingEdge(unsigned char bitfield_index, tRioStatusCode *status) = 0; + virtual bool readExternalTriggers_FallingEdge(unsigned char bitfield_index, tRioStatusCode *status) = 0; + + + + +private: + tDMA(const tDMA&); + void operator=(const tDMA&); +}; + +} +} + +#endif // __nFRC_2012_1_6_4_DMA_h__ diff --git a/hal/lib/Athena/FRC_FPGA_ChipObject/nRuntimeFPGANamespace/tEncoder.h b/hal/lib/Athena/FRC_FPGA_ChipObject/nRuntimeFPGANamespace/tEncoder.h new file mode 100644 index 0000000000..7255920278 --- /dev/null +++ b/hal/lib/Athena/FRC_FPGA_ChipObject/nRuntimeFPGANamespace/tEncoder.h @@ -0,0 +1,199 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2012_1_6_4_Encoder_h__ +#define __nFRC_2012_1_6_4_Encoder_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_2012_1_6_4 +{ + +class tEncoder +{ +public: + tEncoder(){} + virtual ~tEncoder(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tEncoder* create(unsigned char sys_index, tRioStatusCode *status); + virtual unsigned char getSystemIndex() = 0; + + + typedef enum + { + kNumSystems = 4, + } tIfaceConstants; + + typedef + union{ + struct{ +#ifdef __vxworks + unsigned Direction : 1; + signed Value : 31; +#else + signed Value : 31; + unsigned Direction : 1; +#endif + }; + struct{ + unsigned value : 32; + }; + } tOutput; + typedef + union{ + struct{ +#ifdef __vxworks + unsigned ASource_Channel : 4; + unsigned ASource_Module : 1; + unsigned ASource_AnalogTrigger : 1; + unsigned BSource_Channel : 4; + unsigned BSource_Module : 1; + unsigned BSource_AnalogTrigger : 1; + unsigned IndexSource_Channel : 4; + unsigned IndexSource_Module : 1; + unsigned IndexSource_AnalogTrigger : 1; + unsigned IndexActiveHigh : 1; + unsigned Reverse : 1; + unsigned Enable : 1; +#else + unsigned Enable : 1; + unsigned Reverse : 1; + unsigned IndexActiveHigh : 1; + unsigned IndexSource_AnalogTrigger : 1; + unsigned IndexSource_Module : 1; + unsigned IndexSource_Channel : 4; + unsigned BSource_AnalogTrigger : 1; + unsigned BSource_Module : 1; + unsigned BSource_Channel : 4; + unsigned ASource_AnalogTrigger : 1; + unsigned ASource_Module : 1; + unsigned ASource_Channel : 4; +#endif + }; + struct{ + unsigned value : 21; + }; + } tConfig; + typedef + union{ + struct{ +#ifdef __vxworks + unsigned Period : 23; + signed Count : 8; + unsigned Stalled : 1; +#else + unsigned Stalled : 1; + signed Count : 8; + unsigned Period : 23; +#endif + }; + struct{ + unsigned value : 32; + }; + } tTimerOutput; + typedef + union{ + struct{ +#ifdef __vxworks + unsigned StallPeriod : 24; + unsigned AverageSize : 7; + unsigned UpdateWhenEmpty : 1; +#else + unsigned UpdateWhenEmpty : 1; + unsigned AverageSize : 7; + unsigned StallPeriod : 24; +#endif + }; + struct{ + unsigned value : 32; + }; + } tTimerConfig; + + + typedef enum + { + } tOutput_IfaceConstants; + + virtual tOutput readOutput(tRioStatusCode *status) = 0; + virtual bool readOutput_Direction(tRioStatusCode *status) = 0; + virtual signed int readOutput_Value(tRioStatusCode *status) = 0; + + + typedef enum + { + } tConfig_IfaceConstants; + + virtual void writeConfig(tConfig value, tRioStatusCode *status) = 0; + virtual void writeConfig_ASource_Channel(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_ASource_Module(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_ASource_AnalogTrigger(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_BSource_Channel(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_BSource_Module(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_BSource_AnalogTrigger(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_IndexSource_Channel(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_IndexSource_Module(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_IndexSource_AnalogTrigger(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_IndexActiveHigh(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Reverse(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable(bool value, tRioStatusCode *status) = 0; + virtual tConfig readConfig(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_ASource_Channel(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_ASource_Module(tRioStatusCode *status) = 0; + virtual bool readConfig_ASource_AnalogTrigger(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_BSource_Channel(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_BSource_Module(tRioStatusCode *status) = 0; + virtual bool readConfig_BSource_AnalogTrigger(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_IndexSource_Channel(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_IndexSource_Module(tRioStatusCode *status) = 0; + virtual bool readConfig_IndexSource_AnalogTrigger(tRioStatusCode *status) = 0; + virtual bool readConfig_IndexActiveHigh(tRioStatusCode *status) = 0; + virtual bool readConfig_Reverse(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable(tRioStatusCode *status) = 0; + + + typedef enum + { + } tTimerOutput_IfaceConstants; + + virtual tTimerOutput readTimerOutput(tRioStatusCode *status) = 0; + virtual unsigned int readTimerOutput_Period(tRioStatusCode *status) = 0; + virtual signed char readTimerOutput_Count(tRioStatusCode *status) = 0; + virtual bool readTimerOutput_Stalled(tRioStatusCode *status) = 0; + + + typedef enum + { + } tReset_IfaceConstants; + + virtual void strobeReset(tRioStatusCode *status) = 0; + + + typedef enum + { + } tTimerConfig_IfaceConstants; + + virtual void writeTimerConfig(tTimerConfig value, tRioStatusCode *status) = 0; + virtual void writeTimerConfig_StallPeriod(unsigned int value, tRioStatusCode *status) = 0; + virtual void writeTimerConfig_AverageSize(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeTimerConfig_UpdateWhenEmpty(bool value, tRioStatusCode *status) = 0; + virtual tTimerConfig readTimerConfig(tRioStatusCode *status) = 0; + virtual unsigned int readTimerConfig_StallPeriod(tRioStatusCode *status) = 0; + virtual unsigned char readTimerConfig_AverageSize(tRioStatusCode *status) = 0; + virtual bool readTimerConfig_UpdateWhenEmpty(tRioStatusCode *status) = 0; + + + + + +private: + tEncoder(const tEncoder&); + void operator=(const tEncoder&); +}; + +} +} + +#endif // __nFRC_2012_1_6_4_Encoder_h__ diff --git a/hal/lib/Athena/FRC_FPGA_ChipObject/nRuntimeFPGANamespace/tGlobal.h b/hal/lib/Athena/FRC_FPGA_ChipObject/nRuntimeFPGANamespace/tGlobal.h new file mode 100644 index 0000000000..0782f35109 --- /dev/null +++ b/hal/lib/Athena/FRC_FPGA_ChipObject/nRuntimeFPGANamespace/tGlobal.h @@ -0,0 +1,70 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2012_1_6_4_Global_h__ +#define __nFRC_2012_1_6_4_Global_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_2012_1_6_4 +{ + +class tGlobal +{ +public: + tGlobal(){} + virtual ~tGlobal(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tGlobal* create(tRioStatusCode *status); + + typedef enum + { + kNumSystems = 1, + } tIfaceConstants; + + + + + typedef enum + { + } tVersion_IfaceConstants; + + virtual unsigned short readVersion(tRioStatusCode *status) = 0; + + + typedef enum + { + } tLocalTime_IfaceConstants; + + virtual unsigned int readLocalTime(tRioStatusCode *status) = 0; + + + typedef enum + { + } tFPGA_LED_IfaceConstants; + + virtual void writeFPGA_LED(bool value, tRioStatusCode *status) = 0; + virtual bool readFPGA_LED(tRioStatusCode *status) = 0; + + + typedef enum + { + } tRevision_IfaceConstants; + + virtual unsigned int readRevision(tRioStatusCode *status) = 0; + + + + +private: + tGlobal(const tGlobal&); + void operator=(const tGlobal&); +}; + +} +} + +#endif // __nFRC_2012_1_6_4_Global_h__ diff --git a/hal/lib/Athena/FRC_FPGA_ChipObject/nRuntimeFPGANamespace/tInterrupt.h b/hal/lib/Athena/FRC_FPGA_ChipObject/nRuntimeFPGANamespace/tInterrupt.h new file mode 100644 index 0000000000..40186e539d --- /dev/null +++ b/hal/lib/Athena/FRC_FPGA_ChipObject/nRuntimeFPGANamespace/tInterrupt.h @@ -0,0 +1,93 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2012_1_6_4_Interrupt_h__ +#define __nFRC_2012_1_6_4_Interrupt_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_2012_1_6_4 +{ + +class tInterrupt +{ +public: + tInterrupt(){} + virtual ~tInterrupt(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tInterrupt* create(unsigned char sys_index, tRioStatusCode *status); + virtual unsigned char getSystemIndex() = 0; + + + typedef enum + { + kNumSystems = 8, + } tIfaceConstants; + + typedef + union{ + struct{ +#ifdef __vxworks + unsigned Source_Channel : 4; + unsigned Source_Module : 1; + unsigned Source_AnalogTrigger : 1; + unsigned RisingEdge : 1; + unsigned FallingEdge : 1; + unsigned WaitForAck : 1; +#else + unsigned WaitForAck : 1; + unsigned FallingEdge : 1; + unsigned RisingEdge : 1; + unsigned Source_AnalogTrigger : 1; + unsigned Source_Module : 1; + unsigned Source_Channel : 4; +#endif + }; + struct{ + unsigned value : 9; + }; + } tConfig; + + + typedef enum + { + } tTimeStamp_IfaceConstants; + + virtual unsigned int readTimeStamp(tRioStatusCode *status) = 0; + + + typedef enum + { + } tConfig_IfaceConstants; + + virtual void writeConfig(tConfig value, tRioStatusCode *status) = 0; + virtual void writeConfig_Source_Channel(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_Source_Module(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_Source_AnalogTrigger(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_RisingEdge(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_FallingEdge(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_WaitForAck(bool value, tRioStatusCode *status) = 0; + virtual tConfig readConfig(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_Source_Channel(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_Source_Module(tRioStatusCode *status) = 0; + virtual bool readConfig_Source_AnalogTrigger(tRioStatusCode *status) = 0; + virtual bool readConfig_RisingEdge(tRioStatusCode *status) = 0; + virtual bool readConfig_FallingEdge(tRioStatusCode *status) = 0; + virtual bool readConfig_WaitForAck(tRioStatusCode *status) = 0; + + + + + +private: + tInterrupt(const tInterrupt&); + void operator=(const tInterrupt&); +}; + +} +} + +#endif // __nFRC_2012_1_6_4_Interrupt_h__ diff --git a/hal/lib/Athena/FRC_FPGA_ChipObject/nRuntimeFPGANamespace/tSPI.h b/hal/lib/Athena/FRC_FPGA_ChipObject/nRuntimeFPGANamespace/tSPI.h new file mode 100644 index 0000000000..45c208c6ed --- /dev/null +++ b/hal/lib/Athena/FRC_FPGA_ChipObject/nRuntimeFPGANamespace/tSPI.h @@ -0,0 +1,228 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2012_1_6_4_SPI_h__ +#define __nFRC_2012_1_6_4_SPI_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_2012_1_6_4 +{ + +class tSPI +{ +public: + tSPI(){} + virtual ~tSPI(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tSPI* create(tRioStatusCode *status); + + typedef enum + { + kNumSystems = 1, + } tIfaceConstants; + + typedef + union{ + struct{ +#ifdef __vxworks + unsigned ReceivedDataOverflow : 1; + unsigned Idle : 1; +#else + unsigned Idle : 1; + unsigned ReceivedDataOverflow : 1; +#endif + }; + struct{ + unsigned value : 2; + }; + } tStatus; + typedef + union{ + struct{ +#ifdef __vxworks + unsigned BusBitWidth : 8; + unsigned ClockHalfPeriodDelay : 8; + unsigned MSBfirst : 1; + unsigned DataOnFalling : 1; + unsigned LatchFirst : 1; + unsigned LatchLast : 1; + unsigned FramePolarity : 1; + unsigned WriteOnly : 1; + unsigned ClockPolarity : 1; +#else + unsigned ClockPolarity : 1; + unsigned WriteOnly : 1; + unsigned FramePolarity : 1; + unsigned LatchLast : 1; + unsigned LatchFirst : 1; + unsigned DataOnFalling : 1; + unsigned MSBfirst : 1; + unsigned ClockHalfPeriodDelay : 8; + unsigned BusBitWidth : 8; +#endif + }; + struct{ + unsigned value : 23; + }; + } tConfig; + typedef + union{ + struct{ +#ifdef __vxworks + unsigned SCLK_Channel : 4; + unsigned SCLK_Module : 1; + unsigned MOSI_Channel : 4; + unsigned MOSI_Module : 1; + unsigned MISO_Channel : 4; + unsigned MISO_Module : 1; + unsigned SS_Channel : 4; + unsigned SS_Module : 1; +#else + unsigned SS_Module : 1; + unsigned SS_Channel : 4; + unsigned MISO_Module : 1; + unsigned MISO_Channel : 4; + unsigned MOSI_Module : 1; + unsigned MOSI_Channel : 4; + unsigned SCLK_Module : 1; + unsigned SCLK_Channel : 4; +#endif + }; + struct{ + unsigned value : 20; + }; + } tChannels; + + + + typedef enum + { + } tStatus_IfaceConstants; + + virtual tStatus readStatus(tRioStatusCode *status) = 0; + virtual bool readStatus_ReceivedDataOverflow(tRioStatusCode *status) = 0; + virtual bool readStatus_Idle(tRioStatusCode *status) = 0; + + + typedef enum + { + } tReceivedData_IfaceConstants; + + virtual unsigned int readReceivedData(tRioStatusCode *status) = 0; + + + typedef enum + { + } tDataToLoad_IfaceConstants; + + virtual void writeDataToLoad(unsigned int value, tRioStatusCode *status) = 0; + virtual unsigned int readDataToLoad(tRioStatusCode *status) = 0; + + + typedef enum + { + } tConfig_IfaceConstants; + + virtual void writeConfig(tConfig value, tRioStatusCode *status) = 0; + virtual void writeConfig_BusBitWidth(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_ClockHalfPeriodDelay(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_MSBfirst(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_DataOnFalling(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_LatchFirst(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_LatchLast(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_FramePolarity(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_WriteOnly(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_ClockPolarity(bool value, tRioStatusCode *status) = 0; + virtual tConfig readConfig(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_BusBitWidth(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_ClockHalfPeriodDelay(tRioStatusCode *status) = 0; + virtual bool readConfig_MSBfirst(tRioStatusCode *status) = 0; + virtual bool readConfig_DataOnFalling(tRioStatusCode *status) = 0; + virtual bool readConfig_LatchFirst(tRioStatusCode *status) = 0; + virtual bool readConfig_LatchLast(tRioStatusCode *status) = 0; + virtual bool readConfig_FramePolarity(tRioStatusCode *status) = 0; + virtual bool readConfig_WriteOnly(tRioStatusCode *status) = 0; + virtual bool readConfig_ClockPolarity(tRioStatusCode *status) = 0; + + + typedef enum + { + } tClearReceivedData_IfaceConstants; + + virtual void strobeClearReceivedData(tRioStatusCode *status) = 0; + + + typedef enum + { + } tReceivedElements_IfaceConstants; + + virtual unsigned short readReceivedElements(tRioStatusCode *status) = 0; + + + typedef enum + { + } tLoad_IfaceConstants; + + virtual void strobeLoad(tRioStatusCode *status) = 0; + + + typedef enum + { + } tReset_IfaceConstants; + + virtual void strobeReset(tRioStatusCode *status) = 0; + + + typedef enum + { + } tChannels_IfaceConstants; + + virtual void writeChannels(tChannels value, tRioStatusCode *status) = 0; + virtual void writeChannels_SCLK_Channel(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeChannels_SCLK_Module(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeChannels_MOSI_Channel(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeChannels_MOSI_Module(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeChannels_MISO_Channel(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeChannels_MISO_Module(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeChannels_SS_Channel(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeChannels_SS_Module(unsigned char value, tRioStatusCode *status) = 0; + virtual tChannels readChannels(tRioStatusCode *status) = 0; + virtual unsigned char readChannels_SCLK_Channel(tRioStatusCode *status) = 0; + virtual unsigned char readChannels_SCLK_Module(tRioStatusCode *status) = 0; + virtual unsigned char readChannels_MOSI_Channel(tRioStatusCode *status) = 0; + virtual unsigned char readChannels_MOSI_Module(tRioStatusCode *status) = 0; + virtual unsigned char readChannels_MISO_Channel(tRioStatusCode *status) = 0; + virtual unsigned char readChannels_MISO_Module(tRioStatusCode *status) = 0; + virtual unsigned char readChannels_SS_Channel(tRioStatusCode *status) = 0; + virtual unsigned char readChannels_SS_Module(tRioStatusCode *status) = 0; + + + typedef enum + { + } tAvailableToLoad_IfaceConstants; + + virtual unsigned short readAvailableToLoad(tRioStatusCode *status) = 0; + + + typedef enum + { + } tReadReceivedData_IfaceConstants; + + virtual void strobeReadReceivedData(tRioStatusCode *status) = 0; + + + + +private: + tSPI(const tSPI&); + void operator=(const tSPI&); +}; + +} +} + +#endif // __nFRC_2012_1_6_4_SPI_h__ diff --git a/hal/lib/Athena/ChipObject/tSolenoid.h b/hal/lib/Athena/FRC_FPGA_ChipObject/nRuntimeFPGANamespace/tSolenoid.h similarity index 100% rename from hal/lib/Athena/ChipObject/tSolenoid.h rename to hal/lib/Athena/FRC_FPGA_ChipObject/nRuntimeFPGANamespace/tSolenoid.h diff --git a/hal/lib/Athena/FRC_FPGA_ChipObject/nRuntimeFPGANamespace/tSysWatchdog.h b/hal/lib/Athena/FRC_FPGA_ChipObject/nRuntimeFPGANamespace/tSysWatchdog.h new file mode 100644 index 0000000000..2ef01ffbc4 --- /dev/null +++ b/hal/lib/Athena/FRC_FPGA_ChipObject/nRuntimeFPGANamespace/tSysWatchdog.h @@ -0,0 +1,71 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2012_1_6_4_SysWatchdog_h__ +#define __nFRC_2012_1_6_4_SysWatchdog_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_2012_1_6_4 +{ + +class tSysWatchdog +{ +public: + tSysWatchdog(){} + virtual ~tSysWatchdog(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tSysWatchdog* create(tRioStatusCode *status); + + typedef enum + { + kNumSystems = 1, + } tIfaceConstants; + + + + + typedef enum + { + } tCommand_IfaceConstants; + + virtual void writeCommand(unsigned short value, tRioStatusCode *status) = 0; + virtual unsigned short readCommand(tRioStatusCode *status) = 0; + + + typedef enum + { + } tChallenge_IfaceConstants; + + virtual unsigned char readChallenge(tRioStatusCode *status) = 0; + + + typedef enum + { + } tActive_IfaceConstants; + + virtual void writeActive(bool value, tRioStatusCode *status) = 0; + virtual bool readActive(tRioStatusCode *status) = 0; + + + typedef enum + { + } tTimer_IfaceConstants; + + virtual unsigned int readTimer(tRioStatusCode *status) = 0; + + + + +private: + tSysWatchdog(const tSysWatchdog&); + void operator=(const tSysWatchdog&); +}; + +} +} + +#endif // __nFRC_2012_1_6_4_SysWatchdog_h__ diff --git a/hal/lib/Athena/ChipObject/tWatchdog.h b/hal/lib/Athena/FRC_FPGA_ChipObject/nRuntimeFPGANamespace/tWatchdog.h similarity index 100% rename from hal/lib/Athena/ChipObject/tWatchdog.h rename to hal/lib/Athena/FRC_FPGA_ChipObject/nRuntimeFPGANamespace/tWatchdog.h diff --git a/hal/lib/Athena/ChipObject/printFpgaVersion.h b/hal/lib/Athena/FRC_FPGA_ChipObject/printFpgaVersion.h similarity index 100% rename from hal/lib/Athena/ChipObject/printFpgaVersion.h rename to hal/lib/Athena/FRC_FPGA_ChipObject/printFpgaVersion.h diff --git a/hal/lib/Athena/ChipObject/tDMAManager.h b/hal/lib/Athena/FRC_FPGA_ChipObject/tDMAManager.h similarity index 100% rename from hal/lib/Athena/ChipObject/tDMAManager.h rename to hal/lib/Athena/FRC_FPGA_ChipObject/tDMAManager.h diff --git a/hal/lib/Athena/ChipObject/tInterruptManager.h b/hal/lib/Athena/FRC_FPGA_ChipObject/tInterruptManager.h similarity index 100% rename from hal/lib/Athena/ChipObject/tInterruptManager.h rename to hal/lib/Athena/FRC_FPGA_ChipObject/tInterruptManager.h diff --git a/hal/lib/Athena/ChipObject/tSystem.h b/hal/lib/Athena/FRC_FPGA_ChipObject/tSystem.h similarity index 100% rename from hal/lib/Athena/ChipObject/tSystem.h rename to hal/lib/Athena/FRC_FPGA_ChipObject/tSystem.h diff --git a/hal/lib/Athena/ChipObject/tSystemInterface.h b/hal/lib/Athena/FRC_FPGA_ChipObject/tSystemInterface.h similarity index 70% rename from hal/lib/Athena/ChipObject/tSystemInterface.h rename to hal/lib/Athena/FRC_FPGA_ChipObject/tSystemInterface.h index 4a80b0a7f6..ce7eb9b7ba 100644 --- a/hal/lib/Athena/ChipObject/tSystemInterface.h +++ b/hal/lib/Athena/FRC_FPGA_ChipObject/tSystemInterface.h @@ -12,9 +12,9 @@ public: tSystemInterface(){} virtual ~tSystemInterface(){} - virtual uint16_t getExpectedFPGAVersion()=0; - virtual uint32_t getExpectedFPGARevision()=0; - virtual uint32_t * getExpectedFPGASignature()=0; + virtual const uint16_t getExpectedFPGAVersion()=0; + virtual const uint32_t getExpectedFPGARevision()=0; + virtual const uint32_t * const getExpectedFPGASignature()=0; virtual void getHardwareFpgaSignature(uint32_t *guid_ptr, tRioStatusCode *status)=0; virtual uint32_t getLVHandle(tRioStatusCode *status)=0; virtual uint32_t getHandle()=0; @@ -23,4 +23,3 @@ public: } #endif // __tSystemInterface_h__ - diff --git a/hal/lib/Athena/HAL.cpp b/hal/lib/Athena/HAL.cpp index 63bc412bba..c4798897c7 100644 --- a/hal/lib/Athena/HAL.cpp +++ b/hal/lib/Athena/HAL.cpp @@ -6,7 +6,6 @@ #include "NetworkCommunication/FRCComm.h" #include "NetworkCommunication/UsageReporting.h" #include "NetworkCommunication/LoadOut.h" -#include "ChipObject/nInterfaceGlobals.h" #include #include #include @@ -116,26 +115,24 @@ int HALSetErrorData(const char *errors, int errorsLength, int wait_ms) return setErrorData(errors, errorsLength, wait_ms); } -int HALSetUserDsLcdData(const char *userDsLcdData, int userDsLcdDataLength, - int wait_ms) +int HALGetControlWord(HALControlWord *data) { - return setUserDsLcdData(userDsLcdData, userDsLcdDataLength, wait_ms); + return FRC_NetworkCommunication_getControlWord((ControlWord_t*) data); } -int HALOverrideIOConfig(const char *ioConfig, int wait_ms) +int HALGetAllianceStation(enum HALAllianceStationID *allianceStation) { - return overrideIOConfig(ioConfig, wait_ms); + return FRC_NetworkCommunication_getAllianceStation((AllianceStationID_t*) allianceStation); } -int HALGetDynamicControlData(uint8_t type, char *dynamicData, int32_t maxLength, - int wait_ms) +int HALGetJoystickAxes(uint8_t joystickNum, HALJoystickAxes *axes, uint8_t maxAxes) { - return getDynamicControlData(type, dynamicData, maxLength, wait_ms); + return FRC_NetworkCommunication_getJoystickAxes(joystickNum, (JoystickAxes_t*) axes, maxAxes); } -int HALGetCommonControlData(HALCommonControlData *data, int wait_ms) +int HALGetJoystickButtons(uint8_t joystickNum, HALJoystickButtons *buttons, uint8_t *count) { - return getRecentCommonControlData((FRCCommonControlData*) data, wait_ms); + return FRC_NetworkCommunication_getJoystickButtons(joystickNum, buttons, count); } void HALSetNewDataSem(pthread_mutex_t * param) @@ -240,8 +237,12 @@ void HALNetworkCommunicationObserveUserProgramTest(void) uint32_t HALReport(uint8_t resource, uint8_t instanceNumber, uint8_t context, const char *feature) { - //return FRC_NetworkCommunication_nUsageReporting_report( resource, instanceNumber, context, feature); - return 0; + if(feature == NULL) + { + feature = ""; + } + + return FRC_NetworkCommunication_nUsageReporting_report(resource, instanceNumber, context, feature); } // TODO: HACKS @@ -267,12 +268,3 @@ void imaqGetLastError() void niTimestamp64() { } - -#include "NetworkCommunication/LoadOut.h" -namespace nLoadOut -{ -bool getModulePresence(tModuleType moduleType, uint8_t moduleNumber) -{ - return true; -} -} diff --git a/hal/lib/Athena/NetworkCommunication/CANInterfacePlugin.h b/hal/lib/Athena/NetworkCommunication/CANInterfacePlugin.h index bf0abef86a..f4c4064dc6 100644 --- a/hal/lib/Athena/NetworkCommunication/CANInterfacePlugin.h +++ b/hal/lib/Athena/NetworkCommunication/CANInterfacePlugin.h @@ -50,6 +50,23 @@ public: * @return This should return 0 if a message was populated, non-0 if no message was not populated. */ virtual int32_t receiveMessage(uint32_t &messageID, uint8_t *data, uint8_t &dataSize) = 0; + + /** + * This entry-point of the CANInterfacePlugin returns status of the CAN bus. + * + * This function may be called from multiple contexts and must therefore be reentrant. + * + * This function will return detailed hardware status if available for diagnostics of the CAN interface. + * + * @param busOffCount The number of times that sendMessage failed with a busOff error indicating that messages + * are not successfully transmitted on the bus. + * @param txFullCount The number of times that sendMessage failed with a txFifoFull error indicating that messages + * are not successfully received by any CAN device. + * @param receiveErrorCount The count of receive errors as reported by the CAN driver. + * @param transmitErrorCount The count of transmit errors as reported by the CAN driver. + * @return This should return 0 if all status was retrieved successfully or an error code if not. + */ + virtual int32_t getStatus(uint32_t &busOffCount, uint32_t &txFullCount, uint32_t &receiveErrorCount, uint32_t &transmitErrorCount) {return 0;} }; /** diff --git a/hal/lib/Athena/NetworkCommunication/CANSessionMux.h b/hal/lib/Athena/NetworkCommunication/CANSessionMux.h index d31c76c1a2..81f63c579f 100644 --- a/hal/lib/Athena/NetworkCommunication/CANSessionMux.h +++ b/hal/lib/Athena/NetworkCommunication/CANSessionMux.h @@ -41,6 +41,7 @@ namespace nCANSessionMux void openStreamSession(uint32_t *sessionHandle, uint32_t messageID, uint32_t messageIDMask, uint32_t maxMessages, int32_t *status); void closeStreamSession(uint32_t sessionHandle); void readStreamSession(uint32_t sessionHandle, struct tCANStreamMessage *messages, uint32_t messagesToRead, uint32_t *messagesRead, int32_t *status); + void getCANStatus(float *percentBusUtilization, uint32_t *busOffCount, uint32_t *txFullCount, uint32_t *receiveErrorCount, uint32_t *transmitErrorCount, int32_t *status); } #ifdef __cplusplus @@ -53,6 +54,7 @@ extern "C" void FRC_NetworkCommunication_CANSessionMux_openStreamSession(uint32_t *sessionHandle, uint32_t messageID, uint32_t messageIDMask, uint32_t maxMessages, int32_t *status); void FRC_NetworkCommunication_CANSessionMux_closeStreamSession(uint32_t sessionHandle); void FRC_NetworkCommunication_CANSessionMux_readStreamSession(uint32_t sessionHandle, struct tCANStreamMessage *messages, uint32_t messagesToRead, uint32_t *messagesRead, int32_t *status); + void FRC_NetworkCommunication_CANSessionMux_getCANStatus(float *percentBusUtilization, uint32_t *busOffCount, uint32_t *txFullCount, uint32_t *receiveErrorCount, uint32_t *transmitErrorCount, int32_t *status); #ifdef __cplusplus } diff --git a/hal/lib/Athena/NetworkCommunication/FRCComm.h b/hal/lib/Athena/NetworkCommunication/FRCComm.h index 4d40d237d4..51d8488491 100644 --- a/hal/lib/Athena/NetworkCommunication/FRCComm.h +++ b/hal/lib/Athena/NetworkCommunication/FRCComm.h @@ -32,133 +32,52 @@ #endif #endif -// Commandeer some bytes at the end for advanced I/O feedback. -#define IO_CONFIG_DATA_SIZE 32 -#define SYS_STATUS_DATA_SIZE 44 -#define USER_STATUS_DATA_SIZE (984 - IO_CONFIG_DATA_SIZE - SYS_STATUS_DATA_SIZE) -#define USER_DS_LCD_DATA_SIZE 128 - -struct FRCCommonControlData{ - uint16_t packetIndex; - union { - uint8_t control; -#ifndef __vxworks - struct { - uint8_t checkVersions :1; - uint8_t test :1; - uint8_t resync : 1; - uint8_t fmsAttached:1; - uint8_t autonomous : 1; - uint8_t enabled : 1; - uint8_t notEStop : 1; - uint8_t reset : 1; - }; -#else - struct { - uint8_t reset : 1; - uint8_t notEStop : 1; - uint8_t enabled : 1; - uint8_t autonomous : 1; - uint8_t fmsAttached:1; - uint8_t resync : 1; - uint8_t test :1; - uint8_t checkVersions :1; - }; -#endif - }; - uint8_t dsDigitalIn; - uint16_t teamID; - - char dsID_Alliance; - char dsID_Position; - - union { - int8_t stick0Axes[6]; - struct { - int8_t stick0Axis1; - int8_t stick0Axis2; - int8_t stick0Axis3; - int8_t stick0Axis4; - int8_t stick0Axis5; - int8_t stick0Axis6; - }; - }; - uint16_t stick0Buttons; // Left-most 4 bits are unused - - union { - int8_t stick1Axes[6]; - struct { - int8_t stick1Axis1; - int8_t stick1Axis2; - int8_t stick1Axis3; - int8_t stick1Axis4; - int8_t stick1Axis5; - int8_t stick1Axis6; - }; - }; - uint16_t stick1Buttons; // Left-most 4 bits are unused - - union { - int8_t stick2Axes[6]; - struct { - int8_t stick2Axis1; - int8_t stick2Axis2; - int8_t stick2Axis3; - int8_t stick2Axis4; - int8_t stick2Axis5; - int8_t stick2Axis6; - }; - }; - uint16_t stick2Buttons; // Left-most 4 bits are unused - - union { - int8_t stick3Axes[6]; - struct { - int8_t stick3Axis1; - int8_t stick3Axis2; - int8_t stick3Axis3; - int8_t stick3Axis4; - int8_t stick3Axis5; - int8_t stick3Axis6; - }; - }; - uint16_t stick3Buttons; // Left-most 4 bits are unused - - //Analog inputs are 10 bit right-justified - uint16_t analog1; - uint16_t analog2; - uint16_t analog3; - uint16_t analog4; - - uint64_t cRIOChecksum; - uint32_t FPGAChecksum0; - uint32_t FPGAChecksum1; - uint32_t FPGAChecksum2; - uint32_t FPGAChecksum3; - - char versionData[8]; +enum AllianceStationID_t { + kAllianceStationID_red1, + kAllianceStationID_red2, + kAllianceStationID_red3, + kAllianceStationID_blue1, + kAllianceStationID_blue2, + kAllianceStationID_blue3, }; -#define kFRC_NetworkCommunication_DynamicType_DSEnhancedIO_Input 17 -#define kFRC_NetworkCommunication_DynamicType_DSEnhancedIO_Output 18 -#define kFRC_NetworkCommunication_DynamicType_Kinect_Header 19 -#define kFRC_NetworkCommunication_DynamicType_Kinect_Extra1 20 -#define kFRC_NetworkCommunication_DynamicType_Kinect_Vertices1 21 -#define kFRC_NetworkCommunication_DynamicType_Kinect_Extra2 22 -#define kFRC_NetworkCommunication_DynamicType_Kinect_Vertices2 23 -#define kFRC_NetworkCommunication_DynamicType_Kinect_Joystick 24 -#define kFRC_NetworkCommunication_DynamicType_Kinect_Custom 25 +struct ControlWord_t { +#ifndef __vxworks + uint32_t enabled : 1; + uint32_t autonomous : 1; + uint32_t test :1; + uint32_t eStop : 1; + uint32_t fmsAttached:1; + uint32_t dsAttached:1; + uint32_t control_reserved : 26; +#else + uint32_t control_reserved : 26; + uint32_t dsAttached:1; + uint32_t fmsAttached:1; + uint32_t eStop : 1; + uint32_t test :1; + uint32_t autonomous : 1; + uint32_t enabled : 1; +#endif +}; + +struct JoystickAxes_t { + uint16_t count; + int16_t axes[1]; +}; + +struct JoystickPOV_t { + uint16_t count; + uint16_t povs[1]; +}; #ifdef __cplusplus extern "C" { #endif + int EXPORT_FUNC FRC_NetworkCommunication_Reserve(void *instance); #ifndef SIMULATION void EXPORT_FUNC getFPGAHardwareVersion(uint16_t *fpgaVersion, uint32_t *fpgaRevision); #endif - int EXPORT_FUNC getCommonControlData(struct FRCCommonControlData *data, int wait_ms); - int EXPORT_FUNC getRecentCommonControlData(struct FRCCommonControlData *commonData, int wait_ms); - int EXPORT_FUNC getRecentStatusData(uint8_t *batteryInt, uint8_t *batteryDec, uint8_t *dsDigitalOut, int wait_ms); - int EXPORT_FUNC getDynamicControlData(uint8_t type, char *dynamicData, int32_t maxLength, int wait_ms); int EXPORT_FUNC setStatusData(float battery, uint8_t dsDigitalOut, uint8_t updateNumber, const char *userDataHigh, int userDataHighLength, const char *userDataLow, int userDataLowLength, int wait_ms); @@ -166,30 +85,28 @@ extern "C" { const char *userDataHigh, int userDataHighLength, const char *userDataLow, int userDataLowLength, int wait_ms); int EXPORT_FUNC setErrorData(const char *errors, int errorsLength, int wait_ms); - int EXPORT_FUNC setUserDsLcdData(const char *userDsLcdData, int userDsLcdDataLength, int wait_ms); - int EXPORT_FUNC overrideIOConfig(const char *ioConfig, int wait_ms); #ifdef SIMULATION void EXPORT_FUNC setNewDataSem(HANDLE); #else # if defined (__vxworks) void EXPORT_FUNC setNewDataSem(SEM_ID); - void EXPORT_FUNC setResyncSem(SEM_ID); # else void EXPORT_FUNC setNewDataSem(pthread_mutex_t *); - void EXPORT_FUNC setResyncSem(pthread_mutex_t *); # endif - void EXPORT_FUNC signalResyncActionDone(void); #endif // this uint32_t is really a LVRefNum - void EXPORT_FUNC setNewDataOccurRef(uint32_t refnum); -#ifndef SIMULATION - void EXPORT_FUNC setResyncOccurRef(uint32_t refnum); -#endif + int EXPORT_FUNC setNewDataOccurRef(uint32_t refnum); + + int EXPORT_FUNC FRC_NetworkCommunication_getControlWord(struct ControlWord_t *controlWord); + int EXPORT_FUNC FRC_NetworkCommunication_getAllianceStation(enum AllianceStationID_t *allianceStation); + int EXPORT_FUNC FRC_NetworkCommunication_getJoystickAxes(uint8_t joystickNum, struct JoystickAxes_t *axes, uint8_t maxAxes); + int EXPORT_FUNC FRC_NetworkCommunication_getJoystickButtons(uint8_t joystickNum, uint32_t *buttons, uint8_t *count); + int EXPORT_FUNC FRC_NetworkCommunication_getJoystickPOVs(uint8_t joystickNum, struct JoystickPOV_t *povs, uint8_t maxPOVs); void EXPORT_FUNC FRC_NetworkCommunication_getVersionString(char *version); - void EXPORT_FUNC FRC_NetworkCommunication_observeUserProgramStarting(void); + int EXPORT_FUNC FRC_NetworkCommunication_observeUserProgramStarting(void); void EXPORT_FUNC FRC_NetworkCommunication_observeUserProgramDisabled(void); void EXPORT_FUNC FRC_NetworkCommunication_observeUserProgramAutonomous(void); void EXPORT_FUNC FRC_NetworkCommunication_observeUserProgramTeleop(void); diff --git a/hal/lib/Athena/NetworkCommunication/LoadOut.h b/hal/lib/Athena/NetworkCommunication/LoadOut.h index 2433b0cc71..fce88a28e2 100644 --- a/hal/lib/Athena/NetworkCommunication/LoadOut.h +++ b/hal/lib/Athena/NetworkCommunication/LoadOut.h @@ -16,6 +16,7 @@ #define kMaxModuleNumber 2 namespace nLoadOut { +#if defined(__vxworks) || defined(SIMULATION) typedef enum { kModuleType_Unknown = 0x00, kModuleType_Analog = 0x01, @@ -23,15 +24,18 @@ namespace nLoadOut kModuleType_Solenoid = 0x03, } tModuleType; bool EXPORT_FUNC getModulePresence(tModuleType moduleType, uint8_t moduleNumber); +#endif typedef enum { kTargetClass_Unknown = 0x00, kTargetClass_FRC1 = 0x10, kTargetClass_FRC2 = 0x20, kTargetClass_FRC3 = 0x30, kTargetClass_RoboRIO = 0x40, +#if defined(__vxworks) || defined(SIMULATION) kTargetClass_FRC2_Analog = kTargetClass_FRC2 | kModuleType_Analog, kTargetClass_FRC2_Digital = kTargetClass_FRC2 | kModuleType_Digital, kTargetClass_FRC2_Solenoid = kTargetClass_FRC2 | kModuleType_Solenoid, +#endif kTargetClass_FamilyMask = 0xF0, kTargetClass_ModuleMask = 0x0F, } tTargetClass; @@ -42,7 +46,9 @@ namespace nLoadOut extern "C" { #endif +#if defined(__vxworks) || defined(SIMULATION) uint32_t EXPORT_FUNC FRC_NetworkCommunication_nLoadOut_getModulePresence(uint32_t moduleType, uint8_t moduleNumber); +#endif uint32_t EXPORT_FUNC FRC_NetworkCommunication_nLoadOut_getTargetClass(); #ifdef __cplusplus diff --git a/ni-libraries/libFRC_FPGA_ChipObject.so b/ni-libraries/libFRC_FPGA_ChipObject.so deleted file mode 100755 index 51f6d195ae..0000000000 Binary files a/ni-libraries/libFRC_FPGA_ChipObject.so and /dev/null differ diff --git a/ni-libraries/libFRC_FPGA_ChipObject.so.1 b/ni-libraries/libFRC_FPGA_ChipObject.so.1 deleted file mode 100755 index 51f6d195ae..0000000000 Binary files a/ni-libraries/libFRC_FPGA_ChipObject.so.1 and /dev/null differ diff --git a/ni-libraries/libFRC_NetworkCommunication.so b/ni-libraries/libFRC_NetworkCommunication.so old mode 100755 new mode 100644 index 90c9f86fe0..a24218eec1 Binary files a/ni-libraries/libFRC_NetworkCommunication.so and b/ni-libraries/libFRC_NetworkCommunication.so differ diff --git a/ni-libraries/libFRC_NetworkCommunication.so.1 b/ni-libraries/libFRC_NetworkCommunication.so.1 old mode 100755 new mode 100644 index 90c9f86fe0..e1ec38ab36 Binary files a/ni-libraries/libFRC_NetworkCommunication.so.1 and b/ni-libraries/libFRC_NetworkCommunication.so.1 differ diff --git a/ni-libraries/libFRC_NetworkCommunication.so.1.5 b/ni-libraries/libFRC_NetworkCommunication.so.1.5 new file mode 100644 index 0000000000..845c7599a5 --- /dev/null +++ b/ni-libraries/libFRC_NetworkCommunication.so.1.5 @@ -0,0 +1,2 @@ +OUTPUT_FORMAT(elf32-littlearm) +GROUP ( libFRC_NetworkCommunication.so.1.5.0 ) diff --git a/ni-libraries/libFRC_NetworkCommunication.so.1.5.0 b/ni-libraries/libFRC_NetworkCommunication.so.1.5.0 new file mode 100755 index 0000000000..15c2a83a7f Binary files /dev/null and b/ni-libraries/libFRC_NetworkCommunication.so.1.5.0 differ diff --git a/ni-libraries/libFRC_NetworkCommunicationLV.so b/ni-libraries/libFRC_NetworkCommunicationLV.so new file mode 100644 index 0000000000..c7c2653383 --- /dev/null +++ b/ni-libraries/libFRC_NetworkCommunicationLV.so @@ -0,0 +1,2 @@ +OUTPUT_FORMAT(elf32-littlearm) +GROUP ( libFRC_NetworkCommunicationLV.so.1 ) diff --git a/ni-libraries/libFRC_NetworkCommunicationLV.so.1 b/ni-libraries/libFRC_NetworkCommunicationLV.so.1 new file mode 100644 index 0000000000..1254b6d71d --- /dev/null +++ b/ni-libraries/libFRC_NetworkCommunicationLV.so.1 @@ -0,0 +1,2 @@ +OUTPUT_FORMAT(elf32-littlearm) +GROUP ( libFRC_NetworkCommunicationLV.so.1.5 ) diff --git a/ni-libraries/libFRC_NetworkCommunicationLV.so.1.5 b/ni-libraries/libFRC_NetworkCommunicationLV.so.1.5 new file mode 100644 index 0000000000..30022dbed4 --- /dev/null +++ b/ni-libraries/libFRC_NetworkCommunicationLV.so.1.5 @@ -0,0 +1,2 @@ +OUTPUT_FORMAT(elf32-littlearm) +GROUP ( libFRC_NetworkCommunicationLV.so.1.5.0 ) diff --git a/ni-libraries/libFRC_NetworkCommunicationLV.so.1.5.0 b/ni-libraries/libFRC_NetworkCommunicationLV.so.1.5.0 new file mode 100755 index 0000000000..60c079c67b Binary files /dev/null and b/ni-libraries/libFRC_NetworkCommunicationLV.so.1.5.0 differ diff --git a/ni-libraries/libRoboRIO_FRC_ChipObject.so b/ni-libraries/libRoboRIO_FRC_ChipObject.so old mode 100755 new mode 100644 index 5281f6379b..b44dc03baf Binary files a/ni-libraries/libRoboRIO_FRC_ChipObject.so and b/ni-libraries/libRoboRIO_FRC_ChipObject.so differ diff --git a/ni-libraries/libRoboRIO_FRC_ChipObject.so.1 b/ni-libraries/libRoboRIO_FRC_ChipObject.so.1 old mode 100755 new mode 100644 index 5281f6379b..fff4f97abe Binary files a/ni-libraries/libRoboRIO_FRC_ChipObject.so.1 and b/ni-libraries/libRoboRIO_FRC_ChipObject.so.1 differ diff --git a/ni-libraries/libRoboRIO_FRC_ChipObject.so.1.2 b/ni-libraries/libRoboRIO_FRC_ChipObject.so.1.2 new file mode 100644 index 0000000000..467fa0ef7c --- /dev/null +++ b/ni-libraries/libRoboRIO_FRC_ChipObject.so.1.2 @@ -0,0 +1,2 @@ +OUTPUT_FORMAT(elf32-littlearm) +GROUP ( libRoboRIO_FRC_ChipObject.so.1.2.0 ) diff --git a/ni-libraries/libRoboRIO_FRC_ChipObject.so.1.2.0 b/ni-libraries/libRoboRIO_FRC_ChipObject.so.1.2.0 new file mode 100755 index 0000000000..6b511629e9 Binary files /dev/null and b/ni-libraries/libRoboRIO_FRC_ChipObject.so.1.2.0 differ diff --git a/ni-libraries/libfrccanfirmwareupdate.so b/ni-libraries/libfrccanfirmwareupdate.so new file mode 100755 index 0000000000..e66e0f8df2 Binary files /dev/null and b/ni-libraries/libfrccanfirmwareupdate.so differ diff --git a/ni-libraries/libfrccansae.so b/ni-libraries/libfrccansae.so new file mode 100644 index 0000000000..c6efb2b1f0 --- /dev/null +++ b/ni-libraries/libfrccansae.so @@ -0,0 +1,2 @@ +OUTPUT_FORMAT(elf32-littlearm) +GROUP ( libfrccansae.so.1 ) diff --git a/ni-libraries/libfrccansae.so.1 b/ni-libraries/libfrccansae.so.1 new file mode 100644 index 0000000000..4b42d2ed5b --- /dev/null +++ b/ni-libraries/libfrccansae.so.1 @@ -0,0 +1,2 @@ +OUTPUT_FORMAT(elf32-littlearm) +GROUP ( libfrccansae.so.1.0 ) diff --git a/ni-libraries/libfrccansae.so.1.0 b/ni-libraries/libfrccansae.so.1.0 new file mode 100644 index 0000000000..a4dbf588e6 --- /dev/null +++ b/ni-libraries/libfrccansae.so.1.0 @@ -0,0 +1,2 @@ +OUTPUT_FORMAT(elf32-littlearm) +GROUP ( libfrccansae.so.1.0.0 ) diff --git a/ni-libraries/libfrccansae.so.1.0.0 b/ni-libraries/libfrccansae.so.1.0.0 new file mode 100755 index 0000000000..8dfc4d112c Binary files /dev/null and b/ni-libraries/libfrccansae.so.1.0.0 differ diff --git a/ni-libraries/libi2c.so b/ni-libraries/libi2c.so old mode 100755 new mode 100644 index f59b7ea1fc..673ca375fe Binary files a/ni-libraries/libi2c.so and b/ni-libraries/libi2c.so differ diff --git a/ni-libraries/libi2c.so.1 b/ni-libraries/libi2c.so.1 old mode 100755 new mode 100644 index f59b7ea1fc..e10758b25e Binary files a/ni-libraries/libi2c.so.1 and b/ni-libraries/libi2c.so.1 differ diff --git a/ni-libraries/libi2c.so.1.0 b/ni-libraries/libi2c.so.1.0 new file mode 100644 index 0000000000..68c589079a --- /dev/null +++ b/ni-libraries/libi2c.so.1.0 @@ -0,0 +1,2 @@ +OUTPUT_FORMAT(elf32-littlearm) +GROUP ( libi2c.so.1.0.0 ) diff --git a/ni-libraries/libi2c.so.1.0.0 b/ni-libraries/libi2c.so.1.0.0 new file mode 100755 index 0000000000..fd88049f0c Binary files /dev/null and b/ni-libraries/libi2c.so.1.0.0 differ diff --git a/ni-libraries/libspi.so b/ni-libraries/libspi.so old mode 100755 new mode 100644 index 207ea3b761..e77606f676 Binary files a/ni-libraries/libspi.so and b/ni-libraries/libspi.so differ diff --git a/ni-libraries/libspi.so.1 b/ni-libraries/libspi.so.1 old mode 100755 new mode 100644 index 207ea3b761..5aa0632f71 Binary files a/ni-libraries/libspi.so.1 and b/ni-libraries/libspi.so.1 differ diff --git a/ni-libraries/libspi.so.1.0 b/ni-libraries/libspi.so.1.0 new file mode 100644 index 0000000000..9f016dfcde --- /dev/null +++ b/ni-libraries/libspi.so.1.0 @@ -0,0 +1,2 @@ +OUTPUT_FORMAT(elf32-littlearm) +GROUP ( libspi.so.1.0.0 ) diff --git a/ni-libraries/libspi.so.1.0.0 b/ni-libraries/libspi.so.1.0.0 new file mode 100755 index 0000000000..19870c63d6 Binary files /dev/null and b/ni-libraries/libspi.so.1.0.0 differ diff --git a/ni-libraries/libvisa.so b/ni-libraries/libvisa.so index 9edd2eaa0b..4ca711ce90 100755 Binary files a/ni-libraries/libvisa.so and b/ni-libraries/libvisa.so differ diff --git a/wpilibc/wpilibC++/include/Buttons/AnalogIOButton.h b/wpilibc/wpilibC++/include/Buttons/AnalogIOButton.h deleted file mode 100644 index 9b867e6537..0000000000 --- a/wpilibc/wpilibC++/include/Buttons/AnalogIOButton.h +++ /dev/null @@ -1,26 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) FIRST 2011. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */ -/*----------------------------------------------------------------------------*/ - -#ifndef __ANALOG_IO_BUTTON_H__ -#define __ANALOG_IO_BUTTON_H__ - -#include "Buttons/Button.h" - -class AnalogIOButton : public Trigger -{ -public: - static const double kThreshold; - - AnalogIOButton(int port); - virtual ~AnalogIOButton() {} - virtual bool Get(); - -private: - int m_port; -}; - -#endif - diff --git a/wpilibc/wpilibC++/include/Buttons/DigitalIOButton.h b/wpilibc/wpilibC++/include/Buttons/DigitalIOButton.h deleted file mode 100644 index 6482c75ecb..0000000000 --- a/wpilibc/wpilibC++/include/Buttons/DigitalIOButton.h +++ /dev/null @@ -1,26 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) FIRST 2011. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */ -/*----------------------------------------------------------------------------*/ - -#ifndef __DIGITAL_IO_BUTTON_H__ -#define __DIGITAL_IO_BUTTON_H__ - -#include "Buttons/Button.h" - -class DigitalIOButton: public Button -{ -public: - static const bool kActiveState; - - DigitalIOButton(int port); - virtual ~DigitalIOButton() {} - - virtual bool Get(); - -private: - int m_port; -}; - -#endif diff --git a/wpilibc/wpilibC++/include/DriverStation.h b/wpilibc/wpilibC++/include/DriverStation.h index 115e7b01c9..afdbdf7f25 100644 --- a/wpilibc/wpilibC++/include/DriverStation.h +++ b/wpilibc/wpilibC++/include/DriverStation.h @@ -1,16 +1,15 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) FIRST 2008. All Rights Reserved. */ +/* Copyright (c) FIRST 2008. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */ /*----------------------------------------------------------------------------*/ #pragma once #include "Dashboard.h" -#include "DriverStationEnhancedIO.h" #include "SensorBase.h" #include "Task.h" -struct HALCommonControlData; +struct HALControlWord; class AnalogInput; /** @@ -29,18 +28,12 @@ public: virtual ~DriverStation(); static DriverStation *GetInstance(); - static const uint32_t kBatteryChannel = 7; static const uint32_t kJoystickPorts = 4; static const uint32_t kJoystickAxes = 6; float GetStickAxis(uint32_t stick, uint32_t axis); short GetStickButtons(uint32_t stick); - float GetAnalogIn(uint32_t channel); - bool GetDigitalIn(uint32_t channel); - void SetDigitalOut(uint32_t channel, bool value); - bool GetDigitalOut(uint32_t channel); - bool IsEnabled(); bool IsDisabled(); bool IsAutonomous(); @@ -49,13 +42,11 @@ public: bool IsNewControlData(); bool IsFMSAttached(); - uint32_t GetPacketNumber(); Alliance GetAlliance(); uint32_t GetLocation(); void WaitForData(); double GetMatchTime(); float GetBatteryVoltage(); - uint16_t GetTeamNumber(); // Get the default dashboard packers. These instances stay around even after // a call to SetHigh|LowPriorityDashboardPackerToUse() changes which packer @@ -92,11 +83,6 @@ public: m_dashboardInUseLow = db; } - DriverStationEnhancedIO& GetEnhancedIO() - { - return m_enhancedIO; - } - void IncrementUpdateNumber() { m_updateNumber++; @@ -145,14 +131,15 @@ private: static void InitTask(DriverStation *ds); static DriverStation *m_instance; static uint8_t m_updateNumber; - ///< TODO: Get rid of this and use the semaphore signaling - static constexpr float kUpdatePeriod = 0.02; void Run(); - struct HALCommonControlData *m_controlData; + HALControlWord m_controlWord; + HALAllianceStationID m_allianceStationID; + HALJoystickAxes m_joystickAxes[kJoystickPorts]; + HALJoystickButtons m_joystickButtons[kJoystickPorts]; + uint8_t m_digitalOut; - AnalogInput *m_batteryChannel; MUTEX_ID m_statusDataSemaphore; Task m_task; Dashboard m_dashboardHigh; // the default dashboard packers @@ -161,7 +148,6 @@ private: DashboardBase* m_dashboardInUseLow; SEMAPHORE_ID m_newControlData; MUTEX_ID m_packetDataAvailableSem; - DriverStationEnhancedIO m_enhancedIO; MULTIWAIT_ID m_waitForDataSem; double m_approxMatchTimeOffset; bool m_userInDisabled; diff --git a/wpilibc/wpilibC++/include/DriverStationEnhancedIO.h b/wpilibc/wpilibC++/include/DriverStationEnhancedIO.h deleted file mode 100644 index 3913de0a3b..0000000000 --- a/wpilibc/wpilibC++/include/DriverStationEnhancedIO.h +++ /dev/null @@ -1,147 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) FIRST 2008. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */ -/*----------------------------------------------------------------------------*/ -#pragma once - -#include "ErrorBase.h" -#include -#include -#include "HAL/HAL.hpp" - -#include "HAL/Semaphore.hpp" - -#define kAnalogInputResolution ((double)((1<<14)-1)) -#define kAnalogInputReference 3.3 -#define kAnalogOutputResolution ((double)((1<<8)-1)) -#define kAnalogOutputReference 4.0 -#define kAccelOffset 8300 -#define kAccelScale 3300.0 -#define kSupportedAPIVersion 1 - -/** - * Interact with the more complete I/O available from the - * newest driver station. Get a reference to an object - * of this type by calling GetEnhancedIO() on the DriverStation object. - */ -class DriverStationEnhancedIO : public ErrorBase -{ - // Can only be constructed by the DriverStation class. - friend class DriverStation; - -#pragma pack(push,1) - // BEGIN: Definitions from the Cypress firmware - typedef struct - { - uint16_t digital; - uint16_t digital_oe; - uint16_t digital_pe; - uint16_t pwm_compare[4]; - uint16_t pwm_period[2]; - uint8_t dac[2]; - uint8_t leds; - union - { - struct - { - // Bits are inverted from cypress fw because of big-endian! - uint8_t pwm_enable : 4; - uint8_t comparator_enable : 2; - uint8_t quad_index_enable : 2; - }; - uint8_t enables; - }; - uint8_t fixed_digital_out; - } output_t; //data to IO (23 bytes) - - typedef struct - { - uint8_t api_version; - uint8_t fw_version; - int16_t analog[8]; - uint16_t digital; - int16_t accel[3]; - int16_t quad[2]; - uint8_t buttons; - uint8_t capsense_slider; - uint8_t capsense_proximity; - } input_t; //data from IO (33 bytes) - // END: Definitions from the Cypress firmware - - // Dynamic block definitions - typedef struct - { - uint8_t size; // Must be 25 (size remaining in the block not counting the size variable) - uint8_t id; // Must be 18 - output_t data; - uint8_t flags; - } status_block_t; - - typedef struct - { - uint8_t size; // Must be 34 - uint8_t id; // Must be 17 - input_t data; - } control_block_t; -#pragma pack(pop) - - enum tBlockID - { - kInputBlockID = HALFRC_NetworkCommunication_DynamicType_DSEnhancedIO_Input, - kOutputBlockID = HALFRC_NetworkCommunication_DynamicType_DSEnhancedIO_Output, - }; - enum tStatusFlags {kStatusValid = 0x01, kStatusConfigChanged = 0x02, kForceEnhancedMode = 0x04}; - -public: - enum tDigitalConfig {kUnknown, kInputFloating, kInputPullUp, kInputPullDown, kOutput, kPWM, kAnalogComparator}; - enum tAccelChannel {kAccelX = 0, kAccelY = 1, kAccelZ = 2}; - enum tPWMPeriodChannels {kPWMChannels1and2, kPWMChannels3and4}; - - double GetAcceleration(tAccelChannel channel); - double GetAnalogIn(uint32_t channel); - double GetAnalogInRatio(uint32_t channel); - double GetAnalogOut(uint32_t channel); - void SetAnalogOut(uint32_t channel, double value); - bool GetButton(uint32_t channel); - uint8_t GetButtons(); - void SetLED(uint32_t channel, bool value); - void SetLEDs(uint8_t value); - bool GetDigital(uint32_t channel); - uint16_t GetDigitals(); - void SetDigitalOutput(uint32_t channel, bool value); - tDigitalConfig GetDigitalConfig(uint32_t channel); - void SetDigitalConfig(uint32_t channel, tDigitalConfig config); - double GetPWMPeriod(tPWMPeriodChannels channels); - void SetPWMPeriod(tPWMPeriodChannels channels, double period); - bool GetFixedDigitalOutput(uint32_t channel); - void SetFixedDigitalOutput(uint32_t channel, bool value); - int16_t GetEncoder(uint32_t encoderNumber); - void ResetEncoder(uint32_t encoderNumber); - bool GetEncoderIndexEnable(uint32_t encoderNumber); - void SetEncoderIndexEnable(uint32_t encoderNumber, bool enable); - double GetTouchSlider(); - double GetPWMOutput(uint32_t channel); - void SetPWMOutput(uint32_t channel, double value); - uint8_t GetFirmwareVersion(); - -private: - DriverStationEnhancedIO(); - virtual ~DriverStationEnhancedIO(); - void UpdateData(); - void MergeConfigIntoOutput(const status_block_t &dsOutputBlock, status_block_t &localCache); - bool IsConfigEqual(const status_block_t &dsOutputBlock, const status_block_t &localCache); - - // Usage Guidelines... - DISALLOW_COPY_AND_ASSIGN(DriverStationEnhancedIO); - - control_block_t m_inputData; - status_block_t m_outputData; - MUTEX_ID m_inputDataSemaphore; - MUTEX_ID m_outputDataSemaphore; - bool m_inputValid; - bool m_outputValid; - bool m_configChanged; - bool m_requestEnhancedEnable; - int16_t m_encoderOffsets[2]; -}; diff --git a/wpilibc/wpilibC++/include/DriverStationLCD.h b/wpilibc/wpilibC++/include/DriverStationLCD.h deleted file mode 100644 index a99215b204..0000000000 --- a/wpilibc/wpilibC++/include/DriverStationLCD.h +++ /dev/null @@ -1,58 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) FIRST 2008. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */ -/*----------------------------------------------------------------------------*/ -#pragma once - -#include "SensorBase.h" -#include "HAL/Semaphore.hpp" -#include - -/** - * Provide access to "LCD" on the Driver Station. - * This is the Messages box on the DS Operation tab. - * - * Buffer the printed data locally and then send it - * when UpdateLCD is called. - */ -class DriverStationLCD : public SensorBase -{ -public: - static const uint32_t kSyncTimeout_ms = 20; - static const uint16_t kFullDisplayTextCommand = 0x9FFF; - static const int32_t kLineLength = 21; - static const int32_t kNumLines = 6; - enum Line - { - kMain_Line6 = 0, - kUser_Line1 = 0, - kUser_Line2 = 1, - kUser_Line3 = 2, - kUser_Line4 = 3, - kUser_Line5 = 4, - kUser_Line6 = 5 - }; - - virtual ~DriverStationLCD(); - static DriverStationLCD *GetInstance(); - - void UpdateLCD(); - void Printf(Line line, int32_t startingColumn, const char *writeFmt, ...); - void VPrintf(Line line, int32_t startingColumn, const char *writeFmt, va_list args); - void PrintfLine(Line line, const char *writeFmt, ...); - void VPrintfLine(Line line, const char *writeFmt, va_list args); - - void Clear(); - -protected: - DriverStationLCD(); - -private: - static void InitTask(DriverStationLCD *ds); - static DriverStationLCD *m_instance; - - DISALLOW_COPY_AND_ASSIGN(DriverStationLCD); - char *m_textBuffer; - MUTEX_ID m_textBufferSemaphore; -}; diff --git a/wpilibc/wpilibC++/include/NetworkCommunication/CANInterfacePlugin.h b/wpilibc/wpilibC++/include/NetworkCommunication/CANInterfacePlugin.h index bf0abef86a..f4c4064dc6 100644 --- a/wpilibc/wpilibC++/include/NetworkCommunication/CANInterfacePlugin.h +++ b/wpilibc/wpilibC++/include/NetworkCommunication/CANInterfacePlugin.h @@ -50,6 +50,23 @@ public: * @return This should return 0 if a message was populated, non-0 if no message was not populated. */ virtual int32_t receiveMessage(uint32_t &messageID, uint8_t *data, uint8_t &dataSize) = 0; + + /** + * This entry-point of the CANInterfacePlugin returns status of the CAN bus. + * + * This function may be called from multiple contexts and must therefore be reentrant. + * + * This function will return detailed hardware status if available for diagnostics of the CAN interface. + * + * @param busOffCount The number of times that sendMessage failed with a busOff error indicating that messages + * are not successfully transmitted on the bus. + * @param txFullCount The number of times that sendMessage failed with a txFifoFull error indicating that messages + * are not successfully received by any CAN device. + * @param receiveErrorCount The count of receive errors as reported by the CAN driver. + * @param transmitErrorCount The count of transmit errors as reported by the CAN driver. + * @return This should return 0 if all status was retrieved successfully or an error code if not. + */ + virtual int32_t getStatus(uint32_t &busOffCount, uint32_t &txFullCount, uint32_t &receiveErrorCount, uint32_t &transmitErrorCount) {return 0;} }; /** diff --git a/wpilibc/wpilibC++/include/NetworkCommunication/CANSessionMux.h b/wpilibc/wpilibC++/include/NetworkCommunication/CANSessionMux.h index d31c76c1a2..81f63c579f 100644 --- a/wpilibc/wpilibC++/include/NetworkCommunication/CANSessionMux.h +++ b/wpilibc/wpilibC++/include/NetworkCommunication/CANSessionMux.h @@ -41,6 +41,7 @@ namespace nCANSessionMux void openStreamSession(uint32_t *sessionHandle, uint32_t messageID, uint32_t messageIDMask, uint32_t maxMessages, int32_t *status); void closeStreamSession(uint32_t sessionHandle); void readStreamSession(uint32_t sessionHandle, struct tCANStreamMessage *messages, uint32_t messagesToRead, uint32_t *messagesRead, int32_t *status); + void getCANStatus(float *percentBusUtilization, uint32_t *busOffCount, uint32_t *txFullCount, uint32_t *receiveErrorCount, uint32_t *transmitErrorCount, int32_t *status); } #ifdef __cplusplus @@ -53,6 +54,7 @@ extern "C" void FRC_NetworkCommunication_CANSessionMux_openStreamSession(uint32_t *sessionHandle, uint32_t messageID, uint32_t messageIDMask, uint32_t maxMessages, int32_t *status); void FRC_NetworkCommunication_CANSessionMux_closeStreamSession(uint32_t sessionHandle); void FRC_NetworkCommunication_CANSessionMux_readStreamSession(uint32_t sessionHandle, struct tCANStreamMessage *messages, uint32_t messagesToRead, uint32_t *messagesRead, int32_t *status); + void FRC_NetworkCommunication_CANSessionMux_getCANStatus(float *percentBusUtilization, uint32_t *busOffCount, uint32_t *txFullCount, uint32_t *receiveErrorCount, uint32_t *transmitErrorCount, int32_t *status); #ifdef __cplusplus } diff --git a/wpilibc/wpilibC++/include/NetworkCommunication/FRCComm.h b/wpilibc/wpilibC++/include/NetworkCommunication/FRCComm.h index 4d40d237d4..51d8488491 100644 --- a/wpilibc/wpilibC++/include/NetworkCommunication/FRCComm.h +++ b/wpilibc/wpilibC++/include/NetworkCommunication/FRCComm.h @@ -32,133 +32,52 @@ #endif #endif -// Commandeer some bytes at the end for advanced I/O feedback. -#define IO_CONFIG_DATA_SIZE 32 -#define SYS_STATUS_DATA_SIZE 44 -#define USER_STATUS_DATA_SIZE (984 - IO_CONFIG_DATA_SIZE - SYS_STATUS_DATA_SIZE) -#define USER_DS_LCD_DATA_SIZE 128 - -struct FRCCommonControlData{ - uint16_t packetIndex; - union { - uint8_t control; -#ifndef __vxworks - struct { - uint8_t checkVersions :1; - uint8_t test :1; - uint8_t resync : 1; - uint8_t fmsAttached:1; - uint8_t autonomous : 1; - uint8_t enabled : 1; - uint8_t notEStop : 1; - uint8_t reset : 1; - }; -#else - struct { - uint8_t reset : 1; - uint8_t notEStop : 1; - uint8_t enabled : 1; - uint8_t autonomous : 1; - uint8_t fmsAttached:1; - uint8_t resync : 1; - uint8_t test :1; - uint8_t checkVersions :1; - }; -#endif - }; - uint8_t dsDigitalIn; - uint16_t teamID; - - char dsID_Alliance; - char dsID_Position; - - union { - int8_t stick0Axes[6]; - struct { - int8_t stick0Axis1; - int8_t stick0Axis2; - int8_t stick0Axis3; - int8_t stick0Axis4; - int8_t stick0Axis5; - int8_t stick0Axis6; - }; - }; - uint16_t stick0Buttons; // Left-most 4 bits are unused - - union { - int8_t stick1Axes[6]; - struct { - int8_t stick1Axis1; - int8_t stick1Axis2; - int8_t stick1Axis3; - int8_t stick1Axis4; - int8_t stick1Axis5; - int8_t stick1Axis6; - }; - }; - uint16_t stick1Buttons; // Left-most 4 bits are unused - - union { - int8_t stick2Axes[6]; - struct { - int8_t stick2Axis1; - int8_t stick2Axis2; - int8_t stick2Axis3; - int8_t stick2Axis4; - int8_t stick2Axis5; - int8_t stick2Axis6; - }; - }; - uint16_t stick2Buttons; // Left-most 4 bits are unused - - union { - int8_t stick3Axes[6]; - struct { - int8_t stick3Axis1; - int8_t stick3Axis2; - int8_t stick3Axis3; - int8_t stick3Axis4; - int8_t stick3Axis5; - int8_t stick3Axis6; - }; - }; - uint16_t stick3Buttons; // Left-most 4 bits are unused - - //Analog inputs are 10 bit right-justified - uint16_t analog1; - uint16_t analog2; - uint16_t analog3; - uint16_t analog4; - - uint64_t cRIOChecksum; - uint32_t FPGAChecksum0; - uint32_t FPGAChecksum1; - uint32_t FPGAChecksum2; - uint32_t FPGAChecksum3; - - char versionData[8]; +enum AllianceStationID_t { + kAllianceStationID_red1, + kAllianceStationID_red2, + kAllianceStationID_red3, + kAllianceStationID_blue1, + kAllianceStationID_blue2, + kAllianceStationID_blue3, }; -#define kFRC_NetworkCommunication_DynamicType_DSEnhancedIO_Input 17 -#define kFRC_NetworkCommunication_DynamicType_DSEnhancedIO_Output 18 -#define kFRC_NetworkCommunication_DynamicType_Kinect_Header 19 -#define kFRC_NetworkCommunication_DynamicType_Kinect_Extra1 20 -#define kFRC_NetworkCommunication_DynamicType_Kinect_Vertices1 21 -#define kFRC_NetworkCommunication_DynamicType_Kinect_Extra2 22 -#define kFRC_NetworkCommunication_DynamicType_Kinect_Vertices2 23 -#define kFRC_NetworkCommunication_DynamicType_Kinect_Joystick 24 -#define kFRC_NetworkCommunication_DynamicType_Kinect_Custom 25 +struct ControlWord_t { +#ifndef __vxworks + uint32_t enabled : 1; + uint32_t autonomous : 1; + uint32_t test :1; + uint32_t eStop : 1; + uint32_t fmsAttached:1; + uint32_t dsAttached:1; + uint32_t control_reserved : 26; +#else + uint32_t control_reserved : 26; + uint32_t dsAttached:1; + uint32_t fmsAttached:1; + uint32_t eStop : 1; + uint32_t test :1; + uint32_t autonomous : 1; + uint32_t enabled : 1; +#endif +}; + +struct JoystickAxes_t { + uint16_t count; + int16_t axes[1]; +}; + +struct JoystickPOV_t { + uint16_t count; + uint16_t povs[1]; +}; #ifdef __cplusplus extern "C" { #endif + int EXPORT_FUNC FRC_NetworkCommunication_Reserve(void *instance); #ifndef SIMULATION void EXPORT_FUNC getFPGAHardwareVersion(uint16_t *fpgaVersion, uint32_t *fpgaRevision); #endif - int EXPORT_FUNC getCommonControlData(struct FRCCommonControlData *data, int wait_ms); - int EXPORT_FUNC getRecentCommonControlData(struct FRCCommonControlData *commonData, int wait_ms); - int EXPORT_FUNC getRecentStatusData(uint8_t *batteryInt, uint8_t *batteryDec, uint8_t *dsDigitalOut, int wait_ms); - int EXPORT_FUNC getDynamicControlData(uint8_t type, char *dynamicData, int32_t maxLength, int wait_ms); int EXPORT_FUNC setStatusData(float battery, uint8_t dsDigitalOut, uint8_t updateNumber, const char *userDataHigh, int userDataHighLength, const char *userDataLow, int userDataLowLength, int wait_ms); @@ -166,30 +85,28 @@ extern "C" { const char *userDataHigh, int userDataHighLength, const char *userDataLow, int userDataLowLength, int wait_ms); int EXPORT_FUNC setErrorData(const char *errors, int errorsLength, int wait_ms); - int EXPORT_FUNC setUserDsLcdData(const char *userDsLcdData, int userDsLcdDataLength, int wait_ms); - int EXPORT_FUNC overrideIOConfig(const char *ioConfig, int wait_ms); #ifdef SIMULATION void EXPORT_FUNC setNewDataSem(HANDLE); #else # if defined (__vxworks) void EXPORT_FUNC setNewDataSem(SEM_ID); - void EXPORT_FUNC setResyncSem(SEM_ID); # else void EXPORT_FUNC setNewDataSem(pthread_mutex_t *); - void EXPORT_FUNC setResyncSem(pthread_mutex_t *); # endif - void EXPORT_FUNC signalResyncActionDone(void); #endif // this uint32_t is really a LVRefNum - void EXPORT_FUNC setNewDataOccurRef(uint32_t refnum); -#ifndef SIMULATION - void EXPORT_FUNC setResyncOccurRef(uint32_t refnum); -#endif + int EXPORT_FUNC setNewDataOccurRef(uint32_t refnum); + + int EXPORT_FUNC FRC_NetworkCommunication_getControlWord(struct ControlWord_t *controlWord); + int EXPORT_FUNC FRC_NetworkCommunication_getAllianceStation(enum AllianceStationID_t *allianceStation); + int EXPORT_FUNC FRC_NetworkCommunication_getJoystickAxes(uint8_t joystickNum, struct JoystickAxes_t *axes, uint8_t maxAxes); + int EXPORT_FUNC FRC_NetworkCommunication_getJoystickButtons(uint8_t joystickNum, uint32_t *buttons, uint8_t *count); + int EXPORT_FUNC FRC_NetworkCommunication_getJoystickPOVs(uint8_t joystickNum, struct JoystickPOV_t *povs, uint8_t maxPOVs); void EXPORT_FUNC FRC_NetworkCommunication_getVersionString(char *version); - void EXPORT_FUNC FRC_NetworkCommunication_observeUserProgramStarting(void); + int EXPORT_FUNC FRC_NetworkCommunication_observeUserProgramStarting(void); void EXPORT_FUNC FRC_NetworkCommunication_observeUserProgramDisabled(void); void EXPORT_FUNC FRC_NetworkCommunication_observeUserProgramAutonomous(void); void EXPORT_FUNC FRC_NetworkCommunication_observeUserProgramTeleop(void); diff --git a/wpilibc/wpilibC++/include/NetworkCommunication/LoadOut.h b/wpilibc/wpilibC++/include/NetworkCommunication/LoadOut.h index 2433b0cc71..fce88a28e2 100644 --- a/wpilibc/wpilibC++/include/NetworkCommunication/LoadOut.h +++ b/wpilibc/wpilibC++/include/NetworkCommunication/LoadOut.h @@ -16,6 +16,7 @@ #define kMaxModuleNumber 2 namespace nLoadOut { +#if defined(__vxworks) || defined(SIMULATION) typedef enum { kModuleType_Unknown = 0x00, kModuleType_Analog = 0x01, @@ -23,15 +24,18 @@ namespace nLoadOut kModuleType_Solenoid = 0x03, } tModuleType; bool EXPORT_FUNC getModulePresence(tModuleType moduleType, uint8_t moduleNumber); +#endif typedef enum { kTargetClass_Unknown = 0x00, kTargetClass_FRC1 = 0x10, kTargetClass_FRC2 = 0x20, kTargetClass_FRC3 = 0x30, kTargetClass_RoboRIO = 0x40, +#if defined(__vxworks) || defined(SIMULATION) kTargetClass_FRC2_Analog = kTargetClass_FRC2 | kModuleType_Analog, kTargetClass_FRC2_Digital = kTargetClass_FRC2 | kModuleType_Digital, kTargetClass_FRC2_Solenoid = kTargetClass_FRC2 | kModuleType_Solenoid, +#endif kTargetClass_FamilyMask = 0xF0, kTargetClass_ModuleMask = 0x0F, } tTargetClass; @@ -42,7 +46,9 @@ namespace nLoadOut extern "C" { #endif +#if defined(__vxworks) || defined(SIMULATION) uint32_t EXPORT_FUNC FRC_NetworkCommunication_nLoadOut_getModulePresence(uint32_t moduleType, uint8_t moduleNumber); +#endif uint32_t EXPORT_FUNC FRC_NetworkCommunication_nLoadOut_getTargetClass(); #ifdef __cplusplus diff --git a/wpilibc/wpilibC++/include/WPILib.h b/wpilibc/wpilibC++/include/WPILib.h index 02a9899916..40fe549dcb 100644 --- a/wpilibc/wpilibC++/include/WPILib.h +++ b/wpilibc/wpilibC++/include/WPILib.h @@ -19,8 +19,6 @@ #include "AnalogTrigger.h" #include "AnalogTriggerOutput.h" #include "BuiltInAccelerometer.h" -#include "Buttons/AnalogIOButton.h" -#include "Buttons/DigitalIOButton.h" #include "Buttons/InternalButton.h" #include "Buttons/JoystickButton.h" #include "Buttons/NetworkButton.h" @@ -44,8 +42,6 @@ #include "DigitalSource.h" #include "DoubleSolenoid.h" #include "DriverStation.h" -#include "DriverStationEnhancedIO.h" -#include "DriverStationLCD.h" #include "Encoder.h" #include "ErrorBase.h" #include "GearTooth.h" diff --git a/wpilibc/wpilibC++/lib/Buttons/AnalogIOButton.cpp b/wpilibc/wpilibC++/lib/Buttons/AnalogIOButton.cpp deleted file mode 100644 index b2122ff291..0000000000 --- a/wpilibc/wpilibC++/lib/Buttons/AnalogIOButton.cpp +++ /dev/null @@ -1,20 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) FIRST 2011. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */ -/*----------------------------------------------------------------------------*/ - -#include "Buttons/AnalogIOButton.h" -#include "DriverStation.h" - -const double AnalogIOButton::kThreshold = 0.5; - -AnalogIOButton::AnalogIOButton(int port) : - m_port(port) -{ -} - -bool AnalogIOButton::Get() -{ - return DriverStation::GetInstance()->GetEnhancedIO().GetAnalogIn(m_port) < kThreshold; -} diff --git a/wpilibc/wpilibC++/lib/Buttons/DigitalIOButton.cpp b/wpilibc/wpilibC++/lib/Buttons/DigitalIOButton.cpp deleted file mode 100644 index 8bb39be1fe..0000000000 --- a/wpilibc/wpilibC++/lib/Buttons/DigitalIOButton.cpp +++ /dev/null @@ -1,20 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) FIRST 2011. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */ -/*----------------------------------------------------------------------------*/ - -#include "Buttons/DigitalIOButton.h" -#include "DriverStation.h" - -const bool DigitalIOButton::kActiveState = false; - -DigitalIOButton::DigitalIOButton(int port) : - m_port(port) -{ -} - -bool DigitalIOButton::Get() -{ - return DriverStation::GetInstance()->GetEnhancedIO().GetDigital(m_port) == kActiveState; -} diff --git a/wpilibc/wpilibC++/lib/DriverStation.cpp b/wpilibc/wpilibC++/lib/DriverStation.cpp index 546f7ecfdf..389b8bc531 100644 --- a/wpilibc/wpilibC++/lib/DriverStation.cpp +++ b/wpilibc/wpilibC++/lib/DriverStation.cpp @@ -8,8 +8,6 @@ #include "AnalogInput.h" #include "HAL/cpp/Synchronized.hpp" #include "Timer.h" -//#include "NetworkCommunication/FRCComm.h" -//#include "NetworkCommunication/UsageReporting.h" #include "MotorSafetyHelper.h" #include "Utility.h" #include "WPIErrors.h" @@ -20,13 +18,11 @@ TLogLevel dsLogLevel = logDEBUG; #define DS_LOG(level) \ - if (level > dsLogLevel) ; \ - else Log().Get(level) + if (level > dsLogLevel) ; \ + else Log().Get(level) -const uint32_t DriverStation::kBatteryChannel; const uint32_t DriverStation::kJoystickPorts; const uint32_t DriverStation::kJoystickAxes; -constexpr float DriverStation::kUpdatePeriod; DriverStation* DriverStation::m_instance = NULL; uint8_t DriverStation::m_updateNumber = 0; @@ -36,9 +32,7 @@ uint8_t DriverStation::m_updateNumber = 0; * This is only called once the first time GetInstance() is called */ DriverStation::DriverStation() - : m_controlData (NULL) - , m_digitalOut (0) - , m_batteryChannel (NULL) + : m_digitalOut (0) , m_statusDataSemaphore (initializeMutexNormal()) , m_task ("DriverStation", (FUNCPTR)DriverStation::InitTask) , m_dashboardHigh(m_statusDataSemaphore) @@ -47,7 +41,6 @@ DriverStation::DriverStation() , m_dashboardInUseLow(&m_dashboardLow) , m_newControlData(0) , m_packetDataAvailableSem (0) - , m_enhancedIO() , m_waitForDataSem(0) , m_approxMatchTimeOffset(-1.0) , m_userInDisabled(false) @@ -65,35 +58,6 @@ DriverStation::DriverStation() m_waitForDataSem = initializeMultiWait(); - m_controlData = new HALCommonControlData; - - // initialize packet number and control words to zero; - m_controlData->packetIndex = 0; - m_controlData->control = 0; - - // set all joystick axis values to neutral; buttons to OFF - m_controlData->stick0Axis1 = m_controlData->stick0Axis2 = m_controlData->stick0Axis3 = 0; - m_controlData->stick1Axis1 = m_controlData->stick1Axis2 = m_controlData->stick1Axis3 = 0; - m_controlData->stick2Axis1 = m_controlData->stick2Axis2 = m_controlData->stick2Axis3 = 0; - m_controlData->stick3Axis1 = m_controlData->stick3Axis2 = m_controlData->stick3Axis3 = 0; - m_controlData->stick0Axis4 = m_controlData->stick0Axis5 = m_controlData->stick0Axis6 = 0; - m_controlData->stick1Axis4 = m_controlData->stick1Axis5 = m_controlData->stick1Axis6 = 0; - m_controlData->stick2Axis4 = m_controlData->stick2Axis5 = m_controlData->stick2Axis6 = 0; - m_controlData->stick3Axis4 = m_controlData->stick3Axis5 = m_controlData->stick3Axis6 = 0; - m_controlData->stick0Buttons = 0; - m_controlData->stick1Buttons = 0; - m_controlData->stick2Buttons = 0; - m_controlData->stick3Buttons = 0; - - // initialize the analog and digital data. - m_controlData->analog1 = 0; - m_controlData->analog2 = 0; - m_controlData->analog3 = 0; - m_controlData->analog4 = 0; - m_controlData->dsDigitalIn = 0; - - m_batteryChannel = new AnalogInput(kBatteryChannel); - AddToSingletonList(); if (!m_task.Start((int32_t)this)) @@ -106,8 +70,6 @@ DriverStation::~DriverStation() { m_task.Stop(); deleteMutex(m_statusDataSemaphore); - delete m_batteryChannel; - delete m_controlData; m_instance = NULL; deleteMultiWait(m_waitForDataSem); // Unregister our semaphore. @@ -127,7 +89,6 @@ void DriverStation::Run() { takeMutex(m_packetDataAvailableSem); SetData(); - m_enhancedIO.UpdateData(); GetData(); giveMultiWait(m_waitForDataSem); if (++period >= 4) @@ -139,10 +100,10 @@ void DriverStation::Run() HALNetworkCommunicationObserveUserProgramDisabled(); if (m_userInAutonomous) HALNetworkCommunicationObserveUserProgramAutonomous(); - if (m_userInTeleop) - HALNetworkCommunicationObserveUserProgramTeleop(); - if (m_userInTest) - HALNetworkCommunicationObserveUserProgramTest(); + if (m_userInTeleop) + HALNetworkCommunicationObserveUserProgramTeleop(); + if (m_userInTest) + HALNetworkCommunicationObserveUserProgramTest(); } } @@ -158,6 +119,8 @@ DriverStation* DriverStation::GetInstance() return m_instance; } +#include + /** * Copy data from the DS task for the user. * If no new data exists, it will just be returned, otherwise @@ -167,7 +130,19 @@ void DriverStation::GetData() { static bool lastEnabled = false; - HALGetCommonControlData(m_controlData, HAL_WAIT_FOREVER); + // Get the status data + HALGetControlWord(&m_controlWord); + + // Get the location/alliance data + HALGetAllianceStation(&m_allianceStationID); + + // Get the status of all of the joysticks + for(uint8_t stick = 0; stick < kJoystickPorts; stick++) { + uint8_t count; + + HALGetJoystickAxes(stick, &m_joystickAxes[stick], kJoystickAxes); + HALGetJoystickButtons(stick, &m_joystickButtons[stick], &count); + } if (!lastEnabled && IsEnabled()) { @@ -199,30 +174,23 @@ void DriverStation::SetData() m_dashboardInUseHigh->GetStatusBuffer(&userStatusDataHigh, &userStatusDataHighSize); m_dashboardInUseLow->GetStatusBuffer(&userStatusDataLow, &userStatusDataLowSize); - HALSetStatusData(GetBatteryVoltage(), m_digitalOut, m_updateNumber, - userStatusDataHigh, userStatusDataHighSize, userStatusDataLow, userStatusDataLowSize, HAL_WAIT_FOREVER); + + //TODO ??? + //HALSetStatusData(GetBatteryVoltage(), m_digitalOut, m_updateNumber, + // userStatusDataHigh, userStatusDataHighSize, userStatusDataLow, userStatusDataLowSize, HAL_WAIT_FOREVER); m_dashboardInUseHigh->Flush(); m_dashboardInUseLow->Flush(); } /** - * Read the battery voltage from the specified AnalogInput. - * - * This accessor assumes that the battery voltage is being measured - * through the voltage divider on an analog breakout. + * Read the battery voltage. * * @return The battery voltage. */ float DriverStation::GetBatteryVoltage() { - if (m_batteryChannel == NULL) - wpi_setWPIError(NullParameter); - - // The Analog bumper has a voltage divider on the battery source. - // Vbatt *--/\/\/\--* Vsample *--/\/\/\--* Gnd - // 680 Ohms 1000 Ohms - return m_batteryChannel->GetAverageVoltage() * (1680.0 / 1000.0); + return 0.0f; // TODO } /** @@ -235,43 +203,28 @@ float DriverStation::GetBatteryVoltage() */ float DriverStation::GetStickAxis(uint32_t stick, uint32_t axis) { + if (stick < 1 || stick > kJoystickPorts) + { + wpi_setWPIError(BadJoystickIndex); + return 0; + } + if (axis < 1 || axis > kJoystickAxes) { wpi_setWPIError(BadJoystickAxis); - return 0.0; + return 0.0f; } - int8_t value; - switch (stick) + int8_t value = m_joystickAxes[stick - 1].axes[axis - 1]; + + if(value < 0) { - case 1: - value = m_controlData->stick0Axes[axis-1]; - break; - case 2: - value = m_controlData->stick1Axes[axis-1]; - break; - case 3: - value = m_controlData->stick2Axes[axis-1]; - break; - case 4: - value = m_controlData->stick3Axes[axis-1]; - break; - default: - wpi_setWPIError(BadJoystickIndex); - return 0.0; + return value / 128.0f; } - - float result; - if (value < 0) - result = ((float) value) / 128.0; else - result = ((float) value) / 127.0; - wpi_assert(result <= 1.0 && result >= -1.0); - if (result > 1.0) - result = 1.0; - else if (result < -1.0) - result = -1.0; - return result; + { + return value / 127.0f; + } } /** @@ -283,143 +236,38 @@ float DriverStation::GetStickAxis(uint32_t stick, uint32_t axis) */ short DriverStation::GetStickButtons(uint32_t stick) { - if (stick < 1 || stick > 4) - wpi_setWPIErrorWithContext(ParameterOutOfRange, "stick must be between 1 and 4"); - - switch (stick) + if (stick < 1 || stick > kJoystickPorts) { - case 1: - return m_controlData->stick0Buttons; - case 2: - return m_controlData->stick1Buttons; - case 3: - return m_controlData->stick2Buttons; - case 4: - return m_controlData->stick3Buttons; - } - return 0; -} - -// 5V divided by 10 bits -#define kDSAnalogInScaling ((float)(5.0 / 1023.0)) - -/** - * Get an analog voltage from the Driver Station. - * The analog values are returned as voltage values for the Driver Station analog inputs. - * These inputs are typically used for advanced operator interfaces consisting of potentiometers - * or resistor networks representing values on a rotary switch. - * - * @param channel The analog input channel on the driver station to read from. Valid range is 1 - 4. - * @return The analog voltage on the input. - */ -float DriverStation::GetAnalogIn(uint32_t channel) -{ - if (channel < 1 || channel > 4) - wpi_setWPIErrorWithContext(ParameterOutOfRange, "channel must be between 1 and 4"); - - static uint8_t reported_mask = 0; - if (!(reported_mask & (1 >> channel))) - { - HALReport(HALUsageReporting::kResourceType_DriverStationCIO, channel, HALUsageReporting::kDriverStationCIO_Analog); - reported_mask |= (1 >> channel); + wpi_setWPIError(BadJoystickIndex); + return 0; } - switch (channel) - { - case 1: - return kDSAnalogInScaling * m_controlData->analog1; - case 2: - return kDSAnalogInScaling * m_controlData->analog2; - case 3: - return kDSAnalogInScaling * m_controlData->analog3; - case 4: - return kDSAnalogInScaling * m_controlData->analog4; - } - return 0.0; -} - -/** - * Get values from the digital inputs on the Driver Station. - * Return digital values from the Drivers Station. These values are typically used for buttons - * and switches on advanced operator interfaces. - * @param channel The digital input to get. Valid range is 1 - 8. - */ -bool DriverStation::GetDigitalIn(uint32_t channel) -{ - if (channel < 1 || channel > 8) - wpi_setWPIErrorWithContext(ParameterOutOfRange, "channel must be between 1 and 8"); - - static uint8_t reported_mask = 0; - if (!(reported_mask & (1 >> channel))) - { - HALReport(HALUsageReporting::kResourceType_DriverStationCIO, channel, HALUsageReporting::kDriverStationCIO_DigitalIn); - reported_mask |= (1 >> channel); - } - - return ((m_controlData->dsDigitalIn >> (channel-1)) & 0x1) ? true : false; -} - -/** - * Set a value for the digital outputs on the Driver Station. - * - * Control digital outputs on the Drivers Station. These values are typically used for - * giving feedback on a custom operator station such as LEDs. - * - * @param channel The digital output to set. Valid range is 1 - 8. - * @param value The state to set the digital output. - */ -void DriverStation::SetDigitalOut(uint32_t channel, bool value) -{ - if (channel < 1 || channel > 8) - wpi_setWPIErrorWithContext(ParameterOutOfRange, "channel must be between 1 and 8"); - - static uint8_t reported_mask = 0; - if (!(reported_mask & (1 >> channel))) - { - HALReport(HALUsageReporting::kResourceType_DriverStationCIO, channel,HALUsageReporting::kDriverStationCIO_DigitalOut); - reported_mask |= (1 >> channel); - } - - m_digitalOut &= ~(0x1 << (channel-1)); - m_digitalOut |= ((uint8_t)value << (channel-1)); -} - -/** - * Get a value that was set for the digital outputs on the Driver Station. - * @param channel The digital ouput to monitor. Valid range is 1 through 8. - * @return A digital value being output on the Drivers Station. - */ -bool DriverStation::GetDigitalOut(uint32_t channel) -{ - if (channel < 1 || channel > 8) - wpi_setWPIErrorWithContext(ParameterOutOfRange, "channel must be between 1 and 8"); - - return ((m_digitalOut >> (channel-1)) & 0x1) ? true : false; + return m_joystickButtons[stick - 1]; } bool DriverStation::IsEnabled() { - return m_controlData->enabled; + return m_controlWord.enabled; } bool DriverStation::IsDisabled() { - return !m_controlData->enabled; + return !m_controlWord.enabled; } bool DriverStation::IsAutonomous() { - return m_controlData->autonomous; + return m_controlWord.autonomous; } bool DriverStation::IsOperatorControl() { - return !(m_controlData->autonomous || m_controlData->test); + return !(m_controlWord.autonomous || m_controlWord.test); } bool DriverStation::IsTest() { - return m_controlData->test; + return m_controlWord.test; } /** @@ -440,18 +288,7 @@ bool DriverStation::IsNewControlData() */ bool DriverStation::IsFMSAttached() { - return m_controlData->fmsAttached; -} - -/** - * Return the DS packet number. - * The packet number is the index of this set of data returned by the driver station. - * Each time new data is received, the packet number (included with the sent data) is returned. - * @return The driver station packet number - */ -uint32_t DriverStation::GetPacketNumber() -{ - return m_controlData->packetIndex; + return m_controlWord.fmsAttached; } /** @@ -461,10 +298,19 @@ uint32_t DriverStation::GetPacketNumber() */ DriverStation::Alliance DriverStation::GetAlliance() { - if (m_controlData->dsID_Alliance == 'R') return kRed; - if (m_controlData->dsID_Alliance == 'B') return kBlue; - wpi_assert(false); - return kInvalid; + switch(m_allianceStationID) + { + case kHALAllianceStationID_red1: + case kHALAllianceStationID_red2: + case kHALAllianceStationID_red3: + return kRed; + case kHALAllianceStationID_blue1: + case kHALAllianceStationID_blue2: + case kHALAllianceStationID_blue3: + return kBlue; + default: + return kInvalid; + } } /** @@ -474,8 +320,20 @@ DriverStation::Alliance DriverStation::GetAlliance() */ uint32_t DriverStation::GetLocation() { - wpi_assert ((m_controlData->dsID_Position >= '1') && (m_controlData->dsID_Position <= '3')); - return m_controlData->dsID_Position - '0'; + switch(m_allianceStationID) + { + case kHALAllianceStationID_red1: + case kHALAllianceStationID_blue1: + return 1; + case kHALAllianceStationID_red2: + case kHALAllianceStationID_blue2: + return 2; + case kHALAllianceStationID_red3: + case kHALAllianceStationID_blue3: + return 3; + default: + return 0; + } } /** @@ -504,12 +362,3 @@ double DriverStation::GetMatchTime() return 0.0; return Timer::GetFPGATimestamp() - m_approxMatchTimeOffset; } - -/** - * Return the team number that the Driver Station is configured for - * @return The team number - */ -uint16_t DriverStation::GetTeamNumber() -{ - return m_controlData->teamID; -} diff --git a/wpilibc/wpilibC++/lib/DriverStationEnhancedIO.cpp b/wpilibc/wpilibC++/lib/DriverStationEnhancedIO.cpp deleted file mode 100644 index 3c3c779cf1..0000000000 --- a/wpilibc/wpilibC++/lib/DriverStationEnhancedIO.cpp +++ /dev/null @@ -1,996 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) FIRST 2008. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */ -/*----------------------------------------------------------------------------*/ - -#include "DriverStationEnhancedIO.h" -//#include "NetworkCommunication/UsageReporting.h" -#include "HAL/cpp/Synchronized.hpp" -#include "WPIErrors.h" -#include - -/** - * DriverStationEnhancedIO contructor. - * - * This is only called once when the DriverStation constructor is called. - */ -DriverStationEnhancedIO::DriverStationEnhancedIO() - : m_inputValid (false) - , m_outputValid (false) - , m_configChanged (false) - , m_requestEnhancedEnable (false) -{ - bzero((char*)&m_inputData, sizeof(m_inputData)); - bzero((char*)&m_outputData, sizeof(m_outputData)); - m_outputData.size = sizeof(m_outputData) - 1; - m_outputData.id = kOutputBlockID; - // Expected to be active low, so initialize inactive. - m_outputData.data.fixed_digital_out = 0x3; - m_inputDataSemaphore = initializeMutexNormal(); - m_outputDataSemaphore = initializeMutexNormal(); - m_encoderOffsets[0] = 0; - m_encoderOffsets[1] = 0; -} - -/** - * DriverStationEnhancedIO destructor. - * - * Called only when the DriverStation class is destroyed. - */ -DriverStationEnhancedIO::~DriverStationEnhancedIO() -{ - deleteMutex(m_outputDataSemaphore); - deleteMutex(m_inputDataSemaphore); -} - -/** - * Called by the DriverStation class when data is available. - * This function will set any modified configuration / output, - * then read the input and configuration from the IO. - */ -void DriverStationEnhancedIO::UpdateData() -{ - int32_t retVal; - { - status_block_t tempOutputData; - Synchronized sync(m_outputDataSemaphore); - if (m_outputValid || m_configChanged || m_requestEnhancedEnable) - { - m_outputData.flags = kStatusValid; - if (m_requestEnhancedEnable) - { - // Someone called one of the get config APIs, but we are not in enhanced mode. - m_outputData.flags |= kForceEnhancedMode; - } - if (m_configChanged) - { - if (!m_outputValid) - { - // Someone called one of the set config APIs, but we are not in enhanced mode. - m_outputData.flags |= kForceEnhancedMode; - } - m_outputData.flags |= kStatusConfigChanged; - } - HALOverrideIOConfig((char*)&m_outputData, 5); - } - retVal = HALGetDynamicControlData(kOutputBlockID, (char*)&tempOutputData, sizeof(status_block_t), 5); - if (retVal == 0) - { - if (m_outputValid) - { - if (m_configChanged) - { - // If our config change made the round trip then clear the flag. - if (IsConfigEqual(tempOutputData, m_outputData)) - { - m_configChanged = false; - } - } - else - { - // TODO: This won't work until artf1128 is fixed - //if (tempOutputData.flags & kStatusConfigChanged) - { - // Configuration was updated on the DS, so update our local cache. - MergeConfigIntoOutput(tempOutputData, m_outputData); - } - } - } - else - { - // Initialize the local cache. - MergeConfigIntoOutput(tempOutputData, m_outputData); - } - m_requestEnhancedEnable = false; - m_outputValid = true; - } - else - { - m_outputValid = false; - m_inputValid = false; - } - } - { - Synchronized sync(m_inputDataSemaphore); - control_block_t tempInputData; - retVal = HALGetDynamicControlData(kInputBlockID, (char*)&tempInputData, sizeof(control_block_t), 5); - if (retVal == 0 && tempInputData.data.api_version == kSupportedAPIVersion) - { - m_inputData = tempInputData; - m_inputValid = true; - } - else - { - m_outputValid = false; - m_inputValid = false; - } - } -} - -/** - * Merge the config portion of the DS output block into the local cache. - */ -void DriverStationEnhancedIO::MergeConfigIntoOutput(const status_block_t &dsOutputBlock, status_block_t &localCache) -{ - localCache.data.digital = (localCache.data.digital & dsOutputBlock.data.digital_oe) | - (dsOutputBlock.data.digital & ~dsOutputBlock.data.digital_oe); - localCache.data.digital_oe = dsOutputBlock.data.digital_oe; - localCache.data.digital_pe = dsOutputBlock.data.digital_pe; - localCache.data.pwm_period[0] = dsOutputBlock.data.pwm_period[0]; - localCache.data.pwm_period[1] = dsOutputBlock.data.pwm_period[1]; - localCache.data.enables = dsOutputBlock.data.enables; -} - -/** - * Compare the config portion of the output blocks. - */ -bool DriverStationEnhancedIO::IsConfigEqual(const status_block_t &dsOutputBlock, const status_block_t &localCache) -{ - if (localCache.data.digital_oe != dsOutputBlock.data.digital_oe) return false; - if ((localCache.data.digital & ~dsOutputBlock.data.digital) != - (dsOutputBlock.data.digital & ~dsOutputBlock.data.digital)) return false; - if (localCache.data.digital_pe != dsOutputBlock.data.digital_pe) return false; - if (localCache.data.pwm_period[0] != dsOutputBlock.data.pwm_period[0]) return false; - if (localCache.data.pwm_period[1] != dsOutputBlock.data.pwm_period[1]) return false; - if (localCache.data.enables != dsOutputBlock.data.enables) return false; - return true; -} - -/** - * Query an accelerometer channel on the DS IO. - * - * @param channel The channel number to read. - * @return The current acceleration on the channel in Gs. - */ -double DriverStationEnhancedIO::GetAcceleration(tAccelChannel channel) -{ - if (channel < 1 || channel > 2) - { - wpi_setWPIErrorWithContext(ParameterOutOfRange, "channel must be between 1 and 2"); - return 0.0; - } - if (!m_inputValid) - { - wpi_setWPIError(EnhancedIOMissing); - return 0.0; - } - - static uint8_t reported_mask = 0; - if (!(reported_mask & (1 >> channel))) - { - HALReport(HALUsageReporting::kResourceType_DriverStationEIO, channel, HALUsageReporting::kDriverStationEIO_Acceleration); - reported_mask |= (1 >> channel); - } - - Synchronized sync(m_inputDataSemaphore); - return (m_inputData.data.accel[channel] - kAccelOffset) / kAccelScale; -} - -/** - * Query an analog input channel on the DS IO. - * - * @param channel The channel number to read. [1,8] - * @return The analog input voltage for the channel. - */ -double DriverStationEnhancedIO::GetAnalogIn(uint32_t channel) -{ - // 3.3V is the analog reference voltage - return GetAnalogInRatio(channel) * kAnalogInputReference; -} - -/** - * Query an analog input channel on the DS IO in ratiometric form. - * - * @param channel The channel number to read. [1,8] - * @return The analog input percentage for the channel. - */ -double DriverStationEnhancedIO::GetAnalogInRatio(uint32_t channel) -{ - if (channel < 1 || channel > 8) - { - wpi_setWPIErrorWithContext(ParameterOutOfRange, "channel must be between 1 and 8"); - return 0.0; - } - if (!m_inputValid) - { - wpi_setWPIError(EnhancedIOMissing); - return 0.0; - } - - static uint16_t reported_mask = 0; - if (!(reported_mask & (1 >> channel))) - { - HALReport(HALUsageReporting::kResourceType_DriverStationEIO, channel, HALUsageReporting::kDriverStationEIO_AnalogIn); - reported_mask |= (1 >> channel); - } - - Synchronized sync(m_inputDataSemaphore); - return m_inputData.data.analog[channel-1] / kAnalogInputResolution; -} - -/** - * Query the voltage currently being output. - * - * AO1 is pin 11 on the top connector (P2). - * AO2 is pin 12 on the top connector (P2). - * - * @param channel The analog output channel on the DS IO. [1,2] - * @return The voltage being output on the channel. - */ -double DriverStationEnhancedIO::GetAnalogOut(uint32_t channel) -{ - if (channel < 1 || channel > 2) - { - wpi_setWPIErrorWithContext(ParameterOutOfRange, "channel must be between 1 and 2"); - return 0.0; - } - if (!m_outputValid) - { - wpi_setWPIError(EnhancedIOMissing); - return 0.0; - } - - Synchronized sync(m_outputDataSemaphore); - return m_outputData.data.dac[channel-1] * kAnalogOutputReference / kAnalogOutputResolution; -} - -/** - * Set the analog output voltage. - * - * AO1 is pin 11 on the top connector (P2). - * AO2 is pin 12 on the top connector (P2). - * AO1 is the reference voltage for the 2 analog comparators on DIO15 and DIO16. - * - * The output range is 0V to 4V, however due to the supply voltage don't expect more than about 3V. - * Current supply capability is only 100uA. - * - * @param channel The analog output channel on the DS IO. [1,2] - * @param value The voltage to output on the channel. - */ -void DriverStationEnhancedIO::SetAnalogOut(uint32_t channel, double value) -{ - if (channel < 1 || channel > 2) - { - wpi_setWPIErrorWithContext(ParameterOutOfRange, "channel must be between 1 and 2"); - return; - } - if (!m_outputValid) - { - wpi_setWPIError(EnhancedIOMissing); - return; - } - if (value < 0.0) value = 0.0; - if (value > kAnalogOutputReference) value = kAnalogOutputReference; - - static uint8_t reported_mask = 0; - if (!(reported_mask & (1 >> channel))) - { - HALReport(HALUsageReporting::kResourceType_DriverStationEIO, channel, HALUsageReporting::kDriverStationEIO_AnalogOut); - reported_mask |= (1 >> channel); - } - - Synchronized sync(m_outputDataSemaphore); - m_outputData.data.dac[channel-1] = (uint8_t)(value / kAnalogOutputReference * kAnalogOutputResolution); -} - -/** - * Get the state of a button on the IO board. - * - * Button1 is the physical button "S1". - * Button2 is pin 4 on the top connector (P2). - * Button3 is pin 6 on the top connector (P2). - * Button4 is pin 8 on the top connector (P2). - * Button5 is pin 10 on the top connector (P2). - * Button6 is pin 7 on the top connector (P2). - * - * Button2 through Button6 are Capacitive Sense buttons. - * - * @param channel The button channel to read. [1,6] - * @return The state of the selected button. - */ -bool DriverStationEnhancedIO::GetButton(uint32_t channel) -{ - if (channel < 1 || channel > 6) - { - wpi_setWPIErrorWithContext(ParameterOutOfRange, "channel must be between 1 and 6"); - return false; - } - - static uint8_t reported_mask = 0; - if (!(reported_mask & (1 >> channel))) - { - HALReport(HALUsageReporting::kResourceType_DriverStationEIO, channel, HALUsageReporting::kDriverStationEIO_Button); - reported_mask |= (1 >> channel); - } - - return ((GetButtons() >> (channel-1)) & 1) != 0; -} - -/** - * Get the state of all the button channels. - * - * @return The state of the 6 button channels in the 6 lsb of the returned byte. - */ -uint8_t DriverStationEnhancedIO::GetButtons() -{ - if (!m_inputValid) - { - wpi_setWPIError(EnhancedIOMissing); - return 0; - } - HALReport(HALUsageReporting::kResourceType_DriverStationEIO, 0, HALUsageReporting::kDriverStationEIO_Button); - Synchronized sync(m_inputDataSemaphore); - return m_inputData.data.buttons; -} - -/** - * Set the state of an LED on the IO board. - * - * @param channel The LED channel to set. [1,8] - * @param value True to turn the LED on. - */ -void DriverStationEnhancedIO::SetLED(uint32_t channel, bool value) -{ - if (channel < 1 || channel > 8) - { - wpi_setWPIErrorWithContext(ParameterOutOfRange, "channel must be between 1 and 8"); - return; - } - if (!m_outputValid) - { - wpi_setWPIError(EnhancedIOMissing); - return; - } - - static uint16_t reported_mask = 0; - if (!(reported_mask & (1 >> channel))) - { - HALReport(HALUsageReporting::kResourceType_DriverStationEIO, channel, HALUsageReporting::kDriverStationEIO_LED); - reported_mask |= (1 >> channel); - } - - uint8_t leds; - Synchronized sync(m_outputDataSemaphore); - leds = m_outputData.data.leds; - - leds &= ~(1 << (channel-1)); - if (value) leds |= 1 << (channel-1); - - m_outputData.data.leds = leds; -} - -/** - * Set the state of all 8 LEDs on the IO board. - * - * @param value The state of each LED. LED1 is lsb and LED8 is msb. - */ -void DriverStationEnhancedIO::SetLEDs(uint8_t value) -{ - if (!m_outputValid) - { - wpi_setWPIError(EnhancedIOMissing); - return; - } - - HALReport(HALUsageReporting::kResourceType_DriverStationEIO, 0, HALUsageReporting::kDriverStationEIO_LED); - Synchronized sync(m_outputDataSemaphore); - m_outputData.data.leds = value; -} - -/** - * Get the current state of a DIO channel regardless of mode. - * - * @param channel The DIO channel to read. [1,16] - * @return The state of the selected digital line. - */ -bool DriverStationEnhancedIO::GetDigital(uint32_t channel) -{ - if (channel < 1 || channel > 16) - { - wpi_setWPIErrorWithContext(ParameterOutOfRange, "channel must be between 1 and 16"); - return false; - } - - static uint32_t reported_mask = 0; - if (!(reported_mask & (1 >> channel))) - { - HALReport(HALUsageReporting::kResourceType_DriverStationEIO, channel, HALUsageReporting::kDriverStationEIO_DigitalIn); - reported_mask |= (1 >> channel); - } - - return ((GetDigitals() >> (channel-1)) & 1) != 0; -} - -/** - * Get the state of all 16 DIO lines regardless of mode. - * - * @return The state of all DIO lines. DIO1 is lsb and DIO16 is msb. - */ -uint16_t DriverStationEnhancedIO::GetDigitals() -{ - if (!m_inputValid) - { - wpi_setWPIError(EnhancedIOMissing); - return 0; - } - HALReport(HALUsageReporting::kResourceType_DriverStationEIO, 0, HALUsageReporting::kDriverStationEIO_DigitalIn); - Synchronized sync(m_inputDataSemaphore); - return m_inputData.data.digital; -} - -/** - * Set the state of a DIO line that is configured for digital output. - * - * @param channel The DIO channel to set. [1,16] - * @param value The state to set the selected channel to. - */ -void DriverStationEnhancedIO::SetDigitalOutput(uint32_t channel, bool value) -{ - if (channel < 1 || channel > 16) - { - wpi_setWPIErrorWithContext(ParameterOutOfRange, "channel must be between 1 and 16"); - return; - } - if (!m_outputValid) - { - wpi_setWPIError(EnhancedIOMissing); - return; - } - - static uint32_t reported_mask = 0; - if (!(reported_mask & (1 >> channel))) - { - HALReport(HALUsageReporting::kResourceType_DriverStationEIO, channel, HALUsageReporting::kDriverStationEIO_DigitalOut); - reported_mask |= (1 >> channel); - } - - uint16_t digital; - Synchronized sync(m_outputDataSemaphore); - - if (m_outputData.data.digital_oe & (1 << (channel-1))) - { - digital = m_outputData.data.digital; - - digital &= ~(1 << (channel-1)); - if (value) digital |= 1 << (channel-1); - - m_outputData.data.digital = digital; - } - else - { - wpi_setWPIError(LineNotOutput); - } -} - -/** - * Get the current configuration for a DIO line. - * - * This has the side effect of forcing the Driver Station to switch to Enhanced mode if it's not when called. - * If Enhanced mode is not enabled when this is called, it will return kUnknown. - * - * @param channel The DIO channel config to get. [1,16] - * @return The configured mode for the DIO line. - */ -DriverStationEnhancedIO::tDigitalConfig DriverStationEnhancedIO::GetDigitalConfig(uint32_t channel) -{ - if (channel < 1 || channel > 16) - { - wpi_setWPIErrorWithContext(ParameterOutOfRange, "channel must be between 1 and 16"); - return kUnknown; - } - if (!m_outputValid) - { - m_requestEnhancedEnable = true; - wpi_setWPIError(EnhancedIOMissing); - return kUnknown; - } - Synchronized sync(m_outputDataSemaphore); - if ((channel >= 1) && (channel <= 4)) - { - if (m_outputData.data.pwm_enable & (1 << (channel - 1))) - { - return kPWM; - } - } - if ((channel >= 15) && (channel <= 16)) - { - if (m_outputData.data.comparator_enable & (1 << (channel - 15))) - { - return kAnalogComparator; - } - } - if (m_outputData.data.digital_oe & (1 << (channel - 1))) - { - return kOutput; - } - if (!(m_outputData.data.digital_pe & (1 << (channel - 1)))) - { - return kInputFloating; - } - if (m_outputData.data.digital & (1 << (channel - 1))) - { - return kInputPullUp; - } - else - { - return kInputPullDown; - } -} - -/** - * Override the DS's configuration of a DIO line. - * - * If configured to kInputFloating, the selected DIO line will be tri-stated with no internal pull resistor. - * - * If configured to kInputPullUp, the selected DIO line will be tri-stated with a 5k-Ohm internal pull-up resistor enabled. - * - * If configured to kInputPullDown, the selected DIO line will be tri-stated with a 5k-Ohm internal pull-down resistor enabled. - * - * If configured to kOutput, the selected DIO line will actively drive to 0V or Vddio (specified by J1 and J4). - * DIO1 through DIO12, DIO15, and DIO16 can source 4mA and can sink 8mA. - * DIO12 and DIO13 can source 4mA and can sink 25mA. - * - * In addition to the common configurations, DIO1 through DIO4 can be configured to kPWM to enable PWM output. - * - * In addition to the common configurations, DIO15 and DIO16 can be configured to kAnalogComparator to enable - * analog comparators on those 2 DIO lines. When enabled, the lines are tri-stated and will accept analog voltages - * between 0V and 3.3V. If the input voltage is greater than the voltage output by AO1, the DIO will read as true, - * if less then false. - * - * @param channel The DIO line to configure. [1,16] - * @param config The mode to put the DIO line in. - */ -void DriverStationEnhancedIO::SetDigitalConfig(uint32_t channel, tDigitalConfig config) -{ - if (channel < 1 || channel > 16) - { - wpi_setWPIErrorWithContext(ParameterOutOfRange, "channel must be between 1 and 16"); - return; - } - if (config == kPWM && (channel < 1 || channel > 4)) - { - wpi_setWPIErrorWithContext(ParameterOutOfRange, "channel in PWM mode must be between 1 and 4"); - return; - } - if (config == kAnalogComparator && (channel < 15 || channel > 16)) - { - wpi_setWPIErrorWithContext(ParameterOutOfRange, "channel in Analog Comparator mode must be between 15 and 16"); - return; - } - - Synchronized sync(m_outputDataSemaphore); - m_configChanged = true; - - if ((channel >= 1) && (channel <= 4)) - { - if (config == kPWM) - { - m_outputData.data.pwm_enable |= 1 << (channel - 1); - m_outputData.data.digital &= ~(1 << (channel - 1)); - m_outputData.data.digital_oe |= 1 << (channel - 1); - m_outputData.data.digital_pe &= ~(1 << (channel - 1)); - return; - } - else - { - m_outputData.data.pwm_enable &= ~(1 << (channel - 1)); - } - } - else if ((channel >= 15) && (channel <= 16)) - { - if (config == kAnalogComparator) - { - m_outputData.data.comparator_enable |= 1 << (channel - 15); - m_outputData.data.digital &= ~(1 << (channel - 1)); - m_outputData.data.digital_oe &= ~(1 << (channel - 1)); - m_outputData.data.digital_pe &= ~(1 << (channel - 1)); - return; - } - else - { - m_outputData.data.comparator_enable &= ~(1 << (channel - 15)); - } - } - if (config == kInputFloating) - { - m_outputData.data.digital &= ~(1 << (channel - 1)); - m_outputData.data.digital_oe &= ~(1 << (channel - 1)); - m_outputData.data.digital_pe &= ~(1 << (channel - 1)); - } - else if (config == kInputPullUp) - { - m_outputData.data.digital |= 1 << (channel - 1); - m_outputData.data.digital_oe &= ~(1 << (channel - 1)); - m_outputData.data.digital_pe |= 1 << (channel - 1); - } - else if (config == kInputPullDown) - { - m_outputData.data.digital &= ~(1 << (channel - 1)); - m_outputData.data.digital_oe &= ~(1 << (channel - 1)); - m_outputData.data.digital_pe |= 1 << (channel - 1); - } - else if (config == kOutput) - { - m_outputData.data.digital_oe |= 1 << (channel - 1); - m_outputData.data.digital_pe &= ~(1 << (channel - 1)); - } - else - { - // Something went wrong. - } -} - -/** - * Get the period of a PWM generator. - * - * This has the side effect of forcing the Driver Station to switch to Enhanced mode if it's not when called. - * If Enhanced mode is not enabled when this is called, it will return 0. - * - * @param channels Select the generator by specifying the two channels to which it is connected. - * @return The period of the PWM generator in seconds. - */ -double DriverStationEnhancedIO::GetPWMPeriod(tPWMPeriodChannels channels) -{ - if (channels < kPWMChannels1and2 || channels > kPWMChannels3and4) - { - wpi_setWPIErrorWithContext(ParameterOutOfRange, "channels must be kPWMChannels1and2 or kPWMChannels3and4"); - return 0.0; - } - if (!m_outputValid) - { - m_requestEnhancedEnable = true; - wpi_setWPIError(EnhancedIOMissing); - return 0.0; - } - - Synchronized sync(m_outputDataSemaphore); - return m_outputData.data.pwm_period[channels] / 24000000.0; -} - -/** - * Set the period of a PWM generator. - * - * There are 2 PWM generators on the IO board. One can generate PWM signals on DIO1 and DIO2, - * the other on DIO3 and DIO4. Each generator has one counter and two compare registers. As such, - * each pair of PWM outputs share the output period but have independent duty cycles. - * - * @param channels Select the generator by specifying the two channels to which it is connected. - * @param period The period of the PWM generator in seconds. [0.0,0.002731] - */ -void DriverStationEnhancedIO::SetPWMPeriod(tPWMPeriodChannels channels, double period) -{ - if (channels < kPWMChannels1and2 || channels > kPWMChannels3and4) - { - wpi_setWPIErrorWithContext(ParameterOutOfRange, "channels must be kPWMChannels1and2 or kPWMChannels3and4"); - return; - } - - // Convert to ticks based on the IO board's 24MHz clock - double ticks = period * 24000000.0; - // Limit the range of the ticks... warn if too big. - if (ticks > 65534.0) - { - wpi_setWPIError(EnhancedIOPWMPeriodOutOfRange); - ticks = 65534.0; - } - else if (ticks < 0.0) ticks = 0.0; - // Preserve the duty cycles. - double dutyCycles[2]; - dutyCycles[0] = GetPWMOutput((channels << 1) + 1); - dutyCycles[1] = GetPWMOutput((channels << 1) + 2); - { - Synchronized sync(m_outputDataSemaphore); - // Update the period - m_outputData.data.pwm_period[channels] = (uint16_t)ticks; - m_configChanged = true; - } - // Restore the duty cycles - SetPWMOutput((channels << 1) + 1, dutyCycles[0]); - SetPWMOutput((channels << 1) + 2, dutyCycles[1]); -} - -/** - * Get the state being output on a fixed digital output. - * - * @param channel The FixedDO line to get. [1,2] - * @return The state of the FixedDO line. - */ -bool DriverStationEnhancedIO::GetFixedDigitalOutput(uint32_t channel) -{ - if (channel < 1 || channel > 2) - { - wpi_setWPIErrorWithContext(ParameterOutOfRange, "channel must be between 1 and 2"); - return 0; - } - if (!m_outputValid) - { - wpi_setWPIError(EnhancedIOMissing); - return 0; - } - - Synchronized sync(m_outputDataSemaphore); - return ((m_outputData.data.fixed_digital_out >> (channel-1)) & 1) != 0; -} - -/** - * Set the state to output on a Fixed High Current Digital Output line. - * - * FixedDO1 is pin 5 on the top connector (P2). - * FixedDO2 is pin 3 on the top connector (P2). - * - * The FixedDO lines always output 0V and 3.3V regardless of J1 and J4. - * They can source 4mA and can sink 25mA. Because of this, they are expected to be used - * in an active low configuration, such as connecting to the cathode of a bright LED. - * Because they are expected to be active low, they default to true. - * - * @param channel The FixedDO channel to set. - * @param value The state to set the FixedDO. - */ -void DriverStationEnhancedIO::SetFixedDigitalOutput(uint32_t channel, bool value) -{ - if (channel < 1 || channel > 2) - { - wpi_setWPIErrorWithContext(ParameterOutOfRange, "channel must be between 1 and 2"); - return; - } - if (!m_outputValid) - { - wpi_setWPIError(EnhancedIOMissing); - return; - } - - static uint8_t reported_mask = 0; - if (!(reported_mask & (1 >> channel))) - { - HALReport(HALUsageReporting::kResourceType_DriverStationEIO, channel, HALUsageReporting::kDriverStationEIO_FixedDigitalOut); - reported_mask |= (1 >> channel); - } - - uint8_t digital; - Synchronized sync(m_outputDataSemaphore); - digital = m_outputData.data.fixed_digital_out; - - digital &= ~(1 << (channel-1)); - if (value) digital |= 1 << (channel-1); - - m_outputData.data.fixed_digital_out = digital; -} - -/** - * Get the position of a quadrature encoder. - * - * There are two signed 16-bit 4X quadrature decoders on the IO board. These decoders are always monitoring - * the state of the lines assigned to them, but these lines do not have to be used for encoders. - * - * Encoder1 uses DIO4 for "A", DIO6 for "B", and DIO8 for "Index". - * Encoder2 uses DIO5 for "A", DIO7 for "B", and DIO9 for "Index". - * - * The index functionality can be enabled or disabled using SetEncoderIndexEnable(). - * - * @param encoderNumber The quadrature encoder to access. [1,2] - * @return The current position of the quadrature encoder. - */ -int16_t DriverStationEnhancedIO::GetEncoder(uint32_t encoderNumber) -{ - if (encoderNumber < 1 || encoderNumber > 2) - { - wpi_setWPIErrorWithContext(ParameterOutOfRange, "encoderNumber must be between 1 and 2"); - return 0; - } - if (!m_inputValid) - { - wpi_setWPIError(EnhancedIOMissing); - return 0; - } - - static uint8_t reported_mask = 0; - if (!(reported_mask & (1 >> encoderNumber))) - { - HALReport(HALUsageReporting::kResourceType_DriverStationEIO, encoderNumber, HALUsageReporting::kDriverStationEIO_Encoder); - reported_mask |= (1 >> encoderNumber); - } - - Synchronized sync(m_inputDataSemaphore); - return m_inputData.data.quad[encoderNumber - 1] - m_encoderOffsets[encoderNumber - 1]; -} - -/** - * Reset the position of an encoder to 0. - * - * This simply stores an offset locally. It does not reset the hardware counter on the IO board. - * If you use this method with Index enabled, you may get unexpected results. - * - * @param encoderNumber The quadrature encoder to reset. [1,2] - */ -void DriverStationEnhancedIO::ResetEncoder(uint32_t encoderNumber) -{ - if (encoderNumber < 1 || encoderNumber > 2) - { - wpi_setWPIErrorWithContext(ParameterOutOfRange, "encoderNumber must be between 1 and 2"); - return; - } - if (!m_inputValid) - { - wpi_setWPIError(EnhancedIOMissing); - return; - } - - Synchronized sync(m_inputDataSemaphore); - m_encoderOffsets[encoderNumber - 1] = m_inputData.data.quad[encoderNumber - 1]; -} - -/** - * Get the current configuration of a quadrature encoder index channel. - * - * This has the side effect of forcing the Driver Station to switch to Enhanced mode if it's not when called. - * If Enhanced mode is not enabled when this is called, it will return false. - * - * @param encoderNumber The quadrature encoder. [1,2] - * @return Is the index channel of the encoder enabled. - */ -bool DriverStationEnhancedIO::GetEncoderIndexEnable(uint32_t encoderNumber) -{ - if (encoderNumber < 1 || encoderNumber > 2) - { - wpi_setWPIErrorWithContext(ParameterOutOfRange, "encoderNumber must be between 1 and 2"); - return false; - } - if (!m_outputValid) - { - m_requestEnhancedEnable = true; - wpi_setWPIError(EnhancedIOMissing); - return false; - } - - Synchronized sync(m_outputDataSemaphore); - return ((m_outputData.data.quad_index_enable >> (encoderNumber - 1)) & 1) != 0; -} - -/** - * Enable or disable the index channel of a quadrature encoder. - * - * The quadrature decoders on the IO board support an active-low index input. - * - * Encoder1 uses DIO8 for "Index". - * Encoder2 uses DIO9 for "Index". - * - * When enabled, the decoder's counter will be reset to 0 when A, B, and Index are all low. - * - * @param encoderNumber The quadrature encoder. [1,2] - * @param enable If true, reset the encoder in an index condition. - */ -void DriverStationEnhancedIO::SetEncoderIndexEnable(uint32_t encoderNumber, bool enable) -{ - if (encoderNumber < 1 || encoderNumber > 2) - { - wpi_setWPIErrorWithContext(ParameterOutOfRange, "encoderNumber must be between 1 and 2"); - return; - } - - Synchronized sync(m_outputDataSemaphore); - m_outputData.data.quad_index_enable &= ~(1 << (encoderNumber - 1)); - if (enable) m_outputData.data.quad_index_enable |= 1 << (encoderNumber - 1); - m_configChanged = true; -} - -/** - * Get the value of the Capacitive Sense touch slider. - * - * @return Value between 0.0 (toward center of board) and 1.0 (toward edge of board). -1.0 means no touch detected. - */ -double DriverStationEnhancedIO::GetTouchSlider() -{ - if (!m_inputValid) - { - wpi_setWPIError(EnhancedIOMissing); - return 0.0; - } - - HALReport(HALUsageReporting::kResourceType_DriverStationEIO, 1, HALUsageReporting::kDriverStationEIO_TouchSlider); - - Synchronized sync(m_inputDataSemaphore); - uint8_t value = m_inputData.data.capsense_slider; - return value == 255 ? -1.0 : value / 254.0; -} - -/** - * Get the percent duty-cycle that the PWM generator channel is configured to output. - * - * @param channel The DIO line's PWM generator to get the duty-cycle from. [1,4] - * @return The percent duty-cycle being output (if the DIO line is configured for PWM). [0.0,1.0] - */ -double DriverStationEnhancedIO::GetPWMOutput(uint32_t channel) -{ - if (channel < 1 || channel > 4) - { - wpi_setWPIErrorWithContext(ParameterOutOfRange, "channel must be between 1 and 4"); - return 0.0; - } - if (!m_outputValid) - { - wpi_setWPIError(EnhancedIOMissing); - return 0.0; - } - - Synchronized sync(m_outputDataSemaphore); - return (double)m_outputData.data.pwm_compare[channel - 1] / (double)m_outputData.data.pwm_period[(channel - 1) >> 1]; -} - -/** - * Set the percent duty-cycle to output on a PWM enabled DIO line. - * - * DIO1 through DIO4 have the ability to output a PWM signal. The period of the - * signal can be configured in pairs using SetPWMPeriod(). - * - * @param channel The DIO line's PWM generator to set. [1,4] - * @param value The percent duty-cycle to output from the PWM generator. [0.0,1.0] - */ -void DriverStationEnhancedIO::SetPWMOutput(uint32_t channel, double value) -{ - if (channel < 1 || channel > 4) - { - wpi_setWPIErrorWithContext(ParameterOutOfRange, "channel must be between 1 and 4"); - return; - } - if (!m_outputValid) - { - wpi_setWPIError(EnhancedIOMissing); - return; - } - - static uint8_t reported_mask = 0; - if (!(reported_mask & (1 >> channel))) - { - HALReport(HALUsageReporting::kResourceType_DriverStationEIO, channel, HALUsageReporting::kDriverStationEIO_PWM); - reported_mask |= (1 >> channel); - } - - if (value > 1.0) value = 1.0; - else if (value < 0.0) value = 0.0; - Synchronized sync(m_outputDataSemaphore); - m_outputData.data.pwm_compare[channel - 1] = (uint16_t)(value * (double)m_outputData.data.pwm_period[(channel - 1) >> 1]); -} - -/** - * Get the firmware version running on the IO board. - * - * This also has the side effect of forcing the driver station to switch to Enhanced mode if it is not. - * If you plan to switch between Driver Stations with unknown IO configurations, you can call this - * until it returns a non-0 version to ensure that this API is accessible before proceeding. - * - * @return The version of the firmware running on the IO board. 0 if the board is not attached or not in Enhanced mode. - */ -uint8_t DriverStationEnhancedIO::GetFirmwareVersion() -{ - if (!m_inputValid) - { - m_requestEnhancedEnable = true; - wpi_setWPIError(EnhancedIOMissing); - return 0; - } - - Synchronized sync(m_inputDataSemaphore); - return m_inputData.data.fw_version; -} - diff --git a/wpilibc/wpilibC++/lib/DriverStationLCD.cpp b/wpilibc/wpilibC++/lib/DriverStationLCD.cpp deleted file mode 100644 index ab16d8acec..0000000000 --- a/wpilibc/wpilibC++/lib/DriverStationLCD.cpp +++ /dev/null @@ -1,168 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) FIRST 2008. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */ -/*----------------------------------------------------------------------------*/ - -#include "DriverStationLCD.h" - -//#include -#include -//#include "NetworkCommunication/FRCComm.h" -//#include "NetworkCommunication/UsageReporting.h" -#include "HAL/cpp/Synchronized.hpp" -#include "WPIErrors.h" -#undef min - -const uint32_t DriverStationLCD::kSyncTimeout_ms; -const uint16_t DriverStationLCD::kFullDisplayTextCommand; -const int32_t DriverStationLCD::kLineLength; -const int32_t DriverStationLCD::kNumLines; -DriverStationLCD* DriverStationLCD::m_instance = NULL; - -/** - * DriverStationLCD contructor. - * - * This is only called once the first time GetInstance() is called - */ -DriverStationLCD::DriverStationLCD() - : m_textBuffer (NULL) - , m_textBufferSemaphore (NULL) -{ - m_textBuffer = new char[HAL_USER_DS_LCD_DATA_SIZE]; - memset(m_textBuffer, ' ', HAL_USER_DS_LCD_DATA_SIZE); - - *((uint16_t *)m_textBuffer) = kFullDisplayTextCommand; - - m_textBufferSemaphore = initializeMutexNormal(); - - HALReport(HALUsageReporting::kResourceType_DriverStationLCD, 0); - - AddToSingletonList(); -} - -DriverStationLCD::~DriverStationLCD() -{ - deleteMutex(m_textBufferSemaphore); - delete [] m_textBuffer; - m_instance = NULL; -} - -/** - * Return a pointer to the singleton DriverStationLCD. - */ -DriverStationLCD* DriverStationLCD::GetInstance() -{ - if (m_instance == NULL) - { - m_instance = new DriverStationLCD(); - } - return m_instance; -} - -/** - * Send the text data to the Driver Station. - */ -void DriverStationLCD::UpdateLCD() -{ - Synchronized sync(m_textBufferSemaphore); - HALSetUserDsLcdData(m_textBuffer, HAL_USER_DS_LCD_DATA_SIZE, kSyncTimeout_ms); -} - -/** - * Print formatted text to the Driver Station LCD text bufer. - * - * Use UpdateLCD() periodically to actually send the text to the Driver Station. - * - * @param line The line on the LCD to print to. - * @param startingColumn The column to start printing to. This is a 1-based number. - * @param writeFmt The printf format string describing how to print. - */ -void DriverStationLCD::Printf(Line line, int32_t startingColumn, const char *writeFmt, ...) -{ - va_list args; - va_start (args, writeFmt); - VPrintf(line, startingColumn, writeFmt, args); - va_end (args); -} - -void DriverStationLCD::VPrintf(Line line, int32_t startingColumn, const char *writeFmt, va_list args) -{ - uint32_t start = startingColumn - 1; - int32_t maxLength = kLineLength - start; - char lineBuffer[kLineLength + 1]; - - if (startingColumn < 1 || startingColumn > kLineLength) - { - wpi_setWPIErrorWithContext(ParameterOutOfRange, "startingColumn"); - return; - } - - if (line < kMain_Line6 || line > kUser_Line6) - { - wpi_setWPIErrorWithContext(ParameterOutOfRange, "line"); - return; - } - - { - Synchronized sync(m_textBufferSemaphore); - // snprintf appends NULL to its output. Therefore we can't write directly to the buffer. - int32_t length = vsnprintf(lineBuffer, kLineLength + 1, writeFmt, args); - if (length < 0) length = kLineLength; - - memcpy(m_textBuffer + start + line * kLineLength + sizeof(uint16_t), lineBuffer, std::min(maxLength,length)); - } -} - -/** - * Print formatted text to the Driver Station LCD text bufer. This function - * pads the line with empty spaces. - * - * Use UpdateLCD() periodically to actually send the text to the Driver Station. - * - * @param line The line on the LCD to print to. - * @param writeFmt The printf format string describing how to print. - */ -void DriverStationLCD::PrintfLine(Line line, const char *writeFmt, ...) -{ - va_list args; - va_start (args, writeFmt); - VPrintfLine(line, writeFmt, args); - va_end (args); -} - -void DriverStationLCD::VPrintfLine(Line line, const char *writeFmt, va_list args) -{ - char lineBuffer[kLineLength + 1]; - - if (line < kMain_Line6 || line > kUser_Line6) - { - wpi_setWPIErrorWithContext(ParameterOutOfRange, "line"); - return; - } - - { - Synchronized sync(m_textBufferSemaphore); - // snprintf appends NULL to its output. Therefore we can't write directly to the buffer. - int32_t length = std::min(vsnprintf(lineBuffer, kLineLength + 1, writeFmt, args), (int)kLineLength); - if (length < 0) length = kLineLength; - - // Fill the rest of the buffer - if (length < kLineLength) - { - memset(lineBuffer + length, ' ', kLineLength - length); - } - - memcpy(m_textBuffer + line * kLineLength + sizeof(uint16_t), lineBuffer, kLineLength); - } -} - -/** - * Clear all lines on the LCD. - */ -void DriverStationLCD::Clear() -{ - Synchronized sync(m_textBufferSemaphore); - memset(m_textBuffer + sizeof(uint16_t), ' ', kLineLength*kNumLines); -} - diff --git a/wpilibc/wpilibC++/lib/SensorBase.cpp b/wpilibc/wpilibC++/lib/SensorBase.cpp index a7942b8013..a725418cd8 100644 --- a/wpilibc/wpilibC++/lib/SensorBase.cpp +++ b/wpilibc/wpilibC++/lib/SensorBase.cpp @@ -101,7 +101,7 @@ void SensorBase::DeleteSingletons() */ bool SensorBase::CheckSolenoidModule(uint8_t moduleNumber) { - if (nLoadOut::getModulePresence(nLoadOut::kModuleType_Solenoid, moduleNumber - 1)) + if (moduleNumber < 64) return true; return false; } diff --git a/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/DriverStation.java b/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/DriverStation.java index eaa3e32862..0d44ffd958 100644 --- a/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/DriverStation.java +++ b/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/DriverStation.java @@ -10,8 +10,8 @@ import java.nio.ByteBuffer; import java.nio.ByteOrder; import edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary; -import edu.wpi.first.wpilibj.communication.FRCCommonControlData; -import edu.wpi.first.wpilibj.communication.FRCCommonControlMasks; +import edu.wpi.first.wpilibj.communication.HALControlWord; +import edu.wpi.first.wpilibj.communication.HALAllianceStationID; import edu.wpi.first.wpilibj.hal.HALUtil; import edu.wpi.first.wpilibj.Timer; @@ -24,14 +24,6 @@ public class DriverStation implements RobotState.Interface { * The size of the user status data */ public static final int USER_STATUS_DATA_SIZE = FRCNetworkCommunicationsLibrary.USER_STATUS_DATA_SIZE; - /** - * Slot for the analog module to read the battery - */ - public static final int kBatterySlot = 1; - /** - * Analog channel to read the battery - */ - public static final int kBatteryChannel = 7; /** * Number of Joystick Ports */ @@ -48,28 +40,7 @@ public class DriverStation implements RobotState.Interface { /** * The robot alliance that the robot is a part of */ - public static class Alliance { - - /** The integer value representing this enumeration. */ - public final int value; - /** The Alliance name. */ - public final String name; - public static final int kRed_val = 0; - public static final int kBlue_val = 1; - public static final int kInvalid_val = 2; - /** alliance: Red */ - public static final Alliance kRed = new Alliance(kRed_val, "Red"); - /** alliance: Blue */ - public static final Alliance kBlue = new Alliance(kBlue_val, "Blue"); - /** alliance: Invalid */ - public static final Alliance kInvalid = new Alliance(kInvalid_val, "invalid"); - - private Alliance(int value, String name) { - this.value = value; - this.name = name; - } - } /* Alliance */ - + public enum Alliance { Red, Blue, Invalid } private static class DriverStationTask implements Runnable { @@ -85,8 +56,12 @@ public class DriverStation implements RobotState.Interface { } /* DriverStationTask */ private static DriverStation instance = new DriverStation(); - private FRCCommonControlData m_controlData; - private AnalogInput m_batteryChannel; + + private HALControlWord m_controlWord; + private HALAllianceStationID m_allianceStationID; + private short[][] m_joystickAxes = new short[kJoystickAxes][kJoystickPorts]; + private int[] m_joystickButtons = new int[kJoystickPorts]; + private Thread m_thread; private final Object m_semaphore; private final Object m_dataSem; @@ -121,18 +96,12 @@ public class DriverStation implements RobotState.Interface { * instance static member variable. */ protected DriverStation() { - m_controlData = new FRCCommonControlData(); m_semaphore = new Object(); m_dataSem = new Object(); m_dashboardInUseHigh = m_dashboardDefaultHigh = new Dashboard(m_semaphore); m_dashboardInUseLow = m_dashboardDefaultLow = new Dashboard(m_semaphore); - // m_controlData is initialized in constructor FRCCommonControlData. - - // XXX: Uncomment when analogChannel is fixed - //m_batteryChannel = new AnalogChannel(kBatterySlot, kBatteryChannel); - m_packetDataAvailableSem = HALUtil.initializeMutexNormal(); // set the byte order @@ -216,7 +185,17 @@ public class DriverStation implements RobotState.Interface { * the data will be copied from the DS polling loop. */ protected synchronized void getData() { - FRCNetworkCommunicationsLibrary.getCommonControlData(m_controlData); + // Get the status data + m_controlWord = FRCNetworkCommunicationsLibrary.HALGetControlWord(); + + // Get the location/alliance data + m_allianceStationID = FRCNetworkCommunicationsLibrary.HALGetAllianceStation(); + + // Get the status of all of the joysticks + for(byte stick = 0; stick < kJoystickPorts; stick++) { + m_joystickButtons[stick] = FRCNetworkCommunicationsLibrary.HALGetJoystickButtons(stick); + m_joystickAxes[stick] = FRCNetworkCommunicationsLibrary.HALGetJoystickAxes(stick); + } if (!lastEnabled && isEnabled()) { // If starting teleop, assume that autonomous just took up 15 seconds @@ -239,7 +218,8 @@ public class DriverStation implements RobotState.Interface { */ protected void setData() { synchronized (m_semaphore) { - FRCNetworkCommunicationsLibrary.setStatusData((float) getBatteryVoltage(), + // TODO ??? + /*FRCNetworkCommunicationsLibrary.setStatusData((float) getBatteryVoltage(), (byte) m_digitalOut, (byte) m_updateNumber, new String(m_dashboardInUseHigh.getBytes()), @@ -247,25 +227,17 @@ public class DriverStation implements RobotState.Interface { new String(m_dashboardInUseLow.getBytes()), m_dashboardInUseLow.getBytesLength()); m_dashboardInUseHigh.flush(); - m_dashboardInUseLow.flush(); + m_dashboardInUseLow.flush();*/ } } /** - * Read the battery voltage from the specified AnalogChannel. - * - * This accessor assumes that the battery voltage is being measured - * through the voltage divider on an analog breakout. + * Read the battery voltage. * * @return The battery voltage. */ public double getBatteryVoltage() { - // The Analog bumper has a voltage divider on the battery source. - // Vbatt *--/\/\/\--* Vsample *--/\/\/\--* Gnd - // 680 Ohms 1000 Ohms - // XXX: Uncomment this when analog channel is fixed - //return m_batteryChannel.getAverageVoltage() * (1680.0 / 1000.0); - return 12.0; + return 0.0; // TODO } /** @@ -277,42 +249,21 @@ public class DriverStation implements RobotState.Interface { * @return The value of the axis on the joystick. */ public double getStickAxis(int stick, int axis) { + if(stick < 1 || stick > kJoystickPorts) { + throw new RuntimeException("Joystick index is out of range, should be 1-4"); + } + if (axis < 1 || axis > kJoystickAxes) { - return 0.0; + throw new RuntimeException("Joystick axis is out of range"); } - int value; - switch (stick) { - case 1: - value = m_controlData.stick0Axes[axis - 1]; - break; - case 2: - value = m_controlData.stick1Axes[axis - 1]; - break; - case 3: - value = m_controlData.stick2Axes[axis - 1]; - break; - case 4: - value = m_controlData.stick3Axes[axis - 1]; - break; - default: - return 0.0; - } + byte value = (byte)m_joystickAxes[stick - 1][axis - 1]; - double result; - if (value < 0) { - result = ((double) value) / 128.0; + if(value < 0) { + return value / 128.0; } else { - result = ((double) value) / 127.0; + return value / 127.0; } - - // wpi_assert(result <= 1.0 && result >= -1.0); - if (result > 1.0) { - result = 1.0; - } else if (result < -1.0) { - result = -1.0; - } - return result; } /** @@ -323,76 +274,11 @@ public class DriverStation implements RobotState.Interface { * @return The state of the buttons on the joystick. */ public int getStickButtons(final int stick) { - switch (stick) { - case 1: - return m_controlData.stick0Buttons; - case 2: - return m_controlData.stick1Buttons; - case 3: - return m_controlData.stick2Buttons; - case 4: - return m_controlData.stick3Buttons; - default: - return 0; + if(stick < 1 || stick > kJoystickPorts) { + throw new RuntimeException("Joystick index is out of range, should be 1-4"); } - } - /** - * Get an analog voltage from the Driver Station. - * The analog values are returned as voltage values for the Driver Station analog inputs. - * These inputs are typically used for advanced operator interfaces consisting of potentiometers - * or resistor networks representing values on a rotary switch. - * - * @param channel The analog input channel on the driver station to read from. Valid range is 1 - 4. - * @return The analog voltage on the input. - */ - public double getAnalogIn(final int channel) { - switch (channel) { - case 1: - return kDSAnalogInScaling * m_controlData.analog1; - case 2: - return kDSAnalogInScaling * m_controlData.analog2; - case 3: - return kDSAnalogInScaling * m_controlData.analog3; - case 4: - return kDSAnalogInScaling * m_controlData.analog4; - default: - return 0.0; - } - } - - /** - * Get values from the digital inputs on the Driver Station. - * Return digital values from the Drivers Station. These values are typically used for buttons - * and switches on advanced operator interfaces. - * @param channel The digital input to get. Valid range is 1 - 8. - * @return The value of the digital input - */ - public boolean getDigitalIn(final int channel) { - return ((m_controlData.dsDigitalIn >> (channel - 1)) & 0x1) == 0x1; - } - - /** - * Set a value for the digital outputs on the Driver Station. - * - * Control digital outputs on the Drivers Station. These values are typically used for - * giving feedback on a custom operator station such as LEDs. - * - * @param channel The digital output to set. Valid range is 1 - 8. - * @param value The state to set the digital output. - */ - public void setDigitalOut(final int channel, final boolean value) { - m_digitalOut &= ~(0x1 << (channel - 1)); - m_digitalOut |= ((value ? 1 : 0) << (channel - 1)); - } - - /** - * Get a value that was set for the digital outputs on the Driver Station. - * @param channel The digital ouput to monitor. Valid range is 1 through 8. - * @return A digital value being output on the Drivers Station. - */ - public boolean getDigitalOut(final int channel) { - return ((m_digitalOut >> (channel - 1)) & 0x1) == 0x1; + return (int)m_joystickButtons[stick - 1]; } /** @@ -402,7 +288,7 @@ public class DriverStation implements RobotState.Interface { * @return True if the robot is enabled, false otherwise. */ public boolean isEnabled() { - return (m_controlData.control & FRCCommonControlMasks.ENABLED) != 0; + return m_controlWord.getEnabled(); } /** @@ -422,7 +308,7 @@ public class DriverStation implements RobotState.Interface { * @return True if autonomous mode should be enabled, false otherwise. */ public boolean isAutonomous() { - return (m_controlData.control & FRCCommonControlMasks.AUTONOMOUS) != 0; + return m_controlWord.getAutonomous(); } /** @@ -431,7 +317,7 @@ public class DriverStation implements RobotState.Interface { * @return True if test mode should be enabled, false otherwise. */ public boolean isTest() { - return (m_controlData.control & FRCCommonControlMasks.TEST) != 0; + return m_controlWord.getTest(); } /** @@ -454,29 +340,24 @@ public class DriverStation implements RobotState.Interface { return result; } - /** - * Return the DS packet number. - * The packet number is the index of this set of data returned by the driver station. - * Each time new data is received, the packet number (included with the sent data) is returned. - * - * @return The DS packet number. - */ - public int getPacketNumber() { - return m_controlData.packetIndex; - } - /** * Get the current alliance from the FMS * @return the current alliance */ public Alliance getAlliance() { - switch (m_controlData.dsID_Alliance) { - case 'R': - return Alliance.kRed; - case 'B': - return Alliance.kBlue; - default: - return Alliance.kInvalid; + switch (m_allianceStationID) { + case Red1: + case Red2: + case Red3: + return Alliance.Red; + + case Blue1: + case Blue2: + case Blue3: + return Alliance.Blue; + + default: + return Alliance.Invalid; } } @@ -486,15 +367,22 @@ public class DriverStation implements RobotState.Interface { * @return the location of the team's driver station controls: 1, 2, or 3 */ public int getLocation() { - return m_controlData.dsID_Position - '0'; - } + switch (m_allianceStationID) { + case Red1: + case Blue1: + return 1; - /** - * Return the team number that the Driver Station is configured for - * @return The team number - */ - public int getTeamNumber() { - return m_controlData.teamID; + case Red2: + case Blue2: + return 2; + + case Blue3: + case Red3: + return 3; + + default: + return 0; + } } /** @@ -590,7 +478,7 @@ public class DriverStation implements RobotState.Interface { * @return True if the robot is competing on a field being controlled by a Field Management System */ public boolean isFMSAttached() { - return (m_controlData.control & FRCCommonControlMasks.FMS_ATTATCHED) > 0; + return m_controlWord.getFMSAttached(); } /** diff --git a/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/DriverStationLCD.java b/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/DriverStationLCD.java deleted file mode 100644 index 531c85554e..0000000000 --- a/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/DriverStationLCD.java +++ /dev/null @@ -1,197 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) FIRST 2008-2012. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -package edu.wpi.first.wpilibj; - -import java.nio.ByteBuffer; -import java.nio.IntBuffer; - -import edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary; -import edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary.tResourceType; -import edu.wpi.first.wpilibj.communication.UsageReporting; - -/** - * Provide access to "LCD" on the Driver Station. - * This is the Messages box on the DS Operation tab. - * - * Buffer the printed data locally and then send it - * when UpdateLCD is called. - */ -public class DriverStationLCD extends SensorBase { - - private static DriverStationLCD m_instance; - /** - * Driver station timeout in milliseconds - */ - public static final int kSyncTimeout_ms = 20; - /** - * Command to display text - */ - public static final int kFullDisplayTextCommand = 0x9FFF; - /** - * Maximum line length for Driver Station display - */ - public static final int kLineLength = 21; - /** - * Total number of lines available - */ - public static final int kNumLines = 6; - - /** - * The line number on the Driver Station LCD - */ - public static class Line { - - /** - * The integer value representing this enumeration - */ - public final int value; - static final int kMain6_val = 0; - static final int kUser1_val = 0; - static final int kUser2_val = 1; - static final int kUser3_val = 2; - static final int kUser4_val = 3; - static final int kUser5_val = 4; - static final int kUser6_val = 5; - /** - * @deprecated Use kUser1 - * Line at the Top of the screen - */ - public static final Line kMain6 = new Line(kMain6_val); - /** - * Line at the Top of the screen - */ - public static final Line kUser1 = new Line(kUser1_val); - /** - * Line on the user screen - */ - public static final Line kUser2 = new Line(kUser2_val); - /** - * Line on the user screen - */ - public static final Line kUser3 = new Line(kUser3_val); - /** - * Line on the user screen - */ - public static final Line kUser4 = new Line(kUser4_val); - /** - * Line on the user screen - */ - public static final Line kUser5 = new Line(kUser5_val); - /** - * Bottom line on the user screen - */ - public static final Line kUser6 = new Line(kUser6_val); - - private Line(int value) { - this.value = value; - } - } - - byte[] m_textBuffer; - - /** - * Get an instance of the DriverStationLCD - * @return an instance of the DriverStationLCD - */ - public static synchronized DriverStationLCD getInstance() { - if (m_instance == null) - m_instance = new DriverStationLCD(); - return m_instance; - } - - /** - * DriverStationLCD constructor. - * - * This is only called once the first time GetInstance() is called - */ - private DriverStationLCD() { - m_textBuffer = new byte[FRCNetworkCommunicationsLibrary.USER_DS_LCD_DATA_SIZE]; - - for (int i = 0; i < FRCNetworkCommunicationsLibrary.USER_DS_LCD_DATA_SIZE; i++) { - m_textBuffer[i] = ' '; - } - - m_textBuffer[0] = (byte) (kFullDisplayTextCommand >> 8); - m_textBuffer[1] = (byte) kFullDisplayTextCommand; - - UsageReporting.report(tResourceType.kResourceType_DriverStationLCD, 0); - } - - /** - * Send the text data to the Driver Station. - */ - public synchronized void updateLCD() { - FRCNetworkCommunicationsLibrary.setUserDsLcdData(new String(m_textBuffer), FRCNetworkCommunicationsLibrary.USER_DS_LCD_DATA_SIZE, kSyncTimeout_ms); - } - - /** - * Print formatted text to the Driver Station LCD text buffer. - * - * Use UpdateLCD() periodically to actually send the test to the Driver Station. - * - * @param line The line on the LCD to print to. - * @param startingColumn The column to start printing to. This is a 1-based number. - * @param text the text to print - */ - public void println(Line line, int startingColumn, String text) { - int start = startingColumn - 1; - int maxLength = kLineLength - start; - - if (startingColumn < 1 || startingColumn > kLineLength) { - throw new IndexOutOfBoundsException("Column must be between 1 and " + kLineLength + ", inclusive"); - } - - int length = text.length(); - int finalLength = (length < maxLength ? length : maxLength); - synchronized (this) { - for (int i = 0; i < finalLength; i++) { - m_textBuffer[i + start + line.value * kLineLength + 2] = (byte)text.charAt(i); - } - } - } - - /** - * Print formatted text to the Driver Station LCD text buffer. - * - * Use UpdateLCD() periodically to actually send the test to the Driver Station. - * - * @param line The line on the LCD to print to. - * @param startingColumn The column to start printing to. This is a 1-based number. - * @param text the text to print - */ - public void println(Line line, int startingColumn, StringBuffer text) { - int start = startingColumn - 1; - int maxLength = kLineLength - start; - - if (startingColumn < 1 || startingColumn > kLineLength) { - throw new IndexOutOfBoundsException("Column must be between 1 and " + kLineLength + ", inclusive"); - } - - int length = text.length(); - int finalLength = (length < maxLength ? length : maxLength); - synchronized (this) { - for (int i = 0; i < finalLength; i++) { - m_textBuffer[i + start + line.value * kLineLength + 2] = (byte) text.charAt(i); - } - } - } - - /** - * Clear User Messages box on DS Operations Tab - * - * This method will clear all text currently displayed in the message box - */ - public void clear() { - synchronized (this) { - for (int i=0; i < kLineLength*kNumLines; i++) { - m_textBuffer[i+2] = ' '; - } - } - updateLCD(); - } -} diff --git a/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/communication/FRCCommonControlData.java b/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/communication/FRCCommonControlData.java deleted file mode 100644 index ea9c132651..0000000000 --- a/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/communication/FRCCommonControlData.java +++ /dev/null @@ -1,440 +0,0 @@ -package edu.wpi.first.wpilibj.communication; -//import com.ochafik.lang.jnaerator.runtime.Structure; -//import com.ochafik.lang.jnaerator.runtime.Union; -//import com.sun.jna.Pointer; -import java.util.Arrays; -import java.util.List; -/** - * native declaration : src\main\include\NetworkCommunication\FRCComm.h:11
- * This file was autogenerated by JNAerator,
- * a tool written by Olivier Chafik that uses a few opensource projects..
- * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class FRCCommonControlData /*extends Structure*/ { - public short packetIndex; - /** C type : field1_union */ - public byte control; - public byte dsDigitalIn; - public short teamID; - public byte dsID_Alliance; - public byte dsID_Position; - public byte[] stick0Axes = new byte[6]; - /** Left-most 4 bits are unused */ - public short stick0Buttons; - public byte[] stick1Axes = new byte[6]; - /** Left-most 4 bits are unused */ - public short stick1Buttons; - public byte[] stick2Axes = new byte[6]; - /** Left-most 4 bits are unused */ - public short stick2Buttons; - public byte[] stick3Axes = new byte[6]; - /** Left-most 4 bits are unused */ - public short stick3Buttons; - /** Analog inputs are 10 bit right-justified */ - public short analog1; - public short analog2; - public short analog3; - public short analog4; - public long cRIOChecksum; - public int FPGAChecksum0; - public int FPGAChecksum1; - public int FPGAChecksum2; - public int FPGAChecksum3; - /** C type : char[8] */ - public byte[] versionData = new byte[8]; - - /** native declaration : src\main\include\NetworkCommunication\FRCComm.h:13 */ - public static class field1_union /*extends Union*/ { - public byte control; - /** C type : field1_struct */ - public field1_struct field1; - /** native declaration : src\main\include\NetworkCommunication\FRCComm.h:16 */ - public static abstract class field1_struct /*extends Structure*/ { - /** Conversion Error : checkVersions:1 (This runtime does not support bit fields : JNAerator (based on JNA) (please use BridJ instead)) */ - /** Conversion Error : test:1 (This runtime does not support bit fields : JNAerator (based on JNA) (please use BridJ instead)) */ - /** Conversion Error : resync:1 (This runtime does not support bit fields : JNAerator (based on JNA) (please use BridJ instead)) */ - /** Conversion Error : fmsAttached:1 (This runtime does not support bit fields : JNAerator (based on JNA) (please use BridJ instead)) */ - /** Conversion Error : autonomous:1 (This runtime does not support bit fields : JNAerator (based on JNA) (please use BridJ instead)) */ - /** Conversion Error : enabled:1 (This runtime does not support bit fields : JNAerator (based on JNA) (please use BridJ instead)) */ - /** Conversion Error : notEStop:1 (This runtime does not support bit fields : JNAerator (based on JNA) (please use BridJ instead)) */ - /** Conversion Error : reset:1 (This runtime does not support bit fields : JNAerator (based on JNA) (please use BridJ instead)) */ - public field1_struct() { - super(); - } - protected List getFieldOrder() { - return Arrays.asList(); - } - //public field1_struct(Pointer peer) { - // super(peer); - //} - //public static abstract class ByReference extends field1_struct implements Structure.ByReference { - - //}; - //public static abstract class ByValue extends field1_struct implements Structure.ByValue { - - //}; - }; - public field1_union() { - super(); - } - /** @param field1 C type : field1_struct */ - public field1_union(field1_struct field1) { - super(); - this.field1 = field1; - //setType(field1_struct.class); - } - public field1_union(byte control) { - super(); - this.control = control; - //setType(Byte.TYPE); - } - //public field1_union(Pointer peer) { - // super(peer); - //} - //protected ByReference newByReference() { return new ByReference(); } - //protected ByValue newByValue() { return new ByValue(); } - protected field1_union newInstance() { return new field1_union(); } - //public static field1_union[] newArray(int arrayLength) { - // return Union.newArray(field1_union.class, arrayLength); - //} - //public static class ByReference extends field1_union implements Structure.ByReference { - - //}; - //public static class ByValue extends field1_union implements Structure.ByValue { - - //}; - }; - /** native declaration : src\main\include\NetworkCommunication\FRCComm.h:45 */ - public static class field2_union /*extends Union*/ { - /** C type : int8_t[6] */ - public byte[] stick0Axes = new byte[6]; - /** C type : field1_struct */ - public field1_struct field1; - /** native declaration : src\main\include\NetworkCommunication\FRCComm.h:47 */ - public static class field1_struct /*extends Structure*/ { - public byte stick0Axis1; - public byte stick0Axis2; - public byte stick0Axis3; - public byte stick0Axis4; - public byte stick0Axis5; - public byte stick0Axis6; - public field1_struct() { - super(); - } - protected List getFieldOrder() { - return Arrays.asList("stick0Axis1", "stick0Axis2", "stick0Axis3", "stick0Axis4", "stick0Axis5", "stick0Axis6"); - } - public field1_struct(byte stick0Axis1, byte stick0Axis2, byte stick0Axis3, byte stick0Axis4, byte stick0Axis5, byte stick0Axis6) { - super(); - this.stick0Axis1 = stick0Axis1; - this.stick0Axis2 = stick0Axis2; - this.stick0Axis3 = stick0Axis3; - this.stick0Axis4 = stick0Axis4; - this.stick0Axis5 = stick0Axis5; - this.stick0Axis6 = stick0Axis6; - } - //public field1_struct(Pointer peer) { - // super(peer); - //} - //protected ByReference newByReference() { return new ByReference(); } - //protected ByValue newByValue() { return new ByValue(); } - protected field1_struct newInstance() { return new field1_struct(); } - //public static field1_struct[] newArray(int arrayLength) { - // return Structure.newArray(field1_struct.class, arrayLength); - //} - //public static class ByReference extends field1_struct implements Structure.ByReference { - - //}; - //public static class ByValue extends field1_struct implements Structure.ByValue { - - //}; - }; - public field2_union() { - super(); - } - /** @param field1 C type : field1_struct */ - public field2_union(field1_struct field1) { - super(); - this.field1 = field1; - //setType(field1_struct.class); - } - /** @param stick0Axes C type : int8_t[6] */ - public field2_union(byte stick0Axes[]) { - super(); - if ((stick0Axes.length != this.stick0Axes.length)) - throw new IllegalArgumentException("Wrong array size !"); - this.stick0Axes = stick0Axes; - //setType(byte[].class); - } - //public field2_union(Pointer peer) { - // super(peer); - //} - //protected ByReference newByReference() { return new ByReference(); } - //protected ByValue newByValue() { return new ByValue(); } - protected field2_union newInstance() { return new field2_union(); } - //public static field2_union[] newArray(int arrayLength) { - // return Union.newArray(field2_union.class, arrayLength); - //} - //public static class ByReference extends field2_union implements Structure.ByReference { - - //}; - //public static class ByValue extends field2_union implements Structure.ByValue { - - //}; - }; - /** native declaration : src\main\include\NetworkCommunication\FRCComm.h:58 */ - public static class field3_union /*extends Union*/ { - /** C type : int8_t[6] */ - public byte[] stick1Axes = new byte[6]; - /** C type : field1_struct */ - public field1_struct field1; - /** native declaration : src\main\include\NetworkCommunication\FRCComm.h:60 */ - public static class field1_struct /* extends Structure*/ { - public byte stick1Axis1; - public byte stick1Axis2; - public byte stick1Axis3; - public byte stick1Axis4; - public byte stick1Axis5; - public byte stick1Axis6; - public field1_struct() { - super(); - } - protected List getFieldOrder() { - return Arrays.asList("stick1Axis1", "stick1Axis2", "stick1Axis3", "stick1Axis4", "stick1Axis5", "stick1Axis6"); - } - public field1_struct(byte stick1Axis1, byte stick1Axis2, byte stick1Axis3, byte stick1Axis4, byte stick1Axis5, byte stick1Axis6) { - super(); - this.stick1Axis1 = stick1Axis1; - this.stick1Axis2 = stick1Axis2; - this.stick1Axis3 = stick1Axis3; - this.stick1Axis4 = stick1Axis4; - this.stick1Axis5 = stick1Axis5; - this.stick1Axis6 = stick1Axis6; - } - //public field1_struct(Pointer peer) { - // super(peer); - //} - //protected ByReference newByReference() { return new ByReference(); } - //protected ByValue newByValue() { return new ByValue(); } - protected field1_struct newInstance() { return new field1_struct(); } - //public static field1_struct[] newArray(int arrayLength) { - // return Structure.newArray(field1_struct.class, arrayLength); - //} - //public static class ByReference extends field1_struct implements Structure.ByReference { - // - //}; - //public static class ByValue extends field1_struct implements Structure.ByValue { - // - //}; - }; - public field3_union() { - super(); - } - /** @param field1 C type : field1_struct */ - public field3_union(field1_struct field1) { - super(); - this.field1 = field1; - //setType(field1_struct.class); - } - /** @param stick1Axes C type : int8_t[6] */ - public field3_union(byte stick1Axes[]) { - super(); - if ((stick1Axes.length != this.stick1Axes.length)) - throw new IllegalArgumentException("Wrong array size !"); - this.stick1Axes = stick1Axes; - //setType(byte[].class); - } - //public field3_union(Pointer peer) { - // super(peer); - //} - //protected ByReference newByReference() { return new ByReference(); } - //protected ByValue newByValue() { return new ByValue(); } - protected field3_union newInstance() { return new field3_union(); } - //public static field3_union[] newArray(int arrayLength) { - // return Union.newArray(field3_union.class, arrayLength); - //} - //public static class ByReference extends field3_union implements Structure.ByReference { - // - //}; - //public static class ByValue extends field3_union implements Structure.ByValue { - - //}; - }; - /** native declaration : src\main\include\NetworkCommunication\FRCComm.h:71 */ - public static class field4_union /*extends Union*/ { - /** C type : int8_t[6] */ - public byte[] stick2Axes = new byte[6]; - /** C type : field1_struct */ - public field1_struct field1; - /** native declaration : src\main\include\NetworkCommunication\FRCComm.h:73 */ - public static class field1_struct /* extends Structure*/ { - public byte stick2Axis1; - public byte stick2Axis2; - public byte stick2Axis3; - public byte stick2Axis4; - public byte stick2Axis5; - public byte stick2Axis6; - public field1_struct() { - super(); - } - protected List getFieldOrder() { - return Arrays.asList("stick2Axis1", "stick2Axis2", "stick2Axis3", "stick2Axis4", "stick2Axis5", "stick2Axis6"); - } - public field1_struct(byte stick2Axis1, byte stick2Axis2, byte stick2Axis3, byte stick2Axis4, byte stick2Axis5, byte stick2Axis6) { - super(); - this.stick2Axis1 = stick2Axis1; - this.stick2Axis2 = stick2Axis2; - this.stick2Axis3 = stick2Axis3; - this.stick2Axis4 = stick2Axis4; - this.stick2Axis5 = stick2Axis5; - this.stick2Axis6 = stick2Axis6; - } - //public field1_struct(Pointer peer) { - // super(peer); - //} - //protected ByReference newByReference() { return new ByReference(); } - //protected ByValue newByValue() { return new ByValue(); } - protected field1_struct newInstance() { return new field1_struct(); } - //public static field1_struct[] newArray(int arrayLength) { - // return Structure.newArray(field1_struct.class, arrayLength); - //} - //public static class ByReference extends field1_struct implements Structure.ByReference { - - //}; - //public static class ByValue extends field1_struct implements Structure.ByValue { - - //}; - }; - public field4_union() { - super(); - } - /** @param field1 C type : field1_struct */ - public field4_union(field1_struct field1) { - super(); - this.field1 = field1; - //setType(field1_struct.class); - } - /** @param stick2Axes C type : int8_t[6] */ - public field4_union(byte stick2Axes[]) { - super(); - if ((stick2Axes.length != this.stick2Axes.length)) - throw new IllegalArgumentException("Wrong array size !"); - this.stick2Axes = stick2Axes; - //setType(byte[].class); - } - //public field4_union(Pointer peer) { - // super(peer); - //} - //protected ByReference newByReference() { return new ByReference(); } - //protected ByValue newByValue() { return new ByValue(); } - protected field4_union newInstance() { return new field4_union(); } - //public static field4_union[] newArray(int arrayLength) { - // return Union.newArray(field4_union.class, arrayLength); - //} - //public static class ByReference extends field4_union implements Structure.ByReference { - - //}; - //public static class ByValue extends field4_union implements Structure.ByValue { - - //}; - }; - /** native declaration : src\main\include\NetworkCommunication\FRCComm.h:84 */ - public static class field5_union /* extends Union*/ { - /** C type : int8_t[6] */ - public byte[] stick3Axes = new byte[6]; - /** C type : field1_struct */ - public field1_struct field1; - /** native declaration : src\main\include\NetworkCommunication\FRCComm.h:86 */ - public static class field1_struct /*extends Structure*/ { - public byte stick3Axis1; - public byte stick3Axis2; - public byte stick3Axis3; - public byte stick3Axis4; - public byte stick3Axis5; - public byte stick3Axis6; - public field1_struct() { - super(); - } - protected List getFieldOrder() { - return Arrays.asList("stick3Axis1", "stick3Axis2", "stick3Axis3", "stick3Axis4", "stick3Axis5", "stick3Axis6"); - } - public field1_struct(byte stick3Axis1, byte stick3Axis2, byte stick3Axis3, byte stick3Axis4, byte stick3Axis5, byte stick3Axis6) { - super(); - this.stick3Axis1 = stick3Axis1; - this.stick3Axis2 = stick3Axis2; - this.stick3Axis3 = stick3Axis3; - this.stick3Axis4 = stick3Axis4; - this.stick3Axis5 = stick3Axis5; - this.stick3Axis6 = stick3Axis6; - } - //public field1_struct(Pointer peer) { - // super(peer); - //} - //protected ByReference newByReference() { return new ByReference(); } - //protected ByValue newByValue() { return new ByValue(); } - protected field1_struct newInstance() { return new field1_struct(); } - //public static field1_struct[] newArray(int arrayLength) { - // return Structure.newArray(field1_struct.class, arrayLength); - //} - //public static class ByReference extends field1_struct implements Structure.ByReference { - - //}; - //public static class ByValue extends field1_struct implements Structure.ByValue { - - //}; - }; - public field5_union() { - super(); - } - /** @param field1 C type : field1_struct */ - public field5_union(field1_struct field1) { - super(); - this.field1 = field1; - //setType(field1_struct.class); - } - /** @param stick3Axes C type : int8_t[6] */ - public field5_union(byte stick3Axes[]) { - super(); - if ((stick3Axes.length != this.stick3Axes.length)) - throw new IllegalArgumentException("Wrong array size !"); - this.stick3Axes = stick3Axes; - //setType(byte[].class); - } - //public field5_union(Pointer peer) { - // super(peer); - //} - //protected ByReference newByReference() { return new ByReference(); } - //protected ByValue newByValue() { return new ByValue(); } - protected field5_union newInstance() { return new field5_union(); } - //public static field5_union[] newArray(int arrayLength) { - // return Union.newArray(field5_union.class, arrayLength); - //} - //public static class ByReference extends field5_union implements Structure.ByReference { - - //}; - //public static class ByValue extends field5_union implements Structure.ByValue { - - //}; - }; - public FRCCommonControlData() { - super(); - } - protected List getFieldOrder() { - return Arrays.asList("packetIndex", "field1", "dsDigitalIn", "teamID", "dsID_Alliance", "dsID_Position", "field2", "stick0Buttons", "field3", "stick1Buttons", "field4", "stick2Buttons", "field5", "stick3Buttons", "analog1", "analog2", "analog3", "analog4", "cRIOChecksum", "FPGAChecksum0", "FPGAChecksum1", "FPGAChecksum2", "FPGAChecksum3", "versionData"); - } - //public FRCCommonControlData(Pointer peer) { - // super(peer); - //} - //protected ByReference newByReference() { return new ByReference(); } - //protected ByValue newByValue() { return new ByValue(); } - protected FRCCommonControlData newInstance() { return new FRCCommonControlData(); } - //public static FRCCommonControlData[] newArray(int arrayLength) { - // return Structure.newArray(FRCCommonControlData.class, arrayLength); - //} - //public static class ByReference extends FRCCommonControlData implements Structure.ByReference { - // - //}; - //public static class ByValue extends FRCCommonControlData implements Structure.ByValue { - - //}; -} diff --git a/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/communication/FRCCommonControlMasks.java b/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/communication/FRCCommonControlMasks.java deleted file mode 100644 index d0b73bf4d2..0000000000 --- a/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/communication/FRCCommonControlMasks.java +++ /dev/null @@ -1,12 +0,0 @@ -package edu.wpi.first.wpilibj.communication; - -public class FRCCommonControlMasks { - public static byte CHECK_VERSIONS = 1 << 0; - public static byte TEST = 1 << 1; - public static byte RESYNC = 1 << 2; - public static byte FMS_ATTATCHED = 1 << 3; - public static byte AUTONOMOUS = 1 << 4; - public static byte ENABLED = 1 << 5; - public static byte NOT_ESTOP = 1 << 6; - public static byte RESET = (byte) (1 << 7); -} diff --git a/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/communication/FRCNetworkCommunicationsLibrary.java b/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/communication/FRCNetworkCommunicationsLibrary.java index 4cf383c4a3..fce6d1d689 100644 --- a/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/communication/FRCNetworkCommunicationsLibrary.java +++ b/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/communication/FRCNetworkCommunicationsLibrary.java @@ -263,7 +263,7 @@ public class FRCNetworkCommunicationsLibrary extends JNIWrapper { * native declaration : src\main\include\NetworkCommunication\AICalibration.h:7
* @deprecated use the safer methods {@link #FRC_NetworkCommunication_nAICalibration_getLSBWeight(int, int, java.nio.IntBuffer)} and {@link #FRC_NetworkCommunication_nAICalibration_getLSBWeight(int, int, com.sun.jna.ptr.IntByReference)} instead */ - //@Deprecated + //@Deprecated //public static native int FRC_NetworkCommunication_nAICalibration_getLSBWeight(int aiSystemIndex, int channel, Integer status); /** * Original signature : uint32_t FRC_NetworkCommunication_nAICalibration_getLSBWeight(const uint32_t, const uint32_t, int32_t*)
@@ -275,18 +275,13 @@ public class FRCNetworkCommunicationsLibrary extends JNIWrapper { * native declaration : src\main\include\NetworkCommunication\AICalibration.h:8
* @deprecated use the safer methods {@link #FRC_NetworkCommunication_nAICalibration_getOffset(int, int, java.nio.IntBuffer)} and {@link #FRC_NetworkCommunication_nAICalibration_getOffset(int, int, com.sun.jna.ptr.IntByReference)} instead */ - //@Deprecated + //@Deprecated //public static native int FRC_NetworkCommunication_nAICalibration_getOffset(int aiSystemIndex, int channel, Integer status); /** * Original signature : int32_t FRC_NetworkCommunication_nAICalibration_getOffset(const uint32_t, const uint32_t, int32_t*)
* native declaration : src\main\include\NetworkCommunication\AICalibration.h:8 */ public static native int FRCNetworkCommunicationAICalibrationGetOffset(int aiSystemIndex, int channel, Integer status); - /** - * Original signature : bool getModulePresence(tModuleType, uint8_t)
- * native declaration : src\main\include\NetworkCommunication\LoadOut.h:14 - */ - public static native byte getModulePresence(int moduleType, byte moduleNumber); /** * Original signature : tTargetClass getTargetClass()
* native declaration : src\main\include\NetworkCommunication\LoadOut.h:25 @@ -309,7 +304,7 @@ public class FRCNetworkCommunicationsLibrary extends JNIWrapper { * native declaration : src\main\include\NetworkCommunication\symModuleLink.h:6
* @deprecated use the safer methods {@link #moduleNameFindBySymbolName(java.lang.String, java.nio.ByteBuffer)} and {@link #moduleNameFindBySymbolName(com.sun.jna.Pointer, com.sun.jna.Pointer)} instead */ - //@Deprecated + //@Deprecated //public static native FRC_NetworkCommunicationsLibrary.STATUS moduleNameFindBySymbolName(Pointer symbol, Pointer module); /** * Original signature : STATUS moduleNameFindBySymbolName(const char*, char*)
@@ -320,7 +315,7 @@ public class FRCNetworkCommunicationsLibrary extends JNIWrapper { //public static native FRC_NetworkCommunicationsLibrary.STATUS moduleNameFindBySymbolName(String symbol, ByteBuffer module); /** * Report the usage of a resource of interest.
- *
+ *
* @param resource one of the values in the tResourceType above (max value 51).
* @param instanceNumber an index that identifies the resource instance.
* @param context an optional additional context number for some cases (such as module number). Set to 0 to omit.
@@ -329,11 +324,11 @@ public class FRCNetworkCommunicationsLibrary extends JNIWrapper { * native declaration : src\main\include\NetworkCommunication\UsageReporting.h:113
* @deprecated use the safer methods {@link #report(int, byte, byte, java.lang.String)} and {@link #report(int, byte, byte, com.sun.jna.Pointer)} instead */ - //@Deprecated + //@Deprecated //public static native int report(int resource, byte instanceNumber, byte context, Pointer feature); /** * Report the usage of a resource of interest.
- *
+ *
* @param resource one of the values in the tResourceType above (max value 51).
* @param instanceNumber an index that identifies the resource instance.
* @param context an optional additional context number for some cases (such as module number). Set to 0 to omit.
@@ -347,7 +342,7 @@ public class FRCNetworkCommunicationsLibrary extends JNIWrapper { * native declaration : src\main\include\NetworkCommunication\UsageReporting.h:120
* @deprecated use the safer methods {@link #FRC_NetworkCommunication_nUsageReporting_report(byte, byte, byte, java.lang.String)} and {@link #FRC_NetworkCommunication_nUsageReporting_report(byte, byte, byte, com.sun.jna.Pointer)} instead */ - //@Deprecated + //@Deprecated //public static native int FRC_NetworkCommunication_nUsageReporting_report(byte resource, byte instanceNumber, byte context, Pointer feature); /** * Original signature : uint32_t FRC_NetworkCommunication_nUsageReporting_report(uint8_t, uint8_t, uint8_t, const char*)
@@ -359,101 +354,55 @@ public class FRCNetworkCommunicationsLibrary extends JNIWrapper { * native declaration : src\main\include\NetworkCommunication\FRCComm.h:124
* @deprecated use the safer methods {@link #getFPGAHardwareVersion(java.nio.ShortBuffer, java.nio.IntBuffer)} and {@link #getFPGAHardwareVersion(com.sun.jna.ptr.ShortByReference, com.sun.jna.ptr.IntByReference)} instead */ - //@Deprecated + //@Deprecated //public static native void getFPGAHardwareVersion(ShortByReference fpgaVersion, IntByReference fpgaRevision); /** * Original signature : void getFPGAHardwareVersion(uint16_t*, uint32_t*)
* native declaration : src\main\include\NetworkCommunication\FRCComm.h:124 */ public static native void getFPGAHardwareVersion(ShortBuffer fpgaVersion, IntBuffer fpgaRevision); - /** - * Original signature : int getCommonControlData(FRCCommonControlData*, int)
- * native declaration : src\main\include\NetworkCommunication\FRCComm.h:126 - */ - public static native int getCommonControlData(FRCCommonControlData data); - /** - * Original signature : int getRecentCommonControlData(FRCCommonControlData*, int)
- * native declaration : src\main\include\NetworkCommunication\FRCComm.h:127 - */ - public static native int getRecentCommonControlData(FRCCommonControlData commonData, int wait_ms); /** * Original signature : int getRecentStatusData(uint8_t*, uint8_t*, uint8_t*, int)
* native declaration : src\main\include\NetworkCommunication\FRCComm.h:128
* @deprecated use the safer methods {@link #getRecentStatusData(java.nio.ByteBuffer, java.nio.ByteBuffer, java.nio.ByteBuffer, int)} and {@link #getRecentStatusData(com.sun.jna.Pointer, com.sun.jna.Pointer, com.sun.jna.Pointer, int)} instead */ - //@Deprecated + //@Deprecated //public static native int getRecentStatusData(Pointer batteryInt, Pointer batteryDec, Pointer dsDigitalOut, int wait_ms); /** * Original signature : int getRecentStatusData(uint8_t*, uint8_t*, uint8_t*, int)
* native declaration : src\main\include\NetworkCommunication\FRCComm.h:128 */ public static native int getRecentStatusData(ByteBuffer batteryInt, ByteBuffer batteryDec, ByteBuffer dsDigitalOut, int wait_ms); - /** - * Original signature : int getDynamicControlData(uint8_t, char*, int32_t, int)
- * native declaration : src\main\include\NetworkCommunication\FRCComm.h:129
- * @deprecated use the safer methods {@link #getDynamicControlData(byte, java.nio.ByteBuffer, int, int)} and {@link #getDynamicControlData(byte, com.sun.jna.Pointer, int, int)} instead - */ - //@Deprecated - //public static native int getDynamicControlData(byte type, Pointer dynamicData, int maxLength, int wait_ms); - /** - * Original signature : int getDynamicControlData(uint8_t, char*, int32_t, int)
- * native declaration : src\main\include\NetworkCommunication\FRCComm.h:129 - */ - public static native int getDynamicControlData(byte type, ByteBuffer dynamicData, int maxLength, int wait_ms); /** * Original signature : int setStatusData(float, uint8_t, uint8_t, const char*, int, const char*, int, int)
* native declaration : src\main\include\NetworkCommunication\FRCComm.h:130
* @deprecated use the safer methods {@link #setStatusData(float, byte, byte, java.lang.String, int, java.lang.String, int, int)} and {@link #setStatusData(float, byte, byte, com.sun.jna.Pointer, int, com.sun.jna.Pointer, int, int)} instead */ - //@Deprecated + //@Deprecated //public static native int setStatusData(float battery, byte dsDigitalOut, byte updateNumber, Pointer userDataHigh, int userDataHighLength, Pointer userDataLow, int userDataLowLength, int wait_ms); /** * Original signature : int setStatusData(float, uint8_t, uint8_t, const char*, int, const char*, int, int)
* native declaration : src\main\include\NetworkCommunication\FRCComm.h:130 */ public static native int setStatusData(float battery, byte dsDigitalOut, byte updateNumber, String userDataHigh, int userDataHighLength, String userDataLow, int userDataLowLength); - /** - * Original signature : int setStatusDataFloatAsInt(int, uint8_t, uint8_t, const char*, int, const char*, int, int)
- * native declaration : src\main\include\NetworkCommunication\FRCComm.h:133
- * @deprecated use the safer methods {@link #setStatusDataFloatAsInt(int, byte, byte, java.lang.String, int, java.lang.String, int, int)} and {@link #setStatusDataFloatAsInt(int, byte, byte, com.sun.jna.Pointer, int, com.sun.jna.Pointer, int, int)} instead - */ - //@Deprecated - //public static native int setStatusDataFloatAsInt(int battery, byte dsDigitalOut, byte updateNumber, Pointer userDataHigh, int userDataHighLength, Pointer userDataLow, int userDataLowLength, int wait_ms); - /** - * Original signature : int setStatusDataFloatAsInt(int, uint8_t, uint8_t, const char*, int, const char*, int, int)
- * native declaration : src\main\include\NetworkCommunication\FRCComm.h:133 - */ - public static native int setStatusDataFloatAsInt(int battery, byte dsDigitalOut, byte updateNumber, String userDataHigh, int userDataHighLength, String userDataLow, int userDataLowLength, int wait_ms); /** * Original signature : int setErrorData(const char*, int, int)
* native declaration : src\main\include\NetworkCommunication\FRCComm.h:136
* @deprecated use the safer methods {@link #setErrorData(java.lang.String, int, int)} and {@link #setErrorData(com.sun.jna.Pointer, int, int)} instead */ - //@Deprecated + //@Deprecated //public static native int setErrorData(Pointer errors, int errorsLength, int wait_ms); /** * Original signature : int setErrorData(const char*, int, int)
* native declaration : src\main\include\NetworkCommunication\FRCComm.h:136 */ public static native int setErrorData(String errors, int errorsLength, int wait_ms); - /** - * Original signature : int setUserDsLcdData(const char*, int, int)
- * native declaration : src\main\include\NetworkCommunication\FRCComm.h:137
- * @deprecated use the safer methods {@link #setUserDsLcdData(java.lang.String, int, int)} and {@link #setUserDsLcdData(com.sun.jna.Pointer, int, int)} instead - */ - //@Deprecated - //public static native int setUserDsLcdData(Pointer userDsLcdData, int userDsLcdDataLength, int wait_ms); - /** - * Original signature : int setUserDsLcdData(const char*, int, int)
- * native declaration : src\main\include\NetworkCommunication\FRCComm.h:137 - */ - public static native int setUserDsLcdData(String userDsLcdData, int userDsLcdDataLength, int wait_ms); /** * Original signature : int overrideIOConfig(const char*, int)
* native declaration : src\main\include\NetworkCommunication\FRCComm.h:138
* @deprecated use the safer methods {@link #overrideIOConfig(java.lang.String, int)} and {@link #overrideIOConfig(com.sun.jna.Pointer, int)} instead */ - //@Deprecated + //@Deprecated //public static native int overrideIOConfig(String ioConfig, int wait_ms); /** * Original signature : int overrideIOConfig(const char*, int)
@@ -491,7 +440,7 @@ public class FRCNetworkCommunicationsLibrary extends JNIWrapper { * native declaration : src\main\include\NetworkCommunication\FRCComm.h:159
* @deprecated use the safer methods {@link #FRC_NetworkCommunication_getVersionString(java.nio.ByteBuffer)} and {@link #FRC_NetworkCommunication_getVersionString(com.sun.jna.Pointer)} instead */ - //@Deprecated + //@Deprecated //public static native void FRC_NetworkCommunication_getVersionString(Pointer version); /** * Original signature : void FRC_NetworkCommunication_getVersionString(char*)
@@ -504,7 +453,43 @@ public class FRCNetworkCommunicationsLibrary extends JNIWrapper { public static native void FRCNetworkCommunicationObserveUserProgramTeleop(); public static native void FRCNetworkCommunicationObserveUserProgramTest(); public static native void FRCNetworkCommunicationReserve(); - + + private static native int NativeHALGetControlWord(); + public static HALControlWord HALGetControlWord() { + int word = NativeHALGetControlWord(); + return new HALControlWord( + (word & 1) != 0, + ((word >> 2) & 1) != 0, + ((word >> 3) & 1) != 0, + ((word >> 4) & 1) != 0, + ((word >> 5) & 1) != 0, + ((word >> 6) & 1) != 0 + ); + } + + private static native int NativeHALGetAllianceStation(); + public static HALAllianceStationID HALGetAllianceStation() { + switch(NativeHALGetAllianceStation()) { + case 0: + return HALAllianceStationID.Red1; + case 1: + return HALAllianceStationID.Red2; + case 2: + return HALAllianceStationID.Red3; + case 3: + return HALAllianceStationID.Blue1; + case 4: + return HALAllianceStationID.Blue2; + case 5: + return HALAllianceStationID.Blue3; + default: + return null; + } + } + + public static native short[] HALGetJoystickAxes(byte joystickNum); + public static native int HALGetJoystickButtons(byte joystickNum); + /* public static class pthread_mutex_t extends PointerType { public pthread_mutex_t(Pointer address) { @@ -522,7 +507,7 @@ public class FRCNetworkCommunicationsLibrary extends JNIWrapper { super(); } };*/ - + // // JNI Testing // @@ -535,11 +520,11 @@ public class FRCNetworkCommunicationsLibrary extends JNIWrapper { public static native long JNIValueReturnLongTest(long longValue); public static native float JNIValueReturnFloatTest(float floatValue); public static native double JNIValueReturnDoubleTest(double doubleValue); - + public static native String JNIObjectReturnStringTest( String stringObject); - + public static native ByteBuffer JNIObjectReturnByteBufferTest( ByteBuffer byteBuffer ); - + public static native ByteBuffer JNIObjectAndParamReturnIntBufferTest( IntBuffer intBuffer); - + } diff --git a/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/communication/HALAllianceStationID.java b/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/communication/HALAllianceStationID.java new file mode 100644 index 0000000000..7c9748886e --- /dev/null +++ b/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/communication/HALAllianceStationID.java @@ -0,0 +1,10 @@ +package edu.wpi.first.wpilibj.communication; + +public enum HALAllianceStationID { + Red1, + Red2, + Red3, + Blue1, + Blue2, + Blue3 +} diff --git a/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/communication/HALControlWord.java b/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/communication/HALControlWord.java new file mode 100644 index 0000000000..715ec93409 --- /dev/null +++ b/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/communication/HALControlWord.java @@ -0,0 +1,49 @@ +package edu.wpi.first.wpilibj.communication; + +/** + * A wrapper for the HALControlWord bitfield + */ +public class HALControlWord { + private boolean m_enabled; + private boolean m_autonomous; + private boolean m_test; + private boolean m_eStop; + private boolean m_fmsAttached; + private boolean m_dsAttached; + + protected HALControlWord(boolean enabled, boolean autonomous, boolean test, + boolean eStop, boolean fmsAttached, boolean dsAttached) { + m_enabled = enabled; + m_autonomous = autonomous; + m_test = test; + m_eStop = eStop; + m_fmsAttached = fmsAttached; + m_dsAttached = dsAttached; + } + + public boolean getEnabled() { + return m_enabled; + } + + public boolean getAutonomous() { + return m_autonomous; + } + + public boolean getTest() { + return m_test; + } + + public boolean getEStop() { + return m_eStop; + } + + public boolean getFMSAttached() { + return m_fmsAttached; + } + + public boolean getDSAttached() { + return m_dsAttached; + } + + +} diff --git a/wpilibj/wpilibJavaJNI/lib/FRCNetworkCommunicationsLibrary.cpp b/wpilibj/wpilibJavaJNI/lib/FRCNetworkCommunicationsLibrary.cpp index 5778cf51bb..7dc96c0db6 100644 --- a/wpilibj/wpilibJavaJNI/lib/FRCNetworkCommunicationsLibrary.cpp +++ b/wpilibj/wpilibJavaJNI/lib/FRCNetworkCommunicationsLibrary.cpp @@ -38,17 +38,6 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommun assert(false); return 0; } -/* - * Class: edu_wpi_first_wpilibj_communication_FRC_NetworkCommunicationsLibrary - * Method: getModulePresence - * Signature: (IB)B - */ -JNIEXPORT jbyte JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_getModulePresence - (JNIEnv *, jclass, jint, jbyte) -{ - assert(false); - return 0; -} /* * Class: edu_wpi_first_wpilibj_communication_FRC_NetworkCommunicationsLibrary * Method: getTargetClass @@ -145,192 +134,6 @@ jfieldID FPGAChecksum1FieldID; jfieldID FPGAChecksum2FieldID; jfieldID FPGAChecksum3FieldID; jfieldID versionDataFieldID; - -/* - * Class: edu_wpi_first_wpilibj_communication_FRC_NetworkCommunicationsLibrary - * Method: getCommonControlData - * Signature: (Ledu/wpi/first/wpilibj/communication/FRCCommonControlData;I)I - */ -JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_getCommonControlData - (JNIEnv * env, jclass, jobject controlData) -{ - HALCommonControlData controlDataNative; - - controlDataNative.packetIndex = 0xFF; - controlDataNative.control = 0xFF; - - int returnValue = HALGetCommonControlData(&controlDataNative, HAL_WAIT_FOREVER); - - //NETCOMM_LOG(logDEBUG) << "PacketIndex: " << (void*)controlDataNative.packetIndex << " Control: " << (void*)controlDataNative.control << " ReturnValue: " << (void*)returnValue; - - if(!initializeComplete) - { - // control data class - dataClass = (jclass)env->NewGlobalRef(env->GetObjectClass(controlData)); - //dataClass = env->GetObjectClass(controlData); - // public short packetIndex; - packetIndexFieldID = env->GetFieldID(dataClass, "packetIndex", "S" ); - // public byte control; - controlFieldID = env->GetFieldID(dataClass, "control", "B" ); - // public byte dsDigitalIn; - dsDigitalInFieldID = env->GetFieldID(dataClass, "dsDigitalIn", "B" ); - // public short teamID; - teamIDFieldID = env->GetFieldID(dataClass, "teamID", "S" ); - // public byte dsID_Alliance; - dsID_AllianceFieldID = env->GetFieldID(dataClass, "dsID_Alliance", "B" ); - // public byte dsID_Position; - dsID_PositionFieldID = env->GetFieldID(dataClass, "dsID_Position", "B" ); - // public byte[] stick0Axes; - stick0AxesFieldID = env->GetFieldID(dataClass, "stick0Axes", "[B" ); - // public short stick0Buttons; - stick0ButtonsFieldID = env->GetFieldID(dataClass, "stick0Buttons", "S" ); - // public byte[] stick1Axes; - stick1AxesFieldID = env->GetFieldID(dataClass, "stick1Axes", "[B" ); - // public short stick1Buttons; - stick1ButtonsFieldID = env->GetFieldID(dataClass, "stick1Buttons", "S" ); - // public byte[] stick2Axes; - stick2AxesFieldID = env->GetFieldID(dataClass, "stick2Axes", "[B" ); - // public short stick2Buttons; - stick2ButtonsFieldID = env->GetFieldID(dataClass, "stick2Buttons", "S" ); - // public byte[] stick3Axes; - stick3AxesFieldID = env->GetFieldID(dataClass, "stick3Axes", "[B" ); - // public short stick3Buttons; - stick3ButtonsFieldID = env->GetFieldID(dataClass, "stick3Buttons", "S" ); - // public short analog1; - analog1FieldID = env->GetFieldID(dataClass, "analog1", "S" ); - // public short analog2; - analog2FieldID = env->GetFieldID(dataClass, "analog2", "S" ); - // public short analog3; - analog3FieldID = env->GetFieldID(dataClass, "analog3", "S" ); - // public short analog4; - analog4FieldID = env->GetFieldID(dataClass, "analog4", "S" ); - // public long cRIOChecksum; - cRIOChecksumFieldID = env->GetFieldID(dataClass, "cRIOChecksum", "J" ); - // public int FPGAChecksum0; - FPGAChecksum0FieldID = env->GetFieldID(dataClass, "FPGAChecksum0", "I" ); - // public int FPGAChecksum1; - FPGAChecksum1FieldID = env->GetFieldID(dataClass, "FPGAChecksum1", "I" ); - // public int FPGAChecksum2; - FPGAChecksum2FieldID = env->GetFieldID(dataClass, "FPGAChecksum2", "I" ); - // public int FPGAChecksum3; - FPGAChecksum3FieldID = env->GetFieldID(dataClass, "FPGAChecksum3", "I" ); - // public byte[] versionData; - versionDataFieldID = env->GetFieldID(dataClass, "versionData", "[B" ); - - initializeComplete = true; - } - - //NETCOMM_LOG(logDEBUG) << "PacketIndex : " << (short)controlDataNative.packetIndex; - env->SetShortField(controlData,packetIndexFieldID, controlDataNative.packetIndex); - //NETCOMM_LOG(logDEBUG) << "Control : " << (short)controlDataNative.control; - env->SetByteField(controlData,controlFieldID, controlDataNative.control); - env->SetByteField(controlData,dsDigitalInFieldID, controlDataNative.dsDigitalIn); - env->SetShortField(controlData,teamIDFieldID, controlDataNative.teamID); - env->SetByteField(controlData,dsID_AllianceFieldID, controlDataNative.dsID_Alliance); - env->SetByteField(controlData,dsID_PositionFieldID, controlDataNative.dsID_Position); - - // process the axes for joystick 0 - jobject stick0Axes = env->GetObjectField(controlData, stick0AxesFieldID); - jbyteArray * stick0AxesPtr = reinterpret_cast(&stick0Axes); - jbyte * stick0AxesBytePtr = env->GetByteArrayElements(*stick0AxesPtr,NULL); - - for( short axisCount = 0; axisCount < 6; axisCount++) - { - stick0AxesBytePtr[axisCount]=controlDataNative.stick0Axes[axisCount]; - } - - env->ReleaseByteArrayElements(*stick0AxesPtr,stick0AxesBytePtr,0); - - // /** C type : field2_union */ - // public field2_union field2; - // /** Left-most 4 bits are unused */ - env->SetShortField(controlData,stick0ButtonsFieldID, controlDataNative.stick0Buttons); - - // process the axes for joystick 1 - jobject stick1Axes = env->GetObjectField(controlData, stick1AxesFieldID); - jbyteArray * stick1AxesPtr = reinterpret_cast(&stick1Axes); - jbyte * stick1AxesBytePtr = env->GetByteArrayElements(*stick1AxesPtr,NULL); - - for( short axisCount = 0; axisCount < 6; axisCount++) - { - stick1AxesBytePtr[axisCount]=controlDataNative.stick1Axes[axisCount]; - } - - env->ReleaseByteArrayElements(*stick1AxesPtr,stick1AxesBytePtr,0); - - // /** C type : field3_union */ - // public field3_union field3; - // /** Left-most 4 bits are unused */ - env->SetShortField(controlData,stick1ButtonsFieldID, controlDataNative.stick1Buttons); - - // process the axes for joystick 2 - jobject stick2Axes = env->GetObjectField(controlData, stick2AxesFieldID); - jbyteArray * stick2AxesPtr = reinterpret_cast(&stick2Axes); - jbyte * stick2AxesBytePtr = env->GetByteArrayElements(*stick2AxesPtr,NULL); - - for( short axisCount = 0; axisCount < 6; axisCount++) - { - stick2AxesBytePtr[axisCount]=controlDataNative.stick2Axes[axisCount]; - } - - env->ReleaseByteArrayElements(*stick2AxesPtr,stick2AxesBytePtr,0); - - // /** C type : field4_union */ - // public field4_union field4; - // /** Left-most 4 bits are unused */ - env->SetShortField(controlData,stick2ButtonsFieldID, controlDataNative.stick2Buttons); - - // process the axes for joystick 3 - jobject stick3Axes = env->GetObjectField(controlData, stick3AxesFieldID); - jbyteArray * stick3AxesPtr = reinterpret_cast(&stick3Axes); - jbyte * stick3AxesBytePtr = env->GetByteArrayElements(*stick3AxesPtr,NULL); - - for( short axisCount = 0; axisCount < 6; axisCount++) - { - stick3AxesBytePtr[axisCount]=controlDataNative.stick3Axes[axisCount]; - } - - env->ReleaseByteArrayElements(*stick3AxesPtr,stick3AxesBytePtr,0); - - // /** C type : field5_union */ - // public field5_union field5; - // /** Left-most 4 bits are unused */ - env->SetShortField(controlData,stick3ButtonsFieldID, controlDataNative.stick3Buttons); - // /** Analog inputs are 10 bit right-justified */ - env->SetShortField(controlData,analog1FieldID, controlDataNative.analog1); - env->SetShortField(controlData,analog2FieldID, controlDataNative.analog2); - env->SetShortField(controlData,analog3FieldID, controlDataNative.analog3); - env->SetShortField(controlData,analog4FieldID, controlDataNative.analog4); - env->SetLongField(controlData,cRIOChecksumFieldID, controlDataNative.cRIOChecksum); - env->SetIntField(controlData,FPGAChecksum0FieldID, controlDataNative.FPGAChecksum0); - env->SetIntField(controlData,FPGAChecksum1FieldID, controlDataNative.FPGAChecksum1); - env->SetIntField(controlData,FPGAChecksum2FieldID, controlDataNative.FPGAChecksum2); - env->SetIntField(controlData,FPGAChecksum3FieldID, controlDataNative.FPGAChecksum3); - // /** C type : char[8] */ - // public byte[] versionData; - jobject versionData = env->GetObjectField(controlData, versionDataFieldID); - jbyteArray * versionDataPtr = reinterpret_cast(&versionData); - jbyte * versionDataBytePtr = env->GetByteArrayElements(*versionDataPtr,NULL); - - for( short byteCount = 0; byteCount < 8; byteCount++) - { - versionDataBytePtr[byteCount]=controlDataNative.versionData[byteCount]; - } - - env->ReleaseByteArrayElements(*versionDataPtr,versionDataBytePtr,0); - - return returnValue; -} -/* - * Class: edu_wpi_first_wpilibj_communication_FRC_NetworkCommunicationsLibrary - * Method: getRecentCommonControlData - * Signature: (Ledu/wpi/first/wpilibj/communication/FRCCommonControlData;I)I - */ -JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_getRecentCommonControlData - (JNIEnv *, jclass, jobject, jint) -{ - assert(false); -} /* * Class: edu_wpi_first_wpilibj_communication_FRC_NetworkCommunicationsLibrary * Method: getRecentStatusData @@ -341,17 +144,6 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommun { assert(false); } -/* - * Class: edu_wpi_first_wpilibj_communication_FRC_NetworkCommunicationsLibrary - * Method: getDynamicControlData - * Signature: (BLjava/nio/ByteBuffer;II)I - */ -JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_getDynamicControlData - (JNIEnv *, jclass, jbyte, jobject, jint, jint) -{ - assert(false); -} - /* * Class: edu_wpi_first_wpilibj_communication_FRC_NetworkCommunicationsLibrary * Method: setStatusData @@ -368,16 +160,6 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommun env->ReleaseStringUTFChars(paramUserDataLow,userDataLowStr); return returnValue; } -/* - * Class: edu_wpi_first_wpilibj_communication_FRC_NetworkCommunicationsLibrary - * Method: setStatusDataFloatAsInt - * Signature: (IBBLjava/lang/String;ILjava/lang/String;II)I - */ -JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_setStatusDataFloatAsInt - (JNIEnv *, jclass, jint, jbyte, jbyte, jstring, jint, jstring, jint, jint) -{ - assert(false); -} /* * Class: edu_wpi_first_wpilibj_communication_FRC_NetworkCommunicationsLibrary * Method: setErrorData @@ -388,16 +170,6 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommun { assert(false); } -/* - * Class: edu_wpi_first_wpilibj_communication_FRC_NetworkCommunicationsLibrary - * Method: setUserDsLcdData - * Signature: (Ljava/lang/String;II)I - */ -JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_setUserDsLcdData - (JNIEnv *, jclass, jstring, jint, jint) -{ - assert(false); -} /* * Class: edu_wpi_first_wpilibj_communication_FRC_NetworkCommunicationsLibrary * Method: overrideIOConfig @@ -512,6 +284,65 @@ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommun assert(1 == HALInitialize(0)); } +/* + * Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary + * Method: NativeHALGetControlWord + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_NativeHALGetControlWord + (JNIEnv *, jclass) +{ + jint controlWord; + HALGetControlWord((HALControlWord*)&controlWord); + return controlWord; +} + +/* + * Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary + * Method: NativeHALGetAllianceStation + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_NativeHALGetAllianceStation + (JNIEnv *, jclass) +{ + jint allianceStation; + HALGetAllianceStation((HALAllianceStationID*)&allianceStation); + return allianceStation; +} + +/* + * Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary + * Method: HALGetJoystickAxes + * Signature: (B)[S + */ +JNIEXPORT jshortArray JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_HALGetJoystickAxes + (JNIEnv * env, jclass, jbyte joystickNum) +{ + HALJoystickAxes axes; + HALGetJoystickAxes(joystickNum, &axes, 6); + + jshortArray axesArray = env->NewShortArray(axes.count); + env->SetShortArrayRegion(axesArray, 0, axes.count, axes.axes); + + return axesArray; +} + +/* + * Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary + * Method: HALGetJoystickButtons + * Signature: (B)S + */ +JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary_HALGetJoystickButtons + (JNIEnv *, jclass, jbyte joystickNum) +{ + HALJoystickButtons buttons; + uint8_t count; + + HALGetJoystickButtons(joystickNum, &buttons, &count); + + return buttons; +} + /* * Class: edu_wpi_first_wpilibj_communication_FRCNetworkCommunicationsLibrary * Method: setNewDataSem