Add SPI and I2C as communication interfaces. How?

Hi, is there any particolar reason for not using SPI and I2C as communication interfaces? It would simplify a lot my control box cabling and in general SPI/I2C were born as inter-mcu protocols so doesn’t look like a bad idea. I am aware there are some inconsistencies between different implementations of those protocols, so can be a bit tricky to make them work for any mcu; but still, It should be possible.
Am I missing something?

I’m having a look at the code and seems like currently the interface selection is at compile time. Is it possible to make it at run time? Something like:

  • define at compile time a boot interface and a run interface.
  • start on boot interface and test the run interface.
  • if the boot interface is connected, the test on run interface is halted
  • if the run interface is connected the boot interface is disabled.

I’d like to get some tips on how developers would like for this thing to be done, before I start chopping current code into something else.


I hope this approach can make it.

commit b301c876f687768de4ff2df51a99ba85c7c107c0 (HEAD -> flexcoms, origin/flexcoms)
Author: aneetchang <...>
Date:   Fri Sep 2 23:10:59 2022 +0200

    (atmega2560 only) Kconfig options for runtime interface selection

    generic serial_enable_tx_irq() renamed to enable_tx_irq,
    enable_tx_irq is a function pointer now,
    all archs (on serial init) assign their own serial_enable_tx_irq to enable_tx_irq

    slave code added to avr/spi.c