HID-HOST with FRDM-KL25

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

HID-HOST with FRDM-KL25

HID-HOST with FRDM-KL25

In this document we are going to see how to use the attached code which implements the configuration of the FRDM-KL25 board as a USB HOST interfacing with a Numeric Keyboard and a 16x2 LCD.

The project is compiled in the CodeWarrior IDE using Processor Expert and the Components to support the USB module of the USB Stack 4.1.1.

How to add the Processor Expert USB components.

The instructions to install the USB components to use them with Processor Expert are in the documentation of the USB Stack 4.1.1; here you can see the steps as well:

  • Download the USB Stack 4.1.1 from the Freescale’s Website (USB Stack 4.1.1)
  • Run the .exe file and install it in the default location.
  • Open CodeWarrior and select Import Components in the Processor Expert button in menu bar.

import components.png

  • An Open windows will pop up, there you need to go to the path: <install folder>\Freescale USB Stack v4.1.1\ProcessorExpert\Components. To have the complete components and support for the USB module add each PEupd file repeating this step.

open window.png

  • Close CodeWarrior and open it again to ensure correct installation of the components.
  • Check that the new components are available in the Components Library.

usb components.png

About this Project.

This project is based in the example code for Processor Expert in the USB Stack 4.1.1 USB_HID_MOUSE_HOST_MKL25Z128_PEx which implements the use of the FRDM-BOARD KL25 and a HID Mouse Device to interface with.

In this project the HID Device is a Numeric Keyboard and the HOST Device (FRDM-KL25) is handling the data and printing them in a 16x2 LCD used in 8 bits mode (The LCDHTA component used here was created by Erich Styger; find the component an all the information about it here: http://mcuoneclipse.com/2012/12/22/hd44780-2x16-character-display-for-kinetis-and-freedom-board/ and say Thank you Erich: “Thank you Erich”).

Here you can find a video of the implementation of this application:

HID HOST WITH FRDM-KL25

The hardware components are:

  • FRMD-KL25 Rev.E
  • Adafruit Prototype Shield v.5
  • LCD JHD-162A
  • Numeric USB Keyboard (Product Name: Numpad i110, Model No. GK-100010)

USB _host

Inside the project you can see there is a folder called USB_Host an it contains two important folders with source files:

  • App_keyboard: Contains the specific function for the Keyboard configuration: in use, attached detached, callbacks and more; contain how to handle the data coming from the device. The function process_kdb_buffer is where the data is transmitted to the LCD and use it for the application.
  • Classes: contain the necessary function to handle a hid as the device. Handle all the functions necessary for the USB protocol.

Note:

The usb_classes.c and usb_classes.h files are generated by processor expert. I attach these two files as well to have a reference how these files must look like. This is because sometimes during the code generation process Processor Expert erases part of the code.

I hope this project is useful for you.

Best Regards,

Adrian.

附件
评论

Here is a video which shows how the application works:

i tried to interface usb keyboard to kinetis K60DN512Z microcontroller. (codewarrior v.10.4, usb srack 4.1.1. ) same as above example. but the keyboard is detected. but not interfacing

Keyboard_Task(uchar *buffer)

{

switch (hid_device.DEV_STATE)
{
case USB_DEVICE_IDLE:  break;

case USB_DEVICE_ATTACHED:

printf("\nDevice attached");
hid_device.DEV_STATE = USB_DEVICE_SET_INTERFACE_STARTED;

status = _usb_hostdev_select_interface(hid_device.DEV_HANDLE, hid_device.INTF_HANDLE, (pointer) & hid_device.CLASS_INTF);
if(status != USB_OK)
{
printf("\nError in _usb_hostdev_select_interface! STATUS: 0x%x",(unsigned int) status);
}
break;

case USB_DEVICE_SET_INTERFACE_STARTED:

printf("\nInterface started");
break;

case USB_DEVICE_INTERFACED:
printf("Keyboard device interfaced")

.......................

}

while executing the above function, output is 

Device attached

Error in _usb_hostdev_select_interface! STATUS:0xc3     

Interface started

Interface started

Interface started---------

it is not entering in to case USB_DEVICE_INTERFACED:

ie, only just detecting the keyboard . but interface is not propr. (USERR NO DEVICE CLASS ERROR IS COMING)

is there any fault in my code? i am also following the same method as your post..

无评分
版本历史
最后更新:
‎07-10-2014 08:43 AM
更新人: