diff options
| author | Dave Hylands <dhylands@gmail.com> | 2014-01-06 00:20:11 -0800 |
|---|---|---|
| committer | John R. Lenton <jlenton@gmail.com> | 2014-01-07 22:51:08 +0000 |
| commit | b6e9c7c6970971cc0aeadd38cdf287352c97ddf6 (patch) | |
| tree | b9755f0fddff8f943ebafe33305a921bcfce0b5a /teensy/usb.c | |
| parent | b59fa2da28e13d4b38ff799bc330dd6291a49ff7 (diff) | |
Initial support for Teensy 3.1
Diffstat (limited to 'teensy/usb.c')
| -rw-r--r-- | teensy/usb.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/teensy/usb.c b/teensy/usb.c new file mode 100644 index 000000000..a045a2ed6 --- /dev/null +++ b/teensy/usb.c @@ -0,0 +1,44 @@ +#include "Arduino.h" + +#include "usb.h" +#include "usb_serial.h" + +int usb_vcp_is_connected(void) +{ + return usb_configuration && (usb_cdc_line_rtsdtr & (USB_SERIAL_DTR | USB_SERIAL_RTS)); +} + +int usb_vcp_is_enabled(void) +{ + return 1; +} + +int usb_vcp_rx_any(void) +{ + return usb_serial_available(); +} + +char usb_vcp_rx_get(void) +{ + return usb_serial_getchar(); +} + +void usb_vcp_send_str(const char* str) +{ + usb_vcp_send_strn(str, strlen(str)); +} + +void usb_vcp_send_strn(const char* str, int len) +{ + usb_serial_write(str, len); +} + +void usb_vcp_send_strn_cooked(const char *str, int len) +{ + for (const char *top = str + len; str < top; str++) { + if (*str == '\n') { + usb_serial_putchar('\r'); + } + usb_serial_putchar(*str); + } +} |
