Browse Source

Update for Orange Pi Zero

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

6
examples/blink.c

@ -7,16 +7,16 @@ int main (void)
wiringPiSetup () ; wiringPiSetup () ;
for (i=0; i<28; i++) for (i=0; i<17; i++)
pinMode (i, OUTPUT) ; pinMode (i, OUTPUT) ;
for (;;) for (;;)
{ {
for (i=0; i<28; i++) for (i=0; i<17; 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<17; i++)
digitalWrite (i, LOW) ; // Off digitalWrite (i, LOW) ; // Off
delay (500) ; delay (500) ;
} }

53
gpio/OrangePi.c

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

7
gpio/gpio.c

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

2
wiringPi/Makefile

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

104
wiringPi/OrangePi.c

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

2
wiringPi/OrangePi.h

@ -53,7 +53,7 @@
#endif #endif
/************** OrangePi H3 ***********************/ /************** 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 GPIOA_BASE (0x01C20000)
#define GPIO_NUM (0x40) #define GPIO_NUM (0x40)
#define GPIO_BASE_MAP (0x01C20800) #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) ; write (node->fd, b, 2) ;
} }
/* /*
* myAnalogRead: * myAnalogRead:
********************************************************************************* *********************************************************************************

2
wiringPi/wiringPi.c

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

Loading…
Cancel
Save