aboutsummaryrefslogtreecommitdiffstats
path: root/os
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2010-11-01 14:05:59 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2010-11-01 14:05:59 +0000
commit219606d05da820b72a492330256a143d5176317c (patch)
treef4109d82f8240b76d84568b51a8da58ac3137941 /os
parent38acf6953fa4221a1fa7f43d78bfb94402fc8f48 (diff)
downloadChibiOS-219606d05da820b72a492330256a143d5176317c.tar.gz
ChibiOS-219606d05da820b72a492330256a143d5176317c.tar.bz2
ChibiOS-219606d05da820b72a492330256a143d5176317c.zip
Added STM8 SPI demo.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2320 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os')
-rw-r--r--os/hal/platforms/STM8/spi_lld.c18
1 files changed, 6 insertions, 12 deletions
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. */
}
/**