From 456702ee87b1adbbb559778aafe98c349700178a Mon Sep 17 00:00:00 2001 From: Andrew Wygle Date: Sun, 22 May 2016 12:41:42 -0700 Subject: Cleaned up MSP430X port to match recent changes to ChibiOS mainline. Also fixed a couple of bugs identified as part of the refresh. --- os/hal/ports/MSP430X/hal_dma_lld.c | 4 +++- os/hal/ports/MSP430X/hal_serial_lld.c | 1 + os/hal/ports/MSP430X/hal_spi_lld.c | 10 ++++------ os/hal/ports/MSP430X/hal_spi_lld.h | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) (limited to 'os/hal/ports/MSP430X') diff --git a/os/hal/ports/MSP430X/hal_dma_lld.c b/os/hal/ports/MSP430X/hal_dma_lld.c index 43e1d6c..2e17afa 100644 --- a/os/hal/ports/MSP430X/hal_dma_lld.c +++ b/os/hal/ports/MSP430X/hal_dma_lld.c @@ -89,7 +89,9 @@ PORT_IRQ_HANDLER(DMA_VECTOR) { if (index < MSP430X_DMA_CHANNELS) { #if CH_CFG_USE_SEMAPHORES + chSysLockFromISR(); chSemSignalI(&dma_lock); + chSysUnlockFromISR(); #endif msp430x_dma_cb_t * cb = &callbacks[index]; @@ -129,7 +131,7 @@ void dmaInit(void) { bool dmaRequest(msp430x_dma_req_t * request, systime_t timeout) { /* Check if a DMA channel is available */ #if CH_CFG_USE_SEMAPHORES - msg_t semresult = chSemWaitTimeout(&dma_lock, timeout); + msg_t semresult = chSemWaitTimeoutS(&dma_lock, timeout); if (semresult != MSG_OK) return true; #endif diff --git a/os/hal/ports/MSP430X/hal_serial_lld.c b/os/hal/ports/MSP430X/hal_serial_lld.c index 0d9aa1c..8f22650 100644 --- a/os/hal/ports/MSP430X/hal_serial_lld.c +++ b/os/hal/ports/MSP430X/hal_serial_lld.c @@ -374,6 +374,7 @@ PORT_IRQ_HANDLER(USCI_A0_VECTOR) { if (oqIsEmptyI(&SD0.oqueue)) chnAddFlagsI(&SD0, CHN_TRANSMISSION_END); UCA0IE &= ~UCTXCPTIE; + osalSysUnlockFromISR(); break; default: /* other interrupts */ 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; } diff --git a/os/hal/ports/MSP430X/hal_spi_lld.h b/os/hal/ports/MSP430X/hal_spi_lld.h index ebf14c8..0ca4c67 100644 --- a/os/hal/ports/MSP430X/hal_spi_lld.h +++ b/os/hal/ports/MSP430X/hal_spi_lld.h @@ -630,7 +630,7 @@ extern "C" { const void *txbuf, void *rxbuf); void spi_lld_send(SPIDriver *spip, size_t n, const void *txbuf); void spi_lld_receive(SPIDriver *spip, size_t n, void *rxbuf); - uint16_t spi_lld_polled_exchange(SPIDriver *spip, uint16_t frame); + uint8_t spi_lld_polled_exchange(SPIDriver *spip, uint8_t frame); #ifdef __cplusplus } #endif -- cgit v1.2.3