|
@@ -237,7 +237,7 @@ const char *piModelNames [20] =
|
|
|
"Pi 3A+", // 14
|
|
|
"Unknown15", // 15
|
|
|
"CM3+", // 16
|
|
|
- "Unknown17", // 17
|
|
|
+ "Pi 4B", // 17
|
|
|
"Unknown18", // 18
|
|
|
"Unknown19", // 19
|
|
|
} ;
|
|
@@ -818,7 +818,7 @@ int piGpioLayout (void)
|
|
|
|
|
|
for (c = &line [strlen (line) - 1] ; (*c == '\n') || (*c == '\r') ; --c)
|
|
|
*c = 0 ;
|
|
|
-
|
|
|
+
|
|
|
if (wiringPiDebug)
|
|
|
printf ("piGpioLayout: Revision string: %s\n", line) ;
|
|
|
|
|
@@ -887,7 +887,7 @@ int piBoardRev (void)
|
|
|
* So the distinction between boards that I can see is:
|
|
|
*
|
|
|
* 0000 - Error
|
|
|
- * 0001 - Not used
|
|
|
+ * 0001 - Not used
|
|
|
*
|
|
|
* Original Pi boards:
|
|
|
* 0002 - Model B, Rev 1, 256MB, Egoman
|
|
@@ -972,7 +972,7 @@ void piBoardId (int *model, int *rev, int *mem, int *maker, int *warranty)
|
|
|
|
|
|
for (c = &line [strlen (line) - 1] ; (*c == '\n') || (*c == '\r') ; --c)
|
|
|
*c = 0 ;
|
|
|
-
|
|
|
+
|
|
|
if (wiringPiDebug)
|
|
|
printf ("piBoardId: Revision string: %s\n", line) ;
|
|
|
|
|
@@ -1011,7 +1011,7 @@ void piBoardId (int *model, int *rev, int *mem, int *maker, int *warranty)
|
|
|
bMfg = (revision & (0x0F << 16)) >> 16 ;
|
|
|
bMem = (revision & (0x07 << 20)) >> 20 ;
|
|
|
bWarranty = (revision & (0x03 << 24)) != 0 ;
|
|
|
-
|
|
|
+
|
|
|
*model = bType ;
|
|
|
*rev = bRev ;
|
|
|
*mem = bMem ;
|
|
@@ -1038,7 +1038,7 @@ void piBoardId (int *model, int *rev, int *mem, int *maker, int *warranty)
|
|
|
// If longer than 4, we'll assume it's been overvolted
|
|
|
|
|
|
*warranty = strlen (c) > 4 ;
|
|
|
-
|
|
|
+
|
|
|
// Extract last 4 characters:
|
|
|
|
|
|
c = c + strlen (c) - 4 ;
|
|
@@ -1078,7 +1078,7 @@ void piBoardId (int *model, int *rev, int *mem, int *maker, int *warranty)
|
|
|
else { *model = 0 ; *rev = 0 ; *mem = 0 ; *maker = 0 ; }
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
/*
|
|
@@ -1264,7 +1264,7 @@ void gpioClockSet (int pin, int freq)
|
|
|
pin = physToGpio [pin] ;
|
|
|
else if (wiringPiMode != WPI_MODE_GPIO)
|
|
|
return ;
|
|
|
-
|
|
|
+
|
|
|
divi = 19200000 / freq ;
|
|
|
divr = 19200000 % freq ;
|
|
|
divf = (int)((double)divr * 4096.0 / 19200000.0) ;
|
|
@@ -1510,7 +1510,7 @@ void pullUpDnControl (int pin, int pud)
|
|
|
|
|
|
*(gpio + GPPUD) = pud & 3 ; delayMicroseconds (5) ;
|
|
|
*(gpio + gpioToPUDCLK [pin]) = 1 << (pin & 31) ; delayMicroseconds (5) ;
|
|
|
-
|
|
|
+
|
|
|
*(gpio + GPPUD) = 0 ; delayMicroseconds (5) ;
|
|
|
*(gpio + gpioToPUDCLK [pin]) = 0 ; delayMicroseconds (5) ;
|
|
|
}
|
|
@@ -1684,7 +1684,7 @@ void pwmWrite (int pin, int value)
|
|
|
|
|
|
/*
|
|
|
* analogRead:
|
|
|
- * Read the analog value of a given Pin.
|
|
|
+ * Read the analog value of a given Pin.
|
|
|
* There is no on-board Pi analog hardware,
|
|
|
* so this needs to go to a new node.
|
|
|
*********************************************************************************
|
|
@@ -1703,7 +1703,7 @@ int analogRead (int pin)
|
|
|
|
|
|
/*
|
|
|
* analogWrite:
|
|
|
- * Write the analog value to the given Pin.
|
|
|
+ * Write the analog value to the given Pin.
|
|
|
* There is no on-board Pi analog hardware,
|
|
|
* so this needs to go to a new node.
|
|
|
*********************************************************************************
|
|
@@ -1752,7 +1752,7 @@ void pwmToneWrite (int pin, int freq)
|
|
|
* Write an 8-bit byte to the first 8 GPIO pins - try to do it as
|
|
|
* fast as possible.
|
|
|
* However it still needs 2 operations to set the bits, so any external
|
|
|
- * hardware must not rely on seeing a change as there will be a change
|
|
|
+ * hardware must not rely on seeing a change as there will be a change
|
|
|
* to set the outputs bits to zero, then another change to set the 1's
|
|
|
* Reading is just bit fiddling.
|
|
|
* These are wiringPi pin numbers 0..7, or BCM_GPIO pin numbers
|
|
@@ -1808,7 +1808,7 @@ unsigned int digitalReadByte (void)
|
|
|
data = (data << 1) | x ;
|
|
|
}
|
|
|
}
|
|
|
- else
|
|
|
+ else
|
|
|
{
|
|
|
raw = *(gpio + gpioToGPLEV [0]) ; // First bank for these pins
|
|
|
for (pin = 0 ; pin < 8 ; ++pin)
|
|
@@ -1865,7 +1865,7 @@ unsigned int digitalReadByte2 (void)
|
|
|
data = (data << 1) | x ;
|
|
|
}
|
|
|
}
|
|
|
- else
|
|
|
+ else
|
|
|
data = ((*(gpio + gpioToGPLEV [0])) >> 20) & 0xFF ; // First bank for these pins
|
|
|
|
|
|
return data ;
|
|
@@ -2277,7 +2277,7 @@ int wiringPiSetup (void)
|
|
|
|
|
|
// Open the master /dev/ memory control device
|
|
|
// Device strategy: December 2016:
|
|
|
-// Try /dev/mem. If that fails, then
|
|
|
+// Try /dev/mem. If that fails, then
|
|
|
// try /dev/gpiomem. If that fails then game over.
|
|
|
|
|
|
if ((fd = open ("/dev/mem", O_RDWR | O_SYNC | O_CLOEXEC)) < 0)
|
|
@@ -2315,13 +2315,13 @@ int wiringPiSetup (void)
|
|
|
pwm = (uint32_t *)mmap(0, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, GPIO_PWM) ;
|
|
|
if (pwm == MAP_FAILED)
|
|
|
return wiringPiFailure (WPI_ALMOST, "wiringPiSetup: mmap (PWM) failed: %s\n", strerror (errno)) ;
|
|
|
-
|
|
|
+
|
|
|
// Clock control (needed for PWM)
|
|
|
|
|
|
clk = (uint32_t *)mmap(0, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, GPIO_CLOCK_BASE) ;
|
|
|
if (clk == MAP_FAILED)
|
|
|
return wiringPiFailure (WPI_ALMOST, "wiringPiSetup: mmap (CLOCK) failed: %s\n", strerror (errno)) ;
|
|
|
-
|
|
|
+
|
|
|
// The drive pads
|
|
|
|
|
|
pads = (uint32_t *)mmap(0, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, GPIO_PADS) ;
|
|
@@ -2441,7 +2441,7 @@ int wiringPiSetupSys (void)
|
|
|
|
|
|
// Open and scan the directory, looking for exported GPIOs, and pre-open
|
|
|
// the 'value' interface to speed things up for later
|
|
|
-
|
|
|
+
|
|
|
for (pin = 0 ; pin < 64 ; ++pin)
|
|
|
{
|
|
|
sprintf (fName, "/sys/class/gpio/gpio%d/value", pin) ;
|