-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added some helper scripts for bringing up the camera module without t…
…he kernel driver
- Loading branch information
Demo User
committed
Aug 22, 2020
1 parent
eac31ce
commit 0680764
Showing
4 changed files
with
138 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/bin/bash | ||
set -x | ||
|
||
if [ $UID -ne 0 ] | ||
then | ||
echo ERROR: must be root | ||
exit 1 | ||
fi | ||
|
||
# pass the gpio # and the value to set | ||
set_gpio() { | ||
set -x | ||
GPIO=$1 | ||
GPIOPATH=/sys/class/gpio/gpio$GPIO | ||
VAL=$2 | ||
|
||
ls /sys/class/gpio/ | grep gpio$GPIO > /dev/null | ||
# first export the GPIO is it isnt already | ||
if [ $? -ne 0 ]; then | ||
echo "File not found!" | ||
echo $GPIO > /sys/class/gpio/export | ||
fi | ||
|
||
# set GPIO direction | ||
echo out > $GPIOPATH/direction | ||
|
||
# set GPIO value | ||
echo $VAL > $GPIOPATH/value | ||
} | ||
|
||
# enable camera output active low | ||
set_gpio 96 0 | ||
|
||
# enable camera clock clk active high | ||
set_gpio 106 1 | ||
|
||
# disable reset active low (drive high) | ||
set_gpio 84 1 | ||
|
||
# set i2c address with saddr line low (0x20) | ||
set_gpio 83 0 | ||
|
||
# disable standby active high (drive low) | ||
set_gpio 82 0 | ||
|
||
# no trigger active high | ||
set_gpio 98 0 | ||
|
||
# enable voltage regulators on image sensor active high | ||
set_gpio 100 1 | ||
|
||
# finally, enable image sensor control lines so all the | ||
# above signals are sent to image sensor | ||
set_gpio 85 0 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/python3 | ||
|
||
# This script writes the board ID to the EEPROM in the OSD3358 and reads | ||
# it back afterwards. I ran it on another pocketbealge using i2c-2, but | ||
# it would probably work on other boards with a i2c peripheral | ||
|
||
import io | ||
import fcntl | ||
import sys | ||
|
||
# i2c slave address is first argument | ||
slave_addr = int(sys.argv[1], 16) | ||
|
||
reg = int(sys.argv[2], 16) | ||
|
||
addr_bu = (reg >> 8) & 0xff # address upper byte | ||
addr_bl = reg & 0xff # address lower byte | ||
|
||
# I think this is python ioctl/i2c specific magic bytes? | ||
IOCTL_I2C_SLAVE = 0x0703 | ||
|
||
# open the I2C device and set it up to talk to the slave | ||
f = io.open("/dev/i2c-2", "wb+", buffering=0) | ||
fcntl.ioctl(f, IOCTL_I2C_SLAVE, slave_addr) | ||
|
||
# write the register value | ||
f.write(bytearray([addr_bu, addr_bl])) | ||
|
||
# read back the register value | ||
v = f.read(2) | ||
print("Reg: ", hex(slave_addr), " Value: 0x", v.hex(), sep='') | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/bin/bash | ||
set -x | ||
|
||
if [ $UID -ne 0 ] | ||
then | ||
echo ERROR: must be root | ||
exit 1 | ||
fi | ||
|
||
# pass the gpio # and the value to set | ||
set_gpio() { | ||
set -x | ||
GPIO=$1 | ||
GPIOPATH=/sys/class/gpio/gpio$GPIO | ||
VAL=$2 | ||
|
||
ls /sys/class/gpio/ | grep gpio$GPIO > /dev/null | ||
# first export the GPIO is it isnt already | ||
if [ $? -ne 0 ]; then | ||
echo "File not found!" | ||
echo $GPIO > /sys/class/gpio/export | ||
fi | ||
|
||
# set GPIO direction | ||
echo out > $GPIOPATH/direction | ||
|
||
# set GPIO value | ||
echo $VAL > $GPIOPATH/value | ||
} | ||
|
||
# enable camera output active low | ||
set_gpio 96 1 | ||
|
||
# enable camera clock clk active high | ||
set_gpio 106 0 | ||
|
||
# disable reset active low | ||
set_gpio 84 0 | ||
|
||
# disable standby active high | ||
set_gpio 82 1 | ||
|
||
# enable voltage regulators on image sensor active high | ||
set_gpio 100 0 | ||
|
||
# finally, enable image sensor control lines so all the | ||
# above signals are sent to image sensor | ||
set_gpio 85 0 | ||
|
||
|