Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: TSI USBDevice mbed-dev
Fork of SmartWheels by
Diff: PCConnector/SWUSBServer.h
- Revision:
- 11:676ea42afd56
- Child:
- 13:7dcb1642ef99
diff -r fedb5786a109 -r 676ea42afd56 PCConnector/SWUSBServer.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/PCConnector/SWUSBServer.h Tue Feb 07 21:58:20 2017 +0000
@@ -0,0 +1,58 @@
+#pragma once
+#ifndef SW_USBSERVER_H
+#define SW_USBSERVER_H
+
+#define HID_REPORT_LENGTH 64
+
+#define HID_SER_STAT_STOPPED 0
+#define HID_SER_STAT_SEARCHING 1
+#define HID_SER_STAT_CONNECTING 2
+#define HID_SER_STAT_CONNECTED 3
+#define HID_SER_STAT_RUNNING 4
+
+#define HANDSHAKE_MSG_TER "SMARTWHEELS_HANDSHAKE_TERMINAL"
+#define HANDSHAKE_MSG_PC "SMARTWHEELS_HANDSHAKE_PC"
+
+#include <mbed.h>
+#include <USBHID.h>
+#include <rtos.h>
+#include <list>
+#include <string>
+
+namespace SW
+{
+ class USBServer
+ {
+ public:
+ USBServer(uint16_t vendor_id=0x1234, uint16_t product_id=0x0006);
+
+ ~USBServer();
+
+ void Update(float deltaTime);
+
+ bool PushReliableMsg(const char type, const std::string & msg);
+
+ bool PushUnreliableMsg(const char type, const std::string & msg);
+
+ void Terminate();
+
+ private:
+
+ bool m_shouldTerminate;
+
+ uint8_t m_stat;
+
+ Thread * m_usbThread;
+
+ Serial * m_usb;
+
+ std::list<std::string> m_msgQueue;
+
+ Mutex m_qlocker;
+
+ void RunningThread();
+
+ void ConnectingThread();
+ };
+}
+#endif
\ No newline at end of file
