aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2009-11-07 08:59:30 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2009-11-07 08:59:30 +0000
commit0bd69a2cb10011aa34897d747df6a959121a1e4e (patch)
tree7d4e4205028a4b26751245cf834145ce769e85da
parent0521c90a445af93ea53f7d0e1847fa8a12a9c423 (diff)
downloadChibiOS-0bd69a2cb10011aa34897d747df6a959121a1e4e.tar.gz
ChibiOS-0bd69a2cb10011aa34897d747df6a959121a1e4e.tar.bz2
ChibiOS-0bd69a2cb10011aa34897d747df6a959121a1e4e.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1271 35acf78f-673a-0410-8e92-d51de3d6d3f4
-rw-r--r--demos/ARMCM3-STM32F103-GCC/main.c15
-rw-r--r--os/io/spi.c14
2 files changed, 10 insertions, 19 deletions
diff --git a/demos/ARMCM3-STM32F103-GCC/main.c b/demos/ARMCM3-STM32F103-GCC/main.c
index d3889251a..116a0aaf1 100644
--- a/demos/ARMCM3-STM32F103-GCC/main.c
+++ b/demos/ARMCM3-STM32F103-GCC/main.c
@@ -41,13 +41,6 @@ static msg_t Thread1(void *arg) {
return 0;
}
-static SPIConfig spicfg = {
- 16, IOPORT1, 4, 0
-};
-
-static uint8_t txbuf[8] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF};
-static uint8_t rxbuf[8];
-
/*
* Entry point, note, the main() function is already a thread in the system
* on entry.
@@ -67,14 +60,6 @@ int main(int argc, char **argv) {
*/
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
- palSetPadMode(IOPORT1, 4, PAL_MODE_OUTPUT_PUSHPULL);
- palSetPad(IOPORT1, 4);
- spiStart(&SPID1, &spicfg);
- spiSelect(&SPID1);
- spiExchange(&SPID1, 8, txbuf, rxbuf);
- spiUnselect(&SPID1);
- spiStop(&SPID1);
-
/*
* Normal main() thread activity, in this demo it does nothing except
* sleeping in a loop and check the button state.
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();
}
/**