I2C Slave configuré pour la carte Detection2023
This commit is contained in:
parent
c2ea22d326
commit
80593efd46
10
main.c
10
main.c
@ -17,8 +17,8 @@ static const uint I2C_BAUDRATE = 100000; // 100 kHz
|
|||||||
#ifdef i2c_default
|
#ifdef i2c_default
|
||||||
// For this example, we run both the master and slave from the same board.
|
// For this example, we run both the master and slave from the same board.
|
||||||
// You'll need to wire pin GP4 to GP6 (SDA), and pin GP5 to GP7 (SCL).
|
// You'll need to wire pin GP4 to GP6 (SDA), and pin GP5 to GP7 (SCL).
|
||||||
static const uint I2C_SLAVE_SDA_PIN = PICO_DEFAULT_I2C_SDA_PIN; // 4
|
static const uint I2C_SLAVE_SDA_PIN = 19; // 4
|
||||||
static const uint I2C_SLAVE_SCL_PIN = PICO_DEFAULT_I2C_SCL_PIN; // 5
|
static const uint I2C_SLAVE_SCL_PIN = 18; // 5
|
||||||
static const uint I2C_MASTER_SDA_PIN = 6;
|
static const uint I2C_MASTER_SDA_PIN = 6;
|
||||||
static const uint I2C_MASTER_SCL_PIN = 7;
|
static const uint I2C_MASTER_SCL_PIN = 7;
|
||||||
|
|
||||||
@ -70,9 +70,9 @@ static void setup_slave() {
|
|||||||
gpio_set_function(I2C_SLAVE_SCL_PIN, GPIO_FUNC_I2C);
|
gpio_set_function(I2C_SLAVE_SCL_PIN, GPIO_FUNC_I2C);
|
||||||
gpio_pull_up(I2C_SLAVE_SCL_PIN);
|
gpio_pull_up(I2C_SLAVE_SCL_PIN);
|
||||||
|
|
||||||
i2c_init(i2c0, I2C_BAUDRATE);
|
i2c_init(i2c1, I2C_BAUDRATE);
|
||||||
// configure I2C0 for slave mode
|
// configure I2C1 for slave mode
|
||||||
i2c_slave_init(i2c0, I2C_SLAVE_ADDRESS, &i2c_slave_handler);
|
i2c_slave_init(i2c1, I2C_SLAVE_ADDRESS, &i2c_slave_handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user