瀏覽代碼

Add Serial.room()

main
PaulStoffregen 10 年之前
父節點
當前提交
71160e91c2
共有 4 個文件被更改,包括 42 次插入0 次删除
  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 查看文件

@@ -223,6 +223,24 @@ int usb_seremu_write(const void *buffer, uint32_t size)
#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)
{
int i;

+ 3
- 0
teensy3/usb_seremu.h 查看文件

@@ -47,6 +47,7 @@ int usb_seremu_available(void);
void usb_seremu_flush_input(void);
int usb_seremu_putchar(uint8_t c);
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_callback(void);
extern volatile uint8_t usb_seremu_transmit_flush_timer;
@@ -73,6 +74,7 @@ public:
size_t write(long 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); }
int room() { return usb_seremu_room(); }
using Print::write;
void send_now(void) { usb_seremu_flush_output(); };
uint32_t baud(void) { return 9600; }
@@ -109,6 +111,7 @@ public:
size_t write(long n) { return 1; }
size_t write(unsigned int n) { return 1; }
size_t write(int n) { return 1; }
int room() { return 0; }
using Print::write;
void send_now(void) { }
uint32_t baud(void) { return 0; }

+ 18
- 0
teensy3/usb_serial.c 查看文件

@@ -224,6 +224,24 @@ int usb_serial_write(const void *buffer, uint32_t size)
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)
{
if (!usb_configuration) return;

+ 3
- 0
teensy3/usb_serial.h 查看文件

@@ -48,6 +48,7 @@ int usb_serial_read(void *buffer, uint32_t size);
void usb_serial_flush_input(void);
int usb_serial_putchar(uint8_t c);
int usb_serial_write(const void *buffer, uint32_t size);
int usb_serial_room(void);
void usb_serial_flush_output(void);
extern uint32_t usb_cdc_line_coding[2];
extern volatile uint8_t usb_cdc_line_rtsdtr;
@@ -78,6 +79,7 @@ public:
size_t write(long 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); }
int room() { return usb_serial_room(); }
using Print::write;
void send_now(void) { usb_serial_flush_output(); }
uint32_t baud(void) { return usb_cdc_line_coding[0]; }
@@ -124,6 +126,7 @@ public:
size_t write(long n) { return 1; }
size_t write(unsigned int n) { return 1; }
size_t write(int n) { return 1; }
int room() { return 0; }
using Print::write;
void send_now(void) { }
uint32_t baud(void) { return 0; }

Loading…
取消
儲存