mirror of https://github.com/joan2937/pigpio
Merge pull request #328 from joan2937/BCM2711-BSC-slave
Bcm2711 bsc slave. Closes #280 and #327 .
This commit is contained in:
commit
ef48a043af
46
pigpio.3
46
pigpio.3
|
@ -1682,6 +1682,15 @@ will be a latency.
|
||||||
|
|
||||||
.br
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
If you want to track the level of more than one GPIO do so by
|
||||||
|
maintaining the state in the callback. Do not use \fBgpioRead\fP.
|
||||||
|
Remember the event that triggered the callback may have
|
||||||
|
happened several milliseconds before and the GPIO may have
|
||||||
|
changed level many times since then.
|
||||||
|
|
||||||
|
.br
|
||||||
|
|
||||||
.br
|
.br
|
||||||
The tick value is the time stamp of the sample in microseconds, see
|
The tick value is the time stamp of the sample in microseconds, see
|
||||||
\fBgpioTick\fP for more details.
|
\fBgpioTick\fP for more details.
|
||||||
|
@ -4181,12 +4190,6 @@ queue and the master removes it.
|
||||||
|
|
||||||
.br
|
.br
|
||||||
|
|
||||||
.br
|
|
||||||
This function is not available on the BCM2711 (e.g. as
|
|
||||||
used in the Pi4B).
|
|
||||||
|
|
||||||
.br
|
|
||||||
|
|
||||||
.br
|
.br
|
||||||
I can't get SPI to work properly. I tried with a
|
I can't get SPI to work properly. I tried with a
|
||||||
control word of 0x303 and swapped MISO and MOSI.
|
control word of 0x303 and swapped MISO and MOSI.
|
||||||
|
@ -4249,14 +4252,37 @@ that mode until a different control word is sent.
|
||||||
.br
|
.br
|
||||||
|
|
||||||
.br
|
.br
|
||||||
The BSC peripheral uses GPIO 18 (SDA) and 19 (SCL) in I2C mode
|
GPIO used for models other than those based on the BCM2711.
|
||||||
and GPIO 18 (MOSI), 19 (SCLK), 20 (MISO), and 21 (CE) in SPI mode. You
|
|
||||||
need to swap MISO/MOSI between master and slave.
|
|
||||||
|
|
||||||
.br
|
.br
|
||||||
|
|
||||||
.br
|
.br
|
||||||
When a zero control word is received GPIO 18-21 will be reset
|
SDA SCL MOSI SCLK MISO CE
|
||||||
|
.br
|
||||||
|
I2C 18 19 - - - -
|
||||||
|
.br
|
||||||
|
SPI - - 18 19 20 21
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
GPIO used for models based on the BCM2711 (e.g. the Pi4B).
|
||||||
|
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
SDA SCL MOSI SCLK MISO CE
|
||||||
|
.br
|
||||||
|
I2C 10 11 - - - -
|
||||||
|
.br
|
||||||
|
SPI - - 10 11 9 8
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
When a zero control word is received the used GPIO will be reset
|
||||||
to INPUT mode.
|
to INPUT mode.
|
||||||
|
|
||||||
.br
|
.br
|
||||||
|
|
57
pigpio.c
57
pigpio.c
|
@ -25,7 +25,7 @@ OTHER DEALINGS IN THE SOFTWARE.
|
||||||
For more information, please refer to <http://unlicense.org/>
|
For more information, please refer to <http://unlicense.org/>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* pigpio version 74 */
|
/* pigpio version 75 */
|
||||||
|
|
||||||
/* include ------------------------------------------------------- */
|
/* include ------------------------------------------------------- */
|
||||||
|
|
||||||
|
@ -10730,35 +10730,69 @@ int bbI2CZip(
|
||||||
|
|
||||||
void bscInit(int mode)
|
void bscInit(int mode)
|
||||||
{
|
{
|
||||||
|
int sda, scl, miso, ce;
|
||||||
|
|
||||||
bscsReg[BSC_CR]=0; /* clear device */
|
bscsReg[BSC_CR]=0; /* clear device */
|
||||||
bscsReg[BSC_RSR]=0; /* clear underrun and overrun errors */
|
bscsReg[BSC_RSR]=0; /* clear underrun and overrun errors */
|
||||||
bscsReg[BSC_SLV]=0; /* clear I2C slave address */
|
bscsReg[BSC_SLV]=0; /* clear I2C slave address */
|
||||||
bscsReg[BSC_IMSC]=0xf; /* mask off all interrupts */
|
bscsReg[BSC_IMSC]=0xf; /* mask off all interrupts */
|
||||||
bscsReg[BSC_ICR]=0x0f; /* clear all interrupts */
|
bscsReg[BSC_ICR]=0x0f; /* clear all interrupts */
|
||||||
|
|
||||||
gpioSetMode(BSC_SDA_MOSI, PI_ALT3);
|
if (pi_is_2711)
|
||||||
gpioSetMode(BSC_SCL_SCLK, PI_ALT3);
|
{
|
||||||
|
sda = BSC_SDA_MOSI_2711;
|
||||||
|
scl = BSC_SCL_SCLK_2711;
|
||||||
|
miso = BSC_MISO_2711;
|
||||||
|
ce = BSC_CE_N_2711;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sda = BSC_SDA_MOSI;
|
||||||
|
scl = BSC_SCL_SCLK;
|
||||||
|
miso = BSC_MISO;
|
||||||
|
ce = BSC_CE_N;
|
||||||
|
}
|
||||||
|
|
||||||
|
gpioSetMode(sda, PI_ALT3);
|
||||||
|
gpioSetMode(scl, PI_ALT3);
|
||||||
|
|
||||||
if (mode > 1) /* SPI uses all GPIO */
|
if (mode > 1) /* SPI uses all GPIO */
|
||||||
{
|
{
|
||||||
gpioSetMode(BSC_MISO, PI_ALT3);
|
gpioSetMode(miso, PI_ALT3);
|
||||||
gpioSetMode(BSC_CE_N, PI_ALT3);
|
gpioSetMode(ce, PI_ALT3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void bscTerm(int mode)
|
void bscTerm(int mode)
|
||||||
{
|
{
|
||||||
|
int sda, scl, miso, ce;
|
||||||
|
|
||||||
bscsReg[BSC_CR] = 0; /* clear device */
|
bscsReg[BSC_CR] = 0; /* clear device */
|
||||||
bscsReg[BSC_RSR]=0; /* clear underrun and overrun errors */
|
bscsReg[BSC_RSR]=0; /* clear underrun and overrun errors */
|
||||||
bscsReg[BSC_SLV]=0; /* clear I2C slave address */
|
bscsReg[BSC_SLV]=0; /* clear I2C slave address */
|
||||||
|
|
||||||
gpioSetMode(BSC_SDA_MOSI, PI_INPUT);
|
if (pi_is_2711)
|
||||||
gpioSetMode(BSC_SCL_SCLK, PI_INPUT);
|
{
|
||||||
|
sda = BSC_SDA_MOSI_2711;
|
||||||
|
scl = BSC_SCL_SCLK_2711;
|
||||||
|
miso = BSC_MISO_2711;
|
||||||
|
ce = BSC_CE_N_2711;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sda = BSC_SDA_MOSI;
|
||||||
|
scl = BSC_SCL_SCLK;
|
||||||
|
miso = BSC_MISO;
|
||||||
|
ce = BSC_CE_N;
|
||||||
|
}
|
||||||
|
|
||||||
|
gpioSetMode(sda, PI_INPUT);
|
||||||
|
gpioSetMode(scl, PI_INPUT);
|
||||||
|
|
||||||
if (mode > 1)
|
if (mode > 1)
|
||||||
{
|
{
|
||||||
gpioSetMode(BSC_MISO, PI_INPUT);
|
gpioSetMode(miso, PI_INPUT);
|
||||||
gpioSetMode(BSC_CE_N, PI_INPUT);
|
gpioSetMode(ce, PI_INPUT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10778,9 +10812,6 @@ int bscXfer(bsc_xfer_t *xfer)
|
||||||
|
|
||||||
CHECK_INITED;
|
CHECK_INITED;
|
||||||
|
|
||||||
if (pi_is_2711)
|
|
||||||
SOFT_ERROR(PI_NOT_ON_BCM2711, "SPI/BSC slave not available on BCM2711");
|
|
||||||
|
|
||||||
eventAlert[PI_EVENT_BSC].ignore = 1;
|
eventAlert[PI_EVENT_BSC].ignore = 1;
|
||||||
|
|
||||||
if (xfer->control)
|
if (xfer->control)
|
||||||
|
@ -10794,7 +10825,7 @@ int bscXfer(bsc_xfer_t *xfer)
|
||||||
|
|
||||||
if (mode > bscMode)
|
if (mode > bscMode)
|
||||||
{
|
{
|
||||||
bscInit(bscMode);
|
bscInit(mode);
|
||||||
bscMode = mode;
|
bscMode = mode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
32
pigpio.h
32
pigpio.h
|
@ -30,7 +30,7 @@ For more information, please refer to <http://unlicense.org/>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
#define PIGPIO_VERSION 74
|
#define PIGPIO_VERSION 7401
|
||||||
|
|
||||||
/*TEXT
|
/*TEXT
|
||||||
|
|
||||||
|
@ -797,6 +797,11 @@ typedef void *(gpioThreadFunc_t) (void *);
|
||||||
#define BSC_MISO 20
|
#define BSC_MISO 20
|
||||||
#define BSC_CE_N 21
|
#define BSC_CE_N 21
|
||||||
|
|
||||||
|
#define BSC_SDA_MOSI_2711 10
|
||||||
|
#define BSC_SCL_SCLK_2711 11
|
||||||
|
#define BSC_MISO_2711 9
|
||||||
|
#define BSC_CE_N_2711 8
|
||||||
|
|
||||||
/* Longest busy delay */
|
/* Longest busy delay */
|
||||||
|
|
||||||
#define PI_MAX_BUSY_DELAY 100
|
#define PI_MAX_BUSY_DELAY 100
|
||||||
|
@ -1439,6 +1444,12 @@ once per level change since the last time the thread was activated.
|
||||||
i.e. The active alert functions will get all level changes but there
|
i.e. The active alert functions will get all level changes but there
|
||||||
will be a latency.
|
will be a latency.
|
||||||
|
|
||||||
|
If you want to track the level of more than one GPIO do so by
|
||||||
|
maintaining the state in the callback. Do not use [*gpioRead*].
|
||||||
|
Remember the event that triggered the callback may have
|
||||||
|
happened several milliseconds before and the GPIO may have
|
||||||
|
changed level many times since then.
|
||||||
|
|
||||||
The tick value is the time stamp of the sample in microseconds, see
|
The tick value is the time stamp of the sample in microseconds, see
|
||||||
[*gpioTick*] for more details.
|
[*gpioTick*] for more details.
|
||||||
|
|
||||||
|
@ -2913,9 +2924,6 @@ The output process is simple. You simply append data to the FIFO
|
||||||
buffer on the chip. This works like a queue, you add data to the
|
buffer on the chip. This works like a queue, you add data to the
|
||||||
queue and the master removes it.
|
queue and the master removes it.
|
||||||
|
|
||||||
This function is not available on the BCM2711 (e.g. as
|
|
||||||
used in the Pi4B).
|
|
||||||
|
|
||||||
I can't get SPI to work properly. I tried with a
|
I can't get SPI to work properly. I tried with a
|
||||||
control word of 0x303 and swapped MISO and MOSI.
|
control word of 0x303 and swapped MISO and MOSI.
|
||||||
|
|
||||||
|
@ -2947,11 +2955,19 @@ in rxBuf.
|
||||||
Note that the control word sets the BSC mode. The BSC will stay in
|
Note that the control word sets the BSC mode. The BSC will stay in
|
||||||
that mode until a different control word is sent.
|
that mode until a different control word is sent.
|
||||||
|
|
||||||
The BSC peripheral uses GPIO 18 (SDA) and 19 (SCL) in I2C mode
|
GPIO used for models other than those based on the BCM2711.
|
||||||
and GPIO 18 (MOSI), 19 (SCLK), 20 (MISO), and 21 (CE) in SPI mode. You
|
|
||||||
need to swap MISO/MOSI between master and slave.
|
|
||||||
|
|
||||||
When a zero control word is received GPIO 18-21 will be reset
|
@ SDA @ SCL @ MOSI @ SCLK @ MISO @ CE
|
||||||
|
I2C @ 18 @ 19 @ - @ - @ - @ -
|
||||||
|
SPI @ - @ - @ 18 @ 19 @ 20 @ 21
|
||||||
|
|
||||||
|
GPIO used for models based on the BCM2711 (e.g. the Pi4B).
|
||||||
|
|
||||||
|
@ SDA @ SCL @ MOSI @ SCLK @ MISO @ CE
|
||||||
|
I2C @ 10 @ 11 @ - @ - @ - @ -
|
||||||
|
SPI @ - @ - @ 10 @ 11 @ 9 @ 8
|
||||||
|
|
||||||
|
When a zero control word is received the used GPIO will be reset
|
||||||
to INPUT mode.
|
to INPUT mode.
|
||||||
|
|
||||||
The returned function value is the status of the transfer (see below).
|
The returned function value is the status of the transfer (see below).
|
||||||
|
|
60
pigpio.py
60
pigpio.py
|
@ -330,7 +330,7 @@ import threading
|
||||||
import os
|
import os
|
||||||
import atexit
|
import atexit
|
||||||
|
|
||||||
VERSION = "1.45"
|
VERSION = "1.46"
|
||||||
|
|
||||||
exceptions = True
|
exceptions = True
|
||||||
|
|
||||||
|
@ -3557,13 +3557,9 @@ class pi():
|
||||||
buffer on the chip. This works like a queue, you add data to the
|
buffer on the chip. This works like a queue, you add data to the
|
||||||
queue and the master removes it.
|
queue and the master removes it.
|
||||||
|
|
||||||
This function is not available on the BCM2711 (e.g. as
|
|
||||||
used in the Pi4B).
|
|
||||||
|
|
||||||
I can't get SPI to work properly. I tried with a
|
I can't get SPI to work properly. I tried with a
|
||||||
control word of 0x303 and swapped MISO and MOSI.
|
control word of 0x303 and swapped MISO and MOSI.
|
||||||
|
|
||||||
|
|
||||||
The function sets the BSC mode, writes any data in
|
The function sets the BSC mode, writes any data in
|
||||||
the transmit buffer to the BSC transmit FIFO, and
|
the transmit buffer to the BSC transmit FIFO, and
|
||||||
copies any data in the BSC receive FIFO to the
|
copies any data in the BSC receive FIFO to the
|
||||||
|
@ -3580,12 +3576,19 @@ class pi():
|
||||||
Note that the control word sets the BSC mode. The BSC will
|
Note that the control word sets the BSC mode. The BSC will
|
||||||
stay in that mode until a different control word is sent.
|
stay in that mode until a different control word is sent.
|
||||||
|
|
||||||
The BSC peripheral uses GPIO 18 (SDA) and 19 (SCL)
|
GPIO used for models other than those based on the BCM2711.
|
||||||
in I2C mode and GPIO 18 (MOSI), 19 (SCLK), 20 (MISO),
|
|
||||||
and 21 (CE) in SPI mode. You need to swap MISO/MOSI
|
|
||||||
between master and slave.
|
|
||||||
|
|
||||||
When a zero control word is received GPIO 18-21 will be reset
|
@ SDA @ SCL @ MOSI @ SCLK @ MISO @ CE
|
||||||
|
I2C @ 18 @ 19 @ - @ - @ - @ -
|
||||||
|
SPI @ - @ - @ 18 @ 19 @ 20 @ 21
|
||||||
|
|
||||||
|
GPIO used for models based on the BCM2711 (e.g. the Pi4B).
|
||||||
|
|
||||||
|
@ SDA @ SCL @ MOSI @ SCLK @ MISO @ CE
|
||||||
|
I2C @ 10 @ 11 @ - @ - @ - @ -
|
||||||
|
SPI @ - @ - @ 10 @ 11 @ 9 @ 8
|
||||||
|
|
||||||
|
When a zero control word is received the used GPIO will be reset
|
||||||
to INPUT mode.
|
to INPUT mode.
|
||||||
|
|
||||||
bsc_control consists of the following bits:
|
bsc_control consists of the following bits:
|
||||||
|
@ -3684,10 +3687,10 @@ class pi():
|
||||||
(and will contain the error code).
|
(and will contain the error code).
|
||||||
|
|
||||||
Note that an i2c_address of 0 may be used to close
|
Note that an i2c_address of 0 may be used to close
|
||||||
the BSC device and reassign the used GPIO (18/19)
|
the BSC device and reassign the used GPIO as inputs.
|
||||||
as inputs.
|
|
||||||
|
|
||||||
This example assumes GPIO 2/3 are connected to GPIO 18/19.
|
This example assumes GPIO 2/3 are connected to GPIO 18/19
|
||||||
|
(GPIO 10/11 on the BCM2711).
|
||||||
|
|
||||||
...
|
...
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
@ -4939,6 +4942,37 @@ class pi():
|
||||||
A GPIO may have multiple callbacks (although I can't think of
|
A GPIO may have multiple callbacks (although I can't think of
|
||||||
a reason to do so).
|
a reason to do so).
|
||||||
|
|
||||||
|
The GPIO are sampled at a rate set when the pigpio daemon
|
||||||
|
is started (default 5 us).
|
||||||
|
|
||||||
|
The number of samples per second is given in the following table.
|
||||||
|
|
||||||
|
. .
|
||||||
|
samples
|
||||||
|
per sec
|
||||||
|
|
||||||
|
1 1,000,000
|
||||||
|
2 500,000
|
||||||
|
sample 4 250,000
|
||||||
|
rate 5 200,000
|
||||||
|
(us) 8 125,000
|
||||||
|
10 100,000
|
||||||
|
. .
|
||||||
|
|
||||||
|
GPIO level changes shorter than the sample rate may be missed.
|
||||||
|
|
||||||
|
The daemon software which generates the callbacks is triggered
|
||||||
|
1000 times per second. The callbacks will be called once per
|
||||||
|
level change since the last time they were called.
|
||||||
|
i.e. The callbacks will get all level changes but there will
|
||||||
|
be a latency.
|
||||||
|
|
||||||
|
If you want to track the level of more than one GPIO do so by
|
||||||
|
maintaining the state in the callback. Do not use [*read*].
|
||||||
|
Remember the event that triggered the callback may have
|
||||||
|
happened several milliseconds before and the GPIO may have
|
||||||
|
changed level many times since then.
|
||||||
|
|
||||||
...
|
...
|
||||||
def cbf(gpio, level, tick):
|
def cbf(gpio, level, tick):
|
||||||
print(gpio, level, tick)
|
print(gpio, level, tick)
|
||||||
|
|
100
pigpiod_if2.3
100
pigpiod_if2.3
|
@ -5920,6 +5920,66 @@ tick 32 bit The number of microseconds since boot
|
||||||
|
|
||||||
.EE
|
.EE
|
||||||
|
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
The GPIO are sampled at a rate set when the pigpio daemon
|
||||||
|
is started (default 5 us).
|
||||||
|
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
The number of samples per second is given in the following table.
|
||||||
|
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
|
||||||
|
.EX
|
||||||
|
samples
|
||||||
|
.br
|
||||||
|
per sec
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
1 1,000,000
|
||||||
|
.br
|
||||||
|
2 500,000
|
||||||
|
.br
|
||||||
|
sample 4 250,000
|
||||||
|
.br
|
||||||
|
rate 5 200,000
|
||||||
|
.br
|
||||||
|
(us) 8 125,000
|
||||||
|
.br
|
||||||
|
10 100,000
|
||||||
|
.br
|
||||||
|
|
||||||
|
.EE
|
||||||
|
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
GPIO level changes shorter than the sample rate may be missed.
|
||||||
|
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
The daemon software which generates the callbacks is triggered
|
||||||
|
1000 times per second. The callbacks will be called once per
|
||||||
|
level change since the last time they were called.
|
||||||
|
i.e. The callbacks will get all level changes but there will
|
||||||
|
be a latency.
|
||||||
|
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
If you want to track the level of more than one GPIO do so by
|
||||||
|
maintaining the state in the callback. Do not use \fBgpio_read\fP.
|
||||||
|
Remember the event that triggered the callback may have
|
||||||
|
happened several milliseconds before and the GPIO may have
|
||||||
|
changed level many times since then.
|
||||||
|
|
||||||
.IP "\fBint callback_ex(int pi, unsigned user_gpio, unsigned edge, CBFuncEx_t f, void *userdata)\fP"
|
.IP "\fBint callback_ex(int pi, unsigned user_gpio, unsigned edge, CBFuncEx_t f, void *userdata)\fP"
|
||||||
.IP "" 4
|
.IP "" 4
|
||||||
This function initialises a new callback.
|
This function initialises a new callback.
|
||||||
|
@ -6072,12 +6132,6 @@ queue and the master removes it.
|
||||||
|
|
||||||
.br
|
.br
|
||||||
|
|
||||||
.br
|
|
||||||
This function is not available on the BCM2711 (e.g. as
|
|
||||||
used in the Pi4B).
|
|
||||||
|
|
||||||
.br
|
|
||||||
|
|
||||||
.br
|
.br
|
||||||
I can't get SPI to work properly. I tried with a
|
I can't get SPI to work properly. I tried with a
|
||||||
control word of 0x303 and swapped MISO and MOSI.
|
control word of 0x303 and swapped MISO and MOSI.
|
||||||
|
@ -6160,14 +6214,37 @@ that mode until a different control word is sent.
|
||||||
.br
|
.br
|
||||||
|
|
||||||
.br
|
.br
|
||||||
The BSC peripheral uses GPIO 18 (SDA) and 19 (SCL) in I2C mode
|
GPIO used for models other than those based on the BCM2711.
|
||||||
and GPIO 18 (MOSI), 19 (SCLK), 20 (MISO), and 21 (CE) in SPI mode. You
|
|
||||||
need to swap MISO/MOSI between master and slave.
|
|
||||||
|
|
||||||
.br
|
.br
|
||||||
|
|
||||||
.br
|
.br
|
||||||
When a zero control word is received GPIO 18-21 will be reset
|
SDA SCL MOSI SCLK MISO CE
|
||||||
|
.br
|
||||||
|
I2C 18 19 - - - -
|
||||||
|
.br
|
||||||
|
SPI - - 18 19 20 21
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
GPIO used for models based on the BCM2711 (e.g. the Pi4B).
|
||||||
|
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
SDA SCL MOSI SCLK MISO CE
|
||||||
|
.br
|
||||||
|
I2C 10 11 - - - -
|
||||||
|
.br
|
||||||
|
SPI - - 10 11 9 8
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
When a zero control word is received the used GPIO will be reset
|
||||||
to INPUT mode.
|
to INPUT mode.
|
||||||
|
|
||||||
.br
|
.br
|
||||||
|
@ -6390,8 +6467,7 @@ If there was an error the status will be less than zero
|
||||||
|
|
||||||
.br
|
.br
|
||||||
Note that an i2c_address of 0 may be used to close
|
Note that an i2c_address of 0 may be used to close
|
||||||
the BSC device and reassign the used GPIO (18/19)
|
the BSC device and reassign the used GPIO as inputs.
|
||||||
as inputs.
|
|
||||||
|
|
||||||
.IP "\fBint event_callback(int pi, unsigned event, evtCBFunc_t f)\fP"
|
.IP "\fBint event_callback(int pi, unsigned event, evtCBFunc_t f)\fP"
|
||||||
.IP "" 4
|
.IP "" 4
|
||||||
|
|
|
@ -25,7 +25,7 @@ OTHER DEALINGS IN THE SOFTWARE.
|
||||||
For more information, please refer to <http://unlicense.org/>
|
For more information, please refer to <http://unlicense.org/>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* PIGPIOD_IF2_VERSION 16 */
|
/* PIGPIOD_IF2_VERSION 17 */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
|
@ -30,7 +30,7 @@ For more information, please refer to <http://unlicense.org/>
|
||||||
|
|
||||||
#include "pigpio.h"
|
#include "pigpio.h"
|
||||||
|
|
||||||
#define PIGPIOD_IF2_VERSION 16
|
#define PIGPIOD_IF2_VERSION 17
|
||||||
|
|
||||||
/*TEXT
|
/*TEXT
|
||||||
|
|
||||||
|
@ -3352,6 +3352,37 @@ tick 32 bit The number of microseconds since boot
|
||||||
WARNING: this wraps around from
|
WARNING: this wraps around from
|
||||||
4294967295 to 0 roughly every 72 minutes
|
4294967295 to 0 roughly every 72 minutes
|
||||||
. .
|
. .
|
||||||
|
|
||||||
|
The GPIO are sampled at a rate set when the pigpio daemon
|
||||||
|
is started (default 5 us).
|
||||||
|
|
||||||
|
The number of samples per second is given in the following table.
|
||||||
|
|
||||||
|
. .
|
||||||
|
samples
|
||||||
|
per sec
|
||||||
|
|
||||||
|
1 1,000,000
|
||||||
|
2 500,000
|
||||||
|
sample 4 250,000
|
||||||
|
rate 5 200,000
|
||||||
|
(us) 8 125,000
|
||||||
|
10 100,000
|
||||||
|
. .
|
||||||
|
|
||||||
|
GPIO level changes shorter than the sample rate may be missed.
|
||||||
|
|
||||||
|
The daemon software which generates the callbacks is triggered
|
||||||
|
1000 times per second. The callbacks will be called once per
|
||||||
|
level change since the last time they were called.
|
||||||
|
i.e. The callbacks will get all level changes but there will
|
||||||
|
be a latency.
|
||||||
|
|
||||||
|
If you want to track the level of more than one GPIO do so by
|
||||||
|
maintaining the state in the callback. Do not use [*gpio_read*].
|
||||||
|
Remember the event that triggered the callback may have
|
||||||
|
happened several milliseconds before and the GPIO may have
|
||||||
|
changed level many times since then.
|
||||||
D*/
|
D*/
|
||||||
|
|
||||||
/*F*/
|
/*F*/
|
||||||
|
@ -3442,9 +3473,6 @@ The output process is simple. You simply append data to the FIFO
|
||||||
buffer on the chip. This works like a queue, you add data to the
|
buffer on the chip. This works like a queue, you add data to the
|
||||||
queue and the master removes it.
|
queue and the master removes it.
|
||||||
|
|
||||||
This function is not available on the BCM2711 (e.g. as
|
|
||||||
used in the Pi4B).
|
|
||||||
|
|
||||||
I can't get SPI to work properly. I tried with a
|
I can't get SPI to work properly. I tried with a
|
||||||
control word of 0x303 and swapped MISO and MOSI.
|
control word of 0x303 and swapped MISO and MOSI.
|
||||||
|
|
||||||
|
@ -3486,11 +3514,19 @@ less than requested if the FIFO already contained untransmitted data).
|
||||||
Note that the control word sets the BSC mode. The BSC will stay in
|
Note that the control word sets the BSC mode. The BSC will stay in
|
||||||
that mode until a different control word is sent.
|
that mode until a different control word is sent.
|
||||||
|
|
||||||
The BSC peripheral uses GPIO 18 (SDA) and 19 (SCL) in I2C mode
|
GPIO used for models other than those based on the BCM2711.
|
||||||
and GPIO 18 (MOSI), 19 (SCLK), 20 (MISO), and 21 (CE) in SPI mode. You
|
|
||||||
need to swap MISO/MOSI between master and slave.
|
|
||||||
|
|
||||||
When a zero control word is received GPIO 18-21 will be reset
|
@ SDA @ SCL @ MOSI @ SCLK @ MISO @ CE
|
||||||
|
I2C @ 18 @ 19 @ - @ - @ - @ -
|
||||||
|
SPI @ - @ - @ 18 @ 19 @ 20 @ 21
|
||||||
|
|
||||||
|
GPIO used for models based on the BCM2711 (e.g. the Pi4B).
|
||||||
|
|
||||||
|
@ SDA @ SCL @ MOSI @ SCLK @ MISO @ CE
|
||||||
|
I2C @ 10 @ 11 @ - @ - @ - @ -
|
||||||
|
SPI @ - @ - @ 10 @ 11 @ 9 @ 8
|
||||||
|
|
||||||
|
When a zero control word is received the used GPIO will be reset
|
||||||
to INPUT mode.
|
to INPUT mode.
|
||||||
|
|
||||||
control consists of the following bits.
|
control consists of the following bits.
|
||||||
|
@ -3598,8 +3634,7 @@ If there was an error the status will be less than zero
|
||||||
(and will contain the error code).
|
(and will contain the error code).
|
||||||
|
|
||||||
Note that an i2c_address of 0 may be used to close
|
Note that an i2c_address of 0 may be used to close
|
||||||
the BSC device and reassign the used GPIO (18/19)
|
the BSC device and reassign the used GPIO as inputs.
|
||||||
as inputs.
|
|
||||||
D*/
|
D*/
|
||||||
|
|
||||||
/*F*/
|
/*F*/
|
||||||
|
|
34
pigs.1
34
pigs.1
|
@ -925,10 +925,6 @@ The output process is simple. You simply append data to the FIFO
|
||||||
buffer on the chip. This works like a queue, you add data to the
|
buffer on the chip. This works like a queue, you add data to the
|
||||||
queue and the master removes it.
|
queue and the master removes it.
|
||||||
|
|
||||||
.br
|
|
||||||
This function is not available on the BCM2711 (e.g. as
|
|
||||||
used in the Pi4B).
|
|
||||||
|
|
||||||
.br
|
.br
|
||||||
I can't get SPI to work properly. I tried with a
|
I can't get SPI to work properly. I tried with a
|
||||||
control word of 0x303 and swapped MISO and MOSI.
|
control word of 0x303 and swapped MISO and MOSI.
|
||||||
|
@ -950,12 +946,31 @@ For I2C use a control word of (I2C address << 16) + 0x305.
|
||||||
E.g. to talk as I2C slave with address 0x13 use 0x130305.
|
E.g. to talk as I2C slave with address 0x13 use 0x130305.
|
||||||
|
|
||||||
.br
|
.br
|
||||||
The BSC peripheral uses GPIO 18 (SDA) and 19 (SCL) in I2C mode
|
GPIO used for models other than those based on the BCM2711.
|
||||||
and GPIO 18 (MOSI), 19 (SCLK), 20 (MISO), and 21 (CE) in SPI mode. You
|
|
||||||
need to swap MISO/MOSI between master and slave.
|
|
||||||
|
|
||||||
.br
|
.br
|
||||||
When a zero control word is received GPIO 18-21 will be reset
|
|
||||||
|
.EX
|
||||||
|
SDA SCL MOSI SCLK MISO CE
|
||||||
|
I2C 18 19 - - - -
|
||||||
|
SPI - - 18 19 20 21
|
||||||
|
|
||||||
|
.EE
|
||||||
|
|
||||||
|
.br
|
||||||
|
GPIO used for models based on the BCM2711 (e.g. the Pi4B).
|
||||||
|
|
||||||
|
.br
|
||||||
|
|
||||||
|
.EX
|
||||||
|
SDA SCL MOSI SCLK MISO CE
|
||||||
|
I2C 10 11 - - - -
|
||||||
|
SPI - - 10 11 9 8
|
||||||
|
|
||||||
|
.EE
|
||||||
|
|
||||||
|
.br
|
||||||
|
When a zero control word is received the used GPIO will be reset
|
||||||
to INPUT mode.
|
to INPUT mode.
|
||||||
|
|
||||||
.br
|
.br
|
||||||
|
@ -1031,7 +1046,8 @@ TB transmit busy
|
||||||
.EE
|
.EE
|
||||||
|
|
||||||
.br
|
.br
|
||||||
This example assumes that GPIO 2/3 are connected to GPIO 18/19.
|
This example assumes that GPIO 2/3 are connected to GPIO 18/19
|
||||||
|
(GPIO 10/11 on the BCM2711).
|
||||||
|
|
||||||
.br
|
.br
|
||||||
|
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -3,7 +3,7 @@
|
||||||
from distutils.core import setup
|
from distutils.core import setup
|
||||||
|
|
||||||
setup(name='pigpio',
|
setup(name='pigpio',
|
||||||
version='1.45',
|
version='1.46',
|
||||||
author='joan',
|
author='joan',
|
||||||
author_email='joan@abyz.me.uk',
|
author_email='joan@abyz.me.uk',
|
||||||
maintainer='joan',
|
maintainer='joan',
|
||||||
|
|
Loading…
Reference in New Issue