diff options
Diffstat (limited to 'os/io/src')
-rw-r--r-- | os/io/src/adc.c | 27 | ||||
-rw-r--r-- | os/io/src/can.c | 16 | ||||
-rw-r--r-- | os/io/src/mac.c | 8 | ||||
-rw-r--r-- | os/io/src/mii.c | 10 | ||||
-rw-r--r-- | os/io/src/pal.c | 8 | ||||
-rw-r--r-- | os/io/src/serial.c | 8 | ||||
-rw-r--r-- | os/io/src/spi.c | 8 |
7 files changed, 59 insertions, 26 deletions
diff --git a/os/io/src/adc.c b/os/io/src/adc.c index af4508ab7..c074c0224 100644 --- a/os/io/src/adc.c +++ b/os/io/src/adc.c @@ -24,8 +24,10 @@ * @{
*/
-#include <ch.h>
-#include <adc.h>
+#include "ch.h"
+#include "hal.h"
+
+#if CH_HAL_USE_ADC
/**
* @brief ADC Driver initialization.
@@ -132,7 +134,8 @@ bool_t adcStartConversion(ADCDriver *adcp, chSysLock();
chDbgAssert((adcp->ad_state == ADC_READY) ||
- (adcp->ad_state == ADC_RUNNING),
+ (adcp->ad_state == ADC_RUNNING) ||
+ (adcp->ad_state == ADC_COMPLETE),
"adcStartConversion(), #1",
"invalid state");
if (adcp->ad_state == ADC_RUNNING) {
@@ -160,19 +163,26 @@ void adcStopConversion(ADCDriver *adcp) { chSysLock();
chDbgAssert((adcp->ad_state == ADC_READY) ||
- (adcp->ad_state == ADC_RUNNING),
+ (adcp->ad_state == ADC_RUNNING) ||
+ (adcp->ad_state == ADC_COMPLETE),
"adcStopConversion(), #1",
"invalid state");
if (adcp->ad_state == ADC_RUNNING) {
adc_lld_stop_conversion(adcp);
adcp->ad_grpp = NULL;
adcp->ad_state = ADC_READY;
+ chSemResetI(&adcp->ad_sem, 0);
+ chSchRescheduleS();
}
+ else
+ adcp->ad_state = ADC_READY;
chSysUnlock();
}
/**
* @brief Waits for completion.
+ * @details If the conversion is not completed or not yet started then the
+ * invoking thread waits for a conversion completion event.
* * @param[in] adcp pointer to the @p ADCDriver object
* @param[in] timeout the number of ticks before the operation timeouts,
@@ -181,17 +191,18 @@ void adcStopConversion(ADCDriver *adcp) { * - @a TIME_INFINITE no timeout.
* .
* @return The operation result.
- * @retval RDY_OK conversion finished (or not started).
+ * @retval RDY_OK conversion finished.
* @retval RDY_TIMEOUT conversion not finished within the specified time. */
msg_t adcWaitConversion(ADCDriver *adcp, systime_t timeout) {
chSysLock();
chDbgAssert((adcp->ad_state == ADC_READY) ||
- (adcp->ad_state == ADC_RUNNING),
+ (adcp->ad_state == ADC_RUNNING) ||
+ (adcp->ad_state == ADC_COMPLETE),
"adcWaitConversion(), #1",
"invalid state");
- if (adcp->ad_state == ADC_RUNNING) {
+ if (adcp->ad_state != ADC_COMPLETE) {
if (chSemWaitTimeoutS(&adcp->ad_sem, timeout) == RDY_TIMEOUT) {
chSysUnlock();
return RDY_TIMEOUT;
@@ -201,4 +212,6 @@ msg_t adcWaitConversion(ADCDriver *adcp, systime_t timeout) { return RDY_OK;
}
+#endif /* CH_HAL_USE_ADC */
+
/** @} */
diff --git a/os/io/src/can.c b/os/io/src/can.c index 4c88f9c71..bb3e0d1a5 100644 --- a/os/io/src/can.c +++ b/os/io/src/can.c @@ -24,8 +24,10 @@ * @{
*/
-#include <ch.h>
-#include <can.h>
+#include "ch.h"
+#include "hal.h"
+
+#if CH_HAL_USE_CAN
/**
* @brief CAN Driver initialization.
@@ -44,8 +46,8 @@ void canObjectInit(CANDriver *canp) { canp->can_state = CAN_STOP;
canp->can_config = NULL;
- chSemInit(&canp->can_txsem);
- chSemInit(&canp->can_rxsem);
+ chSemInit(&canp->can_txsem, 0);
+ chSemInit(&canp->can_rxsem, 0);
chEvtInit(&canp->can_rxfull_event);
chEvtInit(&canp->can_txempty_event);
#if CAN_USE_SLEEP_MODE
@@ -183,7 +185,7 @@ void canSleep(CANDriver *canp) { chDbgAssert((canp->can_state == CAN_READY) || (canp->can_state == CAN_SLEEP),
"canSleep(), #1",
"invalid state");
- if (canp->can_state = CAN_READY) {
+ if (canp->can_state == CAN_READY) {
can_lld_sleep(canp);
canp->can_state = CAN_SLEEP;
chEvtBroadcastI(&canp->can_sleep_event);
@@ -207,7 +209,7 @@ void canWakeup(CANDriver *canp) { chDbgAssert((canp->can_state == CAN_READY) || (canp->can_state == CAN_SLEEP),
"canWakeup(), #1",
"invalid state");
- if (canp->can_state = CAN_SLEEP) {
+ if (canp->can_state == CAN_SLEEP) {
can_lld_wakeup(canp);
canp->can_state = CAN_READY;
chEvtBroadcastI(&canp->can_wakeup_event);
@@ -217,4 +219,6 @@ void canWakeup(CANDriver *canp) { }
#endif /* CAN_USE_SLEEP_MODE */
+#endif /* CH_HAL_USE_CAN */
+
/** @} */
diff --git a/os/io/src/mac.c b/os/io/src/mac.c index 01541682e..8dfb400aa 100644 --- a/os/io/src/mac.c +++ b/os/io/src/mac.c @@ -24,8 +24,10 @@ * @{
*/
-#include <ch.h>
-#include <mac.h>
+#include "ch.h"
+#include "hal.h"
+
+#if CH_HAL_USE_MAC
/**
* @brief MAC Driver initialization. @@ -171,4 +173,6 @@ bool_t macPollLinkStatus(MACDriver *macp) { return mac_lld_poll_link_status(macp);
}
+#endif /* CH_HAL_USE_MAC */
+
/** @} */
diff --git a/os/io/src/mii.c b/os/io/src/mii.c index da36db9d2..4618ecbbb 100644 --- a/os/io/src/mii.c +++ b/os/io/src/mii.c @@ -24,14 +24,14 @@ * @{
*/
-#include <ch.h>
-#include <mac.h>
-#include <mii.h>
+#include "ch.h"
+#include "mac.h"
+#include "mii.h"
/*
- * Currently there is no code, everything is done in the header, you may
+ * Currently there is no code, everything is done in the header, you may
* omit this file from the project but this may change in future releases.
* The file is here because the driver's naming pattern.
*/
-
+
/** @} */
diff --git a/os/io/src/pal.c b/os/io/src/pal.c index f7645f621..1f9d058d5 100644 --- a/os/io/src/pal.c +++ b/os/io/src/pal.c @@ -24,8 +24,10 @@ * @{
*/
-#include <ch.h>
-#include <pal.h>
+#include "ch.h"
+#include "hal.h"
+
+#if CH_HAL_USE_PAL
/**
* @brief Read from an I/O bus.
@@ -91,4 +93,6 @@ void palSetBusMode(IOBus *bus, uint_fast8_t mode) { palSetGroupMode(bus->bus_portid, bus->bus_mask, mode);
}
+#endif /* CH_HAL_USE_PAL */
+
/** @} */
diff --git a/os/io/src/serial.c b/os/io/src/serial.c index 9c398f5f0..2944a98ab 100644 --- a/os/io/src/serial.c +++ b/os/io/src/serial.c @@ -24,8 +24,10 @@ * @{
*/
-#include <ch.h>
-#include <serial.h>
+#include "ch.h"
+#include "hal.h"
+
+#if CH_HAL_USE_SERIAL
/*
* Interface implementation, the following functions just invoke the equivalent
@@ -194,4 +196,6 @@ sdflags_t sdGetAndClearFlags(SerialDriver *sd) { return mask;
}
+#endif /* CH_HAL_USE_SERIAL */
+
/** @} */
diff --git a/os/io/src/spi.c b/os/io/src/spi.c index 4d45d217d..8b8ea6f32 100644 --- a/os/io/src/spi.c +++ b/os/io/src/spi.c @@ -24,8 +24,10 @@ * @{
*/
-#include <ch.h>
-#include <spi.h>
+#include "ch.h"
+#include "hal.h"
+
+#if CH_HAL_USE_SPI
/**
* @brief SPI Driver initialization.
@@ -255,4 +257,6 @@ void spiReleaseBus(SPIDriver *spip) { }
#endif /*SPI_USE_MUTUAL_EXCLUSION */
+#endif /* CH_HAL_USE_SPI */
+
/** @} */
|