Example #1
0
static void hardwareInit(void)
{

    /* activate pull-ups except on USB lines */
    USB_CFG_IOPORT   = (uchar)~((1<<USB_CFG_DMINUS_BIT)|(1<<USB_CFG_DPLUS_BIT));
    /* all pins input except USB (-> USB reset) */
#ifdef USB_CFG_PULLUP_IOPORT    /* use usbDeviceConnect()/usbDeviceDisconnect() if available */
    USBDDR    = 0;    /* we do RESET by deactivating pullup */
    usbDeviceDisconnect();
#else
    USBDDR    = (1<<USB_CFG_DMINUS_BIT)|(1<<USB_CFG_DPLUS_BIT);
#endif

    /* 250 ms disconnect */
    wdt_reset();
    _delay_ms(250);

#ifdef USB_CFG_PULLUP_IOPORT
    usbDeviceConnect();
#else
    USBDDR    = 0;      /*  remove USB reset condition */
#endif

    /*    USART configuration    */
    baud.dword  = UART_DEFAULT_BPS;
    stopbit = 0;
    parity  = 0;
    databit = 8;
    resetUart();
}
Example #2
0
uchar usbFunctionWrite( uchar *data, uchar len )
{
	/*    SET_LINE_CODING    */
	baud.bytes[0] = data[0];
	baud.bytes[1] = data[1];
	baud.bytes[2] = data[2];
	baud.bytes[3] = data[3];

	stopbit    = data[4];
	parity     = data[5];
	databit    = data[6];

	if( parity>2 )
		parity    = 0;
	if( stopbit==1 )
		stopbit    = 0;

	resetUart();
	return 1;
}