Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: DMSupport DMSupport DMSupport DMSupport
Fork of DM_USBHost by
Revision 33:819bbf04163b, committed 2019-11-04
- Comitter:
- embeddedartists
- Date:
- Mon Nov 04 14:30:07 2019 +0000
- Parent:
- 32:f2d129436056
- Commit message:
- More updates related to mbed OS 5
Changed in this revision
--- a/USBHost/USBHALHost.cpp Wed Oct 23 06:58:55 2019 +0000
+++ b/USBHost/USBHALHost.cpp Mon Nov 04 14:30:07 2019 +0000
@@ -39,10 +39,10 @@
#define TOTAL_SIZE (HCCA_SIZE + (MAX_ENDPOINT*ED_SIZE) + (MAX_TD*TD_SIZE))
-// Put the USB structures in the only memory accessible by the USB stack - the AHBSRAM0
-static volatile uint8_t usb_buf[TOTAL_SIZE] __attribute__((section("AHBSRAM0"),aligned(256)));// __attribute__((section("AHBSRAM0"),aligned(256))); //256 bytes aligned!
+// Put the USB structures in the only memory accessible by the USB stack - the AHBSRAM1
+static volatile uint8_t usb_buf[TOTAL_SIZE] __attribute__((section("AHBSRAM1"),aligned(256)));// __attribute__((section("AHBSRAM0"),aligned(256))); //256 bytes aligned!
-// A very basic implementation of malloc to allocate in the AHBSRAM0
+// A very basic implementation of malloc to allocate in the AHBSRAM1
#define SAFE_MEM_TO_USE (10*1024)
#define SAFE_MEM_BLOCK_SIZE (512)
#define SAFE_MEM_NUM_BLOCKS (SAFE_MEM_TO_USE/SAFE_MEM_BLOCK_SIZE)
@@ -51,7 +51,7 @@
bool used;
} safe_mem_info_t;
static safe_mem_info_t safe_mem_list[SAFE_MEM_NUM_BLOCKS];
-static uint8_t safe_mem_data[SAFE_MEM_TO_USE] __attribute__((section("AHBSRAM0"),aligned(256)));//__attribute__((section("AHBSRAM0"),aligned)); //256 bytes aligned!
+static uint8_t safe_mem_data[SAFE_MEM_TO_USE] __attribute__((section("AHBSRAM1"),aligned(256)));//__attribute__((section("AHBSRAM0"),aligned)); //256 bytes aligned!
// To detect when memory outside of the AHBSRAM0 is passed to the USB stack
void assert_mem_region(uint32_t ptr)
@@ -78,6 +78,7 @@
safe_mem_list[i].used = false;
safe_mem_list[i].ptr = safe_mem_data + SAFE_MEM_BLOCK_SIZE*i;
}
+
}
uint8_t* USBHALHost::getSafeMem(uint32_t size) {
@@ -198,9 +199,7 @@
LPC_USB->HcRhPortStatus1 = OR_RH_PORT_PRSC;
LPC_USB->HcRhPortStatus2 = OR_RH_PORT_CSC;
LPC_USB->HcRhPortStatus2 = OR_RH_PORT_PRSC;
-
resetRootHub();
-
NVIC_SetPriority(USB_IRQn, 0);
NVIC_EnableIRQ(USB_IRQn);
@@ -358,11 +357,12 @@
void USBHALHost::_usbisr(void) {
if (instHost) {
- instHost->UsbIrqhandler();
+ instHost->UsbIrqhandler();
}
}
void USBHALHost::UsbIrqhandler() {
+
if( LPC_USB->HcInterruptStatus & LPC_USB->HcInterruptEnable ) //Is there something to actually process?
{
uint32_t int_status = LPC_USB->HcInterruptStatus & LPC_USB->HcInterruptEnable;
@@ -378,8 +378,8 @@
//Root device connected
if (LPC_USB->HcRhPortStatus2 & OR_RH_PORT_CCS) {
- // wait 150ms to avoid bounce
- ThisThread::sleep_for(150);
+ // wait 150ms to avoid bounce (removed since wait is not allowed in isr)
+ //ThisThread::sleep_for(150);
//Hub 0 (root hub), Port 2 (count starts at 1), Low or High speed
deviceConnected(0, 2, LPC_USB->HcRhPortStatus2 & OR_RH_PORT_LSDA);
@@ -392,8 +392,8 @@
usb_hcca->DoneHead = 0;
}
- // wait 200ms to avoid bounce
- ThisThread::sleep_for(200);
+ // wait 200ms to avoid bounce (removed since wait is not allowed in isr)
+ //wait_ms(200);
deviceDisconnected(0, 2, NULL, usb_hcca->DoneHead & 0xFFFFFFFE);
--- a/USBHost/USBHost.cpp Wed Oct 23 06:58:55 2019 +0000
+++ b/USBHost/USBHost.cpp Mon Nov 04 14:30:07 2019 +0000
@@ -188,7 +188,7 @@
} while(0);
if (listener != 0) {
- osSignalSet(listener, listenerSignal);
+ listener->set(listenerSignal);
}
break;
@@ -216,7 +216,7 @@
} while(0);
if (listener != 0) {
- osSignalSet(listener, listenerSignal);
+ listener->set(listenerSignal);
}
break;
@@ -361,6 +361,7 @@
instHost = new USBHost();
instHost->init();
}
+
return instHost;
}
--- a/USBHost/USBHost.h Wed Oct 23 06:58:55 2019 +0000
+++ b/USBHost/USBHost.h Mon Nov 04 14:30:07 2019 +0000
@@ -187,7 +187,7 @@
}
}
- void signalOnConnections(osThreadId threadId, uint32_t signal) { listener = threadId; listenerSignal = signal; }
+ void signalOnConnections(EventFlags *connectionListener, uint32_t signal) { listener = connectionListener; listenerSignal = signal; }
/**
* Instantiate to protect USB thread from accessing shared objects (USBConnectedDevices and Interfaces)
@@ -286,7 +286,7 @@
Mutex usb_mutex;
Mutex td_mutex;
- osThreadId listener;
+ EventFlags *listener;
uint32_t listenerSignal;
// buffer for conf descriptor
--- a/USBHostHub/USBHostHub.cpp Wed Oct 23 06:58:55 2019 +0000
+++ b/USBHostHub/USBHostHub.cpp Mon Nov 04 14:30:07 2019 +0000
@@ -53,8 +53,6 @@
USBHostHub::USBHostHub() {
host = NULL;
init();
-
- buf = host->getSafeMem(sizeof(HubDescriptor));
}
USBHostHub::~USBHostHub()
@@ -78,6 +76,10 @@
for (int i = 0; i < MAX_HUB_PORT; i++) {
device_children[i] = NULL;
}
+
+ if (host != NULL) {
+ buf = host->getSafeMem(sizeof(HubDescriptor));
+ }
}
void USBHostHub::setHost(USBHost * host_) {
--- a/USBHostMSD/USBHostMSD.cpp Wed Oct 23 06:58:55 2019 +0000
+++ b/USBHostMSD/USBHostMSD.cpp Mon Nov 04 14:30:07 2019 +0000
@@ -32,7 +32,8 @@
USBHostMSD::USBHostMSD(const char * rootdir) : FATFileSystem(rootdir)
{
- host = USBHost::getHostInst();
+ host = USBHost::getHostInst();
+
init();
cbw = (CBW*)host->getSafeMem(sizeof(CBW));
