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:
@@ -31,7 +31,9 @@
|
||||
#include "PRDevice.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#ifndef _MSC_VER
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#ifndef __WIND32__
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
@@ -173,13 +175,13 @@ int PRDevice::GetEvents(PREvent *events, int maxEvents)
|
||||
unrequestedDataQueue.pop();
|
||||
|
||||
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)
|
||||
{
|
||||
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)
|
||||
events[i].type = debounced ? kPREventTypeSwitchOpenDebounced : kPREventTypeSwitchOpenNondebounced;
|
||||
else
|
||||
@@ -624,8 +626,9 @@ PRResult PRDevice::SwitchUpdateRule(uint8_t switchNum, PREventType eventType, PR
|
||||
// Now let's setup the first actual rule:
|
||||
uint16_t firstRuleIndex = 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));
|
||||
}
|
||||
newRule->notifyHost = rule->notifyHost;
|
||||
newRule->reloadActive = rule->reloadActive;
|
||||
newRule->changeOutput = false;
|
||||
@@ -943,8 +946,9 @@ PRResult PRDevice::Open()
|
||||
res = FlushReadBuffer();
|
||||
PRSleep(100);
|
||||
res = VerifyChipID();
|
||||
if (res == kPRFailure)
|
||||
if (res == kPRFailure) {
|
||||
DEBUG(PRLog(kPRLogWarning, "Unable to read Chip ID - P-ROC could not be initialized.\n"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
* libpinproc
|
||||
*/
|
||||
|
||||
#include "../include/pinproc.h"
|
||||
#include "pinproc.h"
|
||||
#include "PRCommon.h"
|
||||
#include "PRHardware.h"
|
||||
#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.
|
||||
*/
|
||||
|
||||
#if defined(__WIN32__)
|
||||
#if defined(__WIN32__) || defined(_WIN32)
|
||||
#define USE_D2XX 1
|
||||
#endif
|
||||
|
||||
@@ -576,7 +576,7 @@ int PRHardwareWrite(uint8_t *buffer, int bytes)
|
||||
if (ftStatus == FT_OK)
|
||||
{
|
||||
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 {
|
||||
for (i=0; (DWORD)i<bytesWritten; i++) {
|
||||
DEBUG(PRLog(kPRLogVerbose,"Wrote byte: %x\n",buffer[i]));
|
||||
|
||||
@@ -27,9 +27,9 @@
|
||||
#define _PROC_HARDWARE_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include "../include/pinproc.h"
|
||||
#include "pinproc.h"
|
||||
|
||||
#if defined(__WIN32__)
|
||||
#if defined(__WIN32__) || defined(_WIN32)
|
||||
#include <windows.h>
|
||||
#define PRSleep(milliseconds) Sleep(milliseconds)
|
||||
#else
|
||||
|
||||
@@ -35,6 +35,10 @@
|
||||
#include <string.h>
|
||||
#include "PRDevice.h"
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER < 1300)
|
||||
#define vsnprintf _vsnprintf
|
||||
#endif
|
||||
|
||||
#define MAX_TEXT (1024)
|
||||
|
||||
typedef void (*PRLogCallback)(PRLogLevel level, const char *text);
|
||||
|
||||
Reference in New Issue
Block a user