Browse Source

Support Orange Pi PC 2

pull/11/head
leeboby 5 years ago
parent
commit
dd0f3178b2
  1. 6
      examples/blink.c
  2. 85
      gpio/OrangePi.c
  3. 78
      wiringPi/OrangePi.c
  4. 4
      wiringPi/OrangePi.h
  5. 2
      wiringPi/wiringPi.c

6
examples/blink.c

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

85
gpio/OrangePi.c

@ -7,27 +7,28 @@
#ifdef CONFIG_ORANGEPI_PC2 #ifdef CONFIG_ORANGEPI_PC2
int physToWpi[64] = 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, 31, //27, 28 17, 18, //27, 28
21, -1, //29, 30 19, -1, //29, 30
22, 26, //31, 32 20, 21, //31, 32
23, -1, //33, 34 22, -1, //33, 34
24, 27, //35, 36 23, 24, //35, 36
25, 28, //37, 38 25, 26, //37, 38
-1, 29, //39, 40 -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, -1, -1, -1, -1, -1, -1, -1, //41-> 55
-1, -1, -1, -1, -1, -1, -1, -1 // 56-> 63 -1, -1, -1, -1, -1, -1, -1, -1 // 56-> 63
}; };
@ -38,24 +39,24 @@ char *physNames[64] =
" 3.3v", "5v ", " 3.3v", "5v ",
" SDA.0", "5V ", " SDA.0", "5V ",
" SCL.0", "0v ", " SCL.0", "GND ",
" GPIO.7", "TxD3 ", " PWM1", "PC05 ",
" 0v", "RxD3 ", " GND", "PC06 ",
" RxD2", "GPIO.1 ", " RxD.2", "PD14 ",
" TxD2", "0v ", " TxD.2", "GND ",
" CTS2", "GPIO.4 ", " CTS.2", "PC04 ",
" 3.3v", "GPIO.5 ", " 3.3v", "PC07 ",
" MOSI", "0v ", " MOSI.1", "GND ",
" MISO", "RTS2 ", " MISO.1", "RTS.2 ",
" SCLK", "CE0 ", " SCLK.1", "CS.1 ",
" 0v", "GPIO.11 ", " GND", "PA21 ",
" SDA.1", "SCL.1 ", " SDA.1", "SCL.1 ",
" GPIO.21", "0v ", " PA07", "GND ",
" GPIO.22", "RTS1 ", " PA08", "RTS.1 ",
" GPIO.23", "0v ", " PA09", "GND ",
" GPIO.24", "CTS1 ", " PA10", "CTS.1 ",
" GPIO.25", "TxD1 ", " PD11", "TxD.1 ",
" 0v", "RxD1 ", " GND", "RxD.1 ",
NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL,
@ -740,11 +741,11 @@ 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");
printf (" +------+-----+----------+------+---+----++----+---+------+----------+-----+------+\n"); printf (" +------+-----+----------+------+---+----++----+---+------+----------+-----+------+\n");
#if defined CONFIG_ORANGEPI_H3 || defined CONFIG_ORANGEPI_RK3399 || CONFIG_ORANGEPI_4 #if defined CONFIG_ORANGEPI_H3 || defined CONFIG_ORANGEPI_RK3399 || CONFIG_ORANGEPI_4 || CONFIG_ORANGEPI_PC2 || CONFIG_ORANGEPI_PRIME
for (pin = 1 ; pin <= 42 ; pin += 2) for (pin = 1 ; pin <= 40; pin += 2)
#elif CONFIG_ORANGEPI_LITE2 || CONFIG_ORANGEPI_H3_ZEROPLUS2 || CONFIG_ORANGEPI_3 || CONFIG_ORANGEPI_ZERO #elif CONFIG_ORANGEPI_LITE2 || CONFIG_ORANGEPI_H3_ZEROPLUS2 || CONFIG_ORANGEPI_3 || CONFIG_ORANGEPI_ZERO || CONFIG_ORANGEPI_ZEROPLUS || CONFIG_ORANGEPI_H5_ZEROPLUS2 || CONFIG_ORANGEPI_R1
for (pin = 1 ; pin <= 26 ; pin += 2) for (pin = 1 ; pin <= 26; pin += 2)
#endif #endif
readallPhys(pin); readallPhys(pin);

78
wiringPi/OrangePi.c

@ -119,22 +119,23 @@ int ORANGEPI_PIN_MASK[4][32] = //[BANK] [INDEX]
#ifdef CONFIG_ORANGEPI_PC2 #ifdef CONFIG_ORANGEPI_PC2
int pinToGpioOrangePi[64] = int pinToGpioOrangePi[64] =
{ {
1,110, // 0, 1 12, 11, // 0, 1
0, 3, // 2, 3 6, 69, // 2, 3
68, 71, // 4 5 70, 1, // 4 5
2, 6, // 6, 7 110,0, // 6, 7
12, 11, // 8, 9 3, 68, // 8, 9
13, 21, //10,11 71, 15, //10,11
15, 16, //12,13 16, 2, //12,13
14, 69, //14,15 14, 13, //14,15
70, -1, //16,17 21, 19, //16,17
-1, -1, //18,19 18, 7, //18,19
-1, 7, //20,21 8, 200, //20,21
8, 9, //22,23 9, 10, //22,23
10,107, //24,25 107,201, //24,25
200,201, //26,27 198, 199, //26,27
198,199, //28,29
19, 18, //30,31 -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, // ... 47
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,// ... 63 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,// ... 63
@ -171,26 +172,25 @@ int physToPinOrangePi[64] = //return wiringPI pin
{ {
-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
17, 18, //27, 28
30, 31, //27, 28 19, -1, //29, 30
21, -1, //29, 30 20, 21, //31, 32
22, 26, //31, 32 22, -1, //33, 34
23, -1, //33, 34 23, 24, //35, 36
24, 27, //35, 36 25, 26, //37, 38
25, 28, //37, 38 -1, 27, //39, 40
-1, 29, //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
@ -199,9 +199,9 @@ int physToPinOrangePi[64] = //return wiringPI pin
int ORANGEPI_PIN_MASK[9][32] = //[BANK] [INDEX] 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,20,21,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PA { 0, 1, 2, 3,-1,-1, 6, 7, 8, 9,10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,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,},//PF
@ -642,7 +642,7 @@ int physToGpioOrangePi [64] =
-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 physToPinOrangePi [64] = int physToPinOrangePi [64] =
{ {

4
wiringPi/OrangePi.h

@ -39,6 +39,7 @@
#define GPIOL_BASE (0x01F02c00) #define GPIOL_BASE (0x01F02c00)
#define GPIOL_BASE_MAP (0x01F02000) #define GPIOL_BASE_MAP (0x01F02000)
#define MAP_SIZE_L (4096 * 2) #define MAP_SIZE_L (4096 * 2)
#define GPIO_PWM_OP (0x01C21000)
#endif #endif
/************** OrangePi A64 ***********************/ /************** OrangePi A64 ***********************/
@ -50,6 +51,7 @@
#define GPIOL_BASE (0x01F02c00) #define GPIOL_BASE (0x01F02c00)
#define GPIOL_BASE_MAP (0x01F02000) #define GPIOL_BASE_MAP (0x01F02000)
#define MAP_SIZE_L (4096 * 2) #define MAP_SIZE_L (4096 * 2)
#define GPIO_PWM_OP (0x01C21000)
#endif #endif
/************** OrangePi H3 ***********************/ /************** OrangePi H3 ***********************/
@ -61,7 +63,7 @@
#define GPIOL_BASE (0x01F02c00) #define GPIOL_BASE (0x01F02c00)
#define GPIOL_BASE_MAP (0x01F02000) #define GPIOL_BASE_MAP (0x01F02000)
#define MAP_SIZE_L (4096 * 2) #define MAP_SIZE_L (4096 * 2)
#define GPIO_PWM_OP (0x01C21000) #define GPIO_PWM_OP (0x01C21000)
#endif #endif
/*********** OrangePi LITE2/OnePlus/PC3 *************/ /*********** OrangePi LITE2/OnePlus/PC3 *************/

2
wiringPi/wiringPi.c

@ -2377,7 +2377,7 @@ int wiringPiSetup (void)
return wiringPiFailure (WPI_ALMOST, "wiringPiSetup: mmap (PWM) failed: %s\n", strerror (errno)) ; return wiringPiFailure (WPI_ALMOST, "wiringPiSetup: mmap (PWM) failed: %s\n", strerror (errno)) ;
#if CONFIG_ORANGEPI_A64 || CONFIG_ORANGEPI_H3_ZEROPLUS2 || CONFIG_ORANGEPI_3 #if CONFIG_ORANGEPI_A64 || CONFIG_ORANGEPI_H3_ZEROPLUS2 || CONFIG_ORANGEPI_3 || CONFIG_ORANGEPI_H5_ZEROPLUS2
/* GPIOC connect CPU with Modem */ /* GPIOC connect CPU with Modem */
OrangePi_gpioC = (uint32_t *)mmap(0, BLOCK_SIZE, PROT_READ | PROT_WRITE, OrangePi_gpioC = (uint32_t *)mmap(0, BLOCK_SIZE, PROT_READ | PROT_WRITE,
MAP_SHARED, fd, GPIOL_BASE_MAP); MAP_SHARED, fd, GPIOL_BASE_MAP);

Loading…
Cancel
Save