Skip to content
Snippets Groups Projects
Commit 207657e3 authored by schneider's avatar schneider
Browse files

fix(usbcdc): Re-enable after lockup when attached again

When opening an ACM device Linux sends the ACM_SET_CONTROL_LINE_STATE
with DTR and CTS high. We can use this re-enable the ACM device on our
side after a lockup.
parent 4e81cb87
No related branches found
No related tags found
1 merge request!383fix(usbcdc): Re-enable after lockup when attached again
Pipeline #4569 passed
...@@ -22,6 +22,8 @@ ...@@ -22,6 +22,8 @@
#include "FreeRTOS.h" #include "FreeRTOS.h"
#include "task.h" #include "task.h"
static volatile int lockup_disable = 0;
static inline struct config_descriptor_cdcacm * static inline struct config_descriptor_cdcacm *
descriptors(struct esb_config *self) descriptors(struct esb_config *self)
{ {
...@@ -36,15 +38,24 @@ static int cb_acm_read_ready(void) ...@@ -36,15 +38,24 @@ static int cb_acm_read_ready(void)
return 0; return 0;
} }
static int cb_acm_connected(void)
{
lockup_disable = 0;
return 0;
}
int esb_cdc_init(struct esb_config *self) int esb_cdc_init(struct esb_config *self)
{ {
LOG_DEBUG("cdcacm", "init"); LOG_DEBUG("cdcacm", "init");
struct config_descriptor_cdcacm *dsc = descriptors(self); struct config_descriptor_cdcacm *dsc = descriptors(self);
usb_read_complete = 0; usb_read_complete = 0;
int ret = acm_init(&dsc->comm_interface);
acm_register_callback( acm_register_callback(
ACM_CB_READ_READY, ACM_CB_READ_READY,
cb_acm_read_ready); //SWYM: actually not needed cb_acm_read_ready); //SWYM: actually not needed
return acm_init(&dsc->comm_interface); acm_register_callback(ACM_CB_CONNECTED, cb_acm_connected);
return ret;
} }
int esb_cdc_configure(struct esb_config *self) int esb_cdc_configure(struct esb_config *self)
...@@ -96,7 +107,6 @@ uint8_t cdcacm_read(void) ...@@ -96,7 +107,6 @@ uint8_t cdcacm_read(void)
void cdcacm_write(uint8_t *data, int len) void cdcacm_write(uint8_t *data, int len)
{ {
static int lockup_disable = 0;
if (acm_present() && !lockup_disable) { if (acm_present() && !lockup_disable) {
int ret = acm_write(data, len); int ret = acm_write(data, len);
if (ret < 0) { if (ret < 0) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment