Jordan Brack / SmartWheelsPublic

Dependencies:   TSI USBDevice mbed-dev

Fork of SmartWheels by haofan Zheng

Committer:
hazheng
Date:
Sat Feb 11 05:05:44 2017 +0000
Revision:
18:bf6c5f8281eb
Parent:
16:66c7a09e71ee
Child:
19:c93f7fab165d
Successfully built connection with PC! (Note: Serial Class is pretty bugy, in order to avoid them, SWUSBServer became much heavier)

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 {
hazheng 18:bf6c5f8281eb 24 class USBServer : public Serial
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
hazheng 18:bf6c5f8281eb 49 //Serial * m_usb;
hazheng 18:bf6c5f8281eb 50
hazheng 18:bf6c5f8281eb 51 //Serial * m_usbIn;
Bobymicjohn 11:676ea42afd56 52
Bobymicjohn 11:676ea42afd56 53 std::list<std::string> m_msgQueue;
Bobymicjohn 11:676ea42afd56 54
Bobymicjohn 11:676ea42afd56 55 Mutex m_qlocker;
Bobymicjohn 11:676ea42afd56 56
hazheng 16:66c7a09e71ee 57 float m_tickMsgTimer;
hazheng 16:66c7a09e71ee 58
Bobymicjohn 11:676ea42afd56 59 void RunningThread();
Bobymicjohn 11:676ea42afd56 60
Bobymicjohn 11:676ea42afd56 61 void ConnectingThread();
hazheng 18:bf6c5f8281eb 62
hazheng 18:bf6c5f8281eb 63 void RxCallback();
Bobymicjohn 11:676ea42afd56 64 };
Bobymicjohn 11:676ea42afd56 65 }
Bobymicjohn 11:676ea42afd56 66 #endif