Skip to content

Commit

Permalink
Merge pull request friendlyarm#4 from Tea-NT/master
Browse files Browse the repository at this point in the history
Add NanoPC-T3 support GPIO input and Output.
  • Loading branch information
friendlyarm authored Oct 11, 2019
2 parents fa138e2 + fe4c18b commit bd92a83
Show file tree
Hide file tree
Showing 3 changed files with 493 additions and 97 deletions.
17 changes: 11 additions & 6 deletions gpio/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1132,15 +1132,20 @@ int main (int argc, char *argv [])
BoardHardwareInfo* retBoardInfo;
int ret = getBoardType(&retBoardInfo);
if (ret >= 0) {
if (retBoardInfo->boardTypeId > ALLWINNER_BASE && retBoardInfo->boardTypeId <= ALLWINNER_MAX
&& retBoardInfo->boardTypeId != NanoPi_A64) {
if (retBoardInfo->boardTypeId > ALLWINNER_BASE && retBoardInfo->boardTypeId <= ALLWINNER_MAX
&& retBoardInfo->boardTypeId != NanoPi_A64) {
printf ("NanoPi Details:\n") ;
printf (" Type: %s, Revision: %d, Maker: FriednlyELEC\n\n",
retBoardInfo->boardDisplayName, retBoardInfo->kernelRevision) ;
printf (" Type: %s, Revision: %d, Maker: FriednlyELEC\n\n",
retBoardInfo->boardDisplayName, retBoardInfo->kernelRevision) ;
} else {
printf ("This NanoPi model is currently not supported. ") ;
if (retBoardInfo->boardTypeId == NanoPC_T3) {
printf(
"This NanoPi-T3 is only supported GPIO input and GPIO outpu. "
"Please Careful! ");
} else {
printf ("This NanoPi model is currently not supported. ") ;
}
}

} else {
printf ("Your NanoPi has an unknown model type. Please report this to\n") ;
printf (" [email protected]\n") ;
Expand Down
99 changes: 99 additions & 0 deletions gpio/readall.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,90 @@ static char *physNames_duo2 [MAX_PIN_COUNT] =
NULL //73
} ;

static int physToWpi_t3 [MAX_PIN_COUNT] =
{
-1, // 0
-1, -1, // 1, 2
3, 4, // 3, 4
-1, -1, // 5, 6
7, 8, // 7, 8

9, 10, // 9, 10
11, 12, //11, 12
13, 14, //13, 14
15, 16, //15, 16
17, 18, //17, 18
19, 20, //19, 20
21, 22, //21, 22
23, 24, //23, 24

25, -1, //25, 26
27, -1, //27, 28
-1, -1, //29, 30
-1, -1, //31, 32


/* ---------nanopi duo end----------- */
-1, -1, //33, 34
-1, -1, //35, 36

-1, -1, //37, 38

/* 39~63 */
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,

/* 64~73 */
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
} ;

static char *physNames_t3 [MAX_PIN_COUNT] =
{
NULL,
// 32 Pin
" 3.3v", "0v ",
" GPIOD20", "GPIOD16 ",
"I2C0_SCL", "I2C0_SDA",
" GPIOC31", "GPIOD0 ",
" GPIOC29", "GPIOC30 ",
" GPIOD21", "GPIOD17 ",
" GPIOB29", "GPIOB28 ", //13, 14
" GPIOB31", "GPIOB30 ",
" GPIOC4", "GPIOC7 ",
" GPIOC8", "GPIOC24 ",
" GPIOC28", "GPIOB26 ",
" GPIOD1", "GPIOD8 ",
" GPIOC13", "AliGPIO3", //25, 26
" GPIOC14", "AliGPIO5",
" 5v", "0v ",

/* ---------nanopc t3 end----------- */
NULL, NULL,
NULL, NULL,
NULL, NULL,

/* UART0, tx, rx */
NULL, NULL,

NULL, NULL, //39, 40
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL, NULL, //49, 50
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL, NULL, //59, 60
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL, NULL, //71, 72
NULL //73
} ;

static int physToWpi_neocore [MAX_PIN_COUNT] =
{
Expand Down Expand Up @@ -533,6 +617,9 @@ static void readallPhys (int faBoardId, int physPin, int pair)
} else if (faBoardId == NanoPi_NEO_Core || faBoardId == NanoPi_NEO_Core2) {
physToWpi = physToWpi_neocore;
physNames = physNames_neocore;
} else if (faBoardId == NanoPC_T3) {
physToWpi = physToWpi_t3;
physNames = physNames_t3;
} else {
return ;
}
Expand Down Expand Up @@ -638,6 +725,9 @@ static void debugReadallPhys (int faBoardId, int physPin)
} else if (faBoardId == NanoPi_NEO_Core || faBoardId == NanoPi_NEO_Core2) {
physToWpi = physToWpi_neocore;
physNames = physNames_neocore;
} else if (faBoardId == NanoPC_T3) {
physToWpi = physToWpi_t3;
physNames = physNames_t3;
} else {
return ;
}
Expand Down Expand Up @@ -677,8 +767,12 @@ void NanoPiReadAll()
&& retBoardInfo->boardTypeId <= ALLWINNER_MAX
&& retBoardInfo->boardTypeId != NanoPi_A64) {
// nothing to do.
} else if(retBoardInfo->boardTypeId == NanoPC_T3) {
printf ("This NanoPC-T3 is only supported GPIO input and GPIO out. \n") ;
printf("Please becareful to use this !!! \n");
} else {
printf ("This NanoPi model is currently not supported. \n") ;
printf ("This NanoPi's boardTypeId is %d .\n",retBoardInfo->boardTypeId);
return ;
}
} else {
Expand All @@ -705,10 +799,15 @@ void NanoPiReadAll()
} else if (retBoardInfo->boardTypeId == NanoPi_Duo
|| retBoardInfo->boardTypeId == NanoPi_Duo2) {
pinCount = 32;
} else if (retBoardInfo->boardTypeId == NanoPC_T3) {
pinCount = 30;
} else {
printf ("This NanoPi model(id: %d) is currently not supported. \n", retBoardInfo->boardTypeId) ;
return ;
}
if (getenv("WIRINGPI_DEBUG") != NULL)
printf("This pinCount num is %d .\nDEBUG_READALL is %d.\nwpMode is %d .\n",
pinCount, DEBUG_READALL, wpMode);

if (DEBUG_READALL) {
printf (" +-----+-----+----------+------+---+-%s--+------+----------+-----+-----+\n", retBoardInfo->boardDisplayName) ;
Expand Down
Loading

0 comments on commit bd92a83

Please sign in to comment.