diff options
36 files changed, 486 insertions, 103 deletions
diff --git a/os/hal/include/hal_usbh.h b/os/hal/include/hal_usbh.h index 1ed6416..aa49205 100644 --- a/os/hal/include/hal_usbh.h +++ b/os/hal/include/hal_usbh.h @@ -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. @@ -52,7 +52,9 @@ #define HAL_USBH_USE_ADDITIONAL_CLASS_DRIVERS FALSE #endif +#ifndef HAL_USBH_USE_IAD #define HAL_USBH_USE_IAD HAL_USBH_USE_UVC +#endif #if (HAL_USE_USBH == TRUE) || defined(__DOXYGEN__) @@ -299,11 +301,22 @@ extern "C" { } /* Synchronous API */ - usbh_urbstatus_t usbhBulkTransfer(usbh_ep_t *ep, + usbh_urbstatus_t usbhSynchronousTransfer(usbh_ep_t *ep, void *data, uint32_t len, uint32_t *actual_len, systime_t timeout); + + static inline usbh_urbstatus_t usbhBulkTransfer(usbh_ep_t *ep, + void *data, + uint32_t len, + uint32_t *actual_len, + systime_t timeout) { + osalDbgAssert(ep->type == USBH_EPTYPE_BULK, "wrong ep"); + + return usbhSynchronousTransfer(ep, data, len, actual_len, timeout); + } + usbh_urbstatus_t usbhControlRequest(usbh_device_t *dev, uint8_t bmRequestType, uint8_t bRequest, diff --git a/os/hal/include/usbh/debug.h b/os/hal/include/usbh/debug.h index d3bdee7..41319b9 100644 --- a/os/hal/include/usbh/debug.h +++ b/os/hal/include/usbh/debug.h @@ -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/include/usbh/defs.h b/os/hal/include/usbh/defs.h index 5e0c466..eb06192 100644 --- a/os/hal/include/usbh/defs.h +++ b/os/hal/include/usbh/defs.h @@ -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/include/usbh/desciter.h b/os/hal/include/usbh/desciter.h index 142bd3c..0223101 100644 --- a/os/hal/include/usbh/desciter.h +++ b/os/hal/include/usbh/desciter.h @@ -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/include/usbh/dev/aoa.h b/os/hal/include/usbh/dev/aoa.h index a7f1c1b..8205dd5 100644 --- a/os/hal/include/usbh/dev/aoa.h +++ b/os/hal/include/usbh/dev/aoa.h @@ -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/include/usbh/dev/ftdi.h b/os/hal/include/usbh/dev/ftdi.h index eedb056..84ea4bc 100644 --- a/os/hal/include/usbh/dev/ftdi.h +++ b/os/hal/include/usbh/dev/ftdi.h @@ -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/include/usbh/dev/hid.h b/os/hal/include/usbh/dev/hid.h index c7371ee..de001ab 100644 --- a/os/hal/include/usbh/dev/hid.h +++ b/os/hal/include/usbh/dev/hid.h @@ -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/include/usbh/dev/hub.h b/os/hal/include/usbh/dev/hub.h index 406fbaf..05a7b4f 100644 --- a/os/hal/include/usbh/dev/hub.h +++ b/os/hal/include/usbh/dev/hub.h @@ -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/include/usbh/dev/msd.h b/os/hal/include/usbh/dev/msd.h index eedd474..b245bfc 100644 --- a/os/hal/include/usbh/dev/msd.h +++ b/os/hal/include/usbh/dev/msd.h @@ -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/include/usbh/dev/uvc.h b/os/hal/include/usbh/dev/uvc.h index 0477312..713d16c 100644 --- a/os/hal/include/usbh/dev/uvc.h +++ b/os/hal/include/usbh/dev/uvc.h @@ -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/include/usbh/internal.h b/os/hal/include/usbh/internal.h index f6f17b7..2473775 100644 --- a/os/hal/include/usbh/internal.h +++ b/os/hal/include/usbh/internal.h @@ -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/ports/STM32/LLD/USBHv1/hal_usbh_lld.c b/os/hal/ports/STM32/LLD/USBHv1/hal_usbh_lld.c index 192b008..787a831 100644 --- a/os/hal/ports/STM32/LLD/USBHv1/hal_usbh_lld.c +++ b/os/hal/ports/STM32/LLD/USBHv1/hal_usbh_lld.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/ports/STM32/LLD/USBHv1/hal_usbh_lld.h b/os/hal/ports/STM32/LLD/USBHv1/hal_usbh_lld.h index fd7f4e0..bb92ede 100644 --- a/os/hal/ports/STM32/LLD/USBHv1/hal_usbh_lld.h +++ b/os/hal/ports/STM32/LLD/USBHv1/hal_usbh_lld.h @@ -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/hal_usbh.c b/os/hal/src/hal_usbh.c index 7dff98a..feaf956 100644 --- a/os/hal/src/hal_usbh.c +++ b/os/hal/src/hal_usbh.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. @@ -302,6 +302,7 @@ msg_t usbhURBSubmitAndWaitS(usbh_urb_t *urb, systime_t timeout) { _check_urb(urb); usbhURBSubmitI(urb); + osalOsRescheduleS(); /* This call is necessary because usbhURBSubmitI may require a reschedule */ ret = usbhURBWaitTimeoutS(urb, timeout); if (ret == MSG_TIMEOUT) _usbh_urb_abort_and_waitS(urb, USBH_URBSTATUS_TIMEOUT); @@ -330,7 +331,7 @@ void _usbh_urb_completeI(usbh_urb_t *urb, usbh_urbstatus_t status) { /* Synchronous API. */ /*===========================================================================*/ -usbh_urbstatus_t usbhBulkTransfer(usbh_ep_t *ep, +usbh_urbstatus_t usbhSynchronousTransfer(usbh_ep_t *ep, void *data, uint32_t len, uint32_t *actual_len, @@ -338,7 +339,6 @@ usbh_urbstatus_t usbhBulkTransfer(usbh_ep_t *ep, osalDbgCheck(ep != NULL); osalDbgCheck((data != NULL) || (len == 0)); - osalDbgAssert(ep->type == USBH_EPTYPE_BULK, "wrong ep"); usbh_urb_t urb; usbhURBObjectInit(&urb, ep, 0, 0, data, len); @@ -860,9 +860,7 @@ static void _port_process_status_change(usbh_port_t *port) { usbhhubClearFeaturePort(port, USBH_PORT_FEAT_C_CONNECTION); if (port->device.status != USBH_DEVSTATUS_DISCONNECTED) { - if (!(port->status & USBH_PORTSTATUS_CONNECTION)) { - _usbh_port_disconnected(port); - } + _usbh_port_disconnected(port); } } diff --git a/os/hal/src/usbh/hal_usbh_aoa.c b/os/hal/src/usbh/hal_usbh_aoa.c index 1447bdb..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. @@ -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); @@ -535,14 +546,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, OSAL_MS2I(16), _vt, aoacp); } - chVTSetI(&aoacp->vt, OSAL_MS2I(16), _vt, aoacp); osalSysUnlockFromISR(); } diff --git a/os/hal/src/usbh/hal_usbh_debug.c b/os/hal/src/usbh/hal_usbh_debug.c index d32f1c6..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. @@ -22,7 +22,13 @@ #include "ch.h" #include "usbh/debug.h" #include <stdarg.h> +#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; } } 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 7bd8f2d..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. @@ -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; 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. diff --git a/os/various/fatfs_bindings/fatfs_devices.h b/os/various/fatfs_bindings/fatfs_devices.h new file mode 100644 index 0000000..cd1ad2f --- /dev/null +++ b/os/various/fatfs_bindings/fatfs_devices.h @@ -0,0 +1,41 @@ +/* + ChibiOS - Copyright (C) 2006..2017 Giovanni Di Sirio + 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. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#ifndef FATFS_DEVICES_H_ +#define FATFS_DEVICES_H_ + +#include "hal.h" + +/*-----------------------------------------------------------------------*/ +/* Correspondence between physical drive number and physical drive. */ +#if HAL_USE_MMC_SPI || HAL_USE_SDC +#define FATFSDEV_MMC 0 +#define FATFSDEV_MMC_DRIVE "0:" +#endif + + +#if HAL_USBH_USE_MSD +#if defined(FATFSDEV_MMC) +#define FATFSDEV_MSD 1 +#define FATFSDEV_MSD_DRIVE "1:" +#else +#define FATFSDEV_MSD 0 +#define FATFSDEV_MSD_DRIVE "0:" +#endif +#endif + +#endif /* FATFS_DEVICES_H_ */ diff --git a/os/various/fatfs_bindings/fatfs_diskio.c b/os/various/fatfs_bindings/fatfs_diskio.c index 7f510a0..e3cfd53 100644 --- a/os/various/fatfs_bindings/fatfs_diskio.c +++ b/os/various/fatfs_bindings/fatfs_diskio.c @@ -7,17 +7,19 @@ #include "hal.h" #include "ffconf.h" +#include "ff.h" #include "diskio.h" #include "usbh/dev/msd.h" +#include "fatfs_devices.h" #if HAL_USE_MMC_SPI && HAL_USE_SDC -#error "cannot specify both MMC_SPI and SDC drivers" +#error "cannot specify both MMC_SPI and FATFSDEV_MMC drivers" #endif // sanity check for no FAT option selected // why is the FAT sources being pulled into the build? #if !HAL_USE_MMC_SPI && !HAL_USE_SDC & !HAL_USBH_USE_MSD -#error "MMC_SPI, SDC or USBH_MSD driver must be specified. None was." +#error "MMC_SPI, FATFSDEV_MMC or USBH_MSD driver must be specified. None was." #endif #if !defined(FATFS_HAL_DEVICE) @@ -41,24 +43,6 @@ extern SDCDriver FATFS_HAL_DEVICE; extern RTCDriver RTCD1; #endif -/*-----------------------------------------------------------------------*/ -/* Correspondence between physical drive number and physical drive. */ -#if HAL_USE_MMC_SPI -#define MMC 0 -#endif - -#if HAL_USE_SDC -#define SDC 0 -#endif - -#if HAL_USBH_USE_MSD -#if defined(MMC) || defined(SDC) -#define MSDLUN0 1 -#else -#define MSDLUN0 0 -#endif -#endif - /*-----------------------------------------------------------------------*/ /* Inidialize a Drive */ @@ -71,7 +55,7 @@ DSTATUS disk_initialize ( switch (pdrv) { #if HAL_USE_MMC_SPI - case MMC: + case FATFSDEV_MMC: stat = 0; /* It is initialized externally, just reads the status.*/ if (blkGetDriverState(&FATFS_HAL_DEVICE) != BLK_READY) @@ -80,7 +64,7 @@ DSTATUS disk_initialize ( stat |= STA_PROTECT; return stat; #elif HAL_USE_SDC - case SDC: + case FATFSDEV_MMC: stat = 0; /* It is initialized externally, just reads the status.*/ if (blkGetDriverState(&FATFS_HAL_DEVICE) != BLK_READY) @@ -90,7 +74,7 @@ DSTATUS disk_initialize ( return stat; #endif #if HAL_USBH_USE_MSD - case MSDLUN0: + case FATFSDEV_MSD: stat = 0; /* It is initialized externally, just reads the status.*/ if (blkGetDriverState(&MSBLKD[0]) != BLK_READY) @@ -114,7 +98,7 @@ DSTATUS disk_status ( switch (pdrv) { #if HAL_USE_MMC_SPI - case MMC: + case FATFSDEV_MMC: stat = 0; /* It is initialized externally, just reads the status.*/ if (blkGetDriverState(&FATFS_HAL_DEVICE) != BLK_READY) @@ -123,7 +107,7 @@ DSTATUS disk_status ( stat |= STA_PROTECT; return stat; #elif HAL_USE_SDC - case SDC: + case FATFSDEV_MMC: stat = 0; /* It is initialized externally, just reads the status.*/ if (blkGetDriverState(&FATFS_HAL_DEVICE) != BLK_READY) @@ -133,7 +117,7 @@ DSTATUS disk_status ( return stat; #endif #if HAL_USBH_USE_MSD - case MSDLUN0: + case FATFSDEV_MSD: stat = 0; /* It is initialized externally, just reads the status.*/ if (blkGetDriverState(&MSBLKD[0]) != BLK_READY) @@ -158,7 +142,7 @@ DRESULT disk_read ( { switch (pdrv) { #if HAL_USE_MMC_SPI - case MMC: + case FATFSDEV_MMC: if (blkGetDriverState(&FATFS_HAL_DEVICE) != BLK_READY) return RES_NOTRDY; if (mmcStartSequentialRead(&FATFS_HAL_DEVICE, sector)) @@ -173,7 +157,7 @@ DRESULT disk_read ( return RES_ERROR; return RES_OK; #elif HAL_USE_SDC - case SDC: + case FATFSDEV_MMC: if (blkGetDriverState(&FATFS_HAL_DEVICE) != BLK_READY) return RES_NOTRDY; if (sdcRead(&FATFS_HAL_DEVICE, sector, buff, count)) @@ -181,7 +165,7 @@ DRESULT disk_read ( return RES_OK; #endif #if HAL_USBH_USE_MSD - case MSDLUN0: + case FATFSDEV_MSD: /* It is initialized externally, just reads the status.*/ if (blkGetDriverState(&MSBLKD[0]) != BLK_READY) return RES_NOTRDY; @@ -209,7 +193,7 @@ DRESULT disk_write ( switch (pdrv) { #if HAL_USE_MMC_SPI - case MMC: + case FATFSDEV_MMC: if (blkGetDriverState(&FATFS_HAL_DEVICE) != BLK_READY) return RES_NOTRDY; if (mmcIsWriteProtected(&FATFS_HAL_DEVICE)) @@ -218,19 +202,19 @@ DRESULT disk_write ( return RES_ERROR; while (count > 0) { - // invalidate cache on buffer - cacheBufferFlush(buff, MMCSD_BLOCK_SIZE); + // invalidate cache on buffer + cacheBufferFlush(buff, MMCSD_BLOCK_SIZE); - if (mmcSequentialWrite(&FATFS_HAL_DEVICE, buff)) - return RES_ERROR; - buff += MMCSD_BLOCK_SIZE; - count--; + if (mmcSequentialWrite(&FATFS_HAL_DEVICE, buff)) + return RES_ERROR; + buff += MMCSD_BLOCK_SIZE; + count--; } if (mmcStopSequentialWrite(&FATFS_HAL_DEVICE)) return RES_ERROR; return RES_OK; #elif HAL_USE_SDC - case SDC: + case FATFSDEV_MMC: if (blkGetDriverState(&FATFS_HAL_DEVICE) != BLK_READY) return RES_NOTRDY; @@ -238,18 +222,18 @@ DRESULT disk_write ( cacheBufferFlush(buff, count * MMCSD_BLOCK_SIZE); if (sdcWrite(&FATFS_HAL_DEVICE, sector, buff, count)) - return RES_ERROR; + return RES_ERROR; return RES_OK; #endif #if HAL_USBH_USE_MSD - case MSDLUN0: + case FATFSDEV_MSD: /* It is initialized externally, just reads the status.*/ if (blkGetDriverState(&MSBLKD[0]) != BLK_READY) return RES_NOTRDY; - // invalidate cache on buffer - cacheBufferFlush(buff, count * MSBLKD[0].info.blk_size); + // invalidate cache on buffer + cacheBufferFlush(buff, count * MSBLKD[0].info.blk_size); if (usbhmsdLUNWrite(&MSBLKD[0], sector, buff, count)) return RES_ERROR; @@ -275,7 +259,7 @@ DRESULT disk_ioctl ( switch (pdrv) { #if HAL_USE_MMC_SPI - case MMC: + case FATFSDEV_MMC: switch (cmd) { case CTRL_SYNC: return RES_OK; @@ -293,7 +277,7 @@ DRESULT disk_ioctl ( return RES_PARERR; } #elif HAL_USE_SDC - case SDC: + case FATFSDEV_MMC: switch (cmd) { case CTRL_SYNC: return RES_OK; @@ -318,7 +302,7 @@ DRESULT disk_ioctl ( } #endif #if HAL_USBH_USE_MSD - case MSDLUN0: + case FATFSDEV_MSD: switch (cmd) { case CTRL_SYNC: return RES_OK; diff --git a/testhal/STM32/STM32F4xx/USB_HOST/.cproject b/testhal/STM32/STM32F4xx/USB_HOST/.cproject index d733e39..8d56b51 100644 --- a/testhal/STM32/STM32F4xx/USB_HOST/.cproject +++ b/testhal/STM32/STM32F4xx/USB_HOST/.cproject @@ -14,7 +14,7 @@ </extensions> </storageModule> <storageModule moduleId="cdtBuildSystem" version="4.0.0"> - <configuration buildProperties="" description="" id="0.1003150841" name="Default" parent="org.eclipse.cdt.build.core.prefbase.cfg"> + <configuration buildProperties="" description="" id="0.1003150841" name="Default" optionalBuildProperties="" parent="org.eclipse.cdt.build.core.prefbase.cfg"> <folderInfo id="0.1003150841." name="/" resourcePath=""> <toolChain id="org.eclipse.cdt.build.core.prefbase.toolchain.748316353" name="No ToolChain" resourceTypeBasedDiscovery="false" superClass="org.eclipse.cdt.build.core.prefbase.toolchain"> <targetPlatform id="org.eclipse.cdt.build.core.prefbase.toolchain.748316353.81353447" name=""/> diff --git a/testhal/STM32/STM32F4xx/USB_HOST/.project b/testhal/STM32/STM32F4xx/USB_HOST/.project index 066a4d6..8db459b 100644 --- a/testhal/STM32/STM32F4xx/USB_HOST/.project +++ b/testhal/STM32/STM32F4xx/USB_HOST/.project @@ -31,9 +31,9 @@ <locationURI>$%7BPARENT-5-PROJECT_LOC%7D/ChibiOS-contrib/os</locationURI> </link> <link> - <name>ChibiOS-RT-os</name> + <name>ChibiOS-RT</name> <type>2</type> - <locationURI>$%7BPARENT-5-PROJECT_LOC%7D/ChibiOS-RT/os</locationURI> + <locationURI>$%7BPARENT-5-PROJECT_LOC%7D/ChibiOS</locationURI> </link> </linkedResources> </projectDescription> diff --git a/testhal/STM32/STM32F4xx/USB_HOST/.settings/org.eclipse.cdt.core.prefs b/testhal/STM32/STM32F4xx/USB_HOST/.settings/org.eclipse.cdt.core.prefs new file mode 100644 index 0000000..8ae48ef --- /dev/null +++ b/testhal/STM32/STM32F4xx/USB_HOST/.settings/org.eclipse.cdt.core.prefs @@ -0,0 +1,6 @@ +eclipse.preferences.version=1 +environment/project/0.1003150841/PATH/delimiter=; +environment/project/0.1003150841/PATH/operation=replace +environment/project/0.1003150841/PATH/value=${PATH};D\:\\toolchains\\gcc-arm-none-eabi-8-2018-q4-major-win32\\bin;${PATH};D\:\\toolchains\\gcc-arm-none-eabi-4_9-2014q4-20141203-win32\\bin;D\:\\toolchains\\msys64\\usr\\bin +environment/project/0.1003150841/append=true +environment/project/0.1003150841/appendContributed=true diff --git a/testhal/STM32/STM32F4xx/USB_HOST/SEGGER_RTT_Conf.h b/testhal/STM32/STM32F4xx/USB_HOST/SEGGER_RTT_Conf.h new file mode 100644 index 0000000..5aa7a69 --- /dev/null +++ b/testhal/STM32/STM32F4xx/USB_HOST/SEGGER_RTT_Conf.h @@ -0,0 +1,123 @@ +/********************************************************************* +* SEGGER Microcontroller GmbH * +* The Embedded Experts * +********************************************************************** +* * +* (c) 1995 - 2019 SEGGER Microcontroller GmbH * +* * +* www.segger.com Support: support@segger.com * +* * +********************************************************************** +* * +* SEGGER RTT * Real Time Transfer for embedded targets * +* * +********************************************************************** +* * +* All rights reserved. * +* * +* SEGGER strongly recommends to not make any changes * +* to or modify the source code of this software in order to stay * +* compatible with the RTT protocol and J-Link. * +* * +* Redistribution and use in source and binary forms, with or * +* without modification, are permitted provided that the following * +* conditions are met: * +* * +* o Redistributions of source code must retain the above copyright * +* notice, this list of conditions and the following disclaimer. * +* * +* o Redistributions in binary form must reproduce the above * +* copyright notice, this list of conditions and the following * +* disclaimer in the documentation and/or other materials provided * +* with the distribution. * +* * +* o Neither the name of SEGGER Microcontroller GmbH * +* nor the names of its contributors may be used to endorse or * +* promote products derived from this software without specific * +* prior written permission. * +* * +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * +* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * +* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * +* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR * +* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * +* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * +* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * +* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * +* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * +* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * +* DAMAGE. * +* * +********************************************************************** +* * +* RTT version: 6.44i * +* * +********************************************************************** +---------------------------END-OF-HEADER------------------------------ +File : SEGGER_RTT_Conf.h +Purpose : Implementation of SEGGER real-time transfer (RTT) which + allows real-time communication on targets which support + debugger memory accesses while the CPU is running. +Revision: $Rev: 13430 $ + +*/ + +#ifndef SEGGER_RTT_CONF_H +#define SEGGER_RTT_CONF_H + +#ifdef __IAR_SYSTEMS_ICC__ + #include <intrinsics.h> +#endif + +/********************************************************************* +* +* Defines, configurable +* +********************************************************************** +*/ + +#define SEGGER_RTT_MAX_NUM_UP_BUFFERS (2) // Max. number of up-buffers (T->H) available on this target (Default: 3) +#define SEGGER_RTT_MAX_NUM_DOWN_BUFFERS (2) // Max. number of down-buffers (H->T) available on this target (Default: 3) + +#define BUFFER_SIZE_UP (1024) // Size of the buffer for terminal output of target, up to host (Default: 1k) +#define BUFFER_SIZE_DOWN (16) // Size of the buffer for terminal input to target from host (Usually keyboard input) (Default: 16) + +#define SEGGER_RTT_PRINTF_BUFFER_SIZE (128u) // Size of buffer for RTT printf to bulk-send chars via RTT (Default: 64) + +#define SEGGER_RTT_MODE_DEFAULT SEGGER_RTT_MODE_NO_BLOCK_SKIP // Mode for pre-initialized terminal channel (buffer 0) + +/********************************************************************* +* +* RTT memcpy configuration +* +* memcpy() is good for large amounts of data, +* but the overhead is big for small amounts, which are usually stored via RTT. +* With SEGGER_RTT_MEMCPY_USE_BYTELOOP a simple byte loop can be used instead. +* +* SEGGER_RTT_MEMCPY() can be used to replace standard memcpy() in RTT functions. +* This is may be required with memory access restrictions, +* such as on Cortex-A devices with MMU. +*/ +#define SEGGER_RTT_MEMCPY_USE_BYTELOOP 0 // 0: Use memcpy/SEGGER_RTT_MEMCPY, 1: Use a simple byte-loop +// +// Example definition of SEGGER_RTT_MEMCPY to external memcpy with GCC toolchains and Cortex-A targets +// +//#if ((defined __SES_ARM) || (defined __CROSSWORKS_ARM) || (defined __GNUC__)) && (defined (__ARM_ARCH_7A__)) +// #define SEGGER_RTT_MEMCPY(pDest, pSrc, NumBytes) SEGGER_memcpy((pDest), (pSrc), (NumBytes)) +//#endif + +// +// Target is not allowed to perform other RTT operations while string still has not been stored completely. +// Otherwise we would probably end up with a mixed string in the buffer. +// If using RTT from within interrupts, multiple tasks or multi processors, define the SEGGER_RTT_LOCK() and SEGGER_RTT_UNLOCK() function here. +#if !defined(SEGGER_RTT_ASM) +#include "ch.h" +#define SEGGER_RTT_LOCK() do { \ + syssts_t LockState = chSysGetStatusAndLockX() +#define SEGGER_RTT_UNLOCK() chSysRestoreStatusX(LockState); \ + } while(0) +#endif +#endif +/*************************** End of file ****************************/ diff --git a/testhal/STM32/STM32F4xx/USB_HOST/SEGGER_SYSVIEW_Conf.h b/testhal/STM32/STM32F4xx/USB_HOST/SEGGER_SYSVIEW_Conf.h new file mode 100644 index 0000000..69a0dbc --- /dev/null +++ b/testhal/STM32/STM32F4xx/USB_HOST/SEGGER_SYSVIEW_Conf.h @@ -0,0 +1,174 @@ +/********************************************************************* +* SEGGER Microcontroller GmbH * +* The Embedded Experts * +********************************************************************** +* * +* (c) 1995 - 2019 SEGGER Microcontroller GmbH * +* * +* www.segger.com Support: support@segger.com * +* * +********************************************************************** +* * +* SEGGER SystemView * Real-time application analysis * +* * +********************************************************************** +* * +* All rights reserved. * +* * +* SEGGER strongly recommends to not make any changes * +* to or modify the source code of this software in order to stay * +* compatible with the RTT protocol and J-Link. * +* * +* Redistribution and use in source and binary forms, with or * +* without modification, are permitted provided that the following * +* conditions are met: * +* * +* o Redistributions of source code must retain the above copyright * +* notice, this list of conditions and the following disclaimer. * +* * +* o Redistributions in binary form must reproduce the above * +* copyright notice, this list of conditions and the following * +* disclaimer in the documentation and/or other materials provided * +* with the distribution. * +* * +* o Neither the name of SEGGER Microcontroller GmbH * +* nor the names of its contributors may be used to endorse or * +* promote products derived from this software without specific * +* prior written permission. * +* * +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * +* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * +* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * +* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR * +* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * +* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * +* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * +* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * +* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * +* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * +* DAMAGE. * +* * +********************************************************************** +* * +* SystemView version: V2.52h * +* * +********************************************************************** +-------------------------- END-OF-HEADER ----------------------------- + +File : SEGGER_SYSVIEW_Conf.h +Purpose : SEGGER SystemView configuration. +Revision: $Rev: 13453 $ +*/ + +#ifndef SEGGER_SYSVIEW_CONF_H +#define SEGGER_SYSVIEW_CONF_H + +/********************************************************************* +* +* Defines, fixed +* +********************************************************************** +*/ +// +// Constants for known core configuration +// +#define SEGGER_SYSVIEW_CORE_OTHER 0 +#define SEGGER_SYSVIEW_CORE_CM0 1 // Cortex-M0/M0+/M1 +#define SEGGER_SYSVIEW_CORE_CM3 2 // Cortex-M3/M4/M7 +#define SEGGER_SYSVIEW_CORE_RX 3 // Renesas RX + +#if (defined __SES_ARM) || (defined __CROSSWORKS_ARM) || (defined __GNUC__) || (defined __clang__) + #if (defined __ARM_ARCH_6M__) || (defined __ARM_ARCH_8M_BASE__) + #define SEGGER_SYSVIEW_CORE SEGGER_SYSVIEW_CORE_CM0 + #elif (defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)) + #define SEGGER_SYSVIEW_CORE SEGGER_SYSVIEW_CORE_CM3 + #endif +#elif defined(__ICCARM__) + #if (defined (__ARM6M__) && (__CORE__ == __ARM6M__)) + #define SEGGER_SYSVIEW_CORE SEGGER_SYSVIEW_CORE_CM0 + #elif ((defined (__ARM7M__) && (__CORE__ == __ARM7M__)) || (defined (__ARM7EM__) && (__CORE__ == __ARM7EM__))) + #define SEGGER_SYSVIEW_CORE SEGGER_SYSVIEW_CORE_CM3 + #endif +#elif defined(__CC_ARM) + #if (defined(__TARGET_ARCH_6S_M)) + #define SEGGER_SYSVIEW_CORE SEGGER_SYSVIEW_CORE_CM0 + #elif (defined(__TARGET_ARCH_7_M) || defined(__TARGET_ARCH_7E_M)) + #define SEGGER_SYSVIEW_CORE SEGGER_SYSVIEW_CORE_CM3 + #endif +#elif defined(__TI_ARM__) + #ifdef __TI_ARM_V6M0__ + #define SEGGER_SYSVIEW_CORE SEGGER_SYSVIEW_CORE_CM0 + #elif (defined(__TI_ARM_V7M3__) || defined(__TI_ARM_V7M4__)) + #define SEGGER_SYSVIEW_CORE SEGGER_SYSVIEW_CORE_CM3 + #endif +#elif defined(__ICCRX__) + #define SEGGER_SYSVIEW_CORE SEGGER_SYSVIEW_CORE_RX +#elif defined(__RX) + #define SEGGER_SYSVIEW_CORE SEGGER_SYSVIEW_CORE_RX +#endif + +#ifndef SEGGER_SYSVIEW_CORE + #define SEGGER_SYSVIEW_CORE SEGGER_SYSVIEW_CORE_OTHER +#endif + +/********************************************************************* +* +* Defines, configurable +* +********************************************************************** +*/ +/********************************************************************* +* +* SystemView buffer configuration +*/ +#define SEGGER_SYSVIEW_RTT_BUFFER_SIZE 65536 // Number of bytes that SystemView uses for the buffer. +#define SEGGER_SYSVIEW_RTT_CHANNEL 1 // The RTT channel that SystemView will use. 0: Auto selection + +#define SEGGER_SYSVIEW_USE_STATIC_BUFFER 1 // Use a static buffer to generate events instead of a buffer on the stack + +#define SEGGER_SYSVIEW_POST_MORTEM_MODE 0 // 1: Enable post mortem analysis mode + +/********************************************************************* +* +* SystemView timestamp configuration +*/ +#if SEGGER_SYSVIEW_CORE == SEGGER_SYSVIEW_CORE_CM3 + #define SEGGER_SYSVIEW_GET_TIMESTAMP() (*(U32 *)(0xE0001004)) // Retrieve a system timestamp. Cortex-M cycle counter. + #define SEGGER_SYSVIEW_TIMESTAMP_BITS 32 // Define number of valid bits low-order delivered by clock source +#else + #define SEGGER_SYSVIEW_GET_TIMESTAMP() SEGGER_SYSVIEW_X_GetTimestamp() // Retrieve a system timestamp via user-defined function + #define SEGGER_SYSVIEW_TIMESTAMP_BITS 32 // Define number of valid bits low-order delivered by SEGGER_SYSVIEW_X_GetTimestamp() +#endif + +/********************************************************************* +* +* SystemView Id configuration +*/ +#define SEGGER_SYSVIEW_ID_BASE 0x20000000 // Default value for the lowest Id reported by the application. Can be overridden by the application via SEGGER_SYSVIEW_SetRAMBase(). (i.e. 0x20000000 when all Ids are an address in this RAM) +#define SEGGER_SYSVIEW_ID_SHIFT 2 // Number of bits to shift the Id to save bandwidth. (i.e. 2 when Ids are 4 byte aligned) + +/********************************************************************* +* +* SystemView interrupt configuration +*/ +#if SEGGER_SYSVIEW_CORE == SEGGER_SYSVIEW_CORE_CM3 + #define SEGGER_SYSVIEW_GET_INTERRUPT_ID() ((*(U32 *)(0xE000ED04)) & 0x1FF) // Get the currently active interrupt Id. (i.e. read Cortex-M ICSR[8:0] = active vector) +#elif SEGGER_SYSVIEW_CORE == SEGGER_SYSVIEW_CORE_CM0 + #if defined(__ICCARM__) + #if (__VER__ > 6100000) + #define SEGGER_SYSVIEW_GET_INTERRUPT_ID() (__get_IPSR()) // Workaround for IAR, which might do a byte-access to 0xE000ED04. Read IPSR instead. + #else + #define SEGGER_SYSVIEW_GET_INTERRUPT_ID() ((*(U32 *)(0xE000ED04)) & 0x3F) // Older versions of IAR do not include __get_IPSR, but might also not optimize to byte-access. + #endif + #else + #define SEGGER_SYSVIEW_GET_INTERRUPT_ID() ((*(U32 *)(0xE000ED04)) & 0x3F) // Get the currently active interrupt Id. (i.e. read Cortex-M ICSR[5:0] = active vector) + #endif +#else + #define SEGGER_SYSVIEW_GET_INTERRUPT_ID() SEGGER_SYSVIEW_X_GetInterruptId() // Get the currently active interrupt Id from the user-provided function. +#endif + +#endif // SEGGER_SYSVIEW_CONF_H + +/*************************** End of file ****************************/ diff --git a/testhal/STM32/STM32F4xx/USB_HOST/chconf.h b/testhal/STM32/STM32F4xx/USB_HOST/chconf.h index f26baa0..12c6673 100644 --- a/testhal/STM32/STM32F4xx/USB_HOST/chconf.h +++ b/testhal/STM32/STM32F4xx/USB_HOST/chconf.h @@ -524,7 +524,7 @@ * @note The default is @p CH_DBG_TRACE_MASK_DISABLED. */ #if !defined(CH_DBG_TRACE_MASK) -#define CH_DBG_TRACE_MASK CH_DBG_TRACE_MASK_ALL +#define CH_DBG_TRACE_MASK CH_DBG_TRACE_MASK_DISABLED #endif /** diff --git a/testhal/STM32/STM32F4xx/USB_HOST/halconf.h b/testhal/STM32/STM32F4xx/USB_HOST/halconf.h index 6b1255e..4a6fcc5 100644 --- a/testhal/STM32/STM32F4xx/USB_HOST/halconf.h +++ b/testhal/STM32/STM32F4xx/USB_HOST/halconf.h @@ -394,7 +394,7 @@ * default configuration. */ #if !defined(SERIAL_DEFAULT_BITRATE) || defined(__DOXYGEN__) -#define SERIAL_DEFAULT_BITRATE 38400 +#define SERIAL_DEFAULT_BITRATE 115200 #endif /** @@ -405,7 +405,7 @@ * buffers. */ #if !defined(SERIAL_BUFFERS_SIZE) || defined(__DOXYGEN__) -#define SERIAL_BUFFERS_SIZE 16 +#define SERIAL_BUFFERS_SIZE 64 #endif /*===========================================================================*/ diff --git a/testhal/STM32/STM32F4xx/USB_HOST/main.c b/testhal/STM32/STM32F4xx/USB_HOST/main.c index c540233..c88880b 100644 --- a/testhal/STM32/STM32F4xx/USB_HOST/main.c +++ b/testhal/STM32/STM32F4xx/USB_HOST/main.c @@ -297,6 +297,7 @@ start: #if HAL_USBH_USE_MSD
#include "usbh/dev/msd.h"
#include "ff.h"
+#include "fatfs_devices.h"
static FATFS MSDLUN0FS;
@@ -388,14 +389,14 @@ start: usbDbgPuts("FS: Block driver ready, try mount...");
- res = f_mount(&MSDLUN0FS, "0:", 1);
+ res = f_mount(&MSDLUN0FS, FATFSDEV_MSD_DRIVE, 1);
if (res != FR_OK) {
usbDbgPuts("FS: Can't mount. Check file system.");
continue;
}
usbDbgPuts("FS: Mounted.");
- res = f_getfree("0:", &clusters, &fsp);
+ res = f_getfree(FATFSDEV_MSD_DRIVE, &clusters, &fsp);
if (res != FR_OK) {
usbDbgPuts("FS: f_getfree() failed");
continue;
@@ -419,7 +420,7 @@ start: //write test
if (1) {
usbDbgPuts("FS: Write test (create file /test.dat, 1MB)");
- f_open(&file, "/test.dat", FA_CREATE_ALWAYS | FA_WRITE);
+ f_open(&file, FATFSDEV_MSD_DRIVE "/test.dat", FA_CREATE_ALWAYS | FA_WRITE);
src = start;
st = chVTGetSystemTime();
for (j = 0; j < 2048; j++) {
@@ -439,7 +440,7 @@ start: //read test
if (1) {
usbDbgPuts("FS: Read test (read file /test.dat, 1MB, compare)");
- f_open(&file, "/test.dat", FA_READ);
+ f_open(&file, FATFSDEV_MSD_DRIVE "/test.dat", FA_READ);
src = start;
st = chVTGetSystemTime();
for (j = 0; j < 2048; j++) {
@@ -463,7 +464,7 @@ start: //scan files test
if (1) {
usbDbgPuts("FS: Scan files test");
- fbuff[0] = 0;
+ strcpy((char *)fbuff, FATFSDEV_MSD_DRIVE);
scan_files(chp, (char *)fbuff);
}
}
diff --git a/testhal/STM32/STM32F4xx/USB_HOST/mcuconf.h b/testhal/STM32/STM32F4xx/USB_HOST/mcuconf.h index 51be912..668ec41 100644 --- a/testhal/STM32/STM32F4xx/USB_HOST/mcuconf.h +++ b/testhal/STM32/STM32F4xx/USB_HOST/mcuconf.h @@ -32,11 +32,18 @@ */ #define STM32F4xx_MCUCONF +#define STM32F405_MCUCONF +#define STM32F415_MCUCONF +#define STM32F407_MCUCONF +#define STM32F417_MCUCONF /* * HAL driver system settings. */ #define STM32_NO_INIT FALSE +#define STM32_PVD_ENABLE FALSE +#define STM32_PLS STM32_PLS_LEV0 +#define STM32_BKPRAM_ENABLE FALSE #define STM32_HSI_ENABLED TRUE #define STM32_LSI_ENABLED TRUE #define STM32_HSE_ENABLED TRUE @@ -60,9 +67,6 @@ #define STM32_I2SSRC STM32_I2SSRC_CKIN #define STM32_PLLI2SN_VALUE 192 #define STM32_PLLI2SR_VALUE 5 -#define STM32_PVD_ENABLE FALSE -#define STM32_PLS STM32_PLS_LEV0 -#define STM32_BKPRAM_ENABLE FALSE /* * IRQ system settings. @@ -234,6 +238,14 @@ #define STM32_PWM_TIM9_IRQ_PRIORITY 7 /* + * RTC driver system settings. + */ +#define STM32_RTC_PRESA_VALUE 32 +#define STM32_RTC_PRESS_VALUE 1024 +#define STM32_RTC_CR_INIT 0 +#define STM32_RTC_TAMPCR_INIT 0 + +/* * SDC driver system settings. */ #define STM32_SDC_SDIO_DMA_PRIORITY 3 @@ -330,9 +342,7 @@ #define STM32_USB_OTG2_IRQ_PRIORITY 14 #define STM32_USB_OTG1_RX_FIFO_SIZE 512 #define STM32_USB_OTG2_RX_FIFO_SIZE 1024 -#define STM32_USB_OTG_THREAD_PRIO LOWPRIO -#define STM32_USB_OTG_THREAD_STACK_SIZE 128 -#define STM32_USB_OTGFIFO_FILL_BASEPRI 0 +#define STM32_USB_HOST_WAKEUP_DURATION 2 /* * WDG driver system settings. diff --git a/testhal/STM32/STM32F4xx/USB_HOST/usbh_additional_class_drivers.h b/testhal/STM32/STM32F4xx/USB_HOST/usbh_additional_class_drivers.h index ac9fc18..9a1a37c 100644 --- a/testhal/STM32/STM32F4xx/USB_HOST/usbh_additional_class_drivers.h +++ b/testhal/STM32/STM32F4xx/USB_HOST/usbh_additional_class_drivers.h @@ -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/testhal/STM32/STM32F4xx/USB_HOST/usbh_custom_class_example.c b/testhal/STM32/STM32F4xx/USB_HOST/usbh_custom_class_example.c index 4585a5c..b0b5560 100644 --- a/testhal/STM32/STM32F4xx/USB_HOST/usbh_custom_class_example.c +++ b/testhal/STM32/STM32F4xx/USB_HOST/usbh_custom_class_example.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/testhal/STM32/STM32F4xx/USB_HOST/usbh_custom_class_example.h b/testhal/STM32/STM32F4xx/USB_HOST/usbh_custom_class_example.h index 3f00fe7..c848fc2 100644 --- a/testhal/STM32/STM32F4xx/USB_HOST/usbh_custom_class_example.h +++ b/testhal/STM32/STM32F4xx/USB_HOST/usbh_custom_class_example.h @@ -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. |