From 0bd69a2cb10011aa34897d747df6a959121a1e4e Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 7 Nov 2009 08:59:30 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1271 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/io/spi.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'os/io') diff --git a/os/io/spi.c b/os/io/spi.c index 10eabb87e..11247f24a 100644 --- a/os/io/spi.c +++ b/os/io/spi.c @@ -60,13 +60,15 @@ void spiObjectInit(SPIDriver *spip) { void spiStart(SPIDriver *spip, const SPIConfig *config) { chDbgCheck((spip != NULL) && (config != NULL), "spiStart"); + + chSysLock(); chDbgAssert((spip->spd_state == SPI_STOP) || (spip->spd_state == SPI_READY), "spiStart(), #1", "invalid state"); - spip->spd_config = config; spi_lld_start(spip); spip->spd_state = SPI_READY; + chSysUnlock(); } /** @@ -77,12 +79,14 @@ void spiStart(SPIDriver *spip, const SPIConfig *config) { void spiStop(SPIDriver *spip) { chDbgCheck(spip != NULL, "spiStop"); + + chSysLock(); chDbgAssert((spip->spd_state == SPI_STOP) || (spip->spd_state == SPI_READY), "spiStop(), #1", "invalid state"); - spi_lld_stop(spip); spip->spd_state = SPI_STOP; + chSysUnlock(); } /** @@ -94,12 +98,13 @@ void spiSelect(SPIDriver *spip) { chDbgCheck(spip != NULL, "spiSelect"); + chSysLock(); chDbgAssert(spip->spd_state == SPI_READY, "spiSelect(), #1", "not idle"); - spi_lld_select(spip); spip->spd_state = SPI_ACTIVE; + chSysUnlock(); } /** @@ -112,12 +117,13 @@ void spiUnselect(SPIDriver *spip) { chDbgCheck(spip != NULL, "spiUnselect"); + chSysLock(); chDbgAssert(spip->spd_state == SPI_ACTIVE, "spiUnselect(), #1", "not locked"); - spi_lld_unselect(spip); spip->spd_state = SPI_READY; + chSysUnlock(); } /** -- cgit v1.2.3