summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNélio Laranjeiro2013-05-23 09:45:22 +0200
committerNélio Laranjeiro2013-06-04 10:40:16 +0200
commit41d9a650fec2cbd2dc3c5753526f938db537f469 (patch)
tree5974425b0e91088a8ef442d65980f7e7740bcc8f
parentcf6021c88e1e4d54a1432bd4166af30e371fa26d (diff)
cesar/cp[av]: set CP_TIMER_OFFSET_STA to allow beacon reception, closes #3990
When there is not traffic on the medium, our CCo sends the central beacon 10ms after the beginning of the beacon period according with CA_ACCESS_MERGE_MARGIN_TCK margin.
-rw-r--r--cesar/cp/beacon/src/beacon.c11
-rw-r--r--cesar/cp/defs.h2
-rw-r--r--cesar/mac/ca/ca.h3
-rw-r--r--cesar/mac/ca/inc/access.h3
4 files changed, 15 insertions, 4 deletions
diff --git a/cesar/cp/beacon/src/beacon.c b/cesar/cp/beacon/src/beacon.c
index 1ecf0b015d..7b3ea86054 100644
--- a/cesar/cp/beacon/src/beacon.c
+++ b/cesar/cp/beacon/src/beacon.c
@@ -32,6 +32,7 @@
#include "hal/gpio/gpio.h"
#include "bsu/beacon/beacon.h"
#include "bsu/bsu.h"
+#include "mac/ca/ca.h"
/* Private headers. */
#include "cp/beacon/inc/beacon.h"
#include "cp/inc/context.h"
@@ -43,6 +44,16 @@
#define CP_BEACON_SPOC_UPDATE_INTERVAL_DEFAULT_MS \
CONFIG_BEACON_SPOC_UPDATE_INTERVAL_DEFAULT_MS
+/* In CSMA_ONLY mode, the beacon periods are always "merged", so this margin
+ * value is always applied and have for consequence to send the central beacon
+ * after this CA_ACCESS_MERGE_MARGIN_TCK.
+ * Knowing this, when the plug acts as a STA, it should program the timer
+ * after this delay plus the necessary time to receive and process the central
+ * beacon. This warning verifies those two values are compatible. */
+#if (CA_ACCESS_MERGE_MARGIN_TCK >= CP_TIMER_OFFSET_STA)
+# warning "CP_TIMER_OFFSET_STA too small"
+#endif
+
/** Timer expires.
* \param ctx the CP context.
*/
diff --git a/cesar/cp/defs.h b/cesar/cp/defs.h
index dde84d508e..3f02b7c123 100644
--- a/cesar/cp/defs.h
+++ b/cesar/cp/defs.h
@@ -150,7 +150,7 @@
/** Timer offset for beacon data update. */
#define CP_TIMER_OFFSET_CCO MAC_MS_TO_TCK(20)
-#define CP_TIMER_OFFSET_STA MAC_MS_TO_TCK(5)
+#define CP_TIMER_OFFSET_STA MAC_MS_TO_TCK(12)
/** Attenuation offset for SPC300 */
#define CP_AGC_SPC300_ATTENUATION_OFFSET 14
diff --git a/cesar/mac/ca/ca.h b/cesar/mac/ca/ca.h
index bd9e6f1166..ee8fbe40a1 100644
--- a/cesar/mac/ca/ca.h
+++ b/cesar/mac/ca/ca.h
@@ -63,6 +63,9 @@ typedef struct ca_t ca_t;
* stack space in ILRAM. */
#define CA_BEACON_PERIOD_NB 6
+/** Margin for merged allocations. */
+#define CA_ACCESS_MERGE_MARGIN_TCK MAC_US_TO_TCK (10000)
+
/** Beacon period entry. */
struct ca_beacon_period_t
{
diff --git a/cesar/mac/ca/inc/access.h b/cesar/mac/ca/inc/access.h
index 05e560efc0..b7ef87bcd0 100644
--- a/cesar/mac/ca/inc/access.h
+++ b/cesar/mac/ca/inc/access.h
@@ -13,9 +13,6 @@
* \ingroup mac_ca
*/
-/** Margin for merged allocations. */
-#define CA_ACCESS_MERGE_MARGIN_TCK MAC_US_TO_TCK (10000)
-
BEGIN_DECLS
/**