demo: dump calibration info

parent 859c9361
...@@ -220,6 +220,7 @@ static void do_command(char *c) ...@@ -220,6 +220,7 @@ static void do_command(char *c)
/* payload */ /* payload */
else if(strcmp(token, "rofreq") == 0) rofreq(); else if(strcmp(token, "rofreq") == 0) rofreq();
else if(strcmp(token, "calinfo") == 0) calinfo();
else if(strcmp(token, "") != 0) else if(strcmp(token, "") != 0)
printf("Command not found\n"); printf("Command not found\n");
......
...@@ -41,7 +41,7 @@ void rofreq() ...@@ -41,7 +41,7 @@ void rofreq()
tdc->FCC = TDC_FCC_ST; tdc->FCC = TDC_FCC_ST;
while(!(tdc->FCC & TDC_FCC_RDY)); while(!(tdc->FCC & TDC_FCC_RDY));
val = tdc->FCR; val = tdc->FCR;
printf("Channel %d: %d\n", channel, val); printf("CHANNEL %d: %d\n", channel, val);
channel++; channel++;
last = tdc->CSEL & TDC_CSEL_LAST; last = tdc->CSEL & TDC_CSEL_LAST;
tdc->CSEL = TDC_CSEL_NEXT; tdc->CSEL = TDC_CSEL_NEXT;
...@@ -49,3 +49,44 @@ void rofreq() ...@@ -49,3 +49,44 @@ void rofreq()
printf("\n"); printf("\n");
} }
} }
#define TDC_RAW_COUNT 9
void calinfo()
{
int channel;
int i;
if(!(tdc->CS & TDC_CS_RDY)) {
printf("Startup calibration not done\n");
return;
}
tdc->DCTL = TDC_DCTL_REQ;
while(!(tdc->DCTL & TDC_DCTL_ACK));
/* go to first channel */
while(!(tdc->CSEL & TDC_CSEL_LAST))
tdc->CSEL = TDC_CSEL_NEXT;
tdc->CSEL = TDC_CSEL_NEXT;
channel = 0;
do {
printf("CHANNEL %d\n", channel);
printf("HIST: ");
for(i=0;i<(1 << TDC_RAW_COUNT);i++) {
tdc->HISA = i;
printf("%d,", tdc->HISD);
}
printf("\n");
printf("LUT: ");
for(i=0;i<(1 << TDC_RAW_COUNT);i++) {
tdc->LUTA = i;
printf("%d,", tdc->LUTD);
}
printf("\n\n");
channel++;
tdc->CSEL = TDC_CSEL_NEXT;
} while(!(tdc->CSEL & TDC_CSEL_LAST));
tdc->DCTL = 0;
}
...@@ -20,5 +20,6 @@ ...@@ -20,5 +20,6 @@
#define __TDC_H #define __TDC_H
void rofreq(); void rofreq();
void calinfo();
#endif /* __TDC_H */ #endif /* __TDC_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment