Example: test execution speed of several methods to toggle a GPIO pin. More...
#include "stdio.h"
#include "time.h"
#include "libpruio/pruio.h"
#include "libpruio/pruio_pins.h"
Go to the source code of this file.
Macros | |
#define | _GNU_SOURCE 1 |
Message for the compiler. | |
#define | C_IN P9_42 |
The pin to use for CAP input. | |
#define | GOUT P8_16 |
The pin to use for GPIO output. | |
#define | G_IN P8_14 |
The pin to use for GPIO input. | |
#define | FREQ(_N_) |
Macro to measure the frequency and compute statistics. More... | |
#define | DIRECT(_O_) |
Macro to set output pin by fast direct PRU command (no error checking). More... | |
#define | FUNC(_O_) |
Macro to set output by normal GPIO function (for better readability). More... | |
Functions | |
int | main (int argc, char **argv) |
The main function. More... | |
Example: test execution speed of several methods to toggle a GPIO pin.
This file contains an example on measuring the execution speed of different controllers that toggles a GPIO output. It measures the frequency of the toggled output from open and closed loop controllers and computes their mimimum, avarage and maximum execution speed. Find a functional description in section performance.
The code performs 50 tests of each controller version and outputs the toggling frequencies in Hz at the end. The controllers are classified by
Licence: GPLv3, Copyright 2014-2023 by Thomas{ dOt ]Freiherr[ At ]gmx[ DoT }net
Compile by: gcc -Wall -o performance performance.c -lpruio
Definition in file performance.c.
#define DIRECT | ( | _O_ | ) |
Macro to set output pin by fast direct PRU command (no error checking).
Definition at line 55 of file performance.c.
#define FREQ | ( | _N_ | ) |
Macro to measure the frequency and compute statistics.
Definition at line 46 of file performance.c.
#define FUNC | ( | _O_ | ) |
Macro to set output by normal GPIO function (for better readability).
Definition at line 65 of file performance.c.
int main | ( | int | argc, |
char ** | argv | ||
) |
The main function.
create new driver structure
< The counter for test loops.
< The counter for test cycles.
< The number of cycles for each test.
< Resulting input GPIO (index and bit number).
< Index of input GPIO.
< The bit number of input bit.
< Resulting output GPIO (index and bit number).
< Index of output GPIO.
< Mask for output bit. , sd
< Register value for CLEARDATAOUT.
< Register value for SETDATAOUT.
< Subsystem adress.
< Output enable register.
< The current measurement result.
< The minimum frequencies.
< The maximum frequencies.
< The summe of measured frequencies (to compute avarage).
Definition at line 70 of file performance.c.