This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
laforge gerrit-no-reply at lists.osmocom.orglaforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/20058 ) Change subject: usb: reset the device on usb reset if it was previously running ...................................................................... usb: reset the device on usb reset if it was previously running Usb init order is desc read -> reset-> set addr -> use device. DADD.ADDEN is automatically cleared upon receiving a reset from the host, at least according to the SAMD51 manual, but DADD.DADD is zero as well (?) so it can't be used to check if usb was previously running and the cable was pulled out and plugged in again while the device was externally powered. This works around this and ensures a device reset from the host leads to a proper device restart and reinitialization in this case, there is no state we want to keep in this case anyway. Change-Id: I692de3dd98cfc30a010b457be87331e482632fb7 Closes: SYS#4908 --- M sysmoOCTSIM/hpl/usb/hpl_usb.c 1 file changed, 17 insertions(+), 0 deletions(-) Approvals: Jenkins Builder: Verified laforge: Looks good to me, approved diff --git a/sysmoOCTSIM/hpl/usb/hpl_usb.c b/sysmoOCTSIM/hpl/usb/hpl_usb.c index eec9728..99e4606 100644 --- a/sysmoOCTSIM/hpl/usb/hpl_usb.c +++ b/sysmoOCTSIM/hpl/usb/hpl_usb.c @@ -39,6 +39,11 @@ #include <hpl_usb_config.h> #include <string.h> #include <utils_assert.h> +#include <hal_delay.h> + +/* save previous setup state to allow device reset when receving usb reset after the device + * was previously properly configured, i.e. when powered externally and usb is disconnected and reconnected */ +volatile bool address_was_set = false; /** * \brief Dummy callback function @@ -974,6 +979,17 @@ hri_usbdevice_set_INTEN_reg(USB, USB_D_SUSPEND_INT_FLAGS); _usb_d_dev_reset_epts(); + + if(address_was_set == true) { + _usb_d_dev_detach(); + address_was_set = 0; + delay_ms(100); + __disable_irq(); + __DMB(); + __DSB(); + NVIC_SystemReset(); + } + dev_inst.callbacks.event(USB_EV_RESET, 0); } @@ -1579,6 +1595,7 @@ void _usb_d_dev_set_address(uint8_t addr) { hri_usbdevice_write_DADD_reg(USB, USB_DEVICE_DADD_ADDEN | USB_DEVICE_DADD_DADD(addr)); + address_was_set = true; } uint8_t _usb_d_dev_get_address(void) -- To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/20058 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-ccid-firmware Gerrit-Branch: master Gerrit-Change-Id: I692de3dd98cfc30a010b457be87331e482632fb7 Gerrit-Change-Number: 20058 Gerrit-PatchSet: 1 Gerrit-Owner: Hoernchen <ewild at sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge at osmocom.org> Gerrit-MessageType: merged -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200910/0bf89c7f/attachment.htm>