(This is still work in progress but wanted to publish it and keep working on it)
The Raspberry PI zero has a good price performance ratio, the 2W even better. I have been working on porting BaseFlight (Flight controller software for STM32 micro-controller) to Linux running on the PI. The code is working with a MPU9250.
The hardware will be a PI Zero or a PI Zero 2W (Still need one), SPI0.0 to the IMU, the SPI0.1 connected to the FPGA. The FPGA will create the signals needed for OneShot, decode 6 channels of PWM (I have an old Transmitter that supports 6 channels of PWM), and LED controller.
Will be using the CS7Mod, its small, has 4 LEDs and 1 RGB. LEDS will be used for status indication for BaseFlight.
So, what will be the communication protocol over SPI? Simple Wishbone bus instructions, Read/Write using address and data.
The WishBone master is interface to the SPI Slave, so the PI Zero will be the master. Here is commands for a read and write
- Command string
- 1 byte command, either Read/Write
- 4 byte address Highest address first (Big Endian)
- 2 byte length: first byte is the highest followed by the lowest
- 4 bytes of data, first byte is the lowest byte. (Little endian)
- Read: example using command line:
- printf '\xA1\x1\x2\x3\x0\x0\x4\xf\x00\x00\x0\x0' | spi-pipe -m 0 -s 1000000 -d /dev/spidev0.1 | hexdump -C
- Wite:
- printf '\xA2\x1\x2\x3\x0\x0\x4\xf\xff\xff\x11\0' | spi-pipe -m 0 -s 1000000 -d /dev/spidev0.1 | hexdump -C
- Simple
- Use existing code for Wishbone Master
- Easy to test
- Extendable (More on that later)
- LED controller
- address 0: set 32 bit register
- address 4: xor 32 bit register (blink)
- address 8: clear 32 bit register
- PWM decoder
- 6 32 bit registers.
- One Shot generator
- 4 32 bit registers
No comments:
Post a Comment