摘要 |
A method for controlling multiple CAN interfaces by using a single-SPI bus comprises: when a receipt mail of any one of multiple CAN chips completes the receiving of data on a CA bus, triggering interruption of the CAN chips; instructing, by using an SPI bus, the interrupted CAN chips to disable the interrupt enable and exit from the interruption; querying the data received by the receipt mails of all CAN chips interrupted by triggering, reading the data to a buffer of a micro controller unit, setting a data identifier in the buffer, and restoring the interrupt enable of the CAN chips interrupted by triggering, so that the CAN chips interrupted by triggering continue to receive data; an application checking whether the buffer has the data identifier, if yes, copying the data identifier to an application buffer, and otherwise, returning a failure message. The solution does not affect the communication and further reduces the cost. |