reduce number of variables in isr and output
This commit is contained in:
		| @@ -12,8 +12,6 @@ const int SPI_CHAN = 0; | |||||||
| const int SPI_SPEED = 1000000; | const int SPI_SPEED = 1000000; | ||||||
|  |  | ||||||
|  |  | ||||||
| uint32_t ec = 0; |  | ||||||
| uint32_t counter = 0; |  | ||||||
| uint32_t diff = 0; | uint32_t diff = 0; | ||||||
|  |  | ||||||
| pthread_mutex_t counterMutex = PTHREAD_MUTEX_INITIALIZER; | pthread_mutex_t counterMutex = PTHREAD_MUTEX_INITIALIZER; | ||||||
| @@ -28,8 +26,6 @@ void isr() { | |||||||
|  |  | ||||||
|   pthread_mutex_lock(&counterMutex); |   pthread_mutex_lock(&counterMutex); | ||||||
|   diff = currentCounter - lastCounter; |   diff = currentCounter - lastCounter; | ||||||
|   counter = currentCounter; |  | ||||||
|   ec++; |  | ||||||
|   pthread_mutex_unlock(&counterMutex); |   pthread_mutex_unlock(&counterMutex); | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -53,8 +49,6 @@ void init() { | |||||||
| } | } | ||||||
|  |  | ||||||
| int main (void) { | int main (void) { | ||||||
|   uint32_t my_ec = 0; |  | ||||||
|   uint32_t my_counter = 0; |  | ||||||
|   uint32_t my_diff = 0; |   uint32_t my_diff = 0; | ||||||
|  |  | ||||||
|   init(); |   init(); | ||||||
| @@ -66,12 +60,10 @@ int main (void) { | |||||||
|     pthread_mutex_unlock(&eventMutex); |     pthread_mutex_unlock(&eventMutex); | ||||||
|  |  | ||||||
|     pthread_mutex_lock(&counterMutex); |     pthread_mutex_lock(&counterMutex); | ||||||
|     my_ec = ec; |  | ||||||
|     my_counter = counter; |  | ||||||
|     my_diff = diff; |     my_diff = diff; | ||||||
|     pthread_mutex_unlock(&counterMutex); |     pthread_mutex_unlock(&counterMutex); | ||||||
|  |  | ||||||
|     double f = 1.0 / (((double) my_diff) / 1000000.0); |     double f = 1.0 / (((double) my_diff) / 1000000.0); | ||||||
|     printf("%u %u %u %f\n", my_ec, my_counter, my_diff, f); |     printf("%f\n", f); | ||||||
|   } |   } | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Wolfgang Hottgenroth
					Wolfgang Hottgenroth