git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6755 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
a6224d1964
commit
bfd29a27c2
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010,
|
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.
|
This file is part of ChibiOS/RT.
|
||||||
|
|
||||||
|
@ -64,10 +64,6 @@
|
||||||
/* Derived constants and error checks. */
|
/* Derived constants and error checks. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
#if DAC_USE_MUTUAL_EXCLUSION && !CH_USE_MUTEXES && !CH_USE_SEMAPHORES && !NIL_USE_MUTEXES && !NIL_USE_SEMAPHORES
|
|
||||||
//#error "DAC_USE_MUTUAL_EXCLUSION requires CH_USE_MUTEXES and/or CH_USE_SEMAPHORES"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Driver data structures and types. */
|
/* Driver data structures and types. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
@ -118,7 +114,6 @@ typedef enum {
|
||||||
*/
|
*/
|
||||||
#define _dac_reset_i(dacp) osalThreadResumeI(&(dacp)->thread, MSG_RESET)
|
#define _dac_reset_i(dacp) osalThreadResumeI(&(dacp)->thread, MSG_RESET)
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Resumes a thread waiting for a conversion completion.
|
* @brief Resumes a thread waiting for a conversion completion.
|
||||||
*
|
*
|
||||||
|
@ -138,7 +133,7 @@ typedef enum {
|
||||||
#define _dac_wakeup_isr(dacp) { \
|
#define _dac_wakeup_isr(dacp) { \
|
||||||
osalSysLockFromISR(); \
|
osalSysLockFromISR(); \
|
||||||
osalThreadResumeI(&(dacp)->thread, MSG_OK); \
|
osalThreadResumeI(&(dacp)->thread, MSG_OK); \
|
||||||
osalSysUnlockFromISR(); \
|
osalSysUnlockFromISR(); \
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -151,7 +146,7 @@ typedef enum {
|
||||||
#define _dac_timeout_isr(dacp) { \
|
#define _dac_timeout_isr(dacp) { \
|
||||||
osalSysLockFromISR(); \
|
osalSysLockFromISR(); \
|
||||||
osalThreadResumeI(&(dacp)->thread, MSG_TIMEOUT); \
|
osalThreadResumeI(&(dacp)->thread, MSG_TIMEOUT); \
|
||||||
osalSysUnlockFromISR(); \
|
osalSysUnlockFromISR(); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#else /* !DAC_USE_WAIT */
|
#else /* !DAC_USE_WAIT */
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010,
|
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.
|
This file is part of ChibiOS/RT.
|
||||||
|
|
||||||
|
@ -97,11 +97,14 @@ void dacStart(DACDriver *dacp, const DACConfig *config) {
|
||||||
osalDbgCheck((dacp != NULL) && (config != NULL));
|
osalDbgCheck((dacp != NULL) && (config != NULL));
|
||||||
|
|
||||||
osalSysLock();
|
osalSysLock();
|
||||||
|
|
||||||
osalDbgAssert((dacp->state == DAC_STOP) || (dacp->state == DAC_READY),
|
osalDbgAssert((dacp->state == DAC_STOP) || (dacp->state == DAC_READY),
|
||||||
"invalid state");
|
"invalid state");
|
||||||
|
|
||||||
dacp->config = config;
|
dacp->config = config;
|
||||||
dac_lld_start(dacp);
|
dac_lld_start(dacp);
|
||||||
dacp->state = DAC_READY;
|
dacp->state = DAC_READY;
|
||||||
|
|
||||||
osalSysUnlock();
|
osalSysUnlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,10 +122,13 @@ void dacStop(DACDriver *dacp) {
|
||||||
osalDbgCheck(dacp != NULL);
|
osalDbgCheck(dacp != NULL);
|
||||||
|
|
||||||
osalSysLock();
|
osalSysLock();
|
||||||
|
|
||||||
osalDbgAssert((dacp->state == DAC_STOP) || (dacp->state == DAC_READY),
|
osalDbgAssert((dacp->state == DAC_STOP) || (dacp->state == DAC_READY),
|
||||||
"invalid state");
|
"invalid state");
|
||||||
|
|
||||||
dac_lld_stop(dacp);
|
dac_lld_stop(dacp);
|
||||||
dacp->state = DAC_STOP;
|
dacp->state = DAC_STOP;
|
||||||
|
|
||||||
osalSysUnlock();
|
osalSysUnlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,11 +183,11 @@ void dacStartConversionI(DACDriver *dacp,
|
||||||
|
|
||||||
osalDbgCheckClassI();
|
osalDbgCheckClassI();
|
||||||
osalDbgCheck((dacp != NULL) && (grpp != NULL) && (samples != NULL) &&
|
osalDbgCheck((dacp != NULL) && (grpp != NULL) && (samples != NULL) &&
|
||||||
((depth == 1) || ((depth & 1) == 0)));
|
((depth == 1) || ((depth & 1) == 0)));
|
||||||
osalDbgAssert((dacp->state == DAC_READY) ||
|
osalDbgAssert((dacp->state == DAC_READY) ||
|
||||||
(dacp->state == DAC_COMPLETE) ||
|
(dacp->state == DAC_COMPLETE) ||
|
||||||
(dacp->state == DAC_ERROR),
|
(dacp->state == DAC_ERROR),
|
||||||
"not ready");
|
"not ready");
|
||||||
|
|
||||||
dacp->samples = samples;
|
dacp->samples = samples;
|
||||||
dacp->depth = depth;
|
dacp->depth = depth;
|
||||||
|
@ -205,15 +211,18 @@ void dacStopConversion(DACDriver *dacp) {
|
||||||
osalDbgCheck(dacp != NULL);
|
osalDbgCheck(dacp != NULL);
|
||||||
|
|
||||||
osalSysLock();
|
osalSysLock();
|
||||||
|
|
||||||
osalDbgAssert((dacp->state == DAC_READY) ||
|
osalDbgAssert((dacp->state == DAC_READY) ||
|
||||||
(dacp->state == DAC_ACTIVE),
|
(dacp->state == DAC_ACTIVE),
|
||||||
"invalid state");
|
"invalid state");
|
||||||
|
|
||||||
if (dacp->state != DAC_READY) {
|
if (dacp->state != DAC_READY) {
|
||||||
dac_lld_stop_conversion(dacp);
|
dac_lld_stop_conversion(dacp);
|
||||||
dacp->grpp = NULL;
|
dacp->grpp = NULL;
|
||||||
dacp->state = DAC_READY;
|
dacp->state = DAC_READY;
|
||||||
_dac_reset_s(dacp);
|
_dac_reset_s(dacp);
|
||||||
}
|
}
|
||||||
|
|
||||||
osalSysUnlock();
|
osalSysUnlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -232,9 +241,9 @@ void dacStopConversionI(DACDriver *dacp) {
|
||||||
osalDbgCheckClassI();
|
osalDbgCheckClassI();
|
||||||
osalDbgCheck(dacp != NULL);
|
osalDbgCheck(dacp != NULL);
|
||||||
osalDbgAssert((dacp->state == DAC_READY) ||
|
osalDbgAssert((dacp->state == DAC_READY) ||
|
||||||
(dacp->state == DAC_ACTIVE) ||
|
(dacp->state == DAC_ACTIVE) ||
|
||||||
(dacp->state == DAC_COMPLETE),
|
(dacp->state == DAC_COMPLETE),
|
||||||
"invalid state");
|
"invalid state");
|
||||||
|
|
||||||
if (dacp->state != DAC_READY) {
|
if (dacp->state != DAC_READY) {
|
||||||
dac_lld_stop_conversion(dacp);
|
dac_lld_stop_conversion(dacp);
|
||||||
|
@ -259,11 +268,11 @@ void dacStopConversionI(DACDriver *dacp) {
|
||||||
* @param[in] depth buffer depth (matrix rows number). The buffer depth
|
* @param[in] depth buffer depth (matrix rows number). The buffer depth
|
||||||
* must be one or an even number.
|
* must be one or an even number.
|
||||||
* @return The operation result.
|
* @return The operation result.
|
||||||
* @retval RDY_OK Conversion finished.
|
* @retval MSG_OK Conversion finished.
|
||||||
* @retval RDY_RESET The conversion has been stopped using
|
* @retval MSG_RESET The conversion has been stopped using
|
||||||
* @p acdStopConversion() or @p acdStopConversionI(),
|
* @p acdStopConversion() or @p acdStopConversionI(),
|
||||||
* the result buffer may contain incorrect data.
|
* 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.
|
* error.
|
||||||
*
|
*
|
||||||
* @api
|
* @api
|
||||||
|
@ -275,9 +284,10 @@ msg_t dacConvert(DACDriver *dacp,
|
||||||
msg_t msg;
|
msg_t msg;
|
||||||
|
|
||||||
osalSysLock();
|
osalSysLock();
|
||||||
osalDbgAssert(dacp->thread == NULL, "already waiting");
|
|
||||||
dacStartConversionI(dacp, grpp, samples, depth);
|
dacStartConversionI(dacp, grpp, samples, depth);
|
||||||
msg = osalThreadSuspendS(&dacp->thread);
|
msg = osalThreadSuspendS(&dacp->thread);
|
||||||
|
|
||||||
osalSysUnlock();
|
osalSysUnlock();
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue