Jordan Brack / SmartWheelsPublic

Dependencies:   TSI USBDevice mbed-dev

Fork of SmartWheels by haofan Zheng

Committer:
hazheng
Date:
Fri Feb 10 03:23:20 2017 +0000
Revision:
16:66c7a09e71ee
Parent:
13:7dcb1642ef99
Child:
18:bf6c5f8281eb
Added delta time.

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
hazheng 13:7dcb1642ef99 7 #define SER_STAT_STOPPED 0
hazheng 13:7dcb1642ef99 8 #define SER_STAT_SEARCHING 1
hazheng 13:7dcb1642ef99 9 #define SER_STAT_CONNECTING 2
hazheng 13:7dcb1642ef99 10 #define SER_STAT_CONNECTED 3
hazheng 13:7dcb1642ef99 11 #define 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"
hazheng 16:66c7a09e71ee 15 #define TICKING_MSG "TICK"
Bobymicjohn 11:676ea42afd56 16
Bobymicjohn 11:676ea42afd56 17 #include <mbed.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
hazheng 13:7dcb1642ef99 39 uint8_t GetStatus() const;
hazheng 13:7dcb1642ef99 40
Bobymicjohn 11:676ea42afd56 41 private:
Bobymicjohn 11:676ea42afd56 42
Bobymicjohn 11:676ea42afd56 43 bool m_shouldTerminate;
Bobymicjohn 11:676ea42afd56 44
Bobymicjohn 11:676ea42afd56 45 uint8_t m_stat;
Bobymicjohn 11:676ea42afd56 46
Bobymicjohn 11:676ea42afd56 47 Thread * m_usbThread;
Bobymicjohn 11:676ea42afd56 48
Bobymicjohn 11:676ea42afd56 49 Serial * m_usb;
Bobymicjohn 11:676ea42afd56 50
Bobymicjohn 11:676ea42afd56 51 std::list<std::string> m_msgQueue;
Bobymicjohn 11:676ea42afd56 52
Bobymicjohn 11:676ea42afd56 53 Mutex m_qlocker;
Bobymicjohn 11:676ea42afd56 54
hazheng 16:66c7a09e71ee 55 float m_tickMsgTimer;
hazheng 16:66c7a09e71ee 56
Bobymicjohn 11:676ea42afd56 57 void RunningThread();
Bobymicjohn 11:676ea42afd56 58
Bobymicjohn 11:676ea42afd56 59 void ConnectingThread();
Bobymicjohn 11:676ea42afd56 60 };
Bobymicjohn 11:676ea42afd56 61 }
Bobymicjohn 11:676ea42afd56 62 #endif