embkernel
 All Classes Functions Variables Typedefs Groups Pages
UsbTxStream.hpp
1 //------------------------------------------------------------------------------
2 //This file is part of milkLib.
3 //See license.txt for the full license governing this code.
4 //------------------------------------------------------------------------------
5 
6 #ifndef USB_TX_STREAM_HPP_
7 #define USB_TX_STREAM_HPP_
8 
9 #include "UsbInCallback.hpp"
10 #include "RtosBuffer.hpp"
11 #include "LibStreamOut.hpp"
12 
13 class UsbTxStream: public UsbInCallback, public LibStreamOut {
14 public:
15  UsbTxStream(uint8_t ep, size_t size);
16  virtual ~UsbTxStream();
17 
18  inline void setMaxTimeout(Rtos::TICK timeout) {
19  mMaxTimeout = timeout;
20  }
21 
22  virtual int write(const void* buffer, int len, Rtos::TICK timeout = Rtos::TICK_INFINITE);
23 private:
24  uint8_t mEp;
25  RtosBuffer mBuffer;
26  Rtos::TICK mMaxTimeout;
27 protected:
28  virtual void onDataInFree(uint8_t ep, uint16_t len);
29 };
30 
31 #endif /* USB_TX_STREAM_HPP_ */