mirror of
https://github.com/preble/libpinproc
synced 2026-02-24 18:25:23 +01:00
More small tweaks for MSVC.
This commit is contained in:
@@ -115,7 +115,7 @@ void RunLoop(PRHandle proc)
|
|||||||
case kPREventTypeSwitchOpenNondebounced: stateText = "open(ndb)"; break;
|
case kPREventTypeSwitchOpenNondebounced: stateText = "open(ndb)"; break;
|
||||||
case kPREventTypeSwitchClosedNondebounced: stateText = "closed(ndb)"; break;
|
case kPREventTypeSwitchClosedNondebounced: stateText = "closed(ndb)"; break;
|
||||||
}
|
}
|
||||||
#ifdef _VC_
|
#ifdef _MSC_VER
|
||||||
struct _timeb tv;
|
struct _timeb tv;
|
||||||
_ftime(&tv);
|
_ftime(&tv);
|
||||||
#else
|
#else
|
||||||
@@ -130,7 +130,7 @@ void RunLoop(PRHandle proc)
|
|||||||
case kPREventTypeSwitchOpenNondebounced:
|
case kPREventTypeSwitchOpenNondebounced:
|
||||||
case kPREventTypeSwitchClosedNondebounced:
|
case kPREventTypeSwitchClosedNondebounced:
|
||||||
{
|
{
|
||||||
#ifdef _VC_
|
#ifdef _MSC_VER
|
||||||
printf("%d.%03d switch % 3d: %s\n", tv.time-startTime, tv.millitm, event->value, stateText);
|
printf("%d.%03d switch % 3d: %s\n", tv.time-startTime, tv.millitm, event->value, stateText);
|
||||||
#else
|
#else
|
||||||
printf("%d.%03d switch % 3d: %s\n", (int)(tv.tv_sec-startTime), (int)tv.tv_usec/1000, event->value, stateText);
|
printf("%d.%03d switch % 3d: %s\n", (int)(tv.tv_sec-startTime), (int)tv.tv_usec/1000, event->value, stateText);
|
||||||
@@ -152,7 +152,7 @@ void RunLoop(PRHandle proc)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
PRFlushWriteData(proc);
|
PRFlushWriteData(proc);
|
||||||
#ifdef _VC_
|
#ifdef _MSC_VER
|
||||||
Sleep(10);
|
Sleep(10);
|
||||||
#else
|
#else
|
||||||
usleep(10*1000); // Sleep for 10ms so we aren't pegging the CPU.
|
usleep(10*1000); // Sleep for 10ms so we aren't pegging the CPU.
|
||||||
|
|||||||
@@ -31,16 +31,16 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
#ifndef _VC_
|
#ifndef _MSC_VER
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include "../../include/pinproc.h" // Include libpinproc's header.
|
#include "pinproc.h" // Include libpinproc's header.
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <yaml-cpp/yaml.h>
|
#include <yaml-cpp/yaml.h>
|
||||||
|
|
||||||
#ifdef _VC_
|
#ifdef _MSC_VER
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <sys/timeb.h>
|
#include <sys/timeb.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|||||||
@@ -31,10 +31,16 @@
|
|||||||
#ifndef _PINPROC_H_
|
#ifndef _PINPROC_H_
|
||||||
#define _PINPROC_H_
|
#define _PINPROC_H_
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 3rd party "stdint.h" replacement available for Visual C++ before version 2010.
|
||||||
|
* http://en.wikipedia.org/wiki/Stdint.h#External_links
|
||||||
|
* -> http://msinttypes.googlecode.com/svn/trunk/stdint.h
|
||||||
|
* Place inside the major include dir (e.g. %ProgramFiles%\Microsoft Visual Studio\VC98\INCLUDE)
|
||||||
|
*/
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
/** @cond */
|
/** @cond */
|
||||||
#if defined(__WIN32__)
|
#if defined(__WIN32__) || defined(_WIN32)
|
||||||
#undef PR_EXPORT
|
#undef PR_EXPORT
|
||||||
#if defined(PR_BUILDING_PR)
|
#if defined(PR_BUILDING_PR)
|
||||||
#define PR_EXPORT __declspec(dllexport) extern
|
#define PR_EXPORT __declspec(dllexport) extern
|
||||||
|
|||||||
@@ -31,7 +31,9 @@
|
|||||||
#include "PRDevice.h"
|
#include "PRDevice.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#ifndef _MSC_VER
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
#ifndef __WIND32__
|
#ifndef __WIND32__
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -173,13 +175,13 @@ int PRDevice::GetEvents(PREvent *events, int maxEvents)
|
|||||||
unrequestedDataQueue.pop();
|
unrequestedDataQueue.pop();
|
||||||
|
|
||||||
events[i].value = event_data & P_ROC_EVENT_SWITCH_NUM_MASK;
|
events[i].value = event_data & P_ROC_EVENT_SWITCH_NUM_MASK;
|
||||||
bool open = (event_data & P_ROC_EVENT_SWITCH_STATE_MASK) >> P_ROC_EVENT_SWITCH_STATE_SHIFT;
|
int open = (event_data & P_ROC_EVENT_SWITCH_STATE_MASK) >> P_ROC_EVENT_SWITCH_STATE_SHIFT;
|
||||||
|
|
||||||
switch ((event_data & P_ROC_EVENT_TYPE_MASK) >> P_ROC_EVENT_TYPE_SHIFT)
|
switch ((event_data & P_ROC_EVENT_TYPE_MASK) >> P_ROC_EVENT_TYPE_SHIFT)
|
||||||
{
|
{
|
||||||
case P_ROC_EVENT_TYPE_SWITCH:
|
case P_ROC_EVENT_TYPE_SWITCH:
|
||||||
{
|
{
|
||||||
bool debounced = (event_data & P_ROC_EVENT_SWITCH_DEBOUNCED_MASK) >> P_ROC_EVENT_SWITCH_DEBOUNCED_SHIFT;
|
int debounced = (event_data & P_ROC_EVENT_SWITCH_DEBOUNCED_MASK) >> P_ROC_EVENT_SWITCH_DEBOUNCED_SHIFT;
|
||||||
if (open)
|
if (open)
|
||||||
events[i].type = debounced ? kPREventTypeSwitchOpenDebounced : kPREventTypeSwitchOpenNondebounced;
|
events[i].type = debounced ? kPREventTypeSwitchOpenDebounced : kPREventTypeSwitchOpenNondebounced;
|
||||||
else
|
else
|
||||||
@@ -624,8 +626,9 @@ PRResult PRDevice::SwitchUpdateRule(uint8_t switchNum, PREventType eventType, PR
|
|||||||
// Now let's setup the first actual rule:
|
// Now let's setup the first actual rule:
|
||||||
uint16_t firstRuleIndex = newRuleIndex;
|
uint16_t firstRuleIndex = newRuleIndex;
|
||||||
PRSwitchRuleInternal *newRule = GetSwitchRuleByIndex(newRuleIndex);
|
PRSwitchRuleInternal *newRule = GetSwitchRuleByIndex(newRuleIndex);
|
||||||
if (newRule->eventType != eventType)
|
if (newRule->eventType != eventType) {
|
||||||
DEBUG(PRLog(kPRLogWarning, "Unexpected state: switch rule at 0x%x has event type 0x%x (expected 0x%x).\n", newRuleIndex, newRule->eventType, eventType));
|
DEBUG(PRLog(kPRLogWarning, "Unexpected state: switch rule at 0x%x has event type 0x%x (expected 0x%x).\n", newRuleIndex, newRule->eventType, eventType));
|
||||||
|
}
|
||||||
newRule->notifyHost = rule->notifyHost;
|
newRule->notifyHost = rule->notifyHost;
|
||||||
newRule->reloadActive = rule->reloadActive;
|
newRule->reloadActive = rule->reloadActive;
|
||||||
newRule->changeOutput = false;
|
newRule->changeOutput = false;
|
||||||
@@ -943,10 +946,11 @@ PRResult PRDevice::Open()
|
|||||||
res = FlushReadBuffer();
|
res = FlushReadBuffer();
|
||||||
PRSleep(100);
|
PRSleep(100);
|
||||||
res = VerifyChipID();
|
res = VerifyChipID();
|
||||||
if (res == kPRFailure)
|
if (res == kPRFailure) {
|
||||||
DEBUG(PRLog(kPRLogWarning, "Unable to read Chip ID - P-ROC could not be initialized.\n"));
|
DEBUG(PRLog(kPRLogWarning, "Unable to read Chip ID - P-ROC could not be initialized.\n"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
* libpinproc
|
* libpinproc
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../include/pinproc.h"
|
#include "pinproc.h"
|
||||||
#include "PRCommon.h"
|
#include "PRCommon.h"
|
||||||
#include "PRHardware.h"
|
#include "PRHardware.h"
|
||||||
#include <queue>
|
#include <queue>
|
||||||
|
|||||||
@@ -347,7 +347,7 @@ int32_t CreateJTAGShiftTDODataBurst ( uint32_t * burst, uint16_t numBits, bool_t
|
|||||||
* As we add support for other drivers (such as D2xx on Windows), we will add more implementations of the PRHardware*() functions here.
|
* As we add support for other drivers (such as D2xx on Windows), we will add more implementations of the PRHardware*() functions here.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(__WIN32__)
|
#if defined(__WIN32__) || defined(_WIN32)
|
||||||
#define USE_D2XX 1
|
#define USE_D2XX 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -576,7 +576,7 @@ int PRHardwareWrite(uint8_t *buffer, int bytes)
|
|||||||
if (ftStatus == FT_OK)
|
if (ftStatus == FT_OK)
|
||||||
{
|
{
|
||||||
DEBUG(PRLog(kPRLogVerbose,"Wrote %d bytes:\n",bytesWritten));
|
DEBUG(PRLog(kPRLogVerbose,"Wrote %d bytes:\n",bytesWritten));
|
||||||
if (bytesWritten != bytes) DEBUG(PRLog(kPRLogVerbose,"Wrote %d bytes, should have written %d bytes",bytesWritten,bytes));
|
if (bytesWritten != DWORD(bytes)) DEBUG(PRLog(kPRLogVerbose,"Wrote %d bytes, should have written %d bytes",bytesWritten,bytes));
|
||||||
else {
|
else {
|
||||||
for (i=0; (DWORD)i<bytesWritten; i++) {
|
for (i=0; (DWORD)i<bytesWritten; i++) {
|
||||||
DEBUG(PRLog(kPRLogVerbose,"Wrote byte: %x\n",buffer[i]));
|
DEBUG(PRLog(kPRLogVerbose,"Wrote byte: %x\n",buffer[i]));
|
||||||
|
|||||||
@@ -27,9 +27,9 @@
|
|||||||
#define _PROC_HARDWARE_H_
|
#define _PROC_HARDWARE_H_
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "../include/pinproc.h"
|
#include "pinproc.h"
|
||||||
|
|
||||||
#if defined(__WIN32__)
|
#if defined(__WIN32__) || defined(_WIN32)
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#define PRSleep(milliseconds) Sleep(milliseconds)
|
#define PRSleep(milliseconds) Sleep(milliseconds)
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -35,6 +35,10 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "PRDevice.h"
|
#include "PRDevice.h"
|
||||||
|
|
||||||
|
#if defined(_MSC_VER) && (_MSC_VER < 1300)
|
||||||
|
#define vsnprintf _vsnprintf
|
||||||
|
#endif
|
||||||
|
|
||||||
#define MAX_TEXT (1024)
|
#define MAX_TEXT (1024)
|
||||||
|
|
||||||
typedef void (*PRLogCallback)(PRLogLevel level, const char *text);
|
typedef void (*PRLogCallback)(PRLogLevel level, const char *text);
|
||||||
|
|||||||
@@ -29,14 +29,15 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
|
||||||
#endif /* DEBUG_MODE */
|
#endif /* DEBUG_MODE */
|
||||||
|
|
||||||
#include "pinprocfw.h"
|
#include "pinprocfw.h"
|
||||||
#include "lenval.h"
|
#include "lenval.h"
|
||||||
|
#ifndef _MSC_VER
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "../../include/pinproc.h" // Include libpinproc's header.
|
#include "pinproc.h" // Include libpinproc's header.
|
||||||
PRMachineType machineType = kPRMachineCustom; // Should work with all machines.
|
PRMachineType machineType = kPRMachineCustom; // Should work with all machines.
|
||||||
|
|
||||||
/*============================================================================
|
/*============================================================================
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
#ifndef PINPROCFW_H
|
#ifndef PINPROCFW_H
|
||||||
#define PINPROCFW_H
|
#define PINPROCFW_H
|
||||||
|
|
||||||
#if defined(__WIN32__)
|
#if defined(__WIN32__) || defined(_WIN32)
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#define PRSleep(milliseconds) Sleep(milliseconds)
|
#define PRSleep(milliseconds) Sleep(milliseconds)
|
||||||
#else
|
#else
|
||||||
|
|||||||
Reference in New Issue
Block a user