Initial commit

This commit is contained in:
Paul Hollinsky
2018-09-10 20:28:29 -04:00
commit e2e5017331
133 changed files with 24597 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
#ifndef __DYNAMICLIB_H_WINDOWS_
#define __DYNAMICLIB_H_WINDOWS_
#include <Windows.h>
#ifdef ICSNEOC_MAKEDLL
#define DLLExport __declspec(dllexport)
#else
#define DLLExport __declspec(dllimport)
#endif
// MSVC does not have the ability to specify a destructor
#define ICSNEO_DESTRUCTOR
#define icsneoDynamicLibraryLoad() LoadLibrary(L"C:\\Users\\Phollinsky\\Code\\icsneonext\\build\\icsneoc.dll")
#define icsneoDynamicLibraryGetFunction(handle, func) GetProcAddress((HMODULE) handle, func)
#define icsneoDynamicLibraryClose(handle) FreeLibrary((HMODULE) handle)
#endif
+16
View File
@@ -0,0 +1,16 @@
#ifndef __FTDI_WINDOWS_H_
#define __FTDI_WINDOWS_H_
#include "platform/windows/include/vcp.h"
namespace icsneo {
class FTDI : public VCP {
public:
FTDI(neodevice_t& forDevice) : VCP(forDevice) {}
static std::vector<neodevice_t> FindByProduct(int product) { return VCP::FindByProduct(product, L"serenum"); }
};
};
#endif
+33
View File
@@ -0,0 +1,33 @@
#ifndef __REGISTRY_H_WINDOWS_
#define __REGISTRY_H_WINDOWS_
#include <Windows.h>
#include <string>
namespace icsneo {
class Registry {
public:
// Get string value
static bool Get(std::wstring path, std::wstring key, std::wstring& value);
static bool Get(std::string path, std::string key, std::string& value);
// Get DWORD value
static bool Get(std::wstring path, std::wstring key, uint32_t& value);
static bool Get(std::string path, std::string key, uint32_t& value);
private:
class Key {
public:
Key(std::wstring path, bool readwrite = false);
~Key();
HKEY GetKey() { return key; }
bool IsOpen() { return key != nullptr; }
private:
HKEY key;
};
};
};
#endif
+16
View File
@@ -0,0 +1,16 @@
#ifndef __STM32_WINDOWS_H_
#define __STM32_WINDOWS_H_
#include "platform/windows/include/vcp.h"
namespace icsneo {
class STM32 : public VCP {
public:
STM32(neodevice_t& forDevice) : VCP(forDevice) {}
static std::vector<neodevice_t> FindByProduct(int product) { return VCP::FindByProduct(product, L"usbser"); }
};
};
#endif
+48
View File
@@ -0,0 +1,48 @@
#ifndef __VCP_H_WINDOWS_
#define __VCP_H_WINDOWS_
#include <vector>
#include <string>
#include <thread>
#include <atomic>
#include <chrono>
#include <Windows.h>
#include "device/include/neodevice.h"
#include "communication/include/icommunication.h"
namespace icsneo {
// Virtual COM Port Communication
class VCP : public ICommunication {
public:
static std::vector<neodevice_t> FindByProduct(int product, wchar_t* driverName);
static bool IsHandleValid(neodevice_handle_t handle);
typedef void(*fn_boolCallback)(bool success);
VCP(neodevice_t& forDevice) : device(forDevice) {
overlappedRead.hEvent = INVALID_HANDLE_VALUE;
overlappedWrite.hEvent = INVALID_HANDLE_VALUE;
overlappedWait.hEvent = INVALID_HANDLE_VALUE;
}
~VCP() { close(); }
bool open() { return open(false); }
void openAsync(fn_boolCallback callback);
bool close();
bool isOpen() { return handle != INVALID_HANDLE_VALUE; }
private:
bool open(bool fromAsync);
bool opening = false;
neodevice_t& device;
HANDLE handle = INVALID_HANDLE_VALUE;
OVERLAPPED overlappedRead = {};
OVERLAPPED overlappedWrite = {};
OVERLAPPED overlappedWait = {};
std::vector<std::shared_ptr<std::thread>> threads;
void readTask();
void writeTask();
};
};
#endif