2009-11-29 08:50:13 +00:00
|
|
|
/*
|
2013-03-30 10:32:37 +00:00
|
|
|
ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
|
2009-11-29 08:50:13 +00:00
|
|
|
|
2013-03-30 10:32:37 +00:00
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
2009-11-29 08:50:13 +00:00
|
|
|
|
2013-03-30 10:32:37 +00:00
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
2009-11-29 08:50:13 +00:00
|
|
|
|
2013-03-30 10:32:37 +00:00
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
2009-11-29 08:50:13 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2010-02-06 16:17:30 +00:00
|
|
|
* @file xxx.c
|
|
|
|
* @brief XXX Driver code.
|
|
|
|
*
|
2009-11-29 08:50:13 +00:00
|
|
|
* @addtogroup XXX
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2009-12-07 16:13:01 +00:00
|
|
|
#include "ch.h"
|
|
|
|
#include "hal.h"
|
2009-11-29 08:50:13 +00:00
|
|
|
|
2010-11-01 17:29:56 +00:00
|
|
|
#if HAL_USE_XXX || defined(__DOXYGEN__)
|
2009-12-08 15:33:39 +00:00
|
|
|
|
2011-08-26 13:47:22 +00:00
|
|
|
/*===========================================================================*/
|
|
|
|
/* Driver local definitions. */
|
|
|
|
/*===========================================================================*/
|
|
|
|
|
2009-12-29 11:12:05 +00:00
|
|
|
/*===========================================================================*/
|
|
|
|
/* Driver exported variables. */
|
|
|
|
/*===========================================================================*/
|
|
|
|
|
2013-02-28 16:23:19 +00:00
|
|
|
/*===========================================================================*/
|
|
|
|
/* Driver local types. */
|
|
|
|
/*===========================================================================*/
|
|
|
|
|
2009-12-29 11:12:05 +00:00
|
|
|
/*===========================================================================*/
|
|
|
|
/* Driver local variables. */
|
|
|
|
/*===========================================================================*/
|
|
|
|
|
|
|
|
/*===========================================================================*/
|
|
|
|
/* Driver local functions. */
|
|
|
|
/*===========================================================================*/
|
|
|
|
|
|
|
|
/*===========================================================================*/
|
|
|
|
/* Driver exported functions. */
|
|
|
|
/*===========================================================================*/
|
|
|
|
|
2009-11-29 08:50:13 +00:00
|
|
|
/**
|
2010-02-06 16:17:30 +00:00
|
|
|
* @brief XXX Driver initialization.
|
2010-12-18 08:31:56 +00:00
|
|
|
* @note This function is implicitly invoked by @p halInit(), there is
|
|
|
|
* no need to explicitly initialize the driver.
|
2010-10-04 17:16:18 +00:00
|
|
|
*
|
|
|
|
* @init
|
2009-11-29 08:50:13 +00:00
|
|
|
*/
|
|
|
|
void xxxInit(void) {
|
|
|
|
|
|
|
|
xxx_lld_init();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-02-06 16:17:30 +00:00
|
|
|
* @brief Initializes the standard part of a @p XXXDriver structure.
|
2009-11-29 08:50:13 +00:00
|
|
|
*
|
2011-01-04 15:08:29 +00:00
|
|
|
* @param[out] xxxp pointer to the @p XXXDriver object
|
2010-10-04 17:16:18 +00:00
|
|
|
*
|
|
|
|
* @init
|
2009-11-29 08:50:13 +00:00
|
|
|
*/
|
|
|
|
void xxxObjectInit(XXXDriver *xxxp) {
|
|
|
|
|
2011-02-28 18:44:46 +00:00
|
|
|
xxxp->state = XXX_STOP;
|
|
|
|
xxxp->config = NULL;
|
2009-11-29 08:50:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-02-06 16:17:30 +00:00
|
|
|
* @brief Configures and activates the XXX peripheral.
|
2009-11-29 08:50:13 +00:00
|
|
|
*
|
|
|
|
* @param[in] xxxp pointer to the @p XXXDriver object
|
|
|
|
* @param[in] config pointer to the @p XXXConfig object
|
2010-10-04 17:16:18 +00:00
|
|
|
*
|
|
|
|
* @api
|
2009-11-29 08:50:13 +00:00
|
|
|
*/
|
|
|
|
void xxxStart(XXXDriver *xxxp, const XXXConfig *config) {
|
|
|
|
|
|
|
|
chDbgCheck((xxxp != NULL) && (config != NULL), "xxxStart");
|
|
|
|
|
|
|
|
chSysLock();
|
2011-02-28 18:44:46 +00:00
|
|
|
chDbgAssert((xxxp->state == XXX_STOP) || (xxxp->state == XXX_READY),
|
|
|
|
"xxxStart(), #1", "invalid state");
|
|
|
|
xxxp->config = config;
|
2009-11-29 08:50:13 +00:00
|
|
|
xxx_lld_start(xxxp);
|
2011-02-28 18:44:46 +00:00
|
|
|
xxxp->state = XXX_READY;
|
2009-11-29 08:50:13 +00:00
|
|
|
chSysUnlock();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-02-06 16:17:30 +00:00
|
|
|
* @brief Deactivates the XXX peripheral.
|
2009-11-29 08:50:13 +00:00
|
|
|
*
|
|
|
|
* @param[in] xxxp pointer to the @p XXXDriver object
|
2010-10-04 17:16:18 +00:00
|
|
|
*
|
|
|
|
* @api
|
2009-11-29 08:50:13 +00:00
|
|
|
*/
|
|
|
|
void xxxStop(XXXDriver *xxxp) {
|
|
|
|
|
|
|
|
chDbgCheck(xxxp != NULL, "xxxStop");
|
|
|
|
|
|
|
|
chSysLock();
|
2011-02-28 18:44:46 +00:00
|
|
|
chDbgAssert((xxxp->state == XXX_STOP) || (xxxp->state == XXX_READY),
|
|
|
|
"xxxStop(), #1", "invalid state");
|
2009-11-29 08:50:13 +00:00
|
|
|
xxx_lld_stop(xxxp);
|
2011-02-28 18:44:46 +00:00
|
|
|
xxxp->state = XXX_STOP;
|
2009-11-29 08:50:13 +00:00
|
|
|
chSysUnlock();
|
|
|
|
}
|
|
|
|
|
2010-11-01 17:29:56 +00:00
|
|
|
#endif /* HAL_USE_XXX */
|
2009-12-08 15:33:39 +00:00
|
|
|
|
2009-11-29 08:50:13 +00:00
|
|
|
/** @} */
|