Browse Source

Add Serial.room()

main
PaulStoffregen 10 years ago
parent
commit
71160e91c2
4 changed files with 42 additions and 0 deletions
  1. +18
    -0
      teensy3/usb_seremu.c
  2. +3
    -0
      teensy3/usb_seremu.h
  3. +18
    -0
      teensy3/usb_serial.c
  4. +3
    -0
      teensy3/usb_serial.h

+ 18
- 0
teensy3/usb_seremu.c View File

#endif #endif
} }


int usb_seremu_room(void)
{
uint32_t len;

tx_noautoflush = 1;
if (!tx_packet) {
if (!usb_configuration ||
usb_tx_packet_count(SEREMU_TX_ENDPOINT) >= TX_PACKET_LIMIT ||
(tx_packet = usb_malloc()) == NULL) {
tx_noautoflush = 0;
return 0;
}
}
len = SEREMU_TX_SIZE - tx_packet->index;
tx_noautoflush = 0;
return len;
}

void usb_seremu_flush_output(void) void usb_seremu_flush_output(void)
{ {
int i; int i;

+ 3
- 0
teensy3/usb_seremu.h View File

void usb_seremu_flush_input(void); void usb_seremu_flush_input(void);
int usb_seremu_putchar(uint8_t c); int usb_seremu_putchar(uint8_t c);
int usb_seremu_write(const void *buffer, uint32_t size); int usb_seremu_write(const void *buffer, uint32_t size);
int usb_seremu_room(void);
void usb_seremu_flush_output(void); void usb_seremu_flush_output(void);
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;
size_t write(long n) { return write((uint8_t)n); } size_t write(long n) { return write((uint8_t)n); }
size_t write(unsigned int n) { return write((uint8_t)n); } size_t write(unsigned int n) { return write((uint8_t)n); }
size_t write(int n) { return write((uint8_t)n); } size_t write(int n) { return write((uint8_t)n); }
int room() { return usb_seremu_room(); }
using Print::write; using Print::write;
void send_now(void) { usb_seremu_flush_output(); }; void send_now(void) { usb_seremu_flush_output(); };
uint32_t baud(void) { return 9600; } uint32_t baud(void) { return 9600; }
size_t write(long n) { return 1; } size_t write(long n) { return 1; }
size_t write(unsigned int n) { return 1; } size_t write(unsigned int n) { return 1; }
size_t write(int n) { return 1; } size_t write(int n) { return 1; }
int room() { return 0; }
using Print::write; using Print::write;
void send_now(void) { } void send_now(void) { }
uint32_t baud(void) { return 0; } uint32_t baud(void) { return 0; }

+ 18
- 0
teensy3/usb_serial.c View File

return 0; return 0;
} }


int usb_serial_room(void)
{
uint32_t len;

tx_noautoflush = 1;
if (!tx_packet) {
if (!usb_configuration ||
usb_tx_packet_count(CDC_TX_ENDPOINT) >= TX_PACKET_LIMIT ||
(tx_packet = usb_malloc()) == NULL) {
tx_noautoflush = 0;
return 0;
}
}
len = CDC_TX_SIZE - tx_packet->index;
tx_noautoflush = 0;
return len;
}

void usb_serial_flush_output(void) void usb_serial_flush_output(void)
{ {
if (!usb_configuration) return; if (!usb_configuration) return;

+ 3
- 0
teensy3/usb_serial.h View File

void usb_serial_flush_input(void); void usb_serial_flush_input(void);
int usb_serial_putchar(uint8_t c); int usb_serial_putchar(uint8_t c);
int usb_serial_write(const void *buffer, uint32_t size); int usb_serial_write(const void *buffer, uint32_t size);
int usb_serial_room(void);
void usb_serial_flush_output(void); void usb_serial_flush_output(void);
extern uint32_t usb_cdc_line_coding[2]; extern uint32_t usb_cdc_line_coding[2];
extern volatile uint8_t usb_cdc_line_rtsdtr; extern volatile uint8_t usb_cdc_line_rtsdtr;
size_t write(long n) { return write((uint8_t)n); } size_t write(long n) { return write((uint8_t)n); }
size_t write(unsigned int n) { return write((uint8_t)n); } size_t write(unsigned int n) { return write((uint8_t)n); }
size_t write(int n) { return write((uint8_t)n); } size_t write(int n) { return write((uint8_t)n); }
int room() { return usb_serial_room(); }
using Print::write; using Print::write;
void send_now(void) { usb_serial_flush_output(); } void send_now(void) { usb_serial_flush_output(); }
uint32_t baud(void) { return usb_cdc_line_coding[0]; } uint32_t baud(void) { return usb_cdc_line_coding[0]; }
size_t write(long n) { return 1; } size_t write(long n) { return 1; }
size_t write(unsigned int n) { return 1; } size_t write(unsigned int n) { return 1; }
size_t write(int n) { return 1; } size_t write(int n) { return 1; }
int room() { return 0; }
using Print::write; using Print::write;
void send_now(void) { } void send_now(void) { }
uint32_t baud(void) { return 0; } uint32_t baud(void) { return 0; }

Loading…
Cancel
Save