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 () ;
for (i=0; i<17; i++)
for (i=0; i<28; i++)
pinMode (i, OUTPUT) ;
for (;;)
{
for (i=0; i<17; i++)
for (i=0; i<28; i++)
digitalWrite (i, HIGH) ; // On
delay (500) ; // mS
for (i=0; i<17; i++)
for (i=0; i<28; i++)
digitalWrite (i, LOW) ; // Off
delay (500) ;
}

85
gpio/OrangePi.c

@ -7,27 +7,28 @@
#ifdef CONFIG_ORANGEPI_PC2
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, 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, // 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
};
@ -38,24 +39,24 @@ 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 ",
" 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", "PA21 ",
" SDA.1", "SCL.1 ",
" GPIO.21", "0v ",
" GPIO.22", "RTS1 ",
" GPIO.23", "0v ",
" GPIO.24", "CTS1 ",
" GPIO.25", "TxD1 ",
" 0v", "RxD1 ",
" PA07", "GND ",
" PA08", "RTS.1 ",
" PA09", "GND ",
" PA10", "CTS.1 ",
" PD11", "TxD.1 ",
" GND", "RxD.1 ",
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 (" +------+-----+----------+------+---+----++----+---+------+----------+-----+------+\n");
#if defined CONFIG_ORANGEPI_H3 || defined CONFIG_ORANGEPI_RK3399 || CONFIG_ORANGEPI_4
for (pin = 1 ; pin <= 42 ; pin += 2)
#if defined CONFIG_ORANGEPI_H3 || defined CONFIG_ORANGEPI_RK3399 || CONFIG_ORANGEPI_4 || CONFIG_ORANGEPI_PC2 || CONFIG_ORANGEPI_PRIME
for (pin = 1 ; pin <= 40; pin += 2)
#elif CONFIG_ORANGEPI_LITE2 || CONFIG_ORANGEPI_H3_ZEROPLUS2 || CONFIG_ORANGEPI_3 || CONFIG_ORANGEPI_ZERO
for (pin = 1 ; pin <= 26 ; pin += 2)
#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)
#endif
readallPhys(pin);

78
wiringPi/OrangePi.c

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

4
wiringPi/OrangePi.h

@ -39,6 +39,7 @@
#define GPIOL_BASE (0x01F02c00)
#define GPIOL_BASE_MAP (0x01F02000)
#define MAP_SIZE_L (4096 * 2)
#define GPIO_PWM_OP (0x01C21000)
#endif
/************** OrangePi A64 ***********************/
@ -50,6 +51,7 @@
#define GPIOL_BASE (0x01F02c00)
#define GPIOL_BASE_MAP (0x01F02000)
#define MAP_SIZE_L (4096 * 2)
#define GPIO_PWM_OP (0x01C21000)
#endif
/************** OrangePi H3 ***********************/
@ -61,7 +63,7 @@
#define GPIOL_BASE (0x01F02c00)
#define GPIOL_BASE_MAP (0x01F02000)
#define MAP_SIZE_L (4096 * 2)
#define GPIO_PWM_OP (0x01C21000)
#define GPIO_PWM_OP (0x01C21000)
#endif
/*********** 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)) ;
#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 */
OrangePi_gpioC = (uint32_t *)mmap(0, BLOCK_SIZE, PROT_READ | PROT_WRITE,
MAP_SHARED, fd, GPIOL_BASE_MAP);

Loading…
Cancel
Save