| } | } | ||||
| #endif | #endif | ||||
| #ifdef SEREMU_INTERFACE | #ifdef SEREMU_INTERFACE | ||||
| if (setup.word1 == 0x03000921 && setup.word2 == ((4<<16)|SEREMU_INTERFACE) | |||||
| && buf[0] == 0xA9 && buf[1] == 0x45 && buf[2] == 0xC2 && buf[3] == 0x6B) { | |||||
| usb_reboot_timer = 5; | |||||
| endpoint0_transmit(NULL, 0); | |||||
| if (setup.word1 == 0x03000921 && setup.word2 == ((4<<16)|SEREMU_INTERFACE)) { | |||||
| if (buf[0] == 0xA9 && buf[1] == 0x45 && buf[2] == 0xC2 && buf[3] == 0x6B) { | |||||
| usb_reboot_timer = 5; | |||||
| endpoint0_transmit(NULL, 0); | |||||
| } else { | |||||
| usb_seremu_online = 1; | |||||
| } | |||||
| } | } | ||||
| #endif | #endif | ||||
| #ifdef AUDIO_INTERFACE | #ifdef AUDIO_INTERFACE | 
| #ifdef SEREMU_INTERFACE | #ifdef SEREMU_INTERFACE | ||||
| extern volatile uint8_t usb_seremu_transmit_flush_timer; | extern volatile uint8_t usb_seremu_transmit_flush_timer; | ||||
| extern void usb_seremu_flush_callback(void); | extern void usb_seremu_flush_callback(void); | ||||
| extern volatile uint8_t usb_seremu_online; | |||||
| #endif | #endif | ||||
| #ifdef KEYBOARD_INTERFACE | #ifdef KEYBOARD_INTERFACE | 
| static usb_packet_t *rx_packet=NULL; | static usb_packet_t *rx_packet=NULL; | ||||
| static usb_packet_t *tx_packet=NULL; | static usb_packet_t *tx_packet=NULL; | ||||
| static volatile uint8_t tx_noautoflush=0; | static volatile uint8_t tx_noautoflush=0; | ||||
| volatile uint8_t usb_seremu_online=0; | |||||
| #define TRANSMIT_FLUSH_TIMEOUT 5 /* in milliseconds */ | #define TRANSMIT_FLUSH_TIMEOUT 5 /* in milliseconds */ | ||||
| void usb_seremu_flush_callback(void); | void usb_seremu_flush_callback(void); | ||||
| extern volatile uint8_t usb_seremu_transmit_flush_timer; | extern volatile uint8_t usb_seremu_transmit_flush_timer; | ||||
| extern volatile uint8_t usb_configuration; | extern volatile uint8_t usb_configuration; | ||||
| extern volatile uint8_t usb_seremu_online; | |||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||
| } | } | ||||
| #endif | #endif | ||||
| uint8_t numbits(void) { return 8; } | uint8_t numbits(void) { return 8; } | ||||
| uint8_t dtr(void) { return 1; } | uint8_t dtr(void) { return 1; } | ||||
| uint8_t rts(void) { return 1; } | uint8_t rts(void) { return 1; } | ||||
| operator bool() { return usb_configuration; } | |||||
| operator bool() { return usb_configuration && usb_seremu_online; } | |||||
| }; | }; | ||||
| extern usb_seremu_class Serial; | extern usb_seremu_class Serial; | ||||
| extern void serialEvent(void); | extern void serialEvent(void); | 
| } | } | ||||
| #endif | #endif | ||||
| #ifdef SEREMU_INTERFACE | #ifdef SEREMU_INTERFACE | ||||
| if (setup.word1 == 0x03000921 && setup.word2 == ((4<<16)|SEREMU_INTERFACE) | |||||
| && endpoint0_buffer[0] == 0xA9 && endpoint0_buffer[1] == 0x45 | |||||
| && endpoint0_buffer[2] == 0xC2 && endpoint0_buffer[3] == 0x6B) { | |||||
| printf("seremu reboot request\n"); | |||||
| usb_start_sof_interrupts(NUM_INTERFACE); | |||||
| usb_reboot_timer = 80; // TODO: 10 if only 12 Mbit/sec | |||||
| if (setup.word1 == 0x03000921 && setup.word2 == ((4<<16)|SEREMU_INTERFACE)) { | |||||
| if (endpoint0_buffer[0] == 0xA9 && endpoint0_buffer[1] == 0x45 | |||||
| && endpoint0_buffer[2] == 0xC2 && endpoint0_buffer[3] == 0x6B) { | |||||
| printf("seremu reboot request\n"); | |||||
| usb_start_sof_interrupts(NUM_INTERFACE); | |||||
| usb_reboot_timer = 80; // TODO: 10 if only 12 Mbit/sec | |||||
| } else { | |||||
| // any other feature report means Arduino Serial Monitor is open | |||||
| usb_seremu_online = 1; | |||||
| } | |||||
| } | } | ||||
| #endif | #endif | ||||
| #ifdef AUDIO_INTERFACE | #ifdef AUDIO_INTERFACE | 
| static volatile uint8_t tx_noautoflush=0; | static volatile uint8_t tx_noautoflush=0; | ||||
| extern volatile uint8_t usb_high_speed; | extern volatile uint8_t usb_high_speed; | ||||
| volatile uint8_t usb_seremu_online=0; | |||||
| // TODO: should be 2 different timeouts, high speed (480) vs full speed (12) | // TODO: should be 2 different timeouts, high speed (480) vs full speed (12) | ||||
| #define TRANSMIT_FLUSH_TIMEOUT 75 /* in microseconds */ | #define TRANSMIT_FLUSH_TIMEOUT 75 /* in microseconds */ | 
| int usb_seremu_write_buffer_free(void); | int usb_seremu_write_buffer_free(void); | ||||
| void usb_seremu_flush_output(void); | void usb_seremu_flush_output(void); | ||||
| extern volatile uint8_t usb_configuration; | extern volatile uint8_t usb_configuration; | ||||
| extern volatile uint8_t usb_seremu_online; | |||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||
| } | } | ||||
| #endif | #endif | ||||
| uint8_t numbits(void) { return 8; } | uint8_t numbits(void) { return 8; } | ||||
| uint8_t dtr(void) { return 1; } | uint8_t dtr(void) { return 1; } | ||||
| uint8_t rts(void) { return 1; } | uint8_t rts(void) { return 1; } | ||||
| operator bool() { return usb_configuration; } | |||||
| operator bool() { return usb_configuration && usb_seremu_online; } | |||||
| }; | }; | ||||
| extern usb_seremu_class Serial; | extern usb_seremu_class Serial; | ||||
| extern void serialEvent(void); | extern void serialEvent(void); |