Browse Source

Support Orange Pi Zero Plus (H5)

pull/11/head
leeboby 5 years ago
parent
commit
81f3b0b81c
  1. 1
      .gitignore
  2. 2
      build
  3. 10
      examples/blink.c
  4. 10
      gpio/Makefile
  5. 78
      gpio/OrangePi.c
  6. 10
      wiringPi/Makefile
  7. 107
      wiringPi/OrangePi.c
  8. 6
      wiringPi/OrangePi.h

1
.gitignore vendored

@ -6,3 +6,4 @@ debian-template/wiringPi
debian-template/wiringpi-*.deb debian-template/wiringpi-*.deb
gpio/gpio gpio/gpio
examples/speed examples/speed
examples/blink

2
build

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

10
examples/blink.c

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

10
gpio/Makefile

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

78
gpio/OrangePi.c

@ -66,7 +66,79 @@ char *physNames[64] =
"GPIO.19", "GPIO.20", "GPIO.19", "GPIO.20",
NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
}; };
#endif #endif /* PC2 */
#ifdef CONFIG_ORANGEPI_ZEROPLUS
int physToWpi [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
-1, -1, //27, 28
-1, -1, //29, 30
-1, -1, //31, 32
-1, -1, //33, 34
-1, -1, //35, 36
-1, -1, //37, 38
-1, -1, //39, 40
-1, -1, //41, 42
// Padding:
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 56
-1, -1, -1, -1, -1, -1, -1, // ... 63
};
char *physNames[64] =
{
NULL,
" 3.3v", "5v ",
" SDA.0", "5v ",
" SCL.0", "GND ",
" PA6", "TxD.1 ",
" GND", "RxD.1 ",
" RXD.2", "PA07 ",
" TXD.2", "GND ",
" CTS.2", "SDA.1 ",
" 3.3v", "SCL.1 ",
" MOSI.1", "GND ",
" MISO.1", "RTS.2 ",
" SCLK.1", "CS.1 ",
" GND", "PA10 ",
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL,
};
#endif /* ZEROPLUS */
#ifdef CONFIG_ORANGEPI_2G_IOT #ifdef CONFIG_ORANGEPI_2G_IOT
char *physNames[64] = char *physNames[64] =
@ -722,6 +794,8 @@ void OrangePiReadAll(void)
wiringPiDebug = FALSE; wiringPiDebug = FALSE;
#ifdef CONFIG_ORANGEPI_PC2 #ifdef CONFIG_ORANGEPI_PC2
printf (" +------+-----+----------+------+---+ OPi PC2 +---+------+----------+-----+------+\n"); printf (" +------+-----+----------+------+---+ OPi PC2 +---+------+----------+-----+------+\n");
#elif CONFIG_ORANGEPI_ZEROPLUS
printf (" +------+-----+----------+------+---+ ZEROPLUS +---+------+----------+-----+------+\n");
#elif CONFIG_ORANGEPI_2G_IOT #elif CONFIG_ORANGEPI_2G_IOT
printf (" +-----+-----+----------+------+---+OrangePi 2G-IOT+---+---+------+---------+-----+--+\n"); printf (" +-----+-----+----------+------+---+OrangePi 2G-IOT+---+---+------+---------+-----+--+\n");
#elif CONFIG_ORANGEPI_H3 || CONFIG_ORANGEPI_H3_ZEROPLUS2 #elif CONFIG_ORANGEPI_H3 || CONFIG_ORANGEPI_H3_ZEROPLUS2
@ -753,6 +827,8 @@ void OrangePiReadAll(void)
printf (" | GPIO | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | GPIO |\n"); printf (" | GPIO | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | GPIO |\n");
#ifdef CONFIG_ORANGEPI_PC2 #ifdef CONFIG_ORANGEPI_PC2
printf (" +------+-----+----------+------+---+ OPi PC2 +---+------+----------+-----+------+\n"); printf (" +------+-----+----------+------+---+ OPi PC2 +---+------+----------+-----+------+\n");
#elif CONFIG_ORANGEPI_ZEROPLUS
printf (" +------+-----+----------+------+---+ ZEROPLUS +---+------+----------+-----+------+\n");
#elif CONFIG_ORANGEPI_2G_IOT #elif CONFIG_ORANGEPI_2G_IOT
printf (" +------+-----+----------+------+---+OrangePi 2G-IOT+---+------+----------+-----+-----+\n"); printf (" +------+-----+----------+------+---+OrangePi 2G-IOT+---+------+----------+-----+-----+\n");
#elif CONFIG_ORANGEPI_H3 || CONFIG_ORANGEPI_H3_ZEROPLUS2 #elif CONFIG_ORANGEPI_H3 || CONFIG_ORANGEPI_H3_ZEROPLUS2

10
wiringPi/Makefile

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

107
wiringPi/OrangePi.c

@ -209,7 +209,108 @@ int ORANGEPI_PIN_MASK[9][32] = //[BANK] [INDEX]
{-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,},//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 {-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 /* CONFIG_ORANGEPI_2G_IOT */ #endif /* PC2 */
#ifdef CONFIG_ORANGEPI_ZEROPLUS
int pinToGpioOrangePi [64] =
{
12, 11, 6, 198, 199, 1, 7, 0, 3, // From the Original Wiki - GPIO 0 through 7: wpi 0 - 7
19, 18, // I2C - SDA0, SCL0 wpi 8 - 9
15, 16, // SPI - CE1, CE0 wpi 10 - 11
2, 14, 13, // SPI - MOSI, MISO, SCLK wpi 12 - 14
10, -1, // UART - Tx, Rx wpi 15 - 16
-1, -1, -1, -1, // Rev 2: New GPIOs 8 though 11 wpi 17 - 20
-1, -1, -1, -1, -1, // B+ wpi 21, 22, 23, 24, 25
-1, -1, // wpi 26, 27
-1, -1, //PA4, PA5(PWM0) wpi 28, 29
-1, -1, // B+ wpi 30, 31
// Padding:
-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] =
{
-1, // 0
-1, -1, // 1, 2
12, -1,
11, -1,
6, 198,
-1, 199,
1, 7,
0, -1,
3, 19,
-1, 18,
15, -1,
16, 2,
14, 13,
-1, 10, // 25, 26
-1, -1, //27, 28
-1, -1, //29, 30
-1, -1, //31, 32
-1, -1, //33, 34
-1, -1, //35, 36
-1, -1, //37, 38
-1, -1, //39, 40
-1, -1, //41, 42
// Padding:
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 56
-1, -1, -1, -1, -1, -1, -1, // ... 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
-1, -1, //27, 28
-1, -1, //29, 30
-1, -1, //31, 32
-1, -1, //33, 34
-1, -1, //35, 36
-1, -1, //37, 38
-1, -1, //39, 40
-1, -1, //41, 42
// Padding:
-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[12][32] = //[BANK] [INDEX]
{
{ 0, 1, 2, 3,-1,-1, 6, 7,-1,-1,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,-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,},//PC
{-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,},//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, 6, 7,-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
{-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,},//PJ
{-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,},//PK
{-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,},//PL
};
#endif /* ZEROPLUS */
#ifdef CONFIG_ORANGEPI_A64 #ifdef CONFIG_ORANGEPI_A64
int pinToGpioOrangePi [64] = int pinToGpioOrangePi [64] =
@ -989,7 +1090,7 @@ const char *piModelNames[6] =
"Compute Module", "Compute Module",
#ifdef CONFIG_ORANGEPI_2G_IOT #ifdef CONFIG_ORANGEPI_2G_IOT
"OrangePi 2G-IOT", "OrangePi 2G-IOT",
#elif CONFIG_ORANGEPI_PC2 #elif CONFIG_ORANGEPI_PC2 || CONFIG_ORANGEPI_ZEROPLUS || CONFIG_ORANGEPI_H5_ZEROPLUS2 || CONFIG_ORANGEPI_PRIME
"OrangePi PC2", "OrangePi PC2",
#elif CONFIG_ORANGEPI_A64 #elif CONFIG_ORANGEPI_A64
"OrangePi Win/Winplus", "OrangePi Win/Winplus",
@ -1658,7 +1759,7 @@ int isOrangePi(void)
#ifdef CONFIG_ORANGEPI_2G_IOT #ifdef CONFIG_ORANGEPI_2G_IOT
/* Support: OrangePi 2G-IOT and OrangePi i96 */ /* Support: OrangePi 2G-IOT and OrangePi i96 */
char *OrangePi_string = "rda8810"; char *OrangePi_string = "rda8810";
#elif CONFIG_ORANGEPI_PC2 #elif CONFIG_ORANGEPI_PC2 || CONFIG_ORANGEPI_ZEROPLUS || CONFIG_ORANGEPI_H5_ZEROPLUS2 || CONFIG_ORANGEPI_PRIME
/* Support: OrangePi PC2 */ /* Support: OrangePi PC2 */
char *OrangePi_string = "sun50iw2"; char *OrangePi_string = "sun50iw2";
#elif CONFIG_ORANGEPI_A64 #elif CONFIG_ORANGEPI_A64

6
wiringPi/OrangePi.h

@ -30,7 +30,7 @@
#endif /* CONFIG_ORANGEPI_2G_IOT */ #endif /* CONFIG_ORANGEPI_2G_IOT */
#ifdef CONFIG_ORANGEPI_PC2 #if CONFIG_ORANGEPI_PC2 || CONFIG_ORANGEPI_ZEROPLUS || CONFIG_ORANGEPI_H5_ZEROPLUS2 || CONFIG_ORANGEPI_PRIME
/************** OrangePi H5 ***********************/ /************** OrangePi H5 ***********************/
#define GPIOA_BASE (0x01C20000) #define GPIOA_BASE (0x01C20000)
#define GPIO_NUM (0x40) #define GPIO_NUM (0x40)
@ -203,13 +203,13 @@ extern const char *piModelNames[6];
#ifdef CONFIG_ORANGEPI_2G_IOT #ifdef CONFIG_ORANGEPI_2G_IOT
extern int ORANGEPI_PIN_MASK[4][32]; extern int ORANGEPI_PIN_MASK[4][32];
#elif CONFIG_ORANGEPI_PC2 #elif CONFIG_ORANGEPI_PC2 || CONFIG_ORANGEPI_PRIME
extern int ORANGEPI_PIN_MASK[9][32]; extern int ORANGEPI_PIN_MASK[9][32];
#elif CONFIG_ORANGEPI_A64 #elif CONFIG_ORANGEPI_A64
extern int ORANGEPI_PIN_MASK[12][32]; extern int ORANGEPI_PIN_MASK[12][32];
#elif CONFIG_ORANGEPI_H3 #elif CONFIG_ORANGEPI_H3
extern int ORANGEPI_PIN_MASK[9][32]; extern int ORANGEPI_PIN_MASK[9][32];
#elif CONFIG_ORANGEPI_ZERO || CONFIG_ORANGEPI_H3_ZEROPLUS2 #elif CONFIG_ORANGEPI_ZERO || CONFIG_ORANGEPI_H3_ZEROPLUS2 || CONFIG_ORANGEPI_ZEROPLUS || CONFIG_ORANGEPI_H5_ZEROPLUS2
extern int ORANGEPI_PIN_MASK[12][32]; extern int ORANGEPI_PIN_MASK[12][32];
#elif CONFIG_ORANGEPI_RK3399 #elif CONFIG_ORANGEPI_RK3399
extern int ORANGEPI_PIN_MASK[5][32]; extern int ORANGEPI_PIN_MASK[5][32];

Loading…
Cancel
Save