aboutsummaryrefslogtreecommitdiffstats
path: root/os
diff options
context:
space:
mode:
authorFabio Utzig <utzig@utzig.org>2016-10-17 12:01:37 +0000
committerFabio Utzig <utzig@utzig.org>2016-10-17 12:01:37 +0000
commitb44d7bed91116ccddc1d018781eede3d187aad42 (patch)
treefca10fca060c10bf079f004547a72852eef7a2b6 /os
parent86e02ab475c5b278cb730012b6528738b0c6c6ee (diff)
downloadChibiOS-b44d7bed91116ccddc1d018781eede3d187aad42.tar.gz
ChibiOS-b44d7bed91116ccddc1d018781eede3d187aad42.tar.bz2
ChibiOS-b44d7bed91116ccddc1d018781eede3d187aad42.zip
Fixed collision in multi-byte SPI write
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@9865 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os')
-rw-r--r--os/hal/ports/AVR/hal_spi_lld.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/os/hal/ports/AVR/hal_spi_lld.c b/os/hal/ports/AVR/hal_spi_lld.c
index 6a89ce112..638f778b1 100644
--- a/os/hal/ports/AVR/hal_spi_lld.c
+++ b/os/hal/ports/AVR/hal_spi_lld.c
@@ -69,24 +69,25 @@ OSAL_IRQ_HANDLER(SPI_STC_vect) {
spip->rxbuf[spip->rxidx++] = SPDR; // receive
}
- /* spi_lld_exchange, spi_lld_send or spi_lld_ignore */
- if (spip->txidx < spip->txbytes) {
- if (spip->txbuf) {
- SPDR = spip->txbuf[spip->txidx++]; // send
- } else {
- SPDR = 0; spip->txidx++; // dummy send
- }
- }
-
- /* spi_lld_send */
- else if (spip->rxidx < spip->rxbytes) { /* rx not done */
- SPDR = 0; // dummy send to keep the clock going
- }
-
/* rx done and tx done */
if (spip->rxidx >= spip->rxbytes && spip->txidx >= spip->txbytes) {
_spi_isr_code(spip);
}
+ else {
+ /* spi_lld_exchange, spi_lld_send or spi_lld_ignore */
+ if (spip->txidx < spip->txbytes) {
+ if (spip->txbuf) {
+ SPDR = spip->txbuf[spip->txidx++]; // send
+ } else {
+ SPDR = 0; spip->txidx++; // dummy send
+ }
+ }
+
+ /* spi_lld_receive */
+ else if (spip->rxidx < spip->rxbytes) { /* rx not done */
+ SPDR = 0; // dummy send to keep the clock going
+ }
+ }
OSAL_IRQ_EPILOGUE();
}