CN-122019443-A - Communication method based on LK stage SPI bus controller and screen IC
Abstract
The invention discloses a communication method of an SPI bus controller and a screen IC based on an LK stage, which comprises the following steps of a, configuring SPI controller hardware, dynamically configuring GPIO function mode functions and creating a register structure body, b, configuring SPI controller initialization functions, customizing SPI communication behaviors based on SPI controller parameters and configuring end sequence modes of data transmission, c, packaging a data receiving function and a data transmitting function, directly reading the data receiving function from a receiving register, processing the data by the data transmitting function, and then transmitting the processed data to the screen IC, and d, initializing the screen IC. The invention realizes the purpose of receiving and transmitting data by calling the SPI bus controller in the LK stage by accessing and controlling the register of the SPI bus controller in the LK stage, packaging into read and write functions and embedding the read and write functions into a platform flow, thereby achieving the purposes of efficiently and accurately receiving and transmitting data, having the characteristics of high transmission rate, short overall startup time and the like.
Inventors
- YANG MING
- LI CHANGYING
Assignees
- 无锡宇宁科技集团股份有限公司
Dates
- Publication Date
- 20260512
- Application Date
- 20260115
Claims (10)
- 1. A communication method based on an LK phase SPI bus controller and a screen IC, the method comprising the steps of: a. configuring SPI controller hardware, dynamically configuring GPIO function mode function and creating register structure; b. configuring an SPI controller initialization function, receiving parameters of the SPI controller transmitted by a user, customizing SPI communication behavior, and configuring an end sequence mode of data transmission; c. Packaging a data receiving function and a data transmitting function, wherein the data receiving function is directly read from a receiving register, and the data transmitting function processes data and then transmits the processed data to a screen IC; d. Initializing the screen IC, namely receiving SPI communication parameters transmitted by a user, calling the GPIO dynamic configuration function in the step a and the SPI controller initialization function in the step b, and performing read-write operation on a register of the SPI controller based on the parameters transmitted by the user, wherein the operation is realized by adding a register offset to a base address of a register structure body created in the step a, and calling the data receiving function and the data transmitting function packaged in the step c to communicate with the screen IC according to the current end sequence mode after the SPI controller is ready, so that the initialization of the screen IC is completed.
- 2. The communication method based on LK phase SPI bus controller and screen IC of claim 1, wherein, In the step a, the method for dynamically configuring the GPIO function mode function is that the function mode of the GPIO pin corresponding to MISO, MOSI, CS, SCLK four paths of signal lines used by the SPI controller is configured to be an SPI function mode.
- 3. The method of communicating with a screen IC based on LK phase SPI bus controller of claim 2, further comprising switching the pin mode back to the normal GPIO mode by the same configuration function when a switch back to the conventional GPIO analog SPI communication mode is required.
- 4. The communication method based on LK-phase SPI bus controller and screen IC according to claim 1, wherein in step a, the register structure is consistent with SPI controller hardware register layout, comprising 13 32-bit unsigned integer members, each member maps a physical register, defining pointer SPI2 REGS pointing to the structure, pointing to mapped virtual address, and realizing direct access to hardware register by operating SPI2 REGS pointer.
- 5. The communication method based on LK phase SPI bus controller and screen IC according to claim 1, wherein in step b, the parameters of said SPI controller include an SPI communication rate, an SPI operation mode, a clock polarity, and a clock phase, the upper limit of said SPI communication rate is 27MHZ, if the incoming value is greater than the upper limit, the SPI operation mode is SPI mode 3, and the clock polarity and clock phase are configured by the SPI operation mode.
- 6. The communication method between the LK phase-based SPI bus controller and the screen IC according to claim 1, wherein in step b, the method for configuring the endian mode of data transmission is as follows: The SPI controller configures the transmitting data containing the initializing code of the screen into a small-end mode and configures the transmitting data containing the display content of the screen into a large-end mode in the data transmitted to the screen IC, wherein the small-end mode firstly transmits the least significant byte and then transmits the most significant byte, and the large-end mode firstly transmits the most significant byte and then transmits the least significant byte.
- 7. The communication method between the LK phase-based SPI bus controller and the screen IC according to claim 1, wherein in step c, the method for processing data by the data transmission function is as follows: The DATA transmission function calls for a loop statement, incoming DATA is written into an SPI_TX_DATA register in a group of 4 bytes, for the remaining DATA of less than 4 bytes, the starting address of the remaining bytes is positioned first, the bytes are precisely combined into a 32-bit variable according to the natural sequence of the bytes in a memory through a loop, the number of the loops is equal to the number of the remaining bytes, and the combined 32-bit variable is written into a transmission register.
- 8. The communication method based on LK phase SPI bus controller and screen IC according to claim 1, wherein in step d, And c, after the user inputs the SPI communication parameters, writing the input SPI rate parameters into the SPI_CFG2 register to realize the control of the transmission rate, writing the input SPI mode parameters into the SPI_CMD register, and realizing the access and operation of the register based on the base address pointed by the first member of the structural body created in the step a and the corresponding offset.
- 9. The communication method based on LK phase SPI bus controller and screen IC according to claim 8, wherein after the SPI controller initialization function processes the incoming SPI communication parameter, the target screen IC is selected by writing 0to the corresponding bit of the spi_cmd register to enable the chip select signal, thereby enabling hardware handshake between the SPI controller and screen IC.
- 10. The communication method based on LK phase SPI bus controller and screen IC according to claim 1, wherein in step d, said step of calling the data receiving function and the data transmitting function encapsulated in step c according to the current endian mode communicates with the screen IC, and the step of initializing the screen IC includes: when the initialization code is sent, the SPI controller is set to be in a small-end mode, then the encapsulated sending function is called, and the initialization code is sent to the screen; when the startup logo image data is sent, the SPI controller is set to be in a large-end mode, and then a packaged sending function is called to send the image data to a display buffer register of the screen IC; Before each call of the sending function, the SPI_STATUS1 register state is read first to confirm that the SPI controller is in an idle state, and if the SPI controller is in the idle state; configuring the time of the high level and the low level of the clock in the clock control register according to the communication rate when data is transmitted each time; The receiving function is used for reading the ID of the screen IC, sending a reading command through the sending function consistent with the current endian mode, and reading the DATA returned by the screen IC from the SPI_RX_DATA register.
Description
Communication method based on LK stage SPI bus controller and screen IC Technical Field The invention relates to the technical field of embedded systems and display driving, in particular to a communication method based on an LK-stage SPI bus controller and a screen IC. Background In the process of starting an embedded device (such as a smart phone or a tablet computer), a bootloader (such as LITTLE KERNEL, LK) needs to quickly initialize a display screen to display starting Logo or debugging information. When the traditional scheme of the GPIO simulation SPI communication protocol is used for receiving and transmitting data, the GPIO simulation SPI communication protocol is adopted for carrying out follow-up equipment communication, the data receiving and transmitting are realized by controlling the high level and the low level of the GPIO corresponding to the MISO/MOSI/CS/SCLK signal line connected with the follow-up equipment through the GPIO operation function according to the time sequence of the SPI communication protocol, a large amount of operation GPIO is needed, the transmission rate is low, the waveform signal precision is poor, and the abnormal data receiving and transmitting can be caused by the insufficient duration time or the overlong holding time of the GPIO level. The logic analyzer is used for grabbing signal waveforms, the maximum clock signal simulated by the GPIO can only reach 1.25MHz, and huge time delay can be caused for a high-speed and high-throughput scene of a screen display image. Actually, a frame of LOGO picture with 320 x 240 resolution in RGB565 format is actually displayed, 1060ms is needed, the time consumption is calculated to be within the starting time, the starting time requirement cannot be met, and the image brushed on the screen is gradually refreshed due to the fact that each transmission is transmitted according to one byte, so that the look and feel are affected. Therefore, the prior art is difficult to combine high performance and high flexibility, and a technical scheme for realizing high-speed and stable SPI communication in the LK phase is needed to optimize the start-up time and enhance the initial display experience. Disclosure of Invention The invention provides a communication method based on an LK-stage SPI bus controller and a screen IC, which is used for solving the problems of low SPI protocol transmission rate, long startup LOGO display time consumption and overall startup time delay caused by a traditional GPIO simulation scheme. In order to achieve the purpose of the invention, the invention provides a communication method based on an LK phase SPI bus controller and a screen IC, which comprises the following steps: a. configuring SPI controller hardware, dynamically configuring GPIO function mode function and creating register structure; b. configuring an SPI controller initialization function, receiving parameters of the SPI controller transmitted by a user, customizing SPI communication behavior, and configuring an end sequence mode of data transmission; c. Packaging a data receiving function and a data transmitting function, wherein the data receiving function is directly read from a receiving register, and the data transmitting function processes data and then transmits the processed data to a screen IC; d. Initializing the screen IC, namely receiving SPI communication parameters transmitted by a user, calling the GPIO dynamic configuration function in the step a and the SPI controller initialization function in the step b, and performing read-write operation on a register of the SPI controller based on the parameters transmitted by the user, wherein the operation is realized by adding a register offset to a base address of a register structure body created in the step a, and calling the data receiving function and the data transmitting function packaged in the step c to communicate with the screen IC according to the current end sequence mode after the SPI controller is ready, so that the initialization of the screen IC is completed. In the step a, the method for dynamically configuring the GPIO function mode function is that the function mode of the GPIO pin corresponding to MISO, MOSI, CS, SCLK four paths of signal lines used by the SPI controller is configured to be an SPI function mode. Further, when the conventional GPIO analog SPI communication mode needs to be switched back, the pin mode is switched back to the common GPIO mode through the same configuration function. In step a, the register structure body is consistent with the hardware register layout of the SPI controller, and comprises 13 32-bit unsigned integer members, each member is mapped with one physical register respectively, a pointer SPI2 REGS pointing to the structure body is defined and points to the mapped virtual address, and the hardware register is directly accessed through the operation of the SPI2 REGS pointer. In the step b, the parameters of the SPI controller co