From 13507233a47f14c48e6051a770bcd014f8c99de1 Mon Sep 17 00:00:00 2001 From: Bernhard Urban Date: Wed, 23 Sep 2009 18:47:10 +0200 Subject: [PATCH] various changes --- main.c | 8 +++++++- usb/core/core.c | 45 ++++++++++++++++------------------------- usb/core/usb.c | 1 - usb/drivers/class/hid.c | 8 ++++++++ usb/drivers/class/hid.h | 1 + 5 files changed, 33 insertions(+), 30 deletions(-) diff --git a/main.c b/main.c index 430db72..a058cfe 100644 --- a/main.c +++ b/main.c @@ -123,11 +123,17 @@ int main(void) usb_init(OHCI0_REG_BASE); /* internal ohci */ - //usb_init(OHCI1_REG_BASE); + usb_init(OHCI1_REG_BASE); /* load HID keyboard driver */ usb_hidkb_init(); + /* wait for usb keyboard plugged in */ + if(!usb_hidkb_inuse()) { + print_str("plug in an usb keyboard", 23); + } + while(!usb_hidkb_inuse()); + /* you are welcome to make this nice :) */ char str[7]; u16 i, j, y=20, x=20; diff --git a/usb/core/core.c b/usb/core/core.c index 889fba4..0b38e77 100644 --- a/usb/core/core.c +++ b/usb/core/core.c @@ -123,34 +123,23 @@ struct usb_device *usb_add_device(u8 lowspeed, u32 reg) #define WTF #ifdef WTF - printf("lololololool PADDING WTF :O lolololololo \n"); - printf("lolololool PADDING WTF :O lolololololo \n"); - printf("lololololool PADDING WTF :O lolololololo \n"); - printf("lololololool PADDING WTF :O lolololololo \n"); - printf("lolololool PADDING WTF :O lolololololo \n"); - printf("lololololool PADDING WTF :O lolololololo \n"); - printf("lollllool PADDING WTF :O lolololololo \n"); - printf("lololololool PADDING WTF :O lolololololo \n"); - printf("lolololool PADDING WTF :O lololoololo \n"); - printf("lololololool PADDING WTF :O lolololololo \n"); - printf("lolololool PADDING WTF :O lolololololo \n"); - printf("lololololool PADDING WTF :O lolololololo \n"); - printf("lollllool PADDING WTF :O lolololololo \n"); - printf("lololololool PADDING WTF :O lolololololo \n"); - printf("lolololool PADDING WTF :O lololoololo \n"); - printf("lololololool PADDING WTF :O lolololololo \n"); - printf("lolololool PADDING WTF :O lolololololo \n"); - printf("lololololool PADDING WTF :O lolololololo \n"); - printf("lollllool PADDING WTF :O lolololololo \n"); - printf("lololololool PADDING WTF :O lolololololo \n"); - printf("lolololool PADDING WTF :O lololoololo \n"); - printf("lololololool PADDING WTF :O lolololololo \n"); - printf("lolololool PADDING WTF :O lolololololo \n"); - printf("lololololool PADDING WTF :O lolololololo \n"); - printf("lollllool PADDING WTF :O lolololololo \n"); - printf("lolololool PADDING WTF :O lolololololo \n"); - printf("lololololool PADDING WTF :O lolololololo \n"); - printf("lollllool PADDING WTF :O lolololololo \n"); + volatile u8 wzf = 11; + if(0 == wzf) { + printf("WTF WTF WTF WTF padding??? WTFWTF WTF\n"); + printf("WTF WTF WTF WTF padding??? WTF WTF WTF\n"); + printf("WTF TF WTF WTF padding??? WTF WTF WTF\n"); + printf("WTF WTF TF WTF padding??? WTF WTWTF\n"); + printf("TF WTF WTF WTF padding??? WTF WTF WTF\n"); + printf("WTF WTF WTF WT padding??? WTF WF WTF\n"); + printf("WTF WTF WTF WTF padding??? WTF WTF WTF\n"); + printf("WTF WTF WTF WTF padding??? WT WTF WTF\n"); + printf("WTF WTF WTF WTF pdding??? WTF WTF WTF\n"); + printf("WTF WTF WTF WTF paddin??? WTF WTF WTF\n"); + printf("WTF WTF WTF WTF padding??? WTF WTF WTF\n"); + printf("WTF WTF WTF WTF padding?? WT WTF WTF\n"); + printf("WTF WTF WTF WTF padding??? WTF WTF WTF\n"); + printf("WTF WTF WTF WTF padding??? WTFWTF WTF\n"); + } #endif u8 address = usb_next_address(); ret = usb_set_address(dev, address); diff --git a/usb/core/usb.c b/usb/core/usb.c index 8b766b0..76c3e85 100644 --- a/usb/core/usb.c +++ b/usb/core/usb.c @@ -303,7 +303,6 @@ s8 usb_set_address(struct usb_device *dev, u8 address) { cleargbuf(); usb_control_msg(dev, 0x00, SET_ADDRESS, address, 0, 0, gbuf, 0); - hexdump((void*) gbuf, 8); wait_ms(210); return 0; } diff --git a/usb/drivers/class/hid.c b/usb/drivers/class/hid.c index 60d3a4d..fe5a17c 100644 --- a/usb/drivers/class/hid.c +++ b/usb/drivers/class/hid.c @@ -36,6 +36,9 @@ void usb_hidkb_probe() while(iterator != NULL) { dev = (struct usb_device*)iterator->data; + if(dev == NULL) { + continue; + } if(dev->conf->intf->bInterfaceClass == HID_CLASSCODE && dev->conf->intf->bInterfaceSubClass == 1 && /* keyboard support boot protocol? */ @@ -51,6 +54,11 @@ void usb_hidkb_check() { } +u8 usb_hidkb_inuse() +{ + return hidkb.data ? 1 : 0; +} + struct kbrep *usb_hidkb_getChars() { struct usb_device *dev = (struct usb_device*) hidkb.data; struct kbrep *ret = (struct kbrep*) malloc(sizeof(struct kbrep)); diff --git a/usb/drivers/class/hid.h b/usb/drivers/class/hid.h index e8e88d9..347a0db 100644 --- a/usb/drivers/class/hid.h +++ b/usb/drivers/class/hid.h @@ -31,6 +31,7 @@ struct kbrep { void usb_hidkb_probe(); void usb_hidkb_check(); void usb_hidkb_init(); +u8 usb_hidkb_inuse(); struct kbrep *usb_hidkb_getChars(); -- 2.25.1