Jordan Brack / SmartWheelsPublic

Dependencies:   TSI USBDevice mbed-dev

Fork of SmartWheels by haofan Zheng

Committer:
Bobymicjohn
Date:
Tue Feb 07 21:58:20 2017 +0000
Revision:
11:676ea42afd56
Child:
13:7dcb1642ef99
Finished Core, and Servo classes.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Bobymicjohn 11:676ea42afd56 1 #pragma once
Bobymicjohn 11:676ea42afd56 2 #ifndef SW_USBSERVER_H
Bobymicjohn 11:676ea42afd56 3 #define SW_USBSERVER_H
Bobymicjohn 11:676ea42afd56 4
Bobymicjohn 11:676ea42afd56 5 #define HID_REPORT_LENGTH 64
Bobymicjohn 11:676ea42afd56 6
Bobymicjohn 11:676ea42afd56 7 #define HID_SER_STAT_STOPPED 0
Bobymicjohn 11:676ea42afd56 8 #define HID_SER_STAT_SEARCHING 1
Bobymicjohn 11:676ea42afd56 9 #define HID_SER_STAT_CONNECTING 2
Bobymicjohn 11:676ea42afd56 10 #define HID_SER_STAT_CONNECTED 3
Bobymicjohn 11:676ea42afd56 11 #define HID_SER_STAT_RUNNING 4
Bobymicjohn 11:676ea42afd56 12
Bobymicjohn 11:676ea42afd56 13 #define HANDSHAKE_MSG_TER "SMARTWHEELS_HANDSHAKE_TERMINAL"
Bobymicjohn 11:676ea42afd56 14 #define HANDSHAKE_MSG_PC "SMARTWHEELS_HANDSHAKE_PC"
Bobymicjohn 11:676ea42afd56 15
Bobymicjohn 11:676ea42afd56 16 #include <mbed.h>
Bobymicjohn 11:676ea42afd56 17 #include <USBHID.h>
Bobymicjohn 11:676ea42afd56 18 #include <rtos.h>
Bobymicjohn 11:676ea42afd56 19 #include <list>
Bobymicjohn 11:676ea42afd56 20 #include <string>
Bobymicjohn 11:676ea42afd56 21
Bobymicjohn 11:676ea42afd56 22 namespace SW
Bobymicjohn 11:676ea42afd56 23 {
Bobymicjohn 11:676ea42afd56 24 class USBServer
Bobymicjohn 11:676ea42afd56 25 {
Bobymicjohn 11:676ea42afd56 26 public:
Bobymicjohn 11:676ea42afd56 27 USBServer(uint16_t vendor_id=0x1234, uint16_t product_id=0x0006);
Bobymicjohn 11:676ea42afd56 28
Bobymicjohn 11:676ea42afd56 29 ~USBServer();
Bobymicjohn 11:676ea42afd56 30
Bobymicjohn 11:676ea42afd56 31 void Update(float deltaTime);
Bobymicjohn 11:676ea42afd56 32
Bobymicjohn 11:676ea42afd56 33 bool PushReliableMsg(const char type, const std::string & msg);
Bobymicjohn 11:676ea42afd56 34
Bobymicjohn 11:676ea42afd56 35 bool PushUnreliableMsg(const char type, const std::string & msg);
Bobymicjohn 11:676ea42afd56 36
Bobymicjohn 11:676ea42afd56 37 void Terminate();
Bobymicjohn 11:676ea42afd56 38
Bobymicjohn 11:676ea42afd56 39 private:
Bobymicjohn 11:676ea42afd56 40
Bobymicjohn 11:676ea42afd56 41 bool m_shouldTerminate;
Bobymicjohn 11:676ea42afd56 42
Bobymicjohn 11:676ea42afd56 43 uint8_t m_stat;
Bobymicjohn 11:676ea42afd56 44
Bobymicjohn 11:676ea42afd56 45 Thread * m_usbThread;
Bobymicjohn 11:676ea42afd56 46
Bobymicjohn 11:676ea42afd56 47 Serial * m_usb;
Bobymicjohn 11:676ea42afd56 48
Bobymicjohn 11:676ea42afd56 49 std::list<std::string> m_msgQueue;
Bobymicjohn 11:676ea42afd56 50
Bobymicjohn 11:676ea42afd56 51 Mutex m_qlocker;
Bobymicjohn 11:676ea42afd56 52
Bobymicjohn 11:676ea42afd56 53 void RunningThread();
Bobymicjohn 11:676ea42afd56 54
Bobymicjohn 11:676ea42afd56 55 void ConnectingThread();
Bobymicjohn 11:676ea42afd56 56 };
Bobymicjohn 11:676ea42afd56 57 }
Bobymicjohn 11:676ea42afd56 58 #endif