Controller port expansion device and method
By establishing communication and DMA transmission modes between controllers and using virtual mapping tables to implement port expansion, the problem of insufficient pins of existing controllers is solved, logic is simplified and system reliability is improved, making it suitable for complex smart cockpits. Control needs.
Patent Information
- Application Number
- CN202210188482.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-02-28
- Publication Date
- 2024-09-13
- Estimated Expiration
- 2042-02-28
AI Technical Summary
The number of pins of the existing controller is not enough to meet the needs of the complex control system of the intelligent cockpit, resulting in difficulty in timing synchronization, complex logic and poor maintainability when multiple controllers are controlled in parallel.
A controller port expansion device is designed. By establishing communication and DMA transmission modes between master and slave controllers, the virtual mapping table and DMA controller are used to implement port expansion, simplify logic and improve system reliability.
It realizes the expansion of controller ports, has simple logic and high system reliability, avoids the complexity of multi-controller coordination and timing synchronization difficulties, and improves the performance and maintainability of the system.
Smart Images

Figure CN114741343B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of controllers, and in particular to a controller port expansion device and method. Background Art
[0002] With the continuous development of automotive electronic technology, the cockpit has evolved from a traditional cockpit with a single function to a multi-screen interactive intelligent cockpit. The intelligent cockpit integrates more and more functions, the system control is becoming more and more complex, and the number of monitored I / O ports is increasing, so the controller also needs to be more powerful. However, the number of pins in the current controller is not enough to meet the needs of the complex control system of the intelligent cockpit.
[0003] To solve this technical problem, the method of parallel control of multiple controllers is generally adopted. However, this solution has difficulty in timing synchronization and coordination between multiple controllers, and the logic is complex, resulting in long software code and poor maintainability. Summary of the invention
[0004] The present invention provides a controller port expansion device and method, aiming to solve the defects in the prior art, realize the port expansion of the controller, and has simple logic and high system reliability.
[0005] In order to achieve the above object, the technical solution adopted by the present invention is:
[0006] In one aspect, the present invention provides a controller port expansion device, comprising:
[0007] A first communication module, a first storage module, a first DMA controller, and a parameter read-write module are arranged in the first controller; a second communication module, a second storage module, a second DMA controller, a copy module, and an I / O read-write module are arranged in the second controller;
[0008] The first DMA controller is connected to the first communication module and the first storage module, and the first storage module is also connected to the parameter read-write module; the second DMA controller is connected to the second communication module and the second storage module, and the second storage module is also connected to the copy module and the I / O read-write module; the first communication module is connected to the second communication module;
[0009] The first communication module and the second communication module are used to establish communication between the first controller and the second controller, and have two modes: a normal communication mode and a DMA transmission mode;
[0010] The first DMA controller and the second DMA controller are used to control the sending and receiving of data when the first communication module and the second communication module operate in the DMA transmission mode;
[0011] The first storage module includes a first storage unit, and the second storage module includes a third storage unit and a fourth storage unit;
[0012] The first storage unit is used to store a first virtual mapping table of each I / O port of the second controller;
[0013] The third storage unit is used to store a second virtual mapping table of each I / O port of the second controller;
[0014] The fourth storage unit is used to cache the target I / O port parameters acquired by the third storage unit and the PIN status register and PIN value written into each I / O port of the second controller;
[0015] The parameter reading and writing module is used to write the target I / O port parameters of the second controller into the first virtual mapping table;
[0016] The copy module is used to copy the target I / O port parameters acquired by the third storage unit to the fourth storage unit;
[0017] The I / O read / write module is used to write the target I / O port parameters into the corresponding I / O port.
[0018] Furthermore, the controller port expansion device also includes:
[0019] A second storage unit provided in the first storage module, used for storing a backup of the first virtual mapping table;
[0020] The parameter backup module connected to the first storage unit and the second storage unit is used to back up the current first virtual mapping table to the second storage unit before rewriting the first virtual mapping table.
[0021] Furthermore, the controller port expansion device also includes:
[0022] An edge detection module connected to the receiving signal line of the second communication module, an interrupt event module connected to the edge detection module, and a timing module connected to the interrupt event module and the second DMA controller;
[0023] The edge detection module is used to detect the signal edge on the receiving signal line of the second communication module;
[0024] The interrupt event module is used to generate an interrupt and an event when a preset signal edge is detected;
[0025] The timing module is used to start timing after receiving an interruption and an event, and generate a timing interrupt after the timing times out.
[0026] Specifically, the edge detection module is an I / O port configured in external interrupt mode.
[0027] Specifically, the first controller is a master controller, and the second controller is a slave controller.
[0028] Another aspect of the present invention provides a controller port expansion method, comprising:
[0029] Step 1: presetting a first virtual mapping table and a second virtual mapping table in the first controller and the second controller respectively;
[0030] Step 2: the first controller writes the first virtual mapping table into the first storage module, and controls the second controller to start, and the second controller writes the second virtual mapping table into the second storage module;
[0031] Step 3, the first controller receives target I / O port parameters;
[0032] Step 4: the first controller modifies the first virtual mapping table according to the target I / O port parameters, and notifies the second controller to read the first virtual mapping table;
[0033] Step 5: The first controller sends the first virtual mapping table, and the second controller receives the first virtual mapping table and stores it in a second storage module of the second controller;
[0034] Step 6: The second controller compares the first virtual mapping table with the second virtual mapping table, and obtains the target I / O port parameter for caching;
[0035] Step 7: The second controller reads the cache and writes the target I / O port parameters to the corresponding I / O port.
[0036] Furthermore, after step 3 and before step 4, the method further includes:
[0037] Step 31: The first controller backs up the first virtual mapping table.
[0038] Furthermore, after step 7, the method further includes:
[0039] Step 8: When the first controller determines that the system is in an idle state, the second controller is controlled to shut down and the first controller is controlled to enter sleep mode.
[0040] Specifically, the first controller sending the first virtual mapping table includes:
[0041] Step A: If the first controller determines that the data volume of the target I / O port parameter exceeds a preset threshold, or the first controller determines that the usage rate of the first controller and / or the second controller is higher than a preset usage rate threshold, the first controller and the second controller are controlled to enter the DMA transmission mode and proceed to the next step, otherwise the first controller sends the first virtual mapping table in the normal communication mode of the communication module;
[0042] Step B, the first controller sends the first virtual mapping table to the second controller in DMA transmission mode;
[0043] Step C: the second controller receives the first virtual mapping table in DMA mode.
[0044] Specifically, the step C comprises:
[0045] Step c1, setting any I / O port of the second controller to an external interrupt mode, and connecting it to a receiving signal line of the communication module of the second controller;
[0046] Step c2, determine whether a preset signal edge is detected, if yes, generate an interrupt and event and proceed to the next step, otherwise, execute this step in a loop;
[0047] Step c3, controlling the timing module of the second controller to start working and clearing the timer;
[0048] Step c4, determine whether the timing module generates a timing interrupt, if yes, turn off the timing module, process the received data, and reset the DMA controller of the second controller, otherwise return to step c2.
[0049] The beneficial effects of the present invention are as follows: the present invention pre-sets a first virtual mapping table and a second virtual mapping table, receives target I / O port parameters, modifies the first virtual mapping table according to the target I / O port parameters, then compares the first virtual mapping table with the second virtual mapping table to obtain the target I / O port parameters, and then changes the state of the corresponding I / O port according to the target I / O port parameters, thereby realizing port expansion of the controller, and the logic is simple and the system reliability is high. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] Figure 1 is a schematic structural diagram of a controller port expansion device of the present invention;
[0051] Figure 2 is another structural schematic diagram of the controller port expansion device of the present invention;
[0052] Figure 3 is a schematic diagram of a first storage module and a second storage module of the present invention;
[0053] Figure 4 It is another structural schematic diagram of the controller port expansion device of the present invention. DETAILED DESCRIPTION
[0054] The following specifically describes the implementation modes of the present invention in conjunction with the accompanying drawings, which are only used for reference and illustration and do not constitute a limitation on the scope of patent protection of the present invention.
[0055] Example 1
[0056] like Figure 1 As shown, this embodiment provides a controller port expansion device, including:
[0057] A first communication module, a first storage module, a first DMA controller, and a parameter read-write module are arranged in the first controller; a second communication module, a second storage module, a second DMA controller, a copy module, and an I / O read-write module are arranged in the second controller;
[0058] The first DMA controller is connected to the first communication module and the first storage module, and the first storage module is also connected to the parameter read-write module; the second DMA controller is connected to the second communication module and the second storage module, and the second storage module is also connected to the copy module and the I / O read-write module; the first communication module is connected to the second communication module;
[0059] The first communication module and the second communication module are used to establish communication between the first controller and the second controller, and have two modes: a normal communication mode and a DMA transmission mode;
[0060] The first DMA controller and the second DMA controller are used to control the sending and receiving of data when the first communication module and the second communication module operate in the DMA transmission mode;
[0061] The first storage module includes a first storage unit, and the second storage module includes a third storage unit and a fourth storage unit;
[0062] The first storage unit is used to store a first virtual mapping table of each I / O port of the second controller;
[0063] The third storage unit is used to store a second virtual mapping table of each I / O port of the second controller;
[0064] The fourth storage unit is used to cache the target I / O port parameters acquired by the third storage unit and the PIN status register and PIN value written into each I / O port of the second controller;
[0065] The parameter reading and writing module is used to write the target I / O port parameters of the second controller into the first virtual mapping table;
[0066] The copy module is used to copy the target I / O port parameters acquired by the third storage unit to the fourth storage unit;
[0067] The I / O read / write module is used to write the target I / O port parameters into the corresponding I / O port.
[0068] In this embodiment, the first controller is a master controller, and the second controller is a slave controller.
[0069] In this embodiment, the first storage module and the second storage module are SRAMs on-chip of the first controller and the second controller.
[0070] In this embodiment, the first virtual mapping table and the second virtual mapping table are the same, and include: a PIN address, a PIN status register, and a PIN value of each I / O port of the second controller.
[0071] For example, the PIN addresses of each I / O port of the second controller are 0x2000 to 0x2100; the PIN status register is the status register value that controls the working mode of the I / O port, for example, 0x0001 represents the I / O output mode, Ox0010 represents the A / D mode, etc.; the PIN value is related to the working mode of the I / O port, for example, when the I / O port works in the I / O output mode, the PIN value is a logic high level 1 or a low level 0; when the I / O port works in the A / D mode, the PIN value is a specific A / D value, and so on.
[0072] In this embodiment, the target I / O port parameters are parameters of the I / O port of the second controller that the first controller wants to control and modify, including port working mode, port value, etc.
[0073] When the first controller wants to modify the parameters of an I / O port of the second controller, the first controller writes the I / O port parameters into the virtual mapping table in the first storage unit. The second controller can directly read the data of the first storage unit of the first controller through the communication I / O, store it in the third storage unit of the second controller, and copy it to the fourth storage unit. The I / O read-write module writes it into the corresponding I / O port, thereby realizing the first controller's control over the I / O port of the second controller.
[0074] like Figure 2 As shown, in another embodiment of the present invention, the controller port expansion device further includes:
[0075] A second storage unit provided in the first storage module, used for storing a backup of the first virtual mapping table;
[0076] The parameter backup module connected to the first storage unit and the second storage unit is used to back up the current first virtual mapping table to the second storage unit before rewriting the first virtual mapping table.
[0077] The relationship between the first storage module, the second storage module, and the first storage unit, the second storage unit, the third storage unit, and the fourth storage unit of the present invention is as follows: Figure 3 shown.
[0078] The GPIO port register and the virtual mapping table of the controller are stored in the first storage module and the second storage module. The GPIO register of the second controller is stored in the first virtual mapping table of the first storage module by mapping. In this way, the purpose of changing the GPIO register of the second controller can be achieved by modifying the first virtual mapping table, thereby realizing the control of the I / O port of the second controller.
[0079] Example 2
[0080] like Figure 4 As shown, different from Embodiment 1, the controller port expansion device provided in this embodiment further includes:
[0081] An edge detection module connected to the receiving signal line of the second communication module, an interrupt event module connected to the edge detection module, and a timing module connected to the interrupt event module and the second DMA controller;
[0082] The edge detection module is used to detect the signal edge on the receiving signal line of the second communication module;
[0083] The interrupt event module is used to generate an interrupt and an event when a preset signal edge is detected;
[0084] The timing module is used to start timing after receiving an interruption and an event, and generate a timing interrupt after the timing times out.
[0085] In this embodiment, the edge detection module is an I / O port configured in external interrupt mode.
[0086] In this embodiment, the preset signal edge is a rising edge or a falling edge.
[0087] In a specific implementation, an I / O port (for example, I / O0) of the second controller is set to an external interrupt mode and connected to the signal receiving pin of the second communication module. When I / O0 detects a signal edge (for example, a falling edge) at which data transmission starts, the interrupt event module generates an interrupt and the timing module starts working. When I / O0 detects a falling edge, an event is generated at the same time. After receiving the event, the timing module clears the timer to prevent a timing interrupt from being generated. After the timing module generates a timing interrupt, the timing module is turned off, the received data is processed, and the second DMA controller is reset.
[0088] By setting the above modules, the defect that the DMA transfer mode can only receive data of fixed length is overcome, and the reception of data of arbitrary length can be achieved, thereby further improving the system performance.
[0089] Example 3
[0090] This embodiment provides a controller port expansion method, including:
[0091] Step 1: Preset a first virtual mapping table and a second virtual mapping table in the first controller and the second controller respectively.
[0092] Step 2: The first controller writes the first virtual mapping table into a first storage module, and controls the second controller to start up, and the second controller writes the second virtual mapping table into a second storage module.
[0093] In this embodiment, the first virtual mapping table is the same as the second virtual mapping table.
[0094] Step 3: The first controller receives target I / O port parameters.
[0095] Step 4: The first controller modifies the first virtual mapping table according to the target I / O port parameters, and notifies the second controller to read the first virtual mapping table.
[0096] Step 5: The first controller sends the first virtual mapping table, and the second controller receives the first virtual mapping table and stores it in a second storage module of the second controller.
[0097] In this embodiment, the first controller sending the first virtual mapping table includes:
[0098] Step A: If the first controller determines that the data volume of the target I / O port parameter exceeds a preset threshold, or the first controller determines that the usage rate of the first controller and / or the second controller is higher than a preset usage rate threshold, the first controller and the second controller are controlled to enter the DMA transfer mode and proceed to the next step; otherwise, the first controller sends the first virtual mapping table in the normal communication mode of the communication module.
[0099] Step B: The first controller sends the first virtual mapping table to the second controller in DMA transmission mode.
[0100] Step C: the second controller receives the first virtual mapping table in DMA mode.
[0101] In this embodiment, step C includes:
[0102] Step c1, setting any I / O port of the second controller to an external interrupt mode, and connecting it to a receiving signal line of the communication module of the second controller;
[0103] Step c2, determine whether a preset signal edge is detected, if yes, generate an interrupt and event and proceed to the next step, otherwise, execute this step in a loop;
[0104] Step c3, controlling the timing module of the second controller to start working and clearing the timer;
[0105] Step c4, determine whether the timing module generates a timing interrupt, if yes, turn off the timing module, process the received data, and reset the DMA controller of the second controller, otherwise return to step c2.
[0106] Step 6: The second controller compares the first virtual mapping table with the second virtual mapping table, and obtains the target I / O port parameters for caching.
[0107] Step 7: The second controller reads the cache and writes the target I / O port parameters to the corresponding I / O port.
[0108] In another embodiment of the present invention, after step 3 and before step 4, the method further includes:
[0109] Step 31: The first controller backs up the first virtual mapping table.
[0110] In another embodiment of the present invention, after step 7, the method further includes:
[0111] Step 8: When the first controller determines that the system is in an idle state, the second controller is controlled to shut down and the first controller is controlled to enter sleep mode.
[0112] When in an idle state, the first controller enters sleep mode and the second controller enters shutdown mode, which can effectively reduce the standby current of the system.
[0113] The above disclosure is only a preferred embodiment of the present invention, which cannot be used to limit the scope of protection of the present invention. Therefore, equivalent changes made according to the scope of the patent application of the present invention are still within the scope covered by the present invention.
Claims
1. A controller port expansion device, characterized in that: include: A first communication module, a first storage module, a first DMA controller, and a parameter reading and writing module are arranged in the first controller; A second communication module, a second storage module, a second DMA controller, a copy module, and an I / O read / write module are arranged in the second controller; The first DMA controller is connected to the first communication module and the first storage module, and the first storage module is also connected to the parameter read-write module; the second DMA controller is connected to the second communication module and the second storage module, and the second storage module is also connected to the copy module and the I / O read-write module; the first communication module is connected to the second communication module; The first communication module and the second communication module are used to establish communication between the first controller and the second controller, and have two modes: a normal communication mode and a DMA transmission mode; The first DMA controller and the second DMA controller are used to control the sending and receiving of data when the first communication module and the second communication module operate in the DMA transmission mode; The first storage module includes a first storage unit, and the second storage module includes a third storage unit and a fourth storage unit; The first storage unit is used to store a first virtual mapping table of each I / O port of the second controller; The third storage unit is used to store a second virtual mapping table of each I / O port of the second controller; The fourth storage unit is used to cache the target I / O port parameters acquired by the third storage unit and the PIN status register and PIN value written into each I / O port of the second controller; The parameter reading and writing module is used to write the target I / O port parameters of the second controller into the first virtual mapping table; The copy module is used to copy the target I / O port parameters acquired by the third storage unit to the fourth storage unit; The I / O read / write module is used to write the target I / O port parameters into the corresponding I / O port.
2. The controller port expansion device according to claim 1, characterized in that: The controller port expansion device also includes: A second storage unit provided in the first storage module, used for storing a backup of the first virtual mapping table; The parameter backup module connected to the first storage unit and the second storage unit is used to back up the current first virtual mapping table to the second storage unit before rewriting the first virtual mapping table.
3. The controller port expansion device according to claim 1, characterized in that: The controller port expansion device also includes: An edge detection module connected to the receiving signal line of the second communication module, an interrupt event module connected to the edge detection module, and a timing module connected to the interrupt event module and the second DMA controller; The edge detection module is used to detect the signal edge on the receiving signal line of the second communication module; The interrupt event module is used to generate an interrupt and an event when a preset signal edge is detected; The timing module is used to start timing after receiving an interruption and an event, and generate a timing interrupt after the timing times out.
4. The controller port expansion device according to claim 3, characterized in that: The edge detection module is an I / O port configured in external interrupt mode.
5. The controller port expansion device according to any one of claims 1 to 4, characterized in that: The first controller is a master controller, and the second controller is a slave controller.
6. A controller port expansion method, characterized in that: include: Step 1: presetting a first virtual mapping table and a second virtual mapping table in the first controller and the second controller respectively; Step 2: The first controller writes the first virtual mapping table into a first storage module, and controls the second controller to start, and the second controller writes the second virtual mapping table into a second storage module; Step 3, the first controller receives target I / O port parameters; Step 4: the first controller modifies the first virtual mapping table according to the target I / O port parameters, and notifies the second controller to read the first virtual mapping table; Step 5: The first controller sends the first virtual mapping table, and the second controller receives the first virtual mapping table and stores it in a second storage module of the second controller; Step 6: The second controller compares the first virtual mapping table with the second virtual mapping table, and obtains the target I / O port parameter for caching; Step 7: The second controller reads the cache and writes the target I / O port parameters to the corresponding I / O port.
7. The controller port expansion method according to claim 6, characterized in that: After step 3 and before step 4, the method further includes: Step 31: The first controller backs up the first virtual mapping table.
8. The controller port expansion method according to claim 6, characterized in that: After step 7, the method further includes: Step 8: When the first controller determines that the system is in an idle state, the second controller is controlled to shut down and the first controller is controlled to enter sleep mode.
9. The controller port expansion method according to claim 6, characterized in that: The first controller sending the first virtual mapping table includes: Step A: If the first controller determines that the data volume of the target I / O port parameter exceeds a preset threshold, or the first controller determines that the usage rate of the first controller and / or the second controller is higher than a preset usage rate threshold, the first controller and the second controller are controlled to enter the DMA transmission mode and proceed to the next step, otherwise the first controller sends the first virtual mapping table in the normal communication mode of the communication module; Step B, the first controller sends the first virtual mapping table to the second controller in DMA transmission mode; Step C: The second controller receives the first virtual mapping table in DMA mode.
10. The controller port expansion method according to claim 9, characterized in that: The step C comprises: Step c1, setting any I / O port of the second controller to an external interrupt mode, and connecting it to a receiving signal line of the communication module of the second controller; Step c2, determine whether a preset signal edge is detected, if yes, generate an interrupt and event and proceed to the next step, otherwise, execute this step in a loop; Step c3, controlling the timing module of the second controller to start working and clearing the timer; Step c4, determine whether the timing module generates a timing interrupt, if yes, turn off the timing module, process the received data, and reset the DMA controller of the second controller, otherwise return to step c2.
