Data transmission control method and device based on SPI communication protocol, equipment and medium
By directly transmitting the image information to the TFT screen after initializing and formatting the MCU, the problems of low data transmission rate and poor reliability of the TFT screen are solved, and a high-efficiency and smooth image display effect is achieved.
Patent Information
- Application Number
- CN202411797938.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-09
- Publication Date
- 2025-01-10
- Estimated Expiration
- 2044-12-09
AI Technical Summary
Existing technologies for data transmission in TFT screens suffer from low data transmission rates, poor reliability, and subpar image display quality. In particular, under high refresh rate and high resolution scenarios, it is difficult to guarantee the integrity and accuracy of image information.
The MCU initializes and configures the SPI communication, generates the final configuration information for the chip select signal, formats the image information according to the TFT screen communication protocol, saves it to the SPI-FLASH, and directly transmits it to the TFT screen for display, avoiding additional processing by the MCU.
It improves data transmission rate and screen refresh rate, ensuring smooth and stable image display, and enhancing data transmission efficiency and reliability.
Smart Images

Figure CN119299600A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data transmission control, and in particular to a data transmission control method, device, equipment and medium based on an SPI communication protocol. Background Art
[0002] With the rapid development of information technology, display technology has been widely used in various fields. Especially in embedded systems, TFT (Thin Film Transistor) screens have become the mainstream choice due to their high resolution, high contrast and fast response time. In order to achieve efficient data transmission and display, SPI (Serial Peripheral Interface) as a high-speed synchronous serial communication standard is widely used in many embedded systems. The SPI communication protocol has become one of the important ways to connect microcontrollers (MCUs) and external storage devices (such as SPI-FLASH) with its simple and efficient characteristics.
[0003] In the existing technology, in order to achieve efficient display of TFT screen, the traditional data transmission method requires MCU to convert and process the image data multiple times, which not only increases the burden of MCU, but also reduces the data transmission rate. Secondly, there is the problem of data transmission reliability. Since the data needs to be processed multiple times during the transmission process, it is easy to cause data loss or errors, which in turn affects the display effect. In addition, when processing complex image data, the existing methods are difficult to ensure the integrity and accuracy of image information, especially in high refresh rate and high resolution display scenarios, these problems are more prominent. Therefore, how to improve data transmission efficiency and display quality has become a technical problem that needs to be solved urgently. Summary of the invention
[0004] In order to improve data transmission efficiency and display quality, the present application provides a data transmission control method, device, equipment and medium based on the SPI communication protocol.
[0005] The above-mentioned invention objective of the present application is achieved through the following technical solutions: A data transmission control method based on the SPI communication protocol, the data transmission control method based on the SPI communication protocol comprising: Acquire parameter information of SPI communication, and initialize and configure SPI communication through MCU according to the parameter information of SPI communication to generate final configuration information of chip select signal; Based on the final configuration information of the chip select signal, pre-formatting the image information according to the communication protocol of the TFT screen to obtain formatted image information, and saving the formatted image information into the SPI-FLASH according to the structural sequence of the TFT screen communication protocol; After completing the initialization configuration and saving the formatted image information, the MCU controls the final configuration information of the chip select signal of the SPI, reads the formatted image information from the SPI-FLASH, and directly transmits the formatted image information to the TFT screen for display.
[0006] By adopting the above technical solution, SPI communication can be controlled by MCU to ensure that when reading the image data in SPI-FLASH, the image information has been pre-formatted according to the communication protocol of the TFT screen, so that the data can be directly transmitted to the TFT screen, avoiding the MCU's additional conversion or processing of the data. In this way, by standardizing the pixel arrangement and color format of the image information in the data preprocessing stage, the data layout in SPI-FLASH is completely matched with the display requirements of the TFT screen. During the data transmission process, the MCU only needs to send the data in SPI-FLASH to the TFT screen block by block according to the protocol sequence, without further intervention in the data format conversion, thereby ensuring the efficiency of data transmission. Through this direct transmission method, the data transmission rate and screen refresh rate are effectively improved, thereby achieving a smoother image display effect.
[0007] In a preferred example, the present application may be further configured as follows: the acquisition of parameter information of SPI communication, initialization configuration of SPI communication through MCU according to the parameter information, to generate final configuration information of chip select signal, including: According to the target device information in the parameter information of the SPI communication, the chip select control register of the MCU is configured, the chip select pin of the SPI-FLASH is designated as the communication channel, and the initial configuration information of the chip select signal is generated; Based on the initial configuration information, the level state of the chip select signal is set to a low level, the communication mode of the SPI-FLASH is activated, and the final configuration information of the chip select signal is generated.
[0008] By adopting the above technical solution and configuring the chip select control register of the MCU, the chip select pin of the SPI-FLASH is used as an independent communication channel, which can ensure the independence of the chip select signal and avoid interference in multi-device communication, thereby ensuring efficient data transmission. By activating the SPI-FLASH communication mode after the chip select signal is set to a low level and generating the final configuration information of the chip select signal, the data transmission mode of the SPI-FLASH can be stably controlled, and the continuity and reliability of data transmission can be effectively improved, thereby further improving the stability and transmission efficiency of the SPI communication process.
[0009] In a preferred example, the present application can be further configured as follows: the final configuration information based on the chip select signal pre-formats the image information according to the communication protocol of the TFT screen to obtain the formatted image information, and saves the formatted image information to the SPI-FLASH according to the structural sequence of the TFT screen communication protocol, including: According to the communication protocol of the TFT screen, the pixel arrangement of the image information and the format requirements of the image information are analyzed to generate preliminary formatting information that complies with the communication protocol of the TFT screen; According to the preliminary formatting information, the pixel arrangement of the image information is adjusted and encoded to obtain the formatted image information, and the formatted image information is saved in the SPI-FLASH according to the structural sequence of the TFT screen communication protocol.
[0010] By adopting the above technical solution, the pixel arrangement and format requirements of the image information can be parsed based on the communication protocol of the TFT screen to ensure that the formatted image information meets the display standards of the TFT screen, thereby avoiding image distortion caused by format incompatibility during data transmission; by storing the formatted image information in the SPI-FLASH according to the structural order of the TFT screen communication protocol, it can be directly transmitted to the TFT screen in the display order during the subsequent reading process, ensuring the continuity of data transmission and the stability of the display effect, thereby improving data transmission efficiency and increasing the refresh rate of the screen.
[0011] In a preferred example, the present application can be further configured as follows: adjusting and encoding the pixel arrangement of the image information according to the preliminary formatting information to obtain the formatted image information, and saving the formatted image information in the SPI-FLASH according to the structural sequence of the TFT screen communication protocol, including: According to the pixel arrangement requirements in the preliminary formatting information, rearrange the pixel information of the image information to generate adjusted pixel arrangement information, perform encoding processing on the adjusted pixel arrangement information to generate the formatted image information matching the TFT screen communication protocol; Writing the formatted image information into the designated storage area of the SPI-FLASH block by block according to the structural sequence of the TFT screen communication protocol, and recording the storage location information of each block of the formatted image information; The writing status of each block of the formatted image information is verified according to the storage location information to confirm that the formatted image information is saved in the SPI-FLASH.
[0012] By adopting the above technical solution, the pixel arrangement of the image information can be adjusted and encoded according to the preliminary formatting information, so that the generated formatted image information matches the TFT screen communication protocol, thereby ensuring the consistency of the data format transmitted to the TFT screen and realizing efficient data docking; by writing the formatted image information block by block into the designated storage area of SPI-FLASH and recording the storage location information of each block, the position of each data block can be accurately located in the subsequent reading to avoid information confusion; at the same time, by verifying the writing status of each block of image information, it is ensured that the image information is completely saved in the SPI-FLASH, thereby improving the reliability of data storage and the stability of subsequent display effects.
[0013] In a preferred example, the present application may be further configured as follows: the writing status of each block of the formatted image information is verified according to the storage location information to confirm that the formatted image information is saved in the SPI-FLASH, including: Reading the content of each block of the formatted image information one by one according to the storage location information to generate verification information; Comparing the verification information with the preset information in the storage location information, identifying the writing integrity of each block of formatted image information, and obtaining a comparison result; Based on the comparison result, the writing status of each block of the formatted image information is confirmed to ensure that the formatted image information has been completely saved in the SPI-FLASH.
[0014] By adopting the above technical solution, the content of each block of formatted image information can be read one by one and verification information can be generated, so that the stored image information content can be checked block by block to ensure that no data is missed or tampered with during the reading process; by comparing the verification information with the preset information in the storage location information, it is helpful to identify the writing integrity of each block of image information and effectively eliminate data damage or incompleteness; based on the comparison result, the writing status of each block of image information is confirmed to ensure that the image information has been completely saved in the SPI-FLASH, thereby improving the reliability of data storage and providing guarantee for subsequent stable and efficient image display.
[0015] In a preferred example, the present application can be further configured as follows: after completing the initialization configuration and saving the formatted image information, the MCU controls the final configuration information of the chip select signal of the SPI, reads the formatted image information from the SPI-FLASH, and directly transmits the formatted image information to the TFT screen for display, including: By controlling the low level state of the final configuration information of the chip select signal, the SPI-FLASH is put into a read mode, a communication channel between the SPI-FLASH and the MCU is established, and read channel information is obtained; According to the read channel information, the formatted image information is read block by block from the SPI-FLASH in accordance with the structural sequence of the TFT screen communication protocol to generate the read image information; The read image information is transmitted to the TFT screen to realize direct display of the read image information.
[0016] By adopting the above technical solution, the SPI-FLASH can enter the read mode through the low level state of the chip select signal, and a stable communication channel with the MCU can be established, thereby ensuring the connection reliability during data transmission; by obtaining and utilizing the read channel information, the formatted image information can be read from the SPI-FLASH block by block according to the structural order of the TFT screen communication protocol, ensuring that the image data is read in the order of display requirements, avoiding data confusion or repeated transmission; finally, the read image information is directly transmitted to the TFT screen to achieve smooth and delay-free image display.
[0017] In a preferred example, the present application may be further configured as follows: the image information after reading is transmitted to the TFT screen to realize direct display of the image information after reading, and further includes: During the transmission process of the read image information, the transmission rate of the read image information is detected in real time according to the current display state of the TFT screen, and the transmission state information is generated; The refresh rate of the TFT screen is adjusted in real time through the transmission status information to ensure smooth display of the read image information. The brightness of the TFT screen is dynamically adjusted through the transmission status information to adapt to the current ambient lighting conditions and optimize the display of the read image information.
[0018] By adopting the above technical solution, the transmission rate of image information can be detected in real time according to the current display status of the TFT screen, thereby generating transmission status information to reflect dynamic changes in the transmission process. The refresh rate of the TFT screen can be adjusted in real time through the transmission status information, thereby ensuring smooth display of image information and avoiding screen freezes or delays. At the same time, by dynamically adjusting the screen brightness through the transmission status information, the display brightness of the TFT screen can be adapted to the current ambient lighting conditions, further optimizing the image display effect, thereby improving the user's viewing experience and visual comfort.
[0019] The second object of the invention is achieved by the following technical solutions: A data transmission control device based on the SPI communication protocol, the data transmission control device based on the SPI communication protocol comprising: The SPI initialization configuration module is used to obtain parameter information of SPI communication, and initialize and configure the SPI communication through the MCU according to the parameter information of the SPI communication to generate final configuration information of the chip select signal; An image information formatting and saving module, used to pre-format the image information according to the communication protocol of the TFT screen based on the final configuration information of the chip select signal to obtain formatted image information, and save the formatted image information into SPI-FLASH according to the structural sequence of the TFT screen communication protocol; The image information reading and display module is used to control the final configuration information of the chip select signal of SPI by the MCU after completing the initialization configuration and saving the formatted image information, read the formatted image information from the SPI-FLASH, and directly transmit the formatted image information to the TFT screen for display.
[0020] By adopting the above technical solution, SPI communication can be controlled by MCU to ensure that when reading the image data in SPI-FLASH, the image information has been pre-formatted according to the communication protocol of the TFT screen, so that the data can be directly transmitted to the TFT screen, avoiding the MCU's additional conversion or processing of the data. In this way, by standardizing the pixel arrangement and color format of the image information in the data preprocessing stage, the data layout in SPI-FLASH is completely matched with the display requirements of the TFT screen. During the data transmission process, the MCU only needs to send the data in SPI-FLASH to the TFT screen block by block according to the protocol sequence, without further intervention in the data format conversion, thereby ensuring the efficiency of data transmission. Through this direct transmission method, the data transmission rate and screen refresh rate are effectively improved, thereby achieving a smoother image display effect.
[0021] The third objective of the present application is achieved through the following technical solutions: A computer device comprises a memory, a processor and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the data transmission control method based on the SPI communication protocol are implemented.
[0022] The fourth objective of the present application is achieved through the following technical solutions: A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the data transmission control method based on the SPI communication protocol are implemented.
[0023] In summary, the present application includes at least one of the following beneficial technical effects: 1. The SPI communication can be controlled by MCU to ensure that when reading the image data in SPI-FLASH, the image information has been pre-formatted according to the communication protocol of the TFT screen, so that the data can be directly transmitted to the TFT screen, avoiding the MCU's additional conversion or processing of the data. In this way, by standardizing the pixel arrangement and color format of the image information in the data preprocessing stage, the data layout in SPI-FLASH is completely matched with the display requirements of the TFT screen. During the data transmission process, the MCU only needs to send the data in SPI-FLASH to the TFT screen block by block according to the protocol sequence, without further intervention in the data format conversion, thereby ensuring the efficiency of data transmission. Through this direct transmission method, the data transmission rate and screen refresh rate are effectively improved, thereby achieving a smoother image display effect; 2. Through the low level state of the chip select signal, the SPI-FLASH can enter the read mode and establish a stable communication channel with the MCU, thereby ensuring the connection reliability during data transmission; by obtaining and using the read channel information, the formatted image information can be read from the SPI-FLASH block by block according to the structural sequence of the TFT screen communication protocol, ensuring that the image data is read in the order of display requirements to avoid data confusion or repeated transmission; finally, the read image information is directly transmitted to the TFT screen to achieve smooth and delay-free image display; 3. The pixel arrangement of the image information can be adjusted and encoded according to the preliminary formatting information, so that the generated formatted image information matches the TFT screen communication protocol, thereby ensuring the consistency of the data format transmitted to the TFT screen and achieving efficient data docking; by writing the formatted image information block by block into the designated storage area of SPI-FLASH and recording the storage location information of each block, the position of each data block can be accurately located in the subsequent reading to avoid information confusion; at the same time, by verifying the writing status of each block of image information, it is ensured that the image information is completely saved in SPI-FLASH, thereby improving the reliability of data storage and the stability of subsequent display effects. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] Figure 1 It is a flow chart of a data transmission control method based on the SPI communication protocol in one embodiment of the present application; Figure 2 It is an implementation flow chart of step S10 in the data transmission control method based on the SPI communication protocol in one embodiment of the present application; Figure 3It is an implementation flow chart of step S20 in the data transmission control method based on the SPI communication protocol in one embodiment of the present application; Figure 4 It is an implementation flow chart of step S201 in the data transmission control method based on the SPI communication protocol in one embodiment of the present application; Figure 5 It is an implementation flow chart of step S2013 in the data transmission control method based on the SPI communication protocol in one embodiment of the present application; Figure 6 It is an implementation flow chart of step S30 in the data transmission control method based on the SPI communication protocol in one embodiment of the present application; Figure 7 It is a flowchart of the implementation after step S302 in the data transmission control method based on the SPI communication protocol in one embodiment of the present application; Figure 8 It is a principle block diagram of a data transmission control device based on the SPI communication protocol in one embodiment of the present application; Fig. 9 It is a schematic diagram of a device in an embodiment of the present application. DETAILED DESCRIPTION
[0025] The present application is further described in detail below in conjunction with the accompanying drawings.
[0026] In one embodiment, if Figure 1 As shown, the present application discloses a data transmission control method based on the SPI communication protocol, which specifically includes the following steps: S10: Acquire parameter information of SPI communication, and initialize and configure SPI communication through MCU according to the parameter information of SPI communication to generate final configuration information of chip select signal.
[0027] Specifically, when obtaining the parameter information of SPI communication, according to the model and communication protocol parameters of the SPI communication target device, first obtain parameter information including clock frequency, data transmission mode and chip select control mode, and load these parameter information into the chip select control register, clock control register and mode selection register of the MCU to ensure that the MCU can establish a reliable communication connection with the SPI-FLASH and keep it stable during the communication process. Then, set the chip select signal to a low level state, so that the SPI-FLASH enters the communication mode, and verify the response of each parameter item by item, including detecting whether the response of the chip select signal meets expectations, whether the clock frequency is within the communication range, and whether the data transmission mode is compatible with the TFT screen, to ensure that the configuration of the chip select signal and the SPI communication is completed, and finally form a valid state of the chip select signal, thereby generating the final configuration information of the chip select signal.
[0028] S20: Based on the final configuration information of the chip select signal, pre-format the image information according to the communication protocol of the TFT screen to obtain formatted image information, and save the formatted image information into the SPI-FLASH according to the structural sequence of the TFT screen communication protocol.
[0029] Specifically, based on the final configuration information of the chip select signal, when the image information is pre-formatted according to the communication protocol of the TFT screen, according to the communication protocol requirements of the TFT screen, the image information is first pre-processed for pixel arrangement and color coding, the pixels of the image information are arranged in the row and column order required by the screen, and the pixel information is converted into the specified format such as RGB565 or RGB888 required for screen display; after completing the conversion of the pixel arrangement and color format, the formatted image information is rearranged according to the data transmission sequence of the TFT screen communication protocol, and the information is saved in segments by data blocking. The size of each segment of information is adjusted according to the reading capability of the SPI-FLASH and the refresh rate of the TFT screen, so that the data block meets the refresh rhythm of the screen when reading, and all data blocks are stored in the continuous storage area of the SPI-FLASH in a structural order to ensure that the data maintains format consistency and transmission integrity when it is read subsequently.
[0030] S30: After completing the initialization configuration and saving the formatted image information, the MCU controls the final configuration information of the SPI chip select signal, reads the formatted image information from the SPI-FLASH, and directly transmits the formatted image information to the TFT screen for display.
[0031] Specifically, after completing the initialization configuration and saving the formatted image information, the MCU controls the final configuration information of the chip select signal of the SPI. When the formatted image information is read from the SPI-FLASH and directly transmitted to the TFT screen for display, the chip select signal is kept in a low level state to maintain the communication channel with the SPI-FLASH, so that the SPI-FLASH enters the information reading mode. The MCU reads the image information information block block by block according to the requirements of the TFT screen communication protocol, and ensures that the reading order of the information blocks is consistent with the screen display requirements. After reading the information block, the information block is directly transmitted to the TFT screen through the SPI interface. After receiving each information block, the TFT screen displays it row by row and column by column in the designated area to achieve a continuous display effect and ensure the integrity and smoothness of the displayed content. When the information blocks are transmitted and completed block by block, the last information block of the image information is written into the display area of the TFT screen, and the entire transmission and display process is completed.
[0032] In one embodiment, if Figure 2As shown, in step S10, the parameter information of the SPI communication is obtained, and the SPI communication is initialized and configured through the MCU according to the parameter information to generate the final configuration information of the chip select signal, including: S101: According to the target device information in the parameter information of the SPI communication, the chip select control register of the MCU is configured, the chip select pin of the SPI-FLASH is designated as the communication channel, and the initial configuration information of the chip select signal is generated.
[0033] Specifically, according to the target device information in the parameter information of the SPI communication, the MCU configures the chip select control register, firstly loads the required target device information into the internal register of the MCU, including the address information, communication channel number and register location information of the SPI-FLASH, sets the chip select pin of the SPI-FLASH as the only communication channel between the MCU, ensures that only the chip select signal is sent to the designated device during the communication process, sets the pin as a dedicated chip select port, and performs relevant settings, confirms whether the establishment of the chip select channel is valid by reading and writing each bit in the register, including whether the signal reception stability and channel mutual exclusivity meet the requirements, and once the verification is successful, completes the generation of the initial configuration information of the chip select signal to ensure that the dedicated channel configuration for subsequent communications is in place.
[0034] S102: Based on the initial configuration information, the level state of the chip select signal is set to a low level, the communication mode of the SPI-FLASH is activated, and the final configuration information of the chip select signal is generated.
[0035] Specifically, based on the initial configuration information, the level state of the chip select signal is set to a low level to activate the communication mode of the SPI-FLASH. First, the MCU controls the chip select pin to pull the level state of the chip select signal down from the default high level to enable the SPI-FLASH to enter an activated state. The low level state of the chip select signal is maintained continuously, indicating that the SPI-FLASH is the only device in the communication mode. During the activation process, the feedback signal of the chip select pin is monitored in real time to confirm the stability of the low level state and avoid fluctuations in the level state caused by external interference, thereby ensuring that the SPI-FLASH always remains in the selected state during the communication process and generating and locking the final configuration information of the chip select signal.
[0036] In one embodiment, if Figure 3 As shown, in step S20, i.e. based on the final configuration information of the chip select signal, the image information is pre-formatted according to the communication protocol of the TFT screen to obtain the formatted image information, and the formatted image information is saved in the SPI-FLASH according to the structural sequence of the TFT screen communication protocol, including: S201: According to the communication protocol of the TFT screen, the pixel arrangement of the image information and the format requirements of the image information are analyzed to generate preliminary formatting information that complies with the communication protocol of the TFT screen.
[0037] Specifically, when parsing the pixel arrangement and format requirements of the image information according to the communication protocol of the TFT screen, first, by reading the protocol standard of the TFT screen, key information such as pixel arrangement, color depth and transmission order is extracted, and this information is mapped to the storage structure of the image data. According to the pixel arrangement method in the protocol standard, such as horizontal scanning or vertical scanning requirements, the priority of the image pixel arrangement is determined, and the color coding requirements, such as RGB565 or RGB888 format, are extracted. According to the format requirements, the image information is converted to an appropriate bit depth, and the extracted arrangement rules and format standards are combined to form a set of preliminary formatting information suitable for TFT screen display, so as to ensure that the image information processed in subsequent steps can match the display requirements of the screen.
[0038] S202: According to the preliminary formatting information, the pixel arrangement of the image information is adjusted and encoded to obtain the formatted image information, and the formatted image information is saved in the SPI-FLASH according to the structural sequence of the TFT screen communication protocol.
[0039] Specifically, when adjusting and encoding the pixel arrangement of the image information according to the generated preliminary formatting information, the image data is first transformed into rows and columns, and the pixel arrangement is adjusted to the horizontal or vertical scanning order required by the TFT screen. The pixel data is gradually rearranged by traversing each row or column of the image, and then color depth encoding is performed to encode the pixel information into a color format that matches the TFT screen format. For example, 24-bit RGB data is compressed into a 16-bit RGB565 format or maintained in an RGB888 format. After color encoding is completed, all formatted image data are organized and stored in SPI-FLASH block by block according to the transmission order of the TFT screen communication protocol, ensuring that the arrangement order of the data blocks is consistent with the display order of the TFT screen, so that no additional conversion is required in the subsequent reading process, thereby achieving a fast and direct screen display effect.
[0040] In one embodiment, if Figure 4 As shown, in step S202, the pixel arrangement of the image information is adjusted and encoded according to the preliminary formatting information to obtain the formatted image information, and the formatted image information is saved in the SPI-FLASH according to the structural sequence of the TFT screen communication protocol, including: S2021: rearrange the pixel information of the image information according to the pixel arrangement requirements in the preliminary formatting information to generate adjusted pixel arrangement information, encode the adjusted pixel arrangement information to generate formatted image information matching the TFT screen communication protocol.
[0041] Specifically, when rearranging the pixel information of the image information according to the pixel arrangement requirements in the preliminary formatting information, firstly, the arrangement order of the pixels is determined by analyzing the preliminary formatting information, such as whether it needs to be arranged from left to right, from top to bottom or in other specific directions, and the pixel information is reorganized row by row or column by column according to the determined order to make it consistent with the display order of the TFT screen, and the color depth and color format in the pixel information are standardized and adjusted; after the arrangement adjustment is completed, the adjusted pixel arrangement information is encoded, and the original color format is converted into a format that meets the requirements of the TFT screen communication protocol, such as converting 24-bit RGB information into 16-bit RGB565 encoding, or encoding according to other formats required by the TFT screen, ensuring that the pixel arrangement and color encoding are compatible with the TFT screen protocol, and finally generating formatted image information to ensure the accuracy and integrity of the information in the subsequent SPI communication transmission and display process.
[0042] S2022: Write the formatted image information into the designated storage area of the SPI-FLASH block by block according to the structural sequence of the TFT screen communication protocol, and record the storage location information of each block of the formatted image information.
[0043] Specifically, when the formatted image information is written block by block into the designated storage area of SPI-FLASH according to the structural order of the TFT screen communication protocol, the formatted image information is first divided into a number of information blocks of the same size according to the protocol requirements, and the storage order and position information of each block of information are determined; in the write operation, each block of information is sequentially written into the designated storage address of SPI-FLASH through the SPI communication protocol, and the starting address and storage position offset of each block of information are recorded in real time during the writing process for subsequent positioning and verification, and the write feedback signal is checked after each block of information is written to ensure that the information block is successfully stored at the target address. If a write failure is detected, a rewrite operation is immediately performed until it succeeds, and the storage position information table is updated after successful writing to ensure that the physical storage position of each block of formatted image information is completely recorded, providing accurate position information support for subsequent information reading and verification.
[0044] S2023: Verify the writing status of each block of formatted image information according to the storage location information, and confirm that the formatted image information is saved in the SPI-FLASH.
[0045] Specifically, when verifying the writing status of each block of formatted image information according to the storage location information, the storage address of each block of information in the SPI-FLASH is read in turn, the physical address of each block of information is located according to the location information in the storage location information table, each block of information is extracted from the SPI-FLASH through a reading operation, and a bit-by-bit comparison and verification is performed with the content in the original formatted image information to confirm whether the information content is consistent; during the comparison process, the verification result of each block of information is recorded in real time, if inconsistent information is detected, the information block is marked as a write failure state, and the writing and verification operations are re-executed until the comparison results are consistent, thereby ensuring that each block of formatted image information is accurately saved in the SPI-FLASH, and finally confirming that all information blocks have been successfully written and are consistent with the original information.
[0046] In one embodiment, if Figure 5 As shown, in step S2023, the writing status of each block of formatted image information is verified according to the storage location information to confirm that the formatted image information is saved in the SPI-FLASH, including: S20231: Read the content of each block of formatted image information one by one according to the storage location information to generate verification information.
[0047] Specifically, according to the storage location information, the SPI communication instruction directly reads the content of the formatted image information block by block from the SPI-FLASH, and transmits it to the TFT screen in sequence in an order that complies with the TFT screen communication protocol. The MCU does not perform any data caching or additional transfer operations during this process, and directly reads and transmits each block of image information from the SPI-FLASH to the designated display area of the TFT screen to achieve continuous and efficient data transmission. To ensure a smooth transmission process, the MCU detects the status feedback of the SPI-FLASH chip select signal after each block of information is transmitted. If an abnormality occurs during the reading, such as unstable signal or low-level state interruption, the MCU resends the chip select signal to restore the stability of the communication channel. After completing the reading and transmission of all image information block by block, the data displayed on the TFT screen is guaranteed to be smooth, continuous and uninterrupted, meeting the efficient display requirements of direct transmission.
[0048] S20232: Compare the verification information with the preset information in the storage location information to identify the writing integrity of each block of formatted image information and obtain a comparison result.
[0049] Specifically, during the direct transmission of image information, the MCU monitors the stability of data transmission in real time by monitoring the transmission status of the SPI interface and the validity of the chip select signal, ensuring that the communication channel between the SPI-FLASH and the TFT screen always remains connected. When the level of the chip select signal remains low, the MCU continues to read and transmit image information to the TFT screen to achieve fast and continuous transmission. If the chip select signal is abnormal due to external interference or communication accidents, the MCU immediately triggers the operation of resending the chip select signal to restore the communication mode of the SPI-FLASH and ensure the continuity of subsequent transmissions, avoiding image display freezes or delays due to signal abnormalities, and ensuring the smoothness of the entire display process.
[0050] S20233: Based on the comparison result, confirm the writing status of each block of formatted image information to ensure that the formatted image information has been completely saved in the SPI-FLASH.
[0051] Specifically, after completing the direct transmission of all image information to the TFT screen, the MCU confirms the integrity of each data block during the transmission process based on the feedback information of the SPI communication status, and determines whether there are omissions or transmission errors in the transmission process by monitoring the status register of the SPI interface or receiving feedback information. If any incomplete or incomplete data transmission is detected, the MCU will mark the corresponding data block, re-read the data block from the SPI-FLASH and retransmit it to the TFT screen until all image information blocks are confirmed to be completely transmitted, to ensure that each information block received by the TFT screen is accurate.
[0052] In one embodiment, if Figure 6 As shown, in step S30, that is, after completing the initialization configuration and saving the formatted image information, the MCU controls the final configuration information of the chip select signal of the SPI, reads the formatted image information from the SPI-FLASH, and directly transmits the formatted image information to the TFT screen for display, including: S301: By controlling the low level state of the final configuration information of the chip select signal, the SPI-FLASH enters the read mode, a communication channel between the SPI-FLASH and the MCU is established, and the read channel information is obtained.
[0053] Specifically, by controlling the final configuration information of the chip select signal to keep it in a low level state, the SPI-FLASH is activated and enters the read mode, thereby establishing a communication channel with the MCU. At this time, the SPI-FLASH is ready to respond to the read request of the MCU. The MCU ensures the stability of the channel connectivity through continuous chip select signal control, and continuously maintains communication when the chip select signal is in a low level state. The read channel information is used to specify the data area that needs to be accessed in the SPI-FLASH, and ensure that the SPI-FLASH is only connected to the current MCU communication channel, laying the foundation for subsequent data transmission and completing the establishment of the read channel.
[0054] S302: Read the formatted image information from the SPI-FLASH block by block according to the read channel information and the structural sequence of the TFT screen communication protocol to generate the read image information.
[0055] Specifically, according to the read channel information, the MCU reads the formatted image information block by block from the SPI-FLASH in accordance with the structural order of the TFT screen communication protocol. The MCU reads the data block of the specified storage address from the SPI-FLASH and transmits it in the order required by the protocol. When reading each piece of information, the MCU directly obtains the content from the SPI-FLASH according to the TFT screen protocol without the need for additional caching or processing of the data. Each data block is organized and read in the format and order required by the screen display so that it can be directly transmitted to the display area of the TFT screen to generate the read image information, ensuring smooth connection of the image information during the transmission process and achieving continuous image display.
[0056] S303: Transmitting the read image information to the TFT screen to realize direct display of the read image information.
[0057] Specifically, after the read image information completes data decoding, it is immediately transmitted to the display buffer of the TFT screen through the SPI interface in a specified order. During the transmission process, the stability of the SPI communication is ensured by maintaining the low level state of the chip select signal, so that each frame of image information can be transmitted to the display area row by row and column by column according to the protocol requirements of the TFT screen, and the final pixel rendering and display are completed in the control circuit of the TFT screen. The entire transmission process is continuous and efficient, and does not require the MCU to further process or intervene in the data. The SPI interface directly matches the display protocol of the TFT screen during transmission to ensure the integrity and clarity of the image. When the image information is transmitted, the TFT screen automatically refreshes and displays the complete image content.
[0058] In one embodiment, if Figure 7 As shown, after step S303, the read image information is transmitted to the TFT screen to realize direct display of the read image information, and further includes: S3031: During the transmission process of the read image information, the transmission rate of the read image information is detected in real time according to the current display state of the TFT screen, and transmission state information is generated.
[0059] Specifically, during the transmission of image information, the MCU monitors the transmission rate of image data in real time by analyzing the display status information returned from the TFT screen. The acquired display status includes frame rate, current received data rate and delayed feedback. The transmission status information is dynamically generated based on these data. The MCU calculates and analyzes the received data. When the transmission rate deviates or differs from the preset threshold, the transmission status information is generated and the transmission status is marked as low speed or normal, so as to provide basic information support for subsequent refresh rate and brightness adjustment. The entire monitoring and generation process can ensure the stability of the transmission rate and make the image information transmission meet the display requirements of the TFT screen.
[0060] S3032: By transmitting status information, the refresh rate of the TFT screen is adjusted in real time to ensure smooth display of the image information after reading. By transmitting status information, the brightness of the TFT screen is dynamically adjusted to adapt to the current ambient lighting conditions and optimize the display of the image information after reading.
[0061] Specifically, after the MCU receives the transmission status information, it adjusts the display refresh rate in real time to maintain the smoothness of image transmission. For example, when the transmission rate decreases, the refresh rate is appropriately reduced to synchronize the image content with the transmission rhythm to avoid screen tearing or frame skipping. At the same time, during the brightness adjustment process, the MCU adjusts the brightness based on the transmission status information and the feedback information of the current ambient light to ensure that the display effect of the TFT screen can adapt to the ambient lighting conditions. When the light is weak, the brightness is reduced to avoid visual discomfort caused by excessive light, or the brightness is increased in a well-lit environment to ensure that the image is clearly visible. The entire refresh rate and brightness adjustment process is based on the transmission status information, thereby achieving stable and adaptive display of the image, ensuring that the visual effect and viewing experience of the final image are optimized.
[0062] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0063] In one embodiment, a data transmission control device based on the SPI communication protocol is provided, and the data transmission control device based on the SPI communication protocol corresponds one-to-one to the data transmission control method based on the SPI communication protocol in the above embodiment. Figure 8As shown, the data transmission control device based on the SPI communication protocol includes an SPI initialization configuration module, an image information formatting and storage module, and an image information reading and display module. The detailed description of each functional module is as follows: The SPI initialization configuration module is used to obtain the parameter information of the SPI communication, and initialize the SPI communication through the MCU according to the parameter information of the SPI communication to generate the final configuration information of the chip select signal; The image information formatting and saving module is used to pre-format the image information according to the communication protocol of the TFT screen based on the final configuration information of the chip selection signal to obtain the formatted image information, and save the formatted image information into the SPI-FLASH according to the structural sequence of the TFT screen communication protocol; The image information reading and display module is used to control the final configuration information of the SPI chip select signal by the MCU after completing the initialization configuration and saving the formatted image information, read the formatted image information from the SPI-FLASH, and directly transmit the formatted image information to the TFT screen for display.
[0064] Optionally, the SPI initialization configuration module includes: The chip select register configuration submodule is used to configure the chip select control register of the MCU according to the target device information in the parameter information of the SPI communication, specify the chip select pin of the SPI-FLASH as the communication channel, and generate the initial configuration information of the chip select signal; The chip select signal activation submodule is used to set the level state of the chip select signal to a low level based on the initial configuration information, activate the communication mode of the SPI-FLASH, and generate the final configuration information of the chip select signal.
[0065] Optionally, the image information formatting and saving module includes: The image information format parsing submodule is used to parse the pixel arrangement and format requirements of the image information according to the communication protocol of the TFT screen, and generate preliminary formatting information that complies with the communication protocol of the TFT screen; The formatting information storage submodule is used to adjust and encode the pixel arrangement of the image information according to the preliminary formatting information to obtain the formatted image information, and save the formatted image information into the SPI-FLASH according to the structural sequence of the TFT screen communication protocol.
[0066] Optionally, the formatting information storage submodule includes: A pixel arrangement adjustment unit, used for rearranging pixel information of the image information according to the pixel arrangement requirements in the preliminary formatting information, generating adjusted pixel arrangement information, encoding the adjusted pixel arrangement information, and generating formatted image information matching the TFT screen communication protocol; The formatted information writing unit is used to write the formatted image information into the designated storage area of the SPI-FLASH block by block according to the structural sequence of the TFT screen communication protocol, and record the storage location information of each block of the formatted image information; The information writing verification unit is used to verify the writing status of each block of formatted image information according to the storage location information, and confirm that the formatted image information is saved in the SPI-FLASH.
[0067] Optionally, the information writing verification unit includes: The information reading subunit is used to read the content of each block of formatted image information one by one according to the storage location information to generate verification information; The verification and comparison subunit is used to compare the verification information with the preset information in the storage location information, identify the writing integrity of each block of formatted image information, and obtain a comparison result; The write status confirmation subunit is used to confirm the write status of each block of formatted image information based on the comparison result, and ensure that the formatted image information has been completely saved in the SPI-FLASH.
[0068] Optionally, the image information reading and display module includes: The read channel establishment submodule is used to make the SPI-FLASH enter the read mode by controlling the low level state of the final configuration information of the chip select signal, establish the communication channel between the SPI-FLASH and the MCU, and obtain the read channel information; The block-by-block reading submodule is used to read the formatted image information from the SPI-FLASH block by block according to the reading channel information and the structural sequence of the TFT screen communication protocol to generate the read image information; The direct display submodule is used to transmit the read image information to the TFT screen to realize the direct display of the read image information.
[0069] Optionally, directly displaying the submodule also includes: A transmission rate detection unit is used to detect the transmission rate of the read image information in real time according to the current display state of the TFT screen during the transmission process of the read image information, and generate transmission state information; The refresh rate adjustment and brightness dynamic adjustment unit is used to adjust the refresh rate of the TFT screen in real time by transmitting status information to ensure smooth display of the image information after reading, and dynamically adjust the brightness of the TFT screen by transmitting status information to adapt to the current ambient lighting conditions and optimize the display of the image information after reading.
[0070] For the specific definition of the data transmission control device based on the SPI communication protocol, please refer to the definition of the data transmission control method based on the SPI communication protocol above, which will not be repeated here. Each module in the above-mentioned data transmission control device based on the SPI communication protocol can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0071] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Fig. 9 As shown. The computer device includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a data transmission control method based on the SPI communication protocol is implemented.
[0072] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the computer program: Obtain the parameter information of SPI communication, and initialize and configure the SPI communication through the MCU according to the parameter information of SPI communication to generate the final configuration information of the chip select signal; Based on the final configuration information of the chip selection signal, the image information is pre-formatted according to the communication protocol of the TFT screen to obtain the formatted image information, and the formatted image information is saved in the SPI-FLASH according to the structural sequence of the TFT screen communication protocol; After completing the initialization configuration and saving the formatted image information, the MCU controls the final configuration information of the SPI chip select signal, reads the formatted image information from the SPI-FLASH, and directly transmits the formatted image information to the TFT screen for display.
[0073] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented: Obtain the parameter information of SPI communication, and initialize and configure the SPI communication through the MCU according to the parameter information of SPI communication to generate the final configuration information of the chip select signal; Based on the final configuration information of the chip selection signal, the image information is pre-formatted according to the communication protocol of the TFT screen to obtain the formatted image information, and the formatted image information is saved in the SPI-FLASH according to the structural sequence of the TFT screen communication protocol; After completing the initialization configuration and saving the formatted image information, the MCU controls the final configuration information of the SPI chip select signal, reads the formatted image information from the SPI-FLASH, and directly transmits the formatted image information to the TFT screen for display.
[0074] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0075] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0076] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A data transmission control method based on SPI communication protocol, characterized in that: The data transmission control method based on the SPI communication protocol includes: Acquire parameter information of SPI communication, and initialize and configure SPI communication through MCU according to the parameter information of SPI communication to generate final configuration information of chip select signal; Based on the final configuration information of the chip select signal, pre-formatting the image information according to the communication protocol of the TFT screen to obtain formatted image information, and saving the formatted image information into the SPI-FLASH according to the structural sequence of the TFT screen communication protocol; After completing the initialization configuration and saving the formatted image information, the MCU controls the final configuration information of the chip select signal of the SPI, reads the formatted image information from the SPI-FLASH, and directly transmits the formatted image information to the TFT screen for display.
2. The data transmission control method based on the SPI communication protocol according to claim 1, characterized in that: The acquiring parameter information of the SPI communication and initializing the configuration of the SPI communication through the MCU according to the parameter information to generate final configuration information of the chip select signal includes: According to the target device information in the parameter information of the SPI communication, the chip select control register of the MCU is configured, the chip select pin of the SPI-FLASH is designated as the communication channel, and the initial configuration information of the chip select signal is generated; Based on the initial configuration information, the level state of the chip select signal is set to a low level, the communication mode of the SPI-FLASH is activated, and the final configuration information of the chip select signal is generated.
3. The data transmission control method based on the SPI communication protocol according to claim 1, characterized in that: The final configuration information based on the chip select signal pre-formats the image information according to the communication protocol of the TFT screen to obtain the formatted image information, and saves the formatted image information in the SPI-FLASH according to the structural sequence of the TFT screen communication protocol, including: According to the communication protocol of the TFT screen, the pixel arrangement of the image information and the format requirements of the image information are analyzed to generate preliminary formatting information that complies with the communication protocol of the TFT screen; According to the preliminary formatting information, the pixel arrangement of the image information is adjusted and encoded to obtain the formatted image information, and the formatted image information is saved in the SPI-FLASH according to the structural sequence of the TFT screen communication protocol.
4. The data transmission control method based on the SPI communication protocol according to claim 3 is characterized in that: The method of adjusting and encoding the pixel arrangement of the image information according to the preliminary formatting information to obtain the formatted image information, and saving the formatted image information in the SPI-FLASH according to the structural sequence of the TFT screen communication protocol includes: According to the pixel arrangement requirements in the preliminary formatting information, rearrange the pixel information of the image information to generate adjusted pixel arrangement information, perform encoding processing on the adjusted pixel arrangement information to generate the formatted image information matching the TFT screen communication protocol; Writing the formatted image information into the designated storage area of the SPI-FLASH block by block according to the structural sequence of the TFT screen communication protocol, and recording the storage location information of each block of the formatted image information; The writing status of each block of the formatted image information is verified according to the storage location information to confirm that the formatted image information is saved in the SPI-FLASH.
5. The data transmission control method based on the SPI communication protocol according to claim 4, characterized in that: The step of verifying the writing status of each block of the formatted image information according to the storage location information to confirm that the formatted image information is saved in the SPI-FLASH includes: Reading the content of each block of the formatted image information one by one according to the storage location information to generate verification information; Comparing the verification information with the preset information in the storage location information, identifying the writing integrity of each block of formatted image information, and obtaining a comparison result; Based on the comparison result, the writing status of each block of the formatted image information is confirmed to ensure that the formatted image information has been completely saved in the SPI-FLASH.
6. The data transmission control method based on the SPI communication protocol according to claim 1, characterized in that: After completing the initialization configuration and saving the formatted image information, the MCU controls the final configuration information of the chip select signal of the SPI, reads the formatted image information from the SPI-FLASH, and directly transmits the formatted image information to the TFT screen for display, including: By controlling the low level state of the final configuration information of the chip select signal, the SPI-FLASH is put into a read mode, a communication channel between the SPI-FLASH and the MCU is established, and read channel information is obtained; According to the read channel information, the formatted image information is read block by block from the SPI-FLASH in accordance with the structural sequence of the TFT screen communication protocol to generate the read image information; The read image information is transmitted to the TFT screen to realize direct display of the read image information.
7. The data transmission control method based on the SPI communication protocol according to claim 1, characterized in that: The method of transmitting the read image information to the TFT screen to realize direct display of the read image information further includes: During the transmission process of the read image information, the transmission rate of the read image information is detected in real time according to the current display state of the TFT screen, and the transmission state information is generated; The refresh rate of the TFT screen is adjusted in real time through the transmission status information to ensure smooth display of the read image information. The brightness of the TFT screen is dynamically adjusted through the transmission status information to adapt to the current ambient lighting conditions and optimize the display of the read image information.
8. A data transmission control device based on SPI communication protocol, characterized in that: The data transmission control device based on the SPI communication protocol includes: The SPI initialization configuration module is used to obtain parameter information of SPI communication, and initialize and configure the SPI communication through the MCU according to the parameter information of the SPI communication to generate final configuration information of the chip select signal; An image information formatting and saving module, used to pre-format the image information according to the communication protocol of the TFT screen based on the final configuration information of the chip select signal to obtain formatted image information, and save the formatted image information into SPI-FLASH according to the structural sequence of the TFT screen communication protocol; The image information reading and display module is used to control the final configuration information of the chip select signal of SPI by the MCU after completing the initialization configuration and saving the formatted image information, read the formatted image information from the SPI-FLASH, and directly transmit the formatted image information to the TFT screen for display.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the data transmission control method based on the SPI communication protocol are implemented as described in any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the data transmission control method based on the SPI communication protocol as described in any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Interface protocol display method and system and storage medium
CN116614566A
Display system, reference monitor, and display control method and device
CN116847157A
Display system and reference monitor
CN116916100A
Image display method and device based on ink screen, medium and product
CN119028289A
Driving integrated circuit and upate method thereof
US20140215110A1
Cited By
Vehicle firmware upgrading method, vehicle machine system and vehicle
CN120447937A