xref: /haiku/src/add-ons/kernel/drivers/ports/usb_serial/KLSI.h (revision 13581b3d2a71545960b98fefebc5225b5bf29072)
1 /*
2  * Copyright (c) 2007-2008 by Michael Lotz
3  * Heavily based on the original usb_serial driver which is:
4  *
5  * Copyright (c) 2003-2004 by Siarzhuk Zharski <imker@gmx.li>
6  * Distributed under the terms of the MIT License.
7  */
8 #ifndef _USB_KLSI_H_
9 #define _USB_KLSI_H_
10 
11 
12 #include "SerialDevice.h"
13 
14 
15 /* supported vendor and product ids */
16 #define VENDOR_PALM		0x0830
17 #define VENDOR_KLSI		0x05e9
18 
19 const usb_serial_device kKLSIDevices[] = {
20 	{VENDOR_PALM, 0x0080, "PalmConnect RS232"},
21 	{VENDOR_KLSI, 0x00c0, "KLSI KL5KUSB105D"}
22 };
23 
24 
25 /* protocol defines */
26 #define KLSI_SET_REQUEST			0x01
27 #define KLSI_POLL_REQUEST			0x02
28 #define KLSI_CONF_REQUEST			0x03
29 #define KLSI_CONF_REQUEST_READ_ON	0x03
30 #define KLSI_CONF_REQUEST_READ_OFF	0x02
31 
32 // not sure
33 #define KLSI_BUFFER_SIZE			64
34 
35 enum {
36 	klsi_sio_b115200 = 0,
37 	klsi_sio_b57600 = 1,
38 	klsi_sio_b38400 = 2,
39 	klsi_sio_b19200 = 4,
40 	klsi_sio_b9600 = 6,
41 	/* unchecked */
42 	klsi_sio_b4800 = 8,
43 	klsi_sio_b2400 = 9,
44 	klsi_sio_b1200 = 10,
45 	klsi_sio_b600 = 11,
46 	klsi_sio_b300 = 12
47 };
48 
49 
50 class KLSIDevice : public SerialDevice {
51 public:
52 								KLSIDevice(usb_device device, uint16 vendorID,
53 									uint16 productID, const char *description);
54 
55 virtual	status_t				AddDevice(const usb_configuration_info *config);
56 
57 virtual	status_t				ResetDevice();
58 
59 virtual	status_t				SetLineCoding(usb_cdc_line_coding *coding);
60 
61 virtual	void					OnRead(char **buffer, size_t *numBytes);
62 virtual	void					OnWrite(const char *buffer, size_t *numBytes,
63 									size_t *packetBytes);
64 virtual	void					OnClose();
65 };
66 
67 
68 #endif //_USB_KLSI_H_
69