Hi to all, I am new in keil v5 and i want to implement usb ufi class mass storage under cbi protocol and i want use keil usb custom class in order to done that,but i do not know how i can use keil custom class and port it to my MCB17000 board and after searching in internet i do not find anything about that. Can any one me how can i create and config project with keil usb custom class??
ok friends, after some hours of Paddle i found that when i initialize usb core it return an error,code of main function is as below:
int main(void){ usbStatus stat; osKernelInitialize (); // initialize CMSIS-RTOS // initialize peripherals here // create 'thread' functions that start executing, // example: tid_name = osThreadCreate (osThread(name), NULL); osKernelStart (); // start thread execution stat = USBD_Initialize(0); //now stat is usbThreadError if(stat == usbOK) stat = USBD_Connect(0); while(1) { osDelay(1000); } }
as you can see USBD_Initialize function return usbThreadError,now can any one give me some advice to how solve that??
You have started up the OS. But have you created any threads that will actually perform any work?
Did press send too quickly - does your configuration allow additional threads to be created?
hi per, yes, in main i only start os and config the usb device and in USBD_USER_DEVICE_0.c in USBD_Device0_Endpoint0_SetupPacketReceived function i am waiting for usb_class_request setup packet to start my work and this is correct way. and yes, my problem was in os configuration and after increasing stack configuration it worked and now can i receive some setup packet in USBD_Device0_Endpoint0_SetupPacketReceived function. but i have new question, i read in some place that usb_core will process usb_standard request if i return usbdRequestNotProcessed in USBD_Device0_Endpoint0_SetupPacketReceived function but i think that it didn't. in below i list setup packets that i receive in USBD_Device0_Endpoint0_SetupPacketReceived function:
setup packet 1 : brequest=0x06 wValue=0x0100 :mean get Device descriptor setup packet 2 : brequest=0x05 wValue=0x0001 :mean set address descriptor setup packet 3 : brequest=0x06 wValue=0x0100 :mean get Device descriptor setup packet 4 : brequest=0x06 wValue=0x0200 :mean get Configuration descriptor setup packet 5 : brequest=0x06 wValue=0x0100 :mean get Device descriptor setup packet 6 : brequest=0x06 wValue=0x0200 :mean get Configuration descriptor setup packet 7 : brequest=0x09 wValue=0x0001 :mean Set configuration
in the last setup packet that i receive i send usbdRequestNotProcessed and after that i wait for receive any setup packet in USBD_Device0_Endpoint0_SetupPacketReceived function but this dose not happen, i am think that keil usb middelware dose not handdle it or at lease it fail to handle it. what is your opinion?? may it happen that keil fail to handle this request or crash or any other problem???
in the following of my previous post i seen that after receiving last setup packet that contain a request with brequest=0x09(Set configuration request), USBD_Device0_Endpoint0_SetupPacketProcessed function that must be called after processing this request dose not call in the even that for previous request this function triggered.
excuse for continuous posts, but in following my previous post i added below code to USBD_Device0_Endpoint0_SetupPacketReceived function:
switch (setup_packet->bmRequestType.Type) { case USB_REQUEST_STANDARD: if(setup_packet->bRequest == 0x09) { return usbdRequestOK; handle_request = true; } break; case USB_REQUEST_CLASS: if(setup_packet->bmRequestType.Type == 0x01) return usbdRequestNotProcessed; break; case USB_REQUEST_VENDOR: if(setup_packet->bmRequestType.Type == 0x01) return usbdRequestNotProcessed; break; case USB_REQUEST_RESERVED: if(setup_packet->bmRequestType.Type == 0x01) return usbdRequestNotProcessed; break; } return usbdRequestNotProcessed;
as you can see if SetConfiguration request received, i will return usbdRequestOK code without handling it and in this manner communication despite to previous state with host will continue and host send another setup packet as below :
setup packet 8 : brequest=0x00 :mean Get Status Request
but because i didn't really handle it host in following request ask me to done it again. what is your opinion, problem is os configuration such as stack and others???
Well, you should try to first understand things before implementing functionality as otherwise you are only guessing and using trial and error mechanism.
Anyways, if you defined all configuration paramaters for your device then when SetConfiguration request is received by USB stack it will configure and start all endpoints that device uses. In case that you are doing what you are doing, USB stack will not configure any endpoints nor start any communication, and you say you do not handle that request but return usbdRequestOK, so it can not work that way.
SetConfiguration request is very important if you do want to override default functionality of the USB stack you should know much more of what you need to do, but I do not see much reason why you would override SetConfiguration request, you can catch it to know when USB Host has requested that your device is configured but you should leave processing to USB stack.
as i said i want to implement ufi spec under cbi communication protocol so i need 4 endpoint as below :
endpoint 0 : default control endpoint endpoint 1 : bulk in and out endpoint endpoint 2 : interrupt endpoint
i add these endpoints to USBD_Config_CustomClass_0.h as i need, but when leaving processing of SetConfiguration command to usb_stack it fail to handle it, i say this because after receiving this command and i return usbdRequestNotProcessed, usb_stack do not call USBD_Device0_Endpoint0_SetupPacketProcessed function that must call after processing received command. also after leaving this command to usb_stack i dose not receive any setup packet in USBD_Device0_Endpoint0_SetupPacketReceived function. now i am searching for solution for this problem.
I can already point one problem if you setup your endpoints as described, by documentation LPC17xx microcontroller has specific endpoint types for specific endpoint numbers for example endpoint 1 can not be of bulk type but only interrupt, and endpoint 2 can only be of bulk type. So, I first suggest you reverse to use endpoint 2 as bulk, and endpoint 1 as interrupt.
you are my best man Milorad, it worked and my problem was that you point. because i was in hurry to done this project i didn't read lpc17xx datasheet. thanks again.
Ignoring the data sheets seldom speeds up the progress.