usb generic hid multiple endpoints sdk 1.20 KL 26

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

usb generic hid multiple endpoints sdk 1.20 KL 26

1,619 Views
enoregrattoni
Contributor I

I try to set up a generic hid on a kinetis kl26 128k  starting from hid device mouse example. I setup input endpoint changing descriptors included report descriptor.

Input endpoint works fine tested with HID_CLIENT Keil example and also some other programs..

I am working with keil MDK and my hardware is a freedom platform.

I am trying to setup output endpoint. I already add endpoint output descriptor and change endpoints number from 1 to 2.

Now I need to activate app callback and this  sdk is more complex than previous example so I am looking for some help.

I think that there are some structure to modify but it is not clear how to proceed.

From PC with some utilities I can read all descriptors and all seems OK.

Input and output endpoint are interrupt type and on PC side output transaction is 1 byte long (HID_CLIENT Keil example)

 

Waiting some tips

 

Thanks

Labels (1)
0 Kudos
8 Replies

1,044 Views
enoregrattoni
Contributor I

Hi

nobody of stack developer can validate my bug findings?

0 Kudos

1,044 Views
dankarm
Contributor II

I also had a problem with the USB_HID_SET_REPORT_REQUEST in the USB_App_Class_Callback() function not giving the report data. The pointer referenced "data" passed in was always NULL.

I also determined that this appears to be a problem with the USB_Control_Service() function in the usb_framework.c file. I got it to work when I added the following line: (shown in bold)

Line
   448    /* class or vendor request */
   449size = event->len + USB_SETUP_PKT_SIZE;
       data = event->buffer_ptr;   // DLK added this bug fix
   450error = usb_fw_ptr->request_notify_callback(

Dan

1,045 Views
audi_mcavoy
Contributor IV

I have confirmed that without Dan's modification I cannot send data from the host to the Kinetis HID.

Has anyone at Freescale also verified?  Is this bug going to be fixed in the next KSDK release?

- Audi

0 Kudos

1,045 Views
isaacavila
NXP Employee
NXP Employee

Hello Audi,

In fact, I also tested it yesterday, when i wanted to check for output report (sent in endpoint zero) and as Dan said, this pointer was always NULL in KSDK 1.2 version.. Fortunately, i tested this same project (keyboard example) in the newest KSDK version and this was already fixed.

Could you please try to use the newer KSDK version (KSDK 1.3)? You can download it from Software Development Kit for Kinetis MCUs|Freescale

I hope this can help,

Best Regards,

Isaac

0 Kudos

1,045 Views
audi_mcavoy
Contributor IV

Hi Isaac,

I didn't forget your request.  It actually took me two weeks to successfully build my project on KSDK 1.3 (there were a lot of niggles to overcome).

So here's what I found. . .

- KSDK 1.3 seems to have implemented Dan's fix.

- Unfortunately, KSDK 1.3 doesn't want to play nice (at least using PEx) unless you specify heap space.

See printf() is Broke in KSDK 1.3

Bonus!  Now when PEx adds the fsl-usb_device_hid_class component, it also adds the Init_FMC component and configures it to give the hid_class component access to the Flash space so that the descriptors (which default to constants) can be read.

Thanks,

- Audi

0 Kudos

1,045 Views
Kan_Li
NXP TechSupport
NXP TechSupport

The USB stack provides API of "USB_Class_HID_Recv_Data()" for HID Device output direction transfer, and the application layer receives a callback event USB_DEV_EVENT_DATA_RECEIVED. The transfer fails when the value of the object that the pointer size points is 0xFFFFFFFF in callback event USB_DEV_EVENT_DATA_RECEIVED.

Please kindly refer to USB Stack Device Reference Manual for more details.

Hope that helps,

Kan

0 Kudos

1,045 Views
enoregrattoni
Contributor I

I made more deep test and I get something working changing  like this.

I use one input interrupt endpoint and i use control transaction on endpoint 0 for output.

This is same procedure used in keil example in all hid generic.

I attach following file mouse.c descriptor.h and descriptor.c and usb_framework.c

In file usb_framework.c routine

/**************************************************************************//*!

*

* @name  USB_Control_Service

*

* @brief Called upon a completed endpoint 0 (USB 1.1 Chapter 9) transfer

*

* @param event:        from Service callback function

*

* @return None      

*

*****************************************************************************/

void USB_Control_Service

I think there is a problem

This routine in control output transaction is called 2 times

First time finally is called (at line 415)

                /* expecting host to send data (OUT TRANSACTION)*/

                (void)usb_device_recv_data(event->handle,

                USB_CONTROL_ENDPOINT,(usb_fw_ptr->ext_req_to_host+USB_SETUP_PKT_SIZE),

                (uint32_t)(size));

Second time finally is called this routine

       data=(usb_fw_ptr->ext_req_to_host+USB_SETUP_PKT_SIZE);  // add by Enore

            error = usb_fw_ptr->request_notify_callback(

            (usb_setup_struct_t*) usb_fw_ptr->ext_req_to_host,

            &data,&size,usb_fw_ptr->request_notify_param);

I get callback workin only with my modification

This is working only if I set a breakpoint in mouse.c at this point

    case USB_HID_SET_REPORT_REQUEST:

//     *data = &g_mouse.rpt_buf[0];   // aggiunta da Enore

        for (index = 0; index < MOUSE_BUFF_SIZE; index++)

        { /* copy the report sent by the host */

            output_buf[index] = *(*data + index);

        }

        break;   // <-----------------------breakpoint here

I see that output buffer is same as that sent from pc application

If application is running without breakpoint transaction is not working (meaning output buffer doent change)

I cannot understand why

0 Kudos

1,045 Views
enoregrattoni
Contributor I

I test better

I think I have only one emulation problem

Transfer are ok

So I am pretty sure to catch a bug on usb_framework.c

0 Kudos