2017-03-08 12:43:24 +00:00
|
|
|
#include "py/mphal.h"
|
2017-03-30 14:06:01 +00:00
|
|
|
#include "usb.h"
|
2017-03-08 12:43:24 +00:00
|
|
|
|
2017-03-30 14:06:01 +00:00
|
|
|
#define VCP_IFACE 0x01
|
2017-04-10 16:29:47 +00:00
|
|
|
#define VCP_READ_TIMEOUT 25
|
2017-04-19 15:10:17 +00:00
|
|
|
#define VCP_WRITE_TIMEOUT 0
|
2017-03-08 12:43:24 +00:00
|
|
|
|
|
|
|
int mp_hal_stdin_rx_chr(void) {
|
2017-04-10 16:29:47 +00:00
|
|
|
uint8_t c = 0;
|
|
|
|
while (usb_vcp_read_blocking(VCP_IFACE, &c, 1, VCP_READ_TIMEOUT) < 1);
|
|
|
|
return c;
|
2017-03-08 12:43:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void mp_hal_stdout_tx_strn(const char *str, size_t len) {
|
2017-03-30 14:06:01 +00:00
|
|
|
usb_vcp_write_blocking(VCP_IFACE, (const uint8_t *)str, len, VCP_WRITE_TIMEOUT);
|
2017-03-08 12:43:24 +00:00
|
|
|
}
|