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.
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:
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:
The hardware components are:
Inside the project you can see there is a folder called USB_Host an it contains two important folders with source files:
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..