fixed initialization process
This commit is contained in:
parent
e01ee4fe57
commit
1afb1e5017
1 changed files with 10 additions and 11 deletions
|
@ -302,21 +302,21 @@ uchar usbFunctionWrite(uchar *data, uchar len) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void hardwareInit(void) {
|
void hardwareInit(void) {
|
||||||
int i;
|
|
||||||
|
|
||||||
/* no pullups on USB and ISP pins */
|
uchar i;
|
||||||
DDRB = DDRC = DDRD = 0xff;
|
|
||||||
PORTB = PORTC = PORTD = 0xff;
|
|
||||||
|
|
||||||
/* USB Reset by device only required on Watchdog Reset */
|
PORTC |= (1 << PC0) | (1 << PC1); /* LEDs off */
|
||||||
usbDeviceDisconnect();
|
|
||||||
for(i = 0; i < 500; i++) {
|
usbDeviceDisconnect(); /* enforce re-enumeration, do this while interrupts are disabled! */
|
||||||
|
i = 0;
|
||||||
|
while(--i){ /* fake USB disconnect for > 250 ms */
|
||||||
|
wdt_reset();
|
||||||
_delay_ms(1);
|
_delay_ms(1);
|
||||||
}
|
}
|
||||||
usbDeviceConnect();
|
usbDeviceConnect();
|
||||||
|
|
||||||
/* all inputs except PC0, PC1 */
|
/* all inputs except PC0, PC1 */
|
||||||
DDRC |= 0x03;
|
DDRC = 0x03;
|
||||||
|
|
||||||
/* enable pull up on jumper */
|
/* enable pull up on jumper */
|
||||||
SLOW_SCK_PORT |= (1 << SLOW_SCK_NUM);
|
SLOW_SCK_PORT |= (1 << SLOW_SCK_NUM);
|
||||||
|
@ -331,15 +331,14 @@ void usbAddressAssigned() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
|
usbInit();
|
||||||
|
|
||||||
/* init ports */
|
/* init ports */
|
||||||
hardwareInit();
|
hardwareInit();
|
||||||
|
|
||||||
/* init timer */
|
/* init timer */
|
||||||
clockInit();
|
clockInit();
|
||||||
|
|
||||||
/* main event loop */
|
|
||||||
usbInit();
|
|
||||||
|
|
||||||
/* start interrupts for USB */
|
/* start interrupts for USB */
|
||||||
sei();
|
sei();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue