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.
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.
Close CodeWarrior and open it again to ensure correct installation of the components.
Check that the new components are available in the Components Library.
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.
Numeric USB Keyboard (Product Name: Numpad i110, Model No. GK-100010)
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.
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.