HID firmware Modification (hidtouartexample) bis

Source: Internet
Author: User

1. When the host computer writes data to HID, the first byte transmitted by each packet is the write Data (out)of the report ID, and the upper and lower machine must be identical .

Host Computer Configuration location:


Next machine configuration location:



2. HID up-level machine when the data is returned, the first byte of each packet must also be read Data (in)the report ID, and in the lower machine, the definition of the in report ID must be The first byte of the sending packet is consistent , otherwise a read error. In the report ID is independent of the host computer.




3. the next machine return data is implemented by calling the Sendpacket () function

The parameters of the Sendpacket () function, which is ReportID, go inside the Sendpacket function and see that the sending principle is to call the corresponding report handle function according to the report ID of the parameter (the corresponding report The handle function places the data that will be sent into the in_packet[64] buffer, and then sends the data within the In_packet (that is, the data to be sent).

As currently used Reportid:in_data, Sendpacket (in_data) is used, in_data corresponding report handle function is In_data (), in In_data (), the externally obtained data is assigned to In_ PACKET[64], the code is as follows:

void In_data (void)

{

Inti

In_packet[0]= In_data;

for (I=1; i<64; i++)

                    in_packet[i]= peripheral_read_buf[i-1];                  //periphral_read_buf is assigned a value in the main function or other function

                                                                                                                                         //periphral_read_buf as a bridge for transmitting data from hid Lib with other code

This will open the hid Lib independently.

In_buffer. Ptr= In_packet;

In_buffer. Length = in_data_size + 1;

}

Note: PERIPHERAL_READ_BUF is a custom external receive data storage buffer, in order to be independent of the HID operation in the HID example, its own program can change the value of Peripheral_read_buf, Just press the HID sample sender (Sendpacket) operation on the line. The key is to associate the two with the above code in the In_data () function . This can be hid in the example, the pure HID operation of the part of the independent, do not have to pipe F340 the bottom operation, this part can be made lib.

If you want to send different data in your main function, just do the following.

Read process

Casefpga_r:

{

for (cyccnt=0;cyccnt<64; cyccnt++)

{

PERIPHERAL_READ_BUF[CYCCNT] = cyccnt +10;

}//For PERIPHERAL_READ_BUF assignment can be in any desired position

Sendpacket (In_data);

out_packet[1]= 0;

Break

}

4. The SPI interface has only spi3w and spi4w two chipaddress in the FPGA, and the protocol between the host computer and the slave computer defines a chip address for each SPI interface, Various SPI interfaces can be converted to spi3w and spi4w, and FPGAs are accomplished by setting up a splice register (0x11).

After selecting some SPI interface in the Chipaddress drop-down box, the FPGA is configured as the corresponding stitching in the message function of the drop-down box.

In the lower machine, each SPI read and write branches, the host computer to pass the chip address is set back to fpgaspi3w or spi4w chip address respectively.

Reference: D:\Yifei\WorkPlace\Project\Driver_PG_HDMI2MIPI\Firmware Readme


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.