aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/platforms/STM8S/spi_lld.c
diff options
context:
space:
mode:
Diffstat (limited to 'os/hal/platforms/STM8S/spi_lld.c')
-rw-r--r--os/hal/platforms/STM8S/spi_lld.c49
1 files changed, 26 insertions, 23 deletions
diff --git a/os/hal/platforms/STM8S/spi_lld.c b/os/hal/platforms/STM8S/spi_lld.c
index c950f0bd4..57e459d80 100644
--- a/os/hal/platforms/STM8S/spi_lld.c
+++ b/os/hal/platforms/STM8S/spi_lld.c
@@ -1,5 +1,6 @@
/*
- ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio.
+ ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010,
+ 2011 Giovanni Di Sirio.
This file is part of ChibiOS/RT.
@@ -70,12 +71,12 @@ CH_IRQ_HANDLER(10) {
handle the case where a frame arrives immediately after reading the
DR register.*/
while ((SPI->SR & SPI_SR_RXNE) != 0) {
- if (SPID1.spd_rxptr != NULL)
- *SPID1.spd_rxptr++ = SPI->DR;
+ if (SPID1.rxptr != NULL)
+ *SPID1.rxptr++ = SPI->DR;
else
(void)SPI->DR;
- if (--SPID1.spd_rxcnt == 0) {
- chDbgAssert(SPID1.spd_txcnt == 0,
+ if (--SPID1.rxcnt == 0) {
+ chDbgAssert(SPID1.txcnt == 0,
"IRQ10, #1", "counter out of synch");
/* Stops all the IRQ sources.*/
SPI->ICR = 0;
@@ -89,8 +90,8 @@ CH_IRQ_HANDLER(10) {
}
/* Loading the DR register.*/
if ((SPI->SR & SPI_SR_TXE) != 0) {
- if (SPID1.spd_txptr != NULL)
- SPI->DR = *SPID1.spd_txptr++;
+ if (SPID1.txptr != NULL)
+ SPI->DR = *SPID1.txptr++;
else
SPI->DR = 0xFF;
}
@@ -129,8 +130,10 @@ void spi_lld_start(SPIDriver *spip) {
CLK->PCKENR1 |= CLK_PCKENR1_SPI; /* PCKEN11, clock source. */
/* Configuration.*/
- SPI->CR2 = 0;
- SPI->CR1 = spip->spd_config->spc_cr1 | SPI_CR1_MSTR | SPI_CR1_SPE;
+ SPI->CR1 = 0;
+ SPI->CR1 = spip->config->cr1 | SPI_CR1_MSTR;
+ SPI->CR2 = SPI_CR2_SSI | SPI_CR2_SSM;
+ SPI->CR1 |= SPI_CR1_SPE;
}
/**
@@ -162,7 +165,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);
}
/**
@@ -175,7 +178,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);
}
/**
@@ -191,9 +194,9 @@ 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;
SPI->ICR = SPI_ICR_TXEI | SPI_ICR_RXEI | SPI_ICR_ERRIE;
}
@@ -215,9 +218,9 @@ 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;
SPI->ICR = SPI_ICR_TXEI | SPI_ICR_RXEI | SPI_ICR_ERRIE;
}
@@ -236,9 +239,9 @@ 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;
SPI->ICR = SPI_ICR_TXEI | SPI_ICR_RXEI | SPI_ICR_ERRIE;
}
@@ -257,9 +260,9 @@ 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;
SPI->ICR = SPI_ICR_TXEI | SPI_ICR_RXEI | SPI_ICR_ERRIE;
}