Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding beginner's example on using PD15 in OrangePi 3 #39

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion debian-template/wiringPi/DEBIAN/control
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Package: wiringPi
Version: 2.46
Section: libraries
Priority: optional
Architecture: armhf
Architecture: arm64
Depends: libc6
Maintainer: Boby Lee <[email protected]>
Description: The wiringPi libraries for the OrangePi, headers and gpio command
Expand Down
6 changes: 3 additions & 3 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ Build-Depends: debhelper (>= 8)

Package: libwiringpi2
Section: libs
Architecture: armhf
Architecture: arm64
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: GPIO librariees for Raspberry Pi (runtime).
Runtime for the popular wiringPi library.

Package: wiringpi
Architecture: armhf
Architecture: arm64
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: gpio utility for Raspberry Pi
The wiringPi gpio command line utility, for GPIO access on a
Raspberry Pi from the command line.

Package: libwiringpi-dev
Architecture: armhf
Architecture: arm64
Depends: libwiringpi2 (= ${binary:Version}), libc6-dev, ${misc:Depends}
Suggests: wiringpi
Description: GPIO development library for Raspberry Pi
Expand Down
63 changes: 63 additions & 0 deletions examples/pd15.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#include <wiringPi.h>

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>

#if 0
+------+-----+----------+------+---+ OPi 3 +---+------+----------+-----+------+
| GPIO | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | GPIO |
+------+-----+----------+------+---+----++----+---+------+----------+-----+------+
| | | 3.3V | | | 1 || 2 | | | 5V | | |
| 122 | 0 | SDA.0 | OFF | 0 | 3 || 4 | | | 5V | | |
| 121 | 1 | SCL.0 | OFF | 0 | 5 || 6 | | | GND | | |
| 118 | 2 | PWM.0 | OFF | 0 | 7 || 8 | 0 | OFF | PL02 | 3 | 354 |
| | | GND | | | 9 || 10 | 0 | OFF | PL03 | 4 | 355 |
| 120 | 5 | RXD.3 | ALT4 | 0 | 11 || 12 | 0 | OFF | PD18 | 6 | 114 |
| 119 | 7 | TXD.3 | ALT4 | 0 | 13 || 14 | | | GND | | |
| 362 | 8 | PL10 | OFF | 0 | 15 || 16 | 0 | OFF | PD15 | 9 | 111 |
| | | 3.3V | | | 17 || 18 | 0 | OFF | PD16 | 10 | 112 |
| 229 | 11 | MOSI.1 | ALT2 | 0 | 19 || 20 | | | GND | | |
| 230 | 12 | MISO.1 | ALT2 | 0 | 21 || 22 | 0 | OFF | PD21 | 13 | 117 |
| 228 | 14 | SCLK.1 | ALT2 | 0 | 23 || 24 | 0 | ALT2 | CE.1 | 15 | 227 |
| | | GND | | | 25 || 26 | 0 | OFF | PL08 | 16 | 360 |
+------+-----+----------+------+---+----++----+---+------+----------+-----+------+
| GPIO | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | GPIO |
+------+-----+----------+------+---+ OPi 3 +---+------+----------+-----+------+
#endif

#define PD15_PIN 9

static void usage(const char* argv0)
{
printf("Usage: %s <on|off>\n", argv0);
exit(1);
}

int main(int argc, char* argv[])
{
printf ("OrangePi Pi wiringPi PD15 test program\n");

if (argc != 2) usage(argv[0]);

int mode = 0;
if (!strcmp(argv[1], "on"))
mode = HIGH;
else if (!strcmp(argv[1], "off"))
mode = LOW;
else
usage(argv[0]);

if (wiringPiSetup() == -1)
{
fprintf(stderr, "Error setting up wiringPi\n");
return -1;
}

pinMode(PD15_PIN, OUTPUT);
digitalWrite(PD15_PIN, mode);

return 0;
}

2 changes: 1 addition & 1 deletion newVersion
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Package: wiringpi
Version: `cat VERSION`
Section: libraries
Priority: optional
Architecture: armhf
Architecture: arm64
Depends: libc6
Maintainer: Gordon Henderson <[email protected]>
Description: The wiringPi libraries, headers and gpio command
Expand Down