Browse Source

Support Serial boolean check for Serial Monitor with HID serial emulation

teensy4-core
PaulStoffregen 4 years ago
parent
commit
dcac79c82e
7 changed files with 24 additions and 12 deletions
  1. +7
    -4
      teensy3/usb_dev.c
  2. +1
    -0
      teensy3/usb_dev.h
  3. +1
    -0
      teensy3/usb_seremu.c
  4. +2
    -1
      teensy3/usb_seremu.h
  5. +10
    -6
      teensy4/usb.c
  6. +1
    -0
      teensy4/usb_seremu.c
  7. +2
    -1
      teensy4/usb_seremu.h

+ 7
- 4
teensy3/usb_dev.c View File

} }
#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

+ 1
- 0
teensy3/usb_dev.h View File

#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

+ 1
- 0
teensy3/usb_seremu.c View File

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 */



+ 2
- 1
teensy3/usb_seremu.h View File

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);

+ 10
- 6
teensy4/usb.c View File

} }
#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

+ 1
- 0
teensy4/usb_seremu.c View File



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 */

+ 2
- 1
teensy4/usb_seremu.h View File

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);

Loading…
Cancel
Save