rogerclarkmelbourne / Arduino_STM32

Arduino STM32. Hardware files to support STM32 boards, on Arduino IDE 1.8.x including LeafLabs Maple and other generic STM32F103 boards
Other
2.52k stars 1.26k forks source link

SPI: add parameter to spiclass::on transmit/on receive #830

Closed mean00 closed 3 years ago

mean00 commented 3 years ago

This PR adds a parameter/cookie to the spi class onTransmit/onReceive callbacks This is useful to go back to the client class when the callback is invoked By default the parameter is null, so it should be compatible with the current API

It is especially useful when using a small RTOS like FreeRTOS

To give an example, a transfer to the screen is armed and the task waits on a semaphore The callback cookie is actually the client instance, and upon dereferencing, the semaphore is unlocked

i.e. static void Screen::screencallback(void a) { myScreen s=(Screen *)a; s->transferDone();}

stevstrong commented 3 years ago

I'm afraid the compatibility is not kept because you changed the first parameter (the callback function type) from void(*callback)(void) to void(*callback)(void *).

mean00 commented 3 years ago

Indeed

stevstrong commented 3 years ago

I will not merge this if it does not keep backward compatibility.

mean00 commented 3 years ago

yes, that goes without saying Even if , as it is, the api is a bit awkward and probably not used much

stevstrong commented 3 years ago

Closed due to missing backward compatibility. You may reopen this PR if you re-write it to be compatible.