Page 1 of 1
SPI API Bug
Posted: Wed Nov 25, 2015 8:57 am
by gnif
This is just a bug report with ChibiOS 3.
If spiSend is called with a zero size buffer, the dma transfer is configured, and stared, but will never issue an IRQ due to the zero size, and as such the thread will never unsuspend.
Re: SPI API Bug
Posted: Wed Nov 25, 2015 9:28 am
by Giovanni
Hi,
The OS does not check parameters unless checks are enabled in chconf.h. The condition is actually tested:
Code: Select all
void spiSend(SPIDriver *spip, size_t n, const void *txbuf) {
osalDbgCheck((spip != NULL) && (n > 0U) && (txbuf != NULL));
Enabling debug options would have stopped execution.
Giovanni
Re: SPI API Bug
Posted: Wed Nov 25, 2015 12:05 pm
by gnif
Hrmm, ok, but personally I would have added a simple check for zero size, and return quietly if it is, just like all other IO type methods in most other APIs and languages, ie
Re: SPI API Bug
Posted: Wed Nov 25, 2015 12:29 pm
by Giovanni
Hi,
Our design pattern is that error checks are only performed at development time for efficiency/codesize reasons. The application is responsible for passing correct values to the API.
Giovanni