3, the interrupt will happen whjen TCNT0 is 4) */
uint8_t interrupt_in = 1 + call Compare.get() - call Timer.get();
uint8_t newOcr0;
-
- if (interrupt_in < MINDT || (call TimerCtrl.getInterruptFlag()).bits.ocf0)
+ uint8_t tifr = (uint8_t)((call TimerCtrl.getInterruptFlag()).flat);
+ dbg("Atm128AlarmAsyncP", "Atm128AlarmAsyncP: TIFR is %hhx\n", tifr);
+ if ((interrupt_in != 0 && interrupt_in < MINDT) || (tifr & (1 << OCF0))) {
+ if (interrupt_in < MINDT) {
+ dbg("Atm128AlarmAsyncP", "Atm128AlarmAsyncP: under min: %hhu.\n", interrupt_in);
+ }
+ else {
+ dbg("Atm128AlarmAsyncP", "Atm128AlarmAsyncP: OCF set.\n");
+ }
return; // wait for next interrupt
+ }
/* When no alarm is set, we just ask for an interrupt every MAXT */
- if (!set)
+ if (!set) {
newOcr0 = MAXT;
+ dbg("Atm128AlarmAsyncP", "Atm128AlarmAsyncP: no alarm set, set at max.\n");
+ }
else
{
uint32_t now = call Counter.get();
-
+ dbg("Atm128AlarmAsyncP", "Atm128AlarmAsyncP: now-t0 = %llu, dt = %llu\n", (now-t0), dt);
/* Check if alarm expired */
if ((uint32_t)(now - t0) >= dt)
{
header->type = type;
}
- //command am_group_t AMPacket.group(message_t* amsg) {
- // return amsg->header.group;
- //}
+ command void AMPacket.setGroup(message_t* msg, am_group_t group) {
+ cc1000_header_t* header = getHeader(msg);
+ header->group = group;
+ }
+
+ command am_group_t AMPacket.group(message_t* msg) {
+ cc1000_header_t* header = getHeader(msg);
+ return header->group;
+ }
+
+ command am_group_t AMPacket.localGroup() {
+ return TOS_AM_GROUP;
+ }
default event message_t* Receive.receive[am_id_t id](message_t* msg, void* payload, uint8_t len) {
return msg;
cc1000_header_t* header = getHeader(amsg);\r
header->type = type;\r
}\r
- \r
- //command am_group_t AMPacket.group(message_t* amsg) {\r
- // return amsg->header.group;\r
- //}\r
- \r
+\r
+ command void AMPacket.setGroup(message_t* msg, am_group_t group) {\r
+ cc1000_header_t* header = getHeader(msg);\r
+ header->group = group;\r
+ }\r
+\r
+ command am_group_t AMPacket.group(message_t* msg) {\r
+ cc1000_header_t* header = getHeader(msg);\r
+ return header->group;\r
+ }\r
+\r
+ command am_group_t AMPacket.localGroup() {\r
+ return TOS_AM_GROUP;\r
+ }\r
+\r
default event message_t* Receive.receive[am_id_t id](message_t* msg, void* payload, uint8_t len) {\r
return msg;\r
}\r
header->type = type;
}
+ command void AMPacket.setGroup(message_t* msg, am_group_t group) {
+ cc2420_header_t* header = call CC2420Packet.getHeader(msg);
+ header->destpan = group;
+ }
+
+ command am_group_t AMPacket.group(message_t* msg) {
+ cc2420_header_t* header = call CC2420Packet.getHeader(msg);
+ return header->destpan;
+ }
+
+ command am_group_t AMPacket.localGroup() {
+ return TOS_AM_GROUP;
+ }
+
default event message_t* Receive.receive[am_id_t id](message_t* msg, void* payload, uint8_t len) {
return msg;
}
header->type = type;
}
+ command void AMPacket.setGroup(message_t* msg, am_group_t group) {
+ //tda5250_header_t* header = getHeader(msg);
+ //header->group = group;
+ }
+
+ command am_group_t AMPacket.group(message_t* msg) {
+ //tda5250_header_t* header = getHeader(msg);
+ //return header->group;
+ return TOS_AM_GROUP;
+ }
+
+ command am_group_t AMPacket.localGroup() {
+ return TOS_AM_GROUP;
+ }
+
default event message_t* Receive.receive[am_id_t id](message_t* msg, void* payload, uint8_t len) {
return msg;
}
header->type = type;
}
+ command void AMPacket.setGroup(message_t* msg, am_group_t group) {
+ xe1205_header_t* header = getHeader(msg);
+ header->group = group;
+ }
+
+ command am_group_t AMPacket.group(message_t* msg) {
+ xe1205_header_t* header = getHeader(msg);
+ return header->group;
+ }
+
+ command am_group_t AMPacket.localGroup() {
+ return TOS_AM_GROUP;
+ }
+
command uint8_t AMSend.maxPayloadLength[am_id_t id]() {
return call Packet.maxPayloadLength();
}
command void setType(message_t* amsg, am_id_t t);
+ /**
+ * Get the AM group of the AM packet. The AM group is a logical
+ * identifier that distinguishes sets of nodes which may share
+ * a physical communication medium but wish to not communicate.
+ * The AM group logically separates the sets of nodes. When
+ * a node sends a packet, it fills in its AM group, and typically
+ * nodes only receive packets whose AM group field matches their
+ * own.
+ *
+ * @param amsg the packet
+ * @return the AM group of this packet
+ */
+
+ command am_group_t group(message_t* amsg);
+
+ /**
+ * Set the AM group field of a packet. Note that most data link
+ * stacks will set this field automatically on a send request, which
+ * may overwrite changes made with this command.
+ *
+ * @param amsg the packet
+ * @param group the packet's new AM group value
+ */
+ command void setGroup(message_t* amsg, am_group_t grp);
+
+ /**
+ * Provides the current AM group of this communication interface.
+ *
+ * @return The AM group.
+ */
+
+ command am_group_t localGroup();
}