I'm curious if anyone has experience with or knows what would be the "best practice" for implementing a driver for two devices on a shared SPI bus. Basically, I have two radio chips (AX5043) on one SPI bus, and I'm writing a ChibiOS style driver for them. Both chips provide an IRQ signal, and I'd like the driver to handle these with a "palcallback_t". The argument is the AX5043Driver struct, which contains an AX5043Config containing SPIDriver and SPIConfig, as shown (abbreviated) here:
Code: Select all
struct AX5043Driver {
const struct AX5043Config *config;
...
};
struct AX5043Config {
SPIDriver *spip;
const SPIConfig *spicfg;
ioline_t irq;
...
};
The issue I am running into is, there's no real way from the IRQ context of a "palcallback_t" to ensure I am initiating a SPI transaction using the correct SPIConfig and also "Acquiring" the bus from the interrupt context because I can't invoke "spiAcquireBus(spip);" and "spiStart(((AX5043Driver*)arg)->config->spip, ((AX5043Driver*)arg)->config->spicfg);" from this context.
Is there a best practice for implementing a shared SPI bus architecture when both devices share an IRQ handler callback? The ultimate goal is to receive data from the AX5043's IRQ register and handle it for the correct device.