summaryrefslogtreecommitdiff
path: root/cesar/hal/phy/src/pratic.c
diff options
context:
space:
mode:
Diffstat (limited to 'cesar/hal/phy/src/pratic.c')
-rw-r--r--cesar/hal/phy/src/pratic.c92
1 files changed, 92 insertions, 0 deletions
diff --git a/cesar/hal/phy/src/pratic.c b/cesar/hal/phy/src/pratic.c
new file mode 100644
index 0000000000..6510b3b334
--- /dev/null
+++ b/cesar/hal/phy/src/pratic.c
@@ -0,0 +1,92 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file hal/phy/src/pratic.c
+ * \brief HAL Phy PRATIC functions.
+ * \ingroup hal_phy
+ *
+ * PRATIC timers:
+ * - 1: ACCESS
+ * - 2: TX
+ * - 3: PRP
+ * - 4: RX ACTIVATE
+ * - 5: extra timer
+ *
+ * See also access.c.
+ */
+#include "common/std.h"
+
+#include "inc/context.h"
+#include "inc/regs.h"
+
+u32
+phy_date (phy_t *ctx)
+{
+ dbg_assert (ctx);
+ return PHY_PRATIC_STA_LOCAL_TIMER;
+}
+
+u32
+phy_sysdate (phy_t *ctx)
+{
+ dbg_assert (ctx);
+ return PHY_PRATIC_SYS_LOCAL_TIMER;
+}
+
+void
+phy_clock_set_numerator (phy_t *ctx, uint numerator)
+{
+ dbg_assert (ctx);
+ dbg_assert (BF_CHECK (PHY_PRATIC_CONFIG__DIVISION_FACTOR, numerator));
+ PHY_PRATIC_CONFIG =
+ (PHY_PRATIC_CONFIG & ~BF_MASK (PHY_PRATIC_CONFIG__DIVISION_FACTOR))
+ | BF_SHIFT (PHY_PRATIC_CONFIG__DIVISION_FACTOR, numerator);
+}
+
+u32
+phy_clock_get_zero_cross_captured_date (phy_t *ctx)
+{
+ dbg_assert (ctx);
+ return PHY_PRATIC_STA_LAST_CAPTURED_DATE;
+}
+
+u32
+phy_clock_get_zero_cross_captured_sysdate (phy_t *ctx)
+{
+ dbg_assert (ctx);
+ return PHY_PRATIC_STA_LAST_CAPTURED_DATE;
+}
+
+void
+phy_extra_timer_init (phy_t *ctx, void *extra_timer_user_data,
+ phy_extra_timer_cb_t extra_timer_cb)
+{
+ dbg_assert (ctx);
+ ctx->extra_timer_user_data = extra_timer_user_data;
+ ctx->extra_timer_cb = extra_timer_cb;
+}
+
+void
+phy_extra_timer_program (phy_t *ctx, u32 date)
+{
+ dbg_assert (ctx);
+ dbg_assert (!(PHY_PRATIC_TIMER_5_CTRL
+ & BF_MASK (PHY_PRATIC_TIMER_X_CTRL__VALID)));
+ PHY_PRATIC_TIMER_5_DATE = date;
+ PHY_PRATIC_TIMER_5_CTRL = BF_SHIFT (PHY_PRATIC_TIMER_X_CTRL__ACTION,
+ PHY_PRATIC_ACTION__INTERRUPT1)
+ | BF_MASK (PHY_PRATIC_TIMER_X_CTRL__VALID);
+}
+
+void
+phy_extra_timer_cancel (phy_t *ctx)
+{
+ dbg_assert (ctx);
+ PHY_PRATIC_TIMER_5_CTRL = 0;
+}
+