-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcpu_time_profiling2.patch
More file actions
229 lines (214 loc) · 6.35 KB
/
cpu_time_profiling2.patch
File metadata and controls
229 lines (214 loc) · 6.35 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
diff --git a/drivers/nrf24l01.cpp b/drivers/nrf24l01.cpp
index 4c9a7f4..8b17e79 100644
--- a/drivers/nrf24l01.cpp
+++ b/drivers/nrf24l01.cpp
@@ -92,15 +92,15 @@ void Nrf24l01::setMode(Mode mode)
delayUs(1);
}
- if(this->mode==SLEEP)
- {
- // Wait 1.5ms if old mode was SLEEP
- // Note that the time to send the SPI commands is around 100us resulting
- // in this code taking around 1.6ms
- AuxiliaryTimer& timer=AuxiliaryTimer::instance();
- timer.initTimeoutTimer(static_cast<int>(0.0015f*16384+0.5f));
- timer.waitForTimeout();
- }
+// if(this->mode==SLEEP)
+// {
+// // Wait 1.5ms if old mode was SLEEP
+// // Note that the time to send the SPI commands is around 100us resulting
+// // in this code taking around 1.6ms
+// AuxiliaryTimer& timer=AuxiliaryTimer::instance();
+// timer.initTimeoutTimer(static_cast<int>(0.0015f*16384+0.5f));
+// timer.waitForTimeout();
+// }
// if(mode==RX) nrf::ce::high(); //Start receiving right now if RX
this->mode=mode;
diff --git a/drivers/rtc.cpp b/drivers/rtc.cpp
index e279033..362133d 100644
--- a/drivers/rtc.cpp
+++ b/drivers/rtc.cpp
@@ -183,9 +183,16 @@ void AuxiliaryTimer::initTimeoutTimer(unsigned short ctr)
TIM7->CR1 |= TIM_CR1_CEN;
}
+//--------------
+typedef Gpio<GPIOC_BASE,8> fixme;
+//--------------
+
bool AuxiliaryTimer::waitForPacketOrTimeout()
{
FastInterruptDisableLock dLock;
+
+ fixme::low();
+
while(packetReceived==false && timeout==false)
{
timeoutWaiting=Thread::IRQgetCurrentThread();
@@ -196,12 +203,18 @@ bool AuxiliaryTimer::waitForPacketOrTimeout()
}
}
packetReceived=false;
+
+ fixme::high();
+
return timeout;
}
void AuxiliaryTimer::waitForTimeout()
{
FastInterruptDisableLock dLock;
+
+ fixme::low();
+
while(timeout==false)
{
timeoutWaiting=Thread::IRQgetCurrentThread();
@@ -211,6 +224,9 @@ void AuxiliaryTimer::waitForTimeout()
Thread::yield();
}
}
+
+ fixme::high();
+
}
void AuxiliaryTimer::stopTimeoutTimer()
@@ -290,6 +306,9 @@ void Rtc::setRelativeWakeup(unsigned int value)
void Rtc::wait()
{
FastInterruptDisableLock dLock;
+
+ fixme::low();
+
while(rtcInterrupt==false)
{
waiting=Thread::IRQgetCurrentThread();
@@ -299,6 +318,9 @@ void Rtc::wait()
Thread::yield();
}
}
+
+ fixme::high();
+
}
void Rtc::setAbsoluteWakeupSleep(unsigned int value)
@@ -313,7 +335,9 @@ void Rtc::sleep()
{
FastInterruptDisableLock dLock;
if(rtcInterrupt) return;
-
+
+ fixme::low();
+
sleepAgain:
PWR->CR |= PWR_CR_LPDS;
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
@@ -364,6 +388,9 @@ void Rtc::sleep()
RCC->CR |= RCC_CR_PLLON;
while((RCC->CR & RCC_CR_PLLRDY)==0) ;
+
+ fixme::high();
+
RCC->CFGR &= ~RCC_CFGR_SW;
RCC->CFGR |= RCC_CFGR_SW_PLL;
while((RCC->CFGR & RCC_CFGR_SWS)!=0x08) ;
@@ -467,6 +494,9 @@ void VHT::setAbsoluteWakeupWait(unsigned int value)
void VHT::wait()
{
FastInterruptDisableLock dLock;
+
+ fixme::low();
+
TIM3->DIER |= TIM_DIER_CC1IE;
vhtWaiting=Thread::IRQgetCurrentThread();
while(vhtWaiting)
@@ -478,6 +508,8 @@ void VHT::wait()
}
}
TIM3->DIER &=~ TIM_DIER_CC1IE;
+
+ fixme::high();
}
void VHT::setAbsoluteWakeupSleep(unsigned int value)
diff --git a/experiment.conf b/experiment.conf
index 8d7e23c..82061bc 100644
--- a/experiment.conf
+++ b/experiment.conf
@@ -5,7 +5,7 @@
# General config parameters
experiment_name="test"
experiment_time="60*24*60*60"
-sync_period="60"
+sync_period="5"
relative_clock="0"
interactive_rootnode="0"
event_timestamping="0"
diff --git a/flopsync2.cpp b/flopsync2.cpp
index 99b1773..e00e6f5 100644
--- a/flopsync2.cpp
+++ b/flopsync2.cpp
@@ -144,9 +144,9 @@ bool FlooderSyncNode::synchronize()
}
clockCorrection=r.first;
receiverWindow=r.second;
-
- printf("e=%d u=%d w=%d%s\n",measuredFrameStart-computedFrameStart,
- clockCorrection,receiverWindow,timeout ? " (miss)" : "");
+
+// printf("e=%d u=%d w=%d%s\n",measuredFrameStart-computedFrameStart,
+// clockCorrection,receiverWindow,timeout ? " (miss)" : "");
//Correct frame start considering hops
measuredFrameStart-=hop*retransmitDelta;
diff --git a/flopsync2.h b/flopsync2.h
index daa81d6..3c0be4b 100644
--- a/flopsync2.h
+++ b/flopsync2.h
@@ -290,7 +290,7 @@ private:
unsigned char count;
unsigned char var;
- static const int numSamples=64; //Number of samples for variance compuation
+ static const int numSamples=32; //Number of samples for variance compuation
static const int fp=64; //Fixed point, log2(fp) bits are the decimal part
};
@@ -348,7 +348,7 @@ private:
unsigned char count;
unsigned char var;
- static const int numSamples=64; //Number of samples for variance compuation
+ static const int numSamples=32; //Number of samples for variance compuation
static const int fp=64; //Fixed point, log2(fp) bits are the decimal part
};
diff --git a/flopsync_dynamic_comb.cpp b/flopsync_dynamic_comb.cpp
index d4273a8..7e2e0f4 100644
--- a/flopsync_dynamic_comb.cpp
+++ b/flopsync_dynamic_comb.cpp
@@ -75,6 +75,7 @@ int main()
{
if(flooder.synchronize()) flooder.resynchronize();
+#if 0
MonotonicClock clock(flopsync,flooder);
unsigned int start=node*combSpacing;
for(unsigned int i=start;i<nominalPeriod-combSpacing/2;i+=3*combSpacing)
@@ -106,5 +107,6 @@ int main()
nrf.endWritePacket();
nrf.setMode(Nrf24l01::SLEEP);
}
+#endif
}
}
diff --git a/flopsync_rootnode_comb.cpp b/flopsync_rootnode_comb.cpp
index 1f67b81..eaefd84 100644
--- a/flopsync_rootnode_comb.cpp
+++ b/flopsync_rootnode_comb.cpp
@@ -57,6 +57,7 @@ int main()
{
flooder.synchronize();
+#if 0
puts("----");
unsigned int frameStart=flooder.getMeasuredFrameStart();
for(unsigned int i=combSpacing,j=0;i<nominalPeriod-combSpacing/2;i+=combSpacing,j++)
@@ -91,5 +92,6 @@ int main()
printf("node%d.e=%d\n",(j % 3)+1,measuredTime-(frameStart+i));
}
}
+#endif
}
}