CSI2 MUX example

Description

This code implements a csi2_mux application with a GAP9 and a Raspberry Pi both connected to the same camera OV5647. First, Gap9 starts capturing the image and sends it by uart to the PC then hands control over to the Raspberry Pi. The CSI2 mux is enabled by the PI3WVR626 on the csi2 mux board.

Hardware configuration

Boards: Gap9 Evaluation kit, Raspberry Pi 4 board, CSI2_MUX board, OV5647 camera Cables: 2 FFC 15 pos 1mm same side and 1 opposite side, 3 female to male jumper wires

Connect the camera on J5 of the CSI2_MUX with one of the same side FFC, connect the RPi on J6 of the CSI2_MUX with the other one and the GAP9 on J7 with the opposite side cable.

To connect the UART between Gap and RPi, connect 2 jumper wires between the Mikroe interface and J8 on the RPi like this:

Rx Gap > pin 8
Tx Gap > Pin 10

Then, lastly, connect CN5 pin 10 of Gap to P5 pin 2 of the CSI2_MUX.

Logic diagram

Here’s a logic diagram of the system:

+-------+    +-------+
|  GAP9 |    | RPi   |
|-------|    |-------|
| UART  |<-> | UART  |
|-------|    |-------|
| I2C   |    | I2C   |
| CSI2  |    | CSI2  |
+-------+    +-------+
  |             |
  |             |
  v             v
 +-------+-------+
 | CSI2 MUX      |
 |-------+-------|
         |
         v
     +--------+
     | Camera |
     | OV5647 |
     +--------+

Software configuration

Raspberry Pi configuration:

To enable uart on the GPIO14/15 of the RPi.

cd ../../boot/firmware
sudo vim config.txt

Then add at the bottom:

enable_uart=1 dtoverlay=bt-disable

Then when you do:

ls -la /dev/serial*

You should see the serial0 interfaces wired on AMA0.

Then copy the rpi_test.py from this folder to the rasberry pi.

How to run

You can start the code on both boards at the same time.

Raspberry Pi start:

python rpi_test.py

Gap start:

gap init
gap run

And in another terminal to observe what gap is sending:

python uart_read_image.py 320 240

If no image is showing, try to change the serial port.