summaryrefslogtreecommitdiff
path: root/cesar/hal/phy/maximus
diff options
context:
space:
mode:
authorburet2008-10-20 09:07:39 +0000
committerburet2008-10-20 09:07:39 +0000
commit630e7d8f1af37526109d2a7e5bb30986000a359f (patch)
tree7ff6f00d157faea8bc9239eb4124d97f908d9503 /cesar/hal/phy/maximus
parent871d7341b152463f89b6b8c2e5f3e942b6776a21 (diff)
[maximus] hal phy: cancel the access timer when entering into BUSY-RX state
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@3315 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/hal/phy/maximus')
-rw-r--r--cesar/hal/phy/maximus/src/maximus_phy_access.c8
-rw-r--r--cesar/hal/phy/maximus/src/maximus_phy_ctrl_cb.c3
-rw-r--r--cesar/hal/phy/maximus/test/src/test_phy_access.c67
3 files changed, 73 insertions, 5 deletions
diff --git a/cesar/hal/phy/maximus/src/maximus_phy_access.c b/cesar/hal/phy/maximus/src/maximus_phy_access.c
index 517a6e9698..1ca0e61984 100644
--- a/cesar/hal/phy/maximus/src/maximus_phy_access.c
+++ b/cesar/hal/phy/maximus/src/maximus_phy_access.c
@@ -596,11 +596,9 @@ void maximus_phy_access_timer_cb (void *data)
}
else
{
- if (MAXIMUS_PHY_MEDIUM_BUSY_RX != ctx->access.medium_state)
- {
- ctx->control.current_cb = ctx->control.access_cb;
- maximus_pending_isrs |= (1 << PHY_HAL_INTERRUPT_PHY);
- }
+ /* Access timer may have been cancelled when entering into BUSY-RX state. */
+ ctx->control.current_cb = ctx->control.access_cb;
+ maximus_pending_isrs |= (1 << PHY_HAL_INTERRUPT_PHY);
ctx->access.timer_program_netclock_id = 0;
}
diff --git a/cesar/hal/phy/maximus/src/maximus_phy_ctrl_cb.c b/cesar/hal/phy/maximus/src/maximus_phy_ctrl_cb.c
index 0e50d62d45..a295296ad0 100644
--- a/cesar/hal/phy/maximus/src/maximus_phy_ctrl_cb.c
+++ b/cesar/hal/phy/maximus/src/maximus_phy_ctrl_cb.c
@@ -103,6 +103,9 @@ maximus_phy_recv_preamble_cb (void *data)
maximus_phy_access_backoff_cancel(ctx);
maximus_phy_access_slot_count_reset(ctx);
+ // cancel the access timer when entering into BUSY-RX state
+ phy_access_timer_cancel(ctx);
+
// HW: timer value at last Preamble_found rising edge
ctx->control.rx_param.preamble_start_date = (u32)my_station.current_tick_tck;
}
diff --git a/cesar/hal/phy/maximus/test/src/test_phy_access.c b/cesar/hal/phy/maximus/test/src/test_phy_access.c
index 6aaae9bc4f..e0fb33faf0 100644
--- a/cesar/hal/phy/maximus/test/src/test_phy_access.c
+++ b/cesar/hal/phy/maximus/test/src/test_phy_access.c
@@ -18,6 +18,7 @@
#include "host/fwd.h" // for 'phy_msg_hdr_t'
#include "hal/phy/maximus/inc/maximus_phy_ctx.h"
#include "hal/phy/maximus/inc/maximus_phy_access.h"
+#include "hal/phy/maximus/inc/maximus_phy_ctrl.h" // for 'maximus_phy_recv_preamble_cb()'
#include "hal/phy/maximus/inc/maximus_interrupts.h"
#include "hal/phy/maximus/test/inc/test_phy_maximus.h"
#include "mac/common/timings.h" // for 'MAC_SLOT_TCK'
@@ -686,6 +687,72 @@ void phy_access_timer_program_test_case(test_t t)
netclock_msg_hdr_t *netclock_hdr;
int fd_in = -1;
+ // open pipe or socket
+ fd_in = maximus_phy_open(&my_station);
+
+ // read sci and netclock headers
+ memset(data, '\0', 256);
+ test_fail_unless ((-1 != fd_in)
+ && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
+ && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
+
+ // set netclock header pointer
+ netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
+
+ // check netclock tick value
+ test_fail_unless (date+1 == ntohl(netclock_hdr->tick_low));
+
+ // check netclock id for 'phy_access_timer_cancel'
+ test_fail_unless (ntohs(netclock_hdr->id) == ctx->access.timer_program_netclock_id);
+
+ // close pipe
+ maximus_phy_close(fd_in);
+ } test_end;
+
+ /* Test that access timer is cancelled when entering into BUSY-RX state. */
+ id = ctx->access.timer_program_netclock_id;
+ maximus_phy_recv_preamble_t data;
+ data.ctx = ctx;
+ data.wrong_preamble = false;
+ ctx->access.medium_state = MAXIMUS_PHY_MEDIUM_WAIT_CONF;
+ ctx->control.pre_detection = true;
+ maximus_phy_recv_preamble_cb (&data);
+
+ // check that the correct netclock message has been sent to Maximus
+ test_begin(t, "cancel netclock message")
+ {
+ unsigned char data[256];
+ netclock_msg_hdr_t *netclock_hdr;
+ int fd_in = -1;
+
+ // open pipe or socket
+ fd_in = maximus_phy_open(&my_station);
+
+ // read sci and netclock headers
+ memset(data, '\0', 256);
+ test_fail_unless ((-1 != fd_in)
+ && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
+ && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
+
+ // set netclock header pointer
+ netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
+
+ // check netclock id
+ test_fail_unless (ntohs(netclock_hdr->id) == id);
+
+ // close pipe
+ maximus_phy_close(fd_in);
+ } test_end;
+
+ phy_access_timer_program (ctx, date+1);
+
+ // check that the correct netclock message has been sent to Maximus
+ test_begin(t, "program netclock message")
+ {
+ unsigned char data[256];
+ netclock_msg_hdr_t *netclock_hdr;
+ int fd_in = -1;
+
netclock_callback_t reference, *found_callback;
set_node_t *found_node;