Using TI's tm4c123g Launchpad Development Board, USB interface, to the same chip to burn write.
We only use burn write that piece of function, do not have another chip development function, need jumper source project: from official website tm4c123g, download this board of
Drive, write program, Project。 Lmflashprogrammer.msi the program, drive and Project Sw-tm4c-2.0.1.11577.exe, tivaware_c_series-2.0.1.11577 project, examples\boards\ EK-TM4C123GXL for us to use the Chip project infrared screen schematic, see the project on the PDM nasty undefined error, when taking usb-keyb code in the Mong CDC code when porting. Added the following header file # include "Usblib/usbhid.h"
#include "Usblib/device/usbdhid.h"
#include "Usblib/device/usbdhidkeyb.h"
#include "usb_keyb_structs.h" to the USB to the serial port as the basis to change, first to kill the CDC part except the main function of the file method, and. S file. s file has a few symbols to export, has no, and the reference to the place Usbuartinthandler no longer need, the other 2 is still to be, after the transplant keyboard related functions, have implemented EXTERN Systickinthandler
EXTERN Usbuartinthandler
EXTERN Usb0deviceinthandler; DCD Usb0deviceinthandler; USB0 and so on and then will be prompted not to implement Keyboardhandler, and then put the USB keyboard main function file over there, related to a lump copy all over, compiled successfully! But run up unrecognized, with pb0,2,3 io pull low, locate program, found to run normally. Know while (1) is all fine. It turns out that while (1) you need to write code here? or more. s file add something? The while (1) adds the relevant code, or not. Go ahead and test tomorrow. s file to remove the original USB CDC. s file; EXTERN Usbuartinthandler, sure enough. Now in. s file join keyboard function, and delete Usbuartinthandler,ok, successful recognition! --------------------------------------------------------------------------------------------------------------- Change the USB mouse: usb_xxx_structs C and H files, and the Mian function to achieve
xxxHandler First observe the KEYBOARD,BULK,USB serial port has a usb_bulk_structs such a file 1, there is a string array definition const UINT8_T * Const g_ppui8stringdescriptors[] =
{
G_pui8langdescriptor,
G_pui8manufacturerstring,
G_pui8productstring,
G_pui8serialnumberstring,
G_pui8datainterfacestring,
G_pui8configstring
};2, there are device descriptors.
TusbdhidkeyboarddeviceG_skeyboarddevice =
{
USB_VID_TI_1CBE,
Usb_pid_keyboard,
500,
USB_CONF_ATTR_SELF_PWR | Usb_conf_attr_rwake,
Keyboardhandler,
(void *) &g_skeyboarddevice,
G_ppui8stringdescriptors,
Num_string_descriptors
For bulk, more than 2 buffer is defined
TusbdbulkdeviceG_sbulkdevice =
{
USB_VID_TI_1CBE,
Usb_pid_bulk,
500,
USB_CONF_ATTR_SELF_PWR,
Usbbuffereventcallback,
(void *) &
G_srxbuffer,
Usbbuffereventcallback,
(void *) &
G_stxbuffer,
G_ppui8stringdescriptors,
Num_string_descriptors
For CDC, similar to bulk
TusbdcdcdeviceG_scdcdevice =
{
USB_VID_TI_1CBE,
Usb_pid_serial,
0,
USB_CONF_ATTR_SELF_PWR,
Controlhandler,
(void *) &g_scdcdevice,
Usbbuffereventcallback,
(void *) &
G_srxbuffer,
Usbbuffereventcallback,
(void *) &
G_stxbuffer,
G_ppui8stringdescriptors,
Num_string_descriptors
};
TusbdhidkeyboarddeviceThis structure has to be used by Usbdhidkeyboard. Similarly find found in Usbdhidmouse using Tusbdhidmousedevice,tusbdhidmousedevice search out definition
Tusbdhidmousedevice G_smousedevice{
USB_VID_TI_1CBE,
Usb_pid_mouse,
500,
USB_CONF_ATTR_SELF_PWR | Usb_conf_attr_rwake,
Keyboardhandler,
(void *) &
G_smousedevice, G_ppui8stringdescriptors,
Num_string_descriptors
The other few are easy to change, the point is
Keyboardhandler ReplaceIt's Mousehandler analysis.
keyboardhandler State processing, found that all USB has a state, nothing special, can be directly reused:Analysis Bulk, is rxhandler and Txhandler analysis CDC, more complex, controlhandler processing the common state here and combining Rxhandler, Txhandler so mouse directly with the Keyboardhanlder is good Usb_event_connectedusb_event_disconnectedusb_event_tx_completeusb_event_ suspendusb_event_resumeusbd_hid_keyb_event_set_leds://this upper machine to a single chip on the transmission of an LED light, keyboard only event, the mouse does not
{
//
Set the led to match the current state of the CAPS lock LED.
//
Rom_gpiopinwrite (Gpio_portg_base, Gpio_pin_2,
(Ui32msgdata & Hid_keyb_caps_lock)? Gpio_pin_2:
0);
Break
} Do not need sendstring and its dependent waitforsendidle, delete it, otherwise call
TusbdhidkeyboarddeviceThe structure causes the compilation error main function Usbdhidkeyboardinit, changes the corresponding change to compile again, the general hint is undefined,
D:\ti\TivaWare_C_Series-2.0.1.11577\examples\boards\ek-tm4c123gxl\usb_dev_serial\usb_keyb_structs.h (34): Error: #20: identifier "Tusbdhidmousedevice" is undefinedUsb_keyb_structs.h: Error: #20: identifier "Tusbdhidmousedevice" is undefined this a few hours, and finally found!!! #include "usblib/device/usbdhidmouse.h"
#include "usb_keyb_structs.h"//must be placed at the end, because
Tusbdhidmousedevice defined inUsbdhidmouse.h, by the Usb_keyb_structs.h reference, if the first reference, then can not find the definition header file is in order, Pit Dad!!! Really die, whether it is USB_KEYB_STRUCTS.C structure files, or Mian function files, are to pay attention to the order, "usb_keyb_structs.h" must be placed in the last attached data,
extern is really deceptive, it doesn't work at all.
extern
functions defined in source file A are invisible (that is, inaccessible) in other source files. In order to call this function in the source file B, an external declaration should be added to the head of B:
extern function prototype;
That way, you can call that function in the source file B.
Finally!!! Successful compilation This time can identify the successful mouse. -------------------------------------------------------------finally is the main function, the keyboard is the data received from the IO, upload to the host computer mouse is also, so refer to the practice of the keyboard, Operation in a while loop
The same code, normally on the Development Board, can send analog USB mouse data to see the effect
on the target board, however, only the USB mouse is recognized, but the data sent is unsuccessful. Looking at Io, it seems to be dealing with events connected to the handler without triggering the target board plus a protective ESD or something, and need to be debugged with a hardware engineer. Then the expert resigned to flee.
tm4c123g Infrared Touch Screen: The Development Board finally realized the principle, put on the expert design of the board can not run, so experts to flee the project yellow