aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal
diff options
context:
space:
mode:
Diffstat (limited to 'os/hal')
-rw-r--r--os/hal/ports/AVR/MEGA/LLD/TIMv1/hal_icu_lld.c13
-rw-r--r--os/hal/ports/AVR/MEGA/LLD/TIMv1/hal_icu_lld.h47
2 files changed, 52 insertions, 8 deletions
diff --git a/os/hal/ports/AVR/MEGA/LLD/TIMv1/hal_icu_lld.c b/os/hal/ports/AVR/MEGA/LLD/TIMv1/hal_icu_lld.c
index 2f7000a58..bb540f8e0 100644
--- a/os/hal/ports/AVR/MEGA/LLD/TIMv1/hal_icu_lld.c
+++ b/os/hal/ports/AVR/MEGA/LLD/TIMv1/hal_icu_lld.c
@@ -112,7 +112,7 @@ static inline void handle_capture_isr(ICUDriver *icup,
}
}
-static uint8_t index(ICUDriver *icup) {
+static uint8_t tmrIndex(ICUDriver *icup) {
uint8_t index = 0;
#if AVR_ICU_USE_TIM1 || defined(__DOXYGEN__)
@@ -131,6 +131,7 @@ static uint8_t index(ICUDriver *icup) {
if (icup == &ICUD5) return index;
else index++;
#endif
+ return 255;
}
/*===========================================================================*/
@@ -236,7 +237,7 @@ void icu_lld_init(void) {
void icu_lld_start(ICUDriver *icup) {
if (icup->state == ICU_STOP) {
- uint8_t i = index(icup);
+ uint8_t i = tmrIndex(icup);
/* Normal waveform generation (counts from 0 to 0xFFFF) */
*regs_table[i].tccra &= ~((1 << WGM11) | (1 << WGM10));
*regs_table[i].tccrb &= ~((1 << WGM13) | (1 << WGM12));
@@ -277,9 +278,9 @@ void icu_lld_stop(ICUDriver *icup) {
*
* @notapi
*/
-void icu_lld_enable(ICUDriver *icup) {
+void icu_lld_start_capture(ICUDriver *icup) {
- uint8_t i = index(icup);
+ uint8_t i = tmrIndex(icup);
icup->width = icup->period = 0;
*regs_table[i].tcnt = 0;
*regs_table[i].timsk |= (1 << ICIE1);
@@ -294,9 +295,9 @@ void icu_lld_enable(ICUDriver *icup) {
*
* @notapi
*/
-void icu_lld_disable(ICUDriver *icup) {
+void icu_lld_stop_capture(ICUDriver *icup) {
- uint8_t i = index(icup);
+ uint8_t i = tmrIndex(icup);
*regs_table[i].timsk &= ~((1 << ICIE1) | (1 << TOIE1));
}
diff --git a/os/hal/ports/AVR/MEGA/LLD/TIMv1/hal_icu_lld.h b/os/hal/ports/AVR/MEGA/LLD/TIMv1/hal_icu_lld.h
index 078fbb86d..589df04b1 100644
--- a/os/hal/ports/AVR/MEGA/LLD/TIMv1/hal_icu_lld.h
+++ b/os/hal/ports/AVR/MEGA/LLD/TIMv1/hal_icu_lld.h
@@ -157,6 +157,45 @@ struct ICUDriver {
/* Driver macros. */
/*===========================================================================*/
+
+/**
+ * @brief Returns the width of the latest pulse.
+ * @details The pulse width is defined as number of ticks between the start
+ * edge and the stop edge.
+ *
+ * @param[in] icup pointer to the @p ICUDriver object
+ * @return The number of ticks.
+ *
+ * @notapi
+ */
+/* #define icu_lld_get_width(icup) 1 */
+
+/**
+ * @brief Returns the width of the latest cycle.
+ * @details The cycle width is defined as number of ticks between a start
+ * edge and the next start edge.
+ *
+ * @param[in] icup pointer to the @p ICUDriver object
+ * @return The number of ticks.
+ *
+ * @notapi
+ */
+/* #define icu_lld_get_period(icup) 1 */
+
+/**
+ * @brief Check on notifications status.
+ *
+ * @param[in] icup pointer to the @p ICUDriver object
+ * @return The notifications status.
+ * @retval false if notifications are not enabled.
+ * @retval true if notifications are enabled.
+ *
+ * @notapi
+ */
+/* TODO: The following macros must be implement. */
+#define icu_lld_are_notifications_enabled(icup) \
+ (bool)(FALSE)
+
/*===========================================================================*/
/* External declarations. */
/*===========================================================================*/
@@ -177,11 +216,15 @@ extern ICUDriver ICUD5;
#ifdef __cplusplus
extern "C" {
#endif
+
void icu_lld_init(void);
void icu_lld_start(ICUDriver *icup);
void icu_lld_stop(ICUDriver *icup);
- void icu_lld_enable(ICUDriver *icup);
- void icu_lld_disable(ICUDriver *icup);
+ void icu_lld_start_capture(ICUDriver *icup);
+ void icu_lld_stop_capture(ICUDriver *icup);
+ bool icu_lld_wait_capture(ICUDriver *icup); /* TODO: Implement. */
+ void icu_lld_enable_notifications(ICUDriver *icup); /* TODO: Implement. */
+ void icu_lld_disable_notifications(ICUDriver *icup); /* TODO: Implement. */
icucnt_t icu_lld_get_width(ICUDriver *icup);
icucnt_t icu_lld_get_period(ICUDriver *icup);
#ifdef __cplusplus