diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2014-03-05 10:42:18 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2014-03-05 10:42:18 +0000 |
commit | bfd29a27c2c977de5b565e48012eb38e6541f15f (patch) | |
tree | b25e4548c948c83f2fe902209b52623bb1e8d4d7 /os/hal/src | |
parent | a6224d1964ef80a53500bde178d639c12dda98ee (diff) | |
download | ChibiOS-bfd29a27c2c977de5b565e48012eb38e6541f15f.tar.gz ChibiOS-bfd29a27c2c977de5b565e48012eb38e6541f15f.tar.bz2 ChibiOS-bfd29a27c2c977de5b565e48012eb38e6541f15f.zip |
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6755 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/src')
-rw-r--r-- | os/hal/src/dac.c | 42 |
1 files changed, 26 insertions, 16 deletions
diff --git a/os/hal/src/dac.c b/os/hal/src/dac.c index 92297e520..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. @@ -97,11 +97,14 @@ void dacStart(DACDriver *dacp, const DACConfig *config) { osalDbgCheck((dacp != NULL) && (config != NULL)); osalSysLock(); + osalDbgAssert((dacp->state == DAC_STOP) || (dacp->state == DAC_READY), - "invalid state"); + "invalid state"); + dacp->config = config; dac_lld_start(dacp); dacp->state = DAC_READY; + osalSysUnlock(); } @@ -119,10 +122,13 @@ void dacStop(DACDriver *dacp) { osalDbgCheck(dacp != NULL); osalSysLock(); + osalDbgAssert((dacp->state == DAC_STOP) || (dacp->state == DAC_READY), - "invalid state"); + "invalid state"); + dac_lld_stop(dacp); dacp->state = DAC_STOP; + osalSysUnlock(); } @@ -177,11 +183,11 @@ void dacStartConversionI(DACDriver *dacp, osalDbgCheckClassI(); osalDbgCheck((dacp != NULL) && (grpp != NULL) && (samples != NULL) && - ((depth == 1) || ((depth & 1) == 0))); + ((depth == 1) || ((depth & 1) == 0))); osalDbgAssert((dacp->state == DAC_READY) || - (dacp->state == DAC_COMPLETE) || - (dacp->state == DAC_ERROR), - "not ready"); + (dacp->state == DAC_COMPLETE) || + (dacp->state == DAC_ERROR), + "not ready"); dacp->samples = samples; dacp->depth = depth; @@ -205,15 +211,18 @@ void dacStopConversion(DACDriver *dacp) { osalDbgCheck(dacp != NULL); osalSysLock(); + osalDbgAssert((dacp->state == DAC_READY) || - (dacp->state == DAC_ACTIVE), - "invalid state"); + (dacp->state == DAC_ACTIVE), + "invalid state"); + if (dacp->state != DAC_READY) { dac_lld_stop_conversion(dacp); dacp->grpp = NULL; dacp->state = DAC_READY; _dac_reset_s(dacp); } + osalSysUnlock(); } @@ -232,9 +241,9 @@ void dacStopConversionI(DACDriver *dacp) { osalDbgCheckClassI(); osalDbgCheck(dacp != NULL); osalDbgAssert((dacp->state == DAC_READY) || - (dacp->state == DAC_ACTIVE) || - (dacp->state == DAC_COMPLETE), - "invalid state"); + (dacp->state == DAC_ACTIVE) || + (dacp->state == DAC_COMPLETE), + "invalid state"); if (dacp->state != DAC_READY) { dac_lld_stop_conversion(dacp); @@ -259,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 @@ -275,9 +284,10 @@ msg_t dacConvert(DACDriver *dacp, msg_t msg; osalSysLock(); - osalDbgAssert(dacp->thread == NULL, "already waiting"); + dacStartConversionI(dacp, grpp, samples, depth); msg = osalThreadSuspendS(&dacp->thread); + osalSysUnlock(); return msg; } |