Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //All needed includes for GPIO operation are here.
- #include "EInterface.h"
- #include <sys/time.h>
- #define ITERATIONS 15000.f
- int main()
- {
- //Initialize GPIO Interface, and check if it returns any error code.
- //IF success (if errorCode is -1, it's bad!)
- if (StartInterface() == 1)
- {
- printf("Starting %f x 4 pin switch operations\n", ITERATIONS);
- struct timeval t1, t2;
- gettimeofday(&t1, NULL);
- //If interface was properly initialized, blink the PD1 and PD2 pins five times in 0.2 second intervals:
- int i;
- for (i = 0; i < ITERATIONS; i++)
- {
- SetPinValue(PD1, HIGH);
- SetPinValue(PD2, LOW);
- //printf("-------------\n");
- //usleep(200000);
- SetPinValue(PD1, LOW);
- SetPinValue(PD2, HIGH);
- //printf("-------------\n");
- //usleep(200000);
- }
- gettimeofday(&t2, NULL);
- double elapsedTime = (t2.tv_sec - t1.tv_sec) * 1000.f;
- elapsedTime += (t2.tv_usec - t1.tv_usec) / 1000.f;
- double timePerIteration = elapsedTime / ITERATIONS;
- double timePerSwitch = timePerIteration / 4.f;
- printf("Time total: %fms\n", elapsedTime);
- printf("Time per iteration: %fms\n", timePerIteration);
- printf("Time per switch: %fms\n", timePerSwitch);
- CloseInterface();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement