aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/platforms
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2010-10-12 15:19:15 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2010-10-12 15:19:15 +0000
commit935e2fb27f56a3b81d4161d65e116e9da4fe441c (patch)
treeaf91647e95a1e6ad8879bf28b6cac2921814c10f /os/hal/platforms
parentc5053410867ea8538a918c4593075db04adaebca (diff)
downloadChibiOS-935e2fb27f56a3b81d4161d65e116e9da4fe441c.tar.gz
ChibiOS-935e2fb27f56a3b81d4161d65e116e9da4fe441c.tar.bz2
ChibiOS-935e2fb27f56a3b81d4161d65e116e9da4fe441c.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2250 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/platforms')
-rw-r--r--os/hal/platforms/STM32/adc_lld.h19
-rw-r--r--os/hal/platforms/STM32/spi_lld.c16
-rw-r--r--os/hal/platforms/STM32/spi_lld.h13
3 files changed, 27 insertions, 21 deletions
diff --git a/os/hal/platforms/STM32/adc_lld.h b/os/hal/platforms/STM32/adc_lld.h
index a72ce67f3..b1b1a7840 100644
--- a/os/hal/platforms/STM32/adc_lld.h
+++ b/os/hal/platforms/STM32/adc_lld.h
@@ -148,8 +148,11 @@ typedef struct {
adc_channels_num_t acg_num_channels;
/**
* @brief Callback function associated to the group or @p NULL.
+ * @note In order to use synchronous functions this field must be set to
+ * @p NULL, callbacks and synchronous operations are mutually
+ * exclusive.
*/
- adccallback_t acg_callback;
+ adccallback_t acg_endcb;
/* End of the mandatory fields.*/
/**
* @brief ADC CR1 register initialization data.
@@ -219,10 +222,20 @@ struct ADCDriver {
const ADCConversionGroup *ad_grpp;
#if ADC_USE_WAIT || defined(__DOXYGEN__)
/**
- * @brief Synchronization semaphore.
+ * @brief Waiting thread.
*/
- Semaphore ad_sem;
+ Thread *ad_thread;
#endif
+#if ADC_USE_MUTUAL_EXCLUSION || defined(__DOXYGEN__)
+#if CH_USE_MUTEXES || defined(__DOXYGEN__)
+ /**
+ * @brief Mutex protecting the peripheral.
+ */
+ Mutex ad_mutex;
+#elif CH_USE_SEMAPHORES
+ Semaphore ad_semaphore;
+#endif
+#endif /* ADC_USE_MUTUAL_EXCLUSION */
#if defined(ADC_DRIVER_EXT_FIELDS)
ADC_DRIVER_EXT_FIELDS
#endif
diff --git a/os/hal/platforms/STM32/spi_lld.c b/os/hal/platforms/STM32/spi_lld.c
index 4dc18e80c..87dff24d9 100644
--- a/os/hal/platforms/STM32/spi_lld.c
+++ b/os/hal/platforms/STM32/spi_lld.c
@@ -90,19 +90,9 @@ static void serve_interrupt(SPIDriver *spip) {
/* Stop everything.*/
dma_stop(spip);
- /* If a callback is defined then invokes it.*/
- if (spip->spd_config->spc_endcb)
- spip->spd_config->spc_endcb(spip);
-
- /* Wakeup the waiting thread if any, note that the following macro is
- empty if the SPI_USE_WAIT option is disabled.*/
- _spi_wakeup(spip);
-
- /* State change.*/
- if (spip->spd_state == SPI_SYNC)
- spip->spd_state = SPI_READY;
- else
- spip->spd_state = SPI_SELECTED;
+ /* Portable SPI ISR code defined in the high level driver, note, it is
+ a macro.*/
+ _spi_isr_code(spip);
}
/*===========================================================================*/
diff --git a/os/hal/platforms/STM32/spi_lld.h b/os/hal/platforms/STM32/spi_lld.h
index fcca37c27..5da92d1f7 100644
--- a/os/hal/platforms/STM32/spi_lld.h
+++ b/os/hal/platforms/STM32/spi_lld.h
@@ -178,7 +178,10 @@ typedef void (*spicallback_t)(SPIDriver *spip);
*/
typedef struct {
/**
- * @brief Operation complete callback.
+ * @brief Operation complete callback or @p NULL.
+ * @note In order to use synchronous functions this field must be set to
+ * @p NULL, callbacks and synchronous operations are mutually
+ * exclusive.
*/
spicallback_t spc_endcb;
/* End of the mandatory fields.*/
@@ -204,6 +207,10 @@ struct SPIDriver{
* @brief Driver state.
*/
spistate_t spd_state;
+ /**
+ * @brief Current configuration data.
+ */
+ const SPIConfig *spd_config;
#if SPI_USE_WAIT || defined(__DOXYGEN__)
/**
* @brief Waiting thread.
@@ -220,10 +227,6 @@ struct SPIDriver{
Semaphore spd_semaphore;
#endif
#endif /* SPI_USE_MUTUAL_EXCLUSION */
- /**
- * @brief Current configuration data.
- */
- const SPIConfig *spd_config;
#if defined(SPI_DRIVER_EXT_FIELDS)
SPI_DRIVER_EXT_FIELDS
#endif