refactored
This commit is contained in:
@ -24,7 +24,7 @@ pthread_cond_t eventSignal = PTHREAD_COND_INITIALIZER;
|
||||
void isr() {
|
||||
static uint32_t lastCounter = 0;
|
||||
|
||||
uint32_t currentCounter = read32(CMD_RD | REG_OTR);
|
||||
uint32_t currentCounter = ls7366rReadOTR();
|
||||
|
||||
pthread_mutex_lock(&counterMutex);
|
||||
diff = currentCounter - lastCounter;
|
||||
@ -53,13 +53,12 @@ void init() {
|
||||
}
|
||||
|
||||
int main (void) {
|
||||
static uint32_t lastDiff = 0;
|
||||
uint32_t my_ec = 0;
|
||||
uint32_t my_counter = 0;
|
||||
uint32_t my_diff = 0;
|
||||
|
||||
init();
|
||||
initCounter();
|
||||
ls7366rInit(SPI_CHAN);
|
||||
|
||||
while (1) {
|
||||
pthread_mutex_lock(&eventMutex);
|
||||
@ -72,10 +71,7 @@ int main (void) {
|
||||
my_diff = diff;
|
||||
pthread_mutex_unlock(&counterMutex);
|
||||
|
||||
if (my_diff != lastDiff) {
|
||||
lastDiff = my_diff;
|
||||
double f = 1.0 / (((double) my_diff) / 1000000.0);
|
||||
printf("%d %d %d %f\n", my_ec, my_counter, my_diff, f);
|
||||
}
|
||||
double f = 1.0 / (((double) my_diff) / 1000000.0);
|
||||
printf("%d %d %d %f\n", my_ec, my_counter, my_diff, f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user