1
0
mirror of git://projects.qi-hardware.com/ben-wpan.git synced 2024-11-23 00:10:17 +02:00

atudb/fw: disable the UART in ATUSB_GPIO

- board.c (gpio): split GPIO setup and probing
- board.c (gpio): disable the UART while probing GPIOs
This commit is contained in:
Werner Almesberger 2011-06-05 18:27:40 -03:00
parent d1dd611d1e
commit e6f7d85e8a

View File

@ -172,30 +172,43 @@ int gpio(uint8_t port, uint8_t data, uint8_t dir, uint8_t mask, uint8_t *res)
case 1: case 1:
DDRB = (DDRB & ~mask) | dir; DDRB = (DDRB & ~mask) | dir;
PORTB = (PORTB & ~mask) | data; PORTB = (PORTB & ~mask) | data;
_delay_ms(1); break;
case 2:
DDRC = (DDRC & ~mask) | dir;
PORTC = (PORTC & ~mask) | data;
break;
case 3:
DDRD = (DDRD & ~mask) | dir;
PORTD = (PORTD & ~mask) | data;
break;
default:
return 0;
}
/* disable the UART so that we can meddle with these pins as well. */
UCSR1B = 0;
_delay_ms(1);
switch (port) {
case 1:
res[0] = PINB; res[0] = PINB;
res[1] = PORTB; res[1] = PORTB;
res[2] = DDRB; res[2] = DDRB;
break; break;
case 2: case 2:
DDRC = (DDRC & ~mask) | dir;
PORTC = (PORTC & ~mask) | data;
_delay_ms(1);
res[0] = PINC; res[0] = PINC;
res[1] = PORTC; res[1] = PORTC;
res[2] = DDRC; res[2] = DDRC;
break; break;
case 3: case 3:
DDRD = (DDRD & ~mask) | dir;
PORTD = (PORTD & ~mask) | data;
_delay_ms(1);
res[0] = PIND; res[0] = PIND;
res[1] = PORTD; res[1] = PORTD;
res[2] = DDRD; res[2] = DDRD;
break; break;
default:
return 0;
} }
spi_init();
return 1; return 1;
} }