I have been implementing device driver for the SPI peripheral of the MCU in C language. I would like to exploit interrupt mechanism for reception and also for transmission.
As far as the reception part I think that I can implement this via exposing the function SpiRegisterCallback into the SPI driver interface. This function enables the client register its function which will be invoked as soon as data byte is received (reception buffer full interrupt is invoked).
As far as the transmission part I would like to use some SpiTransmit function which will receive pointer to the data bytes to be transmitted and number of bytes to be transmitted. As far as implementation I am going to define some internal callback function of the SPI driver. This internal callback will be registered for transmission buffer empty interrupt. In this callback function the passed data bytes will be gradually placed into the transmission buffer. I am not sure whether this approach is appropriate. Can anybody give me an advice how to implement SPI peripheral driver which exploits interrupts for data transmission? Thanks in advance for any suggestions.