source: thomson/elec/CrO2/software/device.h@ e017851

main
Last change on this file since e017851 was e017851, checked in by Adrien Destugues <pulkomandy@…>, 11 years ago

Port to Haiku. Untested.

git-svn-id: svn://localhost/thomson@28 85ae3b6b-dc8f-4344-a89d-598714f2e4e5

  • Property mode set to 100644
File size: 1.3 KB
Line 
1/* CrO2 datassette emulator
2 * Copyright 2012, Adrien Destugues <pulkomandy@pulkomandy.ath.cx>
3 *
4 * Distributed under the terms of the MIT licence.
5 *
6 * Handles device communication through libusb
7 */
8
9#include <stdint.h>
10#include <string.h>
11
12class Tape;
13
14class Device
15{
16 public:
17 // Implemented in subclasses object files. Only one of them is linked
18 // and takes care of instanciating itself.
19 static Device& getDevice() throw(const char*);
20
21 // High-level layer (will call functions below)
22 void write(const Tape& file) throw (const char*);
23
24 // Low-level layer (to be implemented by subclasses
25 virtual int read(uint8_t* buffer, size_t max) = 0;
26 // Fill the buffer with data from device
27 virtual int write(const uint8_t* buffer, size_t size, int blktype) = 0;
28 virtual uint8_t getStatus() = 0;
29 // Get the status word from the device
30
31 protected:
32 /* These are the vendor specific commands implemented by our USB device */
33 static const int PSCMD_CONFIG = 0;
34 static const int PSCMD_GET = 1;
35 static const int PSCMD_PUT = 2;
36 static const int PSCMD_STATUS = 3;
37
38 static const uint32_t vid;
39 static const uint32_t pid;
40 static const char* vendor;
41 static const char* product;
42 private:
43 static bool initOnce;
44 static Device* instance;
45};
Note: See TracBrowser for help on using the repository browser.