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
PCConnector/SWUSBServer.h@13:7dcb1642ef99, 2017-02-08 (annotated)
- Committer:
- hazheng
- Date:
- Wed Feb 08 23:47:02 2017 +0000
- Revision:
- 13:7dcb1642ef99
- Parent:
- 11:676ea42afd56
- Child:
- 16:66c7a09e71ee
Finished reading SCCB from camera.
Who changed what in which revision?
| User | Revision | Line number | New 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" |
| 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 | |
| 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 | |
| Bobymicjohn | 11:676ea42afd56 | 55 | void RunningThread(); |
| Bobymicjohn | 11:676ea42afd56 | 56 | |
| Bobymicjohn | 11:676ea42afd56 | 57 | void ConnectingThread(); |
| Bobymicjohn | 11:676ea42afd56 | 58 | }; |
| Bobymicjohn | 11:676ea42afd56 | 59 | } |
| Bobymicjohn | 11:676ea42afd56 | 60 | #endif |
