int main(void) { // Enable pin change interrupt for pulse input PCMSK3 |= _BV(PCINT28); PCICR |= _BV(PCIE3); // Enable pullup resistor on unused pins PORTA = 0xFF; // Set millisecond-timer period to 1ms OCR1A = 9999; STOP_MILLISECOND_TIMER; TIMSK1 |= _BV(OCIE1A); // Set other init usb_initialize(); camera_initialize(); display_initialize(); // Enable relay mode until reboot if (eeprom_read_byte(RELAY_EEPROM_OFFSET) == RELAY_ENABLED) { set_timer_status(TIMER_RELAY); eeprom_update_byte(RELAY_EEPROM_OFFSET, RELAY_DISABLED); } // Enable interrupts sei(); gps_initialize(); // Main program loop for (;;) { // Handle message flags set via interrupt if (message_flags && timer_status != TIMER_RELAY) { uint8_t temp_int_flags = 0; ATOMIC_BLOCK(ATOMIC_FORCEON) { temp_int_flags = message_flags; message_flags = 0; } if (temp_int_flags & FLAG_SEND_TRIGGER) usb_send_trigger(); if (temp_int_flags & FLAG_SEND_TIMESTAMP) usb_send_timestamp(); if (temp_int_flags & FLAG_SEND_STATUS) usb_send_status(timer_status, gps_status); if (temp_int_flags & FLAG_STOP_EXPOSURE) usb_stop_exposure(); if (temp_int_flags & FLAG_DUPLICATE_PULSE) usb_send_message_P(msg_duplicate_pulse); if (temp_int_flags & FLAG_MISSING_PULSE) usb_send_message_P(msg_missing_pulse); if (temp_int_flags & FLAG_TIME_DRIFT) usb_send_message_fmt_P(fmt_time_drift, millisecond_drift); } camera_tick(); usb_tick(); gps_tick(); display_update(); }
static void usb_setup_get_device_status(void) { setup_out_buf[0] = (usb_remote_wakeup != 0) ? 2 : 0; setup_out_buf[1] = 0; usb_send_status(); }