From 18fb8f676f0f650d83f69bc29ab45b04b73e86c1 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 8 Mar 2011 10:09:57 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2808 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/platforms/LPC214x/spi_lld.c | 96 +++++++++++++++++++------------------- os/hal/platforms/LPC214x/spi_lld.h | 30 ++++++------ 2 files changed, 63 insertions(+), 63 deletions(-) (limited to 'os/hal/platforms/LPC214x') diff --git a/os/hal/platforms/LPC214x/spi_lld.c b/os/hal/platforms/LPC214x/spi_lld.c index f920ecf87..808ede590 100644 --- a/os/hal/platforms/LPC214x/spi_lld.c +++ b/os/hal/platforms/LPC214x/spi_lld.c @@ -53,21 +53,21 @@ SPIDriver SPID1; * @param[in] spip pointer to the @p SPIDriver object */ static void ssp_fifo_preload(SPIDriver *spip) { - SSP *ssp = spip->spd_ssp; - uint32_t n = spip->spd_txcnt > LPC214x_SSP_FIFO_DEPTH ? - LPC214x_SSP_FIFO_DEPTH : spip->spd_txcnt; + SSP *ssp = spip->ssp; + uint32_t n = spip->txcnt > LPC214x_SSP_FIFO_DEPTH ? + LPC214x_SSP_FIFO_DEPTH : spip->txcnt; while(((ssp->SSP_SR & SR_TNF) != 0) && (n > 0)) { - if (spip->spd_txptr != NULL) { + if (spip->txptr != NULL) { if ((ssp->SSP_CR0 & CR0_DSSMASK) > CR0_DSS8BIT) - ssp->SSP_DR = *(uint16_t *)spip->spd_txptr++; + ssp->SSP_DR = *(uint16_t *)spip->txptr++; else - ssp->SSP_DR = *(uint8_t *)spip->spd_txptr++; + ssp->SSP_DR = *(uint8_t *)spip->txptr++; } else ssp->SSP_DR = 0xFFFFFFFF; n--; - spip->spd_txcnt--; + spip->txcnt--; } } @@ -80,7 +80,7 @@ __attribute__((noinline)) * @param[in] spip pointer to the @p SPIDriver object */ static void serve_interrupt(SPIDriver *spip) { - SSP *ssp = spip->spd_ssp; + SSP *ssp = spip->ssp; if ((ssp->SSP_MIS & MIS_ROR) != 0) { /* The overflow condition should never happen because priority is given @@ -89,16 +89,16 @@ static void serve_interrupt(SPIDriver *spip) { } ssp->SSP_ICR = ICR_RT | ICR_ROR; while ((ssp->SSP_SR & SR_RNE) != 0) { - if (spip->spd_rxptr != NULL) { + if (spip->rxptr != NULL) { if ((ssp->SSP_CR0 & CR0_DSSMASK) > CR0_DSS8BIT) - *(uint16_t *)spip->spd_rxptr++ = ssp->SSP_DR; + *(uint16_t *)spip->rxptr++ = ssp->SSP_DR; else - *(uint8_t *)spip->spd_rxptr++ = ssp->SSP_DR; + *(uint8_t *)spip->rxptr++ = ssp->SSP_DR; } else (void)ssp->SSP_DR; - if (--spip->spd_rxcnt == 0) { - chDbgAssert(spip->spd_txcnt == 0, + if (--spip->rxcnt == 0) { + chDbgAssert(spip->txcnt == 0, "spi_serve_interrupt(), #1", "counter out of synch"); /* Stops the IRQ sources.*/ ssp->SSP_IMSC = 0; @@ -109,7 +109,7 @@ static void serve_interrupt(SPIDriver *spip) { } } ssp_fifo_preload(spip); - if (spip->spd_txcnt == 0) + if (spip->txcnt == 0) ssp->SSP_IMSC = IMSC_ROR | IMSC_RT | IMSC_RX; } @@ -147,7 +147,7 @@ void spi_lld_init(void) { #if LPC214x_SPI_USE_SSP spiObjectInit(&SPID1); - SPID1.spd_ssp = SSPBase; + SPID1.ssp = SSPBase; SetVICVector(SPI1IrqHandler, LPC214x_SPI_SSP_IRQ_PRIORITY, SOURCE_SPI1); #endif } @@ -161,7 +161,7 @@ void spi_lld_init(void) { */ void spi_lld_start(SPIDriver *spip) { - if (spip->spd_state == SPI_STOP) { + if (spip->state == SPI_STOP) { /* Clock activation.*/ #if LPC214x_SPI_USE_SSP if (&SPID1 == spip) { @@ -171,14 +171,14 @@ void spi_lld_start(SPIDriver *spip) { #endif } /* Configuration.*/ - spip->spd_ssp->SSP_CR1 = 0; + spip->ssp->SSP_CR1 = 0; /* Emptying the receive FIFO, it happens to not be empty while debugging.*/ - while (spip->spd_ssp->SSP_SR & SR_RNE) - (void) spip->spd_ssp->SSP_DR; - spip->spd_ssp->SSP_ICR = ICR_RT | ICR_ROR; - spip->spd_ssp->SSP_CR0 = spip->spd_config->spc_cr0; - spip->spd_ssp->SSP_CPSR = spip->spd_config->spc_cpsr; - spip->spd_ssp->SSP_CR1 = CR1_SSE; + while (spip->ssp->SSP_SR & SR_RNE) + (void) spip->ssp->SSP_DR; + spip->ssp->SSP_ICR = ICR_RT | ICR_ROR; + spip->ssp->SSP_CR0 = spip->config->cr0; + spip->ssp->SSP_CPSR = spip->config->cpsr; + spip->ssp->SSP_CR1 = CR1_SSE; } /** @@ -190,10 +190,10 @@ void spi_lld_start(SPIDriver *spip) { */ void spi_lld_stop(SPIDriver *spip) { - if (spip->spd_state != SPI_STOP) { - spip->spd_ssp->SSP_CR1 = 0; - spip->spd_ssp->SSP_CR0 = 0; - spip->spd_ssp->SSP_CPSR = 0; + if (spip->state != SPI_STOP) { + spip->ssp->SSP_CR1 = 0; + spip->ssp->SSP_CR0 = 0; + spip->ssp->SSP_CPSR = 0; #if LPC214x_SPI_USE_SSP if (&SPID1 == spip) { PCONP = (PCONP & PCALL) & ~PCSPI1; @@ -212,7 +212,7 @@ void spi_lld_stop(SPIDriver *spip) { */ void spi_lld_select(SPIDriver *spip) { - palClearPad(spip->spd_config->spc_ssport, spip->spd_config->spc_sspad); + palClearPad(spip->config->ssport, spip->config->sspad); } /** @@ -225,7 +225,7 @@ void spi_lld_select(SPIDriver *spip) { */ void spi_lld_unselect(SPIDriver *spip) { - palSetPad(spip->spd_config->spc_ssport, spip->spd_config->spc_sspad); + palSetPad(spip->config->ssport, spip->config->sspad); } /** @@ -241,11 +241,11 @@ void spi_lld_unselect(SPIDriver *spip) { */ void spi_lld_ignore(SPIDriver *spip, size_t n) { - spip->spd_rxptr = NULL; - spip->spd_txptr = NULL; - spip->spd_rxcnt = spip->spd_txcnt = n; + spip->rxptr = NULL; + spip->txptr = NULL; + spip->rxcnt = spip->txcnt = n; ssp_fifo_preload(spip); - spip->spd_ssp->SSP_IMSC = IMSC_ROR | IMSC_RT | IMSC_TX | IMSC_RX; + spip->ssp->SSP_IMSC = IMSC_ROR | IMSC_RT | IMSC_TX | IMSC_RX; } /** @@ -266,11 +266,11 @@ void spi_lld_ignore(SPIDriver *spip, size_t n) { void spi_lld_exchange(SPIDriver *spip, size_t n, const void *txbuf, void *rxbuf) { - spip->spd_rxptr = rxbuf; - spip->spd_txptr = txbuf; - spip->spd_rxcnt = spip->spd_txcnt = n; + spip->rxptr = rxbuf; + spip->txptr = txbuf; + spip->rxcnt = spip->txcnt = n; ssp_fifo_preload(spip); - spip->spd_ssp->SSP_IMSC = IMSC_ROR | IMSC_RT | IMSC_TX | IMSC_RX; + spip->ssp->SSP_IMSC = IMSC_ROR | IMSC_RT | IMSC_TX | IMSC_RX; } /** @@ -288,11 +288,11 @@ void spi_lld_exchange(SPIDriver *spip, size_t n, */ void spi_lld_send(SPIDriver *spip, size_t n, const void *txbuf) { - spip->spd_rxptr = NULL; - spip->spd_txptr = txbuf; - spip->spd_rxcnt = spip->spd_txcnt = n; + spip->rxptr = NULL; + spip->txptr = txbuf; + spip->rxcnt = spip->txcnt = n; ssp_fifo_preload(spip); - spip->spd_ssp->SSP_IMSC = IMSC_ROR | IMSC_RT | IMSC_TX | IMSC_RX; + spip->ssp->SSP_IMSC = IMSC_ROR | IMSC_RT | IMSC_TX | IMSC_RX; } /** @@ -310,11 +310,11 @@ void spi_lld_send(SPIDriver *spip, size_t n, const void *txbuf) { */ void spi_lld_receive(SPIDriver *spip, size_t n, void *rxbuf) { - spip->spd_rxptr = rxbuf; - spip->spd_txptr = NULL; - spip->spd_rxcnt = spip->spd_txcnt = n; + spip->rxptr = rxbuf; + spip->txptr = NULL; + spip->rxcnt = spip->txcnt = n; ssp_fifo_preload(spip); - spip->spd_ssp->SSP_IMSC = IMSC_ROR | IMSC_RT | IMSC_TX | IMSC_RX; + spip->ssp->SSP_IMSC = IMSC_ROR | IMSC_RT | IMSC_TX | IMSC_RX; } /** @@ -331,10 +331,10 @@ void spi_lld_receive(SPIDriver *spip, size_t n, void *rxbuf) { */ uint16_t spi_lld_polled_exchange(SPIDriver *spip, uint16_t frame) { - spip->spd_ssp->SSP_DR = (uint32_t)frame; - while ((spip->spd_ssp->SSP_SR & SR_RNE) == 0) + spip->ssp->SSP_DR = (uint32_t)frame; + while ((spip->ssp->SSP_SR & SR_RNE) == 0) ; - return (uint16_t)spip->spd_ssp->SSP_DR; + return (uint16_t)spip->ssp->SSP_DR; } #endif /* HAL_USE_SPI */ diff --git a/os/hal/platforms/LPC214x/spi_lld.h b/os/hal/platforms/LPC214x/spi_lld.h index 0e9a3e782..f2d954e46 100644 --- a/os/hal/platforms/LPC214x/spi_lld.h +++ b/os/hal/platforms/LPC214x/spi_lld.h @@ -99,24 +99,24 @@ typedef struct { /** * @brief Operation complete callback or @p NULL. */ - spicallback_t spc_endcb; + spicallback_t end_cb; /* End of the mandatory fields.*/ /** * @brief The chip select line port. */ - ioportid_t spc_ssport; + ioportid_t ssport; /** * @brief The chip select line pad number. */ - uint16_t spc_sspad; + uint16_t sspad; /** * @brief SSP CR0 initialization data. */ - uint16_t spc_cr0; + uint16_t cr0; /** * @brief SSP CPSR initialization data. */ - uint32_t spc_cpsr; + uint32_t cpsr; } SPIConfig; /** @@ -126,25 +126,25 @@ struct SPIDriver { /** * @brief Driver state. */ - spistate_t spd_state; + spistate_t state; /** * @brief Current configuration data. */ - const SPIConfig *spd_config; + const SPIConfig *config; #if SPI_USE_WAIT || defined(__DOXYGEN__) /** * @brief Waiting thread. */ - Thread *spd_thread; + Thread *thread; #endif /* SPI_USE_WAIT */ #if SPI_USE_MUTUAL_EXCLUSION || defined(__DOXYGEN__) #if CH_USE_MUTEXES || defined(__DOXYGEN__) /** * @brief Mutex protecting the bus. */ - Mutex spd_mutex; + Mutex mutex; #elif CH_USE_SEMAPHORES - Semaphore spd_semaphore; + Semaphore semaphore; #endif #endif /* SPI_USE_MUTUAL_EXCLUSION */ #if defined(SPI_DRIVER_EXT_FIELDS) @@ -154,23 +154,23 @@ struct SPIDriver { /** * @brief Pointer to the SSP registers block. */ - SSP *spd_ssp; + SSP *ssp; /** * @brief Number of bytes yet to be received. */ - uint32_t spd_rxcnt; + uint32_t rxcnt; /** * @brief Receive pointer or @p NULL. */ - void *spd_rxptr; + void *rxptr; /** * @brief Number of bytes yet to be transmitted. */ - uint32_t spd_txcnt; + uint32_t txcnt; /** * @brief Transmit pointer or @p NULL. */ - const void *spd_txptr; + const void *txptr; }; /*===========================================================================*/ -- cgit v1.2.3