Browse Source

Support Orange Pi Prime (H5)

pull/11/head
leeboby 5 years ago
parent
commit
7273273266
  1. 2
      build
  2. 32
      examples/blink.c
  3. 10
      gpio/Makefile
  4. 71
      gpio/OrangePi.c
  5. 10
      wiringPi/Makefile
  6. 101
      wiringPi/OrangePi.c

2
build

@ -49,7 +49,7 @@ select_boards()
local choice
local call=${1}
boards=("OrangePi_PC2" "OrangePi_ZEROPLUS" "OrangePi_A64" "OrangePi_ZERO" "OrangePi_H3" "OrangePi_LITE2" "OrangePi_H3_ZEROPLUS2" "OrangePi_3" "OrangePi_RK3399" "OrangePi_ONEPLUS" "OrangePi_4")
boards=("OrangePi_PC2" "OrangePi_ZEROPLUS" "OrangePi_PRIME" "OrangePi_A64" "OrangePi_ZERO" "OrangePi_H3" "OrangePi_LITE2" "OrangePi_H3_ZEROPLUS2" "OrangePi_3" "OrangePi_RK3399" "OrangePi_ONEPLUS" "OrangePi_4")
printf "All available boards:\n"
for var in ${boards[@]} ; do

32
examples/blink.c

@ -1,26 +1,28 @@
#include <stdio.h>
#include <wiringPi.h>
#define NUM 17
//#define NUM 17
#define NUM 28
int main (void)
{
int i = 0;
int i = 0;
wiringPiSetup () ;
wiringPiSetup () ;
for (i = 0; i < NUM; i++)
pinMode (i, OUTPUT) ;
for (i = 0; i < NUM; i++)
pinMode (i, OUTPUT) ;
for ( ;; )
{
for (i = 0; i < NUM; i++)
digitalWrite (i, HIGH) ; // On
delay (500) ; // mS
for ( ;; )
{
for (i = 0; i < NUM; i++)
digitalWrite (i, HIGH) ; // On
delay (500) ; // mS
for (i = 0; i < NUM; i++)
digitalWrite (i, LOW) ; // Off
delay (500) ;
}
return 0 ;
for (i = 0; i < NUM; i++)
digitalWrite (i, LOW) ; // Off
delay (500) ;
}
return 0;
}

10
gpio/Makefile

@ -42,6 +42,7 @@ LIBS = -lwiringPi -lwiringPiDev -lpthread -lrt -lm -lcrypt
ifeq ($(PLATFORM),)
#PLATFORM = OrangePi_2G-IOT
#PLATFORM = OrangePi_PC2
#PLATFORM = OrangePi_PRIME
#PLATFORM = OrangePi_ZEROPLUS
#PLATFORM = OrangePi_A64
#PLATFORM = OrangePi_H5
@ -64,6 +65,11 @@ EXTRA_CFLAGS = -DCONFIG_ORANGEPI_PC2
EXTRA_CFLAGS += -DCONFIG_ORANGEPI
endif
ifeq ($(PLATFORM), OrangePi_PRIME)
EXTRA_CFLAGS = -DCONFIG_ORANGEPI_PRIME
EXTRA_CFLAGS += -DCONFIG_ORANGEPI
endif
ifeq ($(PLATFORM), OrangePi_ZEROPLUS)
EXTRA_CFLAGS = -DCONFIG_ORANGEPI_ZEROPLUS
EXTRA_CFLAGS += -DCONFIG_ORANGEPI
@ -127,6 +133,10 @@ ifeq ($(PLATFORM), OrangePi_PC2)
SRC += OrangePi.c
endif
ifeq ($(PLATFORM), OrangePi_PRIME)
SRC += OrangePi.c
endif
ifeq ($(PLATFORM), OrangePi_ZEROPLUS)
SRC += OrangePi.c
endif

71
gpio/OrangePi.c

@ -62,12 +62,75 @@ char *physNames[64] =
NULL, NULL,
NULL, NULL,
NULL, NULL,
"GPIO.17", "GPIO.18",
"GPIO.19", "GPIO.20",
NULL, NULL,
NULL, NULL,
NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
};
#endif /* PC2 */
#ifdef CONFIG_ORANGEPI_PRIME
int physToWpi[64] =
{
-1, // 0
-1, -1, // 1, 2
0, -1, //3, 4
1, -1, //5, 6
2, 3, //7, 8
-1, 4, //9,10
5, 6, //11,12
7, -1, //13,14
8, 9, //15,16
-1, 10, //17,18
11, -1, //19,20
12, 13, //21,22
14, 15, //23, 24
-1, 16, // 25, 26
17, 18, //27, 28
19, -1, //29, 30
20, 21, //31, 32
22, -1, //33, 34
23, 24, //35, 36
25, 26, //37, 38
-1, 27, //39, 40
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, //41-> 55
-1, -1, -1, -1, -1, -1, -1, -1 // 56-> 63
};
char *physNames[64] =
{
NULL,
" 3.3v", "5v ",
" SDA.0", "5v ",
" SCL.0", "GND ",
" PWM1", "PC05 ",
" GND", "PC06 ",
" RxD.2", "PD14 ",
" TxD.2", "GND ",
" CTS.2", "PC04 ",
" 3.3v", "PC07 ",
" MOSI.1", "GND ",
" MISO.1", "RTS.2 ",
" SCLK.1", "CS.1 ",
" GND", "PC08 ",
" SDA.1", "SCL.1 ",
" PA07", "GND ",
" PA08", "PC09 ",
" PA09", "GND ",
" PA10", "PC10 ",
" PD11", "PC11 ",
" GND", "PC12 ",
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
};
#endif /* PRIME */
#ifdef CONFIG_ORANGEPI_ZEROPLUS
int physToWpi [64] = //return wiringPI pin
@ -794,6 +857,8 @@ void OrangePiReadAll(void)
wiringPiDebug = FALSE;
#ifdef CONFIG_ORANGEPI_PC2
printf (" +------+-----+----------+------+---+ OPi PC2 +---+------+----------+-----+------+\n");
#elif CONFIG_ORANGEPI_PRIME
printf (" +------+-----+----------+------+---+ PRIME +---+------+----------+-----+------+\n");
#elif CONFIG_ORANGEPI_ZEROPLUS
printf (" +------+-----+----------+------+---+ ZEROPLUS +---+------+----------+-----+------+\n");
#elif CONFIG_ORANGEPI_2G_IOT
@ -827,6 +892,8 @@ void OrangePiReadAll(void)
printf (" | GPIO | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | GPIO |\n");
#ifdef CONFIG_ORANGEPI_PC2
printf (" +------+-----+----------+------+---+ OPi PC2 +---+------+----------+-----+------+\n");
#elif CONFIG_ORANGEPI_PRIME
printf (" +------+-----+----------+------+---+ PRIME +---+------+----------+-----+------+\n");
#elif CONFIG_ORANGEPI_ZEROPLUS
printf (" +------+-----+----------+------+---+ ZEROPLUS +---+------+----------+-----+------+\n");
#elif CONFIG_ORANGEPI_2G_IOT

10
wiringPi/Makefile

@ -47,6 +47,7 @@ LIBS = -lm -lpthread -lrt -lcrypt
ifeq ($(PLATFORM),)
#PLATFORM = OrangePi_2G-IOT
#PLATFORM = OrangePi_PC2
#PLATFORM = OrangePi_PRIME
#PLATFORM = OrangePi_ZEROPLUS
#PLATFORM = OrangePi_A64
#PLATFORM = OrangePi_H3
@ -68,6 +69,11 @@ EXTRA_CFLAGS = -DCONFIG_ORANGEPI_PC2
EXTRA_CFLAGS += -DCONFIG_ORANGEPI
endif
ifeq ($(PLATFORM), OrangePi_PRIME)
EXTRA_CFLAGS = -DCONFIG_ORANGEPI_PRIME
EXTRA_CFLAGS += -DCONFIG_ORANGEPI
endif
ifeq ($(PLATFORM), OrangePi_ZEROPLUS)
EXTRA_CFLAGS = -DCONFIG_ORANGEPI_ZEROPLUS
EXTRA_CFLAGS += -DCONFIG_ORANGEPI
@ -147,6 +153,10 @@ ifeq ($(PLATFORM), OrangePi_PC2)
SRC += OrangePi.c
endif
ifeq ($(PLATFORM), OrangePi_PRIME)
SRC += OrangePi.c
endif
ifeq ($(PLATFORM), OrangePi_ZEROPLUS)
SRC += OrangePi.c
endif

101
wiringPi/OrangePi.c

@ -116,6 +116,101 @@ int ORANGEPI_PIN_MASK[4][32] = //[BANK] [INDEX]
#endif /* CONFIG_ORANGEPI_2G_IOT */
#ifdef CONFIG_ORANGEPI_PRIME
int pinToGpioOrangePi[64] =
{
12, 11, // 0, 1
6, 69, // 2, 3
70, 1, // 4 5
110,0, // 6, 7
3, 68, // 8, 9
71, 15, //10,11
16, 2, //12,13
14, 13, //14,15
72, 19, //16,17
18, 7, //18,19
8, 73, //20,21
9, 10, //22,23
74,107, //24,25
75, 76, //26,27
-1, -1, //28, 29
-1, -1, //30,31
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 47
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,// ... 63
};
int physToGpioOrangePi[64] =//head num map to OrangePi
{
-1, // 0
-1, -1, // 1, 2
12, -1, // 3, 4
11, -1, // 5, 6
6, 69, // 7, 8
-1, 70, // 9, 10
1, 110, //11, 12
0, -1, //13, 14
3, 68, //15, 16
-1, 71, //17, 18
15, -1, //19, 20
16, 2, //21, 22
14, 13, //23, 24
-1, 72, //25, 26
19, 18, //27, 28
7, -1, //29, 30
8, 73, //31, 32
9, -1, //33, 34
10, 74, //35, 36
107, 75, //37, 38
-1, 76, //39, 40
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, //41-> 55
-1, -1, -1, -1, -1, -1, -1, -1 // 56-> 63
};
int physToPinOrangePi[64] = //return wiringPI pin
{
-1, // 0
-1, -1, // 1, 2
0, -1, //3, 4
1, -1, //5, 6
2, 3, //7, 8
-1, 4, //9,10
5, 6, //11,12
7, -1, //13,14
8, 9, //15,16
-1, 10, //17,18
11, -1, //19,20
12, 13, //21,22
14, 15, //23, 24
-1, 16, // 25, 26
17, 18, //27, 28
19, -1, //29, 30
20, 21, //31, 32
22, -1, //33, 34
23, 24, //35, 36
25, 26, //37, 38
-1, 27, //39, 40
// Padding:
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 56
-1, -1, -1, -1, -1, -1, -1, // ... 63
};
int ORANGEPI_PIN_MASK[9][32] = //[BANK] [INDEX]
{
{ 0, 1, 2, 3,-1,-1, 6, 7, 8, 9,10,11,12,13,14,15,16,-1,18,19,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PA
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PB
{-1,-1,-1,-1, 4, 5, 6, 7, 8, 9,10,11,12,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PC
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,-1,-1,14,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PD
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PE
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PF
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PG
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PH
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PI
};
#endif /* PRIME */
#ifdef CONFIG_ORANGEPI_PC2
int pinToGpioOrangePi[64] =
{
@ -131,7 +226,7 @@ int pinToGpioOrangePi[64] =
18, 7, //18,19
8, 200, //20,21
9, 10, //22,23
107,201, //24,25
201,107, //24,25
198, 199, //26,27
-1, -1, //28, 29
@ -1091,13 +1186,13 @@ const char *piModelNames[6] =
#ifdef CONFIG_ORANGEPI_2G_IOT
"OrangePi 2G-IOT",
#elif CONFIG_ORANGEPI_PC2 || CONFIG_ORANGEPI_ZEROPLUS || CONFIG_ORANGEPI_H5_ZEROPLUS2 || CONFIG_ORANGEPI_PRIME
"OrangePi PC2",
"OrangePi H5 family",
#elif CONFIG_ORANGEPI_A64
"OrangePi Win/Winplus",
#elif CONFIG_ORANGEPI_H3 || CONFIG_ORANGEPI_H3_ZEROPLUS2
"OrangePi H3 family",
#elif CONFIG_ORANGEPI_ZERO
"OrangePi Zero",
"OrangePi H2+ family",
#endif
};

Loading…
Cancel
Save