4 #include "../hubolib.h"
5 #include "../hubocfg.h"
25 printf (
"The GPIO interface could not be initialised - terminating.\n");
32 unsigned char pin = 22;
38 printf (
"Input pin %d is set to %d\n", pin,
ReadPin(pin));
42 printf (
"Input pin %d with pull up is set to %d\n", pin,
ReadPin(pin));
46 printf (
"Input pin %d with pull down is set to %d\n", pin,
ReadPin(pin));
53 printf (
"Cleared output pin %d is set to %d\n", pin,
ReadPin(pin));
55 printf (
"Set output pin %d is set to %d\n", pin,
ReadPin(pin));
59 unsigned long long tStart, tStop;
64 for (
int i=0; i<1000000; i++)
69 printf (
"1000000 samples written in %lluµs - thus %fMHz\n", tStop-tStart, 1000000.0/(tStop-tStart));
73 for (
int i=0; i<1000000; i++)
78 printf (
"1000000 samples read in %lluµs - thus %fMHz\n", tStop-tStart, 1000000.0/(tStop-tStart));
82 unsigned long long delay;
90 printf (
"usleep(%lluµs) took %lluµs\n", delay, tStop-tStart);
95 printf (
"Delay_MicroSeconds(%lluµs) took %lluµs\n", delay, tStop-tStart);
102 printf (
"usleep(%lluµs) took %lluµs\n", delay, tStop-tStart);
107 printf (
"Delay_MicroSeconds(%lluµs) took %lluµs\n", delay, tStop-tStart);
unsigned short ReadPin(unsigned short pin)
Reads the value of an (input) pin.
void Delay_MicroSeconds(unsigned long delay_micros)
delays the execution of the calling thread for the given number of micro seconds. ...
bool IsGPIOInitialized()
Returns the status of the initialisation of the GPIO part of the library.
void FunctionSelectPin(unsigned char pin, FunctionSelectType mode)
Use FunctionSelect() to configure the mode of a BCM2835 pin.
void WritePin(unsigned char pin, unsigned char value)
Sets or clears a pin configured to be an output.
unsigned long long GetTime_MicroSeconds()
Returns the number of micro seconds.
void SetPullUpDown(unsigned char pin, PullUpDownType pud)
Enables or disables the BCM2835 internal pull -up or -down resistors for a pin configured as an input...