summaryrefslogtreecommitdiff
path: root/firmware/usbstack/core
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/usbstack/core')
-rw-r--r--firmware/usbstack/core/config.c9
-rw-r--r--firmware/usbstack/core/core.c31
-rw-r--r--firmware/usbstack/core/epsetup.c6
3 files changed, 28 insertions, 18 deletions
diff --git a/firmware/usbstack/core/config.c b/firmware/usbstack/core/config.c
index c49d54702c..1a9b12508e 100644
--- a/firmware/usbstack/core/config.c
+++ b/firmware/usbstack/core/config.c
@@ -23,7 +23,8 @@
23#include <string.h> 23#include <string.h>
24#include "usbstack/core.h" 24#include "usbstack/core.h"
25 25
26static int usb_descriptor_fillbuf(void* buf, unsigned buflen, struct usb_descriptor_header** src) 26static int usb_descriptor_fillbuf(void* buf, unsigned buflen,
27 struct usb_descriptor_header** src)
27{ 28{
28 uint8_t* dest = buf; 29 uint8_t* dest = buf;
29 30
@@ -45,7 +46,8 @@ static int usb_descriptor_fillbuf(void* buf, unsigned buflen, struct usb_descrip
45 return dest - (uint8_t *)buf; 46 return dest - (uint8_t *)buf;
46} 47}
47 48
48int usb_stack_configdesc(const struct usb_config_descriptor* config, void* buf, unsigned length, struct usb_descriptor_header** desc) 49int usb_stack_configdesc(const struct usb_config_descriptor* config, void* buf,
50 unsigned length, struct usb_descriptor_header** desc)
49{ 51{
50 struct usb_config_descriptor* cp = buf; 52 struct usb_config_descriptor* cp = buf;
51 int len; 53 int len;
@@ -58,7 +60,8 @@ int usb_stack_configdesc(const struct usb_config_descriptor* config, void* buf,
58 *cp = *config; 60 *cp = *config;
59 61
60 /* then interface/endpoint/class/vendor/... */ 62 /* then interface/endpoint/class/vendor/... */
61 len = usb_descriptor_fillbuf(USB_DT_CONFIG_SIZE + (uint8_t*)buf, length - USB_DT_CONFIG_SIZE, desc); 63 len = usb_descriptor_fillbuf(USB_DT_CONFIG_SIZE + (uint8_t*)buf,
64 length - USB_DT_CONFIG_SIZE, desc);
62 65
63 if (len < 0) { 66 if (len < 0) {
64 return len; 67 return len;
diff --git a/firmware/usbstack/core/core.c b/firmware/usbstack/core/core.c
index 2fbec5d571..0d2cfc67b9 100644
--- a/firmware/usbstack/core/core.c
+++ b/firmware/usbstack/core/core.c
@@ -99,7 +99,8 @@ void usb_stack_start(void)
99 * and if it has a device driver bind to it */ 99 * and if it has a device driver bind to it */
100 logf("check for auto bind"); 100 logf("check for auto bind");
101 if (usbcore.active_controller->type == DEVICE) { 101 if (usbcore.active_controller->type == DEVICE) {
102 if (usbcore.active_controller->device_driver == NULL && usbcore.device_driver != NULL) { 102 if (usbcore.active_controller->device_driver == NULL &&
103 usbcore.device_driver != NULL) {
103 /* bind driver */ 104 /* bind driver */
104 logf("binding..."); 105 logf("binding...");
105 bind_device_driver(usbcore.device_driver); 106 bind_device_driver(usbcore.device_driver);
@@ -130,7 +131,8 @@ void usb_stack_stop(void)
130void usb_stack_irq(void) 131void usb_stack_irq(void)
131{ 132{
132 /* simply notify usb controller */ 133 /* simply notify usb controller */
133 if (usbcore.active_controller != NULL && usbcore.active_controller->irq != NULL) { 134 if (usbcore.active_controller != NULL &&
135 usbcore.active_controller->irq != NULL) {
134 usbcore.active_controller->irq(); 136 usbcore.active_controller->irq();
135 } 137 }
136} 138}
@@ -190,7 +192,8 @@ int usb_controller_register(struct usb_controller* ctrl)
190 * @param ctrl pointer to controller to unregister. 192 * @param ctrl pointer to controller to unregister.
191 * @return 0 on success else a defined error code. 193 * @return 0 on success else a defined error code.
192 */ 194 */
193int usb_controller_unregister(struct usb_controller* ctrl) { 195int usb_controller_unregister(struct usb_controller* ctrl)
196{
194 197
195 if (ctrl == NULL) { 198 if (ctrl == NULL) {
196 return EINVAL; 199 return EINVAL;
@@ -226,7 +229,8 @@ void usb_controller_select(int type)
226 struct usb_controller* new = NULL; 229 struct usb_controller* new = NULL;
227 230
228 /* check if a controller of the wanted type is already loaded */ 231 /* check if a controller of the wanted type is already loaded */
229 if (usbcore.active_controller != NULL && (int)usbcore.active_controller->type == type) { 232 if (usbcore.active_controller != NULL &&
233 (int)usbcore.active_controller->type == type) {
230 logf("controller already set"); 234 logf("controller already set");
231 return; 235 return;
232 } 236 }
@@ -263,7 +267,8 @@ void usb_controller_select(int type)
263 usbcore.active_controller->init(); 267 usbcore.active_controller->init();
264} 268}
265 269
266int usb_stack_get_mode(void) { 270int usb_stack_get_mode(void)
271{
267 return usbcore.mode; 272 return usbcore.mode;
268} 273}
269 274
@@ -296,8 +301,8 @@ int usb_device_driver_register(struct usb_device_driver* driver)
296 return 0; 301 return 0;
297} 302}
298 303
299int usb_device_driver_bind(const char* name) { 304int usb_device_driver_bind(const char* name)
300 305{
301 int i; 306 int i;
302 struct usb_device_driver *tmp = NULL; 307 struct usb_device_driver *tmp = NULL;
303 struct usb_device_driver *driver = NULL; 308 struct usb_device_driver *driver = NULL;
@@ -340,8 +345,8 @@ int usb_device_driver_bind(const char* name) {
340 return 0; 345 return 0;
341} 346}
342 347
343void usb_device_driver_unbind(void) { 348void usb_device_driver_unbind(void)
344 349{
345 logf("usb_device_driver_unbind"); 350 logf("usb_device_driver_unbind");
346 if (usbcore.active_controller->device_driver != NULL) { 351 if (usbcore.active_controller->device_driver != NULL) {
347 usbcore.active_controller->device_driver->unbind(); 352 usbcore.active_controller->device_driver->unbind();
@@ -351,8 +356,8 @@ void usb_device_driver_unbind(void) {
351 usbcore.device_driver = NULL; 356 usbcore.device_driver = NULL;
352} 357}
353 358
354static void update_driver_names(unsigned char* result) { 359static void update_driver_names(unsigned char* result)
355 360{
356 int i; 361 int i;
357 int pos = 0; 362 int pos = 0;
358 unsigned char terminator = ','; 363 unsigned char terminator = ',';
@@ -376,8 +381,8 @@ static void update_driver_names(unsigned char* result) {
376 } 381 }
377} 382}
378 383
379static void bind_device_driver(struct usb_device_driver* driver) { 384static void bind_device_driver(struct usb_device_driver* driver)
380 385{
381 int ret = 0; 386 int ret = 0;
382 387
383 /* look if there is an old driver */ 388 /* look if there is an old driver */
diff --git a/firmware/usbstack/core/epsetup.c b/firmware/usbstack/core/epsetup.c
index 969678e18f..ef98935fe3 100644
--- a/firmware/usbstack/core/epsetup.c
+++ b/firmware/usbstack/core/epsetup.c
@@ -151,13 +151,15 @@ static int ep_matches(struct usb_ep* ep, struct usb_endpoint_descriptor* desc)
151 switch (type) { 151 switch (type) {
152 case USB_ENDPOINT_XFER_INT: 152 case USB_ENDPOINT_XFER_INT:
153 /* INT: limit 64 bytes full speed, 1024 high speed */ 153 /* INT: limit 64 bytes full speed, 1024 high speed */
154 if ((usbcore.active_controller->speed != USB_SPEED_HIGH) && (max > 64)) { 154 if ((usbcore.active_controller->speed != USB_SPEED_HIGH) &&
155 (max > 64)) {
155 return 0; 156 return 0;
156 } 157 }
157 /* FALLTHROUGH */ 158 /* FALLTHROUGH */
158 159
159 case USB_ENDPOINT_XFER_ISOC: 160 case USB_ENDPOINT_XFER_ISOC:
160 if ((usbcore.active_controller->speed != USB_SPEED_HIGH) && (max > 1023)) { 161 if ((usbcore.active_controller->speed != USB_SPEED_HIGH) &&
162 (max > 1023)) {
161 return 0; 163 return 0;
162 } 164 }
163 break; 165 break;