-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
296 lines (250 loc) · 6.92 KB
/
main.c
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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
#include <msp430.h>
#include "init/init.h"
#include "UART_communication/UART_communication.h"
#include "code_thesis_examples/thesis_example_code.h"
/*
* Created by: Yannick Daelemans
*
* This will test all the methods as discussed in the thesis.
* It will time all the methods and will send this through to a PC over UART.
*/
/*
* main.c
*/
char global_variable = 0b01010101;
unsigned int timer_begin;
unsigned int timer_end;
int main(void)
{
WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer
init_GPIO();
init_clocks();
init_communication();
init_timer();
return 0;
}
void __attribute__ ((noinline)) sending(unsigned int ID, unsigned int timer_begin, unsigned int timer_end){
unsigned int time;
time = timer_end - timer_begin;
send_data(0xFFFF);
send_data(ID);
send_data(timer_begin);
send_data(timer_end);
send_data(time);
send_data(0xFFFF);
}
/*
* Tester of all timings that need to be timed
*/
void __attribute__ ((optimize("-O0"))) SXT_AND_tester(int amount){
unsigned int ans;
int anss;
unsigned char chans;
signed char schans;
uint8_t bans;
int8_t sbans;
for(int i = 0; i < amount; i++){
timer_begin = TA0R;
ans = uintfun(15, 25);
timer_end = TA0R;
sending(1, timer_begin, timer_end);
timer_begin = TA0R;
anss = intfun(15, 25);
timer_end = TA0R;
sending(2, timer_begin, timer_end);
timer_begin = TA0R;
chans = uscfun('1', 'b');
timer_end = TA0R;
sending(3, timer_begin, timer_end);
timer_begin = TA0R;
schans = scfun(-12, 'b');
timer_end = TA0R;
sending(4, timer_begin, timer_end);
timer_begin = TA0R;
schans = cfun(12, 'b');
timer_end = TA0R;
sending(5, timer_begin, timer_end);
timer_begin = TA0R;
sbans = sint8fun(-12, 15);
timer_end = TA0R;
sending(6, timer_begin, timer_end);
timer_begin = TA0R;
bans = usint8fun(12, 15);
timer_end = TA0R;
sending(7, timer_begin, timer_end);
for(int i = 0; i < 30; i++){
__no_operation();
}
}
}
void __attribute__ ((optimize("-O0"))) constants(int amount){
unsigned int ans;
int anss;
unsigned char chans;
signed char schans;
uint8_t bans;
int8_t sbans;
for(int i = 0; i < amount; i++){
timer_begin = TA0R;
anss = function_no_constants();
timer_end = TA0R;
sending(8, timer_begin, timer_end);
timer_begin = TA0R;
anss = function_constants();
timer_end = TA0R;
sending(9, timer_begin, timer_end);
timer_begin = TA0R;
anss = add(10);
timer_end = TA0R;
sending(17, timer_begin, timer_end);
timer_begin = TA0R;
anss = addconst(10);
timer_end = TA0R;
sending(18, timer_begin, timer_end);
timer_begin = TA0R;
anss = examplefunction();
timer_end = TA0R;
sending(10, timer_begin, timer_end);
timer_begin = TA0R;
anss = examplefunctionpointer();
timer_end = TA0R;
sending(11, timer_begin, timer_end);
for(int i = 0; i < 30; i++){
__no_operation();
}
}
}
void __attribute__ ((optimize("-O0"))) unions(int amount){
unsigned int ans;
int anss;
unsigned char chans;
signed char schans;
uint8_t bans;
int8_t sbans;
for(int i = 0; i < amount; i++){
timer_begin = TA0R;
anss = conversion_union(12, 25);
timer_end = TA0R;
sending(12, timer_begin, timer_end);
timer_begin = TA0R;
anss = conversion_shift(22, 15);
timer_end = TA0R;
sending(13, timer_begin, timer_end);
for(int i = 0; i < 30; i++){
__no_operation();
}
}
}
void __attribute__ ((optimize("-O0"))) compare_to(int amount){
int anss;
for(int i = 0; i < amount; i++){
timer_begin = TA0R;
anss = compare_to_zero(25, 22);
timer_end = TA0R;
sending(19, timer_begin, timer_end);
timer_begin = TA0R;
anss = compare_to_reg(25, 22);
timer_end = TA0R;
sending(20, timer_begin, timer_end);
timer_begin = TA0R;
anss = compare_to_num(25, 22);
timer_end = TA0R;
sending(21, timer_begin, timer_end);
timer_begin = TA0R;
anss = not_compare_to_zero(25, 22);
timer_end = TA0R;
sending(22, timer_begin, timer_end);
timer_begin = TA0R;
anss = bigger_to_zero(25, 22);
timer_end = TA0R;
sending(23, timer_begin, timer_end);
timer_begin = TA0R;
anss = smaller_to_zero(-25, -22);
timer_end = TA0R;
sending(24, timer_begin, timer_end);
for(int i = 0; i < 30; i++){
__no_operation();
}
}
}
void __attribute__ ((optimize("-O0"))) loops(int amount){
unsigned int ans;
int anss;
unsigned char chans;
signed char schans;
uint8_t bans;
int8_t sbans;
for(int i = 0; i < amount; i++){
timer_begin = TA0R;
anss = while_function(12, 20, 22);
timer_end = TA0R;
sending(14, timer_begin, timer_end);
timer_begin = TA0R;
anss = while_function_0(22, -2, 15);
timer_end = TA0R;
sending(15, timer_begin, timer_end);
timer_begin = TA0R;
anss = while_function_const(18, 6);
timer_end = TA0R;
sending(16, timer_begin, timer_end);
for(int i = 0; i < 30; i++){
__no_operation();
}
}
}
void total_tester(int amount){
SXT_AND_tester(amount);
constants(amount);
unions(amount);
loops(amount);
compare_to(amount);
}
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=USCI_A1_VECTOR
__interrupt void USCI_A1_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(USCI_A1_VECTOR))) USCI_A1_ISR (void)
#else
#error Compiler not supported!
#endif
{
switch(__even_in_range(UCA1IV, USCI_UART_UCTXCPTIFG))
{
case USCI_NONE: break;
case USCI_UART_UCRXIFG:
while(!(UCA1IFG&UCTXIFG));
UCA1IFG &= ~UCRXIFG;
char read_buf = UCA1RXBUF;
if(read_buf == '1'){
//testing_clock();
}
if(read_buf == 'S'){
SXT_AND_tester(100);
}
__no_operation();
if(read_buf == 'C'){
constants(100);
}
__no_operation();
if(read_buf == 'U'){
unions(100);
}
__no_operation();
if(read_buf == 'W'){
loops(100);
}
__no_operation();
if(read_buf == '0'){
compare_to(100);
}
__no_operation();
if(read_buf == 'T'){
total_tester(100);
}
__no_operation();
break;
case USCI_UART_UCTXIFG: break;
case USCI_UART_UCSTTIFG: break;
case USCI_UART_UCTXCPTIFG: break;
}
}