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
- Committer:
- Bobymicjohn
- Date:
- 2017-02-07
- Revision:
- 11:676ea42afd56
- Child:
- 13:7dcb1642ef99
File content as of revision 11:676ea42afd56:
#pragma once
#ifndef SW_USBSERVER_H
#define SW_USBSERVER_H
#define HID_REPORT_LENGTH 64
#define HID_SER_STAT_STOPPED 0
#define HID_SER_STAT_SEARCHING 1
#define HID_SER_STAT_CONNECTING 2
#define HID_SER_STAT_CONNECTED 3
#define HID_SER_STAT_RUNNING 4
#define HANDSHAKE_MSG_TER "SMARTWHEELS_HANDSHAKE_TERMINAL"
#define HANDSHAKE_MSG_PC "SMARTWHEELS_HANDSHAKE_PC"
#include <mbed.h>
#include <USBHID.h>
#include <rtos.h>
#include <list>
#include <string>
namespace SW
{
class USBServer
{
public:
USBServer(uint16_t vendor_id=0x1234, uint16_t product_id=0x0006);
~USBServer();
void Update(float deltaTime);
bool PushReliableMsg(const char type, const std::string & msg);
bool PushUnreliableMsg(const char type, const std::string & msg);
void Terminate();
private:
bool m_shouldTerminate;
uint8_t m_stat;
Thread * m_usbThread;
Serial * m_usb;
std::list<std::string> m_msgQueue;
Mutex m_qlocker;
void RunningThread();
void ConnectingThread();
};
}
#endif
