-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathUSBManager.cpp
More file actions
43 lines (37 loc) · 1.34 KB
/
Copy pathUSBManager.cpp
File metadata and controls
43 lines (37 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "USBManager.hpp"
#include "USBDevice.hpp"
USBManager::USBManager(uint32_t capacity){
devices = IndexMap<USBDevice*>(capacity);
};
void USBManager::register_device(uint8_t address){
if (address >= devices.max_size()) return;
USBDevice *newdevice = new USBDevice(8,address);
if (!newdevice) return;
devices.add(address,newdevice);
}
void USBManager::register_endpoint(uint8_t slot_id, uint8_t endpoint, uint32_t interval, usb_device_types type, uint16_t packet_size){
if (slot_id >= devices.max_size()) return;
USBDevice *dev = devices[slot_id];
if (dev)
dev->register_endpoint(endpoint, type, interval, packet_size);
}
void USBManager::request_data(uint8_t slot_id, uint8_t endpoint_id, USBDriver *driver){
if (slot_id >= devices.max_size()) return;
USBDevice *dev = devices[slot_id];
if (dev)
dev->request_data(endpoint_id, driver);
}
void USBManager::process_data(uint8_t slot_id, uint8_t endpoint_id, USBDriver *driver){
if (slot_id >= devices.max_size()) return;
USBDevice *dev = devices[slot_id];
if (dev)
dev->process_data(endpoint_id, driver);
}
void USBManager::poll_inputs(USBDriver *driver){
for (uint8_t i = 0; i < devices.max_size(); i++){
USBDevice *device = devices[i];
if (device){
device->poll_inputs(driver);
}
}
}