summaryrefslogtreecommitdiff
path: root/cesar
diff options
context:
space:
mode:
authorlaranjeiro2010-05-17 09:08:13 +0000
committerlaranjeiro2010-05-17 09:08:13 +0000
commit502fd4b44320ff0760eadeb6030241c73925fe10 (patch)
tree7336e7545a55b27bec8a1b16cb0b746d89cfc257 /cesar
parentcd845de8614f39d44d3c518ec04591e3bf8e4134 (diff)
cesar/bsu/ntb: add NTB sub module, refs #1244
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@7017 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar')
-rw-r--r--cesar/bsu/ntb/Module1
-rw-r--r--cesar/bsu/ntb/src/ntb.c131
-rw-r--r--cesar/bsu/ntb/test/utest/Makefile25
-rw-r--r--cesar/bsu/ntb/test/utest/beacon_bts.dat819
-rw-r--r--cesar/bsu/ntb/test/utest/dat2chead.py41
-rw-r--r--cesar/bsu/ntb/test/utest/freq_clk.sci48
-rw-r--r--cesar/bsu/ntb/test/utest/ntb_sync_intellon_sniffed.sci106
-rw-r--r--cesar/bsu/ntb/test/utest/src/ntb.c54
-rw-r--r--cesar/bsu/ntb/test/utest/src/ntb_compute.c102
-rw-r--r--cesar/bsu/ntb/test/utest/src/tests.c28
-rw-r--r--cesar/bsu/ntb/test/utest/sta_sys_date_preamble.dat819
-rw-r--r--cesar/bsu/ntb/test/utest/tests.h55
12 files changed, 2229 insertions, 0 deletions
diff --git a/cesar/bsu/ntb/Module b/cesar/bsu/ntb/Module
new file mode 100644
index 0000000000..330e1813c7
--- /dev/null
+++ b/cesar/bsu/ntb/Module
@@ -0,0 +1 @@
+SOURCES:=ntb.c
diff --git a/cesar/bsu/ntb/src/ntb.c b/cesar/bsu/ntb/src/ntb.c
new file mode 100644
index 0000000000..7db51c2178
--- /dev/null
+++ b/cesar/bsu/ntb/src/ntb.c
@@ -0,0 +1,131 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2010 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file bsu/ntb/src/ntb.c
+ * \brief NTB clock synchronization.
+ * \ingroup bsu_ntb
+ */
+#include "common/std.h"
+#include "lib/fixed.h"
+#include "bsu/ntb/ntb.h"
+#include "hal/phy/spoc/spoc.h"
+#include <string.h>
+
+#define BSU_NTB_WEIGHT 0.25
+#define BSU_NTB_WF BSU_NTB_WEIGHT
+#define BSU_NTB_WO BSU_NTB_WEIGHT
+
+#define BSU_NTB_FE_PPM(fe) \
+ ((double) ((fe) * 1000000.0))
+
+/** Compute the frequency error.
+ * \param ctx module context.
+ * \param freq_error last frequency error computed.
+ * \param bts the last beacon time stamp received in the last beacon.
+ * \param preamble_sysdate the system date preamble corresponding to the
+ * last beacon received.
+ */
+static void
+bsu_ntb_frequency_error (bsu_ntb_sync_t *ctx, double freq_err, u32 bts,
+ u32 preamble_sysdate)
+{
+ dbg_assert (ctx);
+ if (ctx->init)
+ {
+ /* If it is the second shoot. FIXME: Rollover not handled.*/
+ if (ctx->beacon_nb == 2)
+ {
+ ctx->fe = (double) (bts - ctx->bts)
+ / (double) (preamble_sysdate - ctx->preamble_sysdate) - 1;
+ }
+ else
+ {
+ ctx->fe = (double) freq_err + BSU_NTB_WF
+ * ((double) (bts - ctx->bts)
+ / (double) (preamble_sysdate - ctx->preamble_sysdate)
+ - 1 - freq_err);
+ }
+ }
+}
+
+/** Compute the current offset from the NTB clock and the phy clock.
+ * \param ctx module context.
+ * \param phy the phy context.
+ * \param freq_error last frequency error computed.
+ * \param bts the last beacon time stamp received in the last beacon.
+ * \param preamble_sysdate the system date preamble corresponding to the
+ * last beacon received.
+ */
+static s32
+bsu_ntb_offset (bsu_ntb_sync_t *ctx, phy_t *phy, double freq_error,
+ u32 bts, u32 preamble_stadate)
+{
+ s32 offset;
+ u32 delay_systck;
+ dbg_assert (ctx);
+ dbg_assert (phy);
+ /* Get the delay in system ticks. */
+ delay_systck = phy_sysdate (phy) - preamble_stadate;
+ if (ctx->init)
+ {
+ offset = (s32) (bts - preamble_stadate)
+ + (s32) ((ctx->fe * delay_systck)
+ - (freq_error * delay_systck));
+ }
+ else
+ offset = (s32) (bts - preamble_stadate);
+ return offset;
+}
+
+void
+bsu_ntb_init (bsu_ntb_sync_t *ctx)
+{
+ dbg_assert (ctx);
+ memset (ctx, 0, sizeof (bsu_ntb_sync_t));
+}
+
+void
+bsu_ntb_uninit (bsu_ntb_sync_t *ctx)
+{
+ dbg_assert (ctx);
+}
+
+void
+bsu_ntb_clk_sync (bsu_ntb_sync_t * ctx, phy_t *phy, u32 beacon_bts,
+ u32 beacon_sys_ltmr, u32 beacon_sta_ltmr)
+{
+ double freq_error;
+ dbg_assert (ctx);
+ dbg_assert (phy);
+ ctx->beacon_nb ++;
+ freq_error = ctx->fe;
+ bsu_ntb_frequency_error (ctx, freq_error, beacon_bts, beacon_sys_ltmr);
+ ctx->ntb_offset_tck= bsu_ntb_offset (ctx, phy, freq_error, beacon_bts,
+ beacon_sta_ltmr);
+ ctx->preamble_sysdate = beacon_sys_ltmr;
+ ctx->preamble_stadate = beacon_sta_ltmr;
+ ctx->bts = beacon_bts;
+ ctx->init = true;
+}
+
+void
+bsu_ntb_clock_configure (bsu_ntb_sync_t *ctx, mac_config_t *mac_config,
+ phy_t *phy)
+{
+ dbg_assert (ctx);
+ /* Set the current NTB offset in mac config. */
+ mac_config->ntb_offset_tck = ctx->ntb_offset_tck;
+ /* Compute the new numerator. */
+ u32 numerator = BSU_NTB_FE_PPM (ctx->fe + 1.0) + 0.5;
+ if (numerator != ctx->sta_numerator)
+ {
+ /* Update the numerator value in the PRATIC config ! */
+ phy_clock_set_numerator (phy, numerator);
+ ctx->sta_numerator = numerator;
+ }
+}
diff --git a/cesar/bsu/ntb/test/utest/Makefile b/cesar/bsu/ntb/test/utest/Makefile
new file mode 100644
index 0000000000..c0fb8dfda1
--- /dev/null
+++ b/cesar/bsu/ntb/test/utest/Makefile
@@ -0,0 +1,25 @@
+BASE = ../../../..
+
+HOST_PROGRAMS = ntb
+ntb_SOURCES = ntb.c tests.c ntb_compute.c
+ntb_MODULES = lib bsu/ntb mac/common
+
+SCI=ntb_sync_intellon_sniffed.sci
+DATFILE=sta_sys_date_preamble.dat beacon_bts.dat
+GENERATED=$(OBJ_DIR)/offset.dat $(OBJ_DIR)/freqerr.dat \
+ $(OBJ_DIR)/preamble.dat $(OBJ_DIR)/numerator.dat
+HEADERS=$(DATFILE:%.dat=$(OBJ_INC_DIR)/%.h) \
+ $(GENERATED:$(OBJ_DIR)/%.dat=$(OBJ_INC_DIR)/%.h)
+
+COMPILE_DEPS += $(HEADERS)
+CLEAN_FILES+=$(HEADERS) $(GENERATED)
+
+include $(BASE)/common/make/top.mk
+
+$(GENERATED): $(SCI) freq_clk.sci $(OBJ_DIR_STAMP)
+ scilab -nw -f $<
+
+$(OBJ_INC_DIR)/%.h: %.dat $(OBJ_INC_DIR_STAMP)
+ python dat2chead.py $< > $@
+$(OBJ_INC_DIR)/%.h: $(OBJ_DIR)/%.dat $(OBJ_INC_DIR_STAMP)
+ python dat2chead.py $< > $@
diff --git a/cesar/bsu/ntb/test/utest/beacon_bts.dat b/cesar/bsu/ntb/test/utest/beacon_bts.dat
new file mode 100644
index 0000000000..36bbe6f3c2
--- /dev/null
+++ b/cesar/bsu/ntb/test/utest/beacon_bts.dat
@@ -0,0 +1,819 @@
+747440576
+748436292
+749436912
+750436653
+751435989
+752440811
+753440971
+754438007
+755436071
+756440867
+757435481
+758435254
+759460683
+760434935
+761438269
+763434690
+764436793
+765438715
+766439392
+767439279
+768435548
+769434727
+770433931
+771437967
+772433618
+773437940
+775434837
+776436445
+777435601
+778436300
+779437977
+780434140
+781436981
+782436753
+783432512
+784435534
+785434748
+786432169
+787432551
+788433314
+790434921
+791432958
+792431334
+793436538
+794431202
+795431061
+796430817
+797433268
+798433100
+800434480
+801430981
+802430662
+803431488
+804434793
+805432179
+806429619
+807431770
+809430786
+810429069
+811428903
+812433730
+813432991
+814432679
+815433398
+816428218
+818429494
+819427868
+820430859
+821428290
+822431631
+823428813
+824427119
+825431350
+826428381
+827426836
+828426625
+829429887
+830429613
+831426821
+832426088
+833426753
+834426471
+835425756
+836429656
+837426191
+838426914
+839425247
+840426459
+841425144
+842427166
+843429820
+844428652
+845424583
+846429393
+847428300
+848429017
+849424053
+851428621
+852427540
+853425859
+854425513
+855428037
+856426940
+857423438
+858425856
+859424823
+860422245
+861426416
+862422034
+863424233
+864423020
+865421645
+866425558
+867424459
+868425121
+869426083
+870425773
+871423875
+872420691
+873420951
+874421248
+876425871
+877420747
+878421398
+879422746
+880420259
+882419934
+883419131
+884420626
+885420690
+886422919
+887418442
+888420848
+889421816
+890420618
+891417835
+892421106
+893419368
+894417277
+895417110
+896416407
+897416396
+898419303
+899417360
+900417048
+901416623
+902418632
+904417284
+905414994
+906417936
+907417732
+908417449
+909417561
+910416348
+911415304
+912416818
+913418625
+914415647
+915413690
+916415266
+917413461
+918414070
+920414526
+921415521
+922411980
+923415050
+924414841
+925411587
+926412831
+928412379
+929415150
+930413033
+931415630
+932415361
+933410984
+934412490
+935409973
+936413015
+937414873
+938411904
+939410841
+940409148
+941412498
+942408968
+943408672
+944413628
+945409223
+946408471
+948408023
+949408145
+950410190
+951409201
+952407497
+953408071
+954411405
+955407689
+956410208
+957407494
+958408166
+959407116
+960407748
+962407558
+963405990
+964405781
+965409060
+966407946
+967405397
+968409292
+970409125
+971409005
+972408793
+973404699
+974404950
+975408388
+976409105
+977404081
+978407918
+979403659
+981403527
+982407347
+983403040
+984403369
+985403419
+986402684
+987407474
+988407243
+989404668
+990402602
+991405189
+992404051
+993401789
+994401531
+995401392
+996406271
+997401290
+998404247
+999402330
+1001404957
+1002405559
+1003405475
+1004401637
+1005400840
+1006400099
+1007404105
+1008399733
+1009404917
+1010403758
+1011403716
+1012400716
+1013402649
+1014401545
+1015402342
+1016400175
+1017403120
+1018399362
+1020399902
+1021401905
+1022399836
+1023403327
+1024398088
+1025398216
+1026398084
+1027397875
+1028400061
+1029400130
+1030400753
+1031399826
+1033397853
+1034397685
+1035398430
+1036401850
+1037403069
+1038401677
+1039398823
+1040397730
+1041397863
+1043396025
+1044400864
+1045400027
+1046399900
+1047395411
+1048397753
+1049396966
+1050395245
+1051398447
+1053399178
+1054396296
+1055394748
+1056398732
+1057396081
+1058394462
+1059394357
+1060397352
+1061397536
+1062394591
+1064394341
+1065394429
+1066393773
+1067397765
+1068394879
+1069393590
+1070394828
+1071393324
+1072397266
+1073395635
+1074398097
+1075393059
+1076397968
+1077397168
+1079392786
+1080393138
+1081397834
+1082396722
+1083394871
+1084394711
+1085396670
+1086392962
+1087395480
+1088394470
+1089392292
+1090396219
+1091392061
+1093393458
+1094391856
+1095395892
+1096394904
+1097395867
+1098396568
+1099396563
+1102391254
+1103391188
+1104391586
+1105396176
+1106391017
+1107391368
+1108393063
+1109390844
+1110390619
+1111390579
+1112390893
+1113392801
+1114393481
+1115395176
+1116390585
+1117393360
+1118390445
+1119393947
+1121390359
+1122390145
+1123389502
+1124392547
+1125390887
+1126390692
+1127389717
+1128392228
+1129390560
+1130391256
+1131388900
+1132391938
+1133392049
+1134391875
+1135391783
+1136390765
+1137389969
+1139393321
+1140390440
+1141388865
+1142390409
+1143388553
+1144389331
+1147390980
+1149389202
+1150390802
+1151390801
+1152387401
+1153388944
+1154390589
+1155388722
+1156391314
+1157389665
+1158392163
+1160387486
+1161389459
+1162386885
+1163390074
+1164391859
+1166389074
+1167391605
+1168387882
+1169389812
+1170386746
+1171386390
+1172391192
+1173386320
+1174386107
+1175386014
+1176388220
+1177387380
+1178385765
+1179389817
+1181386191
+1182388641
+1184386559
+1185385790
+1186386503
+1187386390
+1188386200
+1189384905
+1190384644
+1191387843
+1192386726
+1193385958
+1195388300
+1196384046
+1197388227
+1198388060
+1199387930
+1201383838
+1202384059
+1203387486
+1204388309
+1205383385
+1206387338
+1207383074
+1208387915
+1209383012
+1211382761
+1212386676
+1213382709
+1214383042
+1215382929
+1217387437
+1218387191
+1219384439
+1220382495
+1221385361
+1222384212
+1224381668
+1225385051
+1226383102
+1227381516
+1228383706
+1229385649
+1230386371
+1231386280
+1232382575
+1233381779
+1234381416
+1235385098
+1236380865
+1237386010
+1238384919
+1239384807
+1240381960
+1241383919
+1242382794
+1243383596
+1244385266
+1245381806
+1246384288
+1247384169
+1248379853
+1249383195
+1250382077
+1251379691
+1252379988
+1253380991
+1254380801
+1255379223
+1256384101
+1257379163
+1258378954
+1259378827
+1260378667
+1261381134
+1262380893
+1263381648
+1264380581
+1265382443
+1266378696
+1267378536
+1268379261
+1269382911
+1270380043
+1271377638
+1272382433
+1273378939
+1274378684
+1275377116
+1276381976
+1277381042
+1278381823
+1279376696
+1280378855
+1281378068
+1282376325
+1283379481
+1284376633
+1285380457
+1286381005
+1288375640
+1289379854
+1290377836
+1291376885
+1292375211
+1293375344
+1294378363
+1295378252
+1296375431
+1297374993
+1298375248
+1299375168
+1300374443
+1301378725
+1302375617
+1303374246
+1304375443
+1306375403
+1307376191
+1309377907
+1310373543
+1311378551
+1312377374
+1313378404
+1314455401
+1315378056
+1316377020
+1317375323
+1318375092
+1319372652
+1320376581
+1321372644
+1322374691
+1323372205
+1324376157
+1325375391
+1326376959
+1328371580
+1329371729
+1331371949
+1332376170
+1334371040
+1335371474
+1336373073
+1337370857
+1338370583
+1339370506
+1340372459
+1341372795
+1342373378
+1343375054
+1344370422
+1345373218
+1346373907
+1347372824
+1348369975
+1349373659
+1350371645
+1351369764
+1352369504
+1353369131
+1354368915
+1355371959
+1356370091
+1357370164
+1358369009
+1360369626
+1361370703
+1362368081
+1363371218
+1364371056
+1365371008
+1366370095
+1367369031
+1368370632
+1369372583
+1370369707
+1371367859
+1372369381
+1373368666
+1374370252
+1375369261
+1376369990
+1377366871
+1378368117
+1379369833
+1380369633
+1381366609
+1382367737
+1383369482
+1384367524
+1385370396
+1386368417
+1387370926
+1388370788
+1389366447
+1390368026
+1392370530
+1393367992
+1394370554
+1395366883
+1396365387
+1397368712
+1398365294
+1399367584
+1400365066
+1401370345
+1402365631
+1403365016
+1404369029
+1405365029
+1406364912
+1407367155
+1409364847
+1410365133
+1411368709
+1412364409
+1413365146
+1414367611
+1415364854
+1416365644
+1417364871
+1418365592
+1419365521
+1420365298
+1421367154
+1422366164
+1423363757
+1424367757
+1425363767
+1426367711
+1428398917
+1429363492
+1430363818
+1431367397
+1432368055
+1433363250
+1435362922
+1436367866
+1437362942
+1438362748
+1439362670
+1440366613
+1441362684
+1442362997
+1444362212
+1445367412
+1446367236
+1447364392
+1448362424
+1449365320
+1450364179
+1451361867
+1452361606
+1453361790
+1454366626
+1455361474
+1456364613
+1457362967
+1458361353
+1459363607
+1460365231
+1461366291
+1462362511
+1463361539
+1464360845
+1465360888
+1466365814
+1468364669
+1469362145
+1470363689
+1471362760
+1472363495
+1473361870
+1474364355
+1475364305
+1476360073
+1477363381
+1480361191
+1482363031
+1483361127
+1484359584
+1485364789
+1486359647
+1487359556
+1489359619
+1490361767
+1491361787
+1492362499
+1493361830
+1494363484
+1495359827
+1496359718
+1497360802
+1498364210
+1500359026
+1501364332
+1502361361
+1503360429
+1504360364
+1505359179
+1506359028
+1507363954
+1508362962
+1509363163
+1510363935
+1511358931
+1512361104
+1513360416
+1514358838
+1515361995
+1516359237
+1517362990
+1518363765
+1519360137
+1520358590
+1521363014
+1522361009
+1523358646
+1524358561
+1525362071
+1526361939
+1527359151
+1528358542
+1529358793
+1530362770
+1531359187
+1532359915
+1533358743
+1534360066
+1535358598
+1536362668
+1537360198
+1538363627
+1539362717
+1540358521
+1541362910
+1542363670
+1543358604
+1544359049
+1545363809
+1546362826
+1547360950
+1548360883
+1549363849
+1551359220
+1552361827
+1553361154
+1554358737
+1555362785
+1556358656
+1557361217
+1558360171
+1559358780
+1561362252
+1562362945
+1563363901
+1564363824
+1565362323
+1567358983
+1568358927
+1569359820
+1570364164
+1571364223
+1572359107
+1573361725
+1574359296
+1575359292
+1576359841
+1577361911
+1578361800
+1579362735
+1580364495
+1581360354
+1582362888
+1583363774
+1584362878
+1585360561
+1587362286
+1588360457
+1589360827
+1590360044
+1591363531
+1592361647
+1593361957
+1594361048
+1595363715
+1596361965
+1597363168
+1598360775
+1599364032
+1600364030
+1601364399
+1602363379
+1603362568
+1605366493
+1606361981
+1608361954
+1609363181
+1610364931
+1611364127
+1613362101
+1614363440
+1615365280
+1616365364
+1617362433
+1618363803
+1619365681
+1620362999
+1621365198
+1624367889
+1625365491
+1626368211
+1627364666
+1628363195
+1629366777
+1630363543
+1631365920
+1632363566
diff --git a/cesar/bsu/ntb/test/utest/dat2chead.py b/cesar/bsu/ntb/test/utest/dat2chead.py
new file mode 100644
index 0000000000..87268b6f35
--- /dev/null
+++ b/cesar/bsu/ntb/test/utest/dat2chead.py
@@ -0,0 +1,41 @@
+#!/usr/bin/python
+
+import sys
+
+# Load the file.
+file = open (sys.argv[1], 'r')
+data = file.read()
+file.close()
+
+name = sys.argv[1].split('.')[0]
+
+double = data.find ('E')
+signed = data.find ('-')
+
+data = data.replace(' ', '')
+data = data.replace('E', 'e')
+data = data.split('\n')
+# Remove the empty values of the table.
+data = data[0:len(data)-1]
+
+# Create the C table.
+name = name.replace ('obj/', '')
+string = "#ifndef __" + name + "__\n"
+string += "#define __" + name + "__\n"
+
+if double != -1:
+ string += "double " + name + " [] = {"
+elif signed == -1:
+ string += "u32 " + name + " [] = {"
+else:
+ string += "s32 " + name + " [] = {"
+
+for i in range (0, len(data)):
+ if i != 0 and i % 5 == 0:
+ string += '\n '
+ string += " " + data[i] + ","
+
+string = string[0:len (string) -1] + "};"
+
+string += "\n#endif /*__" + name + "__*/"
+print string
diff --git a/cesar/bsu/ntb/test/utest/freq_clk.sci b/cesar/bsu/ntb/test/utest/freq_clk.sci
new file mode 100644
index 0000000000..356f2e5d9b
--- /dev/null
+++ b/cesar/bsu/ntb/test/utest/freq_clk.sci
@@ -0,0 +1,48 @@
+// Simulation of two stations with differents frequency clocks.
+
+// Compute the frequency error.
+// i the value of the current iteration.
+// bts0 the bts n - 1
+// bts1 the bts n
+// preamble_sysdate0 the preamble sysdate n - 1
+// preamble_sysdate1 the preamble sysdate n
+// wf the weight frequency to compute the next frequency error.
+function [fe] = f_freqError (i, fe, bts0, bts1, preamble_sysdate0, preamble_sysdate1, wf)
+ if i < 3
+ fe = (bts1 - bts0) / (preamble_sysdate1 - preamble_sysdate0) - 1;
+ else
+ fe = fe + wf* ((bts1 - bts0) / (preamble_sysdate1 - preamble_sysdate0) - 1 - fe);
+ end
+ return fe
+endfunction
+
+// Compute the preamble date
+// preamble_date0 the preamble_date n-1
+// preambule_sysdate0 the preambule_sysdate n-1
+// preambule_sysdate1 the preambule_sysdate n
+// fe0 frequency error n - 2
+// fe1 frequency error n - 1
+// delay_systck the delay after the one the frequency is corrected.
+function [preamble_date] = f_preamble_date (preamble_date0, preamble_sysdate0, preamble_sysdate1, fe0, fe1, delay_systck)
+ preamble_date = preamble_date0 + delay_systck * (1 + fe0) + (preamble_sysdate1 - preamble_sysdate0 - delay_systck) * (1 + fe1);
+ return int(preamble_date);
+endfunction
+
+// Compute the ntb date.
+// premable_date the preamble date computed.
+// offset_tck the computed offset n - 1
+function [ntb] = f_ntb_date (preamble_date, offset_tck)
+ ntb = (preamble_date + offset_tck);
+ return int(ntb);
+endfunction
+
+// Compute the offset between the phy_date and the ntb_date.
+// bts the last bts received in the beacon.
+// preambule_date the preambule n
+// fe0 frequency error n - 1
+// fe1 frequency error n
+// delay_systck the delay to store the frequency in the hardware.
+function [offset] = f_offset (bts, preamble_date, fe0, fe1, delay_systck)
+ offset = (bts - preamble_date) + fe1 * delay_systck - fe0 * delay_systck;
+ return int(offset);
+endfunction
diff --git a/cesar/bsu/ntb/test/utest/ntb_sync_intellon_sniffed.sci b/cesar/bsu/ntb/test/utest/ntb_sync_intellon_sniffed.sci
new file mode 100644
index 0000000000..fee77a29fb
--- /dev/null
+++ b/cesar/bsu/ntb/test/utest/ntb_sync_intellon_sniffed.sci
@@ -0,0 +1,106 @@
+// Sniffed the bts from the intellon modem to simulate a NTB clock
+// synchronisation.
+
+clear;
+args = sciargs();
+
+gui = 1;
+[y, arglen] = size (args)
+for i=1:arglen
+ if args(i) == '-nw'
+ gui = 0
+ end
+end
+
+// Get the function tocompute the data.
+getf ('freq_clk.sci');
+
+// Open the BTS measure from the gidel front of the intellon station.
+fd = file ('open', 'beacon_bts.dat', 'unknown');
+if fd < 0
+ exit ();
+end
+bts = read (fd, -1, 1);
+file ('close', fd);
+bts = bts';
+
+// Open the sysdata measure from the gidel front of the intellon station.
+fd = file ('open', 'sta_sys_date_preamble.dat', 'unknown');
+if fd < 0
+ exit ();
+end
+preamble_sysdate = read (fd, -1, 1);
+file ('close', fd);
+preamble_sysdate = preamble_sysdate';
+
+//delay to process the frequency error.
+delay_systck = 0;
+// Weight
+wo = 1/2^2;
+
+off = zeros (1, length(bts));
+sta_ntb = zeros (1, length (bts));
+freqerr = zeros (1, length (bts));
+numerator = zeros (1, length (bts));
+
+preamble_date(1) = preamble_sysdate (1);
+sta_ntb_date(1) = bts(1);
+off(1) = bts(1) - preamble_sysdate(1);
+decimal_num = 1000000.0 * (freqerr (1) + 1.0)
+numerator(1) = decimal_num + 0.5
+
+freqerr (2) = f_freqError (2, freqerr(1), bts(1), bts(2), preamble_sysdate (1), preamble_sysdate (2), wo);
+preamble_date(2) = f_preamble_date (preamble_date(1), preamble_sysdate(1), preamble_sysdate(2), 0, freqerr(1), delay_systck);
+sta_ntb_date(2) = f_ntb_date (preamble_date (2), off(1));
+off(2) = f_offset (bts(2), preamble_date (2), freqerr(1), freqerr(2), delay_systck);
+decimal_num = 1000000.0 * (freqerr (2) + 1.0)
+numerator(2) = decimal_num + 0.5
+
+for i = 3:length(bts)
+ // Test the worst case having a jitter of 6 PPM on the NTB clock.
+ if i >= 400
+ bts(i) = bts (i) + (i-400) * 6;
+ end
+ freqerr (i) = f_freqError (i, freqerr(i-1), bts(i-1), bts(i), preamble_sysdate (i-1), preamble_sysdate (i), wo);
+ preamble_date (i) = int(f_preamble_date (preamble_date (i-1), preamble_sysdate (i-1), preamble_sysdate(i), freqerr (i-2), freqerr(i-1), delay_systck));
+ sta_ntb_date (i) = f_ntb_date (preamble_date (i), off(i-1));
+ off(i) = int(f_offset (bts(i), preamble_date (i), freqerr(i-1), freqerr(i), delay_systck));
+ decimal_num = 1000000.0 * (freqerr (i) + 1.0)
+ numerator(i) = decimal_num + 0.5
+end
+
+// display the graph.
+if gui
+ xset ('window', 0);
+ xbasc();
+ subplot (2, 1, 1);
+ plot2d ([1:length(bts)], freqerr);
+ xtitle ('Frequency error', 'Beacons', 'Frequency error');
+ subplot (2, 1, 2);
+ plot2d ([1:length(bts)], off);
+ xtitle ('Offset error', 'Beacons', 'Offset error');
+ xset ('window', 1);
+ xbasc();
+ plot2d ([1:length(bts)], preamble_date, style = 1);
+ plot2d ([1:length(bts)], sta_ntb_date, style = -2);
+ plot2d ([1:length(bts)], bts, style = 4);
+ legend (['STA phy date', 'STA NTB', 'Intellon NTB']);
+ xtitle ('Clocks', 'Beacons NTB', 'Time NTB');
+end
+
+if gui == 0
+ // Store the point to a date file.
+ fd = file ('open', 'obj/freqerr.dat', 'unknown');
+ write (fd, freqerr', "(2(X,E24.16))");
+ file ('close', fd);
+ fd = file ('open', 'obj/offset.dat', 'unknown');
+ write (fd, off', "(I32)");
+ file ('close', fd);
+ fd = file ('open', 'obj/preamble.dat', 'unknown');
+ write (fd, preamble_date, "(I32)");
+ file ('close', fd);
+ fd = file ('open', 'obj/numerator.dat', 'unknown');
+ write (fd, numerator, "(I32)");
+ file ('close', fd);
+ exit();
+end
diff --git a/cesar/bsu/ntb/test/utest/src/ntb.c b/cesar/bsu/ntb/test/utest/src/ntb.c
new file mode 100644
index 0000000000..8c2d2051d2
--- /dev/null
+++ b/cesar/bsu/ntb/test/utest/src/ntb.c
@@ -0,0 +1,54 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2010 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file bsu/ntb/test/utest/src/ntb.c
+ * \brief NTB unit test.
+ * \ingroup bsu_ntb
+ */
+#include "common/std.h"
+#include "lib/test.h"
+#include "hal/phy/phy.h"
+#include "bsu/ntb/test/utest/tests.h"
+
+#define DELAY_SYSTCK 100000
+
+void
+test_suite_ntb_compute (test_t test);
+
+int
+main (int argc, char **argv)
+{
+ test_t test;
+ test_init (test, argc, argv);
+ test_suite_ntb_compute (test);
+ test_result (test);
+ return test_nb_failed (test) == 0 ? 0 : 1;
+}
+
+/** STUBS functions. */
+u32
+phy_sysdate (phy_t *ctx) __attribute__ ((weak));
+
+u32
+phy_sysdate (phy_t *ctx)
+{
+ bsu_ntb_test_phy_t *phy = (bsu_ntb_test_phy_t *) ctx;
+ dbg_assert (ctx);
+ return (phy->preamble_sysdate + DELAY_SYSTCK);
+}
+
+void
+phy_clock_set_numerator (phy_t *ctx, uint numerator)__attribute__((weak));
+
+void
+phy_clock_set_numerator (phy_t *ctx, uint numerator)
+{
+ bsu_ntb_test_phy_t *phy = (bsu_ntb_test_phy_t *) ctx;
+ dbg_assert (ctx);
+ phy->numerator = numerator;
+}
diff --git a/cesar/bsu/ntb/test/utest/src/ntb_compute.c b/cesar/bsu/ntb/test/utest/src/ntb_compute.c
new file mode 100644
index 0000000000..8c4a33a70a
--- /dev/null
+++ b/cesar/bsu/ntb/test/utest/src/ntb_compute.c
@@ -0,0 +1,102 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2010 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file bsu/ntb/test/utest/src/ntb_compute.c
+ * \brief NTB unit test.
+ * \ingroup bsu_ntb
+ */
+#include "common/std.h"
+#include "lib/test.h"
+#include "bsu/ntb/test/utest/tests.h"
+#include "bsu/ntb/ntb.h"
+#include "beacon_bts.h"
+#include "sta_sys_date_preamble.h"
+#include "offset.h"
+#include "preamble.h"
+#include "freqerr.h"
+#include "numerator.h"
+
+void
+test_case_ntb_ntb_sync (test_t test)
+{
+ test_case_begin (test, "NTB synchronization");
+ test_begin (test, "NTB")
+ {
+ s32 val;
+ uint i;
+ bsu_ntb_test_t t;
+ bsu_ntb_sync_t sync;
+ bsu_ntb_test_init (&t);
+ bsu_ntb_init (&sync);
+ /* Initialise the values. */
+ for (i = 0; i < COUNT (beacon_bts); i++)
+ {
+ t.phy.preamble_sysdate = sta_sys_date_preamble[i];
+ /* Test the worst case having a jitter of 6 PPM on the NTB clock. */
+ if (i >= 399)
+ beacon_bts[i] = beacon_bts[i] + (i - 399) * 6;
+ /* In this test the sys_date_preamble is the same as the station
+ * date preamble. */
+ bsu_ntb_clk_sync (&sync, (phy_t*) &t.phy, beacon_bts[i],
+ sta_sys_date_preamble[i], preamble[i]);
+ test_fail_unless (sync.fe - freqerr[i] < 1.0e-16);
+ if (less_mod2p32(sync.ntb_offset_tck, offset[i]))
+ val = (s32) offset[i] - (s32) sync.ntb_offset_tck;
+ else
+ val = (s32) sync.ntb_offset_tck - offset[i];
+ if (i == 1)
+ test_fail_unless (val < 2);
+ else
+ test_fail_unless (val == 0);
+ bsu_ntb_clock_configure (&sync, &t.mac_config, (phy_t*) &t.phy);
+ test_fail_unless (sync.sta_numerator == numerator[i], "%d", i);
+ }
+ bsu_ntb_uninit (&sync);
+ bsu_ntb_test_uninit (&t);
+ }
+ test_end;
+}
+
+void
+test_case_ntb_fail_beacons (test_t test)
+{
+ test_case_begin (test, "Beacon failure");
+ test_begin (test, "1 on 5 received")
+ {
+ uint i;
+ double error;
+ bsu_ntb_sync_t sync;
+ bsu_ntb_test_t t;
+ bsu_ntb_test_init (&t);
+ bsu_ntb_init (&sync);
+ /* Parse beacon_bts table with a step of 5. */
+ for (i = 0; i < COUNT (beacon_bts); i+=5)
+ {
+ t.phy.preamble_sysdate = sta_sys_date_preamble[i];
+ /* Test the worst case having a jitter of 6 PPM on the NTB clock. */
+ if (i >= 399)
+ beacon_bts[i] = beacon_bts[i] + (i - 399) * 6;
+ error = sync.fe;
+ bsu_ntb_clk_sync (&sync, (phy_t*) &t.phy, beacon_bts[i],
+ sta_sys_date_preamble[i], preamble[i]);
+ error = ABS(error - sync.fe);
+ test_fail_unless (error < 25.0e-6);
+ }
+ bsu_ntb_uninit (&sync);
+ bsu_ntb_test_uninit (&t);
+ }
+ test_end;
+}
+
+void
+test_suite_ntb_compute (test_t test)
+{
+ test_suite_begin (test, "NTB synchronisation");
+ test_case_ntb_ntb_sync (test);
+ test_case_ntb_fail_beacons (test);
+}
diff --git a/cesar/bsu/ntb/test/utest/src/tests.c b/cesar/bsu/ntb/test/utest/src/tests.c
new file mode 100644
index 0000000000..2750c31444
--- /dev/null
+++ b/cesar/bsu/ntb/test/utest/src/tests.c
@@ -0,0 +1,28 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2010 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file bsu/ntb/test/utest/test.h
+ * \brief tests functions and context.
+ * \ingroup bsu_ntb
+ */
+#include "common/std.h"
+#include "bsu/ntb/test/utest/tests.h"
+#include <string.h>
+
+void
+bsu_ntb_test_init (bsu_ntb_test_t *ctx)
+{
+ dbg_assert (ctx);
+ memset (ctx, 0, sizeof (bsu_ntb_test_t));
+}
+
+void
+bsu_ntb_test_uninit (bsu_ntb_test_t *ctx)
+{
+ dbg_assert (ctx);
+}
diff --git a/cesar/bsu/ntb/test/utest/sta_sys_date_preamble.dat b/cesar/bsu/ntb/test/utest/sta_sys_date_preamble.dat
new file mode 100644
index 0000000000..9775a84fc0
--- /dev/null
+++ b/cesar/bsu/ntb/test/utest/sta_sys_date_preamble.dat
@@ -0,0 +1,819 @@
+1158518705
+1159514406
+1160515012
+1161514737
+1162514058
+1163518865
+1164519009
+1165516030
+1166514079
+1167518860
+1168513460
+1169513217
+1170538630
+1171512868
+1172516187
+1174512577
+1175514666
+1176516572
+1177517235
+1178517106
+1179513360
+1180512524
+1181511713
+1182515734
+1183511370
+1184515676
+1186512544
+1187514136
+1188513277
+1189513961
+1190515622
+1191511770
+1192514597
+1193514353
+1194510097
+1195513105
+1196512303
+1197509709
+1198510076
+1199510823
+1201512401
+1202510422
+1203508784
+1204513973
+1205508621
+1206508465
+1207508206
+1208510641
+1209510459
+1211511808
+1212508294
+1213507961
+1214508771
+1215512061
+1216509432
+1217506856
+1218508993
+1220507978
+1221506247
+1222506065
+1223510877
+1224510123
+1225509795
+1226510500
+1227505305
+1229506550
+1230504909
+1231507885
+1232505301
+1233508627
+1234505794
+1235504084
+1236508301
+1237505316
+1238503756
+1239503530
+1240506777
+1241506488
+1242503681
+1243502933
+1244503583
+1245503286
+1246502556
+1247506441
+1248502960
+1249503668
+1250501986
+1251503183
+1252501852
+1253503859
+1254506499
+1255505315
+1256501232
+1257506027
+1258504918
+1259505620
+1260500641
+1262505179
+1263504083
+1264502386
+1265502025
+1266504535
+1267503422
+1268499905
+1269502308
+1270501259
+1271498667
+1272502822
+1273498425
+1274500609
+1275499382
+1276497991
+1277501889
+1278500775
+1279501421
+1280502369
+1281502043
+1282500131
+1283496931
+1284497177
+1285497458
+1287502050
+1288496911
+1289497548
+1290498880
+1291496379
+1293496023
+1294495205
+1295496685
+1296496733
+1297498947
+1298494456
+1299496846
+1300497799
+1301496586
+1302493788
+1303497044
+1304495291
+1305493184
+1306493003
+1307492285
+1308492258
+1309495150
+1310493193
+1311492865
+1312492425
+1313494419
+1315493040
+1316490735
+1317493662
+1318493443
+1319493145
+1320493242
+1321492014
+1322490955
+1323492453
+1324494246
+1325491252
+1326489280
+1327490842
+1328489022
+1329489615
+1331490040
+1332491020
+1333487465
+1334490519
+1335490296
+1336487027
+1337488255
+1339487773
+1340490528
+1341488397
+1342490979
+1343490694
+1344486303
+1345487794
+1346485261
+1347488288
+1348490131
+1349487146
+1350486068
+1351484360
+1352487695
+1353484150
+1354483840
+1355488780
+1356484360
+1357483593
+1359483115
+1360483221
+1361485251
+1362484248
+1363482529
+1364483087
+1365486406
+1366482675
+1367485178
+1368482450
+1369483107
+1370482041
+1371482659
+1373482438
+1374480855
+1375480631
+1376483894
+1377482765
+1378480201
+1379484081
+1381483884
+1382483749
+1383483522
+1384479413
+1385479648
+1386483071
+1387483773
+1388478734
+1389482557
+1390478283
+1392478120
+1393481925
+1394477602
+1395477917
+1396477952
+1397477201
+1398481977
+1399481730
+1400479140
+1401477059
+1402479630
+1403478477
+1404476200
+1405475928
+1406475773
+1407480638
+1408475642
+1409478583
+1410476651
+1412479248
+1413479834
+1414479735
+1415475882
+1416475071
+1417474315
+1418478305
+1419473918
+1420479086
+1421477913
+1422477855
+1423474840
+1424476759
+1425475640
+1426476421
+1427474239
+1428477169
+1429473395
+1431473906
+1432475893
+1433473809
+1434477286
+1435472031
+1436472144
+1437471997
+1438471772
+1439473943
+1440473998
+1441474605
+1442473664
+1444471660
+1445471477
+1446472207
+1447475611
+1448476816
+1449475409
+1450472539
+1451471432
+1452471550
+1454469681
+1455474505
+1456473652
+1457473511
+1458469007
+1459471333
+1460470532
+1461468796
+1462471982
+1464472683
+1465469785
+1466468223
+1467472192
+1468469525
+1469467891
+1470467771
+1471470751
+1472470920
+1473467960
+1475467679
+1476467753
+1477467081
+1478471059
+1479468158
+1480466853
+1481468076
+1482466557
+1483470483
+1484468837
+1485471285
+1486466231
+1487471125
+1488470311
+1490465898
+1491466235
+1492470915
+1493469789
+1494467923
+1495467747
+1496469691
+1497465969
+1498468471
+1499467446
+1500465253
+1501469164
+1502464991
+1504466358
+1505464741
+1506468763
+1507467759
+1508468707
+1509469392
+1510469372
+1513464018
+1514463938
+1515464320
+1516468895
+1517463721
+1518464057
+1519465736
+1520463503
+1521463263
+1522463207
+1523463507
+1524465400
+1525466064
+1526467744
+1527463138
+1528465897
+1529462967
+1530466455
+1532462836
+1533462608
+1534461949
+1535464979
+1536463303
+1537463093
+1538462104
+1539464600
+1540462916
+1541463598
+1542461227
+1543464249
+1544464345
+1545464157
+1546464048
+1547463015
+1548462205
+1550465527
+1551462630
+1552461040
+1553462569
+1554460698
+1555461461
+1558463064
+1560461256
+1561462841
+1562462825
+1563459410
+1564460937
+1565462568
+1566460685
+1567463262
+1568461598
+1569464081
+1571459374
+1572461332
+1573458742
+1574461916
+1575463686
+1577460872
+1578463387
+1579459649
+1580461564
+1581458483
+1582458111
+1583462898
+1584458011
+1585457783
+1586457675
+1587459867
+1588459011
+1589457381
+1590461417
+1592457762
+1593460197
+1595458085
+1596457301
+1597457998
+1598457870
+1599457665
+1600456354
+1601456079
+1602459263
+1603458130
+1604457347
+1606459659
+1607455390
+1608459555
+1609459373
+1610459229
+1612455106
+1613455313
+1614458724
+1615459532
+1616454593
+1617458530
+1618454251
+1619459078
+1620454160
+1622453878
+1623457778
+1624453796
+1625454114
+1626453986
+1628458463
+1629458202
+1630455435
+1631453476
+1632456327
+1633455163
+1635452589
+1636455956
+1637453993
+1638452392
+1639454566
+1640456495
+1641457201
+1642457095
+1643453375
+1644452564
+1645452185
+1646455852
+1647451605
+1648456734
+1649455629
+1650455501
+1651452639
+1652454583
+1653453442
+1654454229
+1655455885
+1656452409
+1657454876
+1658454742
+1659450412
+1660453738
+1661452605
+1662450204
+1663450485
+1664451474
+1665451268
+1666449675
+1667454539
+1668449586
+1669449361
+1670449219
+1671449044
+1672451496
+1673451239
+1674451979
+1675450898
+1676452745
+1677448983
+1678448807
+1679449517
+1680453151
+1681450268
+1682447849
+1683452628
+1684449119
+1685448850
+1686447267
+1687452111
+1688451161
+1689451927
+1690446785
+1691448930
+1692448127
+1693446369
+1694449510
+1695446648
+1696450456
+1697450989
+1699445593
+1700449793
+1701447759
+1702446794
+1703445105
+1704445222
+1705448226
+1706448100
+1707445263
+1708444810
+1709445051
+1710444955
+1711444215
+1712448483
+1713445359
+1714443973
+1715445155
+1717445085
+1718445858
+1720447544
+1721443165
+1722448157
+1723446965
+1724447980
+1725524961
+1726447602
+1727446551
+1728444838
+1729444593
+1730442137
+1731446051
+1732442099
+1733444131
+1734441629
+1735445566
+1736444786
+1737446338
+1739440929
+1740441063
+1742441253
+1743445458
+1745440299
+1746440717
+1747442301
+1748440071
+1749439782
+1750439689
+1751441627
+1752441947
+1753442516
+1754444177
+1755439529
+1756442310
+1757442985
+1758441886
+1759439022
+1760442691
+1761440661
+1762438765
+1763438491
+1764438102
+1765437871
+1766440900
+1767439017
+1768439075
+1769437905
+1771438491
+1772439554
+1773436917
+1774440039
+1775439861
+1776439798
+1777438870
+1778437791
+1779439376
+1780441312
+1781438422
+1782436558
+1783438065
+1784437335
+1785438906
+1786437900
+1787438614
+1788435480
+1789436711
+1790438412
+1791438196
+1792435158
+1793436271
+1794438000
+1795436027
+1796438884
+1797436889
+1798439384
+1799439231
+1800434874
+1801436439
+1803438912
+1804436359
+1805438906
+1806435219
+1807433708
+1808437019
+1809433585
+1810435860
+1811433328
+1812438591
+1813433862
+1814433232
+1815437229
+1816433214
+1817433083
+1818435310
+1820432972
+1821433243
+1822436804
+1823432489
+1824433210
+1825435661
+1826432889
+1827433663
+1828432876
+1829433582
+1830433495
+1831433257
+1832435098
+1833434092
+1834431671
+1835435656
+1836431650
+1837435579
+1839466755
+1840431315
+1841431626
+1842435189
+1843435833
+1844431012
+1846430654
+1847435584
+1848430644
+1849430435
+1850430342
+1851434269
+1852430326
+1853430624
+1855429808
+1856434993
+1857434802
+1858431943
+1859429960
+1860432840
+1861431684
+1862429358
+1863429081
+1864429251
+1865434071
+1866428904
+1867432028
+1868430367
+1869428737
+1870430977
+1871432585
+1872433630
+1873429835
+1874428849
+1875428139
+1876428167
+1877433077
+1879431903
+1880429364
+1881430892
+1882429949
+1883430669
+1884429028
+1885431498
+1886431433
+1887427185
+1888430479
+1891428244
+1893430053
+1894428134
+1895426575
+1896431766
+1897426609
+1898426503
+1900426536
+1901428669
+1902428673
+1903429370
+1904428686
+1905430324
+1906426653
+1907426529
+1908427597
+1909430990
+1911425776
+1912431067
+1913428081
+1914427133
+1915427053
+1916425854
+1917425687
+1918430599
+1919429591
+1920429777
+1921430534
+1922425515
+1923427672
+1924426970
+1925425377
+1926428518
+1927425746
+1928429483
+1929430243
+1930426600
+1931425038
+1932429447
+1933427427
+1934425049
+1935424948
+1936428443
+1937428296
+1938425493
+1939424869
+1940425105
+1941429066
+1942425469
+1943426182
+1944424994
+1945426303
+1946424820
+1947428874
+1948426389
+1949429802
+1950428878
+1951424666
+1952429040
+1953429786
+1954424704
+1955425135
+1956429879
+1957428881
+1958426989
+1959426907
+1960429858
+1962425200
+1963427791
+1964427103
+1965424671
+1966428704
+1967424560
+1968427106
+1969426045
+1970424639
+1972428080
+1973428758
+1974429699
+1975429607
+1976428090
+1978424721
+1979424649
+1980425528
+1981429857
+1982429900
+1983424769
+1984427371
+1985424927
+1986424908
+1987425443
+1988427497
+1989427372
+1990428292
+1991430036
+1992425880
+1993428399
+1994429269
+1995428359
+1996426026
+1998427722
+1999425878
+2000426232
+2001425434
+2002428906
+2003427006
+2004427302
+2005426377
+2006429029
+2007427265
+2008428453
+2009426044
+2010429286
+2011429269
+2012429622
+2013428587
+2014427762
+2016431657
+2017427130
+2019427072
+2020428284
+2021430019
+2022429200
+2024427143
+2025428468
+2026430292
+2027430361
+2028427415
+2029428770
+2030430632
+2031427936
+2032430119
+2035432765
+2036430352
+2037433057
+2038429496
+2039428010
+2040431577
+2041428328
+2042430690
+2043428321
diff --git a/cesar/bsu/ntb/test/utest/tests.h b/cesar/bsu/ntb/test/utest/tests.h
new file mode 100644
index 0000000000..c36a9269df
--- /dev/null
+++ b/cesar/bsu/ntb/test/utest/tests.h
@@ -0,0 +1,55 @@
+#ifndef bsu_ntb_test_utest_tests_h
+#define bsu_ntb_test_utest_tests_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2010 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file bsu/ntb/test/utest/tests.h
+ * \brief tests functions and context.
+ * \ingroup bsu_ntb
+ */
+#include "mac/common/config.h"
+
+struct bsu_ntb_test_phy_t
+{
+ /* Phy sys date. */
+ u32 sys_date;
+ /* Preamble sys date. */
+ u32 preamble_sysdate;
+ /* Numerator. */
+ u32 numerator;
+};
+typedef struct bsu_ntb_test_phy_t bsu_ntb_test_phy_t;
+
+struct bsu_ntb_test_t
+{
+ /** Phy context. */
+ bsu_ntb_test_phy_t phy;
+ /** mac_config */
+ mac_config_t mac_config;
+};
+typedef struct bsu_ntb_test_t bsu_ntb_test_t;
+
+BEGIN_DECLS
+
+/**
+ * Initialise the BSU NTB sub module.
+ * \param ctx the test context.
+ */
+void
+bsu_ntb_test_init (bsu_ntb_test_t *ctx);
+
+/**
+ * Uninitialise the BSU NTB sub module.
+ * \param ctx the test context.
+ */
+void
+bsu_ntb_test_uninit (bsu_ntb_test_t *ctx);
+
+END_DECLS
+
+#endif /* bsu_ntb_test_utest_tests_h */