boochow / micropython-raspberrypi

bare metal Raspberry Pi Zero / Zero W port of MicroPython
MIT License
215 stars 24 forks source link

USB/SPI/I2C device mode, does it work? #34

Open mfp20 opened 3 years ago

mfp20 commented 3 years ago

Regards

boochow commented 3 years ago

Sorry, not implemented.

mfp20 commented 3 years ago

Is it hard to implement?

boochow commented 3 years ago

I believe it is hard, because I haven't seen any bare-metal project which supports USB device mode

mfp20 commented 3 years ago

I see, I can't find any. Thanks!

BTW, what is the pin toggle speed?

boochow commented 3 years ago

Sorry, I haven't measure it.

mfp20 commented 3 years ago

What about SPI and I2C? Do they work in slave mode?

boochow commented 3 years ago

I have only tested master mode for both SPI and I2C. RPi's hardware SPI does not support slave mode anyway.

mfp20 commented 3 years ago

I have only tested master mode for both SPI and I2C. RPi's hardware SPI does not support slave mode anyway.

https://www.raspberrypi.org/documentation/hardware/raspberrypi/bcm2835/BCM2835-ARM-Peripherals.pdf

Page 4

SPI Slave is supported by hardware, but linux support has been added around v4.13. I wouldn't be surprised if nobody ever used it yet. It looks like the protocol isn't strict enough, so plenty incompatible implementations exist.

boochow commented 3 years ago

SPI Slave is supported by hardware, but linux support has been added around v4.13.

maybe it is referring BSC/SPI described in chapter 11, which I have not implemented. I only implemented SPI0, which cannot be used in slave mode. Also, I have read at somewhere that BSC/SPI slave does not work correctly