Browse Source

Update for Orange Pi Zero

pull/11/head
leeboby 5 years ago
parent
commit
b74f6e4084
  1. 6
      examples/blink.c
  2. 71
      gpio/OrangePi.c
  3. 7
      gpio/gpio.c
  4. 2
      gpio/readall.c
  5. 2
      wiringPi/Makefile
  6. 108
      wiringPi/OrangePi.c
  7. 2
      wiringPi/OrangePi.h
  8. 1
      wiringPi/pcf8591.c
  9. 2
      wiringPi/wiringPi.c

6
examples/blink.c

@ -7,16 +7,16 @@ int main (void)
wiringPiSetup () ;
for (i=0; i<28; i++)
for (i=0; i<17; i++)
pinMode (i, OUTPUT) ;
for (;;)
{
for (i=0; i<28; i++)
for (i=0; i<17; i++)
digitalWrite (i, HIGH) ; // On
delay (500) ; // mS
for (i=0; i<28; i++)
for (i=0; i<17; i++)
digitalWrite (i, LOW) ; // Off
delay (500) ;
}

71
gpio/OrangePi.c

@ -337,30 +337,29 @@ int physToWpi [64] =
{
-1, // 0
-1, -1, // 1, 2
8, -1, // 3, 4
9, -1, // 5, 6
7, 15, // 7, 8
-1, 16, // 9, 10
0, 1, //11, 12
2, -1, //13, 14
3, 4, //15, 16
-1, 5, //17, 18
12, -1, //19, 20
13, 6, //21, 22
14, 10, //23, 24
-1, 11, //25, 26
30, -1, //27, 28
-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, //29, 30
-1, -1, //31, 32
-1, -1, //33, 34
-1, -1, //35, 36
-1, -1, //37, 38
-1, -1, //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
-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, -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] =
@ -370,18 +369,16 @@ char *physNames[64] =
" 3.3v", "5v ",
" SDA.0", "5V ",
" SCL.0", "0v ",
" GPIO.7", "TxD3 ",
" 0v", "RxD3 ",
" RxD2", "GPIO.1 ",
" TxD2", "0v ",
" CTS2", "GPIO.4 ",
" 3.3v", "GPIO.5 ",
" MOSI", "0v ",
" MISO", "RTS2 ",
" SCLK", "CE0 ",
" 0v", "GPIO.11 ",
"STAT-LED", "PWR-LED ",
" PWM.1", "TXD.1 ",
" GND", "RxD.1 ",
" RxD.2", "PA07 ",
" TxD.2", "GND ",
" CTS.2", "SDA.1 ",
" 3.3v", "SCK.1 ",
" MOSI.1", "GND ",
" MISO.1", "RTS.2 ",
" SCLK.1", "CS.1 ",
" GND", "PA10 ",
NULL, NULL,
NULL, NULL,
@ -400,6 +397,7 @@ char *physNames[64] =
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL,
};
#endif
@ -744,7 +742,8 @@ void OrangePiReadAll(void)
#if defined CONFIG_ORANGEPI_H3 || defined CONFIG_ORANGEPI_RK3399 || CONFIG_ORANGEPI_4
for (pin = 1 ; pin <= 42 ; pin += 2)
#else CONFIG_ORANGEPI_LITE2 || CONFIG_ORANGEPI_H3_ZEROPLUS2 || CONFIG_ORANGEPI_3
#elif CONFIG_ORANGEPI_LITE2 || CONFIG_ORANGEPI_H3_ZEROPLUS2 || CONFIG_ORANGEPI_3 || CONFIG_ORANGEPI_ZERO
for (pin = 1 ; pin <= 26 ; pin += 2)
#endif
readallPhys(pin);

7
gpio/gpio.c

@ -445,12 +445,12 @@ static void doSerialTest (UNU int argc, char *argv [])
if ((fd = serialOpen (port, 115200)) < 0) {
fprintf (stderr, "Unable to open serial device: %s\n", strerror (errno)) ;
return 1 ;
return;
}
if (wiringPiSetup () == -1) {
fprintf (stdout, "Unable to start wiringPi: %s\n", strerror (errno)) ;
return 1 ;
return;
}
nextTime = millis () + 300 ;
@ -473,7 +473,7 @@ static void doSerialTest (UNU int argc, char *argv [])
}
printf ("\n") ;
return 0 ;
return;
}
@ -1401,7 +1401,6 @@ static void doPwmClock (int argc, char *argv [])
static void doVersion (char *argv [])
{
int model, rev, mem, maker, warranty ;
struct stat statBuf ;
char name [80] ;
FILE *fd ;

2
gpio/readall.c

@ -181,7 +181,7 @@ void readallPhys (int physPin)
else
pin = physToWpi [physPin] ;
printf (" | %4s", alts [getAlt (pin)]) ;
printf (" | %4s", alts [getAlt(pin)]) ;
printf (" | %d", digitalRead (pin)) ;
}

2
wiringPi/Makefile

@ -39,7 +39,7 @@ DEBUG = -O2
CC = gcc
INCLUDE = -I.
DEFS = -D_GNU_SOURCE
CFLAGS = $(DEBUG) $(DEFS) -Wformat=2 -Wall -Wextra -Winline $(INCLUDE) -pipe -fPIC
CFLAGS = $(DEBUG) $(DEFS) -Wformat=2 -Wextra -Winline $(INCLUDE) -pipe -fPIC
#CFLAGS = $(DEBUG) $(DEFS) -Wformat=2 -Wall -Wextra -Wconversion -Winline $(INCLUDE) -pipe -fPIC
LIBS = -lm -lpthread -lrt -lcrypt

108
wiringPi/OrangePi.c

@ -506,15 +506,15 @@ int ORANGEPI_PIN_MASK[12][32] = //[BANK] [INDEX]
#ifdef CONFIG_ORANGEPI_ZERO
int pinToGpioOrangePi[64] =
{
17, 18, 27, 22, 23, 24, 25, 4, // From the Original Wiki - GPIO 0 through 7: wpi 0 - 7
2, 3, // I2C - SDA0, SCL0 wpi 8 - 9
8, 7, // SPI - CE1, CE0 wpi 10 - 11
10, 9, 11, // SPI - MOSI, MISO, SCLK wpi 12 - 14
14, 15, // UART - Tx, Rx wpi 15 - 16
12, 11, 6, 198, 199, 1, 7, 0, // From the Original Wiki - GPIO 0 through 7: wpi 0 - 7
3, 19, // I2C - SDA0, SCL0 wpi 8 - 9
18, 15, // SPI - CE1, CE0 wpi 10 - 11
16, 2, 14, // SPI - MOSI, MISO, SCLK wpi 12 - 14
13, 10, // UART - Tx, Rx wpi 15 - 16
-1, -1, -1, -1, // Rev 2: New GPIOs 8 though 11 wpi 17 - 20
5, 6, 13, 19, 26, // B+ wpi 21, 22, 23, 24, 25
12, 16, 20, 21, // B+ wpi 26, 27, 28, 29
0, 1, // B+ wpi 30, 31
-1, -1, -1, -1, -1, // B+ wpi 21, 22, 23, 24, 25
-1, -1, -1, -1, // B+ wpi 26, 27, 28, 29
-1, 1, // B+ wpi 30, 31
// Padding:
@ -526,26 +526,26 @@ int physToGpioOrangePi[64] =
{
-1, // 0
-1, -1, // 1, 2
2, -1,
3, -1,
4, 14,
-1, 15,
17, 18,
27, -1,
22, 23,
-1, 24,
10, -1,
9, 25,
11, 8,
-1, 7, // 25, 26
0, 1, //27, 28
5, -1, //29, 30
6, 12, //31, 32
13, -1, //33, 34
19, 16, //35, 36
26, 20, //37, 38
-1, 21, //39, 40
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
// Padding:
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 56
@ -554,39 +554,39 @@ int physToGpioOrangePi[64] =
int physToPinOrangePi[64] =
{
-1, // 0
-1, -1, // 1, 2
8, -1, //3, 4
9, -1, //5, 6
7, 15, //7, 8
-1, 16, //9,10
0, 1, //11,12
2, -1, //13,14
3, 4, //15,16
-1, 5, //17,18
12, -1, //19,20
13, 6, //21,22
14, 10, //23, 24
-1, 11, // 25, 26
-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
30, 31, //27, 28
21, -1, //29, 30
22, 26, //31, 32
23, -1, //33, 34
24, 27, //35, 36
25, 28, //37, 38
-1, 29, //39, 40
-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
// 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[12][32] = //[BANK] [INDEX]
{
{ 0, 1, 2, 3,-1,-1, 6, 7,-1,-1,10,11,12,13,14,15,16,17,18,19,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PA
{ 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
{ 0, 1, 2, 3, 4,-1,-1, 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,},//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,},//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
@ -595,7 +595,7 @@ int ORANGEPI_PIN_MASK[12][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,},//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,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PL
{-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
@ -993,7 +993,7 @@ const char *piModelNames[6] =
"OrangePi PC2",
#elif CONFIG_ORANGEPI_A64
"OrangePi Win/Winplus",
#elif CONFIG_ORANGEPI_H3
#elif CONFIG_ORANGEPI_H3 || CONFIG_ORANGEPI_H3_ZEROPLUS2
"OrangePi H3 family",
#elif CONFIG_ORANGEPI_ZERO
"OrangePi Zero",

2
wiringPi/OrangePi.h

@ -53,7 +53,7 @@
#endif
/************** OrangePi H3 ***********************/
#if CONFIG_ORANGEPI_H3 || CONFIG_ORANGEPI_H3_ZEROPLUS2
#if CONFIG_ORANGEPI_H3 || CONFIG_ORANGEPI_H3_ZEROPLUS2 || CONFIG_ORANGEPI_ZERO
#define GPIOA_BASE (0x01C20000)
#define GPIO_NUM (0x40)
#define GPIO_BASE_MAP (0x01C20800)

1
wiringPi/pcf8591.c

@ -44,7 +44,6 @@ static void myAnalogWrite (struct wiringPiNodeStruct *node, UNU int pin, int val
write (node->fd, b, 2) ;
}
/*
* myAnalogRead:
*********************************************************************************

2
wiringPi/wiringPi.c

@ -2362,7 +2362,7 @@ int wiringPiSetup (void)
#else
#if ! (defined CONFIG_ORANGEPI_RK3399 || defined CONFIG_ORANGEPI_4)
/* GPIO */
#ifdef CONFIG_ORANGEPI_LITE2 || CONFIG_ORANGEPI_3
#if (CONFIG_ORANGEPI_LITE2 || CONFIG_ORANGEPI_3)
gpio = (uint32_t *)mmap(0, BLOCK_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, GPIO_BASE);
#else
gpio = (uint32_t *)mmap(0, BLOCK_SIZE * 10, PROT_READ | PROT_WRITE, MAP_SHARED, fd, GPIO_BASE);

Loading…
Cancel
Save