Ejemplo n.º 1
0
static void
lpbb_setscl(device_t dev, int val)
{
	device_t ppbus = device_get_parent(dev);

	ppb_lock(ppbus);
	if (val == 0)
		ppb_wctr(ppbus, (u_char)(ppb_rctr(ppbus) & ~SCL_out));
	else
		ppb_wctr(ppbus, (u_char)(ppb_rctr(ppbus) | SCL_out));
	ppb_unlock(ppbus);
}
Ejemplo n.º 2
0
/* Reset bus by setting SDA first and then SCL. */
static void
lpbb_reset_bus(device_t dev)
{
	device_t ppbus = device_get_parent(dev);

	ppb_assert_locked(ppbus);
	ppb_wdtr(ppbus, (u_char)~SDA_out);
	ppb_wctr(ppbus, (u_char)(ppb_rctr(ppbus) | SCL_out));
}
Ejemplo n.º 3
0
/*
 * byte_peripheral_write()
 *
 * Write n bytes in BYTE mode
 */
int
byte_peripheral_write(device_t bus, char *buffer, int len, int *sent)
{
	int error = 0, i;
	char r;

	ppb_1284_set_state(bus, PPB_PERIPHERAL_TRANSFER);

	/* wait forever, the remote host is master and should initiate
	 * termination
	 */
	for (i=0; i<len; i++) {
		/* force remote nFAULT low to release the remote waiting
		 * process, if any
		 */
		r = ppb_rctr(bus);
		ppb_wctr(bus, r & ~nINIT);

#ifdef DEBUG_1284
		printf("y");
#endif
		/* Event 7 */
		error = ppb_poll_bus(bus, PPB_FOREVER, nBUSY, nBUSY,
					PPB_INTR);

		if (error && error != EWOULDBLOCK)
			goto error;

#ifdef DEBUG_1284
		printf("b");
#endif
		if ((error = byte_peripheral_outbyte(bus, buffer+i, (i == len-1))))
			goto error;
	}
error:
	if (!error)
		ppb_1284_set_state(bus, PPB_PERIPHERAL_IDLE);

	*sent = i;
	return (error);
}