summaryrefslogtreecommitdiff
path: root/cesar/cp/beacon/src/beacon.c
diff options
context:
space:
mode:
authorNélio Laranjeiro2010-12-01 17:13:52 +0100
committerNélio Laranjeiro2011-01-11 15:38:35 +0100
commit224594457d46d928d94ee26990a510db3e301f9e (patch)
treea4e8b8daf7271f97dd91163da515da0ddd1ca8cd /cesar/cp/beacon/src/beacon.c
parent914df2a99b98f55c244f84c2583a9a2c6f66ef29 (diff)
cesar/cp/beacon: remove shared memory to update beacon to BSU, closes #2126
Diffstat (limited to 'cesar/cp/beacon/src/beacon.c')
-rw-r--r--cesar/cp/beacon/src/beacon.c52
1 files changed, 17 insertions, 35 deletions
diff --git a/cesar/cp/beacon/src/beacon.c b/cesar/cp/beacon/src/beacon.c
index d8cca0da67..836c14323b 100644
--- a/cesar/cp/beacon/src/beacon.c
+++ b/cesar/cp/beacon/src/beacon.c
@@ -54,23 +54,6 @@ cp_beacon_timer_expires (cp_t *ctx)
}
/**
- * Get the next beacon shared memory to update.
- * \param ctx the control plane context.
- * \return a pointer on the next slot.
- */
-static bsu_beacon_t *
-cp_get_next_beacon_shared_memory (cp_t *ctx)
-{
- bsu_beacon_t *next_beacon_shared_memory =
- &ctx->beacon.shared_mem[ctx->beacon.shared_mem_slot_id];
-
- ctx->beacon.shared_mem_slot_id++;
- ctx->beacon.shared_mem_slot_id %= CP_SHARED_MEM_SLOT_NB;
-
- return next_beacon_shared_memory;
-}
-
-/**
* Fill the discover info beacon entry.
* \param ctx the module context.
* \param beacon the beacon to fill.
@@ -114,15 +97,12 @@ cp_beacon_clk_sync_call_spoc (cp_t *ctx, u32 fe)
pbproc_spoc_coeff_set (ctx->pbproc, coeff);
}
-bsu_beacon_t *
-cp_beacon_fill_share_memory (cp_t *ctx)
+void
+cp_beacon_fill (cp_t *ctx, bsu_beacon_t *beacon)
{
- bsu_beacon_t *beacon;
cp_sta_own_data_t *sta;
cp_net_t *net = NULL;
uint nb, ns;
-
- beacon = cp_get_next_beacon_shared_memory (ctx);
dbg_assert (beacon);
beacon->beacon_period_start_date =
bsu_aclf_beacon_period_start_date_next (ctx->bsu_aclf);
@@ -271,8 +251,6 @@ cp_beacon_fill_share_memory (cp_t *ctx)
beacon->bmis.aclsc.present = false;
beacon->bmis.cns.present = false;
beacon->bmis.mac_address_present.present = true;
-
- return beacon;
}
/**
@@ -574,8 +552,6 @@ cp_beacon_init (cp_t *ctx)
hal_timer_instance_init (ctx->hal_timer, &ctx->beacon.leon_timer,
ctx,
(hal_timer_instance_cb_t)cp_beacon_timer_expires);
- // Initialise the mem_share_slot_id so that the next slot is 0.
- ctx->beacon.shared_mem_slot_id = CP_SHARED_MEM_SLOT_NB - 1;
/* Setup beacon indicator. */
GPIO_SETUP (LED_BEACON_TX_RX, GPIO_DIRECTION_OUT);
GPIO_SET (LED_BEACON_TX_RX, 0);
@@ -602,16 +578,21 @@ cp_beacon_uninit (cp_t *ctx)
hal_timer_instance_uninit (ctx->hal_timer, &ctx->beacon.leon_timer);
}
-static bsu_beacon_t*
-cp_beacon_update_beacon_data (cp_t *ctx, bool cco)
+/**
+ * Prepare the beacon and reconfigure the timer of the beacon module.
+ * \param ctx the module context.
+ * \param beacon the bsu_beacon_t structure to fill.
+ * \param cco the cco status.
+ */
+static void
+cp_beacon_update_beacon_data (cp_t *ctx, bsu_beacon_t *beacon, bool cco)
{
cp_beacon_countdowns (ctx);
/** Generate the beacon and send. */
- bsu_beacon_t *beacon = cp_beacon_fill_share_memory (ctx);
+ cp_beacon_fill (ctx, beacon);
/** Program the timer to awake and send another central beacon. */
cp_beacon_reconfigure_timer (ctx, cco);
GPIO_TOGGLE (LED_BEACON_TX_RX);
- return beacon;
}
void
@@ -626,21 +607,22 @@ cp_beacon_sta_update_beacon_data (cp_t *ctx)
void
cp_beacon_cco_update_beacon_data (cp_t *ctx)
{
+ bsu_beacon_t beacon;
dbg_assert (ctx);
- bsu_beacon_t *beacon = cp_beacon_update_beacon_data (ctx, true);
- bsu_update (beacon, BSU_UPDATE_STA_TYPE_CCO);
+ cp_beacon_update_beacon_data (ctx, &beacon, true);
+ bsu_update (&beacon, BSU_UPDATE_STA_TYPE_CCO);
}
void
cp_beacon_poweron_init (cp_t *ctx)
{
+ bsu_beacon_t beacon;
dbg_assert (ctx);
ctx->beacon.countdown_limit_date =
ctx->beacon.last_countdown_date = phy_date ();
/* Generate the beacon and send. */
- bsu_beacon_t *beacon = cp_beacon_fill_share_memory (ctx);
- bsu_update (beacon, BSU_UPDATE_STA_TYPE_STA);
-
+ cp_beacon_fill (ctx, &beacon);
+ bsu_update (&beacon, BSU_UPDATE_STA_TYPE_STA);
GPIO_TOGGLE (LED_BEACON_TX_RX);
}