#include <chipcon/reg1010.h>
#include <chipcon/partCboard.h>
#include <chipcon/hal.h>
#include <chipcon/sdccutils.h>
#include "acltypes.h"
#include <chipcon/partCStack.h>
Go to the source code of this file.
Debug switches | |
#define | DEBUG_USE_UART |
this switch activates debug messages that are sent through a serial port | |
#define | DEBUG_USE_UART1_FOR_DUMPING |
if defined, this switch activates output through uart1, otherwise output is directed to uart0 (default). | |
#define | DEBUG_DUMP_RF_STATE |
if defined, this switch will turn on dumping the state of the node. | |
#define | DEBUG_VERIFY_SCRAMBLING |
this switch turns on scrambling and tests the fitness of the scrambling macros | |
RF defines and variables | |
#define | RF_STATE_MASTER BIN(00000001) |
rf status bit: 1: the node is standalone or a master, sending sync packets every n-th slot. | |
#define | RF_STATE_ALONE BIN(00000010) |
rf status bit: if a master didn't here anything from another node for a certain number of times (normally some minutes) it sets this bit, and resets it at the first reception of a packet. | |
#define | RF_STATE_IN_SYNC BIN(00000100) |
rf status bit: the last synchronization was successful. | |
#define | RF_STATE_TRAFFIC_GROUP BIN(00001000) |
rf status bit: if this bit is 0, the the stack is within an idle group (it may not send and it does not have to recieve packets). | |
#define | RF_STATE_LONG_SEARCH_FOR_MASTER BIN(00010000) |
rf status bit: the node is trying to become master. | |
#define | RF_STATE_MASTER_RIVAL_TEST BIN(00100000) |
rf status bit: a master node goes into this mode every time after sending the 100th sync packet. | |
#define | RF_STATE_RUNNING BIN(10000000) |
rf status bit: rf layer is running | |
#define | RF_SYNC_MAX_SLOT_COUNT 10 |
every RF_SYNC_MAX_SLOT_COUNT slots, a master sends a sync signal / a slave tries to receive a sync signal. | |
#define | RF_ALONE_TEST_FAILED_THRESHOLD 167 |
number of slots without reception of neither an aloneTest response nor a packet, before a node thinks it is alone. | |
#define | RF_ALONE_DEEP_SLEEP |
this switch controls the actions taken if the node detects that it is alone. | |
#define | RF_PREAMBLE_LENGTH_TX 20 |
the number of preamble bytes that are sent before any RF packet on send | |
#define | RF_PREAMBLE_LENGTH_RX 20 |
the number of preamble bytes need to be detected before any RF packen on receive | |
#define | RF_MAX_SYNC_JITTER 5769ul |
the maximum time (im us) that a slave is waiting in a sync slot for the master sync signal. | |
#define | RF_SLOT_LENGTH_IN_US 36865ul |
the slot length im us - according to the manual. | |
#define | RF_MASTER_SEARCH_SLOTS_STARTUP 50 |
number of slots to search for am master at startup. | |
#define | RF_MASTER_SEARCH_SLOTS_AFTER_ALONE 167 |
number of slots to when waking up from alone low power sleep | |
#define | RF_MAX_FAILED_SYNC_COUNT 6 |
after not being able to receive a sync signal for RF_MAX_FAILED_SYNC_COUNT times, a slave goes into status RF_STATE_SYNC_MASTER_LONG_TEST this number has to be less than RF_ALONE_TEST_FAILED_THRESHOLD, because if you have only 2 nodes and the slave looses sync, it has to regain sync faster than the time the master decides to go into power-save-mode. | |
#define | RF_MASTER_RIVAL_TEST_SYNC_COUNT 30 |
after sending this number of sync packets, a master listens for other masters until his next packet is scheduled (State: RF_STATE_SYNC_MASTER_RIVAL_TEST) | |
#define | RF_SYNC_ADDITIONAL_OFFSET 0x89B3 |
additional offset added to start offset transmitted in sync packet in us without this, the slave would wake up slightly to early. | |
#define | RF_ARBITRATION_RSSI_THRESHOLD 0x78 |
maximum rssi signal strength that may be read during arbitration to be able to send a packet. | |
#define | RF_ALONE_TEST_RSSI_THRESHOLD 0xC0 |
the rssi threshold used for the alone test and traffic indication. | |
#define | RF_RENDEZVOUS_SYNC_START_HI 0x7C |
value of timer register TH0 when sync send should begin. | |
#define | RF_RENDEZVOUS_DATA_PACKET_START_HI 0x93 |
value of timer register TH0 when data packet send should begin. | |
#define | RF_RENDEZVOUS_ARBITRATION_START_HI 0x71 |
value of timer register TH0 when arbitration should begin. | |
#define | RF_ARBITRATION_TIMER_TICS_OTHER_PERIODS 0x390 |
how many timer0 tics between rendezvous points optimal value for 76.8 kBaud Manchester: 0x1EA for 2 samples / 13 bit sent 0x24C for 3 samples / 20 bit sent optimal value for 76.8 kBaud NRZ: 0x3D8 for 3 samples / 20 bit sent (for testing and rssi dumping use 0x500) 0x358 - 0x380 | |
#define | RF_BUFFER_SIZE 64 |
size of the sending and reception buffer | |
#define | RF_RENDEZVOUS_TRAFFIC_INDICATION_HI 0x92 |
value of timer register TH0 when traffic indication signal should be sent. | |
#define | RF_RENDEZVOUS_ALONE_TEST_HI 0x8C |
value of timer register TH0 when arbitration should begin. | |
data volatile byte | rfState = 0 |
byte that holds the current rf state. | |
data byte | rfScramblerReg = BIN(01101100) |
current value of the scrambler register which is used to generate a dc-free code with limited run-length for rf transmission. | |
data unsigned long | randomNumberReg |
random number generator register | |
unsigned short | rfSlotsWithoutSignalReceived = 0 |
this variable is increased in every slot. | |
data unsigned short | tEndAvg = 0 |
the average timer value on the master after sending the sync packet. | |
xdata TIMER_DATA | periodDataSlot |
the calculated periods for the timer registers | |
xdata signed short | moduloTimer0 |
the modulo word for timer adjustment of timer 0 | |
xdata byte | rssiSamples [16] |
the rssi samples acquired during arbitration | |
unsigned short | arbitrationGood = 0 |
statistic counter: number of times arbitration succeeded (media access granted) | |
unsigned short | arbitrationBad = 0 |
statistic counter: number of times arbitration failed (media access denied) | |
RF_RXTXPAIR_SETTINGS code | RF_SETTINGS |
xdata RF_RXTXPAIR_CALDATA | RF_CALDATA |
Calibration data. | |
xdata byte | rfFieldStrength |
holds the value of the currently used field strength. | |
LL defines and variables | |
#define | LL_PROTOCOL_VERSION 4 |
the protocol version | |
#define | LL_CRC16_POLY 0x1021 |
check polynom for crc 16 | |
#define | LL_CRC16_INIT 0xFFFF |
initial value of the crc16 register | |
#define | LL_CRC_OK 0 |
modulo for correct crc reception (zero) | |
#define | LL_STATE_SEND_SUCCESS BIN(00000001) |
true if the last packet was sent successfully, false otherwise. updated when LL_STATE_NEED_TO_SEND is reset. | |
#define | LL_STATE_CTRL_MESSAGE_INSERTED BIN(00000010) |
true if packet in send buffer has been replaced by a control message | |
#define | LL_STATE_NEED_TO_SEND BIN(00000100) |
ll status bit: if 1, the data in the send buffer has to be sent. | |
#define | LL_STATE_RECEIVE_BUFFER_LOCKED BIN(00001000) |
true if receive buffer is locked, false otherwise | |
#define | LL_STATE_NEW_DATA BIN(00010000) |
true if new data has arrived in the receive buffer after the last time this flag was set to 0, false otherwise | |
#define | LL_STATE_PACKET_JUST_SENT BIN(00100000) |
true if a packet was sent in the current slot, false otherwise | |
#define | LL_STATE_PACKET_JUST_RECEIVED BIN(01000000) |
true if a packet was received in the current slot, false otherwise | |
#define | LL_STATE_RUNNING BIN(10000000) |
true if ll layer is running, false otherwise | |
xdata byte | LL_sequence_no |
current LL sequence number | |
data volatile byte | llState = 0 |
byte that holds the current rf state. | |
ACL defines and variables | |
#define | ACL_SUBSCRIPTIONLIST_LENGTH 8 |
length of the subscription list, must be dividable by 4 | |
#define | ACL_CONTROL_MESSAGES_TIMEOUT 30 |
timeout in slots for control messages | |
#define | ACL_TYPE_ACM_H ACL_TYPE_ACM_HI |
synonym | |
#define | ACL_TYPE_ACM_L ACL_TYPE_ACM_LO |
synonym | |
Helper functions | |
void | DebugDumpRfState () |
sends a nice representation of the the current rf status to uart | |
void | DebugDumpReceivedAclPacket () |
dumps a representation of the last received packet payload (stored in LL_payload_received) to the serial port. | |
void | putchar (char c) |
classic putchar function that is used to output a character to the "screen", in our case the serial port. | |
void | DebugBuildTestPacketACL () |
builds a test packet. | |
"PIC" Layer | |
actually CC1010 layer - board setup | |
void | ParticleInit () |
sets up the board: LEDs, watchdog timer, memory access, serial port | |
byte | AppSelfTest (char *result) |
RF Layer Functions | |
void | RFInit () |
calibrates the transceiver. calculates timer periods needed for rf. | |
void | RFStart () |
starts the timer. this turns on receiving, sending and sync. turns on rssi. | |
void | RFStop () |
stops the timer. | |
void | RFSetModeTransmit () |
faster version of the halRFSetRxTxOff function to start sending. | |
void | RFSetModeReceive () |
faster version of the halRFSetRxTxOff function to start receiving prior execution of halRFSetRxTxOff() is required. | |
void | RFInitRandom () |
gets a true random number for initialization of the random number generator | |
unsigned short | RFReceivePacket (xdata TIMER_DATA *timeOutPeriodData, bool onlyDataPackets) |
the general function to receive a packet. | |
byte | RFArbitrationBit (bool sendOrListen, byte t0hi, byte t0lo) |
does the arbitration for one arbitration slice. | |
byte | RFArbitrationBitDebug (bool sendOrListen, byte t0hi, byte t0lo) |
does the arbitration for one arbitration slice. | |
bool | RFArbitration (bool tryToObtainMediaAccess) |
tries to get media access through the can arbitration process. | |
byte | RFAloneRandomNumberOfSeconds () |
returns the number of seconds that the node should stay in deep sleep when it detects that it is alone. | |
unsigned short | RFAloneRandomNumberOfSlots () |
returns the number of slots that the node should stay alone mode (suppressing communication) when it detects that it is alone. | |
void | RFLowPowerSleep (byte sleepTime) |
sends the node into power-saving mode for 10-26 seconds. this is done by turning on the 32KHz clock, switching off the 14MHz clock and switching the core to the low frequency clock. the node stays in low freq mode for a random number of seconds and then switches back to high freq mode. | |
byte | RFScramble (byte b) |
this function wraps the marcro RF_SCRAMBLE. | |
byte | RFDescramble (byte b) |
this function wraps the marcro RF_SCRAMBLE. | |
bool | RFLongSearchForMaster (unsigned short numTries) |
does a long search for a sync packet. | |
bool | RFMasterRivalTest () |
does a master rival test. | |
LL Layer Functions | |
byte | LLGetIDFromHardware () |
reads particle address from flash | |
void | LLInit () |
initializes the ll layer (and the lower layers) | |
void | LLStart () |
starts the ll layer and the rf layer | |
void | LLStop () |
stops the ll layer and the rf layer | |
void | LLSlotEnd () |
i guess this function is called at the end of the ISR before returning to "application level". | |
void | LLAbortSending () |
unqueues the current packet. | |
void | LLSetSendingSuccess () |
sets the rfState and llState bits to their sending success value | |
byte | LLSendingBusy () |
byte | LLGetSendSuccess () |
byte | LLIsActive () |
void | LLSetDataToOld () |
resets the "new data flag". | |
void | LLLockReceiveBuffer () |
locks the receive buffer, i.e. | |
byte | LLReceiveBufferLocked () |
void | LLReleaseReceiveBuffer () |
unlocks the receive buffer, i.e. | |
void | LLSetDataToNew () |
sets the "new data flag". | |
byte | LLDataIsNew () |
byte | LLGetFieldStrength () |
void | LLSetFieldStrength (byte value) |
sets the field strength at which packets are sent out (0-255) | |
unsigned short | LLCalcCRC16 (byte *header_data, byte *payload_data, byte payload_size) |
calculates the crc-16 checksum over the rf packet (ll header + payload) | |
byte | LLSendPacket (byte slot_limit) |
prepares the LL header and instructs the rf layer to send the packet out (via flag). | |
byte | LLGetRemainingPayloadSpace () |
byte | LLSentPacketInThisSlot () |
ACL Layer Functions | |
void | ACLStartUp () |
is the first function in any case, runs selftest and aclinit | |
void | ACLInit () |
start ACL and lower layers, resets the whole stack | |
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) | |
void | ACLSubscribeAll () |
subscribes to any possible type (all packets are received) | |
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 | ACLSubscribeDefault () |
subscribes to the default types (control msgs..) | |
byte | ACLVerifySubscription (byte type_h, byte type_l) |
checks if a subscription is there | |
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 | ACLMatchesMyIP (char *buffer, byte start) |
checks, if buffer holds my IP | |
byte | ACLSendPacket (byte slot_timeout) |
queues a packet for transmission | |
void | ACLAbortSending () |
stops a running transmission | |
byte | ACLClearSendData () |
deletes the send buffer of ACL | |
bool | ACLAddNewType (byte type_h, byte type_l) |
adds a new type tuple to the payload | |
byte | ACLAddData (byte newByte) |
adds one byte data into the ACL send buffer | |
byte | ACLGetRemainingPayloadSpace () |
returns the number of free bytes in the transmit buffer | |
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. | |
char * | ACLGetReceivedData (byte type_h, byte type_l) |
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 | ACLFoundReceivedType (byte type_h, byte type_l) |
void | ACLSetControlMessagesBehaviour (boolean ignore, boolean pass) |
note that the settings are independent. | |
byte | ACLSentPacketInThisSlot () |
void | ACLStart () |
restart ACL after ACLstop() | |
void | ACLStop () |
stops the RF stack. Everything is hold, continues after ACLstart. msg stay in queue. | |
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 () |
byte | ACLDataReceivedInThisSlot () |
byte | ACLDataIsNewNow () |
synonym for ACLDataReceivedInThisSlot() | |
byte | ACLAdressedDataIsNew () |
byte | ACLAdressedDataIsNewNow () |
byte | ACLSendPacketAdressed (nodeAddrType *address, byte timeout) |
sends out the current packet with a target ID | |
Received Packet Variables | |
An received data packet is copied into these variables once it arrived completely and and succeeded the crc test | |
xdata byte | LL_header_received [LL_HEADER_SIZE] |
last header received | |
xdata byte | LL_payload_received [LL_PAYLOAD_SIZE] |
last payload received | |
xdata byte | LL_payload_received_length |
length of last payload received | |
xdata byte | LL_tail_received [LL_TAIL_SIZE] |
last tail received | |
Packet Receive Buffer | |
During reception, an incoming packet is written to these variables and on complete arrival and successful crc test (if it is a data packet) is copied into the Received Packet variables.
By this, the next packet can be received immediately. | |
volatile xdata byte | LL_header_receivebuffer [LL_HEADER_SIZE] |
temp store: header received | |
volatile xdata byte | LL_payload_receivebuffer [LL_PAYLOAD_SIZE] |
temp store: payload received | |
volatile xdata byte | LL_payload_receivebuffer_length |
temp store: of last payload received | |
volatile xdata byte | LL_tail_receivebuffer [LL_TAIL_SIZE] |
temp store: tail received | |
Variables For Next Packet to Send | |
The user and the ACL function write the payload of the next packet to send into these variables.
No header and tail variables are needed for "send" because they are evaluated not until sending time. | |
xdata byte | LL_payload_send [LL_PAYLOAD_SIZE] |
next payload to send | |
xdata byte | LL_payload_send_length |
length of next payload to send | |
Packet To Send Buffer | |
On calling LLSendPacket(), the payload to send is copied into these send buffer variables.
The LL_payload_send variable can be accessed again immediately. The "realtime" part only accesses these variables. | |
xdata byte | LL_header_sendbuffer [LL_HEADER_SIZE] |
temp store: header to send | |
xdata byte | LL_payload_sendbuffer [LL_PAYLOAD_SIZE] |
temp store: payload to send | |
xdata byte | LL_payload_sendbuffer_length |
temp store: length of payload to send | |
xdata byte | LL_tail_sendbuffer [LL_TAIL_SIZE] |
temp store: tail to send | |
statistical variables | |
xdata unsigned long | statsRfSlotsInSync |
for a master: number of slots not in master rival test, for slave: number of slots in sync. only in these slots data can be sent | |
xdata unsigned long | statsRfSlotsNeedToSend |
those of the statsRfSlotsInSync where the node had to send something | |
xdata unsigned long | statsRfArbitrationWon |
those of the statsRfSlotsNeedToSend where arbitration was won | |
xdata unsigned long | statsRfDataPacketsReceivedNotNeedingToSend |
those of the statsRfSlotsNoNeedToSend where the node didn't detect another arbitration signal | |
Functions | |
void | isr_timer0 () |
the "realtime"-part of the software. | |
void | isr_timer2 () |
this is a dummy isr. | |
void | main (void) |
the "application level" part of the software. |
it implements a new rf layer but leaves the upper layers compatible with other particles
Use 4 space tabs to ensure readability!
version 0.7, (c) Patrik Spieß, post@patrik-spiess.de, 2004-03-30
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. or see at the web page http://www.gnu.org/copyleft/gpl.html
Definition in file stackMasterSlaveSync.c.
|
if defined, this switch will turn on dumping the state of the node. the rf and ll state of the node is shown after every slot when it has changed.Definition at line 97 of file stackMasterSlaveSync.c. |
|
if defined, this switch activates output through uart1, otherwise output is directed to uart0 (default). if DEBUG_USE_UART is not defined, this define is ignoredDefinition at line 85 of file stackMasterSlaveSync.c. |
|
this switch turns on scrambling and tests the fitness of the scrambling macros Definition at line 112 of file stackMasterSlaveSync.c. |
|
ll status bit: if 1, the data in the send buffer has to be sent. the ll layer resets this bit, after successfully sending the packet or after reaching the slot limit.Definition at line 528 of file stackMasterSlaveSync.c. |
|
this switch controls the actions taken if the node detects that it is alone. if this switch is defined, the stack will halt the execution of the application and go into deep sleep (maximum energy saving). if it is not defined, the execution of the application will continue but outgoing packets are thrown away and the medium is not searched for incoming packets (medium power saving). if deep sleep is used, the node sleeps a random number of seconds seconds. the current number is provided by the function RFAloneRandomNumberOfSeconds(). if transmission suppression is used instead, the node stays in alone mode for a number of slots the current number is provided by the function RFAloneRandomNumberOfSlots().Definition at line 241 of file stackMasterSlaveSync.c. |
|
number of slots without reception of neither an aloneTest response nor a packet, before a node thinks it is alone. Definition at line 228 of file stackMasterSlaveSync.c. |
|
the rssi threshold used for the alone test and traffic indication. after the beacon in the beacon slot, every slave that heard the beacon sends a signal at the rendezvous time RF_RENDEZVOUS_ALONE_TEST_X. by this method, the master knows if it is alone or not. the slaves already know: they hear a master, so they can't be alone.Definition at line 323 of file stackMasterSlaveSync.c. |
|
maximum rssi signal strength that may be read during arbitration to be able to send a packet. if a signal with higher strength (lower ADC value) than this value is received, the node assumes, another node has a 1 and it backs off. this is not actually a dbm value. it is the raw value read from the analog digital converter. if the value is below this threshold, the signal strength is higher than a certain dbm value. e.g.: if the adc val is lower than 116, the dbm val is higher than -75 (recommended values by the chipcon application examples)# old val: 192=0xC0, 0xE0 new val: 151=0x97 (for the big boards) new val: 120=0x78 for the small partcBoards which report higher signal levels => lower rssi valuesDefinition at line 314 of file stackMasterSlaveSync.c. |
|
number of slots to search for am master at startup. actually, a random number of 0-255 is added to this value to ensure that not all slaves synchronously want to become masters after a master gave up it's status.Definition at line 269 of file stackMasterSlaveSync.c. |
|
after not being able to receive a sync signal for RF_MAX_FAILED_SYNC_COUNT times, a slave goes into status RF_STATE_SYNC_MASTER_LONG_TEST this number has to be less than RF_ALONE_TEST_FAILED_THRESHOLD, because if you have only 2 nodes and the slave looses sync, it has to regain sync faster than the time the master decides to go into power-save-mode. Definition at line 283 of file stackMasterSlaveSync.c. |
|
the maximum time (im us) that a slave is waiting in a sync slot for the master sync signal. the shorter this period, the less energy uses the node. but a shorter interval requires a more accurate synchronization.
|
|
value of timer register TH0 when arbitration should begin. optimal values:
|
|
value of timer register TH0 when arbitration should begin. optimal values:
|
|
value of timer register TH0 when data packet send should begin. optimal values:
|
|
value of timer register TH0 when sync send should begin. optimal values:
|
|
value of timer register TH0 when traffic indication signal should be sent. optimal values:
|
|
the slot length im us - according to the manual. actually, this is the desired slot length multiplied with (approximately) 1,2956. a value of 36865ul leads to a period of 30000 usDefinition at line 262 of file stackMasterSlaveSync.c. |
|
rf status bit: if a master didn't here anything from another node for a certain number of times (normally some minutes) it sets this bit, and resets it at the first reception of a packet. Definition at line 153 of file stackMasterSlaveSync.c. |
|
rf status bit: the last synchronization was successful. the node may only send, if this bit is 1Definition at line 159 of file stackMasterSlaveSync.c. |
|
rf status bit: the node is trying to become master. for this it listens to the medium for a while until he is sure, there there is no other masterDefinition at line 172 of file stackMasterSlaveSync.c. |
|
rf status bit: 1: the node is standalone or a master, sending sync packets every n-th slot. 0: the node is a slave and synchronizes to a master every n-th slotDefinition at line 147 of file stackMasterSlaveSync.c. |
|
rf status bit: a master node goes into this mode every time after sending the 100th sync packet. immediately after sending the sync, he listens to the channel if another master broadcasts a sync packet. if he hears one, he gives up and turns into a slave, synchronizing to the other master. he listens at most for n slots until he is due to send the next sync packet.Definition at line 180 of file stackMasterSlaveSync.c. |
|
rf status bit: if this bit is 0, the the stack is within an idle group (it may not send and it does not have to recieve packets). if this bit is 1, it is within a traffic group (packets may be send and have to be received).Definition at line 166 of file stackMasterSlaveSync.c. |
|
additional offset added to start offset transmitted in sync packet in us without this, the slave would wake up slightly to early. measured with oscilloscope. took 24 values, minimized quadratic error. 566 for 76.8kBaud, Manchester. 422 for 76,8kBaud, NRZ, Scrambling und XOR-protection, without avg calculation new system: 0x8A35Definition at line 299 of file stackMasterSlaveSync.c. |
|
every RF_SYNC_MAX_SLOT_COUNT slots, a master sends a sync signal / a slave tries to receive a sync signal. Definition at line 216 of file stackMasterSlaveSync.c. |
|
adds one byte data into the ACL send buffer
References LL_payload_send, and LL_payload_send_length. Referenced by ACLSendPacketAdressed(), ACLStartUp(), and main(). |
|
adds a new type tuple to the payload
References LL_payload_send, and LL_payload_send_length. Referenced by ACLSendPacketAdressed(), ACLStartUp(), and main(). |
|
References ACLDataIsNew(), ACLFoundReceivedType(), ACLGetReceivedData(), and ACLMatchesMyIP(). |
|
References ACLDataIsNewNow(), ACLFoundReceivedType(), ACLGetReceivedData(), and ACLMatchesMyIP(). |
|
References LLDataIsNew(). |
|
References LLSentPacketInThisSlot(). |
|
References ACLGetReceivedDataLength(). Referenced by ACLAdressedDataIsNew(), and ACLAdressedDataIsNewNow(). |
|
searches the first occurrence of type tuple and returns the position-th byte after that tuple
References LL_header_received, and LL_payload_received. |
|
References LL_header_received, and LL_payload_received. Referenced by ACLAdressedDataIsNew(), and ACLAdressedDataIsNewNow(). |
|
searches the last received packet for the given type and returns the data length of the entry found.
References LL_header_received, and LL_payload_received. Referenced by ACLFoundReceivedType(). |
|
returns the number of payload bytes of the last packet received
References LL_header_received. |
|
returns the number of free bytes in the transmit buffer
References LLGetRemainingPayloadSpace(). |
|
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.
References LLGetSendSuccess(). |
|
checks, if buffer holds my IP
References LL_header_sendbuffer. Referenced by ACLAdressedDataIsNew(), ACLAdressedDataIsNewNow(), and ACLProcessControlMessages(). |
|
internal: is called if control msg is there
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(). |
|
References LLReceiveBufferLocked(). |
|
queues a packet for transmission
References LLSendPacket(). Referenced by ACLSendPacketAdressed(), ACLStartUp(), and main(). |
|
sends out the current packet with a target ID
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. |
|
References LLSentPacketInThisSlot(). |
|
note that the settings are independent. you may set ignore to true and pass to false having the effect that control messages are completely thrown away (not processed and filtered). if you set ignore to false and pass to true, they are not processed and copied as payload.
References ACLSetControlMessagesBehaviour(). |
|
adds a type to the subscription list
References ACL_SUBSCRIPTIONLIST_LENGTH. Referenced by ACLSubscribeDefault(). |
|
deletes a type out of the subscription list
References ACL_SUBSCRIPTIONLIST_LENGTH. |
|
checks if a subscription is there
References ACL_SUBSCRIPTIONLIST_LENGTH. |
|
builds a test packet. Definition at line 758 of file stackMasterSlaveSync.c. |
|
dumps a representation of the last received packet payload (stored in LL_payload_received) to the serial port. Definition at line 716 of file stackMasterSlaveSync.c. References ACLLockReceiveBuffer(), LL_header_received, LL_payload_received, LL_payload_received_length, and putchar(). |
|
|
this is a dummy isr. nothing is done. it is used to wake up the node from idle mode in low frequency mode. this is done in RFLowPowerSleep(). Definition at line 3257 of file stackMasterSlaveSync.c. |
|
unqueues the current packet. i.e. the process of sending a packet is being aborted.Definition at line 2207 of file stackMasterSlaveSync.c. References LL_STATE_CTRL_MESSAGE_INSERTED, LL_STATE_NEED_TO_SEND, LL_STATE_SEND_SUCCESS, LLSendingBusy(), and llState. |
|
calculates the crc-16 checksum over the rf packet (ll header + payload)
Referenced by LLSendPacket(), and RFReceivePacket(). |
|
References LL_STATE_NEW_DATA, and llState. |
|
References rfFieldStrength. |
|
References LL_payload_send_length. |
|
References LL_STATE_SEND_SUCCESS, and llState. |
|
References LL_STATE_RUNNING, and llState. |
|
locks the receive buffer, i.e. no packets are received by the rf layer until it is unlocked. useful if the data received needs time-consuming processing.Definition at line 2267 of file stackMasterSlaveSync.c. References LL_STATE_RECEIVE_BUFFER_LOCKED, LLSetDataToOld(), and llState. |
|
References LL_STATE_RECEIVE_BUFFER_LOCKED, and llState. |
|
unlocks the receive buffer, i.e. new packets can be receivedDefinition at line 2282 of file stackMasterSlaveSync.c. References LL_STATE_RECEIVE_BUFFER_LOCKED, LLSetDataToOld(), and llState. |
|
References LL_STATE_NEED_TO_SEND, and llState. |
|
prepares the LL header and instructs the rf layer to send the packet out (via flag). this function is non-blocking.
References LL_header_sendbuffer, LL_payload_send, LL_payload_send_length, LL_payload_sendbuffer, LL_payload_sendbuffer_length, LL_sequence_no, LL_STATE_NEED_TO_SEND, LL_tail_sendbuffer, LLCalcCRC16(), llState, RF_STATE_RUNNING, rfFieldStrength, and rfState. Referenced by ACLProcessControlMessages(), and ACLSendPacket(). |
|
References LL_STATE_PACKET_JUST_SENT, and llState. |
|
sets the "new data flag". Definition at line 2290 of file stackMasterSlaveSync.c. References LL_STATE_NEW_DATA, and llState. |
|
resets the "new data flag". it will be reset again by the rf layer if new data has arrived.Definition at line 2259 of file stackMasterSlaveSync.c. References LL_STATE_NEW_DATA, and llState. |
|
i guess this function is called at the end of the ISR before returning to "application level". it checks if the packet was finally sent and sets the correct ll status.Definition at line 2199 of file stackMasterSlaveSync.c. |
|
the "application level" part of the software. this method runs all tasks that are not time critical. Definition at line 3269 of file stackMasterSlaveSync.c. References ACLDataIsNew(), ACLLockReceiveBuffer(), ACLReleaseReceiveBuffer(), ACLStartUp(), ACLSubscribeAll(), DebugDumpReceivedAclPacket(), ParticleInit(), and RF_LOW_POWER_SLEEP_UNTIL_NEXT_SLOT. |
|
classic putchar function that is used to output a character to the "screen", in our case the serial port. Definition at line 745 of file stackMasterSlaveSync.c. Referenced by DebugDumpReceivedAclPacket(), DebugDumpRfState(), isr_timer0(), LLInit(), main(), and RFArbitrationBitDebug(). |
|
returns the number of seconds that the node should stay in deep sleep when it detects that it is alone. this value should be random between a minimum and a maximum number. suggested boundaries are 10 and 26. this function is only used when RF_ALONE_DEEP_SLEEP is defined.
References RF_NEW_RANDOM_BYTE. |
|
returns the number of slots that the node should stay alone mode (suppressing communication) when it detects that it is alone. this value should be random between a minimum and a maximum number. suggested boundaries are 333 and 867. this function is only used when RF_ALONE_DEEP_SLEEP is not defined.
References RF_NEW_RANDOM_BYTE. |
|
tries to get media access through the can arbitration process. the measured time between switching on the rf for sending and getting a pll lock is ~450 us, twice as long as the manual says (250 us).
References arbitrationBad, arbitrationGood, BIN, bit_test, RF_ARBITRATION_RSSI_THRESHOLD, RF_ARBITRATION_TIMER_TICS_OTHER_PERIODS, RF_NEW_RANDOM_BYTE, RF_RENDEZVOUS_ARBITRATION_START_HI, RF_SET_MODE_SLEEP, RFArbitrationBit(), and rssiSamples. Referenced by isr_timer0(). |
|
does the arbitration for one arbitration slice.
References BIN, RFSetModeReceive(), RFSetModeTransmit(), and WAIT_FOR_TIMER0_EXACT. Referenced by RFAloneTest(), and RFArbitration(). |
|
does the arbitration for one arbitration slice.
References BIN, putchar(), RFSetModeReceive(), and RFSetModeTransmit(). |
|
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 1844 of file stackMasterSlaveSync.c. References rfScramblerReg. Referenced by RFReceivePacket(). |
|
does a long search for a sync packet. this achieve by searching for a sync packet for a time which is a multiple m of slot length. m is at least the value specified by RF_MASTER_SEARCH_SLOTS_STARTUP plus a random value (0-255). the random part is added to ensure that if a master gives up it's role not all slaves want to become master at the same time.
References periodDataSlot, and RFReceivePacket(). Referenced by isr_timer0(). |
|
sends the node into power-saving mode for 10-26 seconds. this is done by turning on the 32KHz clock, switching off the 14MHz clock and switching the core to the low frequency clock. the node stays in low freq mode for a random number of seconds and then switches back to high freq mode.
Referenced by isr_timer0(), and main(). |
|
does a master rival test. from time to time the master searches an entire sync period if he hears any other masters. if so, he gives up and turns into a slave.
References periodDataSlot, and RFReceivePacket(). |
|
the general function to receive a packet. the incoming packet is checked against the ACL subscription list. if the acl type in the RF Header does not match the subscriptions, the transceiver is powered off and 0 is returned. the packet contents is written into LL_header_receivebuffer and LL_payload_receivebuffer. if it matches the subscriptions, both are copied into LL_header_received and LL_payload_received and LL_payload_received_length is set to the correct length. the function tries not to block timer0 interrupt: when timer0 interrupt is enabled, the function not only aborts if timer2 overflows (after the time given by param timeOutPeriodData), but also if there are only 200us left till the next timer0 tick begins. this allows for a simple RFMasterRivalTest() function. uses timer2 which must be available! the function returns an unsigned short:
References ACL_SUBSCRIPTIONLIST_LENGTH, LL_header_receivebuffer, LL_header_received, LL_payload_receivebuffer, LL_payload_received, LL_tail_receivebuffer, LL_tail_received, LLCalcCRC16(), RF_PREAMBLE_LENGTH_RX, RF_RENDEZVOUS_DATA_PACKET_START_HI, RF_SET_MODE_SLEEP, RF_SLOT_500_US_LEFT, RF_SPI_RECEIVE_BYTE, RFDescramble(), RFSetModeReceive(), and WAIT_FOR_TIMER0_EXACT. Referenced by isr_timer0(), RFLongSearchForBeacon(), RFLongSearchForMaster(), RFMasterRivalTest(), and RFShortSearchForBeacon(). |
|
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 1829 of file stackMasterSlaveSync.c. References rfScramblerReg. Referenced by RFSendPacket(). |
|
faster version of the halRFSetRxTxOff function to start receiving prior execution of halRFSetRxTxOff() is required. Definition at line 1086 of file stackMasterSlaveSync.c. References RF_CALDATA, and RF_SETTINGS. |
|
faster version of the halRFSetRxTxOff function to start sending. does not set all values. prior execution of halRFSetRxTxOff() is required.Definition at line 1047 of file stackMasterSlaveSync.c. References RF_CALDATA, RF_SETTINGS, and rfFieldStrength. |
|
byte that holds the current rf state.
|
|
Initial value:
// X-tal frequency: 14.745600 MHz // RF frequency A: 871.042000 MHz Rx // RF frequency B: 871.042000 MHz Tx // RX Mode: Low side LO // Frequency separation: 64 kHz // Data rate: 76.8 kBaud // Data Format: NRZ // RF output power: -5 dBm // IF/RSSI: RSSI Enabled |
|
holds the value of the currently used field strength. the var is set by LLGetFieldStrength() and read by LLGetFieldStrength(). The upper nibble controls the high power array of the transmitter, the lower nibble the low power array. sensible values are: 00, 01, 02, .., 0F, 10, 20, 30, ..., F0. value output power consumption 0F -5db 27mA F0 3db 35mA |
|
current value of the scrambler register which is used to generate a dc-free code with limited run-length for rf transmission. Definition at line 403 of file stackMasterSlaveSync.c. |
|
this variable is increased in every slot. it is reset to zero on reception of an alone test signal or a data packet. once this var becomes bigger than RF_ALONE_TEST_FAILED_THRESHOLD, the master assumes to be alone.Definition at line 413 of file stackMasterSlaveSync.c. |
|
byte that holds the current rf state.
|
|
the average timer value on the master after sending the sync packet. this value is measured by the master and sent to the slave in the sync packet. the slave adjusts his timer to this value after receiving it.Definition at line 420 of file stackMasterSlaveSync.c. |