diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2014-08-31 14:24:12 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2014-08-31 14:24:12 +0000 |
commit | 87e4b85755680a122f690f445b8cb320ca4f05ad (patch) | |
tree | 7f214955a0eda60f7fae53af8557a683bd277ba0 /os/hal/src | |
parent | cb1f7893a41f24a46d0bc99198a3281dcea2148d (diff) | |
download | ChibiOS-87e4b85755680a122f690f445b8cb320ca4f05ad.tar.gz ChibiOS-87e4b85755680a122f690f445b8cb320ca4f05ad.tar.bz2 ChibiOS-87e4b85755680a122f690f445b8cb320ca4f05ad.zip |
Improvements to the ICU driver (not finished).
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@7210 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/src')
-rw-r--r-- | os/hal/src/icu.c | 77 |
1 files changed, 68 insertions, 9 deletions
diff --git a/os/hal/src/icu.c b/os/hal/src/icu.c index 0ef635edd..fcccab727 100644 --- a/os/hal/src/icu.c +++ b/os/hal/src/icu.c @@ -116,40 +116,99 @@ void icuStop(ICUDriver *icup) { }
/**
- * @brief Enables the input capture.
+ * @brief Starts the input capture.
*
* @param[in] icup pointer to the @p ICUDriver object
*
* @api
*/
-void icuEnable(ICUDriver *icup) {
+void icuStartCapture(ICUDriver *icup) {
osalDbgCheck(icup != NULL);
osalSysLock();
osalDbgAssert(icup->state == ICU_READY, "invalid state");
- icu_lld_enable(icup);
- icup->state = ICU_WAITING;
+ icuStartCaptureI(icup);
osalSysUnlock();
}
/**
- * @brief Disables the input capture.
+ * @brief Waits for the first cycle activation edge.
+ * @details The function waits for the next PWM input activation front then
+ * brings the driver in the @p ICU_ACTIVE state.
+ * @note If notifications are enabled then the transition to the
+ * @p ICU_ACTIVE state is done automatically on the first edge.
*
* @param[in] icup pointer to the @p ICUDriver object
*
* @api
*/
-void icuDisable(ICUDriver *icup) {
+void icuWaitCapture(ICUDriver *icup) {
+
+ osalDbgCheck(icup != NULL);
+
+ osalSysLock();
+ osalDbgAssert(icup->state == ICU_WAITING, "invalid state");
+ icuWaitCaptureI(icup);
+ osalSysUnlock();
+}
+
+/**
+ * @brief Stops the input capture.
+ *
+ * @param[in] icup pointer to the @p ICUDriver object
+ *
+ * @api
+ */
+void icuStopCapture(ICUDriver *icup) {
osalDbgCheck(icup != NULL);
osalSysLock();
osalDbgAssert((icup->state == ICU_READY) || (icup->state == ICU_WAITING) ||
- (icup->state == ICU_ACTIVE) || (icup->state == ICU_IDLE),
+ (icup->state == ICU_ACTIVE),
"invalid state");
- icu_lld_disable(icup);
- icup->state = ICU_READY;
+ icuStopCaptureI(icup);
+ osalSysUnlock();
+}
+
+/**
+ * @brief Enables notifications.
+ * @pre The ICU unit must have been activated using @p icuStart().
+ * @note If the notification is already enabled then the call has no effect.
+ *
+ * @param[in] icup pointer to the @p ICUDriver object
+ *
+ * @api
+ */
+void icuEnableNotifications(ICUDriver *icup) {
+
+ osalDbgCheck(icup != NULL);
+
+ osalSysLock();
+ osalDbgAssert((icup->state == ICU_WAITING) || (icup->state == ICU_ACTIVE),
+ "invalid state");
+ icuEnableNotificationsI(icup);
+ osalSysUnlock();
+}
+
+/**
+ * @brief Disables notifications.
+ * @pre The ICU unit must have been activated using @p icuStart().
+ * @note If the notification is already disabled then the call has no effect.
+ *
+ * @param[in] icup pointer to the @p ICUDriver object
+ *
+ * @api
+ */
+void icuDisableNotifications(ICUDriver *icup) {
+
+ osalDbgCheck(icup != NULL);
+
+ osalSysLock();
+ osalDbgAssert((icup->state == ICU_WAITING) || (icup->state == ICU_ACTIVE),
+ "invalid state");
+ icuDisableNotificationsI(icup);
osalSysUnlock();
}
|