More enhancements to the GPT driver.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6759 35acf78f-673a-0410-8e92-d51de3d6d3f4
master
gdisirio 2014-03-08 10:19:32 +00:00
parent f40d33139e
commit 6bc9f636b5
3 changed files with 54 additions and 11 deletions

View File

@ -79,9 +79,7 @@ typedef void (*gptcallback_t)(GPTDriver *gptp);
/** /**
* @brief Changes the interval of GPT peripheral. * @brief Changes the interval of GPT peripheral.
* @details This function changes the interval of a running GPT unit. * @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 be running in continuous mode.
* @pre The GPT unit must have been running in continuous mode using
* @p gptStartContinuous().
* @post The GPT unit interval is changed to the new value. * @post The GPT unit interval is changed to the new value.
* *
* @param[in] gptp pointer to a @p GPTDriver object * @param[in] gptp pointer to a @p GPTDriver object
@ -89,10 +87,34 @@ typedef void (*gptcallback_t)(GPTDriver *gptp);
* *
* @iclass * @iclass
*/ */
#define gptChangeIntervalI(gptp, interval) { \ #define gptChangeIntervalI(gptp, interval) { \
gpt_lld_change_interval(gptp, interval); \ gpt_lld_change_interval(gptp, interval); \
} }
/**
* @brief Returns the interval of GPT peripheral.
* @pre The GPT unit must be running in continuous mode.
*
* @param[in] gptp pointer to a @p GPTDriver object
* @return The current interval.
*
* @xclass
*/
#define gptGetIntervalX(gptp) gpt_lld_get_interval(gptp)
/**
* @brief Returns the counter value of GPT peripheral.
* @pre The GPT unit must be running in continuous mode.
* @note The nature of the counter is not defined, it may count upward
* or downward, it could be continuously running or not.
*
* @param[in] gptp pointer to a @p GPTDriver object
* @return The current counter value.
*
* @xclass
*/
#define gptGetCounterX(gptp) gpt_lld_get_counter(gptp)
/*===========================================================================*/ /*===========================================================================*/
/* External declarations. */ /* External declarations. */
/*===========================================================================*/ /*===========================================================================*/

View File

@ -432,19 +432,42 @@ struct GPTDriver {
/** /**
* @brief Changes the interval of GPT peripheral. * @brief Changes the interval of GPT peripheral.
* @details This function changes the interval of a running GPT unit. * @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 be running in continuous mode.
* @pre The GPT unit must have been running in continuous mode using
* @p gptStartContinuous().
* @post The GPT unit interval is changed to the new value. * @post The GPT unit interval is changed to the new value.
* @note The function has effect at the next cycle start. * @note The function has effect at the next cycle start.
* *
* @param[in] gptp pointer to a @p GPTDriver object * @param[in] gptp pointer to a @p GPTDriver object
* @param[in] interval new cycle time in timer ticks * @param[in] interval new cycle time in timer ticks
*
* @notapi * @notapi
*/ */
#define gpt_lld_change_interval(gptp, interval) \ #define gpt_lld_change_interval(gptp, interval) \
((gptp)->tim->ARR = (uint32_t)((interval) - 1)) ((gptp)->tim->ARR = (uint32_t)((interval) - 1))
/**
* @brief Returns the interval of GPT peripheral.
* @pre The GPT unit must be running in continuous mode.
*
* @param[in] gptp pointer to a @p GPTDriver object
* @return The current interval.
*
* @notapi
*/
#define gpt_lld_get_interval(gptp) ((gptcnt_t)(gptp)->tim->ARR + 1)
/**
* @brief Returns the counter value of GPT peripheral.
* @pre The GPT unit must be running in continuous mode.
* @note The nature of the counter is not defined, it may count upward
* or downward, it could be continuously running or not.
*
* @param[in] gptp pointer to a @p GPTDriver object
* @return The current counter value.
*
* @notapi
*/
#define gpt_lld_get_counter(gptp) ((gptcnt_t)(gptp)->tim->CNT)
/*===========================================================================*/ /*===========================================================================*/
/* External declarations. */ /* External declarations. */
/*===========================================================================*/ /*===========================================================================*/

View File

@ -118,9 +118,7 @@ void gptStop(GPTDriver *gptp) {
/** /**
* @brief Changes the interval of GPT peripheral. * @brief Changes the interval of GPT peripheral.
* @details This function changes the interval of a running GPT unit. * @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 be running in continuous mode.
* @pre The GPT unit must have been running in continuous mode using
* @p gptStartContinuous().
* @post The GPT unit interval is changed to the new value. * @post The GPT unit interval is changed to the new value.
* *
* @param[in] gptp pointer to a @p GPTDriver object * @param[in] gptp pointer to a @p GPTDriver object