summaryrefslogtreecommitdiff
path: root/cesar/hal/phy/src/access.c
diff options
context:
space:
mode:
Diffstat (limited to 'cesar/hal/phy/src/access.c')
-rw-r--r--cesar/hal/phy/src/access.c69
1 files changed, 69 insertions, 0 deletions
diff --git a/cesar/hal/phy/src/access.c b/cesar/hal/phy/src/access.c
new file mode 100644
index 0000000000..504e4c2436
--- /dev/null
+++ b/cesar/hal/phy/src/access.c
@@ -0,0 +1,69 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file hal/phy/src/access.c
+ * \brief HAL Phy ACCESS functions.
+ * \ingroup hal_phy
+ */
+#include "common/std.h"
+
+#include "inc/context.h"
+#include "inc/regs.h"
+
+void
+phy_access_backoff_start (phy_t *ctx, u32 date, uint cap)
+{
+ dbg_assert (ctx);
+ dbg_assert (cap < 4);
+ PHY_PRATIC_CSMA = BF_SHIFT (PHY_PRATIC_CSMA__MPDU_CAP, cap);
+ PHY_PRATIC_TIMER_3_DATE = date;
+ PHY_PRATIC_TIMER_3_CTRL = BF_SHIFT (PHY_PRATIC_TIMER_X_CTRL__ACTION,
+ PHY_PRATIC_ACTION__START_PRP)
+ | BF_MASK (PHY_PRATIC_TIMER_X_CTRL__VALID);
+}
+
+void
+phy_access_backoff_update (phy_t *ctx, uint cap)
+{
+ dbg_assert (ctx);
+ dbg_assert (cap < 4);
+ PHY_PRATIC_CSMA = BF_SHIFT (PHY_PRATIC_CSMA__MPDU_CAP, cap);
+}
+
+uint
+phy_access_backoff_slot_count (phy_t *ctx)
+{
+ dbg_assert (ctx);
+ return BF_GET (PHY_PRATIC_CSMA__NB_SLOTS, PHY_PRATIC_CSMA);
+}
+
+bool
+phy_access_backoff_prp_won (phy_t *ctx)
+{
+ dbg_assert (ctx);
+ // TODO.
+ return true;
+}
+
+void
+phy_access_timer_program (phy_t *ctx, u32 date)
+{
+ dbg_assert (ctx);
+ PHY_PRATIC_TIMER_1_DATE = date;
+ PHY_PRATIC_TIMER_1_CTRL = BF_SHIFT (PHY_PRATIC_TIMER_X_CTRL__ACTION,
+ PHY_PRATIC_ACTION__ACCESS)
+ | BF_MASK (PHY_PRATIC_TIMER_X_CTRL__VALID);
+}
+
+void
+phy_access_timer_cancel (phy_t *ctx)
+{
+ dbg_assert (ctx);
+ PHY_PRATIC_TIMER_1_CTRL = 0;
+}
+