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/LPC13xx/spi_lld.c | 100 ++++++++++++++++++------------------- 1 file changed, 50 insertions(+), 50 deletions(-) (limited to 'os/hal/platforms/LPC13xx/spi_lld.c') diff --git a/os/hal/platforms/LPC13xx/spi_lld.c b/os/hal/platforms/LPC13xx/spi_lld.c index 1a98a7a15..0e186ccd8 100644 --- a/os/hal/platforms/LPC13xx/spi_lld.c +++ b/os/hal/platforms/LPC13xx/spi_lld.c @@ -53,27 +53,27 @@ SPIDriver SPID1; * @param[in] spip pointer to the @p SPIDriver object */ static void ssp_fifo_preload(SPIDriver *spip) { - LPC_SSP_TypeDef *ssp = spip->spd_ssp; - uint32_t n = spip->spd_txcnt > LPC13xx_SSP_FIFO_DEPTH ? - LPC13xx_SSP_FIFO_DEPTH : spip->spd_txcnt; + LPC_SSP_TypeDef *ssp = spip->ssp; + uint32_t n = spip->txcnt > LPC13xx_SSP_FIFO_DEPTH ? + LPC13xx_SSP_FIFO_DEPTH : spip->txcnt; while(((ssp->SR & SR_TNF) != 0) && (n > 0)) { - if (spip->spd_txptr != NULL) { + if (spip->txptr != NULL) { if ((ssp->CR0 & CR0_DSSMASK) > CR0_DSS8BIT) { - const uint16_t *p = spip->spd_txptr; + const uint16_t *p = spip->txptr; ssp->DR = *p++; - spip->spd_txptr = p; + spip->txptr = p; } else { - const uint8_t *p = spip->spd_txptr; + const uint8_t *p = spip->txptr; ssp->DR = *p++; - spip->spd_txptr = p; + spip->txptr = p; } } else ssp->DR = 0xFFFFFFFF; n--; - spip->spd_txcnt--; + spip->txcnt--; } } @@ -83,7 +83,7 @@ static void ssp_fifo_preload(SPIDriver *spip) { * @param[in] spip pointer to the @p SPIDriver object */ static void spi_serve_interrupt(SPIDriver *spip) { - LPC_SSP_TypeDef *ssp = spip->spd_ssp; + LPC_SSP_TypeDef *ssp = spip->ssp; if ((ssp->MIS & MIS_ROR) != 0) { /* The overflow condition should never happen because priority is given @@ -92,22 +92,22 @@ static void spi_serve_interrupt(SPIDriver *spip) { } ssp->ICR = ICR_RT | ICR_ROR; while ((ssp->SR & SR_RNE) != 0) { - if (spip->spd_rxptr != NULL) { + if (spip->rxptr != NULL) { if ((ssp->CR0 & CR0_DSSMASK) > CR0_DSS8BIT) { - uint16_t *p = spip->spd_rxptr; + uint16_t *p = spip->rxptr; *p++ = ssp->DR; - spip->spd_rxptr = p; + spip->rxptr = p; } else { - uint8_t *p = spip->spd_rxptr; + uint8_t *p = spip->rxptr; *p++ = ssp->DR; - spip->spd_rxptr = p; + spip->rxptr = p; } } else (void)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->IMSC = 0; @@ -118,7 +118,7 @@ static void spi_serve_interrupt(SPIDriver *spip) { } } ssp_fifo_preload(spip); - if (spip->spd_txcnt == 0) + if (spip->txcnt == 0) ssp->IMSC = IMSC_ROR | IMSC_RT | IMSC_RX; } @@ -155,7 +155,7 @@ void spi_lld_init(void) { #if LPC13xx_SPI_USE_SSP0 spiObjectInit(&SPID1); - SPID1.spd_ssp = LPC_SSP; + SPID1.ssp = LPC_SSP; LPC_IOCON->SCKLOC = LPC13xx_SPI_SCK0_SELECTOR; #if LPC13xx_SPI_SCK0_SELECTOR == SCK0_IS_PIO0_10 LPC_IOCON->JTAG_TCK_PIO0_10 = 0xC2; /* SCK0 without resistors. */ @@ -178,7 +178,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 LPC13xx_SPI_USE_SSP0 if (&SPID1 == spip) { @@ -191,11 +191,11 @@ void spi_lld_start(SPIDriver *spip) { #endif } /* Configuration.*/ - spip->spd_ssp->CR1 = 0; - spip->spd_ssp->ICR = ICR_RT | ICR_ROR; - spip->spd_ssp->CR0 = spip->spd_config->spc_cr0; - spip->spd_ssp->CPSR = spip->spd_config->spc_cpsr; - spip->spd_ssp->CR1 = CR1_SSE; + spip->ssp->CR1 = 0; + spip->ssp->ICR = ICR_RT | ICR_ROR; + spip->ssp->CR0 = spip->config->cr0; + spip->ssp->CPSR = spip->config->cpsr; + spip->ssp->CR1 = CR1_SSE; } /** @@ -207,10 +207,10 @@ void spi_lld_start(SPIDriver *spip) { */ void spi_lld_stop(SPIDriver *spip) { - if (spip->spd_state != SPI_STOP) { - spip->spd_ssp->CR1 = 0; - spip->spd_ssp->CR0 = 0; - spip->spd_ssp->CPSR = 0; + if (spip->state != SPI_STOP) { + spip->ssp->CR1 = 0; + spip->ssp->CR0 = 0; + spip->ssp->CPSR = 0; #if LPC13xx_SPI_USE_SSP0 if (&SPID1 == spip) { LPC_SYSCON->PRESETCTRL &= ~1; @@ -231,7 +231,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); } /** @@ -244,7 +244,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); } /** @@ -260,11 +260,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->IMSC = IMSC_ROR | IMSC_RT | IMSC_TX | IMSC_RX; + spip->ssp->IMSC = IMSC_ROR | IMSC_RT | IMSC_TX | IMSC_RX; } /** @@ -285,11 +285,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->IMSC = IMSC_ROR | IMSC_RT | IMSC_TX | IMSC_RX; + spip->ssp->IMSC = IMSC_ROR | IMSC_RT | IMSC_TX | IMSC_RX; } /** @@ -307,11 +307,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->IMSC = IMSC_ROR | IMSC_RT | IMSC_TX | IMSC_RX; + spip->ssp->IMSC = IMSC_ROR | IMSC_RT | IMSC_TX | IMSC_RX; } /** @@ -329,11 +329,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->IMSC = IMSC_ROR | IMSC_RT | IMSC_TX | IMSC_RX; + spip->ssp->IMSC = IMSC_ROR | IMSC_RT | IMSC_TX | IMSC_RX; } /** @@ -350,10 +350,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->DR = (uint32_t)frame; - while ((spip->spd_ssp->SR & SR_RNE) == 0) + spip->ssp->DR = (uint32_t)frame; + while ((spip->ssp->SR & SR_RNE) == 0) ; - return (uint16_t)spip->spd_ssp->DR; + return (uint16_t)spip->ssp->DR; } #endif /* HAL_USE_SPI */ -- cgit v1.2.3