26 static Cinfo slinfo[] = {
27 { 0x10c4, 0xea60, }, /* CP210x */
28 { 0x10c4, 0xea61, }, /* CP210x */
32 static Serialops slops;
36 Usbdev *ud = ser->dev->usb;
38 if(matchid(slinfo, ud->vid, ud->did) == nil)
40 ser->Serialops = slops;
45 slwrite(Serialport *p, int req, void *buf, int len)
50 return usbcmd(ser->dev, Rh2d | Rvendor | Riface, req, 0, p->interfc,
55 slput(Serialport *p, uint op, uint val)
60 return usbcmd(ser->dev, Rh2d | Rvendor | Riface, op, val, p->interfc,
65 slread(Serialport *p, int req, void *buf, int len)
70 return usbcmd(ser->dev, Rd2h | Rvendor | Riface, req, 0, p->interfc,
80 dsprint(2, "slinit\n");
86 /* p gets freed by closedev, the process has a reference */
92 slgetparam(Serialport *p)
96 slread(p, Getbaud, &p->baud, sizeof(p->baud));
97 slread(p, Getlcr, &lcr, sizeof(lcr));
98 p->bits = (lcr&Bitsmask)>>Bitsshift;
99 p->parity = (lcr&Parmask)>>Parshift;
100 p->stop = (lcr&Stopmask) == Stop1? 1 : 2;
105 slsetparam(Serialport *p)
109 lcr = p->stop == 1? Stop1 : Stop2;
110 lcr |= (p->bits<<Bitsshift) | (p->parity<<Parshift);
111 slput(p, Setlcr, lcr);
112 slwrite(p, Setbaud, &p->baud, sizeof(p->baud));
117 wait4data(Serialport *p, uchar *data, int count)
122 while ((n = read(p->epin->dfd, data, count)) == 0)
128 static Serialops slops = {
130 .getparam = slgetparam,
131 .setparam = slsetparam,
132 .wait4data = wait4data,