atmel-samd: Only output to USB after DTR and don't send anything larger than the room left in the USB TX buffer.
This commit is contained in:
parent
b7768a74a7
commit
614c1fdba2
atmel-samd
@ -54,8 +54,10 @@ extern void mp_cdc_disable(uint8_t port);
|
|||||||
#define UDI_CDC_RX_NOTIFY(port) usb_rx_notify()
|
#define UDI_CDC_RX_NOTIFY(port) usb_rx_notify()
|
||||||
void usb_rx_notify(void);
|
void usb_rx_notify(void);
|
||||||
#define UDI_CDC_SET_CODING_EXT(port,cfg)
|
#define UDI_CDC_SET_CODING_EXT(port,cfg)
|
||||||
#define UDI_CDC_SET_DTR_EXT(port,set)
|
#define UDI_CDC_SET_DTR_EXT(port,set) usb_dtr_notify(port, set)
|
||||||
#define UDI_CDC_SET_RTS_EXT(port,set)
|
void usb_dtr_notify(uint8_t port, bool set);
|
||||||
|
#define UDI_CDC_SET_RTS_EXT(port,set) usb_rts_notify(port, set)
|
||||||
|
void usb_rts_notify(uint8_t port, bool set);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* USB CDC low level configuration
|
* USB CDC low level configuration
|
||||||
|
@ -50,7 +50,7 @@ void mp_msc_disable()
|
|||||||
|
|
||||||
bool mp_cdc_enable(uint8_t port)
|
bool mp_cdc_enable(uint8_t port)
|
||||||
{
|
{
|
||||||
mp_cdc_enabled = true;
|
mp_cdc_enabled = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,6 +59,14 @@ void mp_cdc_disable(uint8_t port)
|
|||||||
mp_cdc_enabled = false;
|
mp_cdc_enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void usb_dtr_notify(uint8_t port, bool set) {
|
||||||
|
mp_cdc_enabled = set;
|
||||||
|
}
|
||||||
|
|
||||||
|
void usb_rts_notify(uint8_t port, bool set) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
void usb_rx_notify(void)
|
void usb_rx_notify(void)
|
||||||
{
|
{
|
||||||
irqflags_t flags;
|
irqflags_t flags;
|
||||||
@ -177,7 +185,10 @@ void mp_hal_stdout_tx_strn(const char *str, size_t len) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USB_REPL
|
#ifdef USB_REPL
|
||||||
if (mp_cdc_enabled && udi_cdc_is_tx_ready()) {
|
// Always make sure there is enough room in the usb buffer for the outgoing
|
||||||
|
// string. If there isn't we risk getting caught in a loop within the usb
|
||||||
|
// code as it tries to send all the characters it can't buffer.
|
||||||
|
if (mp_cdc_enabled && udi_cdc_get_free_tx_buffer() >= len) {
|
||||||
udi_cdc_write_buf(str, len);
|
udi_cdc_write_buf(str, len);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user