partCStack.h File Reference

Interface of the functions defined in master.c and some utitlity macros by Patrik Spieß. More...

#include <Chipcon/hal.h>

Go to the source code of this file.

Data Structures

struct  NODE_ADDR_STUCT
 data type for a node address More...

Defines

#define RF_DESCRAMBLE_LSB_AND_ROTATE(byte, scrReg, j, i)
 helper macro used by macro RF_DESCRAMBLE. not for direct use
#define RF_SLOT_100_US_LEFT   (TH0 < 0xFF || TL0 < 0x84)
 returns true if at least 100 us (approximately) are left before the next timer0 event occurs TH0:TL0 < 0xFFFF - 100 / (12000/14746), that means smaller than FF84
#define RF_SLOT_200_US_LEFT   (TH0 < 0xFF || TL0 < 0x09)
 returns true if at least 200 us (approximately) are left before the next timer0 event occurs TH0:TL0 < 0xFFFF - 200 / (12000/14746), that means smaller than FF09
#define RF_SLOT_500_US_LEFT   (TH0 < 0xFD || (TH0 == 0xFD && TL0 < 0x98))
 returns true if at least 500 us (approximately) are left before the next timer0 event occurs TH0:TL0 < 0xFFFF - 500 / (12000/14746), that means smaller than FD98
#define RF_SLOT_1_MS_LEFT   (TH0 < 0xFC || (TH0 == 0xFC && TL0 < 0xD2))
 returns true if at least 1 ms (approximately) is left before the next timer0 event occurs TH0:TL0 < 0xFFFF - 500 / (12000/14746), that means smaller than FCD2
#define RF_MICROSECONDS_UNTIL_NEXT_SLOT   ( ((unsigned short)(TH0 << 8 || TL0)) / 10 * 8 )
 returns the approx time in us
#define RF_NEW_RANDOM_BYTE()   ((unsigned char)((randomNumberReg= randomNumberReg * 221 + 1) >> 24))
 returns the next evenly distributed random number
#define RF_SET_MODE_SLEEP
 turns off the transceiver
#define RF_SPI_SEND_BYTE(byte)   RF_WAIT_AND_SEND_BYTE(byte)
 defines RF_SPI_SEND_BYTE as an alias for the macro RF_WAIT_AND_SEND_BYTE defined by chipcon
#define RF_SPI_RECEIVE_BYTE(byte)   RF_WAIT_AND_RECEIVE_BYTE(byte)
 defines RF_SPI_SEND_BYTE as an alias for the macro RF_WAIT_AND_SEND_BYTE defined by chipcon
#define RF_LOW_POWER_SLEEP_UNTIL_NEXT_SLOT()   ENTER_IDLE_MODE()
 this macro can be used by the "application level" to go into power safe mode until the next interrupt (slot begin) occurs.
#define WAIT_FOR_TIMER0_EXACT(thi0, tlo0)
 loops until timer0 is at or later then the given rendevouz point.
#define BIGGER_THAN_TIMER0_RENDEVOUZ_EXACT(thi0, tlo0)   ((TH0 > thi0) || (TH0 == thi0 && TL0 >= tlo0))
 returns false until timer0 is at or later then the given rendevouz point
#define RF_SET_FIELD_STRENGTH(txPower)   PA_POW=txPower;
 sets the field strengh

Typedefs

typedef NODE_ADDR_STUCT nodeAddrType
 data type for a node address

Functions

void RFInitRandom ()
 gets a true random number for initialization of the random number generator
byte RFScramble (byte b)
 this function wraps the marcro RF_SCRAMBLE.
byte RFDescramble (byte b)
 this function wraps the marcro RF_SCRAMBLE.
byte LLSendingBusy ()
byte ACLSubscribe (byte LL_type_h, byte LL_type_l)
 adds a type to the subscription list
byte ACLUnsubscribe (byte LL_type_h, byte LL_type_l)
 deletes a type out of the subscription list
void ACLFlushSubscriptions ()
 deletes all subscriptions (not the default ones)
byte ACLSubscribeDefault ()
 subscribes to the default types (control msgs..)
byte ACLVerifySubscription (byte type_h, byte type_l)
 checks if a subscription is there
void ACLInit ()
 start ACL and lower layers, resets the whole stack
byte ACLProcessControlMessages ()
 internal: is called if control msg is there
void ACLSetFieldStrength (byte power)
 sets the field strength of transmitter signals
byte ACLSendingBusy ()
 returns true if LL has Packet in send queue
byte ACLGetSendSuccess ()
 returns the result of last packet transmission.
byte ACLSendPacket (byte slot_timeout)
 queues a packet for transmission
byte ACLAddNewType (byte type_h, byte type_l)
 adds a new type tuple to the payload
byte ACLAddData (byte data)
 adds one byte data into the ACL send buffer
void ACLAbortSending ()
 stops a running transmission
void ACLSubscribeAll ()
 subscribes to any possible type (all packets are received)
byte ACLMatchesMyIP (char *buffer, byte start)
 checks, if buffer holds my IP
char * ACLGetReceivedData (byte type_h, byte type_l)
byte ACLGetReceivedPayloadLength ()
 returns the number of payload bytes of the last packet received
signed char ACLGetReceivedDataLength (byte type_h, byte type_l)
 searches the last received packet for the given type and returns the data length of the entry found.
byte ACLSentPacketInThisSlot ()
void ACLAnswerOnACM ()
 if a control msg comes in that requires an answer, it is answered
void ACLNoAnswerOnACM ()
 if a control msgs comes in that requires an answer, it will not be answered
byte ACLClearSendData ()
 deletes the send buffer of ACL
void ACLStart ()
 restart ACL after ACLstop()
void ACLStop ()
 stops the RF stack. Everything is hold, continues after ACLstart. msg stay in queue.
byte ACLGetRemainingPayloadSpace ()
 returns the number of free bytes in the transmit buffer
void ACLLockReceiveBuffer ()
 locks the receive buffer: no new msgs are received
byte ACLReceiveBufferLocked ()
void ACLReleaseReceiveBuffer ()
 un-lock the receivebuffer;
void ACLSetDataToOld ()
 set received data to "old": means ACLDataIsNew will not return true unless a new packet was received
void ACLSetDataToNew ()
 set received data to "new": means ACLDataIsNew will return true until ACLSetDataToOld() is called
byte ACLDataIsNew ()
char ACLGetReceivedByte (byte type_h, byte type_l, byte position)
 searches the first occurrence of type tuple and returns the position-th byte after that tuple
byte ACLDataReceivedInThisSlot ()
byte ACLDataIsNewNow ()
 synonym for ACLDataReceivedInThisSlot()
byte ACLFoundReceivedType (byte type_h, byte type_l)
byte ACLAdressedDataIsNew ()
byte ACLAdressedDataIsNewNow ()
byte ACLSendPacketAdressed (nodeAddrType *address, byte timeout)
 sends out the current packet with a target ID
unsigned short LLCalcCRC16 (byte *header_data, byte *payload_data, byte payload_size)
 calculates the crc-16 checksum over the rf packet (ll header + payload)
void putchar (char c)
 classic putchar function that is used to output a character to the "screen", in our case the serial port.


Detailed Description

Interface of the functions defined in master.c and some utitlity macros by Patrik Spieß.

Use 4 space tabs to ensure readablility!

Definition in file partCStack.h.


Define Documentation

 
#define RF_LOW_POWER_SLEEP_UNTIL_NEXT_SLOT  )     ENTER_IDLE_MODE()
 

this macro can be used by the "application level" to go into power safe mode until the next interrupt (slot begin) occurs.

after returning from the ISR, operation will continue after the point when this macro was called. Definition at line 156 of file partCStack.h.

Referenced by main().

#define RF_SET_FIELD_STRENGTH txPower   )     PA_POW=txPower;
 

sets the field strengh

Parameters:
txPower strength to be used
Definition at line 178 of file partCStack.h.

#define WAIT_FOR_TIMER0_EXACT thi0,
tlo0   ) 
 

Value:

while (TH0 < thi0) {}; \ while (TH0 == thi0 && TL0 < tlo0) {};
loops until timer0 is at or later then the given rendevouz point.

it was tried to implement this macro with just one unsigned short value, but this lead to a insufficient accuracy. Definition at line 162 of file partCStack.h.

Referenced by RFArbitrationBit(), RFReceivePacket(), and RFSendPacket().


Function Documentation

byte ACLAddData byte  newByte  ) 
 

adds one byte data into the ACL send buffer

Parameters:
newByte data byte to insert to the current ACL tuple
Returns:
0 if appending succeeded, 1 if packet is full, 2 if sending is busy
Definition at line 2795 of file deepSleepSender/stackMasterSlaveSync.c.

References LL_payload_send, and LL_payload_send_length.

Referenced by ACLSendPacketAdressed(), ACLStartUp(), and main().

byte ACLAddNewType byte  type_h,
byte  type_l
 

adds a new type tuple to the payload

Returns:
0 if appending succeeded, 1 if packet is full, 2 if sending is busy
Definition at line 2775 of file deepSleepSender/stackMasterSlaveSync.c.

References LL_payload_send, and LL_payload_send_length.

Referenced by ACLSendPacketAdressed(), ACLStartUp(), and main().

byte ACLAdressedDataIsNew  ) 
 

Returns:
true if received packet is new and addressed to me
Definition at line 2966 of file deepSleepSender/stackMasterSlaveSync.c.

References ACLDataIsNew(), ACLFoundReceivedType(), ACLGetReceivedData(), and ACLMatchesMyIP().

byte ACLAdressedDataIsNewNow  ) 
 

Returns:
true if packet has been received in current slot and is addressed to me
Definition at line 2979 of file deepSleepSender/stackMasterSlaveSync.c.

References ACLDataIsNewNow(), ACLFoundReceivedType(), ACLGetReceivedData(), and ACLMatchesMyIP().

byte ACLDataIsNew  ) 
 

Returns:
true if data in receive buffer is "new", false otherwise
Definition at line 2945 of file deepSleepSender/stackMasterSlaveSync.c.

References LLDataIsNew().

byte ACLDataReceivedInThisSlot  ) 
 

Returns:
true if packet has been send and the subsequent slot has not yet started
Definition at line 2952 of file deepSleepSender/stackMasterSlaveSync.c.

References LLSentPacketInThisSlot().

byte ACLFoundReceivedType byte  type_h,
byte  type_l
 

Parameters:
type_h the high byte of the acl type
type_l the low byte of the acl type
Returns:
true if a tuple of the given type is included in the last packet, false otherwise
Definition at line 2881 of file deepSleepSender/stackMasterSlaveSync.c.

References ACLGetReceivedDataLength().

Referenced by ACLAdressedDataIsNew(), and ACLAdressedDataIsNewNow().

char ACLGetReceivedByte byte  type_h,
byte  type_l,
byte  position
 

searches the first occurrence of type tuple and returns the position-th byte after that tuple

Returns:
single byte of last received packet on the given position after the first occurrence of the byte
Definition at line 2860 of file deepSleepSender/stackMasterSlaveSync.c.

References LL_header_received, and LL_payload_received.

char* ACLGetReceivedData byte  type_h,
byte  type_l
 

Returns:
pointer to the ACL payload data of the given type in the last received packet or NULL if type was not found in packet
Definition at line 2842 of file deepSleepSender/stackMasterSlaveSync.c.

References LL_header_received, and LL_payload_received.

Referenced by ACLAdressedDataIsNew(), and ACLAdressedDataIsNewNow().

signed char ACLGetReceivedDataLength byte  type_h,
byte  type_l
 

searches the last received packet for the given type and returns the data length of the entry found.

Returns:
see above
Definition at line 2827 of file deepSleepSender/stackMasterSlaveSync.c.

References LL_header_received, and LL_payload_received.

Referenced by ACLFoundReceivedType().

byte ACLGetReceivedPayloadLength  ) 
 

returns the number of payload bytes of the last packet received

Returns:
see above
Definition at line 2819 of file deepSleepSender/stackMasterSlaveSync.c.

References LL_header_received.

byte ACLGetRemainingPayloadSpace  ) 
 

returns the number of free bytes in the transmit buffer

Returns:
see above
Definition at line 2811 of file deepSleepSender/stackMasterSlaveSync.c.

References LLGetRemainingPayloadSpace().

byte ACLGetSendSuccess  ) 
 

returns the result of last packet transmission.

note that this value is valid for the last packet and is not set for the current packet in queue until sending is not busy any more.

Returns:
true if the last packet has been sent successfully, false otherwise
Definition at line 2702 of file deepSleepSender/stackMasterSlaveSync.c.

References LLGetSendSuccess().

byte ACLMatchesMyIP char *  buffer,
byte  start
 

checks, if buffer holds my IP

Parameters:
buffer buffer in which to search
start start offset where to begin the search
Returns:
true if given buffer on the given position matches own ip, false otherwise
Definition at line 2712 of file deepSleepSender/stackMasterSlaveSync.c.

References LL_header_sendbuffer.

Referenced by ACLAdressedDataIsNew(), ACLAdressedDataIsNewNow(), and ACLProcessControlMessages().

byte ACLProcessControlMessages  ) 
 

internal: is called if control msg is there

Returns:
one if there was a control msg, the return value is no longer used.
Definition at line 2607 of file deepSleepSender/stackMasterSlaveSync.c.

References ACL_CONTROL_MESSAGES_TIMEOUT, ACL_TYPE_ACM_H, ACL_TYPE_ACM_L, ACLAbortSending(), ACLMatchesMyIP(), LL_header_receivebuffer, LL_payload_receivebuffer, LL_payload_send, LL_payload_send_length, LL_STATE_CTRL_MESSAGE_INSERTED, LLSendingBusy(), LLSendPacket(), llState, and RFStop().

byte ACLReceiveBufferLocked  ) 
 

Returns:
true if receivebuffer is locked, false otherwise
Definition at line 2923 of file deepSleepSender/stackMasterSlaveSync.c.

References LLReceiveBufferLocked().

byte ACLSendPacket byte  slot_timeout  ) 
 

queues a packet for transmission

Parameters:
slot_timeout number of slots the packet is tried to be sent
Returns:
true, if packed was queued, false if sending is busy or connection is off or anything else goes wrong
Definition at line 2745 of file deepSleepSender/stackMasterSlaveSync.c.

References LLSendPacket().

Referenced by ACLSendPacketAdressed(), ACLStartUp(), and main().

byte ACLSendPacketAdressed nodeAddrType address,
byte  timeout
 

sends out the current packet with a target ID

Parameters:
address pointer to an address data structure
timeout how many slots the packet is tried to be sent until giving up
Definition at line 2995 of file deepSleepSender/stackMasterSlaveSync.c.

References NODE_ADDR_STUCT::a1, NODE_ADDR_STUCT::a2, NODE_ADDR_STUCT::a3, NODE_ADDR_STUCT::a4, NODE_ADDR_STUCT::a5, NODE_ADDR_STUCT::a6, NODE_ADDR_STUCT::a7, NODE_ADDR_STUCT::a8, ACLAddData(), ACLAddNewType(), ACLGetRemainingPayloadSpace(), ACLSendPacket(), and nodeAddrType.

byte ACLSentPacketInThisSlot  ) 
 

Returns:
true after a packet was sent and before the start of the next slot, false otherwise
Definition at line 2901 of file deepSleepSender/stackMasterSlaveSync.c.

References LLSentPacketInThisSlot().

byte ACLSubscribe byte  LL_type_h,
byte  LL_type_l
 

adds a type to the subscription list

Parameters:
LL_type_h the high byte of the acl type
LL_type_l the low byte of the acl type
Returns:
TRUE if action succeeded, false otherwise
Definition at line 2514 of file deepSleepSender/stackMasterSlaveSync.c.

References ACL_SUBSCRIPTIONLIST_LENGTH.

Referenced by ACLSubscribeDefault().

byte ACLUnsubscribe byte  LL_type_h,
byte  LL_type_l
 

deletes a type out of the subscription list

Parameters:
LL_type_h the high byte of the acl type
LL_type_l the low byte of the acl type
Returns:
TRUE if the type was found and deleted, false otherwise
Definition at line 2537 of file deepSleepSender/stackMasterSlaveSync.c.

References ACL_SUBSCRIPTIONLIST_LENGTH.

byte ACLVerifySubscription byte  type_h,
byte  type_l
 

checks if a subscription is there

Parameters:
type_h the high byte of the acl type
type_l the low byte of the acl type
Returns:
true if the given type subscribed, false otherwise
Definition at line 2593 of file deepSleepSender/stackMasterSlaveSync.c.

References ACL_SUBSCRIPTIONLIST_LENGTH.

unsigned short LLCalcCRC16 byte *  header_data,
byte *  payload_data,
byte  payload_size
 

calculates the crc-16 checksum over the rf packet (ll header + payload)

Parameters:
header_data header of the current packet
payload_data payload of the current packet
payload_size as the name suggests
Returns:
checksum
Definition at line 2351 of file deepSleepSender/stackMasterSlaveSync.c.

Referenced by LLSendPacket(), and RFReceivePacket().

byte LLSendingBusy  ) 
 

Returns:
true if the ll layer is busy sending or preparing to send, false otherwise
Definition at line 2263 of file deepSleepSender/stackMasterSlaveSync.c.

References LL_STATE_NEED_TO_SEND, and llState.

void putchar char  c  ) 
 

classic putchar function that is used to output a character to the "screen", in our case the serial port.

Definition at line 743 of file deepSleepSender/stackMasterSlaveSync.c.

Referenced by DebugDumpReceivedAclPacket(), DebugDumpRfState(), isr_timer0(), LLInit(), main(), and RFArbitrationBitDebug().

byte RFDescramble byte  b  ) 
 

this function wraps the marcro RF_SCRAMBLE.

previously, this was "called" directly in RFReceivePacket for efficiency reasons, but there seems to be enough time to call it as a function, which increases run-time-overhead but reduces binary size by 13 percent.Definition at line 1136 of file deepSleepSender/stackMasterSlaveSync.c.

References rfScramblerReg.

Referenced by RFReceivePacket().

byte RFScramble byte  b  ) 
 

this function wraps the marcro RF_SCRAMBLE.

previously, this was "called" directly in RFSendPacket for efficiency reasons, but there seems to be enough time to call it as a function, which increases run-time-overhead but reduces binary size by 13 percent.Definition at line 1868 of file deepSleepSender/stackMasterSlaveSync.c.

References rfScramblerReg.

Referenced by RFSendPacket().


Generated on Fri Aug 27 10:04:04 2004 for Cheap Sensor Network by doxygen 1.3.8