aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/ports/MSP430X/hal_spi_lld.c
diff options
context:
space:
mode:
authorAndrew Wygle <awygle@gmail.com>2016-05-22 12:41:42 -0700
committerAndrew Wygle <awygle@gmail.com>2016-06-05 13:51:10 -0700
commit456702ee87b1adbbb559778aafe98c349700178a (patch)
treed68bd2207a0cb7ccb2af0db58e7f33c2df168e3b /os/hal/ports/MSP430X/hal_spi_lld.c
parent5d20ce4595a564c1f98a31445f5015de41e1e25f (diff)
downloadChibiOS-Contrib-456702ee87b1adbbb559778aafe98c349700178a.tar.gz
ChibiOS-Contrib-456702ee87b1adbbb559778aafe98c349700178a.tar.bz2
ChibiOS-Contrib-456702ee87b1adbbb559778aafe98c349700178a.zip
Cleaned up MSP430X port to match recent changes to ChibiOS mainline.
Also fixed a couple of bugs identified as part of the refresh.
Diffstat (limited to 'os/hal/ports/MSP430X/hal_spi_lld.c')
-rw-r--r--os/hal/ports/MSP430X/hal_spi_lld.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/os/hal/ports/MSP430X/hal_spi_lld.c b/os/hal/ports/MSP430X/hal_spi_lld.c
index 70a357e..3768487 100644
--- a/os/hal/ports/MSP430X/hal_spi_lld.c
+++ b/os/hal/ports/MSP430X/hal_spi_lld.c
@@ -388,10 +388,11 @@ void spi_lld_start(SPIDriver * spip) {
spip->regs->ctlw0 = UCSWRST;
spip->regs->brw = brw;
spip->regs->ctlw0 =
- (spip->config->spi_mode << 14) | (spip->config->bit_order << 13) |
+ ((spip->config->spi_mode ^ 0x02) << 14) | (spip->config->bit_order << 13) |
(spip->config->data_size << 12) | (UCMST) |
((spip->config->ss_line ? 0 : 2) << 9) | (UCSYNC) | (ssel) | (UCSTEM);
*(spip->ifg) = 0;
+ spi_lld_unselect(spip);
}
/**
@@ -561,15 +562,12 @@ void spi_lld_receive(SPIDriver * spip, size_t n, void * rxbuf) {
* @param[in] frame the data frame to send over the SPI bus
* @return The received data frame from the SPI bus.
*/
-uint16_t spi_lld_polled_exchange(SPIDriver * spip, uint16_t frame) {
+uint8_t spi_lld_polled_exchange(SPIDriver * spip, uint8_t frame) {
- osalDbgAssert(!(frame & 0xFF00U), "16-bit transfers not supported");
-
- while (!(*(spip->ifg) & UCTXIFG))
- ;
spip->regs->txbuf = frame;
while (!(*(spip->ifg) & UCRXIFG))
;
+ *(spip->ifg) &= ~(UCRXIFG | UCTXIFG);
return spip->regs->rxbuf;
}