-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArbitrateState.c
More file actions
78 lines (72 loc) · 1.75 KB
/
ArbitrateState.c
File metadata and controls
78 lines (72 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include "EPC_STATE.h"
void ArbitrateStateFunction(){
GLED=LED_ON;
halRFSetRxTxOff(RF_RX, &RF_SETTINGS, &RF_CALDATA); //¥´¶}RX
halRandomNumberGen((byte*)&RN_16,2);
while(1){
//±µ¦¬¸ê®Æ
ReciveByte = halRFReceivePacket(10,&buffer,64,0,CC1010EB_CLKFREQ) ;
if(ReciveByte==0)continue;
command = buffer[0] ;
//¤À¿ë«ü¥O
switch(command){
case SINGLE_SELECT_HEADER:
AnswerToSingleSelect((MySelect*)&buffer);
return;
case SELECT_HEADER :
AnswerToSelect((MySelect*)&buffer);
return;
case QUERY_HEADER :
AnswerToQuery((MyQuery*)&buffer) ;
return;
case QUERY_REP_HEADER :
if( SlotCounter==0x0000 ){
/*if slot=0 roll over 7fffh ,else decrement */
SlotCounter = 0x7FFF ;
/*if slot=0 go to Reply,reply new RN16 */
halRFSetRxTxOff(RF_TX, &RF_SETTINGS, &RF_CALDATA);
halRFSendPacket(PREAMBLE_BYTE_COUNT,(byte*)&RN_16,2);
halRFSetRxTxOff(RF_RX, &RF_SETTINGS, &RF_CALDATA);
state=ReplyState;
return ;
}else{
SlotCounter--;
/*if slot<>0 remain in Arbitrate Reply None*/
continue;
//mainFunctionPointer=&ArbitrateStateFunction;
//return ;
}
break;
case QUERY_ADJUST_HEADER :
QueryAdjustCommand=(MyQueryAdjust*)&buffer;
switch(QueryAdjustCommand->UpDn){
case 0x06:
BackupQ++;
break;
case 0x03:
if(BackupQ>=2){
BackupQ--;
}
break;
default:
break;
}
//halRandomNumberGen((byte*)&SlotCounter ,2 );
SlotCounter=GeneratorSlotCounter(BackupQ);
if(SlotCounter != 0)
{
state=ArbitrateState;
return ;
}
else
{
state=ReplyState;
return ;
}
break;
default:
state=ArbitrateState; //Remain in Arbitrate
return ;
}
}
}