简体   繁体   中英

How to set up Raspberry Pi 4B as a I2C slave

I'm trying to set up a RPi 4B to work as an I2C slave with PSoC (4.4) - CY8C5888LTI-LP097. Below is my code to set up the slave address on the Pi.

import pigpio

pi = None
slave_addr = 0x13

def i2cInterrupt():
   global pi
   global slave_addr
   status, bytes_read, data = pi.bsc_i2c(slave_addr) 

   if bytes_read:
      print(data)

pi = pigpio.pi()
int_handler = pi.event_callback(pigpio.EVENT_BSC, i2cInterrupt)
pi.bsc_i2c(slave_addr)

I have followed this example: http://abyz.me.uk/rpi/pigpio/python.html#bsc_i2c however, not detecting anything when I run

$ i2cdetect -y 1

Have you loopback any i2c master GPIOs to the slave GPIOs?
On RPi4 you'll have to jumper GPIO 2-3 to GPIO 10-11 respectively.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM