Difference between revisions of "CS-MIPI-X i2c"

From wiki_veye
Jump to navigation Jump to search
Line 460: Line 460:
 
r sensor addr 0x300a value 0x3c
 
r sensor addr 0x300a value 0x3c
  
===== striggerone =====
+
=====striggerone=====
 
<code>./cs_mipi_i2c.sh -w -f striggerone</code>
 
<code>./cs_mipi_i2c.sh -w -f striggerone</code>
  
Line 467: Line 467:
 
note: Only CS-MIPI-SC132 support.
 
note: Only CS-MIPI-SC132 support.
  
===== triggeredge =====
+
=====triggeredge=====
 +
<code>./cs_mipi_i2c.sh -w -f triggeredge -p1 [value]</code>
  
=====  {| class="wikitable" |+TrigEdge !value !description |- |0 |上升沿触发 |- |1 |下降沿触发 |}  =====
+
<code>./cs_mipi_i2c.sh -r -f triggeredge</code>
  
===== tgdebncr =====
+
Edge attribute of trigger signal in Hardware Trigger mode.
<br />
+
{| class="wikitable"
 +
!value
 +
!description
 +
|-
 +
|0
 +
|RisingEdge
 +
|-
 +
|1
 +
|FallingEdge
 +
|}
 +
note: Only CS-MIPI-SC132 Support.
  
===== tgdly =====
+
=====tgdebncr=====
<br />
+
<code>./cs_mipi_i2c.sh -w -f triggeredge -p1 enable -p2 [value]</code>
  
===== pickmode =====
+
<code>./cs_mipi_i2c.sh -r -f triggeredge</code><br />In Hardware Trigger mode,the debouncer attribute of the trigger signal.
  
===== pickone =====
+
Any trigger signal that is less than value (us) will be ignored.
  
===== sysreboot =====
+
note: Only CS-MIPI-SC132 Support.
 +
=====tgdly=====
 +
<code>./cs_mipi_i2c.sh -w -f tgdly -p1 [value]</code>
 +
 
 +
<code>./cs_mipi_i2c.sh -r -f tgdly</code>
 +
 
 +
Trigger delay in Hardware Trigger mode (us).<br />note: Only CS-MIPI-SC132 Support.
 +
=====pickmode=====
 +
<code>./cs_mipi_i2c.sh -w -f pickmode -p1 enable</code>
 +
 
 +
<code>./cs_mipi_i2c.sh -r -f pickmode</code>
 +
 
 +
Pickmode is a special function, once turned on, sensor works normally, but the module will not output images, only receive '''pickone''' instructions, output one.
 +
 
 +
=====pickone=====
 +
<code>./cs_mipi_i2c.sh -w -f pickone</code>
 +
 
 +
When pickmode is enable, output one image.
 +
 
 +
=====sysreboot=====
 +
<code>./cs_mipi_i2c.sh -w -f sysreboot -p1 [value]</code>
 +
 
 +
reboot the camera module
 +
{| class="wikitable"
 +
|+reboot_type
 +
!value
 +
!description
 +
|-
 +
|1
 +
|Restart the problem
 +
|-
 +
|2
 +
|Fully reboot (6-8s)
 +
|}
 
<br />
 
<br />

Revision as of 14:55, 18 June 2020

查看中文

cs_mipi_i2c.sh Shell scripts usage

1 Introduction

The cs_mipi_i2c.sh script is a toolset for configuring CS-MIPI-X series cameras through the I2C.

2 RaspberryPi Only, Set IO config

Include the following files,camera_i2c_config、i2c_read、i2c_write、cs_mipi_i2c.sh.

Running

./enable_i2c_vc.sh

./camera_i2c_config

first,it will config IO pin. Then you can run cs_mipi_i2c.sh.

2.1 camera_i2c_config USAGE

  • for standard RPI, just run

./camera_i2c_config

  • for RPI Computer Module

./camera_i2c_config [cameranum]

cameranum description
0 CAM0
1 CAM1

3 cs_mipi_i2c.sh USAGE

./cs_mipi_i2c.sh

this shell scripts should be used for CS-MIPI-IMX307!

Usage:  ./cs_mipi_i2c.sh [-r/w] [-f] function name -p1 param1 -p2 param2 -p3 param3 -b bus

options:

    -r                       read

    -w                       write

    -f [function name]       function name

    -p1 [param1]                           param1 of each function

    -p2 [param1]                           param2 of each function

    -p3 [param1]                           param3 of each function

    -b [i2c bus num]               i2c bus number

    -d [i2c addr]                  i2c addr if not default 0x3b

support functions: devid,hdver,camcap,firmwarever,productmodel,videofmtcap,videofmt,ispcap,i2caddr,streammode,powerhz,

daynightmode ,hue ,contrast , satu , expostate , wbstate ,aemode , aetarget, aetime,aeagc,metime ,meagain , medgain , awbmode , mwbcolortemp , mwbgain,imagedir,sreg,striggerone,triggeredge,autotgcnt,tgdebncr,tgdly,pickmode,discardfrm,pickone,mipistatus,sysreboot,sysreset,paramsave


Pi3B / Pi3B+ / 3A / 4B(1G/2G/4G),we use i2c0

Compute Module/ CM3,we use i2c1,please add -b 1 option.

3.1 devid

./cs_mipi_i2c.sh -r -f devid

0x02 2 lan mipi
3.2 hdver

./veye_mipi_i2c.sh -r -f hdver

get hardware logic version

value description
0xXY Version X.Y

for example:

0x22 means V2.2

3.3 firmwarever

./cs_mipi_i2c.sh -r -f firmwarever

get firmware version, X.Y, 1.0 for example.

3.4 productmodel

./cs_mipi_i2c.sh -r -f productmodel

get product model,for example:CS-MIPI-IMX307,CS-MIPI-SC132

3.5 camcap

./cs_mipi_i2c.sh -r -f camcap

get camera module capbility, each bit represents a function.

camcap
bit description
0 sync stream mode
1 trigger mode
2 pick mode
3.6 videofmtcap

./cs_mipi_i2c.sh -r -f videofmtcap

get camera video format capbility, for example:

1920*1080 @max30fps

1280*720 @max60fps

3.7 videofmt

./cs_mipi_i2c.sh -r -f videofmt

./cs_mipi_i2c.sh -w -f videofmt -p1 1920 -p2 1080 -p3 10

./cs_mipi_i2c.sh -w -f videofmt -p1 1280 -p2 720 -p3 60

./cs_mipi_i2c.sh -w -f videofmt -p1 640 -p2 480 -p3 130

get and set current video format,for example:

1920*1080@10fps

1280*720@60fps

640*480@130fps

If camera support framerate continuously adjustable:

CS-MIPI-IMX307 framerate range: [1,maxframerate]

CS-MIPI-SC132framerate range: [2,maxframerate]

note:sync mode do not support framerate continuously adjustable.

3.8 ispcap

./cs_mipi_i2c.sh -r -f ispcap

get camera isp capbility. Will add details later.

3.9 powerhz

./cs_mipi_i2c.sh -r -f powerhz

./cs_mipi_i2c.sh -w -f powerhz -p1 50

./cs_mipi_i2c.sh -w -f powerhz -p1 60

value description
50 Power frequency is 50Hz
60 Power frequency is 60Hz

Configure the power frequency of the environment in which the camera is used.

  • 50Hz framerate is 25、50、100;60Hz framerate is 30、60、120.
  • camera support antiflicker, accroding to powerhz setting here.
3.10 i2caddr

./cs_mipi_i2c.sh -r -f i2caddr -d i2caddrnow

./cs_mipi_i2c.sh -w -f i2caddr -p1 newi2caddr -d oldi2caddr

This module support i2c addr change by software, i2c addr range[0x3,0x77].

Note: only supported on firmware version >= 1.05

3.11 paramsave

./cs_mipi_i2c.sh -w -f paramsave

Write the configured parameters to flash. So parameters will not be lost when poweroff.

3.12 sysreset

./cs_mipi_i2c.sh -w -f sysreset

The camera reset to the factory default parameters.

3.13 streammode
stream mode
value description
0 free running
1 sync mode
2 Hardware Trigger
3 Software Trigger

./cs_mipi_i2c.sh -r -f streammode

Read the current stream mode and master-slave mode

  • free running mode

./cs_mipi_i2c.sh -w -f streammode -p1 0

Set the current camera to free running mode

slave mode(sync stream mode)

value description
0 master
1 slave

./cs_mipi_i2c.sh -w -f streammode -p1 1 -p2 0

Set the current camera to sync mode, and set to master

./cs_mipi_i2c.sh -w -f streammode -p1 1 -p2 1

Set the current camera to sync mode, and set to slave

sync mode :Camera module Stream Mode manual

Note: only supported on camcap bit 0 is 1.

  • Trigger mode

./cs_mipi_i2c.sh -w -f streammode -p1 2

Set the current camera to hardware trigger mode

./cs_mipi_i2c.sh -w -f streammode -p1 3

Set the current camera to software trigger mode

3.14 daynightmode

./cs_mipi_i2c.sh -r -f daynightmode

./cs_mipi_i2c.sh -w -f daynightmode -p1 [value]

value description
0x1 Color Mode
0x2 Black&White Mode
0x0 Trigger Mode
0x3 IR-CUT day, Image Black&White mode
0x4 IR-CUT night, Image Color mode

IR-CUT (Infrared cut-off filter) is a mechanical shutter design. It is placed between the lens and the image sensor, and is controlled by a motor or an electromagnet.

IR-CUT has two status: Block or Deliver the infrared.

  • Color Mode

Image is Color Mode and IR_CUT status Block infrared.

  • Black&White Mode

Image is Black&White Mode and IR_CUT status Deliver infrared.

  • Trigger Mode

Trigger pin : J4 pin1.

Trigger pin High(3.3~12V),Image is Black&White Mode and IR-CUT status Deliver infrared.

Trigger pin Low(GND),Image is Color Mode and IR-CUT status Bolck infrared.

  • IR-CUT day, Image black&white mode

Image is Black&White Mode and IR_CUT status Block infrared.

  • IR-CUT night, Image color mode

Image is Color Mode and IR_CUT status Deliver infrared.

3.15 hue

./cs_mipi_i2c.sh -r -f hue

./cs_mipi_i2c.sh -w -f hue -p1 50

hue,range [0,100].

3.16 contrast

./cs_mipi_i2c.sh -r -f contrast

./cs_mipi_i2c.sh -w -f contrast-p1 50

contrast,range [0,100].

3.17 satu

./cs_mipi_i2c.sh -r -f satu

./cs_mipi_i2c.sh -w -f satu-p1 50

saturation,range [0,100].

3.18 aemode

./cs_mipi_i2c.sh -r -f aemode

./cs_mipi_i2c.sh -w -f aemode -p1 0

0 : auto exposure

1: manual exposure

3.19 aetarget

./cs_mipi_i2c.sh -r -f aetarget

./cs_mipi_i2c.sh -w -f aetarget -p1 0x40

The target brightness in automatic exposure mode. Effective when aemode is auto.

range:[0,255]

3.20 aetime

./cs_mipi_i2c.sh -r -f aetime

./cs_mipi_i2c.sh -w -f aetime -p1 0x400000

the max exposure time in automatic exposure mode,unit: us。Effective when aemode is auto.

range:(100,1/framerate],if framerate is 30,then the range is (100,33333].

special value:0xFFFFFFFF=1/framerate, the camera will automatically adjust according to the working mode.

3.21 aeagc

./cs_mipi_i2c.sh -w -f aeagc-p1 X -p2 Y

./cs_mipi_i2c.sh -r -f aeagc

Maximum total system gain in automatic exposure mode,unit: dB. Effective when aemode is auto.

agc includes Again+Dgain+ISPGain.

X is the integer part and Y is the decimal part, for example X is 2 and Y is 3 means 2.3dB.

X range: depending on sensor.

Y range: [0-9].

IMX307,again range is[0,135]dB, step 0.3dB.

3.22 metime

./cs_mipi_i2c.sh -r -f metime

./cs_mipi_i2c.sh -w -f metime -p1 10000

manual exposure time, us.

range:[0-1000000/framerate]

3.23 meagain

./cs_mipi_i2c.sh -w -f meagain -p1 X -p2 Y

./cs_mipi_i2c.sh -r -f meagain

manual again,dB. Effective when aemode is manual.

X is the integer part and Y is the decimal part, for example X is 2 and Y is 3 means 2.3dB.

X range: depending on sensor.

Y range: [0-9].

IMX307,again range is[0,27]dB, step 0.3dB.

3.24 medgain

./cs_mipi_i2c.sh -w -f medgain -p1 X -p2 Y

./cs_mipi_i2c.sh -r -f medgain

manual dgain,dB. Effective when aemode is manual.

X is the integer part and Y is the decimal part, for example X is 2 and Y is 3 means 2.3dB.

X range: depending on sensor.

Y range: [0-9].

IMX307,dgain range is[0,42]dB, step 0.3dB.

3.25 awbmode

./cs_mipi_i2c.sh -r -f awbmode

./cs_mipi_i2c.sh -w -f awbmode -p1 0

0 : auto white balance

1: manual white balance, gain mode

2: manual white balance, color temperature mode

3.26 mwbgain

./cs_mipi_i2c.sh -w -f mwbgain -p1 RGAIN -p2 BGAIN

./cs_mipi_i2c.sh -r -f mwbgain

manual white balance mode, set rgain and dgain manually, ggain is always 1.

GAIN is 4-bit decimal precision, for example: 0x23 means 2+3/16=2.19.

3.27 mwbcolortemp

./cs_mipi_i2c.sh -w -f mwbcolortemp -p1 3200

./cs_mipi_i2c.sh -r -f mwbcolortemp

manual white balance, color temperature mode, color tempture,range [1500,15000]

3.28 expostate

./cs_mipi_i2c.sh -r -f expostate

readonly, get the current exposure state. exposure time, again and dgain.

3.29 wbstate

./cs_mipi_i2c.sh -r -f wbstate

readonly, get the current white balance state. rgain, bgain and color tempture.

3.30 imagedir

./cs_mipi_i2c.sh -w -f imagedir -p1 0

./cs_mipi_i2c.sh -r -f imagedir

set image direction

imagedir
value description
0 normal
1 flip
2 mirror
3 flip+mirror
3.31 sreg

./cs_mipi_i2c.sh -r -f sreg -p1 SensorAddr

read the sensor register, indirect access.

for example: CS-MIPI-IMX307

./cs_mipi_i2c.sh -r -f sreg -p1 0x300A

r sensor addr 0x300a value 0x3c

3.32 striggerone

./cs_mipi_i2c.sh -w -f striggerone

In Software Trigger Mode,Trigger an exposure and image output by writing a register.

note: Only CS-MIPI-SC132 support.

3.33 triggeredge

./cs_mipi_i2c.sh -w -f triggeredge -p1 [value]

./cs_mipi_i2c.sh -r -f triggeredge

Edge attribute of trigger signal in Hardware Trigger mode.

value description
0 RisingEdge
1 FallingEdge

note: Only CS-MIPI-SC132 Support.

3.34 tgdebncr

./cs_mipi_i2c.sh -w -f triggeredge -p1 enable -p2 [value]

./cs_mipi_i2c.sh -r -f triggeredge
In Hardware Trigger mode,the debouncer attribute of the trigger signal.

Any trigger signal that is less than value (us) will be ignored.

note: Only CS-MIPI-SC132 Support.

3.35 tgdly

./cs_mipi_i2c.sh -w -f tgdly -p1 [value]

./cs_mipi_i2c.sh -r -f tgdly

Trigger delay in Hardware Trigger mode (us).
note: Only CS-MIPI-SC132 Support.

3.36 pickmode

./cs_mipi_i2c.sh -w -f pickmode -p1 enable

./cs_mipi_i2c.sh -r -f pickmode

Pickmode is a special function, once turned on, sensor works normally, but the module will not output images, only receive pickone instructions, output one.

3.37 pickone

./cs_mipi_i2c.sh -w -f pickone

When pickmode is enable, output one image.

3.38 sysreboot

./cs_mipi_i2c.sh -w -f sysreboot -p1 [value]

reboot the camera module

reboot_type
value description
1 Restart the problem
2 Fully reboot (6-8s)