Ejemplo n.º 1
0
void
uftdi_write(void *vsc, int portno, u_char *to, u_char *from, u_int32_t *count)
{
	struct uftdi_softc *sc = vsc;

	DPRINTFN(10,("uftdi_write: sc=%p, port=%d count=%u data[0]=0x%02x\n",
		     vsc, portno, *count, from[0]));

	/* Make length tag and copy data */
	if (sc->sc_hdrlen > 0)
		*to = FTDI_OUT_TAG(*count, portno);

	memcpy(to + sc->sc_hdrlen, from, *count);
	*count += sc->sc_hdrlen;
}
Ejemplo n.º 2
0
Archivo: FTDI.cpp Proyecto: DonCN/haiku
void
FTDIDevice::OnWrite(const char *buffer, size_t *numBytes, size_t *packetBytes)
{
	if (*numBytes > FTDI_BUFFER_SIZE)
		*numBytes = *packetBytes = FTDI_BUFFER_SIZE;

	char *writeBuffer = WriteBuffer();
	if (fHeaderLength > 0) {
		if (*numBytes > WriteBufferSize() - fHeaderLength)
			*numBytes = *packetBytes = WriteBufferSize() - fHeaderLength;

		*writeBuffer = FTDI_OUT_TAG(*numBytes, FTDI_PIT_DEFAULT);
	}

	memcpy(writeBuffer + fHeaderLength, buffer, *packetBytes);
	*packetBytes += fHeaderLength;
}