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.
SPI API Bug
Moderator: RoccoMarco
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: SPI API Bug
Hi,
The OS does not check parameters unless checks are enabled in chconf.h. The condition is actually tested:
Enabling debug options would have stopped execution.
Giovanni
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
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
Code: Select all
fwrite(buffer, 0, 0, fp) == 0
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: SPI API Bug
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
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