USB pins: INPUT or OUTPUT?

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Post Reply
TheDude
Posts: 2
Joined: Mon Nov 14, 2011 11:45 pm

USB pins: INPUT or OUTPUT?

Post by TheDude » Tue Nov 15, 2011 12:11 am

Hi all,

Code: Select all

DDRD = ~(1 << 2);   /* all outputs except PD2 = INT0 */
DDRB = ~USBMASK;    /* set all pins as outputs except USB */

form the PowerSwitch example project
so USB is input


Code: Select all

DDRD = 7;    /* 0000 0111 bin: all pins input except USB (-> USB reset) */

from HIDKeys example project
so USB is output

what now, input or output?
:?:


thx

Daid
Rank 2
Rank 2
Posts: 55
Joined: Mon Apr 18, 2011 12:19 pm

Re: USB pins: INPUT or OUTPUT?

Post by Daid » Tue Nov 15, 2011 2:41 pm

Both. The USB pins are bi-directional. I think the USB code configures them anyhow, for bi-directional ports you need to change both the DDR and PORT register.

Post Reply