int main(void) { wdt_reset(); wdt_enable(WDTO_120MS); usbInit(); usbDeviceDisconnect(); uint8_t t; for (t=255; t; t--) { _delay_ms(1); wdt_reset(); } usbDeviceConnect(); sei(); gpib_init(); for (;;) { usbPoll(); wdt_reset(); } }
void main() { sysclk_init(); // Initialize oscillator wait_ms(1000); port_init(); // Initialize crossbar and GPIO gpib_init(); timer_init(); EA = 1; // Global Interrupt enable usb0_init(); while (1) { gpib_polling(); usb_polling(); if(sys_state & SYS_PERIODIC_ACTIVE){ sys_state &= ~SYS_PERIODIC_ACTIVE; led_toggle(1); } if(sys_state & SYS_GPIB_CONTROLLER){ led_on(2); }else{ led_off(2); } { // check talked static __xdata u8 persistent = 0; if(sys_state & SYS_GPIB_TALKED){ led_on(3); persistent = 0x40; }else if(persistent > 0){ led_toggle(3); persistent--; }else{ led_off(3); } } { // check listened static __xdata u8 persistent = 0; if(sys_state & SYS_GPIB_LISTENED){ led_on(4); persistent = 0x40; }else if(persistent > 0){ led_toggle(4); persistent--; }else{ led_off(4); } } } }