aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/src
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2014-05-07 08:11:03 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2014-05-07 08:11:03 +0000
commitbec915e05274a94f2b1a5e2443f04de826dd1f6e (patch)
treecec2044911766f5dc5a7bd8b8c9ffe0fe81734f8 /os/hal/src
parent4afa0b98dff9eac6a94c104acf900e15147d2da3 (diff)
parentb43c71424d201583822b26d13d11f7e3634cb515 (diff)
downloadChibiOS-bec915e05274a94f2b1a5e2443f04de826dd1f6e.tar.gz
ChibiOS-bec915e05274a94f2b1a5e2443f04de826dd1f6e.tar.bz2
ChibiOS-bec915e05274a94f2b1a5e2443f04de826dd1f6e.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@6916 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/src')
-rw-r--r--os/hal/src/adc.c96
-rw-r--r--os/hal/src/can.c127
-rw-r--r--os/hal/src/dac.c118
-rw-r--r--os/hal/src/ext.c59
-rw-r--r--os/hal/src/gpt.c78
-rw-r--r--os/hal/src/hal.c89
-rw-r--r--os/hal/src/hal_mmcsd.c (renamed from os/hal/src/mmcsd.c)5
-rw-r--r--os/hal/src/hal_queues.c402
-rw-r--r--os/hal/src/i2c.c100
-rw-r--r--os/hal/src/i2s.c62
-rw-r--r--os/hal/src/icu.c41
-rw-r--r--os/hal/src/mac.c272
-rw-r--r--os/hal/src/mmc_spi.c99
-rw-r--r--os/hal/src/pal.c10
-rw-r--r--os/hal/src/pwm.c50
-rw-r--r--os/hal/src/rtc.c186
-rw-r--r--os/hal/src/sdc.c179
-rw-r--r--os/hal/src/serial.c69
-rw-r--r--os/hal/src/serial_usb.c105
-rw-r--r--os/hal/src/spi.c140
-rw-r--r--os/hal/src/st.c (renamed from os/hal/src/tm.c)120
-rw-r--r--os/hal/src/uart.c99
-rw-r--r--os/hal/src/usb.c100
23 files changed, 1180 insertions, 1426 deletions
diff --git a/os/hal/src/adc.c b/os/hal/src/adc.c
index d0e814ae2..e6d8d8075 100644
--- a/os/hal/src/adc.c
+++ b/os/hal/src/adc.c
@@ -26,7 +26,6 @@
* @{
*/
-#include "ch.h"
#include "hal.h"
#if HAL_USE_ADC || defined(__DOXYGEN__)
@@ -81,11 +80,7 @@ void adcObjectInit(ADCDriver *adcp) {
adcp->thread = NULL;
#endif /* ADC_USE_WAIT */
#if ADC_USE_MUTUAL_EXCLUSION
-#if CH_USE_MUTEXES
- chMtxInit(&adcp->mutex);
-#else
- chSemInit(&adcp->semaphore, 1);
-#endif
+ osalMutexObjectInit(&adcp->mutex);
#endif /* ADC_USE_MUTUAL_EXCLUSION */
#if defined(ADC_DRIVER_EXT_INIT_HOOK)
ADC_DRIVER_EXT_INIT_HOOK(adcp);
@@ -103,15 +98,15 @@ void adcObjectInit(ADCDriver *adcp) {
*/
void adcStart(ADCDriver *adcp, const ADCConfig *config) {
- chDbgCheck(adcp != NULL, "adcStart");
+ osalDbgCheck(adcp != NULL);
- chSysLock();
- chDbgAssert((adcp->state == ADC_STOP) || (adcp->state == ADC_READY),
- "adcStart(), #1", "invalid state");
+ osalSysLock();
+ osalDbgAssert((adcp->state == ADC_STOP) || (adcp->state == ADC_READY),
+ "invalid state");
adcp->config = config;
adc_lld_start(adcp);
adcp->state = ADC_READY;
- chSysUnlock();
+ osalSysUnlock();
}
/**
@@ -123,14 +118,14 @@ void adcStart(ADCDriver *adcp, const ADCConfig *config) {
*/
void adcStop(ADCDriver *adcp) {
- chDbgCheck(adcp != NULL, "adcStop");
+ osalDbgCheck(adcp != NULL);
- chSysLock();
- chDbgAssert((adcp->state == ADC_STOP) || (adcp->state == ADC_READY),
- "adcStop(), #1", "invalid state");
+ osalSysLock();
+ osalDbgAssert((adcp->state == ADC_STOP) || (adcp->state == ADC_READY),
+ "invalid state");
adc_lld_stop(adcp);
adcp->state = ADC_STOP;
- chSysUnlock();
+ osalSysUnlock();
}
/**
@@ -154,9 +149,9 @@ void adcStartConversion(ADCDriver *adcp,
adcsample_t *samples,
size_t depth) {
- chSysLock();
+ osalSysLock();
adcStartConversionI(adcp, grpp, samples, depth);
- chSysUnlock();
+ osalSysUnlock();
}
/**
@@ -182,14 +177,13 @@ void adcStartConversionI(ADCDriver *adcp,
adcsample_t *samples,
size_t depth) {
- chDbgCheckClassI();
- chDbgCheck((adcp != NULL) && (grpp != NULL) && (samples != NULL) &&
- ((depth == 1) || ((depth & 1) == 0)),
- "adcStartConversionI");
- chDbgAssert((adcp->state == ADC_READY) ||
- (adcp->state == ADC_COMPLETE) ||
- (adcp->state == ADC_ERROR),
- "adcStartConversionI(), #1", "not ready");
+ osalDbgCheckClassI();
+ osalDbgCheck((adcp != NULL) && (grpp != NULL) && (samples != NULL) &&
+ ((depth == 1) || ((depth & 1) == 0)));
+ osalDbgAssert((adcp->state == ADC_READY) ||
+ (adcp->state == ADC_COMPLETE) ||
+ (adcp->state == ADC_ERROR),
+ "not ready");
adcp->samples = samples;
adcp->depth = depth;
@@ -210,19 +204,18 @@ void adcStartConversionI(ADCDriver *adcp,
*/
void adcStopConversion(ADCDriver *adcp) {
- chDbgCheck(adcp != NULL, "adcStopConversion");
+ osalDbgCheck(adcp != NULL);
- chSysLock();
- chDbgAssert((adcp->state == ADC_READY) ||
- (adcp->state == ADC_ACTIVE),
- "adcStopConversion(), #1", "invalid state");
+ osalSysLock();
+ osalDbgAssert((adcp->state == ADC_READY) || (adcp->state == ADC_ACTIVE),
+ "invalid state");
if (adcp->state != ADC_READY) {
adc_lld_stop_conversion(adcp);
adcp->grpp = NULL;
adcp->state = ADC_READY;
_adc_reset_s(adcp);
}
- chSysUnlock();
+ osalSysUnlock();
}
/**
@@ -237,12 +230,12 @@ void adcStopConversion(ADCDriver *adcp) {
*/
void adcStopConversionI(ADCDriver *adcp) {
- chDbgCheckClassI();
- chDbgCheck(adcp != NULL, "adcStopConversionI");
- chDbgAssert((adcp->state == ADC_READY) ||
- (adcp->state == ADC_ACTIVE) ||
- (adcp->state == ADC_COMPLETE),
- "adcStopConversionI(), #1", "invalid state");
+ osalDbgCheckClassI();
+ osalDbgCheck(adcp != NULL);
+ osalDbgAssert((adcp->state == ADC_READY) ||
+ (adcp->state == ADC_ACTIVE) ||
+ (adcp->state == ADC_COMPLETE),
+ "invalid state");
if (adcp->state != ADC_READY) {
adc_lld_stop_conversion(adcp);
@@ -282,13 +275,11 @@ msg_t adcConvert(ADCDriver *adcp,
size_t depth) {
msg_t msg;
- chSysLock();
- chDbgAssert(adcp->thread == NULL, "adcConvert(), #1", "already waiting");
+ osalSysLock();
+ osalDbgAssert(adcp->thread == NULL, "already waiting");
adcStartConversionI(adcp, grpp, samples, depth);
- adcp->thread = chThdSelf();
- chSchGoSleepS(THD_STATE_SUSPENDED);
- msg = chThdSelf()->p_u.rdymsg;
- chSysUnlock();
+ msg = osalThreadSuspendS(&adcp->thread);
+ osalSysUnlock();
return msg;
}
#endif /* ADC_USE_WAIT */
@@ -307,13 +298,9 @@ msg_t adcConvert(ADCDriver *adcp,
*/
void adcAcquireBus(ADCDriver *adcp) {
- chDbgCheck(adcp != NULL, "adcAcquireBus");
+ osalDbgCheck(adcp != NULL);
-#if CH_USE_MUTEXES
- chMtxLock(&adcp->mutex);
-#elif CH_USE_SEMAPHORES
- chSemWait(&adcp->semaphore);
-#endif
+ osalMutexLock(&adcp->mutex);
}
/**
@@ -327,14 +314,9 @@ void adcAcquireBus(ADCDriver *adcp) {
*/
void adcReleaseBus(ADCDriver *adcp) {
- chDbgCheck(adcp != NULL, "adcReleaseBus");
+ osalDbgCheck(adcp != NULL);
-#if CH_USE_MUTEXES
- (void)adcp;
- chMtxUnlock();
-#elif CH_USE_SEMAPHORES
- chSemSignal(&adcp->semaphore);
-#endif
+ osalMutexUnlock(&adcp->mutex);
}
#endif /* ADC_USE_MUTUAL_EXCLUSION */
diff --git a/os/hal/src/can.c b/os/hal/src/can.c
index 3f1f7588f..92efdf7e7 100644
--- a/os/hal/src/can.c
+++ b/os/hal/src/can.c
@@ -26,7 +26,6 @@
* @{
*/
-#include "ch.h"
#include "hal.h"
#if HAL_USE_CAN || defined(__DOXYGEN__)
@@ -74,14 +73,14 @@ void canObjectInit(CANDriver *canp) {
canp->state = CAN_STOP;
canp->config = NULL;
- chSemInit(&canp->txsem, 0);
- chSemInit(&canp->rxsem, 0);
- chEvtInit(&canp->rxfull_event);
- chEvtInit(&canp->txempty_event);
- chEvtInit(&canp->error_event);
+ osalThreadQueueObjectInit(&canp->txqueue);
+ osalThreadQueueObjectInit(&canp->rxqueue);
+ osalEventObjectInit(&canp->rxfull_event);
+ osalEventObjectInit(&canp->txempty_event);
+ osalEventObjectInit(&canp->error_event);
#if CAN_USE_SLEEP_MODE
- chEvtInit(&canp->sleep_event);
- chEvtInit(&canp->wakeup_event);
+ osalEventObjectInit(&canp->sleep_event);
+ osalEventObjectInit(&canp->wakeup_event);
#endif /* CAN_USE_SLEEP_MODE */
}
@@ -99,21 +98,21 @@ void canObjectInit(CANDriver *canp) {
*/
void canStart(CANDriver *canp, const CANConfig *config) {
- chDbgCheck(canp != NULL, "canStart");
+ osalDbgCheck(canp != NULL);
- chSysLock();
- chDbgAssert((canp->state == CAN_STOP) ||
- (canp->state == CAN_STARTING) ||
- (canp->state == CAN_READY),
- "canStart(), #1", "invalid state");
+ osalSysLock();
+ osalDbgAssert((canp->state == CAN_STOP) ||
+ (canp->state == CAN_STARTING) ||
+ (canp->state == CAN_READY),
+ "invalid state");
while (canp->state == CAN_STARTING)
- chThdSleepS(1);
+ osalThreadSleepS(1);
if (canp->state == CAN_STOP) {
canp->config = config;
can_lld_start(canp);
canp->state = CAN_READY;
}
- chSysUnlock();
+ osalSysUnlock();
}
/**
@@ -125,17 +124,17 @@ void canStart(CANDriver *canp, const CANConfig *config) {
*/
void canStop(CANDriver *canp) {
- chDbgCheck(canp != NULL, "canStop");
+ osalDbgCheck(canp != NULL);
- chSysLock();
- chDbgAssert((canp->state == CAN_STOP) || (canp->state == CAN_READY),
- "canStop(), #1", "invalid state");
+ osalSysLock();
+ osalDbgAssert((canp->state == CAN_STOP) || (canp->state == CAN_READY),
+ "invalid state");
can_lld_stop(canp);
canp->state = CAN_STOP;
- chSemResetI(&canp->rxsem, 0);
- chSemResetI(&canp->txsem, 0);
- chSchRescheduleS();
- chSysUnlock();
+ osalThreadDequeueAllI(&canp->rxqueue, MSG_RESET);
+ osalThreadDequeueAllI(&canp->txqueue, MSG_RESET);
+ osalOsRescheduleS();
+ osalSysUnlock();
}
/**
@@ -153,9 +152,9 @@ void canStop(CANDriver *canp) {
* - @a TIME_INFINITE no timeout.
* .
* @return The operation result.
- * @retval RDY_OK the frame has been queued for transmission.
- * @retval RDY_TIMEOUT The operation has timed out.
- * @retval RDY_RESET The driver has been stopped while waiting.
+ * @retval MSG_OK the frame has been queued for transmission.
+ * @retval MSG_TIMEOUT The operation has timed out.
+ * @retval MSG_RESET The driver has been stopped while waiting.
*
* @api
*/
@@ -164,22 +163,22 @@ msg_t canTransmit(CANDriver *canp,
const CANTxFrame *ctfp,
systime_t timeout) {
- chDbgCheck((canp != NULL) && (ctfp != NULL) && (mailbox <= CAN_TX_MAILBOXES),
- "canTransmit");
+ osalDbgCheck((canp != NULL) && (ctfp != NULL) &&
+ (mailbox <= CAN_TX_MAILBOXES));
- chSysLock();
- chDbgAssert((canp->state == CAN_READY) || (canp->state == CAN_SLEEP),
- "canTransmit(), #1", "invalid state");
+ osalSysLock();
+ osalDbgAssert((canp->state == CAN_READY) || (canp->state == CAN_SLEEP),
+ "invalid state");
while ((canp->state == CAN_SLEEP) || !can_lld_is_tx_empty(canp, mailbox)) {
- msg_t msg = chSemWaitTimeoutS(&canp->txsem, timeout);
- if (msg != RDY_OK) {
- chSysUnlock();
+ msg_t msg = osalThreadEnqueueTimeoutS(&canp->txqueue, timeout);
+ if (msg != MSG_OK) {
+ osalSysUnlock();
return msg;
}
}
can_lld_transmit(canp, mailbox, ctfp);
- chSysUnlock();
- return RDY_OK;
+ osalSysUnlock();
+ return MSG_OK;
}
/**
@@ -198,9 +197,9 @@ msg_t canTransmit(CANDriver *canp,
* - @a TIME_INFINITE no timeout.
* .
* @return The operation result.
- * @retval RDY_OK a frame has been received and placed in the buffer.
- * @retval RDY_TIMEOUT The operation has timed out.
- * @retval RDY_RESET The driver has been stopped while waiting.
+ * @retval MSG_OK a frame has been received and placed in the buffer.
+ * @retval MSG_TIMEOUT The operation has timed out.
+ * @retval MSG_RESET The driver has been stopped while waiting.
*
* @api
*/
@@ -209,22 +208,22 @@ msg_t canReceive(CANDriver *canp,
CANRxFrame *crfp,
systime_t timeout) {
- chDbgCheck((canp != NULL) && (crfp != NULL) && (mailbox < CAN_RX_MAILBOXES),
- "canReceive");
+ osalDbgCheck((canp != NULL) && (crfp != NULL) &&
+ (mailbox < CAN_RX_MAILBOXES));
- chSysLock();
- chDbgAssert((canp->state == CAN_READY) || (canp->state == CAN_SLEEP),
- "canReceive(), #1", "invalid state");
+ osalSysLock();
+ osalDbgAssert((canp->state == CAN_READY) || (canp->state == CAN_SLEEP),
+ "invalid state");
while ((canp->state == CAN_SLEEP) || !can_lld_is_rx_nonempty(canp, mailbox)) {
- msg_t msg = chSemWaitTimeoutS(&canp->rxsem, timeout);
- if (msg != RDY_OK) {
- chSysUnlock();
+ msg_t msg = osalThreadEnqueueTimeoutS(&canp->rxqueue, timeout);
+ if (msg != MSG_OK) {
+ osalSysUnlock();
return msg;
}
}
can_lld_receive(canp, mailbox, crfp);
- chSysUnlock();
- return RDY_OK;
+ osalSysUnlock();
+ return MSG_OK;
}
#if CAN_USE_SLEEP_MODE || defined(__DOXYGEN__)
@@ -242,18 +241,18 @@ msg_t canReceive(CANDriver *canp,
*/
void canSleep(CANDriver *canp) {
- chDbgCheck(canp != NULL, "canSleep");
+ osalDbgCheck(canp != NULL);
- chSysLock();
- chDbgAssert((canp->state == CAN_READY) || (canp->state == CAN_SLEEP),
- "canSleep(), #1", "invalid state");
+ osalSysLock();
+ osalDbgAssert((canp->state == CAN_READY) || (canp->state == CAN_SLEEP),
+ "invalid state");
if (canp->state == CAN_READY) {
can_lld_sleep(canp);
canp->state = CAN_SLEEP;
- chEvtBroadcastI(&canp->sleep_event);
- chSchRescheduleS();
+ osalEventBroadcastFlagsI(&canp->sleep_event, 0);
+ osalOsRescheduleS();
}
- chSysUnlock();
+ osalSysUnlock();
}
/**
@@ -265,18 +264,18 @@ void canSleep(CANDriver *canp) {
*/
void canWakeup(CANDriver *canp) {
- chDbgCheck(canp != NULL, "canWakeup");
+ osalDbgCheck(canp != NULL);
- chSysLock();
- chDbgAssert((canp->state == CAN_READY) || (canp->state == CAN_SLEEP),
- "canWakeup(), #1", "invalid state");
+ osalSysLock();
+ osalDbgAssert((canp->state == CAN_READY) || (canp->state == CAN_SLEEP),
+ "invalid state");
if (canp->state == CAN_SLEEP) {
can_lld_wakeup(canp);
canp->state = CAN_READY;
- chEvtBroadcastI(&canp->wakeup_event);
- chSchRescheduleS();
+ osalEventBroadcastFlagsI(&canp->wakeup_event, 0);
+ osalOsRescheduleS();
}
- chSysUnlock();
+ osalSysUnlock();
}
#endif /* CAN_USE_SLEEP_MODE */
diff --git a/os/hal/src/dac.c b/os/hal/src/dac.c
index 3ab09f27c..42521c107 100644
--- a/os/hal/src/dac.c
+++ b/os/hal/src/dac.c
@@ -1,6 +1,6 @@
/*
ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010,
- 2011,2012 Giovanni Di Sirio.
+ 2011,2012,2013 Giovanni Di Sirio.
This file is part of ChibiOS/RT.
@@ -26,7 +26,6 @@
* @{
*/
-#include "ch.h"
#include "hal.h"
#if HAL_USE_DAC || defined(__DOXYGEN__)
@@ -78,11 +77,7 @@ void dacObjectInit(DACDriver *dacp) {
dacp->thread = NULL;
#endif /* DAC_USE_WAIT */
#if DAC_USE_MUTUAL_EXCLUSION
-#if CH_USE_MUTEXES
- chMtxInit(&dacp->mutex);
-#else
- chSemInit(&dacp->semaphore, 1);
-#endif
+ osalMutexObjectInit(&dacp->mutex);
#endif /* DAC_USE_MUTUAL_EXCLUSION */
#if defined(DAC_DRIVER_EXT_INIT_HOOK)
DAC_DRIVER_EXT_INIT_HOOK(dacp);
@@ -99,15 +94,18 @@ void dacObjectInit(DACDriver *dacp) {
*/
void dacStart(DACDriver *dacp, const DACConfig *config) {
- chDbgCheck((dacp != NULL) && (config != NULL), "dacStart");
+ osalDbgCheck((dacp != NULL) && (config != NULL));
+
+ osalSysLock();
+
+ osalDbgAssert((dacp->state == DAC_STOP) || (dacp->state == DAC_READY),
+ "invalid state");
- chSysLock();
- chDbgAssert((dacp->state == DAC_STOP) || (dacp->state == DAC_READY),
- "dacStart(), #1", "invalid state");
dacp->config = config;
dac_lld_start(dacp);
dacp->state = DAC_READY;
- chSysUnlock();
+
+ osalSysUnlock();
}
/**
@@ -121,14 +119,17 @@ void dacStart(DACDriver *dacp, const DACConfig *config) {
*/
void dacStop(DACDriver *dacp) {
- chDbgCheck(dacp != NULL, "dacStop");
+ osalDbgCheck(dacp != NULL);
+
+ osalSysLock();
+
+ osalDbgAssert((dacp->state == DAC_STOP) || (dacp->state == DAC_READY),
+ "invalid state");
- chSysLock();
- chDbgAssert((dacp->state == DAC_STOP) || (dacp->state == DAC_READY),
- "dacStop(), #1", "invalid state");
dac_lld_stop(dacp);
dacp->state = DAC_STOP;
- chSysUnlock();
+
+ osalSysUnlock();
}
/**
@@ -152,9 +153,9 @@ void dacStartConversion(DACDriver *dacp,
const dacsample_t *samples,
size_t depth) {
- chSysLock();
+ osalSysLock();
dacStartConversionI(dacp, grpp, samples, depth);
- chSysUnlock();
+ osalSysUnlock();
}
/**
@@ -180,14 +181,13 @@ void dacStartConversionI(DACDriver *dacp,
const dacsample_t *samples,
size_t depth) {
- chDbgCheckClassI();
- chDbgCheck((dacp != NULL) && (grpp != NULL) && (samples != NULL) &&
- ((depth == 1) || ((depth & 1) == 0)),
- "dacStartConversionI");
- chDbgAssert((dacp->state == DAC_READY) ||
- (dacp->state == DAC_COMPLETE) ||
- (dacp->state == DAC_ERROR),
- "dacStartConversionI(), #1", "not ready");
+ osalDbgCheckClassI();
+ osalDbgCheck((dacp != NULL) && (grpp != NULL) && (samples != NULL) &&
+ ((depth == 1) || ((depth & 1) == 0)));
+ osalDbgAssert((dacp->state == DAC_READY) ||
+ (dacp->state == DAC_COMPLETE) ||
+ (dacp->state == DAC_ERROR),
+ "not ready");
dacp->samples = samples;
dacp->depth = depth;
@@ -208,19 +208,22 @@ void dacStartConversionI(DACDriver *dacp,
*/
void dacStopConversion(DACDriver *dacp) {
- chDbgCheck(dacp != NULL, "dacStopConversion");
+ osalDbgCheck(dacp != NULL);
+
+ osalSysLock();
+
+ osalDbgAssert((dacp->state == DAC_READY) ||
+ (dacp->state == DAC_ACTIVE),
+ "invalid state");
- chSysLock();
- chDbgAssert((dacp->state == DAC_READY) ||
- (dacp->state == DAC_ACTIVE),
- "dacStopConversion(), #1", "invalid state");
if (dacp->state != DAC_READY) {
dac_lld_stop_conversion(dacp);
dacp->grpp = NULL;
dacp->state = DAC_READY;
_dac_reset_s(dacp);
}
- chSysUnlock();
+
+ osalSysUnlock();
}
/**
@@ -235,12 +238,12 @@ void dacStopConversion(DACDriver *dacp) {
*/
void dacStopConversionI(DACDriver *dacp) {
- chDbgCheckClassI();
- chDbgCheck(dacp != NULL, "dacStopConversionI");
- chDbgAssert((dacp->state == DAC_READY) ||
- (dacp->state == DAC_ACTIVE) ||
- (dacp->state == DAC_COMPLETE),
- "dacStopConversionI(), #1", "invalid state");
+ osalDbgCheckClassI();
+ osalDbgCheck(dacp != NULL);
+ osalDbgAssert((dacp->state == DAC_READY) ||
+ (dacp->state == DAC_ACTIVE) ||
+ (dacp->state == DAC_COMPLETE),
+ "invalid state");
if (dacp->state != DAC_READY) {
dac_lld_stop_conversion(dacp);
@@ -265,11 +268,11 @@ void dacStopConversionI(DACDriver *dacp) {
* @param[in] depth buffer depth (matrix rows number). The buffer depth
* must be one or an even number.
* @return The operation result.
- * @retval RDY_OK Conversion finished.
- * @retval RDY_RESET The conversion has been stopped using
+ * @retval MSG_OK Conversion finished.
+ * @retval MSG_RESET The conversion has been stopped using
* @p acdStopConversion() or @p acdStopConversionI(),
* the result buffer may contain incorrect data.
- * @retval RDY_TIMEOUT The conversion has been stopped because an hardware
+ * @retval MSG_TIMEOUT The conversion has been stopped because an hardware
* error.
*
* @api
@@ -280,12 +283,12 @@ msg_t dacConvert(DACDriver *dacp,
size_t depth) {
msg_t msg;
- chSysLock();
- chDbgAssert(dacp->thread == NULL, "dacConvert(), #1", "already waiting");
+ osalSysLock();
+
dacStartConversionI(dacp, grpp, samples, depth);
- _dac_wait_s(dacp);
- msg = chThdSelf()->p_u.rdymsg;
- chSysUnlock();
+ msg = osalThreadSuspendS(&dacp->thread);
+
+ osalSysUnlock();
return msg;
}
#endif /* DAC_USE_WAIT */
@@ -304,13 +307,9 @@ msg_t dacConvert(DACDriver *dacp,
*/
void dacAcquireBus(DACDriver *dacp) {
- chDbgCheck(dacp != NULL, "dacAcquireBus");
-
-#if CH_USE_MUTEXES
- chMtxLock(&dacp->mutex);
-#elif CH_USE_SEMAPHORES
- chSemWait(&dacp->semaphore);
-#endif
+ osalDbgCheck(dacp != NULL);
+
+ osalMutexLock(&dacp->mutex);
}
/**
@@ -324,14 +323,9 @@ void dacAcquireBus(DACDriver *dacp) {
*/
void dacReleaseBus(DACDriver *dacp) {
- chDbgCheck(dacp != NULL, "dacReleaseBus");
-
-#if CH_USE_MUTEXES
- (void)dacp;
- chMtxUnlock();
-#elif CH_USE_SEMAPHORES
- chSemSignal(&dacp->semaphore);
-#endif
+ osalDbgCheck(dacp != NULL);
+
+ osalMutexUnlock(&dacp->mutex);
}
#endif /* DAC_USE_MUTUAL_EXCLUSION */
diff --git a/os/hal/src/ext.c b/os/hal/src/ext.c
index a0dc9f38e..81c92525a 100644
--- a/os/hal/src/ext.c
+++ b/os/hal/src/ext.c
@@ -26,7 +26,6 @@
* @{
*/
-#include "ch.h"
#include "hal.h"
#if HAL_USE_EXT || defined(__DOXYGEN__)
@@ -88,15 +87,15 @@ void extObjectInit(EXTDriver *extp) {
*/
void extStart(EXTDriver *extp, const EXTConfig *config) {
- chDbgCheck((extp != NULL) && (config != NULL), "extStart");
+ osalDbgCheck((extp != NULL) && (config != NULL));
- chSysLock();
- chDbgAssert((extp->state == EXT_STOP) || (extp->state == EXT_ACTIVE),
- "extStart(), #1", "invalid state");
+ osalSysLock();
+ osalDbgAssert((extp->state == EXT_STOP) || (extp->state == EXT_ACTIVE),
+ "invalid state");
extp->config = config;
ext_lld_start(extp);
extp->state = EXT_ACTIVE;
- chSysUnlock();
+ osalSysUnlock();
}
/**
@@ -108,14 +107,14 @@ void extStart(EXTDriver *extp, const EXTConfig *config) {
*/
void extStop(EXTDriver *extp) {
- chDbgCheck(extp != NULL, "extStop");
+ osalDbgCheck(extp != NULL);
- chSysLock();
- chDbgAssert((extp->state == EXT_STOP) || (extp->state == EXT_ACTIVE),
- "extStop(), #1", "invalid state");
+ osalSysLock();
+ osalDbgAssert((extp->state == EXT_STOP) || (extp->state == EXT_ACTIVE),
+ "invalid state");
ext_lld_stop(extp);
extp->state = EXT_STOP;
- chSysUnlock();
+ osalSysUnlock();
}
/**
@@ -129,16 +128,15 @@ void extStop(EXTDriver *extp) {
*/
void extChannelEnable(EXTDriver *extp, expchannel_t channel) {
- chDbgCheck((extp != NULL) && (channel < EXT_MAX_CHANNELS),
- "extChannelEnable");
+ osalDbgCheck((extp != NULL) && (channel < EXT_MAX_CHANNELS));
- chSysLock();
- chDbgAssert((extp->state == EXT_ACTIVE) &&
- ((extp->config->channels[channel].mode &
- EXT_CH_MODE_EDGES_MASK) != EXT_CH_MODE_DISABLED),
- "extChannelEnable(), #1", "invalid state");
+ osalSysLock();
+ osalDbgAssert((extp->state == EXT_ACTIVE) &&
+ ((extp->config->channels[channel].mode &
+ EXT_CH_MODE_EDGES_MASK) != EXT_CH_MODE_DISABLED),
+ "invalid state");
extChannelEnableI(extp, channel);
- chSysUnlock();
+ osalSysUnlock();
}
/**
@@ -152,16 +150,15 @@ void extChannelEnable(EXTDriver *extp, expchannel_t channel) {
*/
void extChannelDisable(EXTDriver *extp, expchannel_t channel) {
- chDbgCheck((extp != NULL) && (channel < EXT_MAX_CHANNELS),
- "extChannelDisable");
+ osalDbgCheck((extp != NULL) && (channel < EXT_MAX_CHANNELS));
- chSysLock();
- chDbgAssert((extp->state == EXT_ACTIVE) &&
- ((extp->config->channels[channel].mode &
- EXT_CH_MODE_EDGES_MASK) != EXT_CH_MODE_DISABLED),
- "extChannelDisable(), #1", "invalid state");
+ osalSysLock();
+ osalDbgAssert((extp->state == EXT_ACTIVE) &&
+ ((extp->config->channels[channel].mode &
+ EXT_CH_MODE_EDGES_MASK) != EXT_CH_MODE_DISABLED),
+ "invalid state");
extChannelDisableI(extp, channel);
- chSysUnlock();
+ osalSysUnlock();
}
/**
@@ -186,11 +183,11 @@ void extSetChannelModeI(EXTDriver *extp,
const EXTChannelConfig *extcp) {
EXTChannelConfig *oldcp;
- chDbgCheck((extp != NULL) && (channel < EXT_MAX_CHANNELS) &&
- (extcp != NULL), "extSetChannelModeI");
+ osalDbgCheck((extp != NULL) &&
+ (channel < EXT_MAX_CHANNELS) &&
+ (extcp != NULL));
- chDbgAssert(extp->state == EXT_ACTIVE,
- "extSetChannelModeI(), #1", "invalid state");
+ osalDbgAssert(extp->state == EXT_ACTIVE, "invalid state");
/* Note that here the access is enforced as non-const, known access
violation.*/
diff --git a/os/hal/src/gpt.c b/os/hal/src/gpt.c
index eefeb8e32..52bf6610f 100644
--- a/os/hal/src/gpt.c
+++ b/os/hal/src/gpt.c
@@ -26,7 +26,6 @@
* @{
*/
-#include "ch.h"
#include "hal.h"
#if HAL_USE_GPT || defined(__DOXYGEN__)
@@ -86,15 +85,15 @@ void gptObjectInit(GPTDriver *gptp) {
*/
void gptStart(GPTDriver *gptp, const GPTConfig *config) {
- chDbgCheck((gptp != NULL) && (config != NULL), "gptStart");
+ osalDbgCheck((gptp != NULL) && (config != NULL));
- chSysLock();
- chDbgAssert((gptp->state == GPT_STOP) || (gptp->state == GPT_READY),
- "gptStart(), #1", "invalid state");
+ osalSysLock();
+ osalDbgAssert((gptp->state == GPT_STOP) || (gptp->state == GPT_READY),
+ "invalid state");
gptp->config = config;
gpt_lld_start(gptp);
gptp->state = GPT_READY;
- chSysUnlock();
+ osalSysUnlock();
}
/**
@@ -106,22 +105,20 @@ void gptStart(GPTDriver *gptp, const GPTConfig *config) {
*/
void gptStop(GPTDriver *gptp) {
- chDbgCheck(gptp != NULL, "gptStop");
+ osalDbgCheck(gptp != NULL);
- chSysLock();
- chDbgAssert((gptp->state == GPT_STOP) || (gptp->state == GPT_READY),
- "gptStop(), #1", "invalid state");
+ osalSysLock();
+ osalDbgAssert((gptp->state == GPT_STOP) || (gptp->state == GPT_READY),
+ "invalid state");
gpt_lld_stop(gptp);
gptp->state = GPT_STOP;
- chSysUnlock();
+ osalSysUnlock();
}
/**
* @brief Changes the interval of GPT peripheral.
* @details This function changes the interval of a running GPT unit.
- * @pre The GPT unit must have been activated using @p gptStart().
- * @pre The GPT unit must have been running in continuous mode using
- * @p gptStartContinuous().
+ * @pre The GPT unit must be running in continuous mode.
* @post The GPT unit interval is changed to the new value.
*
* @param[in] gptp pointer to a @p GPTDriver object
@@ -131,13 +128,13 @@ void gptStop(GPTDriver *gptp) {
*/
void gptChangeInterval(GPTDriver *gptp, gptcnt_t interval) {
- chDbgCheck(gptp != NULL, "gptChangeInterval");
+ osalDbgCheck(gptp != NULL);
- chSysLock();
- chDbgAssert(gptp->state == GPT_CONTINUOUS,
- "gptChangeInterval(), #1", "invalid state");
+ osalSysLock();
+ osalDbgAssert(gptp->state == GPT_CONTINUOUS,
+ "invalid state");
gptChangeIntervalI(gptp, interval);
- chSysUnlock();
+ osalSysUnlock();
}
/**
@@ -150,9 +147,9 @@ void gptChangeInterval(GPTDriver *gptp, gptcnt_t interval) {
*/
void gptStartContinuous(GPTDriver *gptp, gptcnt_t interval) {
- chSysLock();
+ osalSysLock();
gptStartContinuousI(gptp, interval);
- chSysUnlock();
+ osalSysUnlock();
}
/**
@@ -165,10 +162,10 @@ void gptStartContinuous(GPTDriver *gptp, gptcnt_t interval) {
*/
void gptStartContinuousI(GPTDriver *gptp, gptcnt_t interval) {
- chDbgCheckClassI();
- chDbgCheck(gptp != NULL, "gptStartContinuousI");
- chDbgAssert(gptp->state == GPT_READY,
- "gptStartContinuousI(), #1", "invalid state");
+ osalDbgCheckClassI();
+ osalDbgCheck(gptp != NULL);
+ osalDbgAssert(gptp->state == GPT_READY,
+ "invalid state");
gptp->state = GPT_CONTINUOUS;
gpt_lld_start_timer(gptp, interval);
@@ -184,9 +181,9 @@ void gptStartContinuousI(GPTDriver *gptp, gptcnt_t interval) {
*/
void gptStartOneShot(GPTDriver *gptp, gptcnt_t interval) {
- chSysLock();
+ osalSysLock();
gptStartOneShotI(gptp, interval);
- chSysUnlock();
+ osalSysUnlock();
}
/**
@@ -199,10 +196,11 @@ void gptStartOneShot(GPTDriver *gptp, gptcnt_t interval) {
*/
void gptStartOneShotI(GPTDriver *gptp, gptcnt_t interval) {
- chDbgCheckClassI();
- chDbgCheck(gptp != NULL, "gptStartOneShotI");
- chDbgAssert(gptp->state == GPT_READY,
- "gptStartOneShotI(), #1", "invalid state");
+ osalDbgCheckClassI();
+ osalDbgCheck(gptp != NULL);
+ osalDbgCheck(gptp->config->callback != NULL);
+ osalDbgAssert(gptp->state == GPT_READY,
+ "invalid state");
gptp->state = GPT_ONESHOT;
gpt_lld_start_timer(gptp, interval);
@@ -217,9 +215,9 @@ void gptStartOneShotI(GPTDriver *gptp, gptcnt_t interval) {
*/
void gptStopTimer(GPTDriver *gptp) {
- chSysLock();
+ osalSysLock();
gptStopTimerI(gptp);
- chSysUnlock();
+ osalSysUnlock();
}
/**
@@ -231,11 +229,11 @@ void gptStopTimer(GPTDriver *gptp) {
*/
void gptStopTimerI(GPTDriver *gptp) {
- chDbgCheckClassI();
- chDbgCheck(gptp != NULL, "gptStopTimerI");
- chDbgAssert((gptp->state == GPT_READY) || (gptp->state == GPT_CONTINUOUS) ||
- (gptp->state == GPT_ONESHOT),
- "gptStopTimerI(), #1", "invalid state");
+ osalDbgCheckClassI();
+ osalDbgCheck(gptp != NULL);
+ osalDbgAssert((gptp->state == GPT_READY) || (gptp->state == GPT_CONTINUOUS) ||
+ (gptp->state == GPT_ONESHOT),
+ "invalid state");
gptp->state = GPT_READY;
gpt_lld_stop_timer(gptp);
@@ -255,8 +253,8 @@ void gptStopTimerI(GPTDriver *gptp) {
*/
void gptPolledDelay(GPTDriver *gptp, gptcnt_t interval) {
- chDbgAssert(gptp->state == GPT_READY,
- "gptPolledDelay(), #1", "invalid state");
+ osalDbgAssert(gptp->state == GPT_READY,
+ "invalid state");
gptp->state = GPT_ONESHOT;
gpt_lld_polled_delay(gptp, interval);
diff --git a/os/hal/src/hal.c b/os/hal/src/hal.c
index d7a088ec9..aa3eca165 100644
--- a/os/hal/src/hal.c
+++ b/os/hal/src/hal.c
@@ -26,7 +26,6 @@
* @{
*/
-#include "ch.h"
#include "hal.h"
/*===========================================================================*/
@@ -60,11 +59,12 @@
*/
void halInit(void) {
+ /* Initializes the OS Abstraction Layer.*/
+ osalInit();
+
+ /* Platform low level initializations.*/
hal_lld_init();
-#if HAL_USE_TM || defined(__DOXYGEN__)
- tmInit();
-#endif
#if HAL_USE_PAL || defined(__DOXYGEN__)
palInit(&pal_default_config);
#endif
@@ -74,9 +74,6 @@ void halInit(void) {
#if HAL_USE_CAN || defined(__DOXYGEN__)
canInit();
#endif
-#if HAL_USE_DAC || defined(__DOXYGEN__)
- dacInit();
-#endif
#if HAL_USE_EXT || defined(__DOXYGEN__)
extInit();
#endif
@@ -86,6 +83,9 @@ void halInit(void) {
#if HAL_USE_I2C || defined(__DOXYGEN__)
i2cInit();
#endif
+#if HAL_USE_I2S || defined(__DOXYGEN__)
+ i2sInit();
+#endif
#if HAL_USE_ICU || defined(__DOXYGEN__)
icuInit();
#endif
@@ -119,79 +119,14 @@ void halInit(void) {
#if HAL_USE_RTC || defined(__DOXYGEN__)
rtcInit();
#endif
+
/* Board specific initialization.*/
boardInit();
-}
-
-#if HAL_IMPLEMENTS_COUNTERS || defined(__DOXYGEN__)
-/**
- * @brief Realtime window test.
- * @details This function verifies if the current realtime counter value
- * lies within the specified range or not. The test takes care
- * of the realtime counter wrapping to zero on overflow.
- * @note When start==end then the function returns always true because the
- * whole time range is specified.
- * @note This is an optional service that could not be implemented in
- * all HAL implementations.
- * @note This function can be called from any context.
- *
- * @par Example 1
- * Example of a guarded loop using the realtime counter. The loop implements
- * a timeout after one second.
- * @code
- * halrtcnt_t start = halGetCounterValue();
- * halrtcnt_t timeout = start + S2RTT(1);
- * while (my_condition) {
- * if (!halIsCounterWithin(start, timeout)
- * return TIMEOUT;
- * // Do something.
- * }
- * // Continue.
- * @endcode
- *
- * @par Example 2
- * Example of a loop that lasts exactly 50 microseconds.
- * @code
- * halrtcnt_t start = halGetCounterValue();
- * halrtcnt_t timeout = start + US2RTT(50);
- * while (halIsCounterWithin(start, timeout)) {
- * // Do something.
- * }
- * // Continue.
- * @endcode
- *
- * @param[in] start the start of the time window (inclusive)
- * @param[in] end the end of the time window (non inclusive)
- * @retval TRUE current time within the specified time window.
- * @retval FALSE current time not within the specified time window.
- *
- * @special
- */
-bool_t halIsCounterWithin(halrtcnt_t start, halrtcnt_t end) {
- halrtcnt_t now = halGetCounterValue();
-
- return end > start ? (now >= start) && (now < end) :
- (now >= start) || (now < end);
-}
-/**
- * @brief Polled delay.
- * @note The real delays is always few cycles in excess of the specified
- * value.
- * @note This is an optional service that could not be implemented in
- * all HAL implementations.
- * @note This function can be called from any context.
- *
- * @param[in] ticks number of ticks
- *
- * @special
- */
-void halPolledDelay(halrtcnt_t ticks) {
- halrtcnt_t start = halGetCounterValue();
- halrtcnt_t timeout = start + (ticks);
- while (halIsCounterWithin(start, timeout))
- ;
+#if (OSAL_ST_MODE != OSAL_ST_MODE_NONE) || defined(__DOXYGEN__)
+ /* System tick service if the underlying OS requires it.*/
+ stInit();
+#endif
}
-#endif /* HAL_IMPLEMENTS_COUNTERS */
/** @} */
diff --git a/os/hal/src/mmcsd.c b/os/hal/src/hal_mmcsd.c
index c83095981..b2cfb65a0 100644
--- a/os/hal/src/mmcsd.c
+++ b/os/hal/src/hal_mmcsd.c
@@ -19,14 +19,13 @@
*/
/**
- * @file mmcsd.c
+ * @file hal_mmcsd.c
* @brief MMC/SD cards common code.
*
* @addtogroup MMCSD
* @{
*/
-#include "ch.h"
#include "hal.h"
#if HAL_USE_MMC_SPI || HAL_USE_SDC || defined(__DOXYGEN__)
@@ -63,7 +62,7 @@ static uint32_t mmcsd_get_slice(uint32_t *data, uint32_t end, uint32_t start) {
unsigned startidx, endidx, startoff;
uint32_t endmask;
- chDbgCheck((end >= start) && ((end - start) < 32), "mmcsd_get_slice");
+ osalDbgCheck((end >= start) && ((end - start) < 32));
startidx = start / 32;
startoff = start % 32;
diff --git a/os/hal/src/hal_queues.c b/os/hal/src/hal_queues.c
new file mode 100644
index 000000000..dac58a155
--- /dev/null
+++ b/os/hal/src/hal_queues.c
@@ -0,0 +1,402 @@
+/*
+ ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010,
+ 2011,2012,2013 Giovanni Di Sirio.
+
+ This file is part of ChibiOS/RT.
+
+ ChibiOS/RT is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS/RT is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * @file hal_queues.c
+ * @brief I/O Queues code.
+ *
+ * @addtogroup io_queues
+ * @details Queues are mostly used in serial-like device drivers.
+ * Serial device drivers are usually designed to have a lower side
+ * (lower driver, it is usually an interrupt service routine) and an
+ * upper side (upper driver, accessed by the application threads).<br>
+ * There are several kind of queues:<br>
+ * - <b>Input queue</b>, unidirectional queue where the writer is the
+ * lower side and the reader is the upper side.
+ * - <b>Output queue</b>, unidirectional queue where the writer is the
+ * upper side and the reader is the lower side.
+ * - <b>Full duplex queue</b>, bidirectional queue. Full duplex queues
+ * are implemented by pairing an input queue and an output queue
+ * together.
+ * .
+ * @{
+ */
+
+#include "hal.h"
+
+#if !defined(_CHIBIOS_RT_) || !CH_CFG_USE_QUEUES || defined(__DOXYGEN__)
+
+/**
+ * @brief Initializes an input queue.
+ * @details A Semaphore is internally initialized and works as a counter of
+ * the bytes contained in the queue.
+ * @note The callback is invoked from within the S-Locked system state,
+ * see @ref system_states.
+ *
+ * @param[out] iqp pointer to an @p input_queue_t structure
+ * @param[in] bp pointer to a memory area allocated as queue buffer
+ * @param[in] size size of the queue buffer
+ * @param[in] infy pointer to a callback function that is invoked when
+ * data is read from the queue. The value can be @p NULL.
+ * @param[in] link application defined pointer
+ *
+ * @init
+ */
+void iqObjectInit(input_queue_t *iqp, uint8_t *bp, size_t size,
+ qnotify_t infy, void *link) {
+
+ osalThreadQueueObjectInit(&iqp->q_waiting);
+ iqp->q_counter = 0;
+ iqp->q_buffer = iqp->q_rdptr = iqp->q_wrptr = bp;
+ iqp->q_top = bp + size;
+ iqp->q_notify = infy;
+ iqp->q_link = link;
+}
+
+/**
+ * @brief Resets an input queue.
+ * @details All the data in the input queue is erased and lost, any waiting
+ * thread is resumed with status @p Q_RESET.
+ * @note A reset operation can be used by a low level driver in order to
+ * obtain immediate attention from the high level layers.
+ *
+ * @param[in] iqp pointer to an @p input_queue_t structure
+ *
+ * @iclass
+ */
+void iqResetI(input_queue_t *iqp) {
+
+ osalDbgCheckClassI();
+
+ iqp->q_rdptr = iqp->q_wrptr = iqp->q_buffer;
+ iqp->q_counter = 0;
+ osalThreadDequeueAllI(&iqp->q_waiting, Q_RESET);
+}
+
+/**
+ * @brief Input queue write.
+ * @details A byte value is written into the low end of an input queue.
+ *
+ * @param[in] iqp pointer to an @p input_queue_t structure
+ * @param[in] b the byte value to be written in the queue
+ * @return The operation status.
+ * @retval Q_OK if the operation has been completed with success.
+ * @retval Q_FULL if the queue is full and the operation cannot be
+ * completed.
+ *
+ * @iclass
+ */
+msg_t iqPutI(input_queue_t *iqp, uint8_t b) {
+
+ osalDbgCheckClassI();
+
+ if (iqIsFullI(iqp))
+ return Q_FULL;
+
+ iqp->q_counter++;
+ *iqp->q_wrptr++ = b;
+ if (iqp->q_wrptr >= iqp->q_top)
+ iqp->q_wrptr = iqp->q_buffer;
+
+ osalThreadDequeueNextI(&iqp->q_waiting, Q_OK);
+
+ return Q_OK;
+}
+
+/**
+ * @brief Input queue read with timeout.
+ * @details This function reads a byte value from an input queue. If the queue
+ * is empty then the calling thread is suspended until a byte arrives
+ * in the queue or a timeout occurs.
+ * @note The callback is invoked before reading the character from the
+ * buffer or before entering the state @p THD_STATE_WTQUEUE.
+ *
+ * @param[in] iqp pointer to an @p input_queue_t structure
+ * @param[in] time the number of ticks before the operation timeouts,
+ * the following special values are allowed:
+ * - @a TIME_IMMEDIATE immediate timeout.
+ * - @a TIME_INFINITE no timeout.
+ * .
+ * @return A byte value from the queue.
+ * @retval Q_TIMEOUT if the specified time expired.
+ * @retval Q_RESET if the queue has been reset.
+ *
+ * @api
+ */
+msg_t iqGetTimeout(input_queue_t *iqp, systime_t time) {
+ uint8_t b;
+
+ osalSysLock();
+ if (iqp->q_notify)
+ iqp->q_notify(iqp);
+
+ while (iqIsEmptyI(iqp)) {
+ msg_t msg;
+ if ((msg = osalThreadEnqueueTimeoutS(&iqp->q_waiting, time)) < Q_OK) {
+ osalSysUnlock();
+ return msg;
+ }
+ }
+
+ iqp->q_counter--;
+ b = *iqp->q_rdptr++;
+ if (iqp->q_rdptr >= iqp->q_top)
+ iqp->q_rdptr = iqp->q_buffer;
+
+ osalSysUnlock();
+ return b;
+}
+
+/**
+ * @brief Input queue read with timeout.
+ * @details The function reads data from an input queue into a buffer. The
+ * operation completes when the specified amount of data has been
+ * transferred or after the specified timeout or if the queue has
+ * been reset.
+ * @note The function is not atomic, if you need atomicity it is suggested
+ * to use a semaphore or a mutex for mutual exclusion.
+ * @note The callback is invoked before reading each character from the
+ * buffer or before entering the state @p THD_STATE_WTQUEUE.
+ *
+ * @param[in] iqp pointer to an @p input_queue_t structure
+ * @param[out] bp pointer to the data buffer
+ * @param[in] n the maximum amount of data to be transferred, the
+ * value 0 is reserved
+ * @param[in] time the number of ticks before the operation timeouts,
+ * the following special values are allowed:
+ * - @a TIME_IMMEDIATE immediate timeout.
+ * - @a TIME_INFINITE no timeout.
+ * .
+ * @return The number of bytes effectively transferred.
+ *
+ * @api
+ */
+size_t iqReadTimeout(input_queue_t *iqp, uint8_t *bp,
+ size_t n, systime_t time) {
+ qnotify_t nfy = iqp->q_notify;
+ size_t r = 0;
+
+ osalDbgCheck(n > 0);
+
+ osalSysLock();
+ while (TRUE) {
+ if (nfy)
+ nfy(iqp);
+
+ while (iqIsEmptyI(iqp)) {
+ if (osalThreadEnqueueTimeoutS(&iqp->q_waiting, time) != Q_OK) {
+ osalSysUnlock();
+ return r;
+ }
+ }
+
+ iqp->q_counter--;
+ *bp++ = *iqp->q_rdptr++;
+ if (iqp->q_rdptr >= iqp->q_top)
+ iqp->q_rdptr = iqp->q_buffer;
+
+ osalSysUnlock(); /* Gives a preemption chance in a controlled point.*/
+ r++;
+ if (--n == 0)
+ return r;
+
+ osalSysLock();
+ }
+}
+
+/**
+ * @brief Initializes an output queue.
+ * @details A Semaphore is internally initialized and works as a counter of
+ * the free bytes in the queue.
+ * @note The callback is invoked from within the S-Locked system state,
+ * see @ref system_states.
+ *
+ * @param[out] oqp pointer to an @p output_queue_t structure
+ * @param[in] bp pointer to a memory area allocated as queue buffer
+ * @param[in] size size of the queue buffer
+ * @param[in] onfy pointer to a callback function that is invoked when
+ * data is written to the queue. The value can be @p NULL.
+ * @param[in] link application defined pointer
+ *
+ * @init
+ */
+void oqObjectInit(output_queue_t *oqp, uint8_t *bp, size_t size,
+ qnotify_t onfy, void *link) {
+
+ osalThreadQueueObjectInit(&oqp->q_waiting);
+ oqp->q_counter = size;
+ oqp->q_buffer = oqp->q_rdptr = oqp->q_wrptr = bp;
+ oqp->q_top = bp + size;
+ oqp->q_notify = onfy;
+ oqp->q_link = link;
+}
+
+/**
+ * @brief Resets an output queue.
+ * @details All the data in the output queue is erased and lost, any waiting
+ * thread is resumed with status @p Q_RESET.
+ * @note A reset operation can be used by a low level driver in order to
+ * obtain immediate attention from the high level layers.
+ *
+ * @param[in] oqp pointer to an @p output_queue_t structure
+ *
+ * @iclass
+ */
+void oqResetI(output_queue_t *oqp) {
+
+ osalDbgCheckClassI();
+
+ oqp->q_rdptr = oqp->q_wrptr = oqp->q_buffer;
+ oqp->q_counter = qSizeI(oqp);
+ osalThreadDequeueAllI(&oqp->q_waiting, Q_RESET);
+}
+
+/**
+ * @brief Output queue write with timeout.
+ * @details This function writes a byte value to an output queue. If the queue
+ * is full then the calling thread is suspended until there is space
+ * in the queue or a timeout occurs.
+ * @note The callback is invoked after writing the character into the
+ * buffer.
+ *
+ * @param[in] oqp pointer to an @p output_queue_t structure
+ * @param[in] b the byte value to be written in the queue
+ * @param[in] time the number of ticks before the operation timeouts,
+ * the following special values are allowed:
+ * - @a TIME_IMMEDIATE immediate timeout.
+ * - @a TIME_INFINITE no timeout.
+ * .
+ * @return The operation status.
+ * @retval Q_OK if the operation succeeded.
+ * @retval Q_TIMEOUT if the specified time expired.
+ * @retval Q_RESET if the queue has been reset.
+ *
+ * @api
+ */
+msg_t oqPutTimeout(output_queue_t *oqp, uint8_t b, systime_t time) {
+
+ osalSysLock();
+ while (oqIsFullI(oqp)) {
+ msg_t msg;
+
+ if ((msg = osalThreadEnqueueTimeoutS(&oqp->q_waiting, time)) < Q_OK) {
+ osalSysUnlock();
+ return msg;
+ }
+ }
+
+ oqp->q_counter--;
+ *oqp->q_wrptr++ = b;
+ if (oqp->q_wrptr >= oqp->q_top)
+ oqp->q_wrptr = oqp->q_buffer;
+
+ if (oqp->q_notify)
+ oqp->q_notify(oqp);
+
+ osalSysUnlock();
+ return Q_OK;
+}
+
+/**
+ * @brief Output queue read.
+ * @details A byte value is read from the low end of an output queue.
+ *
+ * @param[in] oqp pointer to an @p output_queue_t structure
+ * @return The byte value from the queue.
+ * @retval Q_EMPTY if the queue is empty.
+ *
+ * @iclass
+ */
+msg_t oqGetI(output_queue_t *oqp) {
+ uint8_t b;
+
+ osalDbgCheckClassI();
+
+ if (oqIsEmptyI(oqp))
+ return Q_EMPTY;
+
+ oqp->q_counter++;
+ b = *oqp->q_rdptr++;
+ if (oqp->q_rdptr >= oqp->q_top)
+ oqp->q_rdptr = oqp->q_buffer;
+
+ osalThreadDequeueNextI(&oqp->q_waiting, Q_OK);
+
+ return b;
+}
+
+/**
+ * @brief Output queue write with timeout.
+ * @details The function writes data from a buffer to an output queue. The
+ * operation completes when the specified amount of data has been
+ * transferred or after the specified timeout or if the queue has
+ * been reset.
+ * @note The function is not atomic, if you need atomicity it is suggested
+ * to use a semaphore or a mutex for mutual exclusion.
+ * @note The callback is invoked after writing each character into the
+ * buffer.
+ *
+ * @param[in] oqp pointer to an @p output_queue_t structure
+ * @param[out] bp pointer to the data buffer
+ * @param[in] n the maximum amount of data to be transferred, the
+ * value 0 is reserved
+ * @param[in] time the number of ticks before the operation timeouts,
+ * the following special values are allowed:
+ * - @a TIME_IMMEDIATE immediate timeout.
+ * - @a TIME_INFINITE no timeout.
+ * .
+ * @return The number of bytes effectively transferred.
+ *
+ * @api
+ */
+size_t oqWriteTimeout(output_queue_t *oqp, const uint8_t *bp,
+ size_t n, systime_t time) {
+ qnotify_t nfy = oqp->q_notify;
+ size_t w = 0;
+
+ osalDbgCheck(n > 0);
+
+ osalSysLock();
+ while (TRUE) {
+ while (oqIsFullI(oqp)) {
+ if (osalThreadEnqueueTimeoutS(&oqp->q_waiting, time) != Q_OK) {
+ osalSysUnlock();
+ return w;
+ }
+ }
+ oqp->q_counter--;
+ *oqp->q_wrptr++ = *bp++;
+ if (oqp->q_wrptr >= oqp->q_top)
+ oqp->q_wrptr = oqp->q_buffer;
+
+ if (nfy)
+ nfy(oqp);
+
+ osalSysUnlock(); /* Gives a preemption chance in a controlled point.*/
+ w++;
+ if (--n == 0)
+ return w;
+ osalSysLock();
+ }
+}
+
+#endif /* !defined(_CHIBIOS_RT_) || !CH_USE_QUEUES */
+
+/** @} */
diff --git a/os/hal/src/i2c.c b/os/hal/src/i2c.c
index 5ec7c284b..ba349457d 100644
--- a/os/hal/src/i2c.c
+++ b/os/hal/src/i2c.c
@@ -29,7 +29,6 @@
* @addtogroup I2C
* @{
*/
-#include "ch.h"
#include "hal.h"
#if HAL_USE_I2C || defined(__DOXYGEN__)
@@ -62,6 +61,7 @@
* @init
*/
void i2cInit(void) {
+
i2c_lld_init();
}
@@ -78,11 +78,7 @@ void i2cObjectInit(I2CDriver *i2cp) {
i2cp->config = NULL;
#if I2C_USE_MUTUAL_EXCLUSION
-#if CH_USE_MUTEXES
- chMtxInit(&i2cp->mutex);
-#else
- chSemInit(&i2cp->semaphore, 1);
-#endif /* CH_USE_MUTEXES */
+ osalMutexObjectInit(&i2cp->mutex);
#endif /* I2C_USE_MUTUAL_EXCLUSION */
#if defined(I2C_DRIVER_EXT_INIT_HOOK)
@@ -100,17 +96,15 @@ void i2cObjectInit(I2CDriver *i2cp) {
*/
void i2cStart(I2CDriver *i2cp, const I2CConfig *config) {
- chDbgCheck((i2cp != NULL) && (config != NULL), "i2cStart");
- chDbgAssert((i2cp->state == I2C_STOP) || (i2cp->state == I2C_READY) ||
- (i2cp->state == I2C_LOCKED),
- "i2cStart(), #1",
- "invalid state");
+ osalDbgCheck((i2cp != NULL) && (config != NULL));
+ osalDbgAssert((i2cp->state == I2C_STOP) || (i2cp->state == I2C_READY) ||
+ (i2cp->state == I2C_LOCKED), "invalid state");
- chSysLock();
+ osalSysLock();
i2cp->config = config;
i2c_lld_start(i2cp);
i2cp->state = I2C_READY;
- chSysUnlock();
+ osalSysUnlock();
}
/**
@@ -122,16 +116,14 @@ void i2cStart(I2CDriver *i2cp, const I2CConfig *config) {
*/
void i2cStop(I2CDriver *i2cp) {
- chDbgCheck(i2cp != NULL, "i2cStop");
- chDbgAssert((i2cp->state == I2C_STOP) || (i2cp->state == I2C_READY) ||
- (i2cp->state == I2C_LOCKED),
- "i2cStop(), #1",
- "invalid state");
+ osalDbgCheck(i2cp != NULL);
+ osalDbgAssert((i2cp->state == I2C_STOP) || (i2cp->state == I2C_READY) ||
+ (i2cp->state == I2C_LOCKED), "invalid state");
- chSysLock();
+ osalSysLock();
i2c_lld_stop(i2cp);
i2cp->state = I2C_STOP;
- chSysUnlock();
+ osalSysUnlock();
}
/**
@@ -144,7 +136,7 @@ void i2cStop(I2CDriver *i2cp) {
*/
i2cflags_t i2cGetErrors(I2CDriver *i2cp) {
- chDbgCheck(i2cp != NULL, "i2cGetErrors");
+ osalDbgCheck(i2cp != NULL);
return i2c_lld_get_errors(i2cp);
}
@@ -168,10 +160,10 @@ i2cflags_t i2cGetErrors(I2CDriver *i2cp) {
* .
*
* @return The operation status.
- * @retval RDY_OK if the function succeeded.
- * @retval RDY_RESET if one or more I2C errors occurred, the errors can
+ * @retval MSG_OK if the function succeeded.
+ * @retval MSG_RESET if one or more I2C errors occurred, the errors can
* be retrieved using @p i2cGetErrors().
- * @retval RDY_TIMEOUT if a timeout occurred before operation end.
+ * @retval MSG_TIMEOUT if a timeout occurred before operation end.
*
* @api
*/
@@ -184,25 +176,23 @@ msg_t i2cMasterTransmitTimeout(I2CDriver *i2cp,
systime_t timeout) {
msg_t rdymsg;
- chDbgCheck((i2cp != NULL) && (addr != 0) &&
- (txbytes > 0) && (txbuf != NULL) &&
- ((rxbytes == 0) || ((rxbytes > 0) && (rxbuf != NULL))) &&
- (timeout != TIME_IMMEDIATE),
- "i2cMasterTransmitTimeout");
+ osalDbgCheck((i2cp != NULL) && (addr != 0) &&
+ (txbytes > 0) && (txbuf != NULL) &&
+ ((rxbytes == 0) || ((rxbytes > 0) && (rxbuf != NULL))) &&
+ (timeout != TIME_IMMEDIATE));
- chDbgAssert(i2cp->state == I2C_READY,
- "i2cMasterTransmitTimeout(), #1", "not ready");
+ osalDbgAssert(i2cp->state == I2C_READY, "not ready");
- chSysLock();
- i2cp->errors = I2CD_NO_ERROR;
+ osalSysLock();
+ i2cp->errors = I2C_NO_ERROR;
i2cp->state = I2C_ACTIVE_TX;
rdymsg = i2c_lld_master_transmit_timeout(i2cp, addr, txbuf, txbytes,
rxbuf, rxbytes, timeout);
- if (rdymsg == RDY_TIMEOUT)
+ if (rdymsg == MSG_TIMEOUT)
i2cp->state = I2C_LOCKED;
else
i2cp->state = I2C_READY;
- chSysUnlock();
+ osalSysUnlock();
return rdymsg;
}
@@ -219,10 +209,10 @@ msg_t i2cMasterTransmitTimeout(I2CDriver *i2cp,
* .
*
* @return The operation status.
- * @retval RDY_OK if the function succeeded.
- * @retval RDY_RESET if one or more I2C errors occurred, the errors can
+ * @retval MSG_OK if the function succeeded.
+ * @retval MSG_RESET if one or more I2C errors occurred, the errors can
* be retrieved using @p i2cGetErrors().
- * @retval RDY_TIMEOUT if a timeout occurred before operation end.
+ * @retval MSG_TIMEOUT if a timeout occurred before operation end.
*
* @api
*/
@@ -234,23 +224,21 @@ msg_t i2cMasterReceiveTimeout(I2CDriver *i2cp,
msg_t rdymsg;
- chDbgCheck((i2cp != NULL) && (addr != 0) &&
- (rxbytes > 0) && (rxbuf != NULL) &&
- (timeout != TIME_IMMEDIATE),
- "i2cMasterReceiveTimeout");
+ osalDbgCheck((i2cp != NULL) && (addr != 0) &&
+ (rxbytes > 0) && (rxbuf != NULL) &&
+ (timeout != TIME_IMMEDIATE));
- chDbgAssert(i2cp->state == I2C_READY,
- "i2cMasterReceive(), #1", "not ready");
+ osalDbgAssert(i2cp->state == I2C_READY, "not ready");
- chSysLock();
- i2cp->errors = I2CD_NO_ERROR;
+ osalSysLock();
+ i2cp->errors = I2C_NO_ERROR;
i2cp->state = I2C_ACTIVE_RX;
rdymsg = i2c_lld_master_receive_timeout(i2cp, addr, rxbuf, rxbytes, timeout);
- if (rdymsg == RDY_TIMEOUT)
+ if (rdymsg == MSG_TIMEOUT)
i2cp->state = I2C_LOCKED;
else
i2cp->state = I2C_READY;
- chSysUnlock();
+ osalSysUnlock();
return rdymsg;
}
@@ -268,13 +256,9 @@ msg_t i2cMasterReceiveTimeout(I2CDriver *i2cp,
*/
void i2cAcquireBus(I2CDriver *i2cp) {
- chDbgCheck(i2cp != NULL, "i2cAcquireBus");
+ osalDbgCheck(i2cp != NULL);
-#if CH_USE_MUTEXES
- chMtxLock(&i2cp->mutex);
-#elif CH_USE_SEMAPHORES
- chSemWait(&i2cp->semaphore);
-#endif
+ osalMutexLock(&i2cp->mutex);
}
/**
@@ -288,13 +272,9 @@ void i2cAcquireBus(I2CDriver *i2cp) {
*/
void i2cReleaseBus(I2CDriver *i2cp) {
- chDbgCheck(i2cp != NULL, "i2cReleaseBus");
+ osalDbgCheck(i2cp != NULL);
-#if CH_USE_MUTEXES
- chMtxUnlock();
-#elif CH_USE_SEMAPHORES
- chSemSignal(&i2cp->semaphore);
-#endif
+ osalMutexUnlock(&i2cp->mutex);
}
#endif /* I2C_USE_MUTUAL_EXCLUSION */
diff --git a/os/hal/src/i2s.c b/os/hal/src/i2s.c
index e43d51ab2..e2b51ec98 100644
--- a/os/hal/src/i2s.c
+++ b/os/hal/src/i2s.c
@@ -26,7 +26,6 @@
* @{
*/
-#include "ch.h"
#include "hal.h"
#if HAL_USE_I2S || defined(__DOXYGEN__)
@@ -86,15 +85,15 @@ void i2sObjectInit(I2SDriver *i2sp) {
*/
void i2sStart(I2SDriver *i2sp, const I2SConfig *config) {
- chDbgCheck((i2sp != NULL) && (config != NULL), "i2sStart");
+ osalDbgCheck((i2sp != NULL) && (config != NULL));
- chSysLock();
- chDbgAssert((i2sp->state == I2S_STOP) || (i2sp->state == I2S_READY),
- "i2sStart(), #1", "invalid state");
+ osalSysLock();
+ osalDbgAssert((i2sp->state == I2S_STOP) || (i2sp->state == I2S_READY),
+ "invalid state");
i2sp->config = config;
i2s_lld_start(i2sp);
i2sp->state = I2S_READY;
- chSysUnlock();
+ osalSysUnlock();
}
/**
@@ -106,14 +105,14 @@ void i2sStart(I2SDriver *i2sp, const I2SConfig *config) {
*/
void i2sStop(I2SDriver *i2sp) {
- chDbgCheck(i2sp != NULL, "i2sStop");
+ osalDbgCheck(i2sp != NULL);
- chSysLock();
- chDbgAssert((i2sp->state == I2S_STOP) || (i2sp->state == I2S_READY),
- "i2sStop(), #1", "invalid state");
+ osalSysLock();
+ osalDbgAssert((i2sp->state == I2S_STOP) || (i2sp->state == I2S_READY),
+ "invalid state");
i2s_lld_stop(i2sp);
i2sp->state = I2S_STOP;
- chSysUnlock();
+ osalSysUnlock();
}
/**
@@ -125,31 +124,12 @@ void i2sStop(I2SDriver *i2sp) {
*/
void i2sStartExchange(I2SDriver *i2sp) {
- chDbgCheck(i2sp != NULL "i2sStartExchange");
+ osalDbgCheck(i2sp != NULL);
- chSysLock();
- chDbgAssert(i2sp->state == I2S_READY,
- "i2sStartExchange(), #1", "not ready");
+ osalSysLock();
+ osalDbgAssert(i2sp->state == I2S_READY, "not ready");
i2sStartExchangeI(i2sp);
- chSysUnlock();
-}
-
-/**
- * @brief Starts a I2S data exchange in continuous mode.
- *
- * @param[in] i2sp pointer to the @p I2SDriver object
- *
- * @api
- */
-void i2sStartExchangeContinuous(I2SDriver *i2sp) {
-
- chDbgCheck(i2sp != NULL "i2sStartExchangeContinuous");
-
- chSysLock();
- chDbgAssert(i2sp->state == I2S_READY,
- "i2sStartExchangeContinuous(), #1", "not ready");
- i2sStartExchangeContinuousI(i2sp);
- chSysUnlock();
+ osalSysUnlock();
}
/**
@@ -163,15 +143,15 @@ void i2sStartExchangeContinuous(I2SDriver *i2sp) {
*/
void i2sStopExchange(I2SDriver *i2sp) {
- chDbgCheck((i2sp != NULL), "i2sStopExchange");
+ osalDbgCheck((i2sp != NULL));
- chSysLock();
- chDbgAssert((i2sp->state == I2S_READY) ||
- (i2sp->state == I2S_ACTIVE) ||
- (i2sp->state == I2S_COMPLETE),
- "i2sStopExchange(), #1", "not ready");
+ osalSysLock();
+ osalDbgAssert((i2sp->state == I2S_READY) ||
+ (i2sp->state == I2S_ACTIVE) ||
+ (i2sp->state == I2S_COMPLETE),
+ "invalid state");
i2sStopExchangeI(i2sp);
- chSysUnlock();
+ osalSysUnlock();
}
#endif /* HAL_USE_I2S */
diff --git a/os/hal/src/icu.c b/os/hal/src/icu.c
index 65d5de907..291b6df9a 100644
--- a/os/hal/src/icu.c
+++ b/os/hal/src/icu.c
@@ -26,7 +26,6 @@
* @{
*/
-#include "ch.h"
#include "hal.h"
#if HAL_USE_ICU || defined(__DOXYGEN__)
@@ -86,15 +85,15 @@ void icuObjectInit(ICUDriver *icup) {
*/
void icuStart(ICUDriver *icup, const ICUConfig *config) {
- chDbgCheck((icup != NULL) && (config != NULL), "icuStart");
+ osalDbgCheck((icup != NULL) && (config != NULL));
- chSysLock();
- chDbgAssert((icup->state == ICU_STOP) || (icup->state == ICU_READY),
- "icuStart(), #1", "invalid state");
+ osalSysLock();
+ osalDbgAssert((icup->state == ICU_STOP) || (icup->state == ICU_READY),
+ "invalid state");
icup->config = config;
icu_lld_start(icup);
icup->state = ICU_READY;
- chSysUnlock();
+ osalSysUnlock();
}
/**
@@ -106,14 +105,14 @@ void icuStart(ICUDriver *icup, const ICUConfig *config) {
*/
void icuStop(ICUDriver *icup) {
- chDbgCheck(icup != NULL, "icuStop");
+ osalDbgCheck(icup != NULL);
- chSysLock();
- chDbgAssert((icup->state == ICU_STOP) || (icup->state == ICU_READY),
- "icuStop(), #1", "invalid state");
+ osalSysLock();
+ osalDbgAssert((icup->state == ICU_STOP) || (icup->state == ICU_READY),
+ "invalid state");
icu_lld_stop(icup);
icup->state = ICU_STOP;
- chSysUnlock();
+ osalSysUnlock();
}
/**
@@ -125,13 +124,13 @@ void icuStop(ICUDriver *icup) {
*/
void icuEnable(ICUDriver *icup) {
- chDbgCheck(icup != NULL, "icuEnable");
+ osalDbgCheck(icup != NULL);
- chSysLock();
- chDbgAssert(icup->state == ICU_READY, "icuEnable(), #1", "invalid state");
+ osalSysLock();
+ osalDbgAssert(icup->state == ICU_READY, "invalid state");
icu_lld_enable(icup);
icup->state = ICU_WAITING;
- chSysUnlock();
+ osalSysUnlock();
}
/**
@@ -143,15 +142,15 @@ void icuEnable(ICUDriver *icup) {
*/
void icuDisable(ICUDriver *icup) {
- chDbgCheck(icup != NULL, "icuDisable");
+ osalDbgCheck(icup != NULL);
- chSysLock();
- chDbgAssert((icup->state == ICU_READY) || (icup->state == ICU_WAITING) ||
- (icup->state == ICU_ACTIVE) || (icup->state == ICU_IDLE),
- "icuDisable(), #1", "invalid state");
+ osalSysLock();
+ osalDbgAssert((icup->state == ICU_READY) || (icup->state == ICU_WAITING) ||
+ (icup->state == ICU_ACTIVE) || (icup->state == ICU_IDLE),
+ "invalid state");
icu_lld_disable(icup);
icup->state = ICU_READY;
- chSysUnlock();
+ osalSysUnlock();
}
#endif /* HAL_USE_ICU */
diff --git a/os/hal/src/mac.c b/os/hal/src/mac.c
deleted file mode 100644
index cb62db612..000000000
--- a/os/hal/src/mac.c
+++ /dev/null
@@ -1,272 +0,0 @@
-/*
- ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010,
- 2011,2012,2013 Giovanni Di Sirio.
-
- This file is part of ChibiOS/RT.
-
- ChibiOS/RT is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- ChibiOS/RT is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-/**
- * @file mac.c
- * @brief MAC Driver code.
- *
- * @addtogroup MAC
- * @{
- */
-
-#include "ch.h"
-#include "hal.h"
-
-#if HAL_USE_MAC || defined(__DOXYGEN__)
-
-/*===========================================================================*/
-/* Driver local definitions. */
-/*===========================================================================*/
-
-#if MAC_USE_ZERO_COPY && !MAC_SUPPORTS_ZERO_COPY
-#error "MAC_USE_ZERO_COPY not supported by this implementation"
-#endif
-
-/*===========================================================================*/
-/* Driver exported variables. */
-/*===========================================================================*/
-
-/*===========================================================================*/
-/* Driver local variables and types. */
-/*===========================================================================*/
-
-/*===========================================================================*/
-/* Driver local functions. */
-/*===========================================================================*/
-
-/*===========================================================================*/
-/* Driver interrupt handlers. */
-/*===========================================================================*/
-
-/*===========================================================================*/
-/* Driver exported functions. */
-/*===========================================================================*/
-
-/**
- * @brief MAC Driver initialization.
- * @note This function is implicitly invoked by @p halInit(), there is
- * no need to explicitly initialize the driver.
- *
- * @init
- */
-void macInit(void) {
-
- mac_lld_init();
-}
-
-/**
- * @brief Initialize the standard part of a @p MACDriver structure.
- *
- * @param[out] macp pointer to the @p MACDriver object
- *
- * @init
- */
-void macObjectInit(MACDriver *macp) {
-
- macp->state = MAC_STOP;
- macp->config = NULL;
- chSemInit(&macp->tdsem, 0);
- chSemInit(&macp->rdsem, 0);
-#if MAC_USE_EVENTS
- chEvtInit(&macp->rdevent);
-#endif
-}
-
-/**
- * @brief Configures and activates the MAC peripheral.
- *
- * @param[in] macp pointer to the @p MACDriver object
- * @param[in] config pointer to the @p MACConfig object
- *
- * @api
- */
-void macStart(MACDriver *macp, const MACConfig *config) {
-
- chDbgCheck((macp != NULL) && (config != NULL), "macStart");
-
- chSysLock();
- chDbgAssert(macp->state == MAC_STOP,
- "macStart(), #1", "invalid state");
- macp->config = config;
- mac_lld_start(macp);
- macp->state = MAC_ACTIVE;
- chSysUnlock();
-}
-
-/**
- * @brief Deactivates the MAC peripheral.
- *
- * @param[in] macp pointer to the @p MACDriver object
- *
- * @api
- */
-void macStop(MACDriver *macp) {
-
- chDbgCheck(macp != NULL, "macStop");
-
- chSysLock();
- chDbgAssert((macp->state == MAC_STOP) || (macp->state == MAC_ACTIVE),
- "macStop(), #1", "invalid state");
- mac_lld_stop(macp);
- macp->state = MAC_STOP;
- chSysUnlock();
-}
-
-/**
- * @brief Allocates a transmission descriptor.
- * @details One of the available transmission descriptors is locked and
- * returned. If a descriptor is not currently available then the
- * invoking thread is queued until one is freed.
- *
- * @param[in] macp pointer to the @p MACDriver object
- * @param[out] tdp pointer to a @p MACTransmitDescriptor structure
- * @param[in] time the number of ticks before the operation timeouts,
- * the following special values are allowed:
- * - @a TIME_IMMEDIATE immediate timeout.
- * - @a TIME_INFINITE no timeout.
- * .
- * @return The operation status.
- * @retval RDY_OK the descriptor was obtained.
- * @retval RDY_TIMEOUT the operation timed out, descriptor not initialized.
- *
- * @api
- */
-msg_t macWaitTransmitDescriptor(MACDriver *macp,
- MACTransmitDescriptor *tdp,
- systime_t time) {
- msg_t msg;
- systime_t now;
-
- chDbgCheck((macp != NULL) && (tdp != NULL), "macWaitTransmitDescriptor");
- chDbgAssert(macp->state == MAC_ACTIVE, "macWaitTransmitDescriptor(), #1",
- "not active");
-
- while (((msg = mac_lld_get_transmit_descriptor(macp, tdp)) != RDY_OK) &&
- (time > 0)) {
- chSysLock();
- now = chTimeNow();
- if ((msg = chSemWaitTimeoutS(&macp->tdsem, time)) == RDY_TIMEOUT) {
- chSysUnlock();
- break;
- }
- if (time != TIME_INFINITE)
- time -= (chTimeNow() - now);
- chSysUnlock();
- }
- return msg;
-}
-
-/**
- * @brief Releases a transmit descriptor and starts the transmission of the
- * enqueued data as a single frame.
- *
- * @param[in] tdp the pointer to the @p MACTransmitDescriptor structure
- *
- * @api
- */
-void macReleaseTransmitDescriptor(MACTransmitDescriptor *tdp) {
-
- chDbgCheck((tdp != NULL), "macReleaseTransmitDescriptor");
-
- mac_lld_release_transmit_descriptor(tdp);
-}
-
-/**
- * @brief Waits for a received frame.
- * @details Stops until a frame is received and buffered. If a frame is
- * not immediately available then the invoking thread is queued
- * until one is received.
- *
- * @param[in] macp pointer to the @p MACDriver object
- * @param[out] rdp pointer to a @p MACReceiveDescriptor structure
- * @param[in] time the number of ticks before the operation timeouts,
- * the following special values are allowed:
- * - @a TIME_IMMEDIATE immediate timeout.
- * - @a TIME_INFINITE no timeout.
- * .
- * @return The operation status.
- * @retval RDY_OK the descriptor was obtained.
- * @retval RDY_TIMEOUT the operation timed out, descriptor not initialized.
- *
- * @api
- */
-msg_t macWaitReceiveDescriptor(MACDriver *macp,
- MACReceiveDescriptor *rdp,
- systime_t time) {
- msg_t msg;
- systime_t now;
-
- chDbgCheck((macp != NULL) && (rdp != NULL), "macWaitReceiveDescriptor");
- chDbgAssert(macp->state == MAC_ACTIVE, "macWaitReceiveDescriptor(), #1",
- "not active");
-
- while (((msg = mac_lld_get_receive_descriptor(macp, rdp)) != RDY_OK) &&
- (time > 0)) {
- chSysLock();
- now = chTimeNow();
- if ((msg = chSemWaitTimeoutS(&macp->rdsem, time)) == RDY_TIMEOUT) {
- chSysUnlock();
- break;
- }
- if (time != TIME_INFINITE)
- time -= (chTimeNow() - now);
- chSysUnlock();
- }
- return msg;
-}
-
-/**
- * @brief Releases a receive descriptor.
- * @details The descriptor and its buffer are made available for more incoming
- * frames.
- *
- * @param[in] rdp the pointer to the @p MACReceiveDescriptor structure
- *
- * @api
- */
-void macReleaseReceiveDescriptor(MACReceiveDescriptor *rdp) {
-
- chDbgCheck((rdp != NULL), "macReleaseReceiveDescriptor");
-
- mac_lld_release_receive_descriptor(rdp);
-}
-
-/**
- * @brief Updates and returns the link status.
- *
- * @param[in] macp pointer to the @p MACDriver object
- * @return The link status.
- * @retval TRUE if the link is active.
- * @retval FALSE if the link is down.
- *
- * @api
- */
-bool_t macPollLinkStatus(MACDriver *macp) {
-
- chDbgCheck((macp != NULL), "macPollLinkStatus");
- chDbgAssert(macp->state == MAC_ACTIVE, "macPollLinkStatus(), #1",
- "not active");
-
- return mac_lld_poll_link_status(macp);
-}
-
-#endif /* HAL_USE_MAC */
-
-/** @} */
diff --git a/os/hal/src/mmc_spi.c b/os/hal/src/mmc_spi.c
index fbdb92c03..4ffaecfd4 100644
--- a/os/hal/src/mmc_spi.c
+++ b/os/hal/src/mmc_spi.c
@@ -31,7 +31,6 @@
#include <string.h>
-#include "ch.h"
#include "hal.h"
#if HAL_USE_MMC_SPI || defined(__DOXYGEN__)
@@ -49,23 +48,23 @@
/*===========================================================================*/
/* Forward declarations required by mmc_vmt.*/
-static bool_t mmc_read(void *instance, uint32_t startblk,
+static bool mmc_read(void *instance, uint32_t startblk,
uint8_t *buffer, uint32_t n);
-static bool_t mmc_write(void *instance, uint32_t startblk,
+static bool mmc_write(void *instance, uint32_t startblk,
const uint8_t *buffer, uint32_t n);
/**
* @brief Virtual methods table.
*/
static const struct MMCDriverVMT mmc_vmt = {
- (bool_t (*)(void *))mmc_lld_is_card_inserted,
- (bool_t (*)(void *))mmc_lld_is_write_protected,
- (bool_t (*)(void *))mmcConnect,
- (bool_t (*)(void *))mmcDisconnect,
+ (bool (*)(void *))mmc_lld_is_card_inserted,
+ (bool (*)(void *))mmc_lld_is_write_protected,
+ (bool (*)(void *))mmcConnect,
+ (bool (*)(void *))mmcDisconnect,
mmc_read,
mmc_write,
- (bool_t (*)(void *))mmcSync,
- (bool_t (*)(void *, BlockDeviceInfo *))mmcGetInfo
+ (bool (*)(void *))mmcSync,
+ (bool (*)(void *, BlockDeviceInfo *))mmcGetInfo
};
/**
@@ -100,7 +99,7 @@ static const uint8_t crc7_lookup_table[256] = {
/* Driver local functions. */
/*===========================================================================*/
-static bool_t mmc_read(void *instance, uint32_t startblk,
+static bool mmc_read(void *instance, uint32_t startblk,
uint8_t *buffer, uint32_t n) {
if (mmcStartSequentialRead((MMCDriver *)instance, startblk))
@@ -116,7 +115,7 @@ static bool_t mmc_read(void *instance, uint32_t startblk,
return CH_SUCCESS;
}
-static bool_t mmc_write(void *instance, uint32_t startblk,
+static bool mmc_write(void *instance, uint32_t startblk,
const uint8_t *buffer, uint32_t n) {
if (mmcStartSequentialWrite((MMCDriver *)instance, startblk))
@@ -298,7 +297,7 @@ static uint8_t send_command_R3(MMCDriver *mmcp, uint8_t cmd, uint32_t arg,
*
* @notapi
*/
-static bool_t read_CxD(MMCDriver *mmcp, uint8_t cmd, uint32_t cxd[4]) {
+static bool read_CxD(MMCDriver *mmcp, uint8_t cmd, uint32_t cxd[4]) {
unsigned i;
uint8_t *bp, buf[16];
@@ -395,9 +394,9 @@ void mmcObjectInit(MMCDriver *mmcp) {
*/
void mmcStart(MMCDriver *mmcp, const MMCConfig *config) {
- chDbgCheck((mmcp != NULL) && (config != NULL), "mmcStart");
- chDbgAssert((mmcp->state == BLK_STOP) || (mmcp->state == BLK_ACTIVE),
- "mmcStart(), #1", "invalid state");
+ osalDbgCheck((mmcp != NULL) && (config != NULL));
+ osalDbgAssert((mmcp->state == BLK_STOP) || (mmcp->state == BLK_ACTIVE),
+ "invalid state");
mmcp->config = config;
mmcp->state = BLK_ACTIVE;
@@ -412,9 +411,9 @@ void mmcStart(MMCDriver *mmcp, const MMCConfig *config) {
*/
void mmcStop(MMCDriver *mmcp) {
- chDbgCheck(mmcp != NULL, "mmcStop");
- chDbgAssert((mmcp->state == BLK_STOP) || (mmcp->state == BLK_ACTIVE),
- "mmcStop(), #1", "invalid state");
+ osalDbgCheck(mmcp != NULL);
+ osalDbgAssert((mmcp->state == BLK_STOP) || (mmcp->state == BLK_ACTIVE),
+ "invalid state");
spiStop(mmcp->config->spip);
mmcp->state = BLK_STOP;
@@ -437,14 +436,14 @@ void mmcStop(MMCDriver *mmcp) {
*
* @api
*/
-bool_t mmcConnect(MMCDriver *mmcp) {
+bool mmcConnect(MMCDriver *mmcp) {
unsigned i;
uint8_t r3[4];
- chDbgCheck(mmcp != NULL, "mmcConnect");
+ osalDbgCheck(mmcp != NULL);
- chDbgAssert((mmcp->state == BLK_ACTIVE) || (mmcp->state == BLK_READY),
- "mmcConnect(), #1", "invalid state");
+ osalDbgAssert((mmcp->state == BLK_ACTIVE) || (mmcp->state == BLK_READY),
+ "invalid state");
/* Connection procedure in progress.*/
mmcp->state = BLK_CONNECTING;
@@ -545,19 +544,19 @@ failed:
*
* @api
*/
-bool_t mmcDisconnect(MMCDriver *mmcp) {
+bool mmcDisconnect(MMCDriver *mmcp) {
- chDbgCheck(mmcp != NULL, "mmcDisconnect");
+ osalDbgCheck(mmcp != NULL);
- chSysLock();
- chDbgAssert((mmcp->state == BLK_ACTIVE) || (mmcp->state == BLK_READY),
- "mmcDisconnect(), #1", "invalid state");
+ osalSysLock();
+ osalDbgAssert((mmcp->state == BLK_ACTIVE) || (mmcp->state == BLK_READY),
+ "invalid state");
if (mmcp->state == BLK_ACTIVE) {
- chSysUnlock();
+ osalSysUnlock();
return CH_SUCCESS;
}
mmcp->state = BLK_DISCONNECTING;
- chSysUnlock();
+ osalSysUnlock();
/* Wait for the pending write operations to complete.*/
spiStart(mmcp->config->spip, mmcp->config->hscfg);
@@ -580,11 +579,10 @@ bool_t mmcDisconnect(MMCDriver *mmcp) {
*
* @api
*/
-bool_t mmcStartSequentialRead(MMCDriver *mmcp, uint32_t startblk) {
+bool mmcStartSequentialRead(MMCDriver *mmcp, uint32_t startblk) {
- chDbgCheck(mmcp != NULL, "mmcStartSequentialRead");
- chDbgAssert(mmcp->state == BLK_READY,
- "mmcStartSequentialRead(), #1", "invalid state");
+ osalDbgCheck(mmcp != NULL);
+ osalDbgAssert(mmcp->state == BLK_READY, "invalid state");
/* Read operation in progress.*/
mmcp->state = BLK_READING;
@@ -619,10 +617,10 @@ bool_t mmcStartSequentialRead(MMCDriver *mmcp, uint32_t startblk) {
*
* @api
*/
-bool_t mmcSequentialRead(MMCDriver *mmcp, uint8_t *buffer) {
+bool mmcSequentialRead(MMCDriver *mmcp, uint8_t *buffer) {
int i;
- chDbgCheck((mmcp != NULL) && (buffer != NULL), "mmcSequentialRead");
+ osalDbgCheck((mmcp != NULL) && (buffer != NULL));
if (mmcp->state != BLK_READING)
return CH_FAILED;
@@ -654,11 +652,11 @@ bool_t mmcSequentialRead(MMCDriver *mmcp, uint8_t *buffer) {
*
* @api
*/
-bool_t mmcStopSequentialRead(MMCDriver *mmcp) {
+bool mmcStopSequentialRead(MMCDriver *mmcp) {
static const uint8_t stopcmd[] = {0x40 | MMCSD_CMD_STOP_TRANSMISSION,
0, 0, 0, 0, 1, 0xFF};
- chDbgCheck(mmcp != NULL, "mmcStopSequentialRead");
+ osalDbgCheck(mmcp != NULL);
if (mmcp->state != BLK_READING)
return CH_FAILED;
@@ -686,11 +684,10 @@ bool_t mmcStopSequentialRead(MMCDriver *mmcp) {
*
* @api
*/
-bool_t mmcStartSequentialWrite(MMCDriver *mmcp, uint32_t startblk) {
+bool mmcStartSequentialWrite(MMCDriver *mmcp, uint32_t startblk) {
- chDbgCheck(mmcp != NULL, "mmcStartSequentialWrite");
- chDbgAssert(mmcp->state == BLK_READY,
- "mmcStartSequentialWrite(), #1", "invalid state");
+ osalDbgCheck(mmcp != NULL);
+ osalDbgAssert(mmcp->state == BLK_READY, "invalid state");
/* Write operation in progress.*/
mmcp->state = BLK_WRITING;
@@ -723,11 +720,11 @@ bool_t mmcStartSequentialWrite(MMCDriver *mmcp, uint32_t startblk) {
*
* @api
*/
-bool_t mmcSequentialWrite(MMCDriver *mmcp, const uint8_t *buffer) {
+bool mmcSequentialWrite(MMCDriver *mmcp, const uint8_t *buffer) {
static const uint8_t start[] = {0xFF, 0xFC};
uint8_t b[1];
- chDbgCheck((mmcp != NULL) && (buffer != NULL), "mmcSequentialWrite");
+ osalDbgCheck((mmcp != NULL) && (buffer != NULL));
if (mmcp->state != BLK_WRITING)
return CH_FAILED;
@@ -759,10 +756,10 @@ bool_t mmcSequentialWrite(MMCDriver *mmcp, const uint8_t *buffer) {
*
* @api
*/
-bool_t mmcStopSequentialWrite(MMCDriver *mmcp) {
+bool mmcStopSequentialWrite(MMCDriver *mmcp) {
static const uint8_t stop[] = {0xFD, 0xFF};
- chDbgCheck(mmcp != NULL, "mmcStopSequentialWrite");
+ osalDbgCheck(mmcp != NULL);
if (mmcp->state != BLK_WRITING)
return CH_FAILED;
@@ -786,9 +783,9 @@ bool_t mmcStopSequentialWrite(MMCDriver *mmcp) {
*
* @api
*/
-bool_t mmcSync(MMCDriver *mmcp) {
+bool mmcSync(MMCDriver *mmcp) {
- chDbgCheck(mmcp != NULL, "mmcSync");
+ osalDbgCheck(mmcp != NULL);
if (mmcp->state != BLK_READY)
return CH_FAILED;
@@ -816,9 +813,9 @@ bool_t mmcSync(MMCDriver *mmcp) {
*
* @api
*/
-bool_t mmcGetInfo(MMCDriver *mmcp, BlockDeviceInfo *bdip) {
+bool mmcGetInfo(MMCDriver *mmcp, BlockDeviceInfo *bdip) {
- chDbgCheck((mmcp != NULL) && (bdip != NULL), "mmcGetInfo");
+ osalDbgCheck((mmcp != NULL) && (bdip != NULL));
if (mmcp->state != BLK_READY)
return CH_FAILED;
@@ -842,9 +839,9 @@ bool_t mmcGetInfo(MMCDriver *mmcp, BlockDeviceInfo *bdip) {
*
* @api
*/
-bool_t mmcErase(MMCDriver *mmcp, uint32_t startblk, uint32_t endblk) {
+bool mmcErase(MMCDriver *mmcp, uint32_t startblk, uint32_t endblk) {
- chDbgCheck((mmcp != NULL), "mmcErase");
+ osalDbgCheck((mmcp != NULL));
/* Erase operation in progress.*/
mmcp->state = BLK_WRITING;
diff --git a/os/hal/src/pal.c b/os/hal/src/pal.c
index 4e6c63d5f..efebc1a94 100644
--- a/os/hal/src/pal.c
+++ b/os/hal/src/pal.c
@@ -26,7 +26,6 @@
* @{
*/
-#include "ch.h"
#include "hal.h"
#if HAL_USE_PAL || defined(__DOXYGEN__)
@@ -69,8 +68,7 @@
*/
ioportmask_t palReadBus(IOBus *bus) {
- chDbgCheck((bus != NULL) && (bus->offset < PAL_IOPORTS_WIDTH),
- "palReadBus");
+ osalDbgCheck((bus != NULL) && (bus->offset < PAL_IOPORTS_WIDTH));
return palReadGroup(bus->portid, bus->mask, bus->offset);
}
@@ -95,8 +93,7 @@ ioportmask_t palReadBus(IOBus *bus) {
*/
void palWriteBus(IOBus *bus, ioportmask_t bits) {
- chDbgCheck((bus != NULL) && (bus->offset < PAL_IOPORTS_WIDTH),
- "palWriteBus");
+ osalDbgCheck((bus != NULL) && (bus->offset < PAL_IOPORTS_WIDTH));
palWriteGroup(bus->portid, bus->mask, bus->offset, bits);
}
@@ -119,8 +116,7 @@ void palWriteBus(IOBus *bus, ioportmask_t bits) {
*/
void palSetBusMode(IOBus *bus, iomode_t mode) {
- chDbgCheck((bus != NULL) && (bus->offset < PAL_IOPORTS_WIDTH),
- "palSetBusMode");
+ osalDbgCheck((bus != NULL) && (bus->offset < PAL_IOPORTS_WIDTH));
palSetGroupMode(bus->portid, bus->mask, bus->offset, mode);
}
diff --git a/os/hal/src/pwm.c b/os/hal/src/pwm.c
index c6843a928..dfbe32df3 100644
--- a/os/hal/src/pwm.c
+++ b/os/hal/src/pwm.c
@@ -26,7 +26,6 @@
* @{
*/
-#include "ch.h"
#include "hal.h"
#if HAL_USE_PWM || defined(__DOXYGEN__)
@@ -91,16 +90,16 @@ void pwmObjectInit(PWMDriver *pwmp) {
*/
void pwmStart(PWMDriver *pwmp, const PWMConfig *config) {
- chDbgCheck((pwmp != NULL) && (config != NULL), "pwmStart");
+ osalDbgCheck((pwmp != NULL) && (config != NULL));
- chSysLock();
- chDbgAssert((pwmp->state == PWM_STOP) || (pwmp->state == PWM_READY),
- "pwmStart(), #1", "invalid state");
+ osalSysLock();
+ osalDbgAssert((pwmp->state == PWM_STOP) || (pwmp->state == PWM_READY),
+ "invalid state");
pwmp->config = config;
pwmp->period = config->period;
pwm_lld_start(pwmp);
pwmp->state = PWM_READY;
- chSysUnlock();
+ osalSysUnlock();
}
/**
@@ -112,14 +111,14 @@ void pwmStart(PWMDriver *pwmp, const PWMConfig *config) {
*/
void pwmStop(PWMDriver *pwmp) {
- chDbgCheck(pwmp != NULL, "pwmStop");
+ osalDbgCheck(pwmp != NULL);
- chSysLock();
- chDbgAssert((pwmp->state == PWM_STOP) || (pwmp->state == PWM_READY),
- "pwmStop(), #1", "invalid state");
+ osalSysLock();
+ osalDbgAssert((pwmp->state == PWM_STOP) || (pwmp->state == PWM_READY),
+ "invalid state");
pwm_lld_stop(pwmp);
pwmp->state = PWM_STOP;
- chSysUnlock();
+ osalSysUnlock();
}
/**
@@ -139,13 +138,12 @@ void pwmStop(PWMDriver *pwmp) {
*/
void pwmChangePeriod(PWMDriver *pwmp, pwmcnt_t period) {
- chDbgCheck(pwmp != NULL, "pwmChangePeriod");
+ osalDbgCheck(pwmp != NULL);
- chSysLock();
- chDbgAssert(pwmp->state == PWM_READY,
- "pwmChangePeriod(), #1", "invalid state");
+ osalSysLock();
+ osalDbgAssert(pwmp->state == PWM_READY, "invalid state");
pwmChangePeriodI(pwmp, period);
- chSysUnlock();
+ osalSysUnlock();
}
/**
@@ -166,14 +164,12 @@ void pwmEnableChannel(PWMDriver *pwmp,
pwmchannel_t channel,
pwmcnt_t width) {
- chDbgCheck((pwmp != NULL) && (channel < PWM_CHANNELS),
- "pwmEnableChannel");
+ osalDbgCheck((pwmp != NULL) && (channel < PWM_CHANNELS));
- chSysLock();
- chDbgAssert(pwmp->state == PWM_READY,
- "pwmEnableChannel(), #1", "not ready");
+ osalSysLock();
+ osalDbgAssert(pwmp->state == PWM_READY, "not ready");
pwm_lld_enable_channel(pwmp, channel, width);
- chSysUnlock();
+ osalSysUnlock();
}
/**
@@ -192,14 +188,12 @@ void pwmEnableChannel(PWMDriver *pwmp,
*/
void pwmDisableChannel(PWMDriver *pwmp, pwmchannel_t channel) {
- chDbgCheck((pwmp != NULL) && (channel < PWM_CHANNELS),
- "pwmEnableChannel");
+ osalDbgCheck((pwmp != NULL) && (channel < PWM_CHANNELS));
- chSysLock();
- chDbgAssert(pwmp->state == PWM_READY,
- "pwmDisableChannel(), #1", "not ready");
+ osalSysLock();
+ osalDbgAssert(pwmp->state == PWM_READY, "not ready");
pwm_lld_disable_channel(pwmp, channel);
- chSysUnlock();
+ osalSysUnlock();
}
#endif /* HAL_USE_PWM */
diff --git a/os/hal/src/rtc.c b/os/hal/src/rtc.c
deleted file mode 100644
index e0a1c227b..000000000
--- a/os/hal/src/rtc.c
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010,
- 2011,2012,2013 Giovanni Di Sirio.
-
- This file is part of ChibiOS/RT.
-
- ChibiOS/RT is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- ChibiOS/RT is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-/*
- Concepts and parts of this file have been contributed by Uladzimir Pylinsky
- aka barthess.
- */
-
-/**
- * @file rtc.c
- * @brief RTC Driver code.
- *
- * @addtogroup RTC
- * @{
- */
-
-#include "ch.h"
-#include "hal.h"
-
-#if HAL_USE_RTC || defined(__DOXYGEN__)
-
-/*===========================================================================*/
-/* Driver local definitions. */
-/*===========================================================================*/
-
-/*===========================================================================*/
-/* Driver exported variables. */
-/*===========================================================================*/
-
-/*===========================================================================*/
-/* Driver local variables and types. */
-/*===========================================================================*/
-
-/*===========================================================================*/
-/* Driver local functions. */
-/*===========================================================================*/
-
-/*===========================================================================*/
-/* Driver exported functions. */
-/*===========================================================================*/
-
-/**
- * @brief RTC Driver initialization.
- * @note This function is implicitly invoked by @p halInit(), there is
- * no need to explicitly initialize the driver.
- *
- * @init
- */
-void rtcInit(void) {
-
- rtc_lld_init();
-}
-
-/**
- * @brief Set current time.
- *
- * @param[in] rtcp pointer to RTC driver structure
- * @param[in] timespec pointer to a @p RTCTime structure
- *
- * @api
- */
-void rtcSetTime(RTCDriver *rtcp, const RTCTime *timespec) {
-
- chDbgCheck((rtcp != NULL) && (timespec != NULL), "rtcSetTime");
-
- chSysLock();
- rtcSetTimeI(rtcp, timespec);
- chSysUnlock();
-}
-
-/**
- * @brief Get current time.
- *
- * @param[in] rtcp pointer to RTC driver structure
- * @param[out] timespec pointer to a @p RTCTime structure
- *
- * @api
- */
-void rtcGetTime(RTCDriver *rtcp, RTCTime *timespec) {
-
- chDbgCheck((rtcp != NULL) && (timespec != NULL), "rtcGetTime");
-
- chSysLock();
- rtcGetTimeI(rtcp, timespec);
- chSysUnlock();
-}
-
-#if (RTC_ALARMS > 0) || defined(__DOXYGEN__)
-/**
- * @brief Set alarm time.
- *
- * @param[in] rtcp pointer to RTC driver structure
- * @param[in] alarm alarm identifier
- * @param[in] alarmspec pointer to a @p RTCAlarm structure or @p NULL
- *
- * @api
- */
-void rtcSetAlarm(RTCDriver *rtcp,
- rtcalarm_t alarm,
- const RTCAlarm *alarmspec) {
-
- chDbgCheck((rtcp != NULL) && (alarm < RTC_ALARMS), "rtcSetAlarm");
-
- chSysLock();
- rtcSetAlarmI(rtcp, alarm, alarmspec);
- chSysUnlock();
-}
-
-/**
- * @brief Get current alarm.
- * @note If an alarm has not been set then the returned alarm specification
- * is not meaningful.
- *
- * @param[in] rtcp pointer to RTC driver structure
- * @param[in] alarm alarm identifier
- * @param[out] alarmspec pointer to a @p RTCAlarm structure
- *
- * @api
- */
-void rtcGetAlarm(RTCDriver *rtcp,
- rtcalarm_t alarm,
- RTCAlarm *alarmspec) {
-
- chDbgCheck((rtcp != NULL) && (alarm < RTC_ALARMS) && (alarmspec != NULL),
- "rtcGetAlarm");
-
- chSysLock();
- rtcGetAlarmI(rtcp, alarm, alarmspec);
- chSysUnlock();
-}
-#endif /* RTC_ALARMS > 0 */
-
-#if RTC_SUPPORTS_CALLBACKS || defined(__DOXYGEN__)
-/**
- * @brief Enables or disables RTC callbacks.
- * @details This function enables or disables the callback, use a @p NULL
- * pointer in order to disable it.
- *
- * @param[in] rtcp pointer to RTC driver structure
- * @param[in] callback callback function pointer or @p NULL
- *
- * @api
- */
-void rtcSetCallback(RTCDriver *rtcp, rtccb_t callback) {
-
- chDbgCheck((rtcp != NULL), "rtcSetCallback");
-
- chSysLock();
- rtcSetCallbackI(rtcp, callback);
- chSysUnlock();
-}
-#endif /* RTC_SUPPORTS_CALLBACKS */
-
-/**
- * @brief Get current time in format suitable for usage in FatFS.
- *
- * @param[in] rtcp pointer to RTC driver structure
- * @return FAT time value.
- *
- * @api
- */
-uint32_t rtcGetTimeFat(RTCDriver *rtcp) {
-
- chDbgCheck((rtcp != NULL), "rtcSetTime");
- return rtc_lld_get_time_fat(rtcp);
-}
-
-#endif /* HAL_USE_RTC */
-
-/** @} */
diff --git a/os/hal/src/sdc.c b/os/hal/src/sdc.c
index f95331d44..d18f37b55 100644
--- a/os/hal/src/sdc.c
+++ b/os/hal/src/sdc.c
@@ -26,7 +26,6 @@
* @{
*/
-#include "ch.h"
#include "hal.h"
#if HAL_USE_SDC || defined(__DOXYGEN__)
@@ -47,14 +46,14 @@
* @brief Virtual methods table.
*/
static const struct SDCDriverVMT sdc_vmt = {
- (bool_t (*)(void *))sdc_lld_is_card_inserted,
- (bool_t (*)(void *))sdc_lld_is_write_protected,
- (bool_t (*)(void *))sdcConnect,
- (bool_t (*)(void *))sdcDisconnect,
- (bool_t (*)(void *, uint32_t, uint8_t *, uint32_t))sdcRead,
- (bool_t (*)(void *, uint32_t, const uint8_t *, uint32_t))sdcWrite,
- (bool_t (*)(void *))sdcSync,
- (bool_t (*)(void *, BlockDeviceInfo *))sdcGetInfo
+ (bool (*)(void *))sdc_lld_is_card_inserted,
+ (bool (*)(void *))sdc_lld_is_write_protected,
+ (bool (*)(void *))sdcConnect,
+ (bool (*)(void *))sdcDisconnect,
+ (bool (*)(void *, uint32_t, uint8_t *, uint32_t))sdcRead,
+ (bool (*)(void *, uint32_t, const uint8_t *, uint32_t))sdcWrite,
+ (bool (*)(void *))sdcSync,
+ (bool (*)(void *, BlockDeviceInfo *))sdcGetInfo
};
/*===========================================================================*/
@@ -67,37 +66,37 @@ static const struct SDCDriverVMT sdc_vmt = {
* @param[in] sdcp pointer to the @p SDCDriver object
*
* @return The operation status.
- * @retval CH_SUCCESS operation succeeded.
- * @retval CH_FAILED operation failed.
+ * @retval HAL_SUCCESS operation succeeded.
+ * @retval HAL_FAILED operation failed.
*
* @notapi
*/
-bool_t _sdc_wait_for_transfer_state(SDCDriver *sdcp) {
+bool _sdc_wait_for_transfer_state(SDCDriver *sdcp) {
uint32_t resp[1];
while (TRUE) {
if (sdc_lld_send_cmd_short_crc(sdcp, MMCSD_CMD_SEND_STATUS,
sdcp->rca, resp) ||
MMCSD_R1_ERROR(resp[0]))
- return CH_FAILED;
+ return HAL_FAILED;
switch (MMCSD_R1_STS(resp[0])) {
case MMCSD_STS_TRAN:
- return CH_SUCCESS;
+ return HAL_SUCCESS;
case MMCSD_STS_DATA:
case MMCSD_STS_RCV:
case MMCSD_STS_PRG:
#if SDC_NICE_WAITING
- chThdSleepMilliseconds(1);
+ osalThreadSleep(MS2ST(1));
#endif
continue;
default:
/* The card should have been initialized so any other state is not
valid and is reported as an error.*/
- return CH_FAILED;
+ return HAL_FAILED;
}
}
/* If something going too wrong.*/
- return CH_FAILED;
+ return HAL_FAILED;
}
/*===========================================================================*/
@@ -144,15 +143,15 @@ void sdcObjectInit(SDCDriver *sdcp) {
*/
void sdcStart(SDCDriver *sdcp, const SDCConfig *config) {
- chDbgCheck(sdcp != NULL, "sdcStart");
+ osalDbgCheck(sdcp != NULL);
- chSysLock();
- chDbgAssert((sdcp->state == BLK_STOP) || (sdcp->state == BLK_ACTIVE),
- "sdcStart(), #1", "invalid state");
+ osalSysLock();
+ osalDbgAssert((sdcp->state == BLK_STOP) || (sdcp->state == BLK_ACTIVE),
+ "invalid state");
sdcp->config = config;
sdc_lld_start(sdcp);
sdcp->state = BLK_ACTIVE;
- chSysUnlock();
+ osalSysUnlock();
}
/**
@@ -164,14 +163,14 @@ void sdcStart(SDCDriver *sdcp, const SDCConfig *config) {
*/
void sdcStop(SDCDriver *sdcp) {
- chDbgCheck(sdcp != NULL, "sdcStop");
+ osalDbgCheck(sdcp != NULL);
- chSysLock();
- chDbgAssert((sdcp->state == BLK_STOP) || (sdcp->state == BLK_ACTIVE),
- "sdcStop(), #1", "invalid state");
+ osalSysLock();
+ osalDbgAssert((sdcp->state == BLK_STOP) || (sdcp->state == BLK_ACTIVE),
+ "invalid state");
sdc_lld_stop(sdcp);
sdcp->state = BLK_STOP;
- chSysUnlock();
+ osalSysUnlock();
}
/**
@@ -183,17 +182,17 @@ void sdcStop(SDCDriver *sdcp) {
* @param[in] sdcp pointer to the @p SDCDriver object
*
* @return The operation status.
- * @retval CH_SUCCESS operation succeeded.
- * @retval CH_FAILED operation failed.
+ * @retval HAL_SUCCESS operation succeeded.
+ * @retval HAL_FAILED operation failed.
*
* @api
*/
-bool_t sdcConnect(SDCDriver *sdcp) {
+bool sdcConnect(SDCDriver *sdcp) {
uint32_t resp[1];
- chDbgCheck(sdcp != NULL, "sdcConnect");
- chDbgAssert((sdcp->state == BLK_ACTIVE) || (sdcp->state == BLK_READY),
- "mmcConnect(), #1", "invalid state");
+ osalDbgCheck(sdcp != NULL);
+ osalDbgAssert((sdcp->state == BLK_ACTIVE) || (sdcp->state == BLK_READY),
+ "invalid state");
/* Connection procedure in progress.*/
sdcp->state = BLK_CONNECTING;
@@ -258,7 +257,7 @@ bool_t sdcConnect(SDCDriver *sdcp) {
}
if (++i >= SDC_INIT_RETRY)
goto failed;
- chThdSleepMilliseconds(10);
+ osalThreadSleep(MS2ST(10));
}
}
@@ -311,13 +310,13 @@ bool_t sdcConnect(SDCDriver *sdcp) {
/* Initialization complete.*/
sdcp->state = BLK_READY;
- return CH_SUCCESS;
+ return HAL_SUCCESS;
/* Connection failed, state reset to BLK_ACTIVE.*/
failed:
sdc_lld_stop_clk(sdcp);
sdcp->state = BLK_ACTIVE;
- return CH_FAILED;
+ return HAL_FAILED;
}
/**
@@ -326,36 +325,36 @@ failed:
* @param[in] sdcp pointer to the @p SDCDriver object
*
* @return The operation status.
- * @retval CH_SUCCESS operation succeeded.
- * @retval CH_FAILED operation failed.
+ * @retval HAL_SUCCESS operation succeeded.
+ * @retval HAL_FAILED operation failed.
*
* @api
*/
-bool_t sdcDisconnect(SDCDriver *sdcp) {
+bool sdcDisconnect(SDCDriver *sdcp) {
- chDbgCheck(sdcp != NULL, "sdcDisconnect");
+ osalDbgCheck(sdcp != NULL);
- chSysLock();
- chDbgAssert((sdcp->state == BLK_ACTIVE) || (sdcp->state == BLK_READY),
- "sdcDisconnect(), #1", "invalid state");
+ osalSysLock();
+ osalDbgAssert((sdcp->state == BLK_ACTIVE) || (sdcp->state == BLK_READY),
+ "invalid state");
if (sdcp->state == BLK_ACTIVE) {
- chSysUnlock();
- return CH_SUCCESS;
+ osalSysUnlock();
+ return HAL_SUCCESS;
}
sdcp->state = BLK_DISCONNECTING;
- chSysUnlock();
+ osalSysUnlock();
/* Waits for eventual pending operations completion.*/
if (_sdc_wait_for_transfer_state(sdcp)) {
sdc_lld_stop_clk(sdcp);
sdcp->state = BLK_ACTIVE;
- return CH_FAILED;
+ return HAL_FAILED;
}
/* Card clock stopped.*/
sdc_lld_stop_clk(sdcp);
sdcp->state = BLK_ACTIVE;
- return CH_SUCCESS;
+ return HAL_SUCCESS;
}
/**
@@ -369,21 +368,20 @@ bool_t sdcDisconnect(SDCDriver *sdcp) {
* @param[in] n number of blocks to read
*
* @return The operation status.
- * @retval CH_SUCCESS operation succeeded.
- * @retval CH_FAILED operation failed.
+ * @retval HAL_SUCCESS operation succeeded.
+ * @retval HAL_FAILED operation failed.
*
* @api
*/
-bool_t sdcRead(SDCDriver *sdcp, uint32_t startblk,
- uint8_t *buf, uint32_t n) {
- bool_t status;
+bool sdcRead(SDCDriver *sdcp, uint32_t startblk, uint8_t *buf, uint32_t n) {
+ bool status;
- chDbgCheck((sdcp != NULL) && (buf != NULL) && (n > 0), "sdcRead");
- chDbgAssert(sdcp->state == BLK_READY, "sdcRead(), #1", "invalid state");
+ osalDbgCheck((sdcp != NULL) && (buf != NULL) && (n > 0));
+ osalDbgAssert(sdcp->state == BLK_READY, "invalid state");
if ((startblk + n - 1) > sdcp->capacity){
sdcp->errors |= SDC_OVERFLOW_ERROR;
- return CH_FAILED;
+ return HAL_FAILED;
}
/* Read operation in progress.*/
@@ -407,21 +405,21 @@ bool_t sdcRead(SDCDriver *sdcp, uint32_t startblk,
* @param[in] n number of blocks to write
*
* @return The operation status.
- * @retval CH_SUCCESS operation succeeded.
- * @retval CH_FAILED operation failed.
+ * @retval HAL_SUCCESS operation succeeded.
+ * @retval HAL_FAILED operation failed.
*
* @api
*/
-bool_t sdcWrite(SDCDriver *sdcp, uint32_t startblk,
- const uint8_t *buf, uint32_t n) {
- bool_t status;
+bool sdcWrite(SDCDriver *sdcp, uint32_t startblk,
+ const uint8_t *buf, uint32_t n) {
+ bool status;
- chDbgCheck((sdcp != NULL) && (buf != NULL) && (n > 0), "sdcWrite");
- chDbgAssert(sdcp->state == BLK_READY, "sdcWrite(), #1", "invalid state");
+ osalDbgCheck((sdcp != NULL) && (buf != NULL) && (n > 0));
+ osalDbgAssert(sdcp->state == BLK_READY, "invalid state");
if ((startblk + n - 1) > sdcp->capacity){
sdcp->errors |= SDC_OVERFLOW_ERROR;
- return CH_FAILED;
+ return HAL_FAILED;
}
/* Write operation in progress.*/
@@ -445,14 +443,13 @@ bool_t sdcWrite(SDCDriver *sdcp, uint32_t startblk,
sdcflags_t sdcGetAndClearErrors(SDCDriver *sdcp) {
sdcflags_t flags;
- chDbgCheck(sdcp != NULL, "sdcGetAndClearErrors");
- chDbgAssert(sdcp->state == BLK_READY,
- "sdcGetAndClearErrors(), #1", "invalid state");
+ osalDbgCheck(sdcp != NULL);
+ osalDbgAssert(sdcp->state == BLK_READY, "invalid state");
- chSysLock();
+ osalSysLock();
flags = sdcp->errors;
sdcp->errors = SDC_NO_ERROR;
- chSysUnlock();
+ osalSysUnlock();
return flags;
}
@@ -462,18 +459,18 @@ sdcflags_t sdcGetAndClearErrors(SDCDriver *sdcp) {
* @param[in] sdcp pointer to the @p SDCDriver object
*
* @return The operation status.
- * @retval CH_SUCCESS the operation succeeded.
- * @retval CH_FAILED the operation failed.
+ * @retval HAL_SUCCESS the operation succeeded.
+ * @retval HAL_FAILED the operation failed.
*
* @api
*/
-bool_t sdcSync(SDCDriver *sdcp) {
- bool_t result;
+bool sdcSync(SDCDriver *sdcp) {
+ bool result;
- chDbgCheck(sdcp != NULL, "sdcSync");
+ osalDbgCheck(sdcp != NULL);
if (sdcp->state != BLK_READY)
- return CH_FAILED;
+ return HAL_FAILED;
/* Synchronization operation in progress.*/
sdcp->state = BLK_SYNCING;
@@ -492,22 +489,22 @@ bool_t sdcSync(SDCDriver *sdcp) {
* @param[out] bdip pointer to a @p BlockDeviceInfo structure
*
* @return The operation status.
- * @retval CH_SUCCESS the operation succeeded.
- * @retval CH_FAILED the operation failed.
+ * @retval HAL_SUCCESS the operation succeeded.
+ * @retval HAL_FAILED the operation failed.
*
* @api
*/
-bool_t sdcGetInfo(SDCDriver *sdcp, BlockDeviceInfo *bdip) {
+bool sdcGetInfo(SDCDriver *sdcp, BlockDeviceInfo *bdip) {
- chDbgCheck((sdcp != NULL) && (bdip != NULL), "sdcGetInfo");
+ osalDbgCheck((sdcp != NULL) && (bdip != NULL));
if (sdcp->state != BLK_READY)
- return CH_FAILED;
+ return HAL_FAILED;
bdip->blk_num = sdcp->capacity;
bdip->blk_size = MMCSD_BLOCK_SIZE;
- return CH_SUCCESS;
+ return HAL_SUCCESS;
}
@@ -519,16 +516,16 @@ bool_t sdcGetInfo(SDCDriver *sdcp, BlockDeviceInfo *bdip) {
* @param[in] endblk ending block number
*
* @return The operation status.
- * @retval CH_SUCCESS the operation succeeded.
- * @retval CH_FAILED the operation failed.
+ * @retval HAL_SUCCESS the operation succeeded.
+ * @retval HAL_FAILED the operation failed.
*
* @api
*/
-bool_t sdcErase(SDCDriver *sdcp, uint32_t startblk, uint32_t endblk) {
+bool sdcErase(SDCDriver *sdcp, uint32_t startblk, uint32_t endblk) {
uint32_t resp[1];
- chDbgCheck((sdcp != NULL), "sdcErase");
- chDbgAssert(sdcp->state == BLK_READY, "sdcErase(), #1", "invalid state");
+ osalDbgCheck((sdcp != NULL));
+ osalDbgAssert(sdcp->state == BLK_READY, "invalid state");
/* Erase operation in progress.*/
sdcp->state = BLK_WRITING;
@@ -542,17 +539,17 @@ bool_t sdcErase(SDCDriver *sdcp, uint32_t startblk, uint32_t endblk) {
_sdc_wait_for_transfer_state(sdcp);
if ((sdc_lld_send_cmd_short_crc(sdcp, MMCSD_CMD_ERASE_RW_BLK_START,
- startblk, resp) != CH_SUCCESS) ||
+ startblk, resp) != HAL_SUCCESS) ||
MMCSD_R1_ERROR(resp[0]))
goto failed;
if ((sdc_lld_send_cmd_short_crc(sdcp, MMCSD_CMD_ERASE_RW_BLK_END,
- endblk, resp) != CH_SUCCESS) ||
+ endblk, resp) != HAL_SUCCESS) ||
MMCSD_R1_ERROR(resp[0]))
goto failed;
if ((sdc_lld_send_cmd_short_crc(sdcp, MMCSD_CMD_ERASE,
- 0, resp) != CH_SUCCESS) ||
+ 0, resp) != HAL_SUCCESS) ||
MMCSD_R1_ERROR(resp[0]))
goto failed;
@@ -563,11 +560,11 @@ bool_t sdcErase(SDCDriver *sdcp, uint32_t startblk, uint32_t endblk) {
_sdc_wait_for_transfer_state(sdcp);
sdcp->state = BLK_READY;
- return CH_SUCCESS;
+ return HAL_SUCCESS;
failed:
sdcp->state = BLK_READY;
- return CH_FAILED;
+ return HAL_FAILED;
}
#endif /* HAL_USE_SDC */
diff --git a/os/hal/src/serial.c b/os/hal/src/serial.c
index fdb802ccc..4b1fd17d5 100644
--- a/os/hal/src/serial.c
+++ b/os/hal/src/serial.c
@@ -26,7 +26,6 @@
* @{
*/
-#include "ch.h"
#include "hal.h"
#if HAL_USE_SERIAL || defined(__DOXYGEN__)
@@ -54,44 +53,44 @@
static size_t write(void *ip, const uint8_t *bp, size_t n) {
- return chOQWriteTimeout(&((SerialDriver *)ip)->oqueue, bp,
- n, TIME_INFINITE);
+ return oqWriteTimeout(&((SerialDriver *)ip)->oqueue, bp,
+ n, TIME_INFINITE);
}
static size_t read(void *ip, uint8_t *bp, size_t n) {
- return chIQReadTimeout(&((SerialDriver *)ip)->iqueue, bp,
- n, TIME_INFINITE);
+ return iqReadTimeout(&((SerialDriver *)ip)->iqueue, bp,
+ n, TIME_INFINITE);
}
static msg_t put(void *ip, uint8_t b) {
- return chOQPutTimeout(&((SerialDriver *)ip)->oqueue, b, TIME_INFINITE);
+ return oqPutTimeout(&((SerialDriver *)ip)->oqueue, b, TIME_INFINITE);
}
static msg_t get(void *ip) {
- return chIQGetTimeout(&((SerialDriver *)ip)->iqueue, TIME_INFINITE);
+ return iqGetTimeout(&((SerialDriver *)ip)->iqueue, TIME_INFINITE);
}
static msg_t putt(void *ip, uint8_t b, systime_t timeout) {
- return chOQPutTimeout(&((SerialDriver *)ip)->oqueue, b, timeout);
+ return oqPutTimeout(&((SerialDriver *)ip)->oqueue, b, timeout);
}
static msg_t gett(void *ip, systime_t timeout) {
- return chIQGetTimeout(&((SerialDriver *)ip)->iqueue, timeout);
+ return iqGetTimeout(&((SerialDriver *)ip)->iqueue, timeout);
}
static size_t writet(void *ip, const uint8_t *bp, size_t n, systime_t time) {
- return chOQWriteTimeout(&((SerialDriver *)ip)->oqueue, bp, n, time);
+ return oqWriteTimeout(&((SerialDriver *)ip)->oqueue, bp, n, time);
}
static size_t readt(void *ip, uint8_t *bp, size_t n, systime_t time) {
- return chIQReadTimeout(&((SerialDriver *)ip)->iqueue, bp, n, time);
+ return iqReadTimeout(&((SerialDriver *)ip)->iqueue, bp, n, time);
}
static const struct SerialDriverVMT vmt = {
@@ -133,10 +132,10 @@ void sdInit(void) {
void sdObjectInit(SerialDriver *sdp, qnotify_t inotify, qnotify_t onotify) {
sdp->vmt = &vmt;
- chEvtInit(&sdp->event);
+ osalEventObjectInit(&sdp->event);
sdp->state = SD_STOP;
- chIQInit(&sdp->iqueue, sdp->ib, SERIAL_BUFFERS_SIZE, inotify, sdp);
- chOQInit(&sdp->oqueue, sdp->ob, SERIAL_BUFFERS_SIZE, onotify, sdp);
+ iqObjectInit(&sdp->iqueue, sdp->ib, SERIAL_BUFFERS_SIZE, inotify, sdp);
+ oqObjectInit(&sdp->oqueue, sdp->ob, SERIAL_BUFFERS_SIZE, onotify, sdp);
}
/**
@@ -151,15 +150,14 @@ void sdObjectInit(SerialDriver *sdp, qnotify_t inotify, qnotify_t onotify) {
*/
void sdStart(SerialDriver *sdp, const SerialConfig *config) {
- chDbgCheck(sdp != NULL, "sdStart");
+ osalDbgCheck(sdp != NULL);
- chSysLock();
- chDbgAssert((sdp->state == SD_STOP) || (sdp->state == SD_READY),
- "sdStart(), #1",
- "invalid state");
+ osalSysLock();
+ osalDbgAssert((sdp->state == SD_STOP) || (sdp->state == SD_READY),
+ "invalid state");
sd_lld_start(sdp, config);
sdp->state = SD_READY;
- chSysUnlock();
+ osalSysUnlock();
}
/**
@@ -173,18 +171,17 @@ void sdStart(SerialDriver *sdp, const SerialConfig *config) {
*/
void sdStop(SerialDriver *sdp) {
- chDbgCheck(sdp != NULL, "sdStop");
+ osalDbgCheck(sdp != NULL);
- chSysLock();
- chDbgAssert((sdp->state == SD_STOP) || (sdp->state == SD_READY),
- "sdStop(), #1",
- "invalid state");
+ osalSysLock();
+ osalDbgAssert((sdp->state == SD_STOP) || (sdp->state == SD_READY),
+ "invalid state");
sd_lld_stop(sdp);
sdp->state = SD_STOP;
- chOQResetI(&sdp->oqueue);
- chIQResetI(&sdp->iqueue);
- chSchRescheduleS();
- chSysUnlock();
+ oqResetI(&sdp->oqueue);
+ iqResetI(&sdp->iqueue);
+ osalOsRescheduleS();
+ osalSysUnlock();
}
/**
@@ -205,12 +202,12 @@ void sdStop(SerialDriver *sdp) {
*/
void sdIncomingDataI(SerialDriver *sdp, uint8_t b) {
- chDbgCheckClassI();
- chDbgCheck(sdp != NULL, "sdIncomingDataI");
+ osalDbgCheckClassI();
+ osalDbgCheck(sdp != NULL);
- if (chIQIsEmptyI(&sdp->iqueue))
+ if (iqIsEmptyI(&sdp->iqueue))
chnAddFlagsI(sdp, CHN_INPUT_AVAILABLE);
- if (chIQPutI(&sdp->iqueue, b) < Q_OK)
+ if (iqPutI(&sdp->iqueue, b) < Q_OK)
chnAddFlagsI(sdp, SD_OVERRUN_ERROR);
}
@@ -232,10 +229,10 @@ void sdIncomingDataI(SerialDriver *sdp, uint8_t b) {
msg_t sdRequestDataI(SerialDriver *sdp) {
msg_t b;
- chDbgCheckClassI();
- chDbgCheck(sdp != NULL, "sdRequestDataI");
+ osalDbgCheckClassI();
+ osalDbgCheck(sdp != NULL);
- b = chOQGetI(&sdp->oqueue);
+ b = oqGetI(&sdp->oqueue);
if (b < Q_OK)
chnAddFlagsI(sdp, CHN_OUTPUT_EMPTY);
return b;
diff --git a/os/hal/src/serial_usb.c b/os/hal/src/serial_usb.c
index ff6e94b07..7a9476250 100644
--- a/os/hal/src/serial_usb.c
+++ b/os/hal/src/serial_usb.c
@@ -26,7 +26,6 @@
* @{
*/
-#include "ch.h"
#include "hal.h"
#if HAL_USE_SERIAL_USB || defined(__DOXYGEN__)
@@ -61,44 +60,44 @@ static cdc_linecoding_t linecoding = {
static size_t write(void *ip, const uint8_t *bp, size_t n) {
- return chOQWriteTimeout(&((SerialUSBDriver *)ip)->oqueue, bp,
- n, TIME_INFINITE);
+ return oqWriteTimeout(&((SerialUSBDriver *)ip)->oqueue, bp,
+ n, TIME_INFINITE);
}
static size_t read(void *ip, uint8_t *bp, size_t n) {
- return chIQReadTimeout(&((SerialUSBDriver *)ip)->iqueue, bp,
- n, TIME_INFINITE);
+ return iqReadTimeout(&((SerialUSBDriver *)ip)->iqueue, bp,
+ n, TIME_INFINITE);
}
static msg_t put(void *ip, uint8_t b) {
- return chOQPutTimeout(&((SerialUSBDriver *)ip)->oqueue, b, TIME_INFINITE);
+ return oqPutTimeout(&((SerialUSBDriver *)ip)->oqueue, b, TIME_INFINITE);
}
static msg_t get(void *ip) {
- return chIQGetTimeout(&((SerialUSBDriver *)ip)->iqueue, TIME_INFINITE);
+ return iqGetTimeout(&((SerialUSBDriver *)ip)->iqueue, TIME_INFINITE);
}
static msg_t putt(void *ip, uint8_t b, systime_t timeout) {
- return chOQPutTimeout(&((SerialUSBDriver *)ip)->oqueue, b, timeout);
+ return oqPutTimeout(&((SerialUSBDriver *)ip)->oqueue, b, timeout);
}
static msg_t gett(void *ip, systime_t timeout) {
- return chIQGetTimeout(&((SerialUSBDriver *)ip)->iqueue, timeout);
+ return iqGetTimeout(&((SerialUSBDriver *)ip)->iqueue, timeout);
}
static size_t writet(void *ip, const uint8_t *bp, size_t n, systime_t time) {
- return chOQWriteTimeout(&((SerialUSBDriver *)ip)->oqueue, bp, n, time);
+ return oqWriteTimeout(&((SerialUSBDriver *)ip)->oqueue, bp, n, time);
}
static size_t readt(void *ip, uint8_t *bp, size_t n, systime_t time) {
- return chIQReadTimeout(&((SerialUSBDriver *)ip)->iqueue, bp, n, time);
+ return iqReadTimeout(&((SerialUSBDriver *)ip)->iqueue, bp, n, time);
}
static const struct SerialUSBDriverVMT vmt = {
@@ -109,9 +108,9 @@ static const struct SerialUSBDriverVMT vmt = {
/**
* @brief Notification of data removed from the input queue.
*/
-static void inotify(GenericQueue *qp) {
+static void inotify(io_queue_t *qp) {
size_t n, maxsize;
- SerialUSBDriver *sdup = chQGetLink(qp);
+ SerialUSBDriver *sdup = qGetLink(qp);
/* If the USB driver is not in the appropriate state then transactions
must not be started.*/
@@ -124,15 +123,15 @@ static void inotify(GenericQueue *qp) {
the available space.*/
maxsize = sdup->config->usbp->epc[sdup->config->bulk_out]->out_maxsize;
if (!usbGetReceiveStatusI(sdup->config->usbp, sdup->config->bulk_out) &&
- ((n = chIQGetEmptyI(&sdup->iqueue)) >= maxsize)) {
- chSysUnlock();
+ ((n = iqGetEmptyI(&sdup->iqueue)) >= maxsize)) {
+ osalSysUnlock();
n = (n / maxsize) * maxsize;
usbPrepareQueuedReceive(sdup->config->usbp,
sdup->config->bulk_out,
&sdup->iqueue, n);
- chSysLock();
+ osalSysLock();
usbStartReceiveI(sdup->config->usbp, sdup->config->bulk_out);
}
}
@@ -140,9 +139,9 @@ static void inotify(GenericQueue *qp) {
/**
* @brief Notification of data inserted into the output queue.
*/
-static void onotify(GenericQueue *qp) {
+static void onotify(io_queue_t *qp) {
size_t n;
- SerialUSBDriver *sdup = chQGetLink(qp);
+ SerialUSBDriver *sdup = qGetLink(qp);
/* If the USB driver is not in the appropriate state then transactions
must not be started.*/
@@ -153,14 +152,14 @@ static void onotify(GenericQueue *qp) {
/* If there is not an ongoing transaction and the output queue contains
data then a new transaction is started.*/
if (!usbGetTransmitStatusI(sdup->config->usbp, sdup->config->bulk_in) &&
- ((n = chOQGetFullI(&sdup->oqueue)) > 0)) {
- chSysUnlock();
+ ((n = oqGetFullI(&sdup->oqueue)) > 0)) {
+ osalSysUnlock();
usbPrepareQueuedTransmit(sdup->config->usbp,
sdup->config->bulk_in,
&sdup->oqueue, n);
- chSysLock();
+ osalSysLock();
usbStartTransmitI(sdup->config->usbp, sdup->config->bulk_in);
}
}
@@ -191,10 +190,10 @@ void sduInit(void) {
void sduObjectInit(SerialUSBDriver *sdup) {
sdup->vmt = &vmt;
- chEvtInit(&sdup->event);
+ osalEventObjectInit(&sdup->event);
sdup->state = SDU_STOP;
- chIQInit(&sdup->iqueue, sdup->ib, SERIAL_USB_BUFFERS_SIZE, inotify, sdup);
- chOQInit(&sdup->oqueue, sdup->ob, SERIAL_USB_BUFFERS_SIZE, onotify, sdup);
+ iqObjectInit(&sdup->iqueue, sdup->ib, SERIAL_USB_BUFFERS_SIZE, inotify, sdup);
+ oqObjectInit(&sdup->oqueue, sdup->ob, SERIAL_USB_BUFFERS_SIZE, onotify, sdup);
}
/**
@@ -208,18 +207,17 @@ void sduObjectInit(SerialUSBDriver *sdup) {
void sduStart(SerialUSBDriver *sdup, const SerialUSBConfig *config) {
USBDriver *usbp = config->usbp;
- chDbgCheck(sdup != NULL, "sduStart");
+ osalDbgCheck(sdup != NULL);
- chSysLock();
- chDbgAssert((sdup->state == SDU_STOP) || (sdup->state == SDU_READY),
- "sduStart(), #1",
- "invalid state");
+ osalSysLock();
+ osalDbgAssert((sdup->state == SDU_STOP) || (sdup->state == SDU_READY),
+ "invalid state");
usbp->in_params[config->bulk_in - 1] = sdup;
usbp->out_params[config->bulk_out - 1] = sdup;
usbp->in_params[config->int_in - 1] = sdup;
sdup->config = config;
sdup->state = SDU_READY;
- chSysUnlock();
+ osalSysUnlock();
}
/**
@@ -234,13 +232,12 @@ void sduStart(SerialUSBDriver *sdup, const SerialUSBConfig *config) {
void sduStop(SerialUSBDriver *sdup) {
USBDriver *usbp = sdup->config->usbp;
- chDbgCheck(sdup != NULL, "sdStop");
+ osalDbgCheck(sdup != NULL);
- chSysLock();
+ osalSysLock();
- chDbgAssert((sdup->state == SDU_STOP) || (sdup->state == SDU_READY),
- "sduStop(), #1",
- "invalid state");
+ osalDbgAssert((sdup->state == SDU_STOP) || (sdup->state == SDU_READY),
+ "invalid state");
/* Driver in stopped state.*/
usbp->in_params[sdup->config->bulk_in - 1] = NULL;
@@ -250,11 +247,11 @@ void sduStop(SerialUSBDriver *sdup) {
/* Queues reset in order to signal the driver stop to the application.*/
chnAddFlagsI(sdup, CHN_DISCONNECTED);
- chIQResetI(&sdup->iqueue);
- chOQResetI(&sdup->oqueue);
- chSchRescheduleS();
+ iqResetI(&sdup->iqueue);
+ iqResetI(&sdup->oqueue);
+ osalOsRescheduleS();
- chSysUnlock();
+ osalSysUnlock();
}
/**
@@ -267,8 +264,8 @@ void sduStop(SerialUSBDriver *sdup) {
void sduConfigureHookI(SerialUSBDriver *sdup) {
USBDriver *usbp = sdup->config->usbp;
- chIQResetI(&sdup->iqueue);
- chOQResetI(&sdup->oqueue);
+ iqResetI(&sdup->iqueue);
+ oqResetI(&sdup->oqueue);
chnAddFlagsI(sdup, CHN_CONNECTED);
/* Starts the first OUT transaction immediately.*/
@@ -292,7 +289,7 @@ void sduConfigureHookI(SerialUSBDriver *sdup) {
* @retval TRUE Message handled internally.
* @retval FALSE Message not handled.
*/
-bool_t sduRequestsHook(USBDriver *usbp) {
+bool sduRequestsHook(USBDriver *usbp) {
if ((usbp->setup[0] & USB_RTYPE_TYPE_MASK) == USB_RTYPE_TYPE_CLASS) {
switch (usbp->setup[1]) {
@@ -328,17 +325,17 @@ void sduDataTransmitted(USBDriver *usbp, usbep_t ep) {
if (sdup == NULL)
return;
- chSysLockFromIsr();
+ osalSysLockFromISR();
chnAddFlagsI(sdup, CHN_OUTPUT_EMPTY);
- if ((n = chOQGetFullI(&sdup->oqueue)) > 0) {
+ if ((n = oqGetFullI(&sdup->oqueue)) > 0) {
/* The endpoint cannot be busy, we are in the context of the callback,
so it is safe to transmit without a check.*/
- chSysUnlockFromIsr();
+ osalSysUnlockFromISR();
usbPrepareQueuedTransmit(usbp, ep, &sdup->oqueue, n);
- chSysLockFromIsr();
+ osalSysLockFromISR();
usbStartTransmitI(usbp, ep);
}
else if ((usbp->epc[ep]->in_state->txsize > 0) &&
@@ -348,15 +345,15 @@ void sduDataTransmitted(USBDriver *usbp, usbep_t ep) {
size. Otherwise the recipient may expect more data coming soon and
not return buffered data to app. See section 5.8.3 Bulk Transfer
Packet Size Constraints of the USB Specification document.*/
- chSysUnlockFromIsr();
+ osalSysUnlockFromISR();
usbPrepareQueuedTransmit(usbp, ep, &sdup->oqueue, 0);
- chSysLockFromIsr();
+ osalSysLockFromISR();
usbStartTransmitI(usbp, ep);
}
- chSysUnlockFromIsr();
+ osalSysUnlockFromISR();
}
/**
@@ -374,25 +371,25 @@ void sduDataReceived(USBDriver *usbp, usbep_t ep) {
if (sdup == NULL)
return;
- chSysLockFromIsr();
+ osalSysLockFromISR();
chnAddFlagsI(sdup, CHN_INPUT_AVAILABLE);
/* Writes to the input queue can only happen when there is enough space
to hold at least one packet.*/
maxsize = usbp->epc[ep]->out_maxsize;
- if ((n = chIQGetEmptyI(&sdup->iqueue)) >= maxsize) {
+ if ((n = iqGetEmptyI(&sdup->iqueue)) >= maxsize) {
/* The endpoint cannot be busy, we are in the context of the callback,
so a packet is in the buffer for sure.*/
- chSysUnlockFromIsr();
+ osalSysUnlockFromISR();
n = (n / maxsize) * maxsize;
usbPrepareQueuedReceive(usbp, ep, &sdup->iqueue, n);
- chSysLockFromIsr();
+ osalSysLockFromISR();
usbStartReceiveI(usbp, ep);
}
- chSysUnlockFromIsr();
+ osalSysUnlockFromISR();
}
/**
diff --git a/os/hal/src/spi.c b/os/hal/src/spi.c
index 2dc0cc6ee..f47ed0527 100644
--- a/os/hal/src/spi.c
+++ b/os/hal/src/spi.c
@@ -26,7 +26,6 @@
* @{
*/
-#include "ch.h"
#include "hal.h"
#if HAL_USE_SPI || defined(__DOXYGEN__)
@@ -78,11 +77,7 @@ void spiObjectInit(SPIDriver *spip) {
spip->thread = NULL;
#endif /* SPI_USE_WAIT */
#if SPI_USE_MUTUAL_EXCLUSION
-#if CH_USE_MUTEXES
- chMtxInit(&spip->mutex);
-#else
- chSemInit(&spip->semaphore, 1);
-#endif
+ osalMutexObjectInit(&spip->mutex);
#endif /* SPI_USE_MUTUAL_EXCLUSION */
#if defined(SPI_DRIVER_EXT_INIT_HOOK)
SPI_DRIVER_EXT_INIT_HOOK(spip);
@@ -99,15 +94,15 @@ void spiObjectInit(SPIDriver *spip) {
*/
void spiStart(SPIDriver *spip, const SPIConfig *config) {
- chDbgCheck((spip != NULL) && (config != NULL), "spiStart");
+ osalDbgCheck((spip != NULL) && (config != NULL));
- chSysLock();
- chDbgAssert((spip->state == SPI_STOP) || (spip->state == SPI_READY),
- "spiStart(), #1", "invalid state");
+ osalSysLock();
+ osalDbgAssert((spip->state == SPI_STOP) || (spip->state == SPI_READY),
+ "invalid state");
spip->config = config;
spi_lld_start(spip);
spip->state = SPI_READY;
- chSysUnlock();
+ osalSysUnlock();
}
/**
@@ -121,14 +116,14 @@ void spiStart(SPIDriver *spip, const SPIConfig *config) {
*/
void spiStop(SPIDriver *spip) {
- chDbgCheck(spip != NULL, "spiStop");
+ osalDbgCheck(spip != NULL);
- chSysLock();
- chDbgAssert((spip->state == SPI_STOP) || (spip->state == SPI_READY),
- "spiStop(), #1", "invalid state");
+ osalSysLock();
+ osalDbgAssert((spip->state == SPI_STOP) || (spip->state == SPI_READY),
+ "invalid state");
spi_lld_stop(spip);
spip->state = SPI_STOP;
- chSysUnlock();
+ osalSysUnlock();
}
/**
@@ -140,12 +135,12 @@ void spiStop(SPIDriver *spip) {
*/
void spiSelect(SPIDriver *spip) {
- chDbgCheck(spip != NULL, "spiSelect");
+ osalDbgCheck(spip != NULL);
- chSysLock();
- chDbgAssert(spip->state == SPI_READY, "spiSelect(), #1", "not ready");
+ osalSysLock();
+ osalDbgAssert(spip->state == SPI_READY, "not ready");
spiSelectI(spip);
- chSysUnlock();
+ osalSysUnlock();
}
/**
@@ -158,12 +153,12 @@ void spiSelect(SPIDriver *spip) {
*/
void spiUnselect(SPIDriver *spip) {
- chDbgCheck(spip != NULL, "spiUnselect");
+ osalDbgCheck(spip != NULL);
- chSysLock();
- chDbgAssert(spip->state == SPI_READY, "spiUnselect(), #1", "not ready");
+ osalSysLock();
+ osalDbgAssert(spip->state == SPI_READY, "not ready");
spiUnselectI(spip);
- chSysUnlock();
+ osalSysUnlock();
}
/**
@@ -181,12 +176,12 @@ void spiUnselect(SPIDriver *spip) {
*/
void spiStartIgnore(SPIDriver *spip, size_t n) {
- chDbgCheck((spip != NULL) && (n > 0), "spiStartIgnore");
+ osalDbgCheck((spip != NULL) && (n > 0));
- chSysLock();
- chDbgAssert(spip->state == SPI_READY, "spiStartIgnore(), #1", "not ready");
+ osalSysLock();
+ osalDbgAssert(spip->state == SPI_READY, "not ready");
spiStartIgnoreI(spip, n);
- chSysUnlock();
+ osalSysUnlock();
}
/**
@@ -209,13 +204,12 @@ void spiStartIgnore(SPIDriver *spip, size_t n) {
void spiStartExchange(SPIDriver *spip, size_t n,
const void *txbuf, void *rxbuf) {
- chDbgCheck((spip != NULL) && (n > 0) && (rxbuf != NULL) && (txbuf != NULL),
- "spiStartExchange");
+ osalDbgCheck((spip != NULL) && (n > 0) && (rxbuf != NULL) && (txbuf != NULL));
- chSysLock();
- chDbgAssert(spip->state == SPI_READY, "spiStartExchange(), #1", "not ready");
+ osalSysLock();
+ osalDbgAssert(spip->state == SPI_READY, "not ready");
spiStartExchangeI(spip, n, txbuf, rxbuf);
- chSysUnlock();
+ osalSysUnlock();
}
/**
@@ -235,13 +229,12 @@ void spiStartExchange(SPIDriver *spip, size_t n,
*/
void spiStartSend(SPIDriver *spip, size_t n, const void *txbuf) {
- chDbgCheck((spip != NULL) && (n > 0) && (txbuf != NULL),
- "spiStartSend");
+ osalDbgCheck((spip != NULL) && (n > 0) && (txbuf != NULL));
- chSysLock();
- chDbgAssert(spip->state == SPI_READY, "spiStartSend(), #1", "not ready");
+ osalSysLock();
+ osalDbgAssert(spip->state == SPI_READY, "not ready");
spiStartSendI(spip, n, txbuf);
- chSysUnlock();
+ osalSysUnlock();
}
/**
@@ -261,13 +254,12 @@ void spiStartSend(SPIDriver *spip, size_t n, const void *txbuf) {
*/
void spiStartReceive(SPIDriver *spip, size_t n, void *rxbuf) {
- chDbgCheck((spip != NULL) && (n > 0) && (rxbuf != NULL),
- "spiStartReceive");
+ osalDbgCheck((spip != NULL) && (n > 0) && (rxbuf != NULL));
- chSysLock();
- chDbgAssert(spip->state == SPI_READY, "spiStartReceive(), #1", "not ready");
+ osalSysLock();
+ osalDbgAssert(spip->state == SPI_READY, "not ready");
spiStartReceiveI(spip, n, rxbuf);
- chSysUnlock();
+ osalSysUnlock();
}
#if SPI_USE_WAIT || defined(__DOXYGEN__)
@@ -287,14 +279,14 @@ void spiStartReceive(SPIDriver *spip, size_t n, void *rxbuf) {
*/
void spiIgnore(SPIDriver *spip, size_t n) {
- chDbgCheck((spip != NULL) && (n > 0), "spiIgnoreWait");
+ osalDbgCheck((spip != NULL) && (n > 0));
- chSysLock();
- chDbgAssert(spip->state == SPI_READY, "spiIgnore(), #1", "not ready");
- chDbgAssert(spip->config->end_cb == NULL, "spiIgnore(), #2", "has callback");
+ osalSysLock();
+ osalDbgAssert(spip->state == SPI_READY, "not ready");
+ osalDbgAssert(spip->config->end_cb == NULL, "has callback");
spiStartIgnoreI(spip, n);
_spi_wait_s(spip);
- chSysUnlock();
+ osalSysUnlock();
}
/**
@@ -318,16 +310,15 @@ void spiIgnore(SPIDriver *spip, size_t n) {
void spiExchange(SPIDriver *spip, size_t n,
const void *txbuf, void *rxbuf) {
- chDbgCheck((spip != NULL) && (n > 0) && (rxbuf != NULL) && (txbuf != NULL),
- "spiExchange");
+ osalDbgCheck((spip != NULL) && (n > 0) &&
+ (rxbuf != NULL) && (txbuf != NULL));
- chSysLock();
- chDbgAssert(spip->state == SPI_READY, "spiExchange(), #1", "not ready");
- chDbgAssert(spip->config->end_cb == NULL,
- "spiExchange(), #2", "has callback");
+ osalSysLock();
+ osalDbgAssert(spip->state == SPI_READY, "not ready");
+ osalDbgAssert(spip->config->end_cb == NULL, "has callback");
spiStartExchangeI(spip, n, txbuf, rxbuf);
_spi_wait_s(spip);
- chSysUnlock();
+ osalSysUnlock();
}
/**
@@ -348,14 +339,14 @@ void spiExchange(SPIDriver *spip, size_t n,
*/
void spiSend(SPIDriver *spip, size_t n, const void *txbuf) {
- chDbgCheck((spip != NULL) && (n > 0) && (txbuf != NULL), "spiSend");
+ osalDbgCheck((spip != NULL) && (n > 0) && (txbuf != NULL));
- chSysLock();
- chDbgAssert(spip->state == SPI_READY, "spiSend(), #1", "not ready");
- chDbgAssert(spip->config->end_cb == NULL, "spiSend(), #2", "has callback");
+ osalSysLock();
+ osalDbgAssert(spip->state == SPI_READY, "not ready");
+ osalDbgAssert(spip->config->end_cb == NULL, "has callback");
spiStartSendI(spip, n, txbuf);
_spi_wait_s(spip);
- chSysUnlock();
+ osalSysUnlock();
}
/**
@@ -376,16 +367,14 @@ void spiSend(SPIDriver *spip, size_t n, const void *txbuf) {
*/
void spiReceive(SPIDriver *spip, size_t n, void *rxbuf) {
- chDbgCheck((spip != NULL) && (n > 0) && (rxbuf != NULL),
- "spiReceive");
+ osalDbgCheck((spip != NULL) && (n > 0) && (rxbuf != NULL));
- chSysLock();
- chDbgAssert(spip->state == SPI_READY, "spiReceive(), #1", "not ready");
- chDbgAssert(spip->config->end_cb == NULL,
- "spiReceive(), #2", "has callback");
+ osalSysLock();
+ osalDbgAssert(spip->state == SPI_READY, "not ready");
+ osalDbgAssert(spip->config->end_cb == NULL, "has callback");
spiStartReceiveI(spip, n, rxbuf);
_spi_wait_s(spip);
- chSysUnlock();
+ osalSysUnlock();
}
#endif /* SPI_USE_WAIT */
@@ -403,13 +392,9 @@ void spiReceive(SPIDriver *spip, size_t n, void *rxbuf) {
*/
void spiAcquireBus(SPIDriver *spip) {
- chDbgCheck(spip != NULL, "spiAcquireBus");
+ osalDbgCheck(spip != NULL);
-#if CH_USE_MUTEXES
- chMtxLock(&spip->mutex);
-#elif CH_USE_SEMAPHORES
- chSemWait(&spip->semaphore);
-#endif
+ osalMutexLock(&spip->mutex);
}
/**
@@ -423,14 +408,9 @@ void spiAcquireBus(SPIDriver *spip) {
*/
void spiReleaseBus(SPIDriver *spip) {
- chDbgCheck(spip != NULL, "spiReleaseBus");
+ osalDbgCheck(spip != NULL);
-#if CH_USE_MUTEXES
- (void)spip;
- chMtxUnlock();
-#elif CH_USE_SEMAPHORES
- chSemSignal(&spip->semaphore);
-#endif
+ osalMutexUnlock(&spip->mutex);
}
#endif /* SPI_USE_MUTUAL_EXCLUSION */
diff --git a/os/hal/src/tm.c b/os/hal/src/st.c
index 5b002cd90..afb4466fa 100644
--- a/os/hal/src/tm.c
+++ b/os/hal/src/st.c
@@ -19,17 +19,16 @@
*/
/**
- * @file tm.c
- * @brief Time Measurement driver code.
+ * @file st.c
+ * @brief ST Driver code.
*
- * @addtogroup TM
+ * @addtogroup ST
* @{
*/
-#include "ch.h"
#include "hal.h"
-#if HAL_USE_TM || defined(__DOXYGEN__)
+#if (OSAL_ST_MODE != OSAL_ST_MODE_NONE) || defined(__DOXYGEN__)
/*===========================================================================*/
/* Driver local definitions. */
@@ -40,89 +39,98 @@
/*===========================================================================*/
/*===========================================================================*/
-/* Driver local variables and types. */
+/* Driver local types. */
/*===========================================================================*/
-/**
- * @brief Subsystem calibration value.
- */
-static halrtcnt_t measurement_offset;
+/*===========================================================================*/
+/* Driver local variables. */
+/*===========================================================================*/
/*===========================================================================*/
/* Driver local functions. */
/*===========================================================================*/
+/*===========================================================================*/
+/* Driver exported functions. */
+/*===========================================================================*/
+
/**
- * @brief Starts a measurement.
+ * @brief ST Driver initialization.
+ * @note This function is implicitly invoked by @p halInit(), there is
+ * no need to explicitly initialize the driver.
*
- * @param[in,out] tmp pointer to a @p TimeMeasurement structure
- *
- * @notapi
+ * @init
*/
-static void tm_start(TimeMeasurement *tmp) {
+void stInit(void) {
- tmp->last = halGetCounterValue();
+ st_lld_init();
}
+
/**
- * @brief Stops a measurement.
+ * @brief Starts the alarm.
+ * @note Makes sure that no spurious alarms are triggered after
+ * this call.
+ * @note This functionality is only available in free running mode, the
+ * behavior in periodic mode is undefined.
*
- * @param[in,out] tmp pointer to a @p TimeMeasurement structure
+ * @param[in] time the time to be set for the first alarm
*
- * @notapi
+ * @api
*/
-static void tm_stop(TimeMeasurement *tmp) {
-
- halrtcnt_t now = halGetCounterValue();
- tmp->last = now - tmp->last - measurement_offset;
- if (tmp->last > tmp->worst)
- tmp->worst = tmp->last;
- else if (tmp->last < tmp->best)
- tmp->best = tmp->last;
+void stStartAlarm(systime_t time) {
+
+ osalDbgAssert(stIsAlarmActive() == false, "already active");
+
+ st_lld_start_alarm(time);
}
-/*===========================================================================*/
-/* Driver interrupt handlers. */
-/*===========================================================================*/
+/**
+ * @brief Stops the alarm interrupt.
+ * @note This functionality is only available in free running mode, the
+ * behavior in periodic mode is undefined.
+ *
+ * @api
+ */
+void stStopAlarm(void) {
-/*===========================================================================*/
-/* Driver exported functions. */
-/*===========================================================================*/
+ osalDbgAssert(stIsAlarmActive() != false, "not active");
+
+ st_lld_stop_alarm();
+}
/**
- * @brief Initializes the Time Measurement unit.
+ * @brief Sets the alarm time.
+ * @note This functionality is only available in free running mode, the
+ * behavior in periodic mode is undefined.
*
- * @init
+ * @param[in] time the time to be set for the next alarm
+ *
+ * @api
*/
-void tmInit(void) {
- TimeMeasurement tm;
-
- /* Time Measurement subsystem calibration, it does a null measurement
- and calculates the call overhead which is subtracted to real
- measurements.*/
- measurement_offset = 0;
- tmObjectInit(&tm);
- tmStartMeasurement(&tm);
- tmStopMeasurement(&tm);
- measurement_offset = tm.last;
+void stSetAlarm(systime_t time) {
+
+ osalDbgAssert(stIsAlarmActive() != false, "not active");
+
+ st_lld_set_alarm(time);
}
/**
- * @brief Initializes a @p TimeMeasurement object.
+ * @brief Returns the current alarm time.
+ * @note This functionality is only available in free running mode, the
+ * behavior in periodic mode is undefined.
*
- * @param[out] tmp pointer to a @p TimeMeasurement structure
+ * @return The currently set alarm time.
*
- * @init
+ * @api
*/
-void tmObjectInit(TimeMeasurement *tmp) {
+systime_t stGetAlarm(void) {
+
+ osalDbgAssert(stIsAlarmActive() != false, "not active");
- tmp->start = tm_start;
- tmp->stop = tm_stop;
- tmp->last = (halrtcnt_t)0;
- tmp->worst = (halrtcnt_t)0;
- tmp->best = (halrtcnt_t)-1;
+ return st_lld_get_alarm();
}
-#endif /* HAL_USE_TM */
+#endif /* OSAL_ST_MODE != OSAL_ST_MODE_NONE */
/** @} */
diff --git a/os/hal/src/uart.c b/os/hal/src/uart.c
index 71869538d..a25b594aa 100644
--- a/os/hal/src/uart.c
+++ b/os/hal/src/uart.c
@@ -26,7 +26,6 @@
* @{
*/
-#include "ch.h"
#include "hal.h"
#if HAL_USE_UART || defined(__DOXYGEN__)
@@ -92,16 +91,16 @@ void uartObjectInit(UARTDriver *uartp) {
*/
void uartStart(UARTDriver *uartp, const UARTConfig *config) {
- chDbgCheck((uartp != NULL) && (config != NULL), "uartStart");
+ osalDbgCheck((uartp != NULL) && (config != NULL));
- chSysLock();
- chDbgAssert((uartp->state == UART_STOP) || (uartp->state == UART_READY),
- "uartStart(), #1", "invalid state");
+ osalSysLock();
+ osalDbgAssert((uartp->state == UART_STOP) || (uartp->state == UART_READY),
+ "invalid state");
uartp->config = config;
uart_lld_start(uartp);
uartp->state = UART_READY;
- chSysUnlock();
+ osalSysUnlock();
}
/**
@@ -113,17 +112,17 @@ void uartStart(UARTDriver *uartp, const UARTConfig *config) {
*/
void uartStop(UARTDriver *uartp) {
- chDbgCheck(uartp != NULL, "uartStop");
+ osalDbgCheck(uartp != NULL);
- chSysLock();
- chDbgAssert((uartp->state == UART_STOP) || (uartp->state == UART_READY),
- "uartStop(), #1", "invalid state");
+ osalSysLock();
+ osalDbgAssert((uartp->state == UART_STOP) || (uartp->state == UART_READY),
+ "invalid state");
uart_lld_stop(uartp);
uartp->state = UART_STOP;
uartp->txstate = UART_TX_IDLE;
uartp->rxstate = UART_RX_IDLE;
- chSysUnlock();
+ osalSysUnlock();
}
/**
@@ -139,18 +138,15 @@ void uartStop(UARTDriver *uartp) {
*/
void uartStartSend(UARTDriver *uartp, size_t n, const void *txbuf) {
- chDbgCheck((uartp != NULL) && (n > 0) && (txbuf != NULL),
- "uartStartSend");
+ osalDbgCheck((uartp != NULL) && (n > 0) && (txbuf != NULL));
- chSysLock();
- chDbgAssert(uartp->state == UART_READY,
- "uartStartSend(), #1", "is active");
- chDbgAssert(uartp->txstate != UART_TX_ACTIVE,
- "uartStartSend(), #2", "tx active");
+ osalSysLock();
+ osalDbgAssert(uartp->state == UART_READY, "is active");
+ osalDbgAssert(uartp->txstate != UART_TX_ACTIVE, "tx active");
uart_lld_start_send(uartp, n, txbuf);
uartp->txstate = UART_TX_ACTIVE;
- chSysUnlock();
+ osalSysUnlock();
}
/**
@@ -167,13 +163,10 @@ void uartStartSend(UARTDriver *uartp, size_t n, const void *txbuf) {
*/
void uartStartSendI(UARTDriver *uartp, size_t n, const void *txbuf) {
- chDbgCheckClassI();
- chDbgCheck((uartp != NULL) && (n > 0) && (txbuf != NULL),
- "uartStartSendI");
- chDbgAssert(uartp->state == UART_READY,
- "uartStartSendI(), #1", "is active");
- chDbgAssert(uartp->txstate != UART_TX_ACTIVE,
- "uartStartSendI(), #2", "tx active");
+ osalDbgCheckClassI();
+ osalDbgCheck((uartp != NULL) && (n > 0) && (txbuf != NULL));
+ osalDbgAssert(uartp->state == UART_READY, "is active");
+ osalDbgAssert(uartp->txstate != UART_TX_ACTIVE, "tx active");
uart_lld_start_send(uartp, n, txbuf);
uartp->txstate = UART_TX_ACTIVE;
@@ -194,10 +187,10 @@ void uartStartSendI(UARTDriver *uartp, size_t n, const void *txbuf) {
size_t uartStopSend(UARTDriver *uartp) {
size_t n;
- chDbgCheck(uartp != NULL, "uartStopSend");
+ osalDbgCheck(uartp != NULL);
- chSysLock();
- chDbgAssert(uartp->state == UART_READY, "uartStopSend(), #1", "not active");
+ osalSysLock();
+ osalDbgAssert(uartp->state == UART_READY, "not active");
if (uartp->txstate == UART_TX_ACTIVE) {
n = uart_lld_stop_send(uartp);
@@ -205,7 +198,7 @@ size_t uartStopSend(UARTDriver *uartp) {
}
else
n = 0;
- chSysUnlock();
+ osalSysUnlock();
return n;
}
@@ -224,9 +217,9 @@ size_t uartStopSend(UARTDriver *uartp) {
*/
size_t uartStopSendI(UARTDriver *uartp) {
- chDbgCheckClassI();
- chDbgCheck(uartp != NULL, "uartStopSendI");
- chDbgAssert(uartp->state == UART_READY, "uartStopSendI(), #1", "not active");
+ osalDbgCheckClassI();
+ osalDbgCheck(uartp != NULL);
+ osalDbgAssert(uartp->state == UART_READY, "not active");
if (uartp->txstate == UART_TX_ACTIVE) {
size_t n = uart_lld_stop_send(uartp);
@@ -249,18 +242,15 @@ size_t uartStopSendI(UARTDriver *uartp) {
*/
void uartStartReceive(UARTDriver *uartp, size_t n, void *rxbuf) {
- chDbgCheck((uartp != NULL) && (n > 0) && (rxbuf != NULL),
- "uartStartReceive");
+ osalDbgCheck((uartp != NULL) && (n > 0) && (rxbuf != NULL));
- chSysLock();
- chDbgAssert(uartp->state == UART_READY,
- "uartStartReceive(), #1", "is active");
- chDbgAssert(uartp->rxstate != UART_RX_ACTIVE,
- "uartStartReceive(), #2", "rx active");
+ osalSysLock();
+ osalDbgAssert(uartp->state == UART_READY, "is active");
+ osalDbgAssert(uartp->rxstate != UART_RX_ACTIVE, "rx active");
uart_lld_start_receive(uartp, n, rxbuf);
uartp->rxstate = UART_RX_ACTIVE;
- chSysUnlock();
+ osalSysUnlock();
}
/**
@@ -277,13 +267,10 @@ void uartStartReceive(UARTDriver *uartp, size_t n, void *rxbuf) {
*/
void uartStartReceiveI(UARTDriver *uartp, size_t n, void *rxbuf) {
- chDbgCheckClassI();
- chDbgCheck((uartp != NULL) && (n > 0) && (rxbuf != NULL),
- "uartStartReceiveI");
- chDbgAssert(uartp->state == UART_READY,
- "uartStartReceiveI(), #1", "is active");
- chDbgAssert(uartp->rxstate != UART_RX_ACTIVE,
- "uartStartReceiveI(), #2", "rx active");
+ osalDbgCheckClassI();
+ osalDbgCheck((uartp != NULL) && (n > 0) && (rxbuf != NULL));
+ osalDbgAssert(uartp->state == UART_READY, "is active");
+ osalDbgAssert(uartp->rxstate != UART_RX_ACTIVE, "rx active");
uart_lld_start_receive(uartp, n, rxbuf);
uartp->rxstate = UART_RX_ACTIVE;
@@ -304,11 +291,10 @@ void uartStartReceiveI(UARTDriver *uartp, size_t n, void *rxbuf) {
size_t uartStopReceive(UARTDriver *uartp) {
size_t n;
- chDbgCheck(uartp != NULL, "uartStopReceive");
+ osalDbgCheck(uartp != NULL);
- chSysLock();
- chDbgAssert(uartp->state == UART_READY,
- "uartStopReceive(), #1", "not active");
+ osalSysLock();
+ osalDbgAssert(uartp->state == UART_READY, "not active");
if (uartp->rxstate == UART_RX_ACTIVE) {
n = uart_lld_stop_receive(uartp);
@@ -316,7 +302,7 @@ size_t uartStopReceive(UARTDriver *uartp) {
}
else
n = 0;
- chSysUnlock();
+ osalSysUnlock();
return n;
}
@@ -335,10 +321,9 @@ size_t uartStopReceive(UARTDriver *uartp) {
*/
size_t uartStopReceiveI(UARTDriver *uartp) {
- chDbgCheckClassI();
- chDbgCheck(uartp != NULL, "uartStopReceiveI");
- chDbgAssert(uartp->state == UART_READY,
- "uartStopReceiveI(), #1", "not active");
+ osalDbgCheckClassI();
+ osalDbgCheck(uartp != NULL);
+ osalDbgAssert(uartp->state == UART_READY, "not active");
if (uartp->rxstate == UART_RX_ACTIVE) {
size_t n = uart_lld_stop_receive(uartp);
diff --git a/os/hal/src/usb.c b/os/hal/src/usb.c
index b0a6390e7..9b292b7d9 100644
--- a/os/hal/src/usb.c
+++ b/os/hal/src/usb.c
@@ -28,9 +28,7 @@
#include <string.h>
-#include "ch.h"
#include "hal.h"
-#include "usb.h"
#if HAL_USE_USB || defined(__DOXYGEN__)
@@ -79,7 +77,7 @@ static void set_address(USBDriver *usbp) {
* @retval FALSE Request not recognized by the handler or error.
* @retval TRUE Request handled.
*/
-static bool_t default_handler(USBDriver *usbp) {
+static bool default_handler(USBDriver *usbp) {
const USBDescriptor *dp;
/* Decoding the request.*/
@@ -261,17 +259,17 @@ void usbObjectInit(USBDriver *usbp) {
void usbStart(USBDriver *usbp, const USBConfig *config) {
unsigned i;
- chDbgCheck((usbp != NULL) && (config != NULL), "usbStart");
+ osalDbgCheck((usbp != NULL) && (config != NULL));
- chSysLock();
- chDbgAssert((usbp->state == USB_STOP) || (usbp->state == USB_READY),
- "usbStart(), #1", "invalid state");
+ osalSysLock();
+ osalDbgAssert((usbp->state == USB_STOP) || (usbp->state == USB_READY),
+ "invalid state");
usbp->config = config;
for (i = 0; i <= USB_MAX_ENDPOINTS; i++)
usbp->epc[i] = NULL;
usb_lld_start(usbp);
usbp->state = USB_READY;
- chSysUnlock();
+ osalSysUnlock();
}
/**
@@ -283,15 +281,15 @@ void usbStart(USBDriver *usbp, const USBConfig *config) {
*/
void usbStop(USBDriver *usbp) {
- chDbgCheck(usbp != NULL, "usbStop");
+ osalDbgCheck(usbp != NULL);
- chSysLock();
- chDbgAssert((usbp->state == USB_STOP) || (usbp->state == USB_READY) ||
- (usbp->state == USB_SELECTED) || (usbp->state == USB_ACTIVE),
- "usbStop(), #1", "invalid state");
+ osalSysLock();
+ osalDbgAssert((usbp->state == USB_STOP) || (usbp->state == USB_READY) ||
+ (usbp->state == USB_SELECTED) || (usbp->state == USB_ACTIVE),
+ "invalid state");
usb_lld_stop(usbp);
usbp->state = USB_STOP;
- chSysUnlock();
+ osalSysUnlock();
}
/**
@@ -310,12 +308,11 @@ void usbStop(USBDriver *usbp) {
void usbInitEndpointI(USBDriver *usbp, usbep_t ep,
const USBEndpointConfig *epcp) {
- chDbgCheckClassI();
- chDbgCheck((usbp != NULL) && (epcp != NULL), "usbInitEndpointI");
- chDbgAssert(usbp->state == USB_ACTIVE,
- "usbEnableEndpointI(), #1", "invalid state");
- chDbgAssert(usbp->epc[ep] == NULL,
- "usbEnableEndpointI(), #2", "already initialized");
+ osalDbgCheckClassI();
+ osalDbgCheck((usbp != NULL) && (epcp != NULL));
+ osalDbgAssert(usbp->state == USB_ACTIVE,
+ "invalid state");
+ osalDbgAssert(usbp->epc[ep] == NULL, "already initialized");
/* Logically enabling the endpoint in the USBDriver structure.*/
if (epcp->in_state != NULL)
@@ -343,10 +340,9 @@ void usbInitEndpointI(USBDriver *usbp, usbep_t ep,
void usbDisableEndpointsI(USBDriver *usbp) {
unsigned i;
- chDbgCheckClassI();
- chDbgCheck(usbp != NULL, "usbDisableEndpointsI");
- chDbgAssert(usbp->state == USB_SELECTED,
- "usbDisableEndpointsI(), #1", "invalid state");
+ osalDbgCheckClassI();
+ osalDbgCheck(usbp != NULL);
+ osalDbgAssert(usbp->state == USB_SELECTED, "invalid state");
usbp->transmitting &= ~1;
usbp->receiving &= ~1;
@@ -424,7 +420,7 @@ void usbPrepareTransmit(USBDriver *usbp, usbep_t ep,
* @special
*/
void usbPrepareQueuedReceive(USBDriver *usbp, usbep_t ep,
- InputQueue *iqp, size_t n) {
+ input_queue_t *iqp, size_t n) {
USBOutEndpointState *osp = usbp->epc[ep]->out_state;
osp->rxqueued = TRUE;
@@ -450,7 +446,7 @@ void usbPrepareQueuedReceive(USBDriver *usbp, usbep_t ep,
* @special
*/
void usbPrepareQueuedTransmit(USBDriver *usbp, usbep_t ep,
- OutputQueue *oqp, size_t n) {
+ output_queue_t *oqp, size_t n) {
USBInEndpointState *isp = usbp->epc[ep]->in_state;
isp->txqueued = TRUE;
@@ -475,10 +471,10 @@ void usbPrepareQueuedTransmit(USBDriver *usbp, usbep_t ep,
*
* @iclass
*/
-bool_t usbStartReceiveI(USBDriver *usbp, usbep_t ep) {
+bool usbStartReceiveI(USBDriver *usbp, usbep_t ep) {
- chDbgCheckClassI();
- chDbgCheck(usbp != NULL, "usbStartReceiveI");
+ osalDbgCheckClassI();
+ osalDbgCheck(usbp != NULL);
if (usbGetReceiveStatusI(usbp, ep))
return TRUE;
@@ -502,10 +498,10 @@ bool_t usbStartReceiveI(USBDriver *usbp, usbep_t ep) {
*
* @iclass
*/
-bool_t usbStartTransmitI(USBDriver *usbp, usbep_t ep) {
+bool usbStartTransmitI(USBDriver *usbp, usbep_t ep) {
- chDbgCheckClassI();
- chDbgCheck(usbp != NULL, "usbStartTransmitI");
+ osalDbgCheckClassI();
+ osalDbgCheck(usbp != NULL);
if (usbGetTransmitStatusI(usbp, ep))
return TRUE;
@@ -527,10 +523,10 @@ bool_t usbStartTransmitI(USBDriver *usbp, usbep_t ep) {
*
* @iclass
*/
-bool_t usbStallReceiveI(USBDriver *usbp, usbep_t ep) {
+bool usbStallReceiveI(USBDriver *usbp, usbep_t ep) {
- chDbgCheckClassI();
- chDbgCheck(usbp != NULL, "usbStallReceiveI");
+ osalDbgCheckClassI();
+ osalDbgCheck(usbp != NULL);
if (usbGetReceiveStatusI(usbp, ep))
return TRUE;
@@ -551,10 +547,10 @@ bool_t usbStallReceiveI(USBDriver *usbp, usbep_t ep) {
*
* @iclass
*/
-bool_t usbStallTransmitI(USBDriver *usbp, usbep_t ep) {
+bool usbStallTransmitI(USBDriver *usbp, usbep_t ep) {
- chDbgCheckClassI();
- chDbgCheck(usbp != NULL, "usbStallTransmitI");
+ osalDbgCheckClassI();
+ osalDbgCheck(usbp != NULL);
if (usbGetTransmitStatusI(usbp, ep))
return TRUE;
@@ -646,9 +642,9 @@ void _usb_ep0setup(USBDriver *usbp, usbep_t ep) {
/* Starts the transmit phase.*/
usbp->ep0state = USB_EP0_TX;
usbPrepareTransmit(usbp, 0, usbp->ep0next, usbp->ep0n);
- chSysLockFromIsr();
+ osalSysLockFromISR();
usbStartTransmitI(usbp, 0);
- chSysUnlockFromIsr();
+ osalSysUnlockFromISR();
}
else {
/* No transmission phase, directly receiving the zero sized status
@@ -656,9 +652,9 @@ void _usb_ep0setup(USBDriver *usbp, usbep_t ep) {
usbp->ep0state = USB_EP0_WAITING_STS;
#if (USB_EP0_STATUS_STAGE == USB_EP0_STATUS_STAGE_SW)
usbPrepareReceive(usbp, 0, NULL, 0);
- chSysLockFromIsr();
+ osalSysLockFromISR();
usbStartReceiveI(usbp, 0);
- chSysUnlockFromIsr();
+ osalSysUnlockFromISR();
#else
usb_lld_end_setup(usbp, ep);
#endif
@@ -670,9 +666,9 @@ void _usb_ep0setup(USBDriver *usbp, usbep_t ep) {
/* Starts the receive phase.*/
usbp->ep0state = USB_EP0_RX;
usbPrepareReceive(usbp, 0, usbp->ep0next, usbp->ep0n);
- chSysLockFromIsr();
+ osalSysLockFromISR();
usbStartReceiveI(usbp, 0);
- chSysUnlockFromIsr();
+ osalSysUnlockFromISR();
}
else {
/* No receive phase, directly sending the zero sized status
@@ -680,9 +676,9 @@ void _usb_ep0setup(USBDriver *usbp, usbep_t ep) {
usbp->ep0state = USB_EP0_SENDING_STS;
#if (USB_EP0_STATUS_STAGE == USB_EP0_STATUS_STAGE_SW)
usbPrepareTransmit(usbp, 0, NULL, 0);
- chSysLockFromIsr();
+ osalSysLockFromISR();
usbStartTransmitI(usbp, 0);
- chSysUnlockFromIsr();
+ osalSysUnlockFromISR();
#else
usb_lld_end_setup(usbp, ep);
#endif
@@ -712,9 +708,9 @@ void _usb_ep0in(USBDriver *usbp, usbep_t ep) {
transmitted.*/
if ((usbp->ep0n < max) && ((usbp->ep0n % usbp->epc[0]->in_maxsize) == 0)) {
usbPrepareTransmit(usbp, 0, NULL, 0);
- chSysLockFromIsr();
+ osalSysLockFromISR();
usbStartTransmitI(usbp, 0);
- chSysUnlockFromIsr();
+ osalSysUnlockFromISR();
usbp->ep0state = USB_EP0_WAITING_TX0;
return;
}
@@ -724,9 +720,9 @@ void _usb_ep0in(USBDriver *usbp, usbep_t ep) {
usbp->ep0state = USB_EP0_WAITING_STS;
#if (USB_EP0_STATUS_STAGE == USB_EP0_STATUS_STAGE_SW)
usbPrepareReceive(usbp, 0, NULL, 0);
- chSysLockFromIsr();
+ osalSysLockFromISR();
usbStartReceiveI(usbp, 0);
- chSysUnlockFromIsr();
+ osalSysUnlockFromISR();
#else
usb_lld_end_setup(usbp, ep);
#endif
@@ -768,9 +764,9 @@ void _usb_ep0out(USBDriver *usbp, usbep_t ep) {
usbp->ep0state = USB_EP0_SENDING_STS;
#if (USB_EP0_STATUS_STAGE == USB_EP0_STATUS_STAGE_SW)
usbPrepareTransmit(usbp, 0, NULL, 0);
- chSysLockFromIsr();
+ osalSysLockFromISR();
usbStartTransmitI(usbp, 0);
- chSysUnlockFromIsr();
+ osalSysUnlockFromISR();
#else
usb_lld_end_setup(usbp, ep);
#endif