aboutsummaryrefslogtreecommitdiffstats
path: root/os
diff options
context:
space:
mode:
Diffstat (limited to 'os')
-rw-r--r--os/hal/include/gpt.h32
-rw-r--r--os/hal/ports/STM32/LLD/TIMv1/gpt_lld.h29
-rw-r--r--os/hal/src/gpt.c4
3 files changed, 54 insertions, 11 deletions
diff --git a/os/hal/include/gpt.h b/os/hal/include/gpt.h
index 3b474cb14..a900243ba 100644
--- a/os/hal/include/gpt.h
+++ b/os/hal/include/gpt.h
@@ -79,9 +79,7 @@ typedef void (*gptcallback_t)(GPTDriver *gptp);
/**
* @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
@@ -89,10 +87,34 @@ typedef void (*gptcallback_t)(GPTDriver *gptp);
*
* @iclass
*/
-#define gptChangeIntervalI(gptp, interval) { \
- gpt_lld_change_interval(gptp, interval); \
+#define gptChangeIntervalI(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. */
/*===========================================================================*/
diff --git a/os/hal/ports/STM32/LLD/TIMv1/gpt_lld.h b/os/hal/ports/STM32/LLD/TIMv1/gpt_lld.h
index 4a914133e..9f0b16980 100644
--- a/os/hal/ports/STM32/LLD/TIMv1/gpt_lld.h
+++ b/os/hal/ports/STM32/LLD/TIMv1/gpt_lld.h
@@ -432,19 +432,42 @@ struct GPTDriver {
/**
* @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.
* @note The function has effect at the next cycle start.
*
* @param[in] gptp pointer to a @p GPTDriver object
* @param[in] interval new cycle time in timer ticks
+ *
* @notapi
*/
#define gpt_lld_change_interval(gptp, interval) \
((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. */
/*===========================================================================*/
diff --git a/os/hal/src/gpt.c b/os/hal/src/gpt.c
index 780ac407e..d654a3c4a 100644
--- a/os/hal/src/gpt.c
+++ b/os/hal/src/gpt.c
@@ -118,9 +118,7 @@ void gptStop(GPTDriver *gptp) {
/**
* @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