summaryrefslogtreecommitdiff
path: root/cesar/hal/phy/src/tx.c
diff options
context:
space:
mode:
Diffstat (limited to 'cesar/hal/phy/src/tx.c')
-rw-r--r--cesar/hal/phy/src/tx.c91
1 files changed, 91 insertions, 0 deletions
diff --git a/cesar/hal/phy/src/tx.c b/cesar/hal/phy/src/tx.c
new file mode 100644
index 0000000000..7d35887b5f
--- /dev/null
+++ b/cesar/hal/phy/src/tx.c
@@ -0,0 +1,91 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file hal/phy/src/tx.c
+ * \brief HAL Phy TX functions.
+ * \ingroup hal_phy
+ */
+#include "common/std.h"
+
+#include "inc/context.h"
+#include "inc/regs.h"
+
+void
+phy_tx_fc10 (phy_t *ctx, u32 fc_10)
+{
+ dbg_assert (ctx);
+ dbg_assert (BF_CHECK (PHY_DSPSS_TX_FC_10__FC, fc_10));
+ PHY_DSPSS_TX_FC_10 = BF_SHIFT (PHY_DSPSS_TX_FC_10__FC, fc_10)
+ | BF_MASK (PHY_DSPSS_TX_FC_10__CRC);
+ PHY_PRATIC_IMMEDIATE_ACTION = PHY_PRATIC_ACTION__CREATE_FC_10;
+}
+
+void
+phy_tx_param (phy_t *ctx, phy_fc_mode_t fc_mode, bool short_ppdu,
+ phy_mod_t mod, phy_fecrate_t fecrate, phy_pb_size_t pb_size,
+ phy_gil_t gil, uint tonemap_index)
+{
+ dbg_assert (ctx);
+ dbg_assert (fc_mode < PHY_FC_MODE_NB
+ && ((short_ppdu == false
+ && mod < PHY_MOD_NONE
+ && fecrate < PHY_FEC_RATE_NONE
+ && pb_size < PHY_PB_SIZE_NONE
+ && gil < PHY_GIL_NB
+ && BF_CHECK (PHY_DSPSS_TX_PARAM__TMBI, tonemap_index))
+ || short_ppdu == true));
+ if (short_ppdu)
+ {
+ PHY_DSPSS_TX_PARAM =
+ BF_FILL (PHY_DSPSS_TX_PARAM,
+ (FC_MODE, fc_mode),
+ (SHORT_PPDU, 1))
+ | PHY_DSPSS_TX_PARAM__DEFAULT;
+ }
+ else
+ {
+ PHY_DSPSS_TX_PARAM =
+ BF_FILL (PHY_DSPSS_TX_PARAM,
+ (PB_SIZE, pb_size),
+ (PB_RATE, fecrate),
+ (PB_MOD, mod),
+ (FC_MODE, fc_mode),
+ (SHORT_PPDU, 0),
+ (TMBI, tonemap_index))
+ | PHY_DSPSS_TX_PARAM__DEFAULT;
+ static const uint gil_durations_table[] = {
+ PHY_DSPSS_TX_GUARD_TABLE__VALUE_417,
+ PHY_DSPSS_TX_GUARD_TABLE__VALUE_567,
+ PHY_DSPSS_TX_GUARD_TABLE__VALUE_3534,
+ };
+ PHY_DSPSS_TX_GUARD_TABLE =
+ BF_FILL (PHY_DSPSS_TX_GUARD_TABLE,
+ (INDEX, 2),
+ (VALUE, gil_durations_table[gil]));
+ }
+}
+
+void
+phy_tx_frame (phy_t *ctx, u32 date, bool want_conf, bool stop_tx_on_prp_lost,
+ const u32 fc_av[4])
+{
+ dbg_assert (ctx);
+ dbg_assert (fc_av);
+ /* Set FC. */
+ PHY_DSPSS_TX_FC_AV_0 = fc_av[0];
+ PHY_DSPSS_TX_FC_AV_1 = fc_av[1];
+ PHY_DSPSS_TX_FC_AV_2 = fc_av[2];
+ PHY_DSPSS_TX_FC_AV_3 = fc_av[3];
+ /* TODO: want_conf, stop_tx_on_prp_lost. */
+ /* Program TX. */
+ PHY_PRATIC_TIMER_2_DATE = date;
+ PHY_PRATIC_TIMER_2_CTRL = BF_SHIFT (PHY_PRATIC_TIMER_X_CTRL__ACTION,
+ PHY_PRATIC_ACTION__START_TX)
+ | BF_MASK (PHY_PRATIC_TIMER_X_CTRL__VALID);
+}
+