From 219606d05da820b72a492330256a143d5176317c Mon Sep 17 00:00:00 2001 From: gdisirio Date: Mon, 1 Nov 2010 14:05:59 +0000 Subject: Added STM8 SPI demo. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2320 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/platforms/STM8/spi_lld.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'os') diff --git a/os/hal/platforms/STM8/spi_lld.c b/os/hal/platforms/STM8/spi_lld.c index 9f7c057a3..e929f4b69 100644 --- a/os/hal/platforms/STM8/spi_lld.c +++ b/os/hal/platforms/STM8/spi_lld.c @@ -87,18 +87,12 @@ CH_IRQ_HANDLER(10) { goto exit_isr; } } - /* Loading the DR register like it is a FIFO with depth>1 in order to - handle the case where the shift register is empty too.*/ - while ((SPI->SR & SPI_SR_TXE) != 0) { + /* Loading the DR register.*/ + if ((SPI->SR & SPI_SR_TXE) != 0) { if (SPID1.spd_txptr != NULL) SPI->DR = *SPID1.spd_txptr++; else SPI->DR = 0xFF; - if (--SPID1.spd_txcnt == 0) { - /* Stops just the TX interrupt source.*/ - SPI->ICR &= ~SPI_ICR_TXEI; - break; - } } exit_isr: @@ -132,11 +126,11 @@ void spi_lld_init(void) { void spi_lld_start(SPIDriver *spip) { /* Clock activation.*/ - CLK->PCKENR1 |= CLK_PCKENR1_SPI; /* PCKEN11, clock source. */ + CLK->PCKENR1 |= CLK_PCKENR1_SPI; /* PCKEN11, clock source. */ /* Configuration.*/ - SPI->CR2 = SPI_CR2_SSI; - SPI->CR1 = spip->spd_config->spc_cr1 | SPI_CR1_SPE; + SPI->CR2 = 0; + SPI->CR1 = spip->spd_config->spc_cr1 | SPI_CR1_MSTR | SPI_CR1_SPE; } /** @@ -156,7 +150,7 @@ void spi_lld_stop(SPIDriver *spip) { SPI->ICR = 0; /* Clock de-activation.*/ - CLK->PCKENR1 &= ~CLK_PCKENR1_SPI; /* PCKEN11, clock source. */ + CLK->PCKENR1 &= (uint8_t)~CLK_PCKENR1_SPI; /* PCKEN11, clock source. */ } /** -- cgit v1.2.3