Jordan Brack / SmartWheelsPublic

Dependencies:   TSI USBDevice mbed-dev

Fork of SmartWheels by haofan Zheng

Committer:
hazheng
Date:
Thu Mar 02 23:56:42 2017 +0000
Revision:
32:5badeff825dc
Parent:
25:6f63053cee81
Successfully get the first picture from the camera and displayed on the computer screen.

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
hazheng 32:5badeff825dc 5 #define HID_REPORT_LENGTH 640
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 19:c93f7fab165d 15 #define TICK_MSG_PC "PCTICK"
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
hazheng 25:6f63053cee81 29 virtual ~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 std::list<std::string> m_msgQueue;
Bobymicjohn 11:676ea42afd56 50
Bobymicjohn 11:676ea42afd56 51 Mutex m_qlocker;
Bobymicjohn 11:676ea42afd56 52
hazheng 19:c93f7fab165d 53 char * m_recvBuf;
hazheng 19:c93f7fab165d 54
hazheng 19:c93f7fab165d 55 unsigned char m_bufPos;
hazheng 19:c93f7fab165d 56
hazheng 19:c93f7fab165d 57 bool m_hasMsgIn;
hazheng 19:c93f7fab165d 58
hazheng 19:c93f7fab165d 59 bool m_isReading;
hazheng 16:66c7a09e71ee 60
Bobymicjohn 11:676ea42afd56 61 void RunningThread();
Bobymicjohn 11:676ea42afd56 62
Bobymicjohn 11:676ea42afd56 63 void ConnectingThread();
hazheng 18:bf6c5f8281eb 64
hazheng 18:bf6c5f8281eb 65 void RxCallback();
Bobymicjohn 11:676ea42afd56 66 };
Bobymicjohn 11:676ea42afd56 67 }
Bobymicjohn 11:676ea42afd56 68 #endif