From dbaa1b87001d7c0c1e7970b66304011e7538c457 Mon Sep 17 00:00:00 2001 From: Diego Ismirlian Date: Sun, 19 Nov 2017 21:20:57 -0300 Subject: USBH: AOA: Various improvements --- os/hal/src/usbh/hal_usbh_aoa.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) (limited to 'os/hal/src/usbh') diff --git a/os/hal/src/usbh/hal_usbh_aoa.c b/os/hal/src/usbh/hal_usbh_aoa.c index 85c3130..cb3fd18 100644 --- a/os/hal/src/usbh/hal_usbh_aoa.c +++ b/os/hal/src/usbh/hal_usbh_aoa.c @@ -161,6 +161,11 @@ static usbh_baseclassdriver_t *_aoa_load(usbh_device_t *dev, const uint8_t *desc } }; + if (descriptor[1] != USBH_DT_DEVICE) { + uinfo("AOA: Won't try to detect Android device at interface level"); + return NULL; + } + uinfo("AOA: Unrecognized VID"); #if defined(HAL_USBHAOA_FILTER_CALLBACK) @@ -171,6 +176,7 @@ static usbh_baseclassdriver_t *_aoa_load(usbh_device_t *dev, const uint8_t *desc uinfo("AOA: Try if it's an Android device"); if (_get_protocol(dev, &protocol) != HAL_SUCCESS) { + uinfo("AOA: not an Android device"); return NULL; } uinfof("AOA: Possible Android device found (protocol=%d)", protocol); @@ -196,6 +202,8 @@ static usbh_baseclassdriver_t *_aoa_load(usbh_device_t *dev, const uint8_t *desc if (_accessory_start(dev) != HAL_SUCCESS) { uerr("AOA: Can't start accessory; abort channel start"); + } else { + uinfo("AOA: Accessory started"); } return NULL; @@ -320,7 +328,7 @@ static void _out_cb(usbh_urb_t *urb) { return; case USBH_URBSTATUS_DISCONNECTED: uwarn("AOA: URB OUT disconnected"); - chThdDequeueNextI(&aoacp->oq_waiting, Q_RESET); + chThdDequeueAllI(&aoacp->oq_waiting, Q_RESET); chnAddFlagsI(aoacp, CHN_OUTPUT_EMPTY); return; default: @@ -419,7 +427,10 @@ static void _in_cb(usbh_urb_t *urb) { break; case USBH_URBSTATUS_DISCONNECTED: uwarn("AOA: URB IN disconnected"); - chThdDequeueNextI(&aoacp->iq_waiting, Q_RESET); + chThdDequeueAllI(&aoacp->iq_waiting, Q_RESET); + chnAddFlagsI(aoacp, CHN_DISCONNECTED); + aoacp->state = USBHAOA_CHANNEL_STATE_ACTIVE; + container_of(aoacp, USBHAOADriver, channel)->state = USBHAOA_STATE_ACTIVE; break; default: uerrf("AOA: URB IN status unexpected = %d", urb->status); @@ -526,14 +537,16 @@ static void _stop_channelS(USBHAOAChannel *aoacp) { static void _vt(void *p) { USBHAOAChannel *const aoacp = (USBHAOAChannel *)p; osalSysLockFromISR(); - uint32_t len = aoacp->oq_ptr - aoacp->oq_buff; - if (len && !usbhURBIsBusy(&aoacp->oq_urb)) { - _submitOutI(aoacp, len); - } - if ((aoacp->iq_counter == 0) && !usbhURBIsBusy(&aoacp->iq_urb)) { - _submitInI(aoacp); + if (aoacp->state == USBHAOA_CHANNEL_STATE_READY) { + uint32_t len = aoacp->oq_ptr - aoacp->oq_buff; + if (len && !usbhURBIsBusy(&aoacp->oq_urb)) { + _submitOutI(aoacp, len); + } + if ((aoacp->iq_counter == 0) && !usbhURBIsBusy(&aoacp->iq_urb)) { + _submitInI(aoacp); + } + chVTSetI(&aoacp->vt, MS2ST(16), _vt, aoacp); } - chVTSetI(&aoacp->vt, MS2ST(16), _vt, aoacp); osalSysUnlockFromISR(); } -- cgit v1.2.3 From 03615f40dc3d1cbb5354035c326963b49759f440 Mon Sep 17 00:00:00 2001 From: Diego Ismirlian Date: Mon, 4 Dec 2017 13:11:16 -0300 Subject: USBH: debug improvements --- os/hal/src/usbh/hal_usbh_debug.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'os/hal/src/usbh') diff --git a/os/hal/src/usbh/hal_usbh_debug.c b/os/hal/src/usbh/hal_usbh_debug.c index d32f1c6..85c6640 100644 --- a/os/hal/src/usbh/hal_usbh_debug.c +++ b/os/hal/src/usbh/hal_usbh_debug.c @@ -22,7 +22,13 @@ #include "ch.h" #include "usbh/debug.h" #include +#if 0 +#include "debug.h" +#else #include "chprintf.h" +#define dbg_lock() +#define dbg_unlock() +#endif #define MAX_FILLER 11 #define FLOAT_PRECISION 9 @@ -393,6 +399,9 @@ void usbDbgPrintf(const char *fmt, ...) chThdDequeueNextI(&USBH_DEBUG_USBHD.iq.q_waiting, Q_OK); } chSysRestoreStatusX(sts); + if (!port_is_isr_context() && chSchIsPreemptionRequired()) { + chSchRescheduleS(); + } va_end(ap); } @@ -422,6 +431,9 @@ void usbDbgPuts(const char *s) chThdDequeueNextI(&USBH_DEBUG_USBHD.iq.q_waiting, Q_OK); } chSysRestoreStatusX(sts); + if (!port_is_isr_context() && chSchIsPreemptionRequired()) { + chSchRescheduleS(); + } } void usbDbgReset(void) { @@ -435,6 +447,9 @@ void usbDbgReset(void) { USBH_DEBUG_SD.oqueue.q_counter--; } chSysRestoreStatusX(sts); + if (!port_is_isr_context() && chSchIsPreemptionRequired()) { + chSchRescheduleS(); + } } static int _get(void) { @@ -527,6 +542,7 @@ static void usb_debug_thread(void *arg) { uint32_t f = hfnum & 0xffff; uint32_t p = 1000 - ((hfnum >> 16) / (hfir / 1000)); + dbg_lock(); chprintf((BaseSequentialStream *)&USBH_DEBUG_SD, "%05d.%03d ", f, p); state = 4; } else if (state == 3) { @@ -543,6 +559,7 @@ static void usb_debug_thread(void *arg) { c = iqGet(&host->iq); if (c < 0) goto reset; t |= c << 24; + dbg_lock(); chprintf((BaseSequentialStream *)&USBH_DEBUG_SD, "+%08d ", t); state = 4; } else { @@ -550,8 +567,7 @@ static void usb_debug_thread(void *arg) { if (!c) { sdPut(&USBH_DEBUG_SD, '\r'); sdPut(&USBH_DEBUG_SD, '\n'); - state = 0; - break; + goto reset; } sdPut(&USBH_DEBUG_SD, (uint8_t)c); c = iqGet(&host->iq); if (c < 0) goto reset; @@ -560,6 +576,9 @@ static void usb_debug_thread(void *arg) { continue; reset: + if (state == 4) { + dbg_unlock(); + } state = 0; } } -- cgit v1.2.3 From 2a9d939d72a8c22d248450107b26e25506d42160 Mon Sep 17 00:00:00 2001 From: Paul Roukema Date: Sun, 5 Aug 2018 23:59:06 -0400 Subject: Fix incompatible USBH VMTs --- os/hal/src/usbh/hal_usbh_aoa.c | 4 +++- os/hal/src/usbh/hal_usbh_ftdi.c | 5 ++++- os/hal/src/usbh/hal_usbh_msd.c | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) (limited to 'os/hal/src/usbh') diff --git a/os/hal/src/usbh/hal_usbh_aoa.c b/os/hal/src/usbh/hal_usbh_aoa.c index d565595..c2a7646 100644 --- a/os/hal/src/usbh/hal_usbh_aoa.c +++ b/os/hal/src/usbh/hal_usbh_aoa.c @@ -499,6 +499,7 @@ static size_t _read(USBHAOAChannel *aoacp, uint8_t *bp, size_t n) { } static const struct AOADriverVMT async_channel_vmt = { + (size_t) 0, (size_t (*)(void *, const uint8_t *, size_t))_write, (size_t (*)(void *, uint8_t *, size_t))_read, (msg_t (*)(void *, uint8_t))_put, @@ -506,7 +507,8 @@ static const struct AOADriverVMT async_channel_vmt = { (msg_t (*)(void *, uint8_t, systime_t))_put_timeout, (msg_t (*)(void *, systime_t))_get_timeout, (size_t (*)(void *, const uint8_t *, size_t, systime_t))_write_timeout, - (size_t (*)(void *, uint8_t *, size_t, systime_t))_read_timeout + (size_t (*)(void *, uint8_t *, size_t, systime_t))_read_timeout, + (void*) 0 // FIXME: Implement CTL }; static void _stop_channelS(USBHAOAChannel *aoacp) { diff --git a/os/hal/src/usbh/hal_usbh_ftdi.c b/os/hal/src/usbh/hal_usbh_ftdi.c index 6966028..070dbcf 100644 --- a/os/hal/src/usbh/hal_usbh_ftdi.c +++ b/os/hal/src/usbh/hal_usbh_ftdi.c @@ -150,6 +150,7 @@ alloc_ok: case 0x900: //232H; uinfo("FTDI: Type H chip"); ftdip->type = USBHFTDI_TYPE_H; + break; default: uerr("FTDI: Unrecognized chip type"); return NULL; @@ -615,6 +616,7 @@ static void _vt(void *p) { } static const struct FTDIPortDriverVMT async_channel_vmt = { + (size_t) 0, (size_t (*)(void *, const uint8_t *, size_t))_write, (size_t (*)(void *, uint8_t *, size_t))_read, (msg_t (*)(void *, uint8_t))_put, @@ -622,7 +624,8 @@ static const struct FTDIPortDriverVMT async_channel_vmt = { (msg_t (*)(void *, uint8_t, systime_t))_put_timeout, (msg_t (*)(void *, systime_t))_get_timeout, (size_t (*)(void *, const uint8_t *, size_t, systime_t))_write_timeout, - (size_t (*)(void *, uint8_t *, size_t, systime_t))_read_timeout + (size_t (*)(void *, uint8_t *, size_t, systime_t))_read_timeout, + (void*) 0 // FIXME: Implement CTL }; diff --git a/os/hal/src/usbh/hal_usbh_msd.c b/os/hal/src/usbh/hal_usbh_msd.c index 7233a0b..fe97ff0 100644 --- a/os/hal/src/usbh/hal_usbh_msd.c +++ b/os/hal/src/usbh/hal_usbh_msd.c @@ -683,6 +683,7 @@ static msd_result_t scsi_write10(USBHMassStorageLUNDriver *lunp, uint32_t lba, u USBHMassStorageLUNDriver MSBLKD[HAL_USBHMSD_MAX_LUNS]; static const struct USBHMassStorageDriverVMT blk_vmt = { + (size_t)0, (bool (*)(void *))usbhmsdLUNIsInserted, (bool (*)(void *))usbhmsdLUNIsProtected, (bool (*)(void *))usbhmsdLUNConnect, -- cgit v1.2.3 From eb10a7d52faa133a699d859322246f654ccd9042 Mon Sep 17 00:00:00 2001 From: Diego Ismirlian Date: Sun, 29 Sep 2019 19:31:05 -0300 Subject: Update copyright --- os/hal/src/usbh/hal_usbh_aoa.c | 2 +- os/hal/src/usbh/hal_usbh_debug.c | 2 +- os/hal/src/usbh/hal_usbh_desciter.c | 2 +- os/hal/src/usbh/hal_usbh_ftdi.c | 2 +- os/hal/src/usbh/hal_usbh_hid.c | 2 +- os/hal/src/usbh/hal_usbh_hub.c | 2 +- os/hal/src/usbh/hal_usbh_msd.c | 2 +- os/hal/src/usbh/hal_usbh_uvc.c | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) (limited to 'os/hal/src/usbh') diff --git a/os/hal/src/usbh/hal_usbh_aoa.c b/os/hal/src/usbh/hal_usbh_aoa.c index 4e1d65d..0686179 100644 --- a/os/hal/src/usbh/hal_usbh_aoa.c +++ b/os/hal/src/usbh/hal_usbh_aoa.c @@ -1,6 +1,6 @@ /* ChibiOS - Copyright (C) 2006..2017 Giovanni Di Sirio - Copyright (C) 2015..2017 Diego Ismirlian, (dismirlian (at) google's mail) + Copyright (C) 2015..2019 Diego Ismirlian, (dismirlian(at)google's mail) Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/os/hal/src/usbh/hal_usbh_debug.c b/os/hal/src/usbh/hal_usbh_debug.c index 85c6640..57df535 100644 --- a/os/hal/src/usbh/hal_usbh_debug.c +++ b/os/hal/src/usbh/hal_usbh_debug.c @@ -1,6 +1,6 @@ /* ChibiOS - Copyright (C) 2006..2017 Giovanni Di Sirio - Copyright (C) 2015..2017 Diego Ismirlian, (dismirlian (at) google's mail) + Copyright (C) 2015..2019 Diego Ismirlian, (dismirlian(at)google's mail) Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/os/hal/src/usbh/hal_usbh_desciter.c b/os/hal/src/usbh/hal_usbh_desciter.c index 3695881..cfce62b 100644 --- a/os/hal/src/usbh/hal_usbh_desciter.c +++ b/os/hal/src/usbh/hal_usbh_desciter.c @@ -1,6 +1,6 @@ /* ChibiOS - Copyright (C) 2006..2017 Giovanni Di Sirio - Copyright (C) 2015..2017 Diego Ismirlian, (dismirlian (at) google's mail) + Copyright (C) 2015..2019 Diego Ismirlian, (dismirlian(at)google's mail) Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/os/hal/src/usbh/hal_usbh_ftdi.c b/os/hal/src/usbh/hal_usbh_ftdi.c index b262256..b4b03df 100644 --- a/os/hal/src/usbh/hal_usbh_ftdi.c +++ b/os/hal/src/usbh/hal_usbh_ftdi.c @@ -1,6 +1,6 @@ /* ChibiOS - Copyright (C) 2006..2017 Giovanni Di Sirio - Copyright (C) 2015..2017 Diego Ismirlian, (dismirlian (at) google's mail) + Copyright (C) 2015..2019 Diego Ismirlian, (dismirlian(at)google's mail) Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/os/hal/src/usbh/hal_usbh_hid.c b/os/hal/src/usbh/hal_usbh_hid.c index 2b2c5ce..a34325b 100644 --- a/os/hal/src/usbh/hal_usbh_hid.c +++ b/os/hal/src/usbh/hal_usbh_hid.c @@ -1,6 +1,6 @@ /* ChibiOS - Copyright (C) 2006..2017 Giovanni Di Sirio - Copyright (C) 2015..2017 Diego Ismirlian, (dismirlian (at) google's mail) + Copyright (C) 2015..2019 Diego Ismirlian, (dismirlian(at)google's mail) Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/os/hal/src/usbh/hal_usbh_hub.c b/os/hal/src/usbh/hal_usbh_hub.c index 6a83c66..900c6f8 100644 --- a/os/hal/src/usbh/hal_usbh_hub.c +++ b/os/hal/src/usbh/hal_usbh_hub.c @@ -1,6 +1,6 @@ /* ChibiOS - Copyright (C) 2006..2017 Giovanni Di Sirio - Copyright (C) 2015..2017 Diego Ismirlian, (dismirlian (at) google's mail) + Copyright (C) 2015..2019 Diego Ismirlian, (dismirlian(at)google's mail) Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/os/hal/src/usbh/hal_usbh_msd.c b/os/hal/src/usbh/hal_usbh_msd.c index 3d57934..230bf9a 100644 --- a/os/hal/src/usbh/hal_usbh_msd.c +++ b/os/hal/src/usbh/hal_usbh_msd.c @@ -1,6 +1,6 @@ /* ChibiOS - Copyright (C) 2006..2017 Giovanni Di Sirio - Copyright (C) 2015..2017 Diego Ismirlian, (dismirlian (at) google's mail) + Copyright (C) 2015..2019 Diego Ismirlian, (dismirlian(at)google's mail) Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/os/hal/src/usbh/hal_usbh_uvc.c b/os/hal/src/usbh/hal_usbh_uvc.c index a795cd8..ca16c66 100644 --- a/os/hal/src/usbh/hal_usbh_uvc.c +++ b/os/hal/src/usbh/hal_usbh_uvc.c @@ -1,6 +1,6 @@ /* ChibiOS - Copyright (C) 2006..2017 Giovanni Di Sirio - Copyright (C) 2015..2017 Diego Ismirlian, (dismirlian (at) google's mail) + Copyright (C) 2015..2019 Diego Ismirlian, (dismirlian(at)google's mail) Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. -- cgit v1.2.3