1 /* 2 * Copyright 2011, Adrien Destugues <pulkomandy@pulkomandy.ath.cx> 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _USB_SILICON_H_ 6 #define _USB_SILICON_H_ 7 8 #include "SerialDevice.h" 9 10 class SiliconDevice : public SerialDevice { 11 public: 12 SiliconDevice(usb_device device, uint16 vendorID, 13 uint16 productID, const char *description); 14 15 virtual status_t AddDevice(const usb_configuration_info *config); 16 17 virtual status_t ResetDevice(); 18 19 virtual status_t SetLineCoding(usb_cdc_line_coding *coding); 20 virtual status_t SetControlLineState(uint16 state); 21 22 private: 23 enum CP210XRequest { 24 ENABLE_UART = 0, 25 /* 1 to enable the UART function, 0 to disable 26 * (some Silicon Labs chips have other functions such as GPIOs) */ 27 28 29 SET_BAUDRATE_DIVIDER = 1, 30 GET_BAUDRATE_DIVIDER = 2, 31 /* 32 Baudrate base clock is 3686400 33 34 3686400 / 32 = 115200 35 ... 36 3686400 / 384 = 9600 37 */ 38 39 SET_LINE_FORMAT = 3, 40 GET_LINE_FORMAT = 4, 41 /* 42 DataBits << 0x100 | Parity << 0x10 | StopBits 43 44 Databits in [5,9] 45 Parity : 46 0 = none 47 1 = odd 48 2 = even 49 3 = mark 50 4 = space 51 Stop bits: 52 0 = 1 stop bit 53 1 = 1.5 stop bits 54 2 = 2 stop bits 55 */ 56 57 SET_BREAK = 5, 58 /* 1 to enable, 0 to disable */ 59 60 IMMEDIATE_CHAR = 6, 61 62 SET_STATUS = 7, 63 GET_STATUS = 8, 64 /* 65 bit 0 = DTR 66 bit 1 = RTS 67 68 bit 4 = CTS 69 bit 5 = DSR 70 bit 6 = RING 71 bit 7 = DCD 72 bit 8 = WRITE_DTR (unset to not touch DTR) 73 bit 9 = WRITE_RTS (unset to not touch RTS) 74 */ 75 76 SET_XON = 9, 77 SET_XOFF = 10, 78 SET_EVENTMASK = 11, 79 GET_EVENTMASK = 12, 80 SET_CHAR = 13, 81 GET_CHARS = 14, 82 GET_PROPS = 15, 83 GET_COMM_STATUS = 16, 84 RESET = 17, 85 PURGE = 18, 86 87 SET_FLOW = 19, 88 GET_FLOW = 20, 89 /* Hardware flow control setup */ 90 91 EMBED_EVENTS = 21, 92 GET_EVENTSTATE = 22, 93 SET_CHARS = 0x19 94 }; 95 96 private: 97 status_t WriteConfig(CP210XRequest request, uint16_t* data, 98 size_t size); 99 }; 100 101 #define VENDOR_RENESAS 0x045B 102 #define VENDOR_AKATOM 0x0471 103 #define VENDOR_PIRELLI 0x0489 104 #define VENDOR_CYPHERLAB 0x0745 105 #define VENDOR_GEMALTO 0x08E6 106 #define VENDOR_DIGIANSWER 0x08FD 107 #define VENDOR_MEI 0x0BED 108 #define VENDOR_DYNASTREAM 0x0FCF 109 #define VENDOR_KNOCKOFF 0x10A6 110 #define VENDOR_SIEMENS 0x10AB 111 #define VENDOR_NOKIA 0x10B5 112 #define VENDOR_SILICON 0x10C4 113 #define VENDOR_SILICON2 0x10C5 114 #define VENDOR_SILICON3 0x10CE 115 #define VENDOR_BALTECH 0x13AD 116 #define VENDOR_OWEN 0x1555 117 #define VENDOR_CLIPSAL 0x166A 118 #define VENDOR_JABLOTRON 0x16D6 119 #define VENDOR_WIENER 0x16DC 120 #define VENDOR_WAVESENSE 0x17F4 121 #define VENDOR_VAISALA 0x1843 122 #define VENDOR_ELV 0x18EF 123 #define VENDOR_WAGO 0x1BE3 124 #define VENDOR_DW700 0x413C 125 126 127 #endif //_USB_SILICON_H_ 128