diff --git a/build/libraries/camera/ARM7/MT9V113-MTM9-2.ini b/build/libraries/camera/ARM7/MT9V113-MTM9-2.ini new file mode 100644 index 0000000..ce40b57 --- /dev/null +++ b/build/libraries/camera/ARM7/MT9V113-MTM9-2.ini @@ -0,0 +1,770 @@ +;************************************************************************************** +; Copyright 2006 Micron Technology, Inc. All rights reserved. +; +; +; No permission to use, copy, modify, or distribute this software and/or +; its documentation for any purpose has been granted by Micron Technology, Inc. +; If any such permission has been granted ( by separate agreement ), it +; is required that the above copyright notice appear in all copies and +; that both that copyright notice and this permission notice appear in +; supporting documentation, and that the name of Micron Technology, Inc. or any +; of its trademarks may not be used in advertising or publicity pertaining +; to distribution of the software without specific, written prior permission. +; +; +; This software and any associated documentation are provided "AS IS" and +; without warranty of any kind. MICRON TECHNOLOGY, INC. EXPRESSLY DISCLAIMS +; ALL WARRANTIES EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, NONINFRINGEMENT +; OF THIRD PARTY RIGHTS, AND ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS +; FOR A PARTICULAR PURPOSE. MICRON DOES NOT WARRANT THAT THE FUNCTIONS CONTAINED +; IN THIS SOFTWARE WILL MEET YOUR REQUIREMENTS, OR THAT THE OPERATION OF THIS SOFTWARE +; WILL BE UNINTERRUPTED OR ERROR-FREE. FURTHERMORE, MICRON DOES NOT WARRANT OR +; MAKE ANY REPRESENTATIONS REGARDING THE USE OR THE RESULTS OF THE USE OF ANY +; ACCOMPANYING DOCUMENTATION IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY, +; OR OTHERWISE. +;**************************************************************************************/ +; +; Default INI file for the MI-0380-REV1 +; <<< MT9V113-MTM8.ini >>> +; $Revision: 1.3 $ +; $Date: 2007/04/22 07:13:21 $ +; +; This file holds groups of register presets (sections) specific for this sensor. The +; presets allow you to overwrite the power-on default settings with optimized register +; settings. +; The [Default Registers] section contains all optimized register settings for running +; the sensor in the demo environment. Other sections include settings optimized for a +; variety of situations like: Running at different master clock speeds, running under +; different lighting situations, running with different lenses, etc. +; Most of the demonstration software (DevWare, SensorDemo, ...) make use of this file +; to load and store the user presets. +; +; Keyname description: +; REG = assign a new register value +; BITFIELD = do a READ-MODIFY-WRITE to part of a register. The part is defined as a mask. +; LOAD = load an alternate section from this section +; STATE = set non-register state +; DELAY = delay a certain amount of milliseconds before continuing +; +; Keyname format: +; REG = [,]
, // +; BITFIELD = [,]
, , +; Some examples: +; BITFIELD=2, 0x05, 0x0020, 1 //for register 5 on page 2, set the 6th bit to 1 +; BITFIELD=0x06, 0x000F, 0 //for register 6, clear the first 4 bits +; LOAD =
+; STATE = , +; DELAY = +; +; Optional address space for this register. Some sensors (mostly SOC's) +; have multiple register pages (see the sensor spec or developer's guide) +;
the register address +; the new value to assign to the register +; is the part of a register value that needs to be updated with a new value +;
the name of another section to load +; non-register program state names [do not modify] +; wait for this ammount of milliseconds before continuing +; Some form of C-style comments are supported in this .ini file +; +;*************************************************************************************/ + +[Default Registers] +LOAD=Initialize Camera +DELAY=300 +//STATE=Gamma, 9 +//STATE=Black Correct, 5 +//STATE=Contrast, 25 + +LOAD=Image Setting ExtClk=16.76MHz Op_Pix=27.5MHz 15fps +//LOAD=Image Setting ExtClk=6.75MHz Op_Pix=27.5MHz 15fps +//LOAD=Fixed 15fps +LOAD=Lens Correction +LOAD=Auto Exposure +LOAD=Auto White Balance +LOAD=Gamma Correction +LOAD=Sharpness : 0 +LOAD=Refresh + + +[Initialize Camera] +IMAGE=320,240 +REG=0x001A, 0x0011 // RESET_AND_MISC_CONTROL +DELAY=10 +REG=0x001A, 0x0010 // RESET_AND_MISC_CONTROL +DELAY=10 +REG=0x0018, 0x4028 // STANDBY_CONTROL +REG=0x001A, 0x0210 // RESET_AND_MISC_CONTROL +REG=0x001E, 0x0777 // PAD_SLEW +REG=0x0016, 0x42DF // CLOCKS_CONTROL +//REG=0x0010, 0x0231 // PLL_DIVIDERS +//REG=0x0012, 0x0000 // PLL_P_DIVIDERS +REG=0x0014, 0x2147 // PLL_CONTROL +DELAY=10 +REG=0x0014, 0x2047 // PLL_CONTROL +DELAY=10 +REG=0x0014, 0xA046 // PLL_CONTROL +DELAY=10 +REG=0x3040, 0x0027 // READ_MODE +REG=0x301A, 0x1218 // RESET_REGISTER +DELAY=100 +REG=0x301A, 0x121C // RESET_REGISTER +//VAR=7, 0x03, 0x0140 // MODE_OUTPUT_WIDTH_A +//VAR=7, 0x05, 0x00F0 // MODE_OUTPUT_HEIGHT_A +//VAR=7, 0x07, 0x0280 // MODE_OUTPUT_WIDTH_B +//VAR=7, 0x09, 0x01E0 // MODE_OUTPUT_HEIGHT_B +VAR=7, 0x17, 0x0026 // MODE_SENSOR_READ_MODE_A +VAR=7, 0x2D, 0x0026 // MODE_SENSOR_READ_MODE_B + +VAR8=1, 0x03, 0x06 //(1) SEQ_CMD + +//////////////////////////////////////////////////////////////////////////////// +; This file was generated by: MT9V113 (SOC0380) Register Wizard +; Version: 2.8.0.53 Build Date: 06/06/2007 +; +; [PLL PARAMETERS] +; +; Bypass PLL: Unchecked +; Input Frequency: 6.750 +; Use Min Freq.: Unchecked +; Target System Frequency: 27.844 +; Target VCO Frequency: Unspecified +; "M" Value: Unspecified +; "N" Value: Unspecified +; +; Target PLL Frequency: 27.500 MHz +; MT9V113 Input Clock Frequency: 6.750 MHz +; MT9V113 Internal Clock Frequency: 27.844 MHz +; MT9V113 SOC Clock Frequency: 27.844 MHz +; M = 33 +; N = 0 +; Fpdf = 6.750 MHz +; Fvco = 445.500 MHz +; +; [CONTEXT A PARAMETERS] +; +; Requested Frames Per Second: 14.645 +; Output Columns: 640 +; Output Rows: 480 +; Allow Skipping: Unchecked +; Use Context B Line Time: Unchecked +; Low Power: Unchecked +; Blanking Computation: HB Min then VB +; +; Max Frame Time: 68.2827 msec +; Max Frame Clocks: 950623.0 clocks (13.922 MHz) +; Pixel Clock: divided by 1 +; Skip Mode: 1x cols, 1x rows, Bin Mode: No +; Horiz clks: 648 active + 194 blank = 842 total +; Vert rows: 488 active + 641 blank = 1129 total +; Extra Delay: 5 clocks +; +; Actual Frame Clocks: 950623 clocks +; Row Time: 60.480 usec / 842 clocks +; Frame time: 68.282685 msec +; Frames per Sec: 14.645 fps +; +; 50Hz Flicker Period: 165.34 lines +; 60Hz Flicker Period: 137.79 lines +; +; [CONTEXT B PARAMETERS] +; +; Requested Frames Per Second: 14.645 +; Output Columns: 640 +; Output Rows: 480 +; Allow Skipping: Unchecked +; Use Context A Line Time: Unchecked +; Low Power: Unchecked +; Blanking Computation: HB Min then VB +; +; Max Frame Time: 68.2827 msec +; Max Frame Clocks: 950623.0 clocks (13.922 MHz) +; Pixel Clock: divided by 1 +; Skip Mode: 1x cols, 1x rows, Bin Mode: No +; Horiz clks: 648 active + 194 blank = 842 total +; Vert rows: 488 active + 641 blank = 1129 total +; Extra Delay: 5 clocks +; +; Actual Frame Clocks: 950623 clocks +; Row Time: 60.480 usec / 842 clocks +; Frame time: 68.282685 msec +; Frames per Sec: 14.645 fps +; +; 50Hz Flicker Period: 165.34 lines +; 60Hz Flicker Period: 137.79 lines +; +; + +[Image Setting ExtClk=6.75MHz Op_Pix=27.5MHz 15fps] +BITFIELD= 0x14, 1, 1 // Bypass PLL +BITFIELD= 0X14, 2, 0 // Power-down PLL +REG = 0x0010, 0x0021 //PLL Dividers = 0x21 +REG = 0x0012, 0x0000 //PLL P Dividers = 0x0 +REG = 0x0014, 0x244B //PLL control: TEST_BYPASS on = 0x244B +DELAY = 1 // Allow PLL to lock +REG = 0x0014, 0x304B //PLL control: PLL_ENABLE on = 0x304B +POLL_REG=0x0014, 0x8000, ==0, DELAY=50, TIMEOUT=20 // Verify PLL lock +BITFIELD= 0x14, 1, 0 //PLL_BYPASS_OFF +REG = 0x98C, 0x2703 //Output Width (A) +REG = 0x990, 0x0280 // = 640 +REG = 0x98C, 0x2705 //Output Height (A) +REG = 0x990, 0x01E0 // = 480 +REG = 0x98C, 0x2707 //Output Width (B) +REG = 0x990, 0x0280 // = 640 +REG = 0x98C, 0x2709 //Output Height (B) +REG = 0x990, 0x01E0 // = 480 +REG = 0x98C, 0x270D //Row Start (A) +REG = 0x990, 0x004 // = 4 +REG = 0x98C, 0x270F //Column Start (A) +REG = 0x990, 0x004 // = 4 +REG = 0x98C, 0x2711 //Row End (A) +REG = 0x990, 0x1EB // = 491 +REG = 0x98C, 0x2713 //Column End (A) +REG = 0x990, 0x28B // = 651 +REG = 0x98C, 0x2715 //Row Speed (A) +REG = 0x990, 0x0001 // = 1 +REG = 0x98C, 0x2717 //Read Mode (A) +REG = 0x990, 0x0026 // = 38 +REG = 0x98C, 0x2719 //sensor_fine_correction (A) +REG = 0x990, 0x001A // = 26 +REG = 0x98C, 0x271B //sensor_fine_IT_min (A) +REG = 0x990, 0x006B // = 107 +REG = 0x98C, 0x271D //sensor_fine_IT_max_margin (A) +REG = 0x990, 0x006B // = 107 +REG = 0x98C, 0x271F //Frame Lines (A) +REG = 0x990, 0x0469 // = 1129 +REG = 0x98C, 0x2721 //Line Length (A) +REG = 0x990, 0x034A // = 842 +REG = 0x98C, 0x2723 //Row Start (B) +REG = 0x990, 0x004 // = 4 +REG = 0x98C, 0x2725 //Column Start (B) +REG = 0x990, 0x004 // = 4 +REG = 0x98C, 0x2727 //Row End (B) +REG = 0x990, 0x1EB // = 491 +REG = 0x98C, 0x2729 //Column End (B) +REG = 0x990, 0x28B // = 651 +REG = 0x98C, 0x272B //Row Speed (B) +REG = 0x990, 0x0001 // = 1 +REG = 0x98C, 0x272D //Read Mode (B) +REG = 0x990, 0x0026 // = 38 +REG = 0x98C, 0x272F //sensor_fine_correction (B) +REG = 0x990, 0x001A // = 26 +REG = 0x98C, 0x2731 //sensor_fine_IT_min (B) +REG = 0x990, 0x006B // = 107 +REG = 0x98C, 0x2733 //sensor_fine_IT_max_margin (B) +REG = 0x990, 0x006B // = 107 +REG = 0x98C, 0x2735 //Frame Lines (B) +REG = 0x990, 0x0469 // = 1129 +REG = 0x98C, 0x2737 //Line Length (B) +REG = 0x990, 0x034A // = 842 +REG = 0x98C, 0x2739 //Crop_X0 (A) +REG = 0x990, 0x0000 // = 0 +REG = 0x98C, 0x273B //Crop_X1 (A) +REG = 0x990, 0x027F // = 639 +REG = 0x98C, 0x273D //Crop_Y0 (A) +REG = 0x990, 0x0000 // = 0 +REG = 0x98C, 0x273F //Crop_Y1 (A) +REG = 0x990, 0x01DF // = 479 +REG = 0x98C, 0x2747 //Crop_X0 (B) +REG = 0x990, 0x0000 // = 0 +REG = 0x98C, 0x2749 //Crop_X1 (B) +REG = 0x990, 0x027F // = 639 +REG = 0x98C, 0x274B //Crop_Y0 (B) +REG = 0x990, 0x0000 // = 0 +REG = 0x98C, 0x274D //Crop_Y1 (B) +REG = 0x990, 0x01DF // = 479 +REG = 0x98C, 0x222D //R9 Step +REG = 0x990, 0x008A // = 138 +REG = 0x98C, 0xA408 //search_f1_50 +REG = 0x990, 0x19 // = 25 +REG = 0x98C, 0xA409 //search_f2_50 +REG = 0x990, 0x1C // = 28 +REG = 0x98C, 0xA40A //search_f1_60 +REG = 0x990, 0x1F // = 31 +REG = 0x98C, 0xA40B //search_f2_60 +REG = 0x990, 0x22 // = 34 +REG = 0x98C, 0x2411 //R9_Step_60_A +REG = 0x990, 0x008A // = 138 +REG = 0x98C, 0x2413 //R9_Step_50_A +REG = 0x990, 0x00A5 // = 165 +REG = 0x98C, 0x2415 //R9_Step_60_B +REG = 0x990, 0x008A // = 138 +REG = 0x98C, 0x2417 //R9_Step_50_B +REG = 0x990, 0x00A5 // = 165 +REG = 0x98C, 0xA40D //Stat_min +REG = 0x990, 0x02 // = 2 +REG = 0x98C, 0xA410 //Min_amplitude +REG = 0x990, 0x01 // = 1 + +//////////////////////////////////////////////////////////////////////////////// +; This file was generated by: MT9V113 (SOC0380) Register Wizard +; Version: 2.9.0.2 Build Date: 06/29/2007 +; +; [PLL PARAMETERS] +; +; Bypass PLL: Unchecked +; Input Frequency: 16.760 +; Use Min Freq.: Unchecked +; Target System Frequency: 27.759 +; Target VCO Frequency: Unspecified +; "M" Value: Unspecified +; "N" Value: Unspecified +; +; Target PLL Frequency: 27.500 MHz +; MT9V113 Input Clock Frequency: 16.760 MHz +; MT9V113 Internal Clock Frequency: 27.759 MHz +; MT9V113 SOC Clock Frequency: 27.759 MHz +; M = 53 +; N = 3 +; Fpdf = 4.190 MHz +; Fvco = 444.140 MHz +; +; [CONTEXT A PARAMETERS] +; +; Requested Frames Per Second: 15.000 +; Output Columns: 640 +; Output Rows: 480 +; Allow Skipping: Unchecked +; Use Context B Line Time: Unchecked +; Low Power: Unchecked +; Blanking Computation: HB Min then VB +; +; Max Frame Time: 66.6667 msec +; Max Frame Clocks: 925291.6 clocks (13.879 MHz) +; Pixel Clock: divided by 1 +; Skip Mode: 1x cols, 1x rows, Bin Mode: No +; Horiz clks: 648 active + 194 blank = 842 total +; Vert rows: 488 active + 610 blank = 1098 total +; Extra Delay: 775 clocks +; +; Actual Frame Clocks: 925291 clocks +; Row Time: 60.666 usec / 842 clocks +; Frame time: 66.666619 msec +; Frames per Sec: 15 fps +; +; 50Hz Flicker Period: 164.84 lines +; 60Hz Flicker Period: 137.37 lines +; +; [CONTEXT B PARAMETERS] +; +; Requested Frames Per Second: 15.000 +; Output Columns: 640 +; Output Rows: 480 +; Allow Skipping: Unchecked +; Use Context A Line Time: Unchecked +; Low Power: Unchecked +; Blanking Computation: HB Min then VB +; +; Max Frame Time: 66.6667 msec +; Max Frame Clocks: 925291.6 clocks (13.879 MHz) +; Pixel Clock: divided by 1 +; Skip Mode: 1x cols, 1x rows, Bin Mode: No +; Horiz clks: 648 active + 194 blank = 842 total +; Vert rows: 488 active + 610 blank = 1098 total +; Extra Delay: 775 clocks +; +; Actual Frame Clocks: 925291 clocks +; Row Time: 60.666 usec / 842 clocks +; Frame time: 66.666619 msec +; Frames per Sec: 15 fps +; +; 50Hz Flicker Period: 164.84 lines +; 60Hz Flicker Period: 137.37 lines +; +; + +[Image Setting ExtClk=16.76MHz Op_Pix=27.5MHz 15fps] +BITFIELD= 0x14, 1, 1 // Bypass PLL +BITFIELD= 0X14, 2, 0 // Power-down PLL +REG = 0x0010, 0x0335 //PLL Dividers = 0x335 +REG = 0x0012, 0x0000 //PLL P Dividers = 0x0 +REG = 0x0014, 0x244B //PLL control: TEST_BYPASS on = 0x244B +DELAY = 1 // Allow PLL to lock +REG = 0x0014, 0x304B //PLL control: PLL_ENABLE on = 0x304B +POLL_REG=0x0014, 0x8000, ==0, DELAY=50, TIMEOUT=20 // Verify PLL lock +BITFIELD= 0x14, 1, 0 //PLL_BYPASS_OFF +REG = 0x98C, 0x2703 //Output Width (A) +REG = 0x990, 0x0280 // = 640 +REG = 0x98C, 0x2705 //Output Height (A) +REG = 0x990, 0x01E0 // = 480 +REG = 0x98C, 0x2707 //Output Width (B) +REG = 0x990, 0x0280 // = 640 +REG = 0x98C, 0x2709 //Output Height (B) +REG = 0x990, 0x01E0 // = 480 +REG = 0x98C, 0x270D //Row Start (A) +REG = 0x990, 0x004 // = 4 +REG = 0x98C, 0x270F //Column Start (A) +REG = 0x990, 0x004 // = 4 +REG = 0x98C, 0x2711 //Row End (A) +REG = 0x990, 0x1EB // = 491 +REG = 0x98C, 0x2713 //Column End (A) +REG = 0x990, 0x28B // = 651 +REG = 0x98C, 0x2715 //Row Speed (A) +REG = 0x990, 0x0001 // = 1 +REG = 0x98C, 0x2717 //Read Mode (A) +REG = 0x990, 0x0026 // = 38 +REG = 0x98C, 0x2719 //sensor_fine_correction (A) +REG = 0x990, 0x001A // = 26 +REG = 0x98C, 0x271B //sensor_fine_IT_min (A) +REG = 0x990, 0x006B // = 107 +REG = 0x98C, 0x271D //sensor_fine_IT_max_margin (A) +REG = 0x990, 0x006B // = 107 +REG = 0x98C, 0x271F //Frame Lines (A) +REG = 0x990, 0x044A // = 1098 +REG = 0x98C, 0x2721 //Line Length (A) +REG = 0x990, 0x034A // = 842 +REG = 0x98C, 0x2723 //Row Start (B) +REG = 0x990, 0x004 // = 4 +REG = 0x98C, 0x2725 //Column Start (B) +REG = 0x990, 0x004 // = 4 +REG = 0x98C, 0x2727 //Row End (B) +REG = 0x990, 0x1EB // = 491 +REG = 0x98C, 0x2729 //Column End (B) +REG = 0x990, 0x28B // = 651 +REG = 0x98C, 0x272B //Row Speed (B) +REG = 0x990, 0x0001 // = 1 +REG = 0x98C, 0x272D //Read Mode (B) +REG = 0x990, 0x0026 // = 38 +REG = 0x98C, 0x272F //sensor_fine_correction (B) +REG = 0x990, 0x001A // = 26 +REG = 0x98C, 0x2731 //sensor_fine_IT_min (B) +REG = 0x990, 0x006B // = 107 +REG = 0x98C, 0x2733 //sensor_fine_IT_max_margin (B) +REG = 0x990, 0x006B // = 107 +REG = 0x98C, 0x2735 //Frame Lines (B) +REG = 0x990, 0x044A // = 1098 +REG = 0x98C, 0x2737 //Line Length (B) +REG = 0x990, 0x034A // = 842 +REG = 0x98C, 0x2739 //Crop_X0 (A) +REG = 0x990, 0x0000 // = 0 +REG = 0x98C, 0x273B //Crop_X1 (A) +REG = 0x990, 0x027F // = 639 +REG = 0x98C, 0x273D //Crop_Y0 (A) +REG = 0x990, 0x0000 // = 0 +REG = 0x98C, 0x273F //Crop_Y1 (A) +REG = 0x990, 0x01DF // = 479 +REG = 0x98C, 0x2747 //Crop_X0 (B) +REG = 0x990, 0x0000 // = 0 +REG = 0x98C, 0x2749 //Crop_X1 (B) +REG = 0x990, 0x027F // = 639 +REG = 0x98C, 0x274B //Crop_Y0 (B) +REG = 0x990, 0x0000 // = 0 +REG = 0x98C, 0x274D //Crop_Y1 (B) +REG = 0x990, 0x01DF // = 479 +REG = 0x98C, 0x222D //R9 Step +REG = 0x990, 0x0089 // = 137 +REG = 0x98C, 0xA408 //search_f1_50 +REG = 0x990, 0x19 // = 25 +REG = 0x98C, 0xA409 //search_f2_50 +REG = 0x990, 0x1C // = 28 +REG = 0x98C, 0xA40A //search_f1_60 +REG = 0x990, 0x1F // = 31 +REG = 0x98C, 0xA40B //search_f2_60 +REG = 0x990, 0x22 // = 34 +REG = 0x98C, 0x2411 //R9_Step_60_A +REG = 0x990, 0x0089 // = 137 +REG = 0x98C, 0x2413 //R9_Step_50_A +REG = 0x990, 0x00A5 // = 165 +REG = 0x98C, 0x2415 //R9_Step_60_B +REG = 0x990, 0x0089 // = 137 +REG = 0x98C, 0x2417 //R9_Step_50_B +REG = 0x990, 0x00A5 // = 165 +REG = 0x98C, 0xA40D //Stat_min +REG = 0x990, 0x02 // = 2 +REG = 0x98C, 0xA410 //Min_amplitude +REG = 0x990, 0x01 // = 1 + +[Viewfinder ON] +FIELD_WR = SEQ_CAP_MODE, VIDEO, 0 //capture parameters, VIDEO Off +FIELD_WR = SEQ_CMD, 1 //Back to preview + +[Viewfinder OFF] +FIELD_WR = SEQ_CAP_MODE, VIDEO, 1 //capture parameters, VIDEO On +FIELD_WR = SEQ_CMD, 2 //Capture on + +[Video Capture ON] +FIELD_WR = SEQ_CAP_MODE, VIDEO, 1 //capture parameters, VIDEO On +FIELD_WR = SEQ_CMD, 2 //Capture on + +[Video Capture OFF] +FIELD_WR = SEQ_CMD, 1 //Back to preview + +[Lens Calibration Setup] +REG=0x3330, 0x0140 //(2) OUTPUT_FORMAT_TEST +BITFIELD=0x3040, 0x002, 0 + +[Lens Calibration Exit] +BITFIELD=0x3040, 0x002, 1 +REG=0x3330, 0x0000 //(4) OUTPUT_FORMAT_TEST +BITFIELD=0x3210, 0x08, 1 + +[Fixed 15fps] +VAR8=2, 0x0C, 0x08 //(1) AE_MAX_INDEX +VAR=7, 0x1F, 0x076C //(1) MODE_SENSOR_FRAME_LENGTH_A + +[Refresh] +REG = 0x98C, 0xA103 //Refresh Sequencer Mode +REG = 0x990, 0x06 // = 6 +POLL_FIELD=SEQ_CMD, !=0, DELAY=10, TIMEOUT=50 +REG = 0x98C, 0xA103 //Refresh Sequencer +REG = 0x990, 0x05 // = 5 +POLL_FIELD=SEQ_CMD, !=0, DELAY=10, TIMEOUT=50 + +[Auto Exposure] +VAR8=2, 0x07, 0x1A //(2) AE_GATE +VAR8=2, 0x4C, 0x10 //(1) AE_TARGETBUFFERSPEED +VAR8=2, 0x4F, 0x50 //(5) AE_BASETARGET + +[Gamma Correction] +VAR8=11, 0x04, 0x80 //(1) HG_MAX_DLEVEL + +VAR8=11, 0x37, 0x03 //(1) HG_GAMMA_MORPH_CTRL +VAR=11, 0x38, 0x0080 //(1) HG_GAMMASTARTMORPH +VAR=11, 0x3A, 0x00B0 //(1) HG_GAMMASTOPMORPH +VAR8=11, 0x3C, 0x00 //(2) HG_GAMMA_TABLE_A_0 +VAR8=11, 0x3D, 0x02 //(2) HG_GAMMA_TABLE_A_1 +VAR8=11, 0x3E, 0x08 //(2) HG_GAMMA_TABLE_A_2 +VAR8=11, 0x3F, 0x18 //(2) HG_GAMMA_TABLE_A_3 +VAR8=11, 0x40, 0x38 //(2) HG_GAMMA_TABLE_A_4 +VAR8=11, 0x41, 0x55 //(2) HG_GAMMA_TABLE_A_5 +VAR8=11, 0x42, 0x72 //(2) HG_GAMMA_TABLE_A_6 +VAR8=11, 0x43, 0x8E //(2) HG_GAMMA_TABLE_A_7 +VAR8=11, 0x44, 0xA5 //(2) HG_GAMMA_TABLE_A_8 +VAR8=11, 0x45, 0xB6 //(2) HG_GAMMA_TABLE_A_9 +VAR8=11, 0x46, 0xC5 //(2) HG_GAMMA_TABLE_A_10 +VAR8=11, 0x47, 0xD0 //(2) HG_GAMMA_TABLE_A_11 +VAR8=11, 0x48, 0xDA //(2) HG_GAMMA_TABLE_A_12 +VAR8=11, 0x49, 0xE2 //(2) HG_GAMMA_TABLE_A_13 +VAR8=11, 0x4A, 0xE9 //(2) HG_GAMMA_TABLE_A_14 +VAR8=11, 0x4B, 0xF0 //(2) HG_GAMMA_TABLE_A_15 +VAR8=11, 0x4C, 0xF5 //(2) HG_GAMMA_TABLE_A_16 +VAR8=11, 0x4D, 0xFA //(2) HG_GAMMA_TABLE_A_17 +VAR8=11, 0x4E, 0xFF //(2) HG_GAMMA_TABLE_A_18 +VAR8=11, 0x4F, 0x00 //(2) HG_GAMMA_TABLE_B_0 +VAR8=11, 0x50, 0x01 //(2) HG_GAMMA_TABLE_B_1 +VAR8=11, 0x51, 0x02 //(2) HG_GAMMA_TABLE_B_2 +VAR8=11, 0x52, 0x05 //(2) HG_GAMMA_TABLE_B_3 +VAR8=11, 0x53, 0x11 //(2) HG_GAMMA_TABLE_B_4 +VAR8=11, 0x54, 0x1E //(2) HG_GAMMA_TABLE_B_5 +VAR8=11, 0x55, 0x2D //(2) HG_GAMMA_TABLE_B_6 +VAR8=11, 0x56, 0x3F //(2) HG_GAMMA_TABLE_B_7 +VAR8=11, 0x57, 0x53 //(2) HG_GAMMA_TABLE_B_8 +VAR8=11, 0x58, 0x6B //(2) HG_GAMMA_TABLE_B_9 +VAR8=11, 0x59, 0x87 //(2) HG_GAMMA_TABLE_B_10 +VAR8=11, 0x5A, 0xA0 //(2) HG_GAMMA_TABLE_B_11 +VAR8=11, 0x5B, 0xB5 //(2) HG_GAMMA_TABLE_B_12 +VAR8=11, 0x5C, 0xC7 //(2) HG_GAMMA_TABLE_B_13 +VAR8=11, 0x5D, 0xD6 //(2) HG_GAMMA_TABLE_B_14 +VAR8=11, 0x5E, 0xE2 //(2) HG_GAMMA_TABLE_B_15 +VAR8=11, 0x5F, 0xED //(2) HG_GAMMA_TABLE_B_16 +VAR8=11, 0x60, 0xF6 //(2) HG_GAMMA_TABLE_B_17 +VAR8=11, 0x61, 0xFF //(2) HG_GAMMA_TABLE_B_18 + +[Auto White Balance] +VAR=3, 0x06, 0x019B //AWB_CCM_L_0 +VAR=3, 0x08, 0xFF4D //AWB_CCM_L_1 +VAR=3, 0x0A, 0x001C //AWB_CCM_L_2 +VAR=3, 0x0C, 0xFF00 //AWB_CCM_L_3 +VAR=3, 0x0E, 0x02FE //AWB_CCM_L_4 +VAR=3, 0x10, 0xFF14 //AWB_CCM_L_5 +VAR=3, 0x12, 0xFF24 //AWB_CCM_L_6 +VAR=3, 0x14, 0xFD7F //AWB_CCM_L_7 +VAR=3, 0x16, 0x03E9 //AWB_CCM_L_8 +VAR=3, 0x18, 0x002A //AWB_CCM_L_9 +VAR=3, 0x1A, 0x003A //AWB_CCM_L_10 +VAR=3, 0x1C, 0x0020 //AWB_CCM_RL_0 +VAR=3, 0x1E, 0x0065 //AWB_CCM_RL_1 +VAR=3, 0x20, 0xFFB1 //AWB_CCM_RL_2 +VAR=3, 0x22, 0x0063 //AWB_CCM_RL_3 +VAR=3, 0x24, 0xFE8C //AWB_CCM_RL_4 +VAR=3, 0x26, 0x006A //AWB_CCM_RL_5 +VAR=3, 0x28, 0x0077 //AWB_CCM_RL_6 +VAR=3, 0x2A, 0x0161 //AWB_CCM_RL_7 +VAR=3, 0x2C, 0xFE76 //AWB_CCM_RL_8 +VAR=3, 0x2E, 0x0009 //AWB_CCM_RL_9 +VAR=3, 0x30, 0xFFEC //AWB_CCM_RL_10 + +VAR8=3, 0x5D, 0x73 //(1) AWB_STEADY_BGAIN_OUT_MIN +VAR8=3, 0x5E, 0x8D //(1) AWB_STEADY_BGAIN_OUT_MAX + + +[Lens Correction] +REG=0x3658, 0x7D8F //P_RD_P0Q0 +REG=0x365A, 0x314D //P_RD_P0Q1 +REG=0x365C, 0x7912 //P_RD_P0Q2 +REG=0x365E, 0xA10F //P_RD_P0Q3 +REG=0x3660, 0x6874 //P_RD_P0Q4 +REG=0x3680, 0x1F0B //P_RD_P1Q0 +REG=0x3682, 0xD48C //P_RD_P1Q1 +REG=0x3684, 0x0E72 //P_RD_P1Q2 +REG=0x3686, 0x6B51 //P_RD_P1Q3 +REG=0x3688, 0x91F1 //P_RD_P1Q4 +REG=0x36A8, 0x1293 //P_RD_P2Q0 +REG=0x36AA, 0x04F0 //P_RD_P2Q1 +REG=0x36AC, 0x40D6 //P_RD_P2Q2 +REG=0x36AE, 0x1931 //P_RD_P2Q3 +REG=0x36B0, 0xFCD7 //P_RD_P2Q4 +REG=0x36D0, 0x34D1 //P_RD_P3Q0 +REG=0x36D2, 0x5C92 //P_RD_P3Q1 +REG=0x36D4, 0xEDF5 //P_RD_P3Q2 +REG=0x36D6, 0x56B4 //P_RD_P3Q3 +REG=0x36D8, 0x47F9 //P_RD_P3Q4 +REG=0x36F8, 0x4175 //P_RD_P4Q0 +REG=0x36FA, 0xC7F4 //P_RD_P4Q1 +REG=0x36FC, 0xE738 //P_RD_P4Q2 +REG=0x36FE, 0x8C98 //P_RD_P4Q3 +REG=0x3700, 0x4D5C //P_RD_P4Q4 +REG=0x364E, 0x7D0F //P_GR_P0Q0 +REG=0x3650, 0x31CC //P_GR_P0Q1 +REG=0x3652, 0x47D2 //P_GR_P0Q2 +REG=0x3654, 0xC58F //P_GR_P0Q3 +REG=0x3656, 0x2374 //P_GR_P0Q4 +REG=0x3676, 0x232A //P_GR_P1Q0 +REG=0x3678, 0x6186 //P_GR_P1Q1 +REG=0x367A, 0x1852 //P_GR_P1Q2 +REG=0x367C, 0x1F30 //P_GR_P1Q3 +REG=0x367E, 0x9D14 //P_GR_P1Q4 +REG=0x369E, 0x6A52 //P_GR_P2Q0 +REG=0x36A0, 0x3450 //P_GR_P2Q1 +REG=0x36A2, 0x3A96 //P_GR_P2Q2 +REG=0x36A4, 0x93B4 //P_GR_P2Q3 +REG=0x36A6, 0xF5B8 //P_GR_P2Q4 +REG=0x36C6, 0x3D11 //P_GR_P3Q0 +REG=0x36C8, 0x2832 //P_GR_P3Q1 +REG=0x36CA, 0xA816 //P_GR_P3Q2 +REG=0x36CC, 0x2BD4 //P_GR_P3Q3 +REG=0x36CE, 0x7479 //P_GR_P3Q4 +REG=0x36EE, 0x2175 //P_GR_P4Q0 +REG=0x36F0, 0xC714 //P_GR_P4Q1 +REG=0x36F2, 0xC339 //P_GR_P4Q2 +REG=0x36F4, 0x47B6 //P_GR_P4Q3 +REG=0x36F6, 0x0BBD //P_GR_P4Q4 +REG=0x3662, 0x7CAF //P_BL_P0Q0 +REG=0x3664, 0x6BEC //P_BL_P0Q1 +REG=0x3666, 0x4CD2 //P_BL_P0Q2 +REG=0x3668, 0xE80F //P_BL_P0Q3 +REG=0x366A, 0x7B53 //P_BL_P0Q4 +REG=0x368A, 0x2B8B //P_BL_P1Q0 +REG=0x368C, 0x2C0B //P_BL_P1Q1 +REG=0x368E, 0x0EF2 //P_BL_P1Q2 +REG=0x3690, 0x77F0 //P_BL_P1Q3 +REG=0x3692, 0xA1D4 //P_BL_P1Q4 +REG=0x36B2, 0x53B2 //P_BL_P2Q0 +REG=0x36B4, 0x5670 //P_BL_P2Q1 +REG=0x36B6, 0x1D76 //P_BL_P2Q2 +REG=0x36B8, 0xAD10 //P_BL_P2Q3 +REG=0x36BA, 0x8179 //P_BL_P2Q4 +REG=0x36DA, 0x6611 //P_BL_P3Q0 +REG=0x36DC, 0x09D3 //P_BL_P3Q1 +REG=0x36DE, 0xB976 //P_BL_P3Q2 +REG=0x36E0, 0x7F14 //P_BL_P3Q3 +REG=0x36E2, 0x7AD9 //P_BL_P3Q4 +REG=0x3702, 0x16D5 //P_BL_P4Q0 +REG=0x3704, 0x8CD5 //P_BL_P4Q1 +REG=0x3706, 0xD2F9 //P_BL_P4Q2 +REG=0x3708, 0x9316 //P_BL_P4Q3 +REG=0x370A, 0x1BDD //P_BL_P4Q4 +REG=0x366C, 0x7BEF //P_GB_P0Q0 +REG=0x366E, 0x300C //P_GB_P0Q1 +REG=0x3670, 0x4FF2 //P_GB_P0Q2 +REG=0x3672, 0xA2AF //P_GB_P0Q3 +REG=0x3674, 0x1EF4 //P_GB_P0Q4 +REG=0x3694, 0x570B //P_GB_P1Q0 +REG=0x3696, 0xA4A7 //P_GB_P1Q1 +REG=0x3698, 0x1392 //P_GB_P1Q2 +REG=0x369A, 0x4430 //P_GB_P1Q3 +REG=0x369C, 0x82D4 //P_GB_P1Q4 +REG=0x36BC, 0x5F12 //P_GB_P2Q0 +REG=0x36BE, 0x40D0 //P_GB_P2Q1 +REG=0x36C0, 0x2ED6 //P_GB_P2Q2 +REG=0x36C2, 0x95B4 //P_GB_P2Q3 +REG=0x36C4, 0xEA18 //P_GB_P2Q4 +REG=0x36E4, 0x3191 //P_GB_P3Q0 +REG=0x36E6, 0x3632 //P_GB_P3Q1 +REG=0x36E8, 0xA476 //P_GB_P3Q2 +REG=0x36EA, 0xE411 //P_GB_P3Q3 +REG=0x36EC, 0x7339 //P_GB_P3Q4 +REG=0x370C, 0x2655 //P_GB_P4Q0 +REG=0x370E, 0xE994 //P_GB_P4Q1 +REG=0x3710, 0xA5D9 //P_GB_P4Q2 +REG=0x3712, 0x4777 //P_GB_P4Q3 +REG=0x3714, 0x7B9C //P_GB_P4Q4 +REG=0x3644, 0x0158 //POLY_ORIGIN_C +REG=0x3642, 0x00E4 //POLY_ORIGIN_R +STATE=Lens Correction Falloff, 90 +STATE=Lens Correction Center X, 344 +STATE=Lens Correction Center Y, 228 +BITFIELD=0x3210, 0x0008, 1 //PGA_ENABLE + +[Image Size : VGA] +VAR=7, 0x03, 0x0280 //MODE_OUTPUT_WIDTH_A +VAR=7, 0x05, 0x01E0 //MODE_OUTPUT_HEIGHT_A +VAR8=1, 0x03, 0x05 //SEQ_CMD + +[Image Size : QVGA] +VAR=7, 0x03, 0x0140 //MODE_OUTPUT_WIDTH_A +VAR=7, 0x05, 0x00F0 //MODE_OUTPUT_HEIGHT_A +VAR8=1, 0x03, 0x05 //SEQ_CMD + +[Image Size : CIF] +VAR=7, 0x03, 0x0160 //MODE_OUTPUT_WIDTH_A +VAR=7, 0x05, 0x0120 //MODE_OUTPUT_HEIGHT_A +VAR8=1, 0x03, 0x05 //SEQ_CMD + +[Image Size : QCIF] +VAR=7, 0x03, 0x00B0 //MODE_OUTPUT_WIDTH_A +VAR=7, 0x05, 0x0090 //MODE_OUTPUT_HEIGHT_A +VAR8=1, 0x03, 0x05 //SEQ_CMD + +[Effect : Off] +VAR8=1, 0x03, 0x05 //SEQ_CMD +VAR=7, 0x59, 0x6440 //MODE_SPEC_EFFECTS_A +VAR=7, 0x5B, 0x6440 //MODE_SPEC_EFFECTS_B + +[Effect : Mono] +VAR=7, 0x59, 0x6441 //MODE_SPEC_EFFECTS_A +VAR=7, 0x5B, 0x6441 //MODE_SPEC_EFFECTS_B +VAR8=1, 0x03, 0x05 //SEQ_CMD + +[Effect : Sepia] +VAR=7, 0x59, 0x6442 //MODE_SPEC_EFFECTS_A +VAR=7, 0x5B, 0x6442 //MODE_SPEC_EFFECTS_B +VAR=7, 0x63, 0xA921 //MODE_COMMONMODESETTINGS_FX_SEPIA_SETTINGS +VAR8=1, 0x03, 0x05 //SEQ_CMD + +[Manual WB -> Auto WB] +VAR8=1, 0x02, 0x0F //SEQ_MODE + +[Manual White Balance : P1] +VAR8=1, 0x02, 0x0B //SEQ_MODE +VAR8=3, 0x53, 0x0 //AWB_CCM_POSITION + +[Manual White Balance : P2] +VAR8=1, 0x02, 0x0B //SEQ_MODE +VAR8=3, 0x53, 0x12 //AWB_CCM_POSITION + +[Manual White Balance : P3] +VAR8=1, 0x02, 0x0B //SEQ_MODE +VAR8=3, 0x53, 0x24 //AWB_CCM_POSITION + +[Manual White Balance : P4] +VAR8=1, 0x02, 0x0B //SEQ_MODE +VAR8=3, 0x53, 0x36 //AWB_CCM_POSITION + +[Manual White Balance : P5] +VAR8=1, 0x02, 0x0B //SEQ_MODE +VAR8=3, 0x53, 0x48 //AWB_CCM_POSITION + +[Manual White Balance : P6] +VAR8=1, 0x02, 0x0B //SEQ_MODE +VAR8=3, 0x53, 0x5A //AWB_CCM_POSITION + +[Manual White Balance : P7] +VAR8=1, 0x02, 0x0B //SEQ_MODE +VAR8=3, 0x53, 0x6C //AWB_CCM_POSITION + +[Manual White Balance : P8] +VAR8=1, 0x02, 0x0B //SEQ_MODE +VAR8=3, 0x53, 0x7F //AWB_CCM_POSITION + +[Sharpness : 0] +REG=0x326C, 0x1600 //APERTURE_PARAMETERS diff --git a/build/libraries/camera/ARM7/Makefile b/build/libraries/camera/ARM7/Makefile index 731ca38..65ea7cf 100644 --- a/build/libraries/camera/ARM7/Makefile +++ b/build/libraries/camera/ARM7/Makefile @@ -29,7 +29,9 @@ TWL_PROC = ARM7 SRCDIR = ../common . SRCS = \ - camera_i2c.c \ + camera_i2c_common.c \ + camera_i2c_micron.c \ + camera_i2c_sharp.c \ camera_control.c \ L_SET_FILE := A3AFX_EVT2_20fps_16M_PLLoff_hVGA_070209.set \ @@ -40,9 +42,16 @@ L_SET_FILE := A3AFX_EVT2_20fps_16M_PLLoff_hVGA_070209.set \ A3AFX_EVT3_30fps_Scaledown_16.7M_50Hz.set \ A3AFX_EVT3_30fps_Subsampling_16.7M_50Hz.set \ -L_CONVERT_EXE := convert.pl +L_INI_FILE := MT9V113-MTM9-2.ini + +L_SET_CONVERT_EXE := convert_samsung.pl +L_INI_CONVERT_EXE := convert_micron.pl + L_SETC_FILE := $(L_SET_FILE:%.set=%.autogen.c) -SRCS += $(L_SETC_FILE) +#SRCS += $(L_SETC_FILE) + +L_INIC_FILE := $(L_INI_FILE:%.ini=%.autogen.c) +SRCS += $(L_INIC_FILE) TARGET_LIB = libcamera_sp$(TWL_LIBSUFFIX).a @@ -68,7 +77,10 @@ do-build: $(TARGETS) include $(TWLSDK_ROOT)/build/buildtools/modulerules -%.autogen.c: %.set $(L_CONVERT_EXE) - perl $(L_CONVERT_EXE) $< > $@ +%.autogen.c: %.ini $(L_INI_CONVERT_EXE) + perl $(L_INI_CONVERT_EXE) $< > $@ + +%.autogen.c: %.set $(L_SET_CONVERT_EXE) + perl $(L_INI_CONVERT_EXE) $< > $@ #===== End of Makefile ===== diff --git a/build/libraries/camera/ARM7/camera_control.c b/build/libraries/camera/ARM7/camera_control.c index 52b0639..51a56a0 100644 --- a/build/libraries/camera/ARM7/camera_control.c +++ b/build/libraries/camera/ARM7/camera_control.c @@ -19,8 +19,6 @@ /*---------------------------------------------------------------------------* 定数定義 *---------------------------------------------------------------------------*/ -#define CAMERA_STBYN_MASK REG_EXI_GPIO2DATA_IO18_1_MASK - #define CAMERA_PXI_SIZE_CHECK(nums) \ if (cameraWork.total != (nums)) { \ CameraReturnResult(cameraWork.command, CAMERA_PXI_RESULT_INVALID_PARAMETER); \ @@ -43,8 +41,8 @@ /*---------------------------------------------------------------------------* 静的変数定義 *---------------------------------------------------------------------------*/ -static BOOL cameraInitialized; // 初期化確認フラグ -static CAMERAWork cameraWork; // ワーク変数をまとめた構造体 +static BOOL cameraInitialized; // 初期化確認フラグ +static CAMERAWork cameraWork; // ワーク変数をまとめた構造体 /*---------------------------------------------------------------------------* 内部関数定義 @@ -72,10 +70,8 @@ void CAMERA_Init(u32 priority) } cameraInitialized = 1; - // GPIO初期設定 - CAMERA_CLEAR_GPIO(reg_EXI_GPIO2IE); // 割り込みなし - CAMERA_SET_GPIO(reg_EXI_GPIO2DIR); // 出力設定 - CAMERA_CLEAR_GPIO(reg_EXI_GPIO2DATA); // 初期値0 + // ワーク初期化 + cameraWork.camera = CAMERA_SELECT_NONE; // PXI関連を初期化 PXI_Init(); @@ -136,7 +132,7 @@ static void CameraPxiCallback(PXIFifoTag tag, u32 data, BOOL err) switch (cameraWork.command) { // 既知のコマンド群 - case CAMERA_PXI_COMMAND_SET_STBYN: + case CAMERA_PXI_COMMAND_SELECT: // I2C基本操作 case CAMERA_PXI_COMMAND_WRITE_REGISTERS: case CAMERA_PXI_COMMAND_READ_REGISTERS: @@ -234,11 +230,13 @@ static void CameraThread(void *arg) OSMessage msg; BOOL result; +#if 0 u16 data16a; u16 data16b; u16 data16c; u16 data16d; u8 dataArray[CAMERA_PXI_DATA_SIZE_MAX]; // 不定長データ格納用 +#endif while (TRUE) { @@ -248,36 +246,46 @@ static void CameraThread(void *arg) // コマンドに従って各種処理を実行 switch (cameraWork.command) { - case CAMERA_PXI_COMMAND_SET_STBYN: - CAMERA_PXI_SIZE_CHECK(CAMERA_PXI_SIZE_SET_STBYN); - if (cameraWork.data[0]) + case CAMERA_PXI_COMMAND_SELECT: + CAMERA_PXI_SIZE_CHECK(CAMERA_PXI_SIZE_SELECT); + if (cameraWork.camera != cameraWork.data[0]) { - CAMERA_SET_GPIO(reg_EXI_GPIO2DATA); // High - } - else - { - CAMERA_CLEAR_GPIO(reg_EXI_GPIO2DATA); // Low + if (cameraWork.camera != CAMERA_SELECT_NONE) + { + if (FALSE == CAMERA_I2CStandby(cameraWork.camera, TRUE)) + { + CameraReturnResult(cameraWork.command, CAMERA_PXI_RESULT_SUCCESS_FALSE); // ARM9に処理の失敗を通達 + } + } + cameraWork.camera = (CameraSelect)cameraWork.data[0]; + if (cameraWork.camera != CAMERA_SELECT_NONE) + { + if (FALSE == CAMERA_I2CStandby(cameraWork.camera, FALSE)) // set ?XXXXXXXXX + { + CameraReturnResult(cameraWork.command, CAMERA_PXI_RESULT_SUCCESS_FALSE); // ARM9に処理の失敗を通達 + } + } } CameraReturnResult(cameraWork.command, CAMERA_PXI_RESULT_SUCCESS); // ARM9に処理の成功を通達 break; - +#if 0 // I2C基本操作 - case CAMERA_PXI_COMMAND_WRITE_REGISTERS: // IN: addr, data... OUT: TRUE/FALSE - if (cameraWork.total <= 1) + case CAMERA_PXI_COMMAND_WRITE_REGISTERS: // IN: camera, addr, data... OUT: TRUE/FALSE + if (cameraWork.total <= 2) { CameraReturnResult(cameraWork.command, CAMERA_PXI_RESULT_INVALID_PARAMETER); break; } - result = CAMERA_WriteRegisters(cameraWork.data[0], &cameraWork.data[1], (size_t)(cameraWork.total-1)); + result = CAMERA_WriteRegisters((CameraSelect)cameraWork.data[0], cameraWork.data[1], &cameraWork.data[2], (size_t)(cameraWork.total-2)); CameraReturnResult(cameraWork.command, result ? CAMERA_PXI_RESULT_SUCCESS_TRUE : CAMERA_PXI_RESULT_SUCCESS_FALSE); // ARM9に処理の成功を通達 break; - case CAMERA_PXI_COMMAND_READ_REGISTERS: // IN: addr, size OUT: TRUE/FALSE, data... + case CAMERA_PXI_COMMAND_READ_REGISTERS: // IN: camera, addr, size OUT: TRUE/FALSE, data... CAMERA_PXI_SIZE_CHECK(CAMERA_PXI_SIZE_READ_REGISTERS); - result = CAMERA_ReadRegisters(cameraWork.data[0], dataArray, cameraWork.data[1]); + result = CAMERA_ReadRegisters((CameraSelect)cameraWork.data[0], cameraWork.data[1], dataArray, cameraWork.data[2]); if (result) { - CameraReturnResultEx(cameraWork.command, CAMERA_PXI_RESULT_SUCCESS_TRUE, cameraWork.data[1], dataArray); + CameraReturnResultEx(cameraWork.command, CAMERA_PXI_RESULT_SUCCESS_TRUE, cameraWork.data[2], dataArray); } else { @@ -287,67 +295,68 @@ static void CameraThread(void *arg) case CAMERA_PXI_COMMAND_SET_PARAMS: CAMERA_PXI_SIZE_CHECK(CAMERA_PXI_SIZE_SET_PARAMS); - result = CAMERA_SetParams(cameraWork.data[0], cameraWork.data[1], cameraWork.data[2]); + result = CAMERA_SetParams((CameraSelect)cameraWork.data[0], cameraWork.data[1], cameraWork.data[2], cameraWork.data[3]); CameraReturnResult(cameraWork.command, result ? CAMERA_PXI_RESULT_SUCCESS_TRUE : CAMERA_PXI_RESULT_SUCCESS_FALSE); // ARM9に処理の成功を通達 break; case CAMERA_PXI_COMMAND_SET_FLAGS: CAMERA_PXI_SIZE_CHECK(CAMERA_PXI_SIZE_SET_FLAGS); - result = CAMERA_SetFlags(cameraWork.data[0], cameraWork.data[1]); + result = CAMERA_SetFlags((CameraSelect)cameraWork.data[0], cameraWork.data[1], cameraWork.data[2]); CameraReturnResult(cameraWork.command, result ? CAMERA_PXI_RESULT_SUCCESS_TRUE : CAMERA_PXI_RESULT_SUCCESS_FALSE); // ARM9に処理の成功を通達 break; case CAMERA_PXI_COMMAND_CLEAR_FLAGS: CAMERA_PXI_SIZE_CHECK(CAMERA_PXI_SIZE_CLEAR_FLAGS); - result = CAMERA_ClearFlags(cameraWork.data[0], cameraWork.data[1]); + result = CAMERA_ClearFlags((CameraSelect)cameraWork.data[0], cameraWork.data[1], cameraWork.data[2]); CameraReturnResult(cameraWork.command, result ? CAMERA_PXI_RESULT_SUCCESS_TRUE : CAMERA_PXI_RESULT_SUCCESS_FALSE); // ARM9に処理の成功を通達 break; - +#endif case CAMERA_PXI_COMMAND_I2C_INIT: CAMERA_PXI_SIZE_CHECK(CAMERA_PXI_SIZE_I2C_INIT); - result = CAMERA_I2CInit(); + result = CAMERA_I2CInit((CameraSelect)cameraWork.data[0]); CameraReturnResult(cameraWork.command, result ? CAMERA_PXI_RESULT_SUCCESS_TRUE : CAMERA_PXI_RESULT_SUCCESS_FALSE); // ARM9に処理の成功を通達 break; - +#if 0 case CAMERA_PXI_COMMAND_I2C_PRESET: CAMERA_PXI_SIZE_CHECK(CAMERA_PXI_SIZE_I2C_PRESET); - result = CAMERA_I2CPreset((CameraPreset)cameraWork.data[0]); + result = CAMERA_I2CPreset((CameraSelect)cameraWork.data[0], (CameraPreset)cameraWork.data[1]); CameraReturnResult(cameraWork.command, result ? CAMERA_PXI_RESULT_SUCCESS_TRUE : CAMERA_PXI_RESULT_SUCCESS_FALSE); // ARM9に処理の成功を通達 break; - +#endif case CAMERA_PXI_COMMAND_I2C_PRE_SLEEP: CAMERA_PXI_SIZE_CHECK(CAMERA_PXI_SIZE_I2C_PRE_SLEEP); - result = CAMERA_I2CPreSleep(); + result = CAMERA_I2CPreSleep(cameraWork.camera); CameraReturnResult(cameraWork.command, result ? CAMERA_PXI_RESULT_SUCCESS_TRUE : CAMERA_PXI_RESULT_SUCCESS_FALSE); // ARM9に処理の成功を通達 break; case CAMERA_PXI_COMMAND_I2C_POST_SLEEP: CAMERA_PXI_SIZE_CHECK(CAMERA_PXI_SIZE_I2C_POST_SLEEP); - result = CAMERA_I2CPostSleep(); + result = CAMERA_I2CPostSleep(cameraWork.camera); CameraReturnResult(cameraWork.command, result ? CAMERA_PXI_RESULT_SUCCESS_TRUE : CAMERA_PXI_RESULT_SUCCESS_FALSE); // ARM9に処理の成功を通達 break; - +#if 0 case CAMERA_PXI_COMMAND_I2C_SET_CROPPING: CAMERA_PXI_SIZE_CHECK(CAMERA_PXI_SIZE_I2C_SET_CROPPING); - CAMERA_UNPACK_U16(&data16a, &cameraWork.data[0]); - CAMERA_UNPACK_U16(&data16b, &cameraWork.data[2]); - CAMERA_UNPACK_U16(&data16c, &cameraWork.data[4]); - CAMERA_UNPACK_U16(&data16d, &cameraWork.data[6]); - result = CAMERA_I2CSetCropping(data16a, data16b, data16c, data16d); + CAMERA_UNPACK_U16(&data16a, &cameraWork.data[1]); + CAMERA_UNPACK_U16(&data16b, &cameraWork.data[3]); + CAMERA_UNPACK_U16(&data16c, &cameraWork.data[5]); + CAMERA_UNPACK_U16(&data16d, &cameraWork.data[7]); + result = CAMERA_I2CSetCropping((CameraSelect)cameraWork.data[0], data16a, data16b, data16c, data16d); CameraReturnResult(cameraWork.command, result ? CAMERA_PXI_RESULT_SUCCESS_TRUE : CAMERA_PXI_RESULT_SUCCESS_FALSE); // ARM9に処理の成功を通達 break; case CAMERA_PXI_COMMAND_I2C_PAUSE: CAMERA_PXI_SIZE_CHECK(CAMERA_PXI_SIZE_I2C_PAUSE); - result = CAMERA_I2CPause(); + result = CAMERA_I2CPause(cameraWork.camera); CameraReturnResult(cameraWork.command, result ? CAMERA_PXI_RESULT_SUCCESS_TRUE : CAMERA_PXI_RESULT_SUCCESS_FALSE); // ARM9に処理の成功を通達 break; case CAMERA_PXI_COMMAND_I2C_RESUME: CAMERA_PXI_SIZE_CHECK(CAMERA_PXI_SIZE_I2C_RESUME); - result = CAMERA_I2CResume(); + result = CAMERA_I2CResume(cameraWork.camera); CameraReturnResult(cameraWork.command, result ? CAMERA_PXI_RESULT_SUCCESS_TRUE : CAMERA_PXI_RESULT_SUCCESS_FALSE); // ARM9に処理の成功を通達 break; +#endif // サポートしないコマンド default: diff --git a/build/libraries/camera/ARM7/camera_i2c.c b/build/libraries/camera/ARM7/camera_i2c.c deleted file mode 100644 index 2e03018..0000000 --- a/build/libraries/camera/ARM7/camera_i2c.c +++ /dev/null @@ -1,266 +0,0 @@ -/*---------------------------------------------------------------------------* - Project: TwlSDK - libraties - camera - File: camera_i2c.c - - Copyright 2006 Nintendo. All rights reserved. - - These coded instructions, statements, and computer programs contain - proprietary information of Nintendo of America Inc. and/or Nintendo - Company Ltd., and are protected by Federal copyright law. They may - not be disclosed to third parties or copied or duplicated in any form, - in whole or in part, without the prior written consent of Nintendo. - - $Log: $ - $NoKeywords: $ - *---------------------------------------------------------------------------*/ -#include -#include - -//#define USE_MULTIPLE_IO // use [Read|Write]Registers(); - -// for samsung 1/10 - -extern BOOL CAMERAi_I2CPreset_A3AFX_EVT2_20fps_16M_PLLoff_hVGA( void ); -extern BOOL CAMERAi_I2CPreset_A3AFX_EVT2_30fps_16M_QVGA( void ); -extern BOOL CAMERAi_I2CPreset_A3AFX_EVT2_20fps_16M( void ); -extern BOOL CAMERAi_I2CPreset_320x240_noPLL_20fps( void ); -extern BOOL CAMERAi_I2CPreset_320x240_PLL_30fps( void ); -extern BOOL CAMERAi_I2CPreset_A3AFX_EVT3_30fps_Scaledown_16_7M_50Hz( void ); -extern BOOL CAMERAi_I2CPreset_A3AFX_EVT3_30fps_Subsampling_16_7M_50Hz( void ); - -typedef BOOL (*CameraI2CPresetFunc)(void); - -static CameraI2CPresetFunc gs_preset[] = { -// CAMERAi_I2CPreset_A3AFX_EVT2_20fps_16M_PLLoff_hVGA, -// CAMERAi_I2CPreset_A3AFX_EVT2_30fps_16M_QVGA, - CAMERAi_I2CPreset_A3AFX_EVT2_20fps_16M, -// CAMERAi_I2CPreset_320x240_noPLL_20fps, -// CAMERAi_I2CPreset_320x240_PLL_30fps, - CAMERAi_I2CPreset_A3AFX_EVT3_30fps_Scaledown_16_7M_50Hz, - CAMERAi_I2CPreset_A3AFX_EVT3_30fps_Subsampling_16_7M_50Hz, -}; - -BOOL CAMERA_I2CPreset(CameraPreset preset) -{ - if (preset >= CAMERA_PRESET_MAX) { - return FALSE; - } - if (gs_preset[preset] == NULL) { - return FALSE; - } - (void)I2C_Lock(); - if (gs_preset[preset]() == FALSE) { - (void)I2C_Unlock(); - return FALSE; - } - (void)I2C_Unlock(); - return TRUE; -} - - -#define PAGE_ADDR 0xef - -#define MIRROR_MODE 0x02 //[6:7] only? -#define WRP_DOWN 0x04 -#define WCP_DOWN 0x06 - -BOOL CAMERA_I2CSetFlipMode(CameraFlipMode mode) -{ - - (void)I2C_Lock(); - - switch (mode) - { - case CAMERA_FLIPMODE_NONE: - if (CAMERAi_WriteRegister(PAGE_ADDR, 0x02) == FALSE || - CAMERAi_WriteRegister(MIRROR_MODE, 0x00) == FALSE || - CAMERAi_WriteRegister(WRP_DOWN, 0x00) == FALSE || - CAMERAi_WriteRegister(WCP_DOWN, 0x00) == FALSE) { - goto error; - } - break; - case CAMERA_FLIPMODE_HORIZONTAL: - if (CAMERAi_WriteRegister(PAGE_ADDR, 0x02) == FALSE || - CAMERAi_WriteRegister(MIRROR_MODE, 0x40) == FALSE || - CAMERAi_WriteRegister(WRP_DOWN, 0x00) == FALSE || - CAMERAi_WriteRegister(WCP_DOWN, 0x01) == FALSE) { - goto error; - } - break; - case CAMERA_FLIPMODE_VERTICAL: - if (CAMERAi_WriteRegister(PAGE_ADDR, 0x02) == FALSE || - CAMERAi_WriteRegister(MIRROR_MODE, 0x80) == FALSE || - CAMERAi_WriteRegister(WRP_DOWN, 0x01) == FALSE || - CAMERAi_WriteRegister(WCP_DOWN, 0x00) == FALSE) { - goto error; - } - break; - case CAMERA_FLIPMODE_HORIZONTAL_VERTICAL: - if (CAMERAi_WriteRegister(PAGE_ADDR, 0x02) == FALSE || - CAMERAi_WriteRegister(MIRROR_MODE, 0xC0) == FALSE || - CAMERAi_WriteRegister(WRP_DOWN, 0x01) == FALSE || - CAMERAi_WriteRegister(WCP_DOWN, 0x01) == FALSE) { - goto error; - } - break; - default: - goto error; - } - (void)I2C_Unlock(); - return TRUE; -error: - (void)I2C_Unlock(); - return FALSE; -} - -#define NEVAGIVE_EFFECT_MODE 0xD3 -#define SEPIA_EFFECT_MODE 0xD4 -#define SEPIA_EFFECT_CB 0xD5 -#define SEPIA_EFFECT_CR 0xD6 - -BOOL CAMERA_I2CSetSpecialMode(CameraSpecialMode mode) -{ - - (void)I2C_Lock(); - - switch (mode) - { - case CAMERA_SPECIALMODE_NONE: - if (CAMERAi_WriteRegister(PAGE_ADDR, 0x00) == FALSE || - CAMERAi_WriteRegister(NEVAGIVE_EFFECT_MODE, 0x00) == FALSE || - CAMERAi_WriteRegister(SEPIA_EFFECT_MODE, 0x00) == FALSE || - CAMERAi_WriteRegister(SEPIA_EFFECT_CB, 0x2C) == FALSE || - CAMERAi_WriteRegister(SEPIA_EFFECT_CR, 0x81) == FALSE) { - goto error; - } - break; - case CAMERA_SPECIALMODE_NEVATIVE: - if (CAMERAi_WriteRegister(PAGE_ADDR, 0x00) == FALSE || - CAMERAi_WriteRegister(NEVAGIVE_EFFECT_MODE, 0x01) == FALSE || - CAMERAi_WriteRegister(SEPIA_EFFECT_MODE, 0x00) == FALSE || - CAMERAi_WriteRegister(SEPIA_EFFECT_CB, 0x2C) == FALSE || - CAMERAi_WriteRegister(SEPIA_EFFECT_CR, 0x81) == FALSE) { - goto error; - } - break; - case CAMERA_SPECIALMODE_SEPIA: - if (CAMERAi_WriteRegister(PAGE_ADDR, 0x00) == FALSE || - CAMERAi_WriteRegister(NEVAGIVE_EFFECT_MODE, 0x00) == FALSE || - CAMERAi_WriteRegister(SEPIA_EFFECT_MODE, 0x03) == FALSE || - CAMERAi_WriteRegister(SEPIA_EFFECT_CB, 0x2C) == FALSE || - CAMERAi_WriteRegister(SEPIA_EFFECT_CR, 0x81) == FALSE) { - goto error; - } - break; - //case CAMERA_SPECIALMODE_AQUA: - case CAMERA_SPECIALMODE_BLUISH: - if (CAMERAi_WriteRegister(PAGE_ADDR, 0x00) == FALSE || - CAMERAi_WriteRegister(NEVAGIVE_EFFECT_MODE, 0x00) == FALSE || - CAMERAi_WriteRegister(SEPIA_EFFECT_MODE, 0x03) == FALSE || - CAMERAi_WriteRegister(SEPIA_EFFECT_CB, 0xAC) == FALSE || - CAMERAi_WriteRegister(SEPIA_EFFECT_CR, 0x81) == FALSE) { - goto error; - } - break; - case CAMERA_SPECIALMODE_REDDISH: - if (CAMERAi_WriteRegister(PAGE_ADDR, 0x00) == FALSE || - CAMERAi_WriteRegister(NEVAGIVE_EFFECT_MODE, 0x00) == FALSE || - CAMERAi_WriteRegister(SEPIA_EFFECT_MODE, 0x03) == FALSE || - CAMERAi_WriteRegister(SEPIA_EFFECT_CB, 0xAC) == FALSE || - CAMERAi_WriteRegister(SEPIA_EFFECT_CR, 0xC1) == FALSE) { - goto error; - } - break; - case CAMERA_SPECIALMODE_GREENISH: - if (CAMERAi_WriteRegister(PAGE_ADDR, 0x00) == FALSE || - CAMERAi_WriteRegister(NEVAGIVE_EFFECT_MODE, 0x00) == FALSE || - CAMERAi_WriteRegister(SEPIA_EFFECT_MODE, 0x03) == FALSE || - CAMERAi_WriteRegister(SEPIA_EFFECT_CB, 0xAC) == FALSE || - CAMERAi_WriteRegister(SEPIA_EFFECT_CR, 0x41) == FALSE) { - goto error; - } - break; - default: - goto error; - } - (void)I2C_Unlock(); - return TRUE; -error: - (void)I2C_Unlock(); - return FALSE; -} - -#define DEST_ADDR 0x7F -#define CAPT_ADDR 0xC4 -BOOL CAMERA_I2CSetCroppingParams(u16 width, u16 height) -{ -#ifdef USE_MULTIPLE_IO - u8 data[4]; -#endif - if (width > 640 || height > 480) { - return FALSE; - } - (void)I2C_Lock(); - if (CAMERAi_WriteRegister(PAGE_ADDR, 0x00) == FALSE) { - (void)I2C_Unlock(); - return FALSE; - } - // set destination registers -#ifdef USE_MULTIPLE_IO - data[0] = (height + 0x10) >> 8; - data[1] = (height + 0x10) & 0xFF; - data[2] = (width + 0x10) >> 8; - data[3] = (width + 0x10) & 0xFF; - if (CAMERAi_WriteRegisters(DEST_ADDR, data, 4) == FALSE) { -#else - if (CAMERAi_WriteRegister(DEST_ADDR, (u8)((height + 0x10) >> 8)) == FALSE || - CAMERAi_WriteRegister(DEST_ADDR+1, (u8)((height + 0x10) & 0xFF)) ==FALSE || - CAMERAi_WriteRegister(DEST_ADDR+2, (u8)((width + 0x10) >> 8)) == FALSE || - CAMERAi_WriteRegister(DEST_ADDR+3, (u8)((width + 0x10) & 0xFF)) == FALSE) { -#endif - (void)I2C_Unlock(); - return FALSE; - } - // set capture registers -#ifdef USE_MULTIPLE_IO - data[0] = height >> 8; - data[1] = height & 0xFF; - data[2] = width >> 8; - data[3] = width & 0xFF; - if (CAMERAi_WriteRegisters(CAPT_ADDR, data, 4) == FALSE) { -#else - if (CAMERAi_WriteRegister(CAPT_ADDR, (u8)(height >> 8)) == FALSE || - CAMERAi_WriteRegister(CAPT_ADDR+1, (u8)(height & 0xFF)) ==FALSE || - CAMERAi_WriteRegister(CAPT_ADDR+2, (u8)(width >> 8)) == FALSE || - CAMERAi_WriteRegister(CAPT_ADDR+3, (u8)(width & 0xFF)) == FALSE) { -#endif - (void)I2C_Unlock(); - return FALSE; - } - (void)I2C_Unlock(); - return TRUE; -} - -BOOL CAMERA_I2CGetCroppingParams(u16 *pWidth, u16 *pHeight) -{ - u8 data[4]; - (void)I2C_Lock(); - if (CAMERAi_WriteRegister(PAGE_ADDR, 0x00) == FALSE) { - (void)I2C_Unlock(); - return FALSE; - } - data[0] = CAMERAi_ReadRegister(CAPT_ADDR); - data[1] = CAMERAi_ReadRegister(CAPT_ADDR+1); - data[2] = CAMERAi_ReadRegister(CAPT_ADDR+2); - data[3] = CAMERAi_ReadRegister(CAPT_ADDR+3); - - (void)I2C_Unlock(); - - if (pWidth) { - *pWidth = (u16)(data[3] | (data[2] << 8)); - } - if (pHeight) { - *pHeight = (u16)(data[1] | (data[0] << 8)); - } - return TRUE; -} diff --git a/build/libraries/camera/ARM7/camera_i2c_common.c b/build/libraries/camera/ARM7/camera_i2c_common.c new file mode 100644 index 0000000..927e8a9 --- /dev/null +++ b/build/libraries/camera/ARM7/camera_i2c_common.c @@ -0,0 +1,176 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - libraties - camera + File: camera_i2c_common.c + + Copyright 2006 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Log: $ + $NoKeywords: $ + *---------------------------------------------------------------------------*/ +#include +#include + +typedef enum +{ + CAMERA_TYPE_MICRON, + CAMERA_TYPE_SHARP, + + CAMERA_TYPE_UNKNOWN +} +CAMERAType; + +static CAMERAType cameraType = CAMERA_TYPE_MICRON; + +#if 0 + CAMERA_I2CInit()だけがカメラの種類を入れ替える機能を有する +#endif + +/*---------------------------------------------------------------------------* + Name: CAMERA_I2CInit + + Description: initialize CAMERA + + Arguments: camera : one of CameraSelect + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +BOOL CAMERA_I2CInit(CameraSelect camera) +{ + BOOL result = FALSE; + (void)I2C_Lock(); + if (cameraType == CAMERA_TYPE_MICRON) + { + result = CAMERA_M_I2CInit(camera); + if (result == FALSE) + { + cameraType = CAMERA_TYPE_SHARP; + } + } + + if (cameraType == CAMERA_TYPE_SHARP) + { + result = CAMERA_S_I2CInit(camera); + if (result == FALSE) + { + cameraType = CAMERA_TYPE_MICRON; //rotation CAMERA_TYPE_UNKNOWN; + } + } + (void)I2C_Unlock(); + return result; +} + +/*---------------------------------------------------------------------------* + Name: CAMERA_I2CStandby + + Description: standby or resume CAMERA + + Arguments: camera : one of CameraSelect + standby : TRUE if goto standby mode + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +BOOL CAMERA_I2CStandby(CameraSelect camera, BOOL standby) +{ + BOOL result = FALSE; + (void)I2C_Lock(); + switch (camera) + { + case CAMERA_TYPE_MICRON: + CAMERA_M_I2CStandby(camera, standby); + break; + case CAMERA_TYPE_SHARP: + CAMERA_S_I2CStandby(camera, standby); + break; + } + (void)I2C_Unlock(); + return result; +} + +/*---------------------------------------------------------------------------* + Name: CAMERA_I2CResize + + Description: resize CAMERA + + Arguments: camera : one of CameraSelect + width : width of output image + height : height of output image + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +BOOL CAMERA_I2CResize(CameraSelect camera, u16 width, u16 height) +{ + BOOL result = FALSE; + (void)I2C_Lock(); + switch (camera) + { + case CAMERA_TYPE_MICRON: + CAMERA_M_I2CResize(camera, width, height); + break; + case CAMERA_TYPE_SHARP: + CAMERA_S_I2CResize(camera, width, height); + break; + } + (void)I2C_Unlock(); + return result; +} + +/*---------------------------------------------------------------------------* + Name: CAMERA_I2CPreSleep + + Description: preset CAMERA registers + + Arguments: camera : one of CameraSelect + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +BOOL CAMERA_I2CPreSleep(CameraSelect camera) +{ + BOOL result = FALSE; + (void)I2C_Lock(); + switch (camera) + { + case CAMERA_TYPE_MICRON: + CAMERA_M_I2CPreSleep(camera); + break; + case CAMERA_TYPE_SHARP: + CAMERA_M_I2CPreSleep(camera); + break; + } + (void)I2C_Unlock(); + return result; +} + +/*---------------------------------------------------------------------------* + Name: CAMERA_I2CPostSleep + + Description: preset CAMERA registers + + Arguments: camera : one of CameraSelect + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +BOOL CAMERA_I2CPostSleep(CameraSelect camera) +{ + BOOL result = FALSE; + (void)I2C_Lock(); + switch (camera) + { + case CAMERA_TYPE_MICRON: + CAMERA_M_I2CPostSleep(camera); + break; + case CAMERA_TYPE_SHARP: + CAMERA_M_I2CPostSleep(camera); + break; + } + (void)I2C_Unlock(); + return result; +} + + + diff --git a/build/libraries/camera/ARM7/camera_i2c_micron.c b/build/libraries/camera/ARM7/camera_i2c_micron.c new file mode 100644 index 0000000..0baa602 --- /dev/null +++ b/build/libraries/camera/ARM7/camera_i2c_micron.c @@ -0,0 +1,144 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - libraties - camera + File: camera_i2c_micron.c + + Copyright 2006 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Log: $ + $NoKeywords: $ + *---------------------------------------------------------------------------*/ +#include +#include + +//#define USE_MULTIPLE_IO // use [Read|Write]Registers(); + +// for micron +BOOL CAMERAi_M_Default_Registers( CameraSelect camera ); +BOOL CAMERAi_M_Initialize_Camera( CameraSelect camera ); +BOOL CAMERAi_M_Image_Setting_ExtClk_6_75MHz_Op_Pix_27_5MHz_15fps( CameraSelect camera ); +BOOL CAMERAi_M_Image_Setting_ExtClk_16_76MHz_Op_Pix_27_5MHz_15fps( CameraSelect camera ); +BOOL CAMERAi_M_Viewfinder_ON( CameraSelect camera ); +BOOL CAMERAi_M_Viewfinder_OFF( CameraSelect camera ); +BOOL CAMERAi_M_Video_Capture_ON( CameraSelect camera ); +BOOL CAMERAi_M_Video_Capture_OFF( CameraSelect camera ); +BOOL CAMERAi_M_Lens_Calibration_Setup( CameraSelect camera ); +BOOL CAMERAi_M_Lens_Calibration_Exit( CameraSelect camera ); +BOOL CAMERAi_M_Fixed_15fps( CameraSelect camera ); +BOOL CAMERAi_M_Refresh( CameraSelect camera ); +BOOL CAMERAi_M_Auto_Exposure( CameraSelect camera ); +BOOL CAMERAi_M_Gamma_Correction( CameraSelect camera ); +BOOL CAMERAi_M_Auto_White_Balance( CameraSelect camera ); +BOOL CAMERAi_M_Lens_Correction( CameraSelect camera ); +BOOL CAMERAi_M_Image_Size_VGA( CameraSelect camera ); +BOOL CAMERAi_M_Image_Size_QVGA( CameraSelect camera ); +BOOL CAMERAi_M_Image_Size_CIF( CameraSelect camera ); +BOOL CAMERAi_M_Image_Size_QCIF( CameraSelect camera ); +BOOL CAMERAi_M_Effect_Off( CameraSelect camera ); +BOOL CAMERAi_M_Effect_Mono( CameraSelect camera ); +BOOL CAMERAi_M_Effect_Sepia( CameraSelect camera ); +BOOL CAMERAi_M_Manual_WB_To_Auto_WB( CameraSelect camera ); +BOOL CAMERAi_M_Manual_White_Balance_P1( CameraSelect camera ); +BOOL CAMERAi_M_Manual_White_Balance_P2( CameraSelect camera ); +BOOL CAMERAi_M_Manual_White_Balance_P3( CameraSelect camera ); +BOOL CAMERAi_M_Manual_White_Balance_P4( CameraSelect camera ); +BOOL CAMERAi_M_Manual_White_Balance_P5( CameraSelect camera ); +BOOL CAMERAi_M_Manual_White_Balance_P6( CameraSelect camera ); +BOOL CAMERAi_M_Manual_White_Balance_P7( CameraSelect camera ); +BOOL CAMERAi_M_Manual_White_Balance_P8( CameraSelect camera ); +BOOL CAMERAi_M_Sharpness_0( CameraSelect camera ); + +/*---------------------------------------------------------------------------* + Name: CAMERA_M_I2CInit + + Description: initialize CAMERA + + Arguments: camera : one of CameraSelect + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +BOOL CAMERA_M_I2CInit(CameraSelect camera) +{ + return CAMERAi_M_Default_Registers(camera); +} + +/*---------------------------------------------------------------------------* + Name: CAMERA_M_I2CStandby + + Description: standby or resume CAMERA + + Arguments: camera : one of CameraSelect + standby : TRUE if goto standby mode + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +BOOL CAMERA_M_I2CStandby(CameraSelect camera, BOOL standby) +{ + if (standby) + { + } + else + { + } + (void)camera; + return TRUE; +} + +/*---------------------------------------------------------------------------* + Name: CAMERA_M_I2CResize + + Description: resize CAMERA + + Arguments: camera : one of CameraSelect + width : width of output image + height : height of output image + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +BOOL CAMERA_M_I2CResize(CameraSelect camera, u16 width, u16 height) +{ + return CAMERAi_M_WriteRegister(camera, 0x98c, 0x2703) // width (A) + && CAMERAi_M_WriteRegister(camera, 0x990, width) + && CAMERAi_M_WriteRegister(camera, 0x98c, 0x2705) // height (A) + && CAMERAi_M_WriteRegister(camera, 0x990, height) + && CAMERAi_M_WriteRegister(camera, 0x98c, 0x2707) // width (B) + && CAMERAi_M_WriteRegister(camera, 0x990, width) + && CAMERAi_M_WriteRegister(camera, 0x98c, 0x2709) // height (B) + && CAMERAi_M_WriteRegister(camera, 0x990, height); + // anyone else??? +} + +/*---------------------------------------------------------------------------* + Name: CAMERA_M_I2CPreSleep + + Description: preset CAMERA registers + + Arguments: camera : one of CameraSelect + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +BOOL CAMERA_M_I2CPreSleep(CameraSelect camera) +{ + (void)camera; + return FALSE; +} + +/*---------------------------------------------------------------------------* + Name: CAMERA_M_I2CPostSleep + + Description: preset CAMERA registers + + Arguments: camera : one of CameraSelect + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +BOOL CAMERA_M_I2CPostSleep(CameraSelect camera) +{ + (void)camera; + return FALSE; +} diff --git a/build/libraries/camera/ARM7/camera_i2c_samsung.c b/build/libraries/camera/ARM7/camera_i2c_samsung.c new file mode 100644 index 0000000..3c17b19 --- /dev/null +++ b/build/libraries/camera/ARM7/camera_i2c_samsung.c @@ -0,0 +1,264 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - libraties - camera + File: camera_i2c.c + + Copyright 2006 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Log: $ + $NoKeywords: $ + *---------------------------------------------------------------------------*/ +#include +#include + +//#define USE_MULTIPLE_IO // use [Read|Write]Registers(); + +// for samsung 1/10 + +extern BOOL CAMERAi_I2CPreset_A3AFX_EVT2_20fps_16M_PLLoff_hVGA( CameraSelect camera ); +extern BOOL CAMERAi_I2CPreset_A3AFX_EVT2_30fps_16M_QVGA( CameraSelect camera ); +extern BOOL CAMERAi_I2CPreset_A3AFX_EVT2_20fps_16M( CameraSelect camera ); +extern BOOL CAMERAi_I2CPreset_320x240_noPLL_20fps( CameraSelect camera ); +extern BOOL CAMERAi_I2CPreset_320x240_PLL_30fps( CameraSelect camera ); +extern BOOL CAMERAi_I2CPreset_A3AFX_EVT3_30fps_Scaledown_16_7M_50Hz( CameraSelect camera ); +extern BOOL CAMERAi_I2CPreset_A3AFX_EVT3_30fps_Subsampling_16_7M_50Hz( CameraSelect camera ); + +typedef BOOL (*CameraI2CPresetFunc)( CameraSelect camera ); + +static CameraI2CPresetFunc gs_preset[] = { +// CAMERAi_I2CPreset_A3AFX_EVT2_20fps_16M_PLLoff_hVGA, +// CAMERAi_I2CPreset_A3AFX_EVT2_30fps_16M_QVGA, + CAMERAi_I2CPreset_A3AFX_EVT2_20fps_16M, +// CAMERAi_I2CPreset_320x240_noPLL_20fps, +// CAMERAi_I2CPreset_320x240_PLL_30fps, + CAMERAi_I2CPreset_A3AFX_EVT3_30fps_Scaledown_16_7M_50Hz, + CAMERAi_I2CPreset_A3AFX_EVT3_30fps_Subsampling_16_7M_50Hz, +}; + +BOOL CAMERA_I2CPreset(CameraSelect camera, CameraPreset preset) +{ + BOOL result = FALSE; + if (preset >= CAMERA_PRESET_MAX) { + return result; + } + if (gs_preset[preset] == NULL) { + return result; + } + (void)I2C_Lock(); + result = gs_preset[preset](camera); + (void)I2C_Unlock(); + return result; +} + + +#define PAGE_ADDR 0xef + +#define MIRROR_MODE 0x02 //[6:7] only? +#define WRP_DOWN 0x04 +#define WCP_DOWN 0x06 + +BOOL CAMERA_I2CSetFlipMode(CameraSelect camera, CameraFlipMode mode) +{ + + (void)I2C_Lock(); + + switch (mode) + { + case CAMERA_FLIPMODE_NONE: + if (CAMERAi_WriteRegister(camera, PAGE_ADDR, 0x02) == FALSE || + CAMERAi_WriteRegister(camera, MIRROR_MODE, 0x00) == FALSE || + CAMERAi_WriteRegister(camera, WRP_DOWN, 0x00) == FALSE || + CAMERAi_WriteRegister(camera, WCP_DOWN, 0x00) == FALSE) { + goto error; + } + break; + case CAMERA_FLIPMODE_HORIZONTAL: + if (CAMERAi_WriteRegister(camera, PAGE_ADDR, 0x02) == FALSE || + CAMERAi_WriteRegister(camera, MIRROR_MODE, 0x40) == FALSE || + CAMERAi_WriteRegister(camera, WRP_DOWN, 0x00) == FALSE || + CAMERAi_WriteRegister(camera, WCP_DOWN, 0x01) == FALSE) { + goto error; + } + break; + case CAMERA_FLIPMODE_VERTICAL: + if (CAMERAi_WriteRegister(camera, PAGE_ADDR, 0x02) == FALSE || + CAMERAi_WriteRegister(camera, MIRROR_MODE, 0x80) == FALSE || + CAMERAi_WriteRegister(camera, WRP_DOWN, 0x01) == FALSE || + CAMERAi_WriteRegister(camera, WCP_DOWN, 0x00) == FALSE) { + goto error; + } + break; + case CAMERA_FLIPMODE_HORIZONTAL_VERTICAL: + if (CAMERAi_WriteRegister(camera, PAGE_ADDR, 0x02) == FALSE || + CAMERAi_WriteRegister(camera, MIRROR_MODE, 0xC0) == FALSE || + CAMERAi_WriteRegister(camera, WRP_DOWN, 0x01) == FALSE || + CAMERAi_WriteRegister(camera, WCP_DOWN, 0x01) == FALSE) { + goto error; + } + break; + default: + goto error; + } + (void)I2C_Unlock(); + return TRUE; +error: + (void)I2C_Unlock(); + return FALSE; +} + +#define NEVAGIVE_EFFECT_MODE 0xD3 +#define SEPIA_EFFECT_MODE 0xD4 +#define SEPIA_EFFECT_CB 0xD5 +#define SEPIA_EFFECT_CR 0xD6 + +BOOL CAMERA_I2CSetSpecialMode(CameraSelect camera, CameraSpecialMode mode) +{ + + (void)I2C_Lock(); + + switch (mode) + { + case CAMERA_SPECIALMODE_NONE: + if (CAMERAi_WriteRegister(camera, PAGE_ADDR, 0x00) == FALSE || + CAMERAi_WriteRegister(camera, NEVAGIVE_EFFECT_MODE, 0x00) == FALSE || + CAMERAi_WriteRegister(camera, SEPIA_EFFECT_MODE, 0x00) == FALSE || + CAMERAi_WriteRegister(camera, SEPIA_EFFECT_CB, 0x2C) == FALSE || + CAMERAi_WriteRegister(camera, SEPIA_EFFECT_CR, 0x81) == FALSE) { + goto error; + } + break; + case CAMERA_SPECIALMODE_NEVATIVE: + if (CAMERAi_WriteRegister(camera, PAGE_ADDR, 0x00) == FALSE || + CAMERAi_WriteRegister(camera, NEVAGIVE_EFFECT_MODE, 0x01) == FALSE || + CAMERAi_WriteRegister(camera, SEPIA_EFFECT_MODE, 0x00) == FALSE || + CAMERAi_WriteRegister(camera, SEPIA_EFFECT_CB, 0x2C) == FALSE || + CAMERAi_WriteRegister(camera, SEPIA_EFFECT_CR, 0x81) == FALSE) { + goto error; + } + break; + case CAMERA_SPECIALMODE_SEPIA: + if (CAMERAi_WriteRegister(camera, PAGE_ADDR, 0x00) == FALSE || + CAMERAi_WriteRegister(camera, NEVAGIVE_EFFECT_MODE, 0x00) == FALSE || + CAMERAi_WriteRegister(camera, SEPIA_EFFECT_MODE, 0x03) == FALSE || + CAMERAi_WriteRegister(camera, SEPIA_EFFECT_CB, 0x2C) == FALSE || + CAMERAi_WriteRegister(camera, SEPIA_EFFECT_CR, 0x81) == FALSE) { + goto error; + } + break; + //case CAMERA_SPECIALMODE_AQUA: + case CAMERA_SPECIALMODE_BLUISH: + if (CAMERAi_WriteRegister(camera, PAGE_ADDR, 0x00) == FALSE || + CAMERAi_WriteRegister(camera, NEVAGIVE_EFFECT_MODE, 0x00) == FALSE || + CAMERAi_WriteRegister(camera, SEPIA_EFFECT_MODE, 0x03) == FALSE || + CAMERAi_WriteRegister(camera, SEPIA_EFFECT_CB, 0xAC) == FALSE || + CAMERAi_WriteRegister(camera, SEPIA_EFFECT_CR, 0x81) == FALSE) { + goto error; + } + break; + case CAMERA_SPECIALMODE_REDDISH: + if (CAMERAi_WriteRegister(camera, PAGE_ADDR, 0x00) == FALSE || + CAMERAi_WriteRegister(camera, NEVAGIVE_EFFECT_MODE, 0x00) == FALSE || + CAMERAi_WriteRegister(camera, SEPIA_EFFECT_MODE, 0x03) == FALSE || + CAMERAi_WriteRegister(camera, SEPIA_EFFECT_CB, 0xAC) == FALSE || + CAMERAi_WriteRegister(camera, SEPIA_EFFECT_CR, 0xC1) == FALSE) { + goto error; + } + break; + case CAMERA_SPECIALMODE_GREENISH: + if (CAMERAi_WriteRegister(camera, PAGE_ADDR, 0x00) == FALSE || + CAMERAi_WriteRegister(camera, NEVAGIVE_EFFECT_MODE, 0x00) == FALSE || + CAMERAi_WriteRegister(camera, SEPIA_EFFECT_MODE, 0x03) == FALSE || + CAMERAi_WriteRegister(camera, SEPIA_EFFECT_CB, 0xAC) == FALSE || + CAMERAi_WriteRegister(camera, SEPIA_EFFECT_CR, 0x41) == FALSE) { + goto error; + } + break; + default: + goto error; + } + (void)I2C_Unlock(); + return TRUE; +error: + (void)I2C_Unlock(); + return FALSE; +} + +#define DEST_ADDR 0x7F +#define CAPT_ADDR 0xC4 +BOOL CAMERA_I2CSetCroppingParams(CameraSelect camera, u16 width, u16 height) +{ +#ifdef USE_MULTIPLE_IO + u8 data[4]; +#endif + if (width > 640 || height > 480) { + return FALSE; + } + (void)I2C_Lock(); + if (CAMERAi_WriteRegister(camera, PAGE_ADDR, 0x00) == FALSE) { + (void)I2C_Unlock(); + return FALSE; + } + // set destination registers +#ifdef USE_MULTIPLE_IO + data[0] = (height + 0x10) >> 8; + data[1] = (height + 0x10) & 0xFF; + data[2] = (width + 0x10) >> 8; + data[3] = (width + 0x10) & 0xFF; + if (CAMERAi_WriteRegisters(camera, DEST_ADDR, data, 4) == FALSE) { +#else + if (CAMERAi_WriteRegister(camera, DEST_ADDR, (u8)((height + 0x10) >> 8)) == FALSE || + CAMERAi_WriteRegister(camera, DEST_ADDR+1, (u8)((height + 0x10) & 0xFF)) ==FALSE || + CAMERAi_WriteRegister(camera, DEST_ADDR+2, (u8)((width + 0x10) >> 8)) == FALSE || + CAMERAi_WriteRegister(camera, DEST_ADDR+3, (u8)((width + 0x10) & 0xFF)) == FALSE) { +#endif + (void)I2C_Unlock(); + return FALSE; + } + // set capture registers +#ifdef USE_MULTIPLE_IO + data[0] = height >> 8; + data[1] = height & 0xFF; + data[2] = width >> 8; + data[3] = width & 0xFF; + if (CAMERAi_WriteRegisters(camera, CAPT_ADDR, data, 4) == FALSE) { +#else + if (CAMERAi_WriteRegister(camera, CAPT_ADDR, (u8)(height >> 8)) == FALSE || + CAMERAi_WriteRegister(camera, CAPT_ADDR+1, (u8)(height & 0xFF)) ==FALSE || + CAMERAi_WriteRegister(camera, CAPT_ADDR+2, (u8)(width >> 8)) == FALSE || + CAMERAi_WriteRegister(camera, CAPT_ADDR+3, (u8)(width & 0xFF)) == FALSE) { +#endif + (void)I2C_Unlock(); + return FALSE; + } + (void)I2C_Unlock(); + return TRUE; +} + +BOOL CAMERA_I2CGetCroppingParams(CameraSelect camera, u16 *pWidth, u16 *pHeight) +{ + u8 data[4]; + (void)I2C_Lock(); + if (CAMERAi_WriteRegister(camera, PAGE_ADDR, 0x00) == FALSE) { + (void)I2C_Unlock(); + return FALSE; + } + data[0] = CAMERAi_ReadRegister(camera, CAPT_ADDR); + data[1] = CAMERAi_ReadRegister(camera, CAPT_ADDR+1); + data[2] = CAMERAi_ReadRegister(camera, CAPT_ADDR+2); + data[3] = CAMERAi_ReadRegister(camera, CAPT_ADDR+3); + + (void)I2C_Unlock(); + + if (pWidth) { + *pWidth = (u16)(data[3] | (data[2] << 8)); + } + if (pHeight) { + *pHeight = (u16)(data[1] | (data[0] << 8)); + } + return TRUE; +} diff --git a/build/libraries/camera/ARM7/camera_i2c_sharp.c b/build/libraries/camera/ARM7/camera_i2c_sharp.c new file mode 100644 index 0000000..bd8e4fc --- /dev/null +++ b/build/libraries/camera/ARM7/camera_i2c_sharp.c @@ -0,0 +1,107 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - libraties - camera + File: camera_i2c_sharp.c + + Copyright 2006 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Log: $ + $NoKeywords: $ + *---------------------------------------------------------------------------*/ +#include +#include + +//#define USE_MULTIPLE_IO // use [Read|Write]Registers(); + +// for sharp + +/*---------------------------------------------------------------------------* + Name: CAMERA_S_I2CInit + + Description: initialize CAMERA + + Arguments: camera : one of CameraSelect + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +BOOL CAMERA_S_I2CInit(CameraSelect camera) +{ + (void)camera; + return FALSE; +} + +/*---------------------------------------------------------------------------* + Name: CAMERA_S_I2CStandby + + Description: standby or resume CAMERA + + Arguments: camera : one of CameraSelect + standby : TRUE if goto standby mode + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +BOOL CAMERA_S_I2CStandby(CameraSelect camera, BOOL standby) +{ + if (standby) + { + } + else + { + } + (void)camera; + return FALSE; +} + +/*---------------------------------------------------------------------------* + Name: CAMERA_S_I2CResize + + Description: resize CAMERA + + Arguments: camera : one of CameraSelect + width : width of output image + height : height of output image + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +BOOL CAMERA_S_I2CResize(CameraSelect camera, u16 width, u16 height) +{ + (void)height; + (void)width; + (void)camera; + return FALSE; +} + +/*---------------------------------------------------------------------------* + Name: CAMERA_S_I2CPreSleep + + Description: preset CAMERA registers + + Arguments: camera : one of CameraSelect + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +BOOL CAMERA_S_I2CPreSleep(CameraSelect camera) +{ + (void)camera; + return FALSE; +} + +/*---------------------------------------------------------------------------* + Name: CAMERA_S_I2CPostSleep + + Description: preset CAMERA registers + + Arguments: camera : one of CameraSelect + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +BOOL CAMERA_S_I2CPostSleep(CameraSelect camera) +{ + (void)camera; + return FALSE; +} diff --git a/build/libraries/camera/ARM7/convert_micron.pl b/build/libraries/camera/ARM7/convert_micron.pl new file mode 100644 index 0000000..c10e3ca --- /dev/null +++ b/build/libraries/camera/ARM7/convert_micron.pl @@ -0,0 +1,210 @@ +#!/usr/bin/perl -- + +use strict; + +my $file_head_format =<<'EOF'; +/*---------------------------------------------------------------------------* + Project: TwlSDK - libraties - camera + File: %1$s + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Log: $ + $NoKeywords: $ + *---------------------------------------------------------------------------*/ +#include +#include + +//#define PRINT_DEBUG + +#ifdef PRINT_DEBUG +#include +#define DBG_PRINTF OS_TPrintf +#else +#define DBG_PRINTF( ... ) ((void)0) +#define DBG_CHAR( c ) ((void)0) +#endif + +EOF + +my $file_foot_format =<<'EOF'; +EOF + +my $declare_format =<<'EOF'; +BOOL CAMERAi_M_%s( CameraSelect camera ); +EOF + +my $func_head_format =<<'EOF'; +BOOL CAMERAi_M_%s( CameraSelect camera ) +{ +EOF + +my $func_foot_format =<<'EOF'; + return TRUE; +} +EOF + +my $call_format =<<'EOF'; + if (CAMERAi_M_%1$s(camera) == FALSE) {%2$s + DBG_PRINTF("Failed to call CAMERAi_M_%1$s! (%%d)\n", __LINE__); + return FALSE; + } +EOF + +my $reg_format =<<'EOF'; + if (CAMERAi_M_WriteRegister(camera, %s, %s) == FALSE) {%s + DBG_PRINTF("Failed to write a register! (%%d)\n", __LINE__); + return FALSE; + } +EOF + +my $set_format =<<'EOF'; + if (CAMERAi_M_SetFlags(camera, %s, %s) == FALSE) {%s + DBG_PRINTF("Failed to set a register! (%%d)\n", __LINE__); + return FALSE; + } +EOF + +my $clear_format =<<'EOF'; + if (CAMERAi_M_ClearFlags(camera, %s, %s) == FALSE) {%s + DBG_PRINTF("Failed to clear a register! (%%d)\n", __LINE__); + return FALSE; + } +EOF + +my $sleep_format =<<'EOF'; + OS_Sleep(%s);%s +EOF + +my $poolreg_format =<<'EOF'; + i = %5$s;%6$s + while (1) + { + u16 data; + if (CAMERAi_M_ReadRegisters(camera, %1$s, &data, 1) == FALSE) { + DBG_PRINTF("Failed to read a register! (%%d)\n", __LINE__); + return FALSE; + } + if ((data & %2$s) %3$s) + { + if (--i) + { + OS_Sleep(%4$s); + continue; + } + DBG_PRINTF("Failed to poll a register! (%%d)\n", __LINE__); + return FALSE; + } + break; + } +EOF + +my @functions = ({name => "", data => "", declare => ""}); # API + +sub name_conv { + $_ = $_[0]; + s/\>/To/g; + s/[\s\.\:\+\-\=\*\/]+/_/g; + return $_; +} + +sub func_conv { + my($key, $value, $comment) = @_; + $comment = " " . $comment; # insert spaces + if ($key eq "LOAD") { + return sprintf($call_format, name_conv($value), $comment); + } + elsif ($key eq "REG") { + my($reg, $val) = split /\s*\,\s*/, $value; + return sprintf($reg_format, $reg, $val, $comment); + } + elsif ($key eq "BITFIELD") { + my($reg, $mask, $which) = split /\s*\,\s*/, $value; + if ($which) { + return sprintf($set_format, $reg, $mask, $comment); + } else { + return sprintf($clear_format, $reg, $mask, $comment); + } + } + elsif ($key eq "DELAY") { + return sprintf($sleep_format, $value, $comment); + } + elsif ($key eq "POLL_REG") { + my($reg, $mask, $cond, $delay, $timeout) = split /\s*\,\s*/, $value; + $delay =~ s/DELAY\s*=\s*//; + $timeout =~ s/TIMEOUT\s*=\s*//; + ${$functions[$#functions]}{declare} = " int i;\r\n"; + return sprintf($poolreg_format, $reg, $mask, $cond, $delay, $timeout, $comment); + } + return " // " . $key . "=" . $value . $comment . "\r\n"; +} + +die "USAGE: convert.pl [INFILE] > [OUTFILE]\n" if ($#ARGV != 0); + +my $infile = $ARGV[0]; +(my $outfile = $infile) =~ s/\.ini$/.autogen.c/; + +open IN, $infile or die "Cannot open the file!\n"; + +my @packets; # パケットヘッダ+パケットの中身の集まり +my @data; # データ群 + +my $first = -1; # 先頭アドレス +my $current = -1; # 期待アドレス + +while () { + my $comment = ""; + s/[\r\n]+$//; # delete \r and/or \n + s|\;|//|; # replace first ; to // + if (s|(//.*)||) { + $comment = $1; + } + if (/\s*\[(.+)\]/) { + push @functions, {name => name_conv($1), data => "", declare => ""}; + } + elsif (/\s*(.+?)\s*\=\s*(.+?)\s*$/) { + ${$functions[$#functions]}{data} .= func_conv($1, $2, $comment); + } + elsif (/\S+/) { + print "UNKNOWN STATEMENT: <<", $_, ">>\n"; + ${$functions[$#functions]}{data} .= $_ . $comment . "\r\n"; + } + elsif ($comment) { + ${$functions[$#functions]}{data} .= $comment . "\r\n"; + } +} +close(IN); + +#use Data::Dumper; +#print Dumper(\@functions); +#exit(1); + +# output +printf $file_head_format, $outfile; +foreach my $func ( @functions ) { + if ($$func{name}) { + if ($$func{data} !~ /camera/) { + $$func{declare} = "#pragma unused(camera)\r\n"; + } + printf $declare_format, $$func{name}; + } +} +printf "\r\n"; +foreach my $func ( @functions ) { + if ($$func{name}) { + printf $func_head_format, $$func{name}; + print $$func{declare}, "\r\n" if ($$func{declare}); + } + print $$func{data}; + if ($$func{name}) { + printf $func_foot_format; + } +} +printf $file_foot_format; + diff --git a/build/libraries/camera/ARM7/convert.pl b/build/libraries/camera/ARM7/convert_samsung.pl similarity index 89% rename from build/libraries/camera/ARM7/convert.pl rename to build/libraries/camera/ARM7/convert_samsung.pl index c331087..352696e 100644 --- a/build/libraries/camera/ARM7/convert.pl +++ b/build/libraries/camera/ARM7/convert_samsung.pl @@ -18,7 +18,7 @@ my $file_head_format =<<'EOF'; $Log: $ $NoKeywords: $ *---------------------------------------------------------------------------*/ -#include +#include //#define PRINT_DEBUG @@ -30,8 +30,8 @@ my $file_head_format =<<'EOF'; #define DBG_CHAR( c ) ((void)0) #endif -BOOL %2$s( void ); -BOOL %2$s( void ) +BOOL %2$s( CameraSelect camera ); +BOOL %2$s( CameraSelect camera ) { EOF @@ -47,7 +47,7 @@ EOF my $packet_last_format =<<'EOF'; }; - if (CAMERAi_WriteRegisters(0x%s, data, %d) == FALSE) { + if (CAMERAi_WriteRegisters(camera, 0x%s, data, %d) == FALSE) { DBG_PRINTF("Failed to initialize! (%%d)\n", __LINE__); return FALSE; } @@ -55,7 +55,7 @@ my $packet_last_format =<<'EOF'; EOF my $packet_single_format =<<'EOF'; - if (CAMERAi_WriteRegister(0x%s, 0x%s) == FALSE) { + if (CAMERAi_WriteRegister(camera, 0x%s, 0x%s) == FALSE) { DBG_PRINTF("Failed to initialize! (%%d)\n", __LINE__); return FALSE; } diff --git a/build/libraries/camera/ARM9/camera.c b/build/libraries/camera/ARM9/camera.c index 2c868f5..9259368 100644 --- a/build/libraries/camera/ARM9/camera.c +++ b/build/libraries/camera/ARM9/camera.c @@ -28,75 +28,32 @@ 静的変数定義 *---------------------------------------------------------------------------*/ static CameraSelect currentCamera; -static BOOL prestate; - +static BOOL cameraPreSleepState; /*---------------------------------------------------------------------------* 内部関数定義 *---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------* - Name: CAMERA_SelectCamera + Name: CAMERA_Select - Description: set stbyn + Description: select camera to activate Arguments: camera one of CameraSelect Returns: None *---------------------------------------------------------------------------*/ -void CAMERA_SelectCamera( CameraSelect camera ) +BOOL CAMERA_Select( CameraSelect camera ) { - if (currentCamera == camera) + if (currentCamera == camera || CAMERA_SELECT_BOTH == camera) { - return; + return FALSE; } - - switch (camera) + if (CAMERA_I2CSelect(camera) != CAMERA_RESULT_SUCCESS) { - case CAMERA_SELECT_FIRST: - CAMERA_SetStbyn2(FALSE); - break; - case CAMERA_SELECT_SECOND: - CAMERA_SetStbyn(FALSE); - break; - default: - return; + return FALSE; } currentCamera = camera; -} - -/*---------------------------------------------------------------------------* - Name: CAMERA_SetStbyn - - Description: set STBYn for current camera - - Arguments: BOOL High/Low - - Returns: BOOL last state - *---------------------------------------------------------------------------*/ -BOOL CAMERA_SetStbyn( BOOL high ) -{ - static BOOL prev = FALSE; - BOOL temp = prev; - switch (currentCamera) - { - case CAMERA_SELECT_FIRST: - if (high) - { - reg_CAM_CAM_MCNT |= REG_CAM_CAM_MCNT_STBYN_MASK; - } - else - { - reg_CAM_CAM_MCNT &= ~REG_CAM_CAM_MCNT_STBYN_MASK; - } - break; - case CAMERA_SELECT_SECOND: - CAMERA_SetStbyn2(high); - break; - default: - return temp; - } - prev = high; - return temp; + return TRUE; } /*---------------------------------------------------------------------------* @@ -112,22 +69,14 @@ void CAMERA_PowerOn( void ) { reg_CFG_CLK |= REG_CFG_CLK_CAM_MASK; if ((reg_CFG_CLK & REG_CFG_CLK_CAM_CKI_MASK) == 0) { - reg_CAM_CAM_MCNT |= (REG_CAM_CAM_MCNT_V28_MASK // VDD2.8 POWER ON - | REG_CAM_CAM_MCNT_INI_MASK);// setup data line after CPU is powered on - OS_SpinWaitSysCycles( 4 ); // wait to raise VDD2.8 - reg_CAM_CAM_MCNT &= ~REG_CAM_CAM_MCNT_V18_MASK; // VDD1.8 POWER ON - OS_SpinWaitSysCycles( 4 ); // wait to raise VDD1.8 - reg_CAM_CAM_MCNT &= ~REG_CAM_CAM_MCNT_VIO_MASK; // VDDIO POWER ON - OS_SpinWaitSysCycles( 4 ); // wait to raise VDDIO - - reg_CFG_CLK |= REG_CFG_CLK_CAM_CKI_MASK;// MCLK on - OS_SpinWaitSysCycles( 100 ); // wait for over 100 MCLK cycles - + reg_CAM_CAM_MCNT |= REG_CAM_CAM_MCNT_V28_MASK; // VDD2.8 POWER ON + OS_SpinWaitSysCycles( 30 ); // wait for over 15 MCLK (10-20) + reg_CFG_CLK |= REG_CFG_CLK_CAM_CKI_MASK; // MCLK on + OS_SpinWaitSysCycles( 30 ); // wait for over 15 MCLKs (20-10) reg_CAM_CAM_MCNT |= REG_CAM_CAM_MCNT_RSTN_MASK; // RSTN => Hi - CAMERA_SetStbyn(TRUE); // STBYN => Hi - OS_SpinWaitSysCycles( 1800000 ); // wait for over 1800000 MCLK cycles (over 100msec!!!) + OS_SpinWaitSysCycles( 12000 ); // wait for over 6000 MCLKs - reg_CAM_CAM_CNT = REG_CAM_CAM_CNT_CL_MASK; // full reset CNT + reg_CAM_CAM_CNT = REG_CAM_CAM_CNT_CL_MASK; // full reset CNT } } @@ -140,25 +89,18 @@ void CAMERA_PowerOn( void ) Returns: None *---------------------------------------------------------------------------*/ -static inline void CAMERA_PowerOff( void ) +void CAMERA_PowerOff( void ) { if (reg_CFG_CLK & REG_CFG_CLK_CAM_CKI_MASK) { - reg_CAM_CAM_CNT &= ~REG_CAM_CAM_CNT_E_MASK; // stop cmaera output + reg_CAM_CAM_CNT &= ~REG_CAM_CAM_CNT_E_MASK; // stop cmaera output - CAMERA_SetStbyn(FALSE); // STBYN => Lo - OS_SpinWaitSysCycles( 20 ); // wait for over 20 MCLK cycles - reg_CAM_CAM_MCNT &= ~REG_CAM_CAM_MCNT_RSTN_MASK; - OS_SpinWaitSysCycles( 20 ); // wait for over 20 MCLK cycles + reg_CAM_CAM_MCNT &= ~REG_CAM_CAM_MCNT_RSTN_MASK;// RSTN => Lo + OS_SpinWaitSysCycles( 10 ); // wait for over 5 MCLK - reg_CFG_CLK &= ~REG_CFG_CLK_CAM_CKI_MASK; // MCLK off - // no wait + reg_CFG_CLK &= ~REG_CFG_CLK_CAM_CKI_MASK; // MCLK off - reg_CAM_CAM_MCNT |= REG_CAM_CAM_MCNT_VIO_MASK; // VDDIO POWER OFF - OS_SpinWaitSysCycles( 4 ); // wait a moment - reg_CAM_CAM_MCNT |= REG_CAM_CAM_MCNT_V18_MASK; // VDD1.8 POWER OFF - OS_SpinWaitSysCycles( 4 ); // wait a moment reg_CAM_CAM_MCNT &= ~REG_CAM_CAM_MCNT_V28_MASK; // VDD2.8 POWER OFF - OS_SpinWaitSysCycles( 4 ); // wait a moment + OS_SpinWaitSysCycles( 4 ); // wait a moment } reg_CFG_CLK &= ~REG_CFG_CLK_CAM_MASK; /* 必要ある? */ } @@ -175,9 +117,9 @@ static inline void CAMERA_PowerOff( void ) void CAMERA_PreSleep( void ) { if (reg_CFG_CLK & REG_CFG_CLK_CAM_CKI_MASK) { - prestate = CAMERA_SetStbyn(FALSE); - OS_SpinWaitSysCycles( 20 ); // wait for over 20 MCLK cycles - // MCLK will stop automatically + cameraPreSleepState = TRUE; + CAMERA_I2CPreSleep(); + CAMERA_PowerOff(); } } @@ -192,13 +134,10 @@ void CAMERA_PreSleep( void ) *---------------------------------------------------------------------------*/ void CAMERA_PostSleep( void ) { - if (reg_CFG_CLK & REG_CFG_CLK_CAM_CKI_MASK) { - // MCLK started automatically - if (prestate) - { - CAMERA_SetStbyn(TRUE); - OS_SpinWaitSysCycles( 100000 ); // wait for over 100000 MCLK cycles - } + if (cameraPreSleepState == TRUE) { + cameraPreSleepState = FALSE; + CAMERA_PowerOn(); + CAMERA_I2CPostSleep(); } } diff --git a/build/libraries/camera/ARM9/camera_api.c b/build/libraries/camera/ARM9/camera_api.c index a839eb8..c1334dc 100644 --- a/build/libraries/camera/ARM9/camera_api.c +++ b/build/libraries/camera/ARM9/camera_api.c @@ -98,25 +98,30 @@ void CAMERA_Init(void) } /*---------------------------------------------------------------------------* - Name: CAMERA_SetStbyn2Async + Name: CAMERA_I2CSelectAsync - Description: select STBYN for 2nd CAMERA + Description: select CAMERA to activate async version - Arguments: state - High/Low + Arguments: camera - one of CameraSelect callback - 非同期処理が完了した再に呼び出す関数を指定 arg - コールバック関数の呼び出し時の引数を指定。 Returns: CAMERAResult *---------------------------------------------------------------------------*/ -CAMERAResult CAMERA_SetStbyn2Async(BOOL state, CAMERACallback callback, void *arg) +CAMERAResult CAMERA_I2CSelectAsync(CameraSelect camera, CAMERACallback callback, void *arg) { - const CAMERAPxiCommand command = CAMERA_PXI_COMMAND_SET_STBYN; - const u8 size = CAMERA_PXI_SIZE_SET_STBYN; + const CAMERAPxiCommand command = CAMERA_PXI_COMMAND_SELECT; + const u8 size = CAMERA_PXI_SIZE_SELECT; OSIntrMode enabled; SDK_NULL_ASSERT(callback); + if (CAMERA_SELECT_BOTH == camera) + { + return CAMERA_RESULT_ILLEGAL_PARAMETER; + } + enabled = OS_DisableInterrupts(); if (cameraWork.lock) { @@ -129,22 +134,22 @@ CAMERAResult CAMERA_SetStbyn2Async(BOOL state, CAMERACallback callback, void *ar cameraWork.callback = callback; cameraWork.callbackArg = arg; - return CameraSendPxiCommand(command, size, (u8)state) ? CAMERA_RESULT_SUCCESS : CAMERA_RESULT_SEND_ERROR; + return CameraSendPxiCommand(command, size, (u8)camera) ? CAMERA_RESULT_SUCCESS : CAMERA_RESULT_SEND_ERROR; } /*---------------------------------------------------------------------------* - Name: CAMERA_SetStbyn2 + Name: CAMERA_I2CSelect - Description: select STBYN for 2nd CAMERA + Description: select CAMERA to activate sync version. - Arguments: state - High/Low + Arguments: camera - one of CameraSelect Returns: CAMERAResult *---------------------------------------------------------------------------*/ -CAMERAResult CAMERA_SetStbyn2(BOOL state) +CAMERAResult CAMERA_I2CSelect(CameraSelect camera) { - cameraWork.result = CAMERA_SetStbyn2Async(state, CameraSyncCallback, 0); + cameraWork.result = CAMERA_I2CSelectAsync(camera, CameraSyncCallback, 0); if (cameraWork.result == CAMERA_RESULT_SUCCESS) { CameraWaitBusy(); @@ -159,7 +164,8 @@ CAMERAResult CAMERA_SetStbyn2(BOOL state) Description: write CAMERA registers via I2C. async version. - Arguments: addr - start address + Arguments: camera - one of CameraSelect + addr - start address bufp - buffer to write length - length of bufp callback - 非同期処理が完了した再に呼び出す関数を指定 @@ -167,7 +173,7 @@ CAMERAResult CAMERA_SetStbyn2(BOOL state) Returns: CAMERAResult *---------------------------------------------------------------------------*/ -CAMERAResult CAMERA_WriteRegistersAsync(u8 addr, const u8* bufp, size_t length, CAMERACallback callback, void *arg) +CAMERAResult CAMERA_WriteRegistersAsync(CameraSelect camera, u8 addr, const u8* bufp, size_t length, CAMERACallback callback, void *arg) { const CAMERAPxiCommand command = CAMERA_PXI_COMMAND_WRITE_REGISTERS; u8 size; // variable!! @@ -178,7 +184,11 @@ CAMERAResult CAMERA_WriteRegistersAsync(u8 addr, const u8* bufp, size_t length, SDK_NULL_ASSERT(bufp); SDK_NULL_ASSERT(callback); - if (length + 2 > CAMERA_PXI_DATA_SIZE_MAX) + if (CAMERA_SELECT_NONE == camera) + { + return CAMERA_RESULT_ILLEGAL_PARAMETER; + } + if (length + 3 > CAMERA_PXI_DATA_SIZE_MAX) { return CAMERA_RESULT_ILLEGAL_PARAMETER; // too long } @@ -196,10 +206,11 @@ CAMERAResult CAMERA_WriteRegistersAsync(u8 addr, const u8* bufp, size_t length, cameraWork.callbackArg = arg; // データ作成 - data[0] = addr; - data[1] = (u8)length; - MI_CpuCopy8(bufp, &data[2], length); - size = (u8)(length + 2); + data[0] = (u8)camera; + data[1] = addr; + data[2] = (u8)length; + MI_CpuCopy8(bufp, &data[3], length); + size = (u8)(length + 3); // コマンド送信 if (CameraSendPxiCommand(command, size, data[0]) == FALSE) @@ -222,15 +233,16 @@ CAMERAResult CAMERA_WriteRegistersAsync(u8 addr, const u8* bufp, size_t length, Description: write CAMERA registers via I2C. sync version. - Arguments: addr - start address + Arguments: camera - one of CameraSelect + addr - start address bufp - buffer to write length - length of bufp Returns: CAMERAResult *---------------------------------------------------------------------------*/ -CAMERAResult CAMERA_WriteRegisters(u8 addr, const u8* bufp, size_t length) +CAMERAResult CAMERA_WriteRegisters(CameraSelect camera, u8 addr, const u8* bufp, size_t length) { - cameraWork.result = CAMERA_WriteRegistersAsync(addr, bufp, length, CameraSyncCallback, 0); + cameraWork.result = CAMERA_WriteRegistersAsync(camera, addr, bufp, length, CameraSyncCallback, 0); if (cameraWork.result == CAMERA_RESULT_SUCCESS) { CameraWaitBusy(); @@ -243,7 +255,8 @@ CAMERAResult CAMERA_WriteRegisters(u8 addr, const u8* bufp, size_t length) Description: read CAMERA registers via I2C. - Arguments: addr - start address + Arguments: camera - one of CameraSelect + addr - start address bufp - buffer to read length - length of bufp callback - 非同期処理が完了した再に呼び出す関数を指定 @@ -251,7 +264,7 @@ CAMERAResult CAMERA_WriteRegisters(u8 addr, const u8* bufp, size_t length) Returns: CAMERAResult *---------------------------------------------------------------------------*/ -CAMERAResult CAMERA_ReadRegistersAsync(u8 addr, u8* bufp, size_t length, CAMERACallback callback, void *arg) +CAMERAResult CAMERA_ReadRegistersAsync(CameraSelect camera, u8 addr, u8* bufp, size_t length, CAMERACallback callback, void *arg) { const CAMERAPxiCommand command = CAMERA_PXI_COMMAND_READ_REGISTERS; const u8 size = CAMERA_PXI_SIZE_READ_REGISTERS; @@ -262,7 +275,11 @@ CAMERAResult CAMERA_ReadRegistersAsync(u8 addr, u8* bufp, size_t length, CAMERAC SDK_NULL_ASSERT(bufp); SDK_NULL_ASSERT(callback); - if (length + 2 > CAMERA_PXI_DATA_SIZE_MAX) + if (CAMERA_SELECT_NONE == camera) + { + return CAMERA_RESULT_ILLEGAL_PARAMETER; + } + if (length + 1 > CAMERA_PXI_DATA_SIZE_MAX) { return CAMERA_RESULT_ILLEGAL_PARAMETER; // too long } @@ -280,8 +297,9 @@ CAMERAResult CAMERA_ReadRegistersAsync(u8 addr, u8* bufp, size_t length, CAMERAC cameraWork.callbackArg = arg; // データ作成 - data[0] = addr; - data[1] = (u8)length; + data[0] = (u8)camera; + data[1] = addr; + data[2] = (u8)length; // 引数保存 cameraWork.data = bufp; @@ -308,13 +326,16 @@ CAMERAResult CAMERA_ReadRegistersAsync(u8 addr, u8* bufp, size_t length, CAMERAC Description: set CAMERA key normally sync version. - Arguments: pKey - pointer to key data + Arguments: camera - one of CameraSelect + addr - start address + bufp - buffer to read + length - length of bufp Returns: CAMERAResult *---------------------------------------------------------------------------*/ -CAMERAResult CAMERA_ReadRegisters(u8 addr, u8* bufp, size_t length) +CAMERAResult CAMERA_ReadRegisters(CameraSelect camera, u8 addr, u8* bufp, size_t length) { - cameraWork.result = CAMERA_ReadRegistersAsync(addr, bufp, length, CameraSyncCallback, 0); + cameraWork.result = CAMERA_ReadRegistersAsync(camera, addr, bufp, length, CameraSyncCallback, 0); if (cameraWork.result == CAMERA_RESULT_SUCCESS) { CameraWaitBusy(); @@ -327,7 +348,8 @@ CAMERAResult CAMERA_ReadRegisters(u8 addr, u8* bufp, size_t length) Description: set register as reg = (reg & ~mask) | (bits & mask); - Arguments: addr - address to access + Arguments: camera - one of CameraSelect + addr - address to access bits - bits to set mask - mask to touch callback - 非同期処理が完了した再に呼び出す関数を指定 @@ -335,7 +357,7 @@ CAMERAResult CAMERA_ReadRegisters(u8 addr, u8* bufp, size_t length) Returns: CAMERAResult *---------------------------------------------------------------------------*/ -CAMERAResult CAMERA_SetParamsAsync(u8 addr, u8 bits, u8 mask, CAMERACallback callback, void *arg) +CAMERAResult CAMERA_SetParamsAsync(CameraSelect camera, u8 addr, u8 bits, u8 mask, CAMERACallback callback, void *arg) { const CAMERAPxiCommand command = CAMERA_PXI_COMMAND_SET_PARAMS; const u8 size = CAMERA_PXI_SIZE_SET_PARAMS; @@ -345,6 +367,11 @@ CAMERAResult CAMERA_SetParamsAsync(u8 addr, u8 bits, u8 mask, CAMERACallback cal SDK_NULL_ASSERT(callback); + if (CAMERA_SELECT_NONE == camera) + { + return CAMERA_RESULT_ILLEGAL_PARAMETER; + } + enabled = OS_DisableInterrupts(); if (cameraWork.lock) { @@ -358,9 +385,10 @@ CAMERAResult CAMERA_SetParamsAsync(u8 addr, u8 bits, u8 mask, CAMERACallback cal cameraWork.callbackArg = arg; // データ作成 - data[0] = addr; - data[1] = bits; - data[2] = mask; + data[0] = (u8)camera; + data[1] = addr; + data[2] = bits; + data[3] = mask; // コマンド送信 if (CameraSendPxiCommand(command, size, data[0]) == FALSE) @@ -382,15 +410,16 @@ CAMERAResult CAMERA_SetParamsAsync(u8 addr, u8 bits, u8 mask, CAMERACallback cal Description: set register as reg = (reg & ~mask) | (bits & mask); - Arguments: addr - address to access + Arguments: camera - one of CameraSelect + addr - address to access bits - bits to set mask - mask to touch Returns: CAMERAResult *---------------------------------------------------------------------------*/ -CAMERAResult CAMERA_SetParams(u8 addr, u8 bits, u8 mask) +CAMERAResult CAMERA_SetParams(CameraSelect camera, u8 addr, u8 bits, u8 mask) { - cameraWork.result = CAMERA_SetParamsAsync(addr, bits, mask, CameraSyncCallback, 0); + cameraWork.result = CAMERA_SetParamsAsync(camera, addr, bits, mask, CameraSyncCallback, 0); if (cameraWork.result == CAMERA_RESULT_SUCCESS) { CameraWaitBusy(); @@ -403,14 +432,15 @@ CAMERAResult CAMERA_SetParams(u8 addr, u8 bits, u8 mask) Description: set register as reg |= bits; - Arguments: addr - address to access + Arguments: camera - one of CameraSelect + addr - address to access bits - bits to set callback - 非同期処理が完了した再に呼び出す関数を指定 arg - コールバック関数の呼び出し時の引数を指定。 Returns: CAMERAResult *---------------------------------------------------------------------------*/ -CAMERAResult CAMERA_SetFlagsAsync(u8 addr, u8 bits, CAMERACallback callback, void *arg) +CAMERAResult CAMERA_SetFlagsAsync(CameraSelect camera, u8 addr, u8 bits, CAMERACallback callback, void *arg) { const CAMERAPxiCommand command = CAMERA_PXI_COMMAND_SET_FLAGS; const u8 size = CAMERA_PXI_SIZE_SET_FLAGS; @@ -420,6 +450,11 @@ CAMERAResult CAMERA_SetFlagsAsync(u8 addr, u8 bits, CAMERACallback callback, voi SDK_NULL_ASSERT(callback); + if (CAMERA_SELECT_NONE == camera) + { + return CAMERA_RESULT_ILLEGAL_PARAMETER; + } + enabled = OS_DisableInterrupts(); if (cameraWork.lock) { @@ -433,8 +468,9 @@ CAMERAResult CAMERA_SetFlagsAsync(u8 addr, u8 bits, CAMERACallback callback, voi cameraWork.callbackArg = arg; // データ作成 - data[0] = addr; - data[1] = bits; + data[0] = (u8)camera; + data[1] = addr; + data[2] = bits; // コマンド送信 if (CameraSendPxiCommand(command, size, data[0]) == FALSE) @@ -456,14 +492,15 @@ CAMERAResult CAMERA_SetFlagsAsync(u8 addr, u8 bits, CAMERACallback callback, voi Description: set register as reg |= bits; - Arguments: addr - address to access + Arguments: camera - one of CameraSelect + addr - address to access bits - bits to set Returns: CAMERAResult *---------------------------------------------------------------------------*/ -CAMERAResult CAMERA_SetFlags(u8 addr, u8 bits) +CAMERAResult CAMERA_SetFlags(CameraSelect camera, u8 addr, u8 bits) { - cameraWork.result = CAMERA_SetFlagsAsync(addr, bits, CameraSyncCallback, 0); + cameraWork.result = CAMERA_SetFlagsAsync(camera, addr, bits, CameraSyncCallback, 0); if (cameraWork.result == CAMERA_RESULT_SUCCESS) { CameraWaitBusy(); @@ -476,14 +513,15 @@ CAMERAResult CAMERA_SetFlags(u8 addr, u8 bits) Description: set register as reg &= ~bits; - Arguments: addr - address to access + Arguments: camera - one of CameraSelect + addr - address to access bits - bits to clear callback - 非同期処理が完了した再に呼び出す関数を指定 arg - コールバック関数の呼び出し時の引数を指定。 Returns: CAMERAResult *---------------------------------------------------------------------------*/ -CAMERAResult CAMERA_ClearFlagsAsync(u8 addr, u8 bits, CAMERACallback callback, void *arg) +CAMERAResult CAMERA_ClearFlagsAsync(CameraSelect camera, u8 addr, u8 bits, CAMERACallback callback, void *arg) { const CAMERAPxiCommand command = CAMERA_PXI_COMMAND_CLEAR_FLAGS; const u8 size = CAMERA_PXI_SIZE_CLEAR_FLAGS; @@ -493,6 +531,11 @@ CAMERAResult CAMERA_ClearFlagsAsync(u8 addr, u8 bits, CAMERACallback callback, v SDK_NULL_ASSERT(callback); + if (CAMERA_SELECT_NONE == camera) + { + return CAMERA_RESULT_ILLEGAL_PARAMETER; + } + enabled = OS_DisableInterrupts(); if (cameraWork.lock) { @@ -506,8 +549,9 @@ CAMERAResult CAMERA_ClearFlagsAsync(u8 addr, u8 bits, CAMERACallback callback, v cameraWork.callbackArg = arg; // データ作成 - data[0] = addr; - data[1] = bits; + data[0] = (u8)camera; + data[1] = addr; + data[2] = bits; // コマンド送信 if (CameraSendPxiCommand(command, size, data[0]) == FALSE) @@ -529,14 +573,15 @@ CAMERAResult CAMERA_ClearFlagsAsync(u8 addr, u8 bits, CAMERACallback callback, v Description: set register as reg &= ~bits; - Arguments: addr - address to access + Arguments: camera - one of CameraSelect + addr - address to access bits - bits to set Returns: CAMERAResult *---------------------------------------------------------------------------*/ -CAMERAResult CAMERA_ClearFlags(u8 addr, u8 bits) +CAMERAResult CAMERA_ClearFlags(CameraSelect camera, u8 addr, u8 bits) { - cameraWork.result = CAMERA_ClearFlagsAsync(addr, bits, CameraSyncCallback, 0); + cameraWork.result = CAMERA_ClearFlagsAsync(camera, addr, bits, CameraSyncCallback, 0); if (cameraWork.result == CAMERA_RESULT_SUCCESS) { CameraWaitBusy(); @@ -550,12 +595,13 @@ CAMERAResult CAMERA_ClearFlags(u8 addr, u8 bits) Description: initialize camera registers via I2C async version. - Arguments: callback - 非同期処理が完了した再に呼び出す関数を指定 + Arguments: camera - one of CameraSelect + callback - 非同期処理が完了した再に呼び出す関数を指定 arg - コールバック関数の呼び出し時の引数を指定。 Returns: CAMERAResult *---------------------------------------------------------------------------*/ -CAMERAResult CAMERA_I2CInitAsync(CAMERACallback callback, void *arg) +CAMERAResult CAMERA_I2CInitAsync(CameraSelect camera, CAMERACallback callback, void *arg) { const CAMERAPxiCommand command = CAMERA_PXI_COMMAND_I2C_INIT; const u8 size = CAMERA_PXI_SIZE_I2C_INIT; @@ -563,6 +609,11 @@ CAMERAResult CAMERA_I2CInitAsync(CAMERACallback callback, void *arg) SDK_NULL_ASSERT(callback); + if (CAMERA_SELECT_NONE == camera) + { + return CAMERA_RESULT_ILLEGAL_PARAMETER; + } + enabled = OS_DisableInterrupts(); if (cameraWork.lock) { @@ -575,7 +626,7 @@ CAMERAResult CAMERA_I2CInitAsync(CAMERACallback callback, void *arg) cameraWork.callback = callback; cameraWork.callbackArg = arg; - return CameraSendPxiCommand(command, size, 0) ? CAMERA_RESULT_SUCCESS : CAMERA_RESULT_SEND_ERROR; + return CameraSendPxiCommand(command, size, (u8)camera) ? CAMERA_RESULT_SUCCESS : CAMERA_RESULT_SEND_ERROR; } /*---------------------------------------------------------------------------* @@ -584,40 +635,48 @@ CAMERAResult CAMERA_I2CInitAsync(CAMERACallback callback, void *arg) Description: initialize camera registers via I2C sync version. - Arguments: None. + Arguments: camera - one of CameraSelect Returns: CAMERAResult *---------------------------------------------------------------------------*/ -CAMERAResult CAMERA_I2CInit(void) +CAMERAResult CAMERA_I2CInit(CameraSelect camera) { - cameraWork.result = CAMERA_I2CInitAsync(CameraSyncCallback, 0); + cameraWork.result = CAMERA_I2CInitAsync(camera, CameraSyncCallback, 0); if (cameraWork.result == CAMERA_RESULT_SUCCESS) { CameraWaitBusy(); } return cameraWork.result; } - +#if 0 /*---------------------------------------------------------------------------* Name: CAMERA_I2CPresetAsync Description: set camera registers with specified preset via I2C async version - Arguments: preset - preset type + Arguments: camera - one of CameraSelect + preset - preset type callback - 非同期処理が完了した再に呼び出す関数を指定 arg - コールバック関数の呼び出し時の引数を指定。 Returns: CAMERAResult *---------------------------------------------------------------------------*/ -CAMERAResult CAMERA_I2CPresetAsync(CameraPreset preset, CAMERACallback callback, void *arg) +CAMERAResult CAMERA_I2CPresetAsync(CameraSelect camera, CameraPreset preset, CAMERACallback callback, void *arg) { const CAMERAPxiCommand command = CAMERA_PXI_COMMAND_I2C_PRESET; const u8 size = CAMERA_PXI_SIZE_I2C_PRESET; OSIntrMode enabled; + u8 data[size]; + int i; SDK_NULL_ASSERT(callback); + if (CAMERA_SELECT_NONE == camera) + { + return CAMERA_RESULT_ILLEGAL_PARAMETER; + } + enabled = OS_DisableInterrupts(); if (cameraWork.lock) { @@ -630,7 +689,23 @@ CAMERAResult CAMERA_I2CPresetAsync(CameraPreset preset, CAMERACallback callback, cameraWork.callback = callback; cameraWork.callbackArg = arg; - return CameraSendPxiCommand(command, size, (u8)preset) ? CAMERA_RESULT_SUCCESS : CAMERA_RESULT_SEND_ERROR; + // データ作成 + data[0] = (u8)camera; + data[1] = (u8)preset; + + // コマンド送信 + if (CameraSendPxiCommand(command, size, data[0]) == FALSE) + { + return CAMERA_RESULT_SEND_ERROR; + } + for (i = 1; i < size; i+=3) { + if (CameraSendPxiData(&data[i]) == FALSE) + { + return CAMERA_RESULT_SEND_ERROR; + } + } + + return CAMERA_RESULT_SUCCESS; } /*---------------------------------------------------------------------------* @@ -639,20 +714,21 @@ CAMERAResult CAMERA_I2CPresetAsync(CameraPreset preset, CAMERACallback callback, Description: set camera registers with specified preset via I2C sync version. - Arguments: preset - preset type + Arguments: camera - one of CameraSelect + preset - preset type Returns: CAMERAResult *---------------------------------------------------------------------------*/ -CAMERAResult CAMERA_I2CPreset(CameraPreset preset) +CAMERAResult CAMERA_I2CPreset(CameraSelect camera, CameraPreset preset) { - cameraWork.result = CAMERA_I2CPresetAsync(preset, CameraSyncCallback, 0); + cameraWork.result = CAMERA_I2CPresetAsync(camera, preset, CameraSyncCallback, 0); if (cameraWork.result == CAMERA_RESULT_SUCCESS) { CameraWaitBusy(); } return cameraWork.result; } - +#endif /*---------------------------------------------------------------------------* Name: CAMERA_I2CPreSleepAsync @@ -767,7 +843,8 @@ CAMERAResult CAMERA_I2CPostSleep(void) Description: set offset and size - Arguments: x_off - x offset to start capturing + Arguments: camera - one of CameraSelect + x_off - x offset to start capturing y_off - y offset to start capturing width - width of image height - height of image @@ -776,7 +853,7 @@ CAMERAResult CAMERA_I2CPostSleep(void) Returns: CAMERAResult *---------------------------------------------------------------------------*/ -CAMERAResult CAMERA_SetCroppingAsync(u16 x_off, u16 y_off, u16 width, u16 height, CAMERACallback callback, void *arg) +CAMERAResult CAMERA_SetCroppingAsync(CameraSelect camera, u16 x_off, u16 y_off, u16 width, u16 height, CAMERACallback callback, void *arg) { const CAMERAPxiCommand command = CAMERA_PXI_COMMAND_I2C_SET_CROPPING; const u8 size = CAMERA_PXI_SIZE_I2C_SET_CROPPING; @@ -786,6 +863,11 @@ CAMERAResult CAMERA_SetCroppingAsync(u16 x_off, u16 y_off, u16 width, u16 height SDK_NULL_ASSERT(callback); + if (CAMERA_SELECT_NONE == camera) + { + return CAMERA_RESULT_ILLEGAL_PARAMETER; + } + enabled = OS_DisableInterrupts(); if (cameraWork.lock) { @@ -799,10 +881,11 @@ CAMERAResult CAMERA_SetCroppingAsync(u16 x_off, u16 y_off, u16 width, u16 height cameraWork.callbackArg = arg; // データ作成 - CAMERA_PACK_U16(&data[0], &x_off); - CAMERA_PACK_U16(&data[2], &y_off); - CAMERA_PACK_U16(&data[4], &width); - CAMERA_PACK_U16(&data[6], &height); + data[0] = (u8)camera; + CAMERA_PACK_U16(&data[1], &x_off); + CAMERA_PACK_U16(&data[3], &y_off); + CAMERA_PACK_U16(&data[5], &width); + CAMERA_PACK_U16(&data[7], &height); // コマンド送信 if (CameraSendPxiCommand(command, size, data[0]) == FALSE) @@ -824,16 +907,17 @@ CAMERAResult CAMERA_SetCroppingAsync(u16 x_off, u16 y_off, u16 width, u16 height Description: set offset and size - Arguments: x_off - x offset to start capturing + Arguments: camera - one of CameraSelect + x_off - x offset to start capturing y_off - y offset to start capturing width - width of image height - height of image Returns: CAMERAResult *---------------------------------------------------------------------------*/ -CAMERAResult CAMERA_SetCropping(u16 x_off, u16 y_off, u16 width, u16 height) +CAMERAResult CAMERA_SetCropping(CameraSelect camera, u16 x_off, u16 y_off, u16 width, u16 height) { - cameraWork.result = CAMERA_SetCroppingAsync(x_off, y_off, width, height, CameraSyncCallback, 0); + cameraWork.result = CAMERA_SetCroppingAsync(camera, x_off, y_off, width, height, CameraSyncCallback, 0); if (cameraWork.result == CAMERA_RESULT_SUCCESS) { CameraWaitBusy(); diff --git a/build/libraries/i2c/ARM7/src/i2c_instruction.c b/build/libraries/i2c/ARM7/src/i2c_instruction.c index 94b0f7a..c1540a6 100644 --- a/build/libraries/i2c/ARM7/src/i2c_instruction.c +++ b/build/libraries/i2c/ARM7/src/i2c_instruction.c @@ -18,8 +18,12 @@ #define RETRY_COUNT 8 -static u8 I2C_DeviceAddrTable[I2C_SLAVE_NUM] = { I2C_ADDR_CODEC, - I2C_ADDR_CAMERA, +static u8 I2C_DeviceAddrTable[I2C_SLAVE_NUM] = { + I2C_ADDR_CODEC, + I2C_ADDR_CAMERA_MICRON_IN, + I2C_ADDR_CAMERA_MICRON_OUT, + I2C_ADDR_CAMERA_SHARP_IN, + I2C_ADDR_CAMERA_SHARP_OUT, }; static OSMutex mutex; @@ -142,6 +146,30 @@ static inline u8 I2Ci_WaitReceiveLast( void ) return I2Ci_GetData(); } +// 16 bit sequence + +static inline BOOL I2Ci_SendMiddle16( u16 data ) +{ + return I2Ci_SendMiddle( (u8)(data >> 8) ) + && I2Ci_SendMiddle( (u8)(data && 0xFF) ); +} + +static inline BOOL I2Ci_SendLast16( u16 data ) +{ + return I2Ci_SendMiddle( (u8)(data >> 8) ) + && I2Ci_SendLast( (u8)(data && 0xFF) ); +} + +static inline u16 I2Ci_WaitReceiveMiddle16( void ) +{ + return (u16)((I2Ci_WaitReceiveMiddle() << 8) | I2Ci_WaitReceiveMiddle()); +} + +static inline u16 I2Ci_WaitReceiveLast16( void ) +{ + return (u16)((I2Ci_WaitReceiveMiddle() << 8) | I2Ci_WaitReceiveLast()); +} + /*---------------------------------------------------------------------------* Name: I2C_Init @@ -288,6 +316,72 @@ BOOL I2C_ClearFlags( I2CSlave id, u8 reg, u8 clrBits ) return I2C_SetParams( id, reg, 0, clrBits ); } +/*---------------------------------------------------------------------------* + Name: I2C_SetParams16 + + Description: set control bit to device register + + Arguments: reg : device register + setBits : bits to set + + Returns: None + *---------------------------------------------------------------------------*/ +BOOL I2Ci_SetParams16( I2CSlave id, u16 reg, u16 setBits, u16 maskBits ) +{ + u16 tmp; + tmp = I2Ci_ReadRegister16( id, reg ); + tmp &= ~maskBits; + setBits &= maskBits; + tmp |= setBits; + return I2Ci_WriteRegister16( id, reg, tmp ); +} +BOOL I2C_SetParams16( I2CSlave id, u16 reg, u16 setBits, u16 maskBits ) +{ + BOOL result; + (void)I2C_Lock(); + result = I2Ci_SetParams16( id, reg, setBits, maskBits ); + (void)I2C_Unlock(); + return result; +} + +/*---------------------------------------------------------------------------* + Name: I2C_SetFlags16 + + Description: set control bit to device register + + Arguments: reg : device register + setBits : bits to set + + Returns: None + *---------------------------------------------------------------------------*/ +BOOL I2Ci_SetFlags16( I2CSlave id, u16 reg, u16 setBits ) +{ + return I2Ci_SetParams16( id, reg, setBits, setBits ); +} +BOOL I2C_SetFlags16( I2CSlave id, u16 reg, u16 setBits ) +{ + return I2C_SetParams16( id, reg, setBits, setBits ); +} + +/*---------------------------------------------------------------------------* + Name: I2C_ClearFlags16 + + Description: clear control bit to device register + + Arguments: reg : device register + clrBits : bits to set + + Returns: None + *---------------------------------------------------------------------------*/ +BOOL I2Ci_ClearFlags16( I2CSlave id, u16 reg, u16 clrBits ) +{ + return I2Ci_SetParams16( id, reg, 0, clrBits ); +} +BOOL I2C_ClearFlags16( I2CSlave id, u16 reg, u16 clrBits ) +{ + return I2C_SetParams16( id, reg, 0, clrBits ); +} + //================================================================================ // DEVICE ACCESS //================================================================================ @@ -315,6 +409,30 @@ BOOL I2Ci_WriteRegister( I2CSlave id, u8 reg, u8 data ) } return error ? FALSE : TRUE; } +/*---------------------------------------------------------------------------* + Name: I2Ci_WriteRegister16 + + Description: set value to decive register through I2C. + + Arguments: reg : decive register + data : value to be written + + Returns: None + *---------------------------------------------------------------------------*/ +BOOL I2Ci_WriteRegister16( I2CSlave id, u16 reg, u16 data ) +{ + int r; + int error; + for (r = 0; r < RETRY_COUNT; r++) + { + error = 0; + if (I2Ci_SendStart( id ) == FALSE) error++; + if (I2Ci_SendMiddle16( reg ) == FALSE) error++; + if (I2Ci_SendLast16( data ) == FALSE) error++; + if (error == 0) break; + }OS_TPrintf("%s(%d<%d>, %d, %d); => error = %d, r = %d\n", __func__, id, I2C_DeviceAddrTable[id], reg, data, error, r); + return error ? FALSE : TRUE; +} /*---------------------------------------------------------------------------* Name: I2Ci_ReadRegister @@ -366,6 +484,31 @@ u8 I2Ci_ReadRegisterSC( I2CSlave id, u8 reg ) } return error ? (u8)0xee : data; } +/*---------------------------------------------------------------------------* + Name: I2Ci_ReadRegister16 + + Description: get value from decive register through I2C. + + Arguments: reg : decive register + + Returns: value which is read from specified decive register + *---------------------------------------------------------------------------*/ +u16 I2Ci_ReadRegister16( I2CSlave id, u16 reg ) +{ + int r; + u16 data; + int error; + for (r = 0; r < RETRY_COUNT; r++) + { + error = 0; + if (I2Ci_SendStart( id ) == FALSE) error++; + if (I2Ci_SendMiddle16( reg ) == FALSE) error++; + if (I2Ci_ReceiveStart( id ) == FALSE) error++; + data = I2Ci_WaitReceiveLast16(); + if (error == 0) break; + } + return error ? (u16)0xeeee : data; +} /*---------------------------------------------------------------------------* Name: I2Ci_VerifyRegister @@ -396,7 +539,6 @@ BOOL I2Ci_VerifyRegister( I2CSlave id, u8 reg, u8 data ) } return error ? FALSE : (result ? TRUE : FALSE); } - /*---------------------------------------------------------------------------* Name: I2Ci_VerifyRegisterSC @@ -426,6 +568,35 @@ BOOL I2Ci_VerifyRegisterSC( I2CSlave id, u8 reg, u8 data ) } return error ? FALSE : (result ? TRUE : FALSE); } +/*---------------------------------------------------------------------------* + Name: I2Ci_VerifyRegister16 + + Description: get and verify value from decive register through I2C. + + Arguments: reg : decive register + + Returns: value which is read from specified decive register + *---------------------------------------------------------------------------*/ +BOOL I2Ci_VerifyRegister16( I2CSlave id, u16 reg, u16 data ) +{ + int r; + int error; + BOOL result; + for (r = 0; r < RETRY_COUNT; r++) + { + error = 0; + result = TRUE; + if (I2Ci_SendStart( id ) == FALSE) error++; + if (I2Ci_SendMiddle16( reg ) == FALSE) error++; + if (I2Ci_ReceiveStart( id ) == FALSE) error++; + if (data != I2Ci_WaitReceiveLast16()) + { + result = FALSE; + } + if (error == 0) break; + } + return error ? FALSE : (result ? TRUE : FALSE); +} /*---------------------------------------------------------------------------* Name: I2Ci_WriteRegisters @@ -458,6 +629,37 @@ BOOL I2Ci_WriteRegisters( I2CSlave id, u8 reg, const u8 *bufp, size_t size ) } return error ? FALSE : TRUE; } +/*---------------------------------------------------------------------------* + Name: I2Ci_WriteRegisters16 + + Description: set value to decive registers through I2C. + + Arguments: reg : decive register + data : value to be written + + Returns: None + *---------------------------------------------------------------------------*/ +BOOL I2Ci_WriteRegisters16( I2CSlave id, u16 reg, const u16 *bufp, size_t size ) +{ + int i; + int r; + int error; + const u16 *ptr; + for (r = 0; r < RETRY_COUNT; r++) + { + error = 0; + ptr = bufp; + if (I2Ci_SendStart( id ) == FALSE) error++; + if (I2Ci_SendMiddle16( reg ) == FALSE) error++; + for ( i=0; error==0 && i<(size-1); i++ ) + { + if (I2Ci_SendMiddle16( *ptr++ ) == FALSE) error++; + } + if (I2Ci_SendLast16( *ptr++ ) == FALSE) error++; + if (error == 0) break; + } + return error ? FALSE : TRUE; +} /*---------------------------------------------------------------------------* Name: I2Ci_ReadRegisters @@ -497,7 +699,6 @@ BOOL I2Ci_ReadRegisters( I2CSlave id, u8 reg, u8 *bufp, size_t size ) } return error ? FALSE : TRUE; } - /*---------------------------------------------------------------------------* Name: I2Ci_ReadRegistersSC @@ -536,6 +737,44 @@ BOOL I2Ci_ReadRegistersSC( I2CSlave id, u8 reg, u8 *bufp, size_t size ) } return error ? FALSE : TRUE; } +/*---------------------------------------------------------------------------* + Name: I2Ci_ReadRegisters16 + + Description: get value from decive registers through I2C. + + Arguments: reg : decive register + + Returns: value which is read from specified decive register + *---------------------------------------------------------------------------*/ +BOOL I2Ci_ReadRegisters16( I2CSlave id, u16 reg, u16 *bufp, size_t size ) +{ + int i; + int r; + int error; + u16 *ptr; + for (r = 0; r < RETRY_COUNT; r++) + { + error = 0; + ptr = bufp; + if (I2Ci_SendStart( id ) == FALSE) error++; + if (I2Ci_SendMiddle16( reg ) == FALSE) error++; + if (I2Ci_ReceiveStart( id ) == FALSE) error++; + for ( i=0; error==0 && i<(size-1); i++ ) + { + *ptr++ = I2Ci_WaitReceiveMiddle16(); + } + if (error == 0) + { + *ptr++ = I2Ci_WaitReceiveLast16(); + break; + } + else + { + (void)I2Ci_WaitReceiveLast16(); + } + } + return error ? FALSE : TRUE; +} /*---------------------------------------------------------------------------* Name: I2Ci_VerifyRegisters @@ -575,7 +814,6 @@ BOOL I2Ci_VerifyRegisters( I2CSlave id, u8 reg, const u8 *bufp, size_t size ) } return error ? FALSE : (result ? TRUE : FALSE); } - /*---------------------------------------------------------------------------* Name: I2Ci_VerifyRegistersSC @@ -614,6 +852,44 @@ BOOL I2Ci_VerifyRegistersSC( I2CSlave id, u8 reg, const u8 *bufp, size_t size ) } return error ? FALSE : (result ? TRUE : FALSE); } +/*---------------------------------------------------------------------------* + Name: I2Ci_VerifyRegisters16 + + Description: get and verify value from decive registers through I2C. + + Arguments: reg : decive register + + Returns: value which is read from specified decive register + *---------------------------------------------------------------------------*/ +BOOL I2Ci_VerifyRegisters16( I2CSlave id, u16 reg, const u16 *bufp, size_t size ) +{ + int i; + int r; + int error; + const u16 *ptr; + BOOL result; + for (r = 0; r < RETRY_COUNT; r++) + { + error = 0; + ptr = bufp; + result = TRUE; + if (I2Ci_SendStart( id ) == FALSE) error++; + if (I2Ci_SendMiddle16( reg ) == FALSE) error++; + if (I2Ci_ReceiveStart( id ) == FALSE) error++; + for ( i=0; error==0 && result!=FALSE && i<(size-1); i++ ) + { + if (*ptr++ != I2Ci_WaitReceiveMiddle16()) { + result = FALSE; + } + } + if (*ptr++ != I2Ci_WaitReceiveLast16()) + { + result = FALSE; + } + if (error == 0) break; + } + return error ? FALSE : (result ? TRUE : FALSE); +} #if 0 //================================================================================ diff --git a/build/tests/camera/camera-1/ARM7/src/main.c b/build/tests/camera/camera-1/ARM7/src/main.c index 9463064..c6988c5 100644 --- a/build/tests/camera/camera-1/ARM7/src/main.c +++ b/build/tests/camera/camera-1/ARM7/src/main.c @@ -54,12 +54,6 @@ void TwlSpMain(void) // ヒープ領域設定 heapHandle = InitializeAllocateSystem(); - // カメラ初期化 - CAMERA_Init(THREAD_PRIO_CAMERA); - - // ボタン入力サーチ初期化 - (void)PAD_InitXYButton(); - // 割込み許可 (void)OS_SetIrqFunction(OS_IE_V_BLANK, VBlankIntr); (void)OS_EnableIrqMask(OS_IE_V_BLANK); @@ -67,6 +61,12 @@ void TwlSpMain(void) (void)OS_EnableIrq(); (void)OS_EnableInterrupts(); + // カメラ初期化 + CAMERA_Init(THREAD_PRIO_CAMERA); + + // ボタン入力サーチ初期化 + (void)PAD_InitXYButton(); + // SPI初期化 // SPI_Init(THREAD_PRIO_SPI); diff --git a/build/tests/camera/camera-1/ARM9/src/main.c b/build/tests/camera/camera-1/ARM9/src/main.c index 3cb1260..e681da0 100644 --- a/build/tests/camera/camera-1/ARM9/src/main.c +++ b/build/tests/camera/camera-1/ARM9/src/main.c @@ -39,6 +39,7 @@ void TwlMain() // 初期化 OS_Init(); + OS_InitThread(); GX_Init(); OS_InitTick(); @@ -62,18 +63,21 @@ void TwlMain() // カメラ初期化 CAMERA_Init(); - - CAMERA_SelectCamera(CAMERA_SELECT_FIRST); CAMERA_PowerOn(); - result = CAMERA_I2CInit(); - if (result != CAMERA_RESULT_SUCCESS_TRUE) - OS_TPrintf("CAMERA_I2CInit was failed. (%d)\n", result); - result = CAMERA_I2CPreset(CAMERA_PRESET_VGA_20); - if (result != CAMERA_RESULT_SUCCESS_TRUE) - OS_TPrintf("CAMERA_I2CPreset was failed. (%d)\n", result); - CAMERA_SetCropping(0, 0, 320, 240); - CAMERA_SetTrimmingParamsCenter(WIDTH, HEIGHT, 320, 240); // clipped by camera i/f + result = CAMERA_I2CInit(CAMERA_SELECT_BOTH); + if (result != CAMERA_RESULT_SUCCESS_TRUE) + { + OS_TPrintf("CAMERA_I2CInit was failed. (%d)\n", result); + } + else + { + OS_TPrintf("CAMERA_I2CInit was done.\n"); + CAMERA_PowerOff(); + OS_Terminate(); + } + + CAMERA_SetTrimmingParamsCenter(WIDTH, HEIGHT, 640, 480); // clipped by camera i/f CAMERA_SetTrimming(TRUE); CAMERA_SetOutputFormat(CAMERA_OUTPUT_RGB); CAMERA_SetTransferLines(CAMERA_GET_MAX_LINES(WIDTH)); diff --git a/build/tests/dsp/dsp-jtag/ARM9/src/main.c b/build/tests/dsp/dsp-jtag/ARM9/src/main.c index 26f2536..2f0cb26 100644 --- a/build/tests/dsp/dsp-jtag/ARM9/src/main.c +++ b/build/tests/dsp/dsp-jtag/ARM9/src/main.c @@ -63,7 +63,7 @@ void TwlMain() reg_MI_WRAM_B0 = WRAM_BNK_PACK(MI_WRAM_B_ARM9, MI_WRAM_B_OFS_0KB, TRUE); { vu16* addr = (vu16*)(0x03000000 + (((reg_MI_WRAM_B_MAP & REG_MI_WRAM_B_MAP_START_MASK) >> REG_MI_WRAM_B_MAP_START_SHIFT) << 15)); - // br ##0000, true + // br ##0, true *(addr+0) = 0x4180; *(addr+1) = 0x0000; } diff --git a/include/twl/camera.h b/include/twl/camera.h index d52d00a..b717d32 100644 --- a/include/twl/camera.h +++ b/include/twl/camera.h @@ -22,7 +22,7 @@ #ifdef SDK_ARM7 -#include +#include #include #else diff --git a/include/twl/camera/ARM7/control.h b/include/twl/camera/ARM7/control.h index cea9c48..8ede0da 100644 --- a/include/twl/camera/ARM7/control.h +++ b/include/twl/camera/ARM7/control.h @@ -45,6 +45,8 @@ typedef struct CAMERAWork u64 stack[CAMERA_THREAD_STACK_SIZE / sizeof(u64)]; // CAMERA用スレッドのスタック + CameraSelect camera; // アクティブカメラ + CAMERAPxiCommand command; // コマンド種別 u8 current; // 受信済みデータ個数 (バイト単位) u8 total; // 最終データ個数 (1 + 後続コマンド*3) diff --git a/include/twl/camera/ARM7/i2c.h b/include/twl/camera/ARM7/i2c.h deleted file mode 100644 index d4369e6..0000000 --- a/include/twl/camera/ARM7/i2c.h +++ /dev/null @@ -1,381 +0,0 @@ -/*---------------------------------------------------------------------------* - Project: TwlSDK - camera - File: camera_i2c.h - - Copyright 2007 Nintendo. All rights reserved. - - These coded instructions, statements, and computer programs contain - proprietary information of Nintendo of America Inc. and/or Nintendo - Company Ltd., and are protected by Federal copyright law. They may - not be disclosed to third parties or copied or duplicated in any form, - in whole or in part, without the prior written consent of Nintendo. - - $Log: $ - $NoKeywords: $ - *---------------------------------------------------------------------------*/ -#ifndef TWL_CAMERA_CAMERA_I2CH_ -#define TWL_CAMERA_CAMERA_I2CH_ - -#include -#include -#include - -#define CAMERA_DOES_NOT_SUPPORT_MULTIPLE_IO - -#ifdef _cplusplus -extern "C" { -#endif - -//================================================================================ -// I2C_ ACCESS -//================================================================================ -/*---------------------------------------------------------------------------* - Name: CAMERA_WriteRegister - - Description: set value to decive register through I2C_. - - Arguments: reg : decive register - data : value to be written - - Returns: None - *---------------------------------------------------------------------------*/ -static inline BOOL CAMERAi_WriteRegister( u8 reg, u8 data ) -{ - return I2Ci_WriteRegister( I2C_SLAVE_CAMERA, reg, data ); -} -static inline BOOL CAMERA_WriteRegister( u8 reg, u8 data ) -{ - return I2C_WriteRegister( I2C_SLAVE_CAMERA, reg, data ); -} - -/*---------------------------------------------------------------------------* - Name: CAMERA_ReadRegister - - Description: get value from decive register through I2C_. - - Arguments: reg : decive register - - Returns: value which is read from specified decive register - *---------------------------------------------------------------------------*/ -static inline u8 CAMERAi_ReadRegister( u8 reg ) -{ - return I2Ci_ReadRegisterSC( I2C_SLAVE_CAMERA, reg ); -} -static inline u8 CAMERA_ReadRegister( u8 reg ) -{ - return I2C_ReadRegisterSC( I2C_SLAVE_CAMERA, reg ); -} - -/*---------------------------------------------------------------------------* - Name: CAMERA_WriteRegisters - - Description: set value to decive registers through I2C_. - - Arguments: reg : decive register - data : value to be written - - Returns: None - *---------------------------------------------------------------------------*/ -static inline BOOL CAMERAi_WriteRegisters( u8 reg, const u8 *bufp, size_t size ) -{ -#ifdef CAMERA_DOES_NOT_SUPPORT_MULTIPLE_IO - while ( size > 0 ) - { - if ( FALSE == I2Ci_WriteRegisters( I2C_SLAVE_CAMERA, reg++, bufp++, 1 ) ) - { - break; - } - size--; - } - return (size == 0 ? TRUE : FALSE); -#else - return I2Ci_WriteRegisters( I2C_SLAVE_CAMERA, reg, bufp, size ); -#endif -} -static inline BOOL CAMERA_WriteRegisters( u8 reg, const u8 *bufp, size_t size ) -{ -#ifdef CAMERA_DOES_NOT_SUPPORT_MULTIPLE_IO - (void)I2C_Lock(); - while ( size > 0 ) - { - if ( FALSE == I2Ci_WriteRegisters( I2C_SLAVE_CAMERA, reg++, bufp++, 1 ) ) - { - break; - } - size--; - } - (void)I2C_Unlock(); - return (size == 0 ? TRUE : FALSE); -#else - return I2C_WriteRegisters( I2C_SLAVE_CAMERA, reg, bufp, size ); -#endif -} - -/*---------------------------------------------------------------------------* - Name: CAMERA_ReadRegisters - - Description: get value from decive registers through I2C_. - - Arguments: reg : decive register - - Returns: value which is read from specified decive register - *---------------------------------------------------------------------------*/ -static inline BOOL CAMERAi_ReadRegisters( u8 reg, u8 *bufp, size_t size ) -{ -#ifdef CAMERA_DOES_NOT_SUPPORT_MULTIPLE_IO - while ( size > 0 ) - { - if ( FALSE == I2Ci_ReadRegisters( I2C_SLAVE_CAMERA, reg++, bufp++, 1 ) ) - { - break; - } - size--; - } - return (size == 0 ? TRUE : FALSE); -#else - return I2Ci_ReadRegistersSC( I2C_SLAVE_CAMERA, reg, bufp, size ); -#endif -} -static inline BOOL CAMERA_ReadRegisters( u8 reg, u8 *bufp, size_t size ) -{ -#ifdef CAMERA_DOES_NOT_SUPPORT_MULTIPLE_IO - (void)I2C_Lock(); - while ( size > 0 ) - { - if ( FALSE == I2Ci_ReadRegisters( I2C_SLAVE_CAMERA, reg++, bufp++, 1 ) ) - { - break; - } - size--; - } - (void)I2C_Unlock(); - return (size == 0 ? TRUE : FALSE); -#else - return I2C_ReadRegistersSC( I2C_SLAVE_CAMERA, reg, bufp, size ); -#endif -} - -//================================================================================ -// I2C_ BIT CONTROL -//================================================================================ -/*---------------------------------------------------------------------------* - Name: CAMERA_SetParams - - Description: set control bit to device register - - Arguments: reg : device register - setBits : bits to set - maskBits : bits to mask - - Returns: None - *---------------------------------------------------------------------------*/ -static inline BOOL CAMERAi_SetParams( u8 reg, u8 setBits, u8 maskBits ) -{ - return I2Ci_SetParams( I2C_SLAVE_CAMERA, reg, setBits, maskBits ); -} -static inline BOOL CAMERA_SetParams( u8 reg, u8 setBits, u8 maskBits ) -{ - return I2C_SetParams( I2C_SLAVE_CAMERA, reg, setBits, maskBits ); -} - -/*---------------------------------------------------------------------------* - Name: CAMERA_SetFlags - - Description: set control bit to device register - - Arguments: reg : device register - setBits : bits to set - - Returns: None - *---------------------------------------------------------------------------*/ -static inline BOOL CAMERAi_SetFlags( u8 reg, u8 setBits ) -{ - return CAMERAi_SetParams( reg, setBits, setBits ); -} -static inline BOOL CAMERA_SetFlags( u8 reg, u8 setBits ) -{ - return CAMERA_SetParams( reg, setBits, setBits ); -} - -/*---------------------------------------------------------------------------* - Name: CAMERA_ClearFlags - - Description: clear control bit to device register - - Arguments: reg : device register - clrBits : bits to clear - - Returns: None - *---------------------------------------------------------------------------*/ -static inline BOOL CAMERAi_ClearFlags( u8 reg, u8 clrBits ) -{ - return CAMERAi_SetParams( reg, 0, clrBits ); -} -static inline BOOL CAMERA_ClearFlags( u8 reg, u8 clrBits ) -{ - return CAMERA_SetParams( reg, 0, clrBits ); -} - -//================================================================================ -// I2C_ API -//================================================================================ -#define CAMERA_I2CSetCropping(x, y, w, h) CAMERA_I2CSetCroppingParams(w, h) - -/*---------------------------------------------------------------------------* - Name: CAMERA_I2CSetFlipMode - - Description: set CAMERA's flip mode - - Arguments: mode one of CameraFlipMode to apply - - Returns: TRUE if success - *---------------------------------------------------------------------------*/ -BOOL CAMERA_I2CSetFlipMode(CameraFlipMode mode); - -/*---------------------------------------------------------------------------* - Name: CAMERA_I2CSetSpecialMode - - Description: set CAMERA's special mode - - Arguments: mode one of CameraSpecialMode to apply - - Returns: TRUE if success - *---------------------------------------------------------------------------*/ -BOOL CAMERA_I2CSetSpecialMode(CameraSpecialMode mode); - -/*---------------------------------------------------------------------------* - Name: CAMERA_I2CSetCroppingParams - - Description: set CAMERA_ cropping parameters. - - Arguments: width width of image (up to 640) - height height of image (up to 480) - - Returns: TRUE if success - *---------------------------------------------------------------------------*/ -BOOL CAMERA_I2CSetCroppingParams(u16 width, u16 height); - -/*---------------------------------------------------------------------------* - Name: CAMERA_I2CGetCroppingParams - - Description: get current CAMERA_ cropping parameters. - - Arguments: pWidth address to store the width - pHeight address to store the height - - Returns: TRUE if success - *---------------------------------------------------------------------------*/ -BOOL CAMERA_I2CGetCroppingParams(u16 *pWidth, u16 *pHeight); - -/*---------------------------------------------------------------------------* - Name: CAMERA_I2CPause - - Description: pause to send frame - - Arguments: None - - Returns: TRUE if success - *---------------------------------------------------------------------------*/ -static inline BOOL CAMERA_I2CPause(void) -{ - BOOL result; - (void)I2C_Lock(); - result = CAMERAi_WriteRegister( 0xef, 0x00 ) && - CAMERAi_ClearFlags( 0xde, 0x04 ); - (void)I2C_Unlock(); - return result; -} - -/*---------------------------------------------------------------------------* - Name: CAMERA_I2CResume - - Description: resume from pause state - - Arguments: None - - Returns: TRUE if success - *---------------------------------------------------------------------------*/ -static inline BOOL CAMERA_I2CResume(void) -{ - BOOL result; - (void)I2C_Lock(); - result = CAMERAi_WriteRegister( 0xef, 0x00 ) && - CAMERAi_SetFlags( 0xde, 0x04 ); - (void)I2C_Unlock(); - return result; -} - -/*---------------------------------------------------------------------------* - Name: CAMERA_I2CPreSleep - - Description: pre-sleep - - Arguments: None - - Returns: TRUE if success - *---------------------------------------------------------------------------*/ -static inline BOOL CAMERA_I2CPreSleep(void) -{ - BOOL result; - (void)I2C_Lock(); - // not impremented yet - (void)I2C_Unlock(); - return result; -} - -/*---------------------------------------------------------------------------* - Name: CAMERA_I2CPostSleep - - Description: post-sleep - - Arguments: None - - Returns: TRUE if success - *---------------------------------------------------------------------------*/ -static inline BOOL CAMERA_I2CPostSleep(void) -{ - BOOL result; - (void)I2C_Lock(); - // not impremented yet - (void)I2C_Unlock(); - return result; -} - -/*---------------------------------------------------------------------------* - Name: CAMERA_I2CPreset - - Description: preset CAMERA registers - - Arguments: preset one of CameraPreset - - Returns: TRUE if success - *---------------------------------------------------------------------------*/ -BOOL CAMERA_I2CPreset(CameraPreset preset); - -/*---------------------------------------------------------------------------* - Name: CAMERA_I2CInit - - Description: initialize CAMERA - - Arguments: None - - Returns: TRUE if success - *---------------------------------------------------------------------------*/ -static inline BOOL CAMERA_I2CInit(void) -{ - if (CAMERA_I2CPreset(CAMERA_PRESET_DEFAULT) == FALSE) { - return FALSE; - } - if (CAMERA_I2CSetFlipMode(CAMERA_FLIPMODE_DEFAULT) == FALSE) { - return FALSE; - } - return TRUE; -} - - -#ifdef _cplusplus -} /* extern "C" */ -#endif - -/* TWL_CAMERA_CAMERA_I2CH_ */ -#endif diff --git a/include/twl/camera/ARM7/i2c_common.h b/include/twl/camera/ARM7/i2c_common.h new file mode 100644 index 0000000..23f8216 --- /dev/null +++ b/include/twl/camera/ARM7/i2c_common.h @@ -0,0 +1,262 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - camera + File: i2c_common.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Log: $ + $NoKeywords: $ + *---------------------------------------------------------------------------*/ +#ifndef TWL_CAMERA_I2C_COMMON_H_ +#define TWL_CAMERA_I2C_COMMON_H_ + +#include +#include +#include +#include +#include + +#ifdef _cplusplus +extern "C" { +#endif + +#if 0 +//================================================================================ +// I2C_ ACCESS +//================================================================================ +/*---------------------------------------------------------------------------* + Name: CAMERA_WriteRegister + + Description: set value to decive register through I2C_. + + Arguments: camera : one of CameraSelect + reg : decive register + data : value to be written + + Returns: None + *---------------------------------------------------------------------------*/ +static inline BOOL CAMERAi_WriteRegister( CameraSelect camera, u16 reg, u16 data ) +{ + return cameraType ? CAMERAi_S_WriteRegister(camera, reg, data) + : CAMERAi_M_WriteRegister(camera, reg, data); +} +static inline BOOL CAMERA_WriteRegister( CameraSelect camera, u16 reg, u16 data ) +{ + return cameraType ? CAMERA_S_WriteRegister(camera, reg, data) + : CAMERA_M_WriteRegister(camera, reg, data); +} + +/*---------------------------------------------------------------------------* + Name: CAMERA_ReadRegister + + Description: get value from decive register through I2C_. + + Arguments: camera : one of CameraSelect w/o BOTH + reg : decive register + + Returns: value which is read from specified decive register + *---------------------------------------------------------------------------*/ +static inline u16 CAMERAi_ReadRegister( CameraSelect camera, u16 reg ) +{ + return cameraType ? CAMERAi_S_ReadRegister(camera, reg) + : CAMERAi_M_ReadRegister(camera, reg); +} +static inline u16 CAMERA_ReadRegister( CameraSelect camera, u16 reg ) +{ + return cameraType ? CAMERA_S_ReadRegister(camera, reg) + : CAMERA_M_ReadRegister(camera, reg); +} + +/*---------------------------------------------------------------------------* + Name: CAMERA_WriteRegisters + + Description: set value to decive registers through I2C_. + + Arguments: camera : one of CameraSelect + reg : decive register + bufp : data array to be written + size : data size + + Returns: None + *---------------------------------------------------------------------------*/ +static inline BOOL CAMERAi_WriteRegisters( CameraSelect camera, u16 reg, const u16 *bufp, size_t size ) +{ + return cameraType ? CAMERAi_S_WriteRegisters(camera, reg, bufp, size) + : CAMERAi_M_WriteRegisters(camera, reg, bufp, size); +} +static inline BOOL CAMERA_WriteRegisters( CameraSelect camera, u16 reg, const u16 *bufp, size_t size ) +{ + return cameraType ? CAMERA_S_WriteRegisters(camera, reg, bufp, size) + : CAMERA_M_WriteRegisters(camera, reg, bufp, size); +} + +/*---------------------------------------------------------------------------* + Name: CAMERA_ReadRegisters + + Description: get value from decive registers through I2C_. + + Arguments: camera : one of CameraSelect w/o BOTH + reg : decive register + bufp : data array to be read + size : data size + + Returns: value which is read from specified decive register + *---------------------------------------------------------------------------*/ +static inline BOOL CAMERAi_ReadRegisters( CameraSelect camera, u16 reg, u16 *bufp, size_t size ) +{ + return cameraType ? CAMERAi_S_ReadRegisters(camera, reg, bufp, size) + : CAMERAi_M_ReadRegisters(camera, reg, bufp, size); +} +static inline BOOL CAMERA_ReadRegisters( CameraSelect camera, u16 reg, u16 *bufp, size_t size ) +{ + return cameraType ? CAMERA_S_ReadRegisters(camera, reg, bufp, size) + : CAMERA_M_ReadRegisters(camera, reg, bufp, size); +} + +//================================================================================ +// I2C_ BIT CONTROL +//================================================================================ +/*---------------------------------------------------------------------------* + Name: CAMERA_SetParamsM + + Description: set control bit to device register + + Arguments: camera : one of CameraSelect + reg : device register + setBits : bits to set + maskBits : bits to mask + + Returns: None + *---------------------------------------------------------------------------*/ +static inline BOOL CAMERAi_SetParams( CameraSelect camera, u16 reg, u16 setBits, u16 maskBits ) +{ + return cameraType ? CAMERAi_S_SetParams(camera, reg, setBits, maskBits) + : CAMERAi_M_SetParams(camera, reg, setBits, maskBits); +} +static inline BOOL CAMERA_SetParams( CameraSelect camera, u16 reg, u16 setBits, u16 maskBits ) +{ + return cameraType ? CAMERA_S_SetParams(camera, reg, setBits, maskBits) + : CAMERA_M_SetParams(camera, reg, setBits, maskBits); +} + +/*---------------------------------------------------------------------------* + Name: CAMERA_SetFlagsM + + Description: set control bit to device register + + Arguments: camera : one of CameraSelect + reg : device register + setBits : bits to set + + Returns: None + *---------------------------------------------------------------------------*/ +static inline BOOL CAMERAi_SetFlags( CameraSelect camera, u16 reg, u16 setBits ) +{ + return cameraType ? CAMERAi_S_SetFlags(camera, reg, setBits) + : CAMERAi_M_SetFlags(camera, reg, setBits); +} +static inline BOOL CAMERA_SetFlags( CameraSelect camera, u16 reg, u16 setBits ) +{ + return cameraType ? CAMERA_S_SetFlags(camera, reg, setBits) + : CAMERA_M_SetFlags(camera, reg, setBits); +} + +/*---------------------------------------------------------------------------* + Name: CAMERA_ClearFlagsM + + Description: clear control bit to device register + + Arguments: camera : one of CameraSelect + reg : device register + clrBits : bits to clear + + Returns: None + *---------------------------------------------------------------------------*/ +static inline BOOL CAMERAi_ClearFlags( CameraSelect camera, u16 reg, u16 clrBits ) +{ + return cameraType ? CAMERAi_S_ClearFlags(camera, reg, clrBits) + : CAMERAi_M_ClearFlags(camera, reg, clrBits); +} + +static inline BOOL CAMERA_ClearFlags( CameraSelect camera, u16 reg, u16 clrBits ) +{ + return cameraType ? CAMERA_S_ClearFlags(camera, reg, clrBits) + : CAMERA_M_ClearFlags(camera, reg, clrBits); +} +#endif + +//================================================================================ +// I2C_ API +//================================================================================ + +/*---------------------------------------------------------------------------* + Name: CAMERA_I2CInit + + Description: initialize CAMERA + + Arguments: camera : one of CameraSelect + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +BOOL CAMERA_I2CInit(CameraSelect camera); + +/*---------------------------------------------------------------------------* + Name: CAMERA_I2CStandby + + Description: standby or resume CAMERA + + Arguments: camera : one of CameraSelect + standby : TRUE if goto standby mode + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +BOOL CAMERA_I2CStandby(CameraSelect camera, BOOL standby); + +/*---------------------------------------------------------------------------* + Name: CAMERA_I2CResize + + Description: resize CAMERA + + Arguments: camera : one of CameraSelect + width : width of output image + height : height of output image + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +BOOL CAMERA_I2CResize(CameraSelect camera, u16 width, u16 height); + +/*---------------------------------------------------------------------------* + Name: CAMERA_I2CPreSleep + + Description: preset CAMERA registers + + Arguments: camera : one of CameraSelect + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +BOOL CAMERA_I2CPreSleep(CameraSelect camera); + +/*---------------------------------------------------------------------------* + Name: CAMERA_I2CPostSleep + + Description: preset CAMERA registers + + Arguments: camera : one of CameraSelect + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +BOOL CAMERA_I2CPostSleep(CameraSelect camera); + + +#ifdef _cplusplus +} /* extern "C" */ +#endif + +/* TWL_CAMERA_I2C_COMMON_H_ */ +#endif diff --git a/include/twl/camera/ARM7/i2c_micron.h b/include/twl/camera/ARM7/i2c_micron.h new file mode 100644 index 0000000..90467a0 --- /dev/null +++ b/include/twl/camera/ARM7/i2c_micron.h @@ -0,0 +1,447 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - camera + File: i2c_micron.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Log: $ + $NoKeywords: $ + *---------------------------------------------------------------------------*/ +#ifndef TWL_CAMERA_I2C_MICRON_H_ +#define TWL_CAMERA_I2C_MICRON_H_ + +#include +#include +#include + +#define CAMERA_DOES_NOT_SUPPORT_MULTIPLE_IO + +#if 0 + Write時にNONEを指定するとTRUEで返り、Read時にNONEを指定するとFALSEで返る。 + Write時にBOTHを指定すると両方に書き込み、Read時にBOTHを指定するとFALSEで返る。 + SetParams等はWriteと同じ仕様。 +#endif + +#ifdef _cplusplus +extern "C" { +#endif + +//================================================================================ +// I2C_ ACCESS +//================================================================================ +/*---------------------------------------------------------------------------* + Name: CAMERA_M_WriteRegister + + Description: set value to decive register through I2C_. + + Arguments: camera : one of CameraSelect + reg : decive register + data : value to be written + + Returns: None + *---------------------------------------------------------------------------*/ +static inline BOOL CAMERAi_M_WriteRegister( CameraSelect camera, u16 reg, u16 data ) +{ + BOOL rIn = TRUE; + BOOL rOut = TRUE; + if (camera & CAMERA_SELECT_IN) + { + rIn = I2Ci_WriteRegister16( I2C_SLAVE_CAMERA_MICRON_IN, reg, data ); + } + if (camera & CAMERA_SELECT_OUT) + { + rOut = I2Ci_WriteRegister16( I2C_SLAVE_CAMERA_MICRON_OUT, reg, data ); + } + return (rIn && rOut); +} +static inline BOOL CAMERA_M_WriteRegister( CameraSelect camera, u16 reg, u16 data ) +{ + BOOL rIn = TRUE; + BOOL rOut = TRUE; + if (camera & CAMERA_SELECT_IN) + { + rIn = I2C_WriteRegister16( I2C_SLAVE_CAMERA_MICRON_IN, reg, data ); + } + if (camera & CAMERA_SELECT_OUT) + { + rOut = I2C_WriteRegister16( I2C_SLAVE_CAMERA_MICRON_OUT, reg, data ); + } + return (rIn && rOut); +} + +/*---------------------------------------------------------------------------* + Name: CAMERA_M_ReadRegister + + Description: get value from decive register through I2C_. + + Arguments: camera : one of CameraSelect w/o BOTH + reg : decive register + + Returns: value which is read from specified decive register + *---------------------------------------------------------------------------*/ +static inline u16 CAMERAi_M_ReadRegister( CameraSelect camera, u16 reg ) +{ + switch (camera) + { + case CAMERA_SELECT_IN: + return I2Ci_ReadRegister16( I2C_SLAVE_CAMERA_MICRON_IN, reg ); + case CAMERA_SELECT_OUT: + return I2Ci_ReadRegister16( I2C_SLAVE_CAMERA_MICRON_OUT, reg ); + } + return FALSE; +} +static inline u16 CAMERA_M_ReadRegister( CameraSelect camera, u16 reg ) +{ + switch (camera) + { + case CAMERA_SELECT_IN: + return I2C_ReadRegister16( I2C_SLAVE_CAMERA_MICRON_IN, reg ); + case CAMERA_SELECT_OUT: + return I2C_ReadRegister16( I2C_SLAVE_CAMERA_MICRON_OUT, reg ); + } + return FALSE; +} + +/*---------------------------------------------------------------------------* + Name: CAMERA_M_WriteRegisters + + Description: set value to decive registers through I2C_. + + Arguments: camera : one of CameraSelect + reg : decive register + bufp : data array to be written + size : data size + + Returns: None + *---------------------------------------------------------------------------*/ +static inline BOOL CAMERAi_M_WriteRegisters( CameraSelect camera, u16 reg, const u16 *bufp, size_t size ) +{ + BOOL rIn = TRUE; + BOOL rOut = TRUE; + if (camera & CAMERA_SELECT_IN) + { +#ifdef CAMERA_DOES_NOT_SUPPORT_MULTIPLE_IO + while ( size > 0 ) + { + if ( FALSE == I2Ci_WriteRegisters16( I2C_SLAVE_CAMERA_MICRON_IN, reg++, bufp++, 1 ) ) + { + break; + } + size--; + } + rIn = (size == 0 ? TRUE : FALSE); +#else + rIn = I2Ci_WriteRegisters16( I2C_SLAVE_CAMERA_MICRON_IN, reg, bufp, size ); +#endif + } + if (camera & CAMERA_SELECT_OUT) + { +#ifdef CAMERA_DOES_NOT_SUPPORT_MULTIPLE_IO + while ( size > 0 ) + { + if ( FALSE == I2Ci_WriteRegisters16( I2C_SLAVE_CAMERA_MICRON_OUT, reg++, bufp++, 1 ) ) + { + break; + } + size--; + } + rOut = (size == 0 ? TRUE : FALSE); +#else + rOut = I2Ci_WriteRegisters16( I2C_SLAVE_CAMERA_MICRON_OUT, reg, bufp, size ); +#endif + } + return (rIn && rOut); +} +static inline BOOL CAMERA_M_WriteRegisters( CameraSelect camera, u16 reg, const u16 *bufp, size_t size ) +{ + BOOL rIn = TRUE; + BOOL rOut = TRUE; + if (camera & CAMERA_SELECT_IN) + { +#ifdef CAMERA_DOES_NOT_SUPPORT_MULTIPLE_IO + (void)I2C_Lock(); + while ( size > 0 ) + { + if ( FALSE == I2Ci_WriteRegisters16( I2C_SLAVE_CAMERA_MICRON_IN, reg++, bufp++, 1 ) ) + { + break; + } + size--; + } + (void)I2C_Unlock(); + rIn = (size == 0 ? TRUE : FALSE); +#else + rOut = I2C_WriteRegisters16( I2C_SLAVE_CAMERA_MICRON_IN, reg, bufp, size ); +#endif + } + if (camera & CAMERA_SELECT_OUT) + { +#ifdef CAMERA_DOES_NOT_SUPPORT_MULTIPLE_IO + (void)I2C_Lock(); + while ( size > 0 ) + { + if ( FALSE == I2Ci_WriteRegisters16( I2C_SLAVE_CAMERA_MICRON_OUT, reg++, bufp++, 1 ) ) + { + break; + } + size--; + } + (void)I2C_Unlock(); + rOut = (size == 0 ? TRUE : FALSE); +#else + rOut = I2C_WriteRegisters16( I2C_SLAVE_CAMERA_MICRON_OUT, reg, bufp, size ); +#endif + } + return (rIn && rOut); +} + +/*---------------------------------------------------------------------------* + Name: CAMERA_M_ReadRegisters + + Description: get value from decive registers through I2C_. + + Arguments: camera : one of CameraSelect w/o BOTH + reg : decive register + bufp : data array to be read + size : data size + + Returns: value which is read from specified decive register + *---------------------------------------------------------------------------*/ +static inline BOOL CAMERAi_M_ReadRegisters( CameraSelect camera, u16 reg, u16 *bufp, size_t size ) +{ +#ifdef CAMERA_DOES_NOT_SUPPORT_MULTIPLE_IO + switch (camera) + { + case CAMERA_SELECT_IN: + while ( size > 0 ) + { + if ( FALSE == I2Ci_ReadRegisters16( I2C_SLAVE_CAMERA_MICRON_IN, reg++, bufp++, 1 ) ) + { + break; + } + size--; + } + break; + case CAMERA_SELECT_OUT: + while ( size > 0 ) + { + if ( FALSE == I2Ci_ReadRegisters16( I2C_SLAVE_CAMERA_MICRON_OUT, reg++, bufp++, 1 ) ) + { + break; + } + size--; + } + break; + } + return (size == 0 ? TRUE : FALSE); +#else + switch (camera) + { + case CAMERA_SELECT_IN: + return I2Ci_ReadRegisters16( I2C_SLAVE_CAMERA_MICRON_IN, reg, bufp, size ); + case CAMERA_SELECT_OUT: + return I2Ci_ReadRegisters16( I2C_SLAVE_CAMERA_MICRON_OUT, reg, bufp, size ); + } + return FALSE; +#endif +} +static inline BOOL CAMERA_M_ReadRegisters( CameraSelect camera, u16 reg, u16 *bufp, size_t size ) +{ +#ifdef CAMERA_DOES_NOT_SUPPORT_MULTIPLE_IO + (void)I2C_Lock(); + switch (camera) + { + case CAMERA_SELECT_IN: + while ( size > 0 ) + { + if ( FALSE == I2Ci_ReadRegisters16( I2C_SLAVE_CAMERA_MICRON_IN, reg++, bufp++, 1 ) ) + { + break; + } + size--; + } + break; + case CAMERA_SELECT_OUT: + while ( size > 0 ) + { + if ( FALSE == I2Ci_ReadRegisters16( I2C_SLAVE_CAMERA_MICRON_OUT, reg++, bufp++, 1 ) ) + { + break; + } + size--; + } + break; + } + (void)I2C_Unlock(); + return (size == 0 ? TRUE : FALSE); +#else + switch (camera) + { + case CAMERA_SELECT_IN: + return I2C_ReadRegisters16( I2C_SLAVE_CAMERA_MICRON_IN, reg, bufp, size ); + case CAMERA_SELECT_OUT: + return I2C_ReadRegisters16( I2C_SLAVE_CAMERA_MICRON_OUT, reg, bufp, size ); + } + return FALSE; +#endif +} + +//================================================================================ +// I2C_ BIT CONTROL +//================================================================================ +/*---------------------------------------------------------------------------* + Name: CAMERA_M_SetParams + + Description: set control bit to device register + + Arguments: camera : one of CameraSelect + reg : device register + setBits : bits to set + maskBits : bits to mask + + Returns: None + *---------------------------------------------------------------------------*/ +static inline BOOL CAMERAi_M_SetParams( CameraSelect camera, u16 reg, u16 setBits, u16 maskBits ) +{ + BOOL rIn = TRUE; + BOOL rOut = TRUE; + if (camera & CAMERA_SELECT_IN) + { + rIn = I2Ci_SetParams16( I2C_SLAVE_CAMERA_MICRON_IN, reg, setBits, maskBits ); + } + if (camera & CAMERA_SELECT_OUT) + { + rOut = I2Ci_SetParams16( I2C_SLAVE_CAMERA_MICRON_OUT, reg, setBits, maskBits ); + } + return (rIn && rOut); +} +static inline BOOL CAMERA_M_SetParams( CameraSelect camera, u16 reg, u16 setBits, u16 maskBits ) +{ + BOOL rIn = TRUE; + BOOL rOut = TRUE; + if (camera & CAMERA_SELECT_IN) + { + rIn = I2C_SetParams16( I2C_SLAVE_CAMERA_MICRON_IN, reg, setBits, maskBits ); + } + if (camera & CAMERA_SELECT_OUT) + { + rOut = I2C_SetParams16( I2C_SLAVE_CAMERA_MICRON_OUT, reg, setBits, maskBits ); + } + return (rIn && rOut); +} + +/*---------------------------------------------------------------------------* + Name: CAMERA_M_SetFlags + + Description: set control bit to device register + + Arguments: camera : one of CameraSelect + reg : device register + setBits : bits to set + + Returns: None + *---------------------------------------------------------------------------*/ +static inline BOOL CAMERAi_M_SetFlags( CameraSelect camera, u16 reg, u16 setBits ) +{ + return CAMERAi_M_SetParams( camera, reg, setBits, setBits ); +} +static inline BOOL CAMERA_M_SetFlags( CameraSelect camera, u16 reg, u16 setBits ) +{ + return CAMERA_M_SetParams( camera, reg, setBits, setBits ); +} + +/*---------------------------------------------------------------------------* + Name: CAMERA_M_ClearFlags + + Description: clear control bit to device register + + Arguments: camera : one of CameraSelect + reg : device register + clrBits : bits to clear + + Returns: None + *---------------------------------------------------------------------------*/ +static inline BOOL CAMERAi_M_ClearFlags( CameraSelect camera, u16 reg, u16 clrBits ) +{ + return CAMERAi_M_SetParams( camera, reg, 0, clrBits ); +} +static inline BOOL CAMERA_M_ClearFlags( CameraSelect camera, u16 reg, u16 clrBits ) +{ + return CAMERA_M_SetParams( camera, reg, 0, clrBits ); +} + + +//================================================================================ +// I2C_ API +//================================================================================ +/*---------------------------------------------------------------------------* + Name: CAMERA_M_I2CInit + + Description: initialize CAMERA + + Arguments: camera : one of CameraSelect + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +BOOL CAMERA_M_I2CInit(CameraSelect camera); + +/*---------------------------------------------------------------------------* + Name: CAMERA_M_I2CStandby + + Description: standby or resume CAMERA + + Arguments: camera : one of CameraSelect + standby : TRUE if goto standby mode + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +BOOL CAMERA_M_I2CStandby(CameraSelect camera, BOOL standby); + +/*---------------------------------------------------------------------------* + Name: CAMERA_M_I2CResize + + Description: resize CAMERA + + Arguments: camera : one of CameraSelect + width : width of output image + height : height of output image + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +BOOL CAMERA_M_I2CResize(CameraSelect camera, u16 width, u16 height); + +/*---------------------------------------------------------------------------* + Name: CAMERA_M_I2CPreSleep + + Description: preset CAMERA registers + + Arguments: camera : one of CameraSelect + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +BOOL CAMERA_M_I2CPreSleep(CameraSelect camera); + +/*---------------------------------------------------------------------------* + Name: CAMERA_M_I2CPostSleep + + Description: preset CAMERA registers + + Arguments: camera : one of CameraSelect + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +BOOL CAMERA_M_I2CPostSleep(CameraSelect camera); + + +#ifdef _cplusplus +} /* extern "C" */ +#endif + +/* TWL_CAMERA_I2C_MICRON_H_ */ +#endif diff --git a/include/twl/camera/ARM7/i2c_samsung.h b/include/twl/camera/ARM7/i2c_samsung.h new file mode 100644 index 0000000..cc4768b --- /dev/null +++ b/include/twl/camera/ARM7/i2c_samsung.h @@ -0,0 +1,546 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - camera + File: camera_i2c.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Log: $ + $NoKeywords: $ + *---------------------------------------------------------------------------*/ +#ifndef TWL_CAMERA_CAMERA_I2CH_ +#define TWL_CAMERA_CAMERA_I2CH_ + +#include +#include +#include + +#define CAMERA_DOES_NOT_SUPPORT_MULTIPLE_IO + +#if 0 + Write時にNONEを指定するとTRUEで返り、Read時にNONEを指定するとFALSEで返る。 + Write時にBOTHを指定すると両方に書き込み、Read時にBOTHを指定するとFALSEで返る。 + SetParams等はWriteと同じ仕様。 +#endif + +#ifdef _cplusplus +extern "C" { +#endif + +//================================================================================ +// I2C_ ACCESS +//================================================================================ +/*---------------------------------------------------------------------------* + Name: CAMERA_WriteRegister + + Description: set value to decive register through I2C_. + + Arguments: camera : one of CameraSelect + reg : decive register + data : value to be written + + Returns: None + *---------------------------------------------------------------------------*/ +static inline BOOL CAMERAi_WriteRegister( CameraSelect camera, u8 reg, u8 data ) +{ + BOOL rIn = TRUE; + BOOL rOut = TRUE; + if (camera & CAMERA_SELECT_IN) + { + rIn = I2Ci_WriteRegister( I2C_SLAVE_CAMERA_IN, reg, data ); + } + if (camera & CAMERA_SELECT_OUT) + { + rOut = I2Ci_WriteRegister( I2C_SLAVE_CAMERA_OUT, reg, data ); + } + return (rIn && rOut); +} +static inline BOOL CAMERA_WriteRegister( CameraSelect camera, u8 reg, u8 data ) +{ + BOOL rIn = TRUE; + BOOL rOut = TRUE; + if (camera & CAMERA_SELECT_IN) + { + rIn = I2C_WriteRegister( I2C_SLAVE_CAMERA_IN, reg, data ); + } + if (camera & CAMERA_SELECT_OUT) + { + rOut = I2C_WriteRegister( I2C_SLAVE_CAMERA_OUT, reg, data ); + } + return (rIn && rOut); +} + +/*---------------------------------------------------------------------------* + Name: CAMERA_ReadRegister + + Description: get value from decive register through I2C_. + + Arguments: camera : one of CameraSelect w/o BOTH + reg : decive register + + Returns: value which is read from specified decive register + *---------------------------------------------------------------------------*/ +static inline u8 CAMERAi_ReadRegister( CameraSelect camera, u8 reg ) +{ + switch (camera) + { + case CAMERA_SELECT_IN: + return I2Ci_ReadRegisterSC( I2C_SLAVE_CAMERA_IN, reg ); + case CAMERA_SELECT_OUT: + return I2Ci_ReadRegisterSC( I2C_SLAVE_CAMERA_OUT, reg ); + } + return FALSE; +} +static inline u8 CAMERA_ReadRegister( CameraSelect camera, u8 reg ) +{ + switch (camera) + { + case CAMERA_SELECT_IN: + return I2C_ReadRegisterSC( I2C_SLAVE_CAMERA_IN, reg ); + case CAMERA_SELECT_OUT: + return I2C_ReadRegisterSC( I2C_SLAVE_CAMERA_OUT, reg ); + } + return FALSE; +} + +/*---------------------------------------------------------------------------* + Name: CAMERA_WriteRegisters + + Description: set value to decive registers through I2C_. + + Arguments: camera : one of CameraSelect + reg : decive register + bufp : data array to be written + size : data size + + Returns: None + *---------------------------------------------------------------------------*/ +static inline BOOL CAMERAi_WriteRegisters( CameraSelect camera, u8 reg, const u8 *bufp, size_t size ) +{ + BOOL rIn = TRUE; + BOOL rOut = TRUE; + if (camera & CAMERA_SELECT_IN) + { +#ifdef CAMERA_DOES_NOT_SUPPORT_MULTIPLE_IO + while ( size > 0 ) + { + if ( FALSE == I2Ci_WriteRegisters( I2C_SLAVE_CAMERA_IN, reg++, bufp++, 1 ) ) + { + break; + } + size--; + } + rIn = (size == 0 ? TRUE : FALSE); +#else + rIn = I2Ci_WriteRegisters( I2C_SLAVE_CAMERA_IN, reg, bufp, size ); +#endif + } + if (camera & CAMERA_SELECT_OUT) + { +#ifdef CAMERA_DOES_NOT_SUPPORT_MULTIPLE_IO + while ( size > 0 ) + { + if ( FALSE == I2Ci_WriteRegisters( I2C_SLAVE_CAMERA_OUT, reg++, bufp++, 1 ) ) + { + break; + } + size--; + } + rOut = (size == 0 ? TRUE : FALSE); +#else + rOut = I2Ci_WriteRegisters( I2C_SLAVE_CAMERA_OUT, reg, bufp, size ); +#endif + } + return (rIn && rOut); +} +static inline BOOL CAMERA_WriteRegisters( CameraSelect camera, u8 reg, const u8 *bufp, size_t size ) +{ + BOOL rIn = TRUE; + BOOL rOut = TRUE; + if (camera & CAMERA_SELECT_IN) + { +#ifdef CAMERA_DOES_NOT_SUPPORT_MULTIPLE_IO + (void)I2C_Lock(); + while ( size > 0 ) + { + if ( FALSE == I2Ci_WriteRegisters( I2C_SLAVE_CAMERA_IN, reg++, bufp++, 1 ) ) + { + break; + } + size--; + } + (void)I2C_Unlock(); + rIn = (size == 0 ? TRUE : FALSE); +#else + rOut = I2C_WriteRegisters( I2C_SLAVE_CAMERA_IN, reg, bufp, size ); +#endif + } + if (camera & CAMERA_SELECT_OUT) + { +#ifdef CAMERA_DOES_NOT_SUPPORT_MULTIPLE_IO + (void)I2C_Lock(); + while ( size > 0 ) + { + if ( FALSE == I2Ci_WriteRegisters( I2C_SLAVE_CAMERA_OUT, reg++, bufp++, 1 ) ) + { + break; + } + size--; + } + (void)I2C_Unlock(); + rOut = (size == 0 ? TRUE : FALSE); +#else + rOut = I2C_WriteRegisters( I2C_SLAVE_CAMERA_OUT, reg, bufp, size ); +#endif + } + return (rIn && rOut); +} + +/*---------------------------------------------------------------------------* + Name: CAMERA_ReadRegisters + + Description: get value from decive registers through I2C_. + + Arguments: camera : one of CameraSelect w/o BOTH + reg : decive register + bufp : data array to be read + size : data size + + Returns: value which is read from specified decive register + *---------------------------------------------------------------------------*/ +static inline BOOL CAMERAi_ReadRegisters( CameraSelect camera, u8 reg, u8 *bufp, size_t size ) +{ +#ifdef CAMERA_DOES_NOT_SUPPORT_MULTIPLE_IO + switch (camera) + { + case CAMERA_SELECT_IN: + while ( size > 0 ) + { + if ( FALSE == I2Ci_ReadRegistersSC( I2C_SLAVE_CAMERA_IN, reg++, bufp++, 1 ) ) + { + break; + } + size--; + } + break; + case CAMERA_SELECT_OUT: + while ( size > 0 ) + { + if ( FALSE == I2Ci_ReadRegistersSC( I2C_SLAVE_CAMERA_OUT, reg++, bufp++, 1 ) ) + { + break; + } + size--; + } + break; + } + return (size == 0 ? TRUE : FALSE); +#else + switch (camera) + { + case CAMERA_SELECT_IN: + return I2Ci_ReadRegistersSC( I2C_SLAVE_CAMERA_IN, reg, bufp, size ); + case CAMERA_SELECT_OUT: + return I2Ci_ReadRegistersSC( I2C_SLAVE_CAMERA_OUT, reg, bufp, size ); + } + return FALSE; +#endif +} +static inline BOOL CAMERA_ReadRegisters( CameraSelect camera, u8 reg, u8 *bufp, size_t size ) +{ +#ifdef CAMERA_DOES_NOT_SUPPORT_MULTIPLE_IO + (void)I2C_Lock(); + switch (camera) + { + case CAMERA_SELECT_IN: + while ( size > 0 ) + { + if ( FALSE == I2Ci_ReadRegistersSC( I2C_SLAVE_CAMERA_IN, reg++, bufp++, 1 ) ) + { + break; + } + size--; + } + break; + case CAMERA_SELECT_OUT: + while ( size > 0 ) + { + if ( FALSE == I2Ci_ReadRegistersSC( I2C_SLAVE_CAMERA_OUT, reg++, bufp++, 1 ) ) + { + break; + } + size--; + } + break; + } + (void)I2C_Unlock(); + return (size == 0 ? TRUE : FALSE); +#else + switch (camera) + { + case CAMERA_SELECT_IN: + return I2C_ReadRegistersSC( I2C_SLAVE_CAMERA_IN, reg, bufp, size ); + case CAMERA_SELECT_OUT: + return I2C_ReadRegistersSC( I2C_SLAVE_CAMERA_OUT, reg, bufp, size ); + } + return FALSE; +#endif +} + +//================================================================================ +// I2C_ BIT CONTROL +//================================================================================ +/*---------------------------------------------------------------------------* + Name: CAMERA_SetParams + + Description: set control bit to device register + + Arguments: camera : one of CameraSelect + reg : device register + setBits : bits to set + maskBits : bits to mask + + Returns: None + *---------------------------------------------------------------------------*/ +static inline BOOL CAMERAi_SetParams( CameraSelect camera, u8 reg, u8 setBits, u8 maskBits ) +{ + BOOL rIn = TRUE; + BOOL rOut = TRUE; + if (camera & CAMERA_SELECT_IN) + { + rIn = I2Ci_SetParams( I2C_SLAVE_CAMERA_IN, reg, setBits, maskBits ); + } + if (camera & CAMERA_SELECT_OUT) + { + rOut = I2Ci_SetParams( I2C_SLAVE_CAMERA_OUT, reg, setBits, maskBits ); + } + return (rIn && rOut); +} +static inline BOOL CAMERA_SetParams( CameraSelect camera, u8 reg, u8 setBits, u8 maskBits ) +{ + BOOL rIn = TRUE; + BOOL rOut = TRUE; + if (camera & CAMERA_SELECT_IN) + { + rIn = I2C_SetParams( I2C_SLAVE_CAMERA_IN, reg, setBits, maskBits ); + } + if (camera & CAMERA_SELECT_OUT) + { + rOut = I2C_SetParams( I2C_SLAVE_CAMERA_OUT, reg, setBits, maskBits ); + } + return (rIn && rOut); +} + +/*---------------------------------------------------------------------------* + Name: CAMERA_SetFlags + + Description: set control bit to device register + + Arguments: camera : one of CameraSelect + reg : device register + setBits : bits to set + + Returns: None + *---------------------------------------------------------------------------*/ +static inline BOOL CAMERAi_SetFlags( CameraSelect camera, u8 reg, u8 setBits ) +{ + return CAMERAi_SetParams( camera, reg, setBits, setBits ); +} +static inline BOOL CAMERA_SetFlags( CameraSelect camera, u8 reg, u8 setBits ) +{ + return CAMERA_SetParams( camera, reg, setBits, setBits ); +} + +/*---------------------------------------------------------------------------* + Name: CAMERA_ClearFlags + + Description: clear control bit to device register + + Arguments: camera : one of CameraSelect + reg : device register + clrBits : bits to clear + + Returns: None + *---------------------------------------------------------------------------*/ +static inline BOOL CAMERAi_ClearFlags( CameraSelect camera, u8 reg, u8 clrBits ) +{ + return CAMERAi_SetParams( camera, reg, 0, clrBits ); +} +static inline BOOL CAMERA_ClearFlags( CameraSelect camera, u8 reg, u8 clrBits ) +{ + return CAMERA_SetParams( camera, reg, 0, clrBits ); +} + +//================================================================================ +// I2C_ API +//================================================================================ +#define CAMERA_I2CSetCropping(c, x, y, w, h) CAMERA_I2CSetCroppingParams(c, w, h) + +/*---------------------------------------------------------------------------* + Name: CAMERA_I2CSetFlipMode + + Description: set CAMERA's flip mode + + Arguments: camera : one of CameraSelect + mode : one of CameraFlipMode to apply + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +BOOL CAMERA_I2CSetFlipMode(CameraSelect camera, CameraFlipMode mode); + +/*---------------------------------------------------------------------------* + Name: CAMERA_I2CSetSpecialMode + + Description: set CAMERA's special mode + + Arguments: camera : one of CameraSelect + mode : one of CameraSpecialMode to apply + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +BOOL CAMERA_I2CSetSpecialMode(CameraSelect camera, CameraSpecialMode mode); + +/*---------------------------------------------------------------------------* + Name: CAMERA_I2CSetCroppingParams + + Description: set CAMERA_ cropping parameters. + + Arguments: camera : one of CameraSelect + width : width of image (up to 640) + height : height of image (up to 480) + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +BOOL CAMERA_I2CSetCroppingParams(CameraSelect camera, u16 width, u16 height); + +/*---------------------------------------------------------------------------* + Name: CAMERA_I2CGetCroppingParams + + Description: get current CAMERA_ cropping parameters. + + Arguments: camera : one of CameraSelect + pWidth : address to store the width + pHeight : address to store the height + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +BOOL CAMERA_I2CGetCroppingParams(CameraSelect camera, u16 *pWidth, u16 *pHeight); + +/*---------------------------------------------------------------------------* + Name: CAMERA_I2CPause + + Description: pause to send frame + + Arguments: camera : one of CameraSelect + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +static inline BOOL CAMERA_I2CPause(CameraSelect camera) +{ + BOOL result; + (void)I2C_Lock(); + result = CAMERAi_WriteRegister( camera, 0xef, 0x00 ) && + CAMERAi_ClearFlags( camera, 0xde, 0x04 ); + (void)I2C_Unlock(); + return result; +} + +/*---------------------------------------------------------------------------* + Name: CAMERA_I2CResume + + Description: resume from pause state + + Arguments: camera : one of CameraSelect + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +static inline BOOL CAMERA_I2CResume(CameraSelect camera) +{ + BOOL result; + (void)I2C_Lock(); + result = CAMERAi_WriteRegister( camera, 0xef, 0x00 ) && + CAMERAi_SetFlags( camera, 0xde, 0x04 ); + (void)I2C_Unlock(); + return result; +} + +/*---------------------------------------------------------------------------* + Name: CAMERA_I2CPreSleep + + Description: pre-sleep + + Arguments: camera : one of CameraSelect + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +static inline BOOL CAMERA_I2CPreSleep(CameraSelect camera) +{ + BOOL result; + (void)I2C_Lock(); + (void)camera; // not impremented yet + (void)I2C_Unlock(); + return result; +} + +/*---------------------------------------------------------------------------* + Name: CAMERA_I2CPostSleep + + Description: post-sleep + + Arguments: camera : one of CameraSelect + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +static inline BOOL CAMERA_I2CPostSleep(CameraSelect camera) +{ + BOOL result; + (void)I2C_Lock(); + (void)camera; // not impremented yet + (void)I2C_Unlock(); + return result; +} + +/*---------------------------------------------------------------------------* + Name: CAMERA_I2CPreset + + Description: preset CAMERA registers + + Arguments: camera : one of CameraSelect + preset : one of CameraPreset + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +BOOL CAMERA_I2CPreset(CameraSelect camera, CameraPreset preset); + +/*---------------------------------------------------------------------------* + Name: CAMERA_I2CInit + + Description: initialize CAMERA + + Arguments: camera : one of CameraSelect + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +static inline BOOL CAMERA_I2CInit(CameraSelect camera) +{ + if (CAMERA_I2CPreset(camera, CAMERA_PRESET_DEFAULT) == FALSE) { + return FALSE; + } + if (CAMERA_I2CSetFlipMode(camera, CAMERA_FLIPMODE_DEFAULT) == FALSE) { + return FALSE; + } + return TRUE; +} + + +#ifdef _cplusplus +} /* extern "C" */ +#endif + +/* TWL_CAMERA_CAMERA_I2CH_ */ +#endif diff --git a/include/twl/camera/ARM7/i2c_sharp.h b/include/twl/camera/ARM7/i2c_sharp.h new file mode 100644 index 0000000..6120863 --- /dev/null +++ b/include/twl/camera/ARM7/i2c_sharp.h @@ -0,0 +1,447 @@ +/*---------------------------------------------------------------------------* + Project: TwlSDK - camera + File: i2c_sharp.h + + Copyright 2007 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + + $Log: $ + $NoKeywords: $ + *---------------------------------------------------------------------------*/ +#ifndef TWL_CAMERA_I2C_SHARP_H_ +#define TWL_CAMERA_I2C_SHARP_H_ + +#include +#include +#include + +#define CAMERA_DOES_NOT_SUPPORT_MULTIPLE_IO + +#if 0 + Write時にNONEを指定するとTRUEで返り、Read時にNONEを指定するとFALSEで返る。 + Write時にBOTHを指定すると両方に書き込み、Read時にBOTHを指定するとFALSEで返る。 + SetParams等はWriteと同じ仕様。 +#endif + +#ifdef _cplusplus +extern "C" { +#endif + +//================================================================================ +// I2C_ ACCESS +//================================================================================ +/*---------------------------------------------------------------------------* + Name: CAMERA_S_WriteRegister + + Description: set value to decive register through I2C_. + + Arguments: camera : one of CameraSelect + reg : decive register + data : value to be written + + Returns: None + *---------------------------------------------------------------------------*/ +static inline BOOL CAMERAi_S_WriteRegister( CameraSelect camera, u8 reg, u8 data ) +{ + BOOL rIn = TRUE; + BOOL rOut = TRUE; + if (camera & CAMERA_SELECT_IN) + { + rIn = I2Ci_WriteRegister( I2C_SLAVE_CAMERA_MICRON_IN, reg, data ); + } + if (camera & CAMERA_SELECT_OUT) + { + rOut = I2Ci_WriteRegister( I2C_SLAVE_CAMERA_MICRON_OUT, reg, data ); + } + return (rIn && rOut); +} +static inline BOOL CAMERA_S_WriteRegister( CameraSelect camera, u8 reg, u8 data ) +{ + BOOL rIn = TRUE; + BOOL rOut = TRUE; + if (camera & CAMERA_SELECT_IN) + { + rIn = I2C_WriteRegister( I2C_SLAVE_CAMERA_MICRON_IN, reg, data ); + } + if (camera & CAMERA_SELECT_OUT) + { + rOut = I2C_WriteRegister( I2C_SLAVE_CAMERA_MICRON_OUT, reg, data ); + } + return (rIn && rOut); +} + +/*---------------------------------------------------------------------------* + Name: CAMERA_S_ReadRegister + + Description: get value from decive register through I2C_. + + Arguments: camera : one of CameraSelect w/o BOTH + reg : decive register + + Returns: value which is read from specified decive register + *---------------------------------------------------------------------------*/ +static inline u8 CAMERAi_S_ReadRegister( CameraSelect camera, u8 reg ) +{ + switch (camera) + { + case CAMERA_SELECT_IN: + return I2Ci_ReadRegister( I2C_SLAVE_CAMERA_MICRON_IN, reg ); + case CAMERA_SELECT_OUT: + return I2Ci_ReadRegister( I2C_SLAVE_CAMERA_MICRON_OUT, reg ); + } + return FALSE; +} +static inline u8 CAMERA_S_ReadRegister( CameraSelect camera, u8 reg ) +{ + switch (camera) + { + case CAMERA_SELECT_IN: + return I2C_ReadRegister( I2C_SLAVE_CAMERA_MICRON_IN, reg ); + case CAMERA_SELECT_OUT: + return I2C_ReadRegister( I2C_SLAVE_CAMERA_MICRON_OUT, reg ); + } + return FALSE; +} + +/*---------------------------------------------------------------------------* + Name: CAMERA_S_WriteRegisters + + Description: set value to decive registers through I2C_. + + Arguments: camera : one of CameraSelect + reg : decive register + bufp : data array to be written + size : data size + + Returns: None + *---------------------------------------------------------------------------*/ +static inline BOOL CAMERAi_S_WriteRegisters( CameraSelect camera, u8 reg, const u8 *bufp, size_t size ) +{ + BOOL rIn = TRUE; + BOOL rOut = TRUE; + if (camera & CAMERA_SELECT_IN) + { +#ifdef CAMERA_DOES_NOT_SUPPORT_MULTIPLE_IO + while ( size > 0 ) + { + if ( FALSE == I2Ci_WriteRegisters( I2C_SLAVE_CAMERA_MICRON_IN, reg++, bufp++, 1 ) ) + { + break; + } + size--; + } + rIn = (size == 0 ? TRUE : FALSE); +#else + rIn = I2Ci_WriteRegisters( I2C_SLAVE_CAMERA_MICRON_IN, reg, bufp, size ); +#endif + } + if (camera & CAMERA_SELECT_OUT) + { +#ifdef CAMERA_DOES_NOT_SUPPORT_MULTIPLE_IO + while ( size > 0 ) + { + if ( FALSE == I2Ci_WriteRegisters( I2C_SLAVE_CAMERA_MICRON_OUT, reg++, bufp++, 1 ) ) + { + break; + } + size--; + } + rOut = (size == 0 ? TRUE : FALSE); +#else + rOut = I2Ci_WriteRegisters( I2C_SLAVE_CAMERA_MICRON_OUT, reg, bufp, size ); +#endif + } + return (rIn && rOut); +} +static inline BOOL CAMERA_S_WriteRegisters( CameraSelect camera, u8 reg, const u8 *bufp, size_t size ) +{ + BOOL rIn = TRUE; + BOOL rOut = TRUE; + if (camera & CAMERA_SELECT_IN) + { +#ifdef CAMERA_DOES_NOT_SUPPORT_MULTIPLE_IO + (void)I2C_Lock(); + while ( size > 0 ) + { + if ( FALSE == I2Ci_WriteRegisters( I2C_SLAVE_CAMERA_MICRON_IN, reg++, bufp++, 1 ) ) + { + break; + } + size--; + } + (void)I2C_Unlock(); + rIn = (size == 0 ? TRUE : FALSE); +#else + rOut = I2C_WriteRegisters( I2C_SLAVE_CAMERA_MICRON_IN, reg, bufp, size ); +#endif + } + if (camera & CAMERA_SELECT_OUT) + { +#ifdef CAMERA_DOES_NOT_SUPPORT_MULTIPLE_IO + (void)I2C_Lock(); + while ( size > 0 ) + { + if ( FALSE == I2Ci_WriteRegisters( I2C_SLAVE_CAMERA_MICRON_OUT, reg++, bufp++, 1 ) ) + { + break; + } + size--; + } + (void)I2C_Unlock(); + rOut = (size == 0 ? TRUE : FALSE); +#else + rOut = I2C_WriteRegisters( I2C_SLAVE_CAMERA_MICRON_OUT, reg, bufp, size ); +#endif + } + return (rIn && rOut); +} + +/*---------------------------------------------------------------------------* + Name: CAMERA_S_ReadRegisters + + Description: get value from decive registers through I2C_. + + Arguments: camera : one of CameraSelect w/o BOTH + reg : decive register + bufp : data array to be read + size : data size + + Returns: value which is read from specified decive register + *---------------------------------------------------------------------------*/ +static inline BOOL CAMERAi_S_ReadRegisters( CameraSelect camera, u8 reg, u8 *bufp, size_t size ) +{ +#ifdef CAMERA_DOES_NOT_SUPPORT_MULTIPLE_IO + switch (camera) + { + case CAMERA_SELECT_IN: + while ( size > 0 ) + { + if ( FALSE == I2Ci_ReadRegisters( I2C_SLAVE_CAMERA_MICRON_IN, reg++, bufp++, 1 ) ) + { + break; + } + size--; + } + break; + case CAMERA_SELECT_OUT: + while ( size > 0 ) + { + if ( FALSE == I2Ci_ReadRegisters( I2C_SLAVE_CAMERA_MICRON_OUT, reg++, bufp++, 1 ) ) + { + break; + } + size--; + } + break; + } + return (size == 0 ? TRUE : FALSE); +#else + switch (camera) + { + case CAMERA_SELECT_IN: + return I2Ci_ReadRegisters( I2C_SLAVE_CAMERA_MICRON_IN, reg, bufp, size ); + case CAMERA_SELECT_OUT: + return I2Ci_ReadRegisters( I2C_SLAVE_CAMERA_MICRON_OUT, reg, bufp, size ); + } + return FALSE; +#endif +} +static inline BOOL CAMERA_S_ReadRegisters( CameraSelect camera, u8 reg, u8 *bufp, size_t size ) +{ +#ifdef CAMERA_DOES_NOT_SUPPORT_MULTIPLE_IO + (void)I2C_Lock(); + switch (camera) + { + case CAMERA_SELECT_IN: + while ( size > 0 ) + { + if ( FALSE == I2Ci_ReadRegisters( I2C_SLAVE_CAMERA_MICRON_IN, reg++, bufp++, 1 ) ) + { + break; + } + size--; + } + break; + case CAMERA_SELECT_OUT: + while ( size > 0 ) + { + if ( FALSE == I2Ci_ReadRegisters( I2C_SLAVE_CAMERA_MICRON_OUT, reg++, bufp++, 1 ) ) + { + break; + } + size--; + } + break; + } + (void)I2C_Unlock(); + return (size == 0 ? TRUE : FALSE); +#else + switch (camera) + { + case CAMERA_SELECT_IN: + return I2C_ReadRegisters( I2C_SLAVE_CAMERA_MICRON_IN, reg, bufp, size ); + case CAMERA_SELECT_OUT: + return I2C_ReadRegisters( I2C_SLAVE_CAMERA_MICRON_OUT, reg, bufp, size ); + } + return FALSE; +#endif +} + +//================================================================================ +// I2C_ BIT CONTROL +//================================================================================ +/*---------------------------------------------------------------------------* + Name: CAMERA_S_SetParams + + Description: set control bit to device register + + Arguments: camera : one of CameraSelect + reg : device register + setBits : bits to set + maskBits : bits to mask + + Returns: None + *---------------------------------------------------------------------------*/ +static inline BOOL CAMERAi_S_SetParams( CameraSelect camera, u8 reg, u8 setBits, u8 maskBits ) +{ + BOOL rIn = TRUE; + BOOL rOut = TRUE; + if (camera & CAMERA_SELECT_IN) + { + rIn = I2Ci_SetParams( I2C_SLAVE_CAMERA_MICRON_IN, reg, setBits, maskBits ); + } + if (camera & CAMERA_SELECT_OUT) + { + rOut = I2Ci_SetParams( I2C_SLAVE_CAMERA_MICRON_OUT, reg, setBits, maskBits ); + } + return (rIn && rOut); +} +static inline BOOL CAMERA_S_SetParams( CameraSelect camera, u8 reg, u8 setBits, u8 maskBits ) +{ + BOOL rIn = TRUE; + BOOL rOut = TRUE; + if (camera & CAMERA_SELECT_IN) + { + rIn = I2C_SetParams( I2C_SLAVE_CAMERA_MICRON_IN, reg, setBits, maskBits ); + } + if (camera & CAMERA_SELECT_OUT) + { + rOut = I2C_SetParams( I2C_SLAVE_CAMERA_MICRON_OUT, reg, setBits, maskBits ); + } + return (rIn && rOut); +} + +/*---------------------------------------------------------------------------* + Name: CAMERA_S_SetFlags + + Description: set control bit to device register + + Arguments: camera : one of CameraSelect + reg : device register + setBits : bits to set + + Returns: None + *---------------------------------------------------------------------------*/ +static inline BOOL CAMERAi_S_SetFlags( CameraSelect camera, u8 reg, u8 setBits ) +{ + return CAMERAi_S_SetParams( camera, reg, setBits, setBits ); +} +static inline BOOL CAMERA_S_SetFlags( CameraSelect camera, u8 reg, u8 setBits ) +{ + return CAMERA_S_SetParams( camera, reg, setBits, setBits ); +} + +/*---------------------------------------------------------------------------* + Name: CAMERA_S_ClearFlags + + Description: clear control bit to device register + + Arguments: camera : one of CameraSelect + reg : device register + clrBits : bits to clear + + Returns: None + *---------------------------------------------------------------------------*/ +static inline BOOL CAMERAi_S_ClearFlags( CameraSelect camera, u8 reg, u8 clrBits ) +{ + return CAMERAi_S_SetParams( camera, reg, 0, clrBits ); +} +static inline BOOL CAMERA_S_ClearFlags( CameraSelect camera, u8 reg, u8 clrBits ) +{ + return CAMERA_S_SetParams( camera, reg, 0, clrBits ); +} + + +//================================================================================ +// I2C_ API +//================================================================================ +/*---------------------------------------------------------------------------* + Name: CAMERA_S_I2CInit + + Description: initialize CAMERA + + Arguments: camera : one of CameraSelect + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +BOOL CAMERA_S_I2CInit(CameraSelect camera); + +/*---------------------------------------------------------------------------* + Name: CAMERA_S_I2CStandby + + Description: standby or resume CAMERA + + Arguments: camera : one of CameraSelect + standby : TRUE if goto standby mode + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +BOOL CAMERA_S_I2CStandby(CameraSelect camera, BOOL standby); + +/*---------------------------------------------------------------------------* + Name: CAMERA_S_I2CResize + + Description: resize CAMERA + + Arguments: camera : one of CameraSelect + width : width of output image + height : height of output image + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +BOOL CAMERA_S_I2CResize(CameraSelect camera, u16 width, u16 height); + +/*---------------------------------------------------------------------------* + Name: CAMERA_S_I2CPreSleep + + Description: preset CAMERA registers + + Arguments: camera : one of CameraSelect + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +BOOL CAMERA_S_I2CPreSleep(CameraSelect camera); + +/*---------------------------------------------------------------------------* + Name: CAMERA_S_I2CPostSleep + + Description: preset CAMERA registers + + Arguments: camera : one of CameraSelect + + Returns: TRUE if success + *---------------------------------------------------------------------------*/ +BOOL CAMERA_S_I2CPostSleep(CameraSelect camera); + + +#ifdef _cplusplus +} /* extern "C" */ +#endif + +/* TWL_CAMERA_I2C_SHARP_H_ */ +#endif diff --git a/include/twl/camera/ARM9/camera.h b/include/twl/camera/ARM9/camera.h index ad5e8fc..92f8fad 100644 --- a/include/twl/camera/ARM9/camera.h +++ b/include/twl/camera/ARM9/camera.h @@ -31,11 +31,6 @@ extern "C" { #endif -typedef enum { - CAMERA_SELECT_FIRST, - CAMERA_SELECT_SECOND -} CameraSelect; - typedef enum { CAMERA_OUTPUT_YUV, CAMERA_OUTPUT_RGB @@ -48,16 +43,17 @@ typedef enum { } CameraIntrVsync; /*---------------------------------------------------------------------------* - Name: CAMERA_SelectCamera + Name: CAMERA_Select - Description: set stbyn + Description: select camera to activate Arguments: camera one of CameraSelect - Returns: None + Returns: TRUE if success *---------------------------------------------------------------------------*/ -void CAMERA_SelectCamera( CameraSelect camera ); +BOOL CAMERA_Select( CameraSelect camera ); +#if 0 /*---------------------------------------------------------------------------* Name: CAMERA_SetStbyn @@ -68,6 +64,7 @@ void CAMERA_SelectCamera( CameraSelect camera ); Returns: BOOL last state *---------------------------------------------------------------------------*/ BOOL CAMERA_SetStbyn( BOOL high ); +#endif /*---------------------------------------------------------------------------* Name: CAMERA_PowerOn diff --git a/include/twl/camera/ARM9/camera_api.h b/include/twl/camera/ARM9/camera_api.h index df79af0..7f739b0 100644 --- a/include/twl/camera/ARM9/camera_api.h +++ b/include/twl/camera/ARM9/camera_api.h @@ -56,30 +56,30 @@ typedef void (*CAMERACallback)(CAMERAResult result, void *arg); void CAMERA_Init(void); /*---------------------------------------------------------------------------* - Name: CAMERA_SetStbyn2Async + Name: CAMERAi_I2CSelectAsync - Description: select STBYN for 2nd CAMERA + Description: select CAMERA to activate async version - Arguments: state - High/Low + Arguments: camera - one of CameraSelect callback - 非同期処理が完了した再に呼び出す関数を指定 arg - コールバック関数の呼び出し時の引数を指定。 Returns: CAMERAResult *---------------------------------------------------------------------------*/ -CAMERAResult CAMERA_SetStbyn2Async(BOOL state, CAMERACallback callback, void *arg); +CAMERAResult CAMERA_I2CSelectAsync(CameraSelect camera, CAMERACallback callback, void *arg); /*---------------------------------------------------------------------------* - Name: CAMERA_SetStbyn2 + Name: CAMERAi_I2CSelect - Description: select STBYN for 2nd CAMERA + Description: select CAMERA to activate sync version. - Arguments: state - High/Low + Arguments: camera - one of CameraSelect Returns: CAMERAResult *---------------------------------------------------------------------------*/ -CAMERAResult CAMERA_SetStbyn2(BOOL state); +CAMERAResult CAMERA_I2CSelect(CameraSelect camera); /*---------------------------------------------------------------------------* Name: CAMERA_WriteRegistersAsync @@ -87,7 +87,8 @@ CAMERAResult CAMERA_SetStbyn2(BOOL state); Description: write CAMERA registers via I2C. async version. - Arguments: addr - start address + Arguments: camera - one of CameraSelect + addr - start address bufp - buffer to write length - length of bufp callback - 非同期処理が完了した再に呼び出す関数を指定 @@ -95,7 +96,7 @@ CAMERAResult CAMERA_SetStbyn2(BOOL state); Returns: CAMERAResult *---------------------------------------------------------------------------*/ -CAMERAResult CAMERA_WriteRegistersAsync(u8 addr, const u8* bufp, size_t length, CAMERACallback callback, void *arg); +CAMERAResult CAMERA_WriteRegistersAsync(CameraSelect camera, u8 addr, const u8* bufp, size_t length, CAMERACallback callback, void *arg); /*---------------------------------------------------------------------------* Name: CAMERA_WriteRegisters @@ -103,20 +104,22 @@ CAMERAResult CAMERA_WriteRegistersAsync(u8 addr, const u8* bufp, size_t length, Description: write CAMERA registers via I2C. sync version. - Arguments: addr - start address + Arguments: camera - one of CameraSelect + addr - start address bufp - buffer to write length - length of bufp Returns: CAMERAResult *---------------------------------------------------------------------------*/ -CAMERAResult CAMERA_WriteRegisters(u8 addr, const u8* bufp, size_t length); +CAMERAResult CAMERA_WriteRegisters(CameraSelect camera, u8 addr, const u8* bufp, size_t length); /*---------------------------------------------------------------------------* Name: CAMERA_ReadRegistersAsync Description: read CAMERA registers via I2C. - Arguments: addr - start address + Arguments: camera - one of CameraSelect + addr - start address bufp - buffer to read length - length of bufp callback - 非同期処理が完了した再に呼び出す関数を指定 @@ -124,7 +127,7 @@ CAMERAResult CAMERA_WriteRegisters(u8 addr, const u8* bufp, size_t length); Returns: CAMERAResult *---------------------------------------------------------------------------*/ -CAMERAResult CAMERA_ReadRegistersAsync(u8 addr, u8* bufp, size_t length, CAMERACallback callback, void *arg); +CAMERAResult CAMERA_ReadRegistersAsync(CameraSelect camera, u8 addr, u8* bufp, size_t length, CAMERACallback callback, void *arg); /*---------------------------------------------------------------------------* Name: CAMERA_ReadRegisters @@ -132,18 +135,22 @@ CAMERAResult CAMERA_ReadRegistersAsync(u8 addr, u8* bufp, size_t length, CAMERAC Description: set CAMERA key normally sync version. - Arguments: pKey - pointer to key data + Arguments: camera - one of CameraSelect + addr - start address + bufp - buffer to read + length - length of bufp Returns: CAMERAResult *---------------------------------------------------------------------------*/ -CAMERAResult CAMERA_ReadRegisters(u8 addr, u8* bufp, size_t length); +CAMERAResult CAMERA_ReadRegisters(CameraSelect camera, u8 addr, u8* bufp, size_t length); /*---------------------------------------------------------------------------* Name: CAMERA_SetParamsAsync Description: set register as reg = (reg & ~mask) | (bits & mask); - Arguments: addr - address to access + Arguments: camera - one of CameraSelect + addr - address to access bits - bits to set mask - mask to touch callback - 非同期処理が完了した再に呼び出す関数を指定 @@ -151,72 +158,77 @@ CAMERAResult CAMERA_ReadRegisters(u8 addr, u8* bufp, size_t length); Returns: CAMERAResult *---------------------------------------------------------------------------*/ -CAMERAResult CAMERA_SetParamsAsync(u8 addr, u8 bits, u8 mask, CAMERACallback callback, void *arg); +CAMERAResult CAMERA_SetParamsAsync(CameraSelect camera, u8 addr, u8 bits, u8 mask, CAMERACallback callback, void *arg); /*---------------------------------------------------------------------------* Name: CAMERA_SetParams Description: set register as reg = (reg & ~mask) | (bits & mask); - Arguments: addr - address to access + Arguments: camera - one of CameraSelect + addr - address to access bits - bits to set mask - mask to touch Returns: CAMERAResult *---------------------------------------------------------------------------*/ -CAMERAResult CAMERA_SetParams(u8 addr, u8 bits, u8 mask); +CAMERAResult CAMERA_SetParams(CameraSelect camera, u8 addr, u8 bits, u8 mask); /*---------------------------------------------------------------------------* Name: CAMERA_SetFlagsAsync Description: set register as reg |= bits; - Arguments: addr - address to access + Arguments: camera - one of CameraSelect + addr - address to access bits - bits to set callback - 非同期処理が完了した再に呼び出す関数を指定 arg - コールバック関数の呼び出し時の引数を指定。 Returns: CAMERAResult *---------------------------------------------------------------------------*/ -CAMERAResult CAMERA_SetFlagsAsync(u8 addr, u8 bits, CAMERACallback callback, void *arg); +CAMERAResult CAMERA_SetFlagsAsync(CameraSelect camera, u8 addr, u8 bits, CAMERACallback callback, void *arg); /*---------------------------------------------------------------------------* Name: CAMERA_SetFlags Description: set register as reg |= bits; - Arguments: addr - address to access + Arguments: camera - one of CameraSelect + addr - address to access bits - bits to set Returns: CAMERAResult *---------------------------------------------------------------------------*/ -CAMERAResult CAMERA_SetFlags(u8 addr, u8 bits); +CAMERAResult CAMERA_SetFlags(CameraSelect camera, u8 addr, u8 bits); /*---------------------------------------------------------------------------* Name: CAMERA_ClearFlagsAsync Description: set register as reg &= ~bits; - Arguments: addr - address to access + Arguments: camera - one of CameraSelect + addr - address to access bits - bits to clear callback - 非同期処理が完了した再に呼び出す関数を指定 arg - コールバック関数の呼び出し時の引数を指定。 Returns: CAMERAResult *---------------------------------------------------------------------------*/ -CAMERAResult CAMERA_ClearFlagsAsync(u8 addr, u8 bits, CAMERACallback callback, void *arg); +CAMERAResult CAMERA_ClearFlagsAsync(CameraSelect camera, u8 addr, u8 bits, CAMERACallback callback, void *arg); /*---------------------------------------------------------------------------* Name: CAMERA_ClearFlags Description: set register as reg &= ~bits; - Arguments: addr - address to access + Arguments: camera - one of CameraSelect + addr - address to access bits - bits to set Returns: CAMERAResult *---------------------------------------------------------------------------*/ -CAMERAResult CAMERA_ClearFlags(u8 addr, u8 bits); +CAMERAResult CAMERA_ClearFlags(CameraSelect camera, u8 addr, u8 bits); /*---------------------------------------------------------------------------* Name: CAMERA_I2CInitAsync @@ -224,12 +236,13 @@ CAMERAResult CAMERA_ClearFlags(u8 addr, u8 bits); Description: initialize camera registers via I2C async version. - Arguments: callback - 非同期処理が完了した再に呼び出す関数を指定 + Arguments: camera - one of CameraSelect + callback - 非同期処理が完了した再に呼び出す関数を指定 arg - コールバック関数の呼び出し時の引数を指定。 Returns: CAMERAResult *---------------------------------------------------------------------------*/ -CAMERAResult CAMERA_I2CInitAsync(CAMERACallback callback, void *arg); +CAMERAResult CAMERA_I2CInitAsync(CameraSelect camera, CAMERACallback callback, void *arg); /*---------------------------------------------------------------------------* Name: CAMERA_I2CInit @@ -237,25 +250,26 @@ CAMERAResult CAMERA_I2CInitAsync(CAMERACallback callback, void *arg); Description: initialize camera registers via I2C sync version. - Arguments: None. + Arguments: camera - one of CameraSelect Returns: CAMERAResult *---------------------------------------------------------------------------*/ -CAMERAResult CAMERA_I2CInit(void); - +CAMERAResult CAMERA_I2CInit(CameraSelect camera); +#if 0 /*---------------------------------------------------------------------------* Name: CAMERA_I2CPresetAsync Description: set camera registers with specified preset via I2C async version - Arguments: preset - preset type + Arguments: camera - one of CameraSelect + preset - preset type callback - 非同期処理が完了した再に呼び出す関数を指定 arg - コールバック関数の呼び出し時の引数を指定。 Returns: CAMERAResult *---------------------------------------------------------------------------*/ -CAMERAResult CAMERA_I2CPresetAsync(CameraPreset preset, CAMERACallback callback, void *arg); +CAMERAResult CAMERA_I2CPresetAsync(CameraSelect camera, CameraPreset preset, CAMERACallback callback, void *arg); /*---------------------------------------------------------------------------* Name: CAMERA_I2CPreset @@ -263,12 +277,13 @@ CAMERAResult CAMERA_I2CPresetAsync(CameraPreset preset, CAMERACallback callback, Description: set camera registers with specified preset via I2C sync version. - Arguments: preset - preset type + Arguments: camera - one of CameraSelect + preset - preset type Returns: CAMERAResult *---------------------------------------------------------------------------*/ -CAMERAResult CAMERA_I2CPreset(CameraPreset preset); - +CAMERAResult CAMERA_I2CPreset(CameraSelect camera, CameraPreset preset); +#endif /*---------------------------------------------------------------------------* Name: CAMERA_I2CPreSleepAsync @@ -324,7 +339,8 @@ CAMERAResult CAMERA_I2CPostSleep(void); Description: set offset and size - Arguments: x_off - x offset to start capturing + Arguments: camera - one of CameraSelect + x_off - x offset to start capturing y_off - y offset to start capturing width - width of image height - height of image @@ -333,21 +349,22 @@ CAMERAResult CAMERA_I2CPostSleep(void); Returns: CAMERAResult *---------------------------------------------------------------------------*/ -CAMERAResult CAMERA_SetCroppingAsync(u16 x_off, u16 y_off, u16 width, u16 height, CAMERACallback callback, void *arg); +CAMERAResult CAMERA_SetCroppingAsync(CameraSelect camera, u16 x_off, u16 y_off, u16 width, u16 height, CAMERACallback callback, void *arg); /*---------------------------------------------------------------------------* Name: CAMERA_SetCropping Description: set offset and size - Arguments: x_off - x offset to start capturing + Arguments: camera - one of CameraSelect + x_off - x offset to start capturing y_off - y offset to start capturing width - width of image height - height of image Returns: CAMERAResult *---------------------------------------------------------------------------*/ -CAMERAResult CAMERA_SetCropping(u16 x_off, u16 y_off, u16 width, u16 height); +CAMERAResult CAMERA_SetCropping(CameraSelect camera, u16 x_off, u16 y_off, u16 width, u16 height); /*---------------------------------------------------------------------------* Name: CAMERA_PauseAsync diff --git a/include/twl/camera/common/fifo.h b/include/twl/camera/common/fifo.h index 76ee7f2..e001c2b 100644 --- a/include/twl/camera/common/fifo.h +++ b/include/twl/camera/common/fifo.h @@ -47,7 +47,7 @@ extern "C" { // PXIコマンド定義 typedef enum CAMERAPxiCommand { - CAMERA_PXI_COMMAND_SET_STBYN = 0x00, // STBYN操作 + CAMERA_PXI_COMMAND_SELECT = 0x00, // アクティブ選択 // I2C基本操作 CAMERA_PXI_COMMAND_WRITE_REGISTERS = 0x10, CAMERA_PXI_COMMAND_READ_REGISTERS = 0x11, @@ -71,21 +71,21 @@ CAMERAPxiCommand; // PXIコマンドサイズ定義 typedef enum CAMERAPxiSize { - CAMERA_PXI_SIZE_SET_STBYN = 1, // BOOL + CAMERA_PXI_SIZE_SELECT = 1, // camera // I2C基本操作 - CAMERA_PXI_SIZE_WRITE_REGISTERS = 3, // addr, size, data... - CAMERA_PXI_SIZE_READ_REGISTERS = 2, // addr, size - CAMERA_PXI_SIZE_SET_PARAMS = 3, // addr, bits, mask - CAMERA_PXI_SIZE_SET_FLAGS = 2, // addr, bits - CAMERA_PXI_SIZE_CLEAR_FLAGS = 2, // addr, bits + CAMERA_PXI_SIZE_WRITE_REGISTERS = CAMERA_PXI_DATA_SIZE_MAX, // camera, addr, size, data... + CAMERA_PXI_SIZE_READ_REGISTERS = 3, // camera, addr, size + CAMERA_PXI_SIZE_SET_PARAMS = 4, // camera, addr, bits, mask + CAMERA_PXI_SIZE_SET_FLAGS = 3, // camera, addr, bits + CAMERA_PXI_SIZE_CLEAR_FLAGS = 3, // camera, addr, bits // I2C応用操作 - CAMERA_PXI_SIZE_I2C_INIT = 0, - CAMERA_PXI_SIZE_I2C_PRESET = 1, // preset + CAMERA_PXI_SIZE_I2C_INIT = 1, // camera + CAMERA_PXI_SIZE_I2C_PRESET = 2, // camera, preset CAMERA_PXI_SIZE_I2C_PRE_SLEEP = 0, CAMERA_PXI_SIZE_I2C_POST_SLEEP = 0, - CAMERA_PXI_SIZE_I2C_SET_CROPPING = 8, // (u16)x_offset, (u16)y_offset, (u16)width, (u16)height + CAMERA_PXI_SIZE_I2C_SET_CROPPING = 9, // camera, (u16)x_offset, (u16)y_offset, (u16)width, (u16)height CAMERA_PXI_SIZE_I2C_PAUSE = 0, CAMERA_PXI_SIZE_I2C_RESUME = 0 diff --git a/include/twl/camera/common/types.h b/include/twl/camera/common/types.h index f371dd8..4e9648c 100644 --- a/include/twl/camera/common/types.h +++ b/include/twl/camera/common/types.h @@ -23,41 +23,20 @@ extern "C" { /*===========================================================================*/ typedef enum { - CAMERA_FLIPMODE_NONE, - CAMERA_FLIPMODE_HORIZONTAL, - CAMERA_FLIPMODE_VERTICAL, - CAMERA_FLIPMODE_HORIZONTAL_VERTICAL, - CAMERA_FLIPMODE_MAX, - - CAMERA_FLIPMODE_DEFAULT = CAMERA_FLIPMODE_HORIZONTAL -} CameraFlipMode; + CAMERA_SELECT_NONE = 0, + CAMERA_SELECT_IN = (1<<0), + CAMERA_SELECT_OUT = (1<<1), + CAMERA_SELECT_BOTH = (CAMERA_SELECT_IN|CAMERA_SELECT_OUT) +} CameraSelect; typedef enum { - CAMERA_SPECIALMODE_NONE, - CAMERA_SPECIALMODE_NEVATIVE, - CAMERA_SPECIALMODE_SEPIA, - CAMERA_SPECIALMODE_BLUISH, - CAMERA_SPECIALMODE_REDDISH, - CAMERA_SPECIALMODE_GREENISH, - CAMERA_SPECIALMODE_MAX, - - CAMERA_SPECIALMODE_AQUA = CAMERA_SPECIALMODE_BLUISH, - CAMERA_SPECIALMODE_DEFAULT = CAMERA_SPECIALMODE_NONE -} CameraSpecialMode; - -typedef enum { -// CAMERA_PRESET_HVGA_20, -// CAMERA_PRESET_DS_30, - CAMERA_PRESET_VGA_20, -// CAMERA_PRESET_QVGA_20, -// CAMERA_PRESET_QVGA_30, - CAMERA_PRESET_QVGA_30SD, - CAMERA_PRESET_QVGA_30SS, - CAMERA_PRESET_MAX, - - CAMERA_PRESET_DEFAULT = CAMERA_PRESET_QVGA_30SD -} CameraPreset; - + CAMERA_FUNC_INIT, + CAMERA_FUNC_STANDBY, + CAMERA_FUNC_RESIZE, + CAMERA_FUNC_PRESLEEP, + CAMERA_FUNC_POSTSLEEP, + CAMERA_FUNC_MAX +} CameraFunct; /*===========================================================================*/ diff --git a/include/twl/i2c/ARM7/i2c.h b/include/twl/i2c/ARM7/i2c.h index ef8422c..ca60617 100644 --- a/include/twl/i2c/ARM7/i2c.h +++ b/include/twl/i2c/ARM7/i2c.h @@ -32,7 +32,10 @@ extern "C" { typedef enum { I2C_SLAVE_CODEC_TP = 0, - I2C_SLAVE_CAMERA, + I2C_SLAVE_CAMERA_MICRON_IN, + I2C_SLAVE_CAMERA_MICRON_OUT, + I2C_SLAVE_CAMERA_SHARP_IN, + I2C_SLAVE_CAMERA_SHARP_OUT, I2C_SLAVE_NUM } I2CSlave; @@ -47,9 +50,11 @@ typedef enum I2CReadWrite; -#define I2C_ADDR_CODEC (0x18 << 1) -//#define I2C_ADDR_CAMERA 0x5a // SAMSUNG 1/8 -#define I2C_ADDR_CAMERA (0x62 << 1) // SAMSUNG 1/10 +#define I2C_ADDR_CODEC (0x18 << 1) +#define I2C_ADDR_CAMERA_MICRON_IN 0x78 // MICRON +#define I2C_ADDR_CAMERA_MICRON_OUT 0x7A // MICRON +#define I2C_ADDR_CAMERA_SHARP_IN 0xE0 // SHARP +#define I2C_ADDR_CAMERA_SHARP_OUT 0xA0 // SHARP //---------------------------------------------------------------- // subroutine definition @@ -136,6 +141,45 @@ BOOL I2C_SetFlags( I2CSlave id, u8 reg, u8 setBits ); BOOL I2Ci_ClearFlags( I2CSlave id, u8 reg, u8 clrBits ); BOOL I2C_ClearFlags( I2CSlave id, u8 reg, u8 clrBits ); +/*---------------------------------------------------------------------------* + Name: I2C_SetParams16 + + Description: set control bit to device register + + Arguments: reg : device register + setBits : bits to set + + Returns: None + *---------------------------------------------------------------------------*/ +BOOL I2Ci_SetParams16( I2CSlave id, u16 reg, u16 setBits, u16 maskBits ); +BOOL I2C_SetParams16( I2CSlave id, u16 reg, u16 setBits, u16 maskBits ); + +/*---------------------------------------------------------------------------* + Name: I2C_SetFlags16 + + Description: set control bit to device register + + Arguments: reg : device register + setBits : bits to set + + Returns: None + *---------------------------------------------------------------------------*/ +BOOL I2Ci_SetFlags16( I2CSlave id, u16 reg, u16 setBits ); +BOOL I2C_SetFlags16( I2CSlave id, u16 reg, u16 setBits ); + +/*---------------------------------------------------------------------------* + Name: I2C_ClearFlags16 + + Description: clear control bit to device register + + Arguments: reg : device register + setBits : bits to set + + Returns: None + *---------------------------------------------------------------------------*/ +BOOL I2Ci_ClearFlags16( I2CSlave id, u16 reg, u16 clrBits ); +BOOL I2C_ClearFlags16( I2CSlave id, u16 reg, u16 clrBits ); + //================================================================================ // DEVICE ACCESS //================================================================================ @@ -159,6 +203,26 @@ static inline BOOL I2C_WriteRegister( I2CSlave id, u8 reg, u8 data ) return result; } +/*---------------------------------------------------------------------------* + Name: I2C_WriteRegister16 + + Description: set value to decive register through I2C. + + Arguments: reg : decive register + data : value to be written + + Returns: None + *---------------------------------------------------------------------------*/ +BOOL I2Ci_WriteRegister16( I2CSlave id, u16 reg, u16 data ); +static inline BOOL I2C_WriteRegister16( I2CSlave id, u16 reg, u16 data ) +{ + BOOL result; + (void)I2C_Lock(); + result = I2Ci_WriteRegister16( id, reg, data ); + (void)I2C_Unlock(); + return result; +} + /*---------------------------------------------------------------------------* Name: I2C_ReadRegister @@ -198,6 +262,25 @@ static inline u8 I2C_ReadRegisterSC( I2CSlave id, u8 reg ) return result; } +/*---------------------------------------------------------------------------* + Name: I2C_ReadRegister16 + + Description: get value from decive register through I2C. + + Arguments: reg : decive register + + Returns: value which is read from specified decive register + *---------------------------------------------------------------------------*/ +u16 I2Ci_ReadRegister16( I2CSlave id, u16 reg ); +static inline u16 I2C_ReadRegister16( I2CSlave id, u16 reg ) +{ + u16 result; + (void)I2C_Lock(); + result = I2Ci_ReadRegister16( id, reg ); + (void)I2C_Unlock(); + return result; +} + /*---------------------------------------------------------------------------* Name: I2C_VerifyRegister @@ -236,6 +319,26 @@ static inline BOOL I2C_VerifyRegisterSC( I2CSlave id, u8 reg, u8 data ) (void)I2C_Unlock(); return result; } + +/*---------------------------------------------------------------------------* + Name: I2C_VerifyRegister16 + + Description: get and verify value from decive register through I2C. + + Arguments: reg : decive register + + Returns: value which is read from specified decive register + *---------------------------------------------------------------------------*/ +BOOL I2Ci_VerifyRegister16( I2CSlave id, u16 reg, u16 data ); +static inline BOOL I2C_VerifyRegister16( I2CSlave id, u16 reg, u16 data ) +{ + BOOL result; + (void)I2C_Lock(); + result = I2Ci_VerifyRegister16( id, reg, data ); + (void)I2C_Unlock(); + return result; +} + /*---------------------------------------------------------------------------* Name: I2C_WriteRegisters @@ -256,6 +359,26 @@ static inline BOOL I2C_WriteRegisters( I2CSlave id, u8 reg, const u8 *bufp, size return result; } +/*---------------------------------------------------------------------------* + Name: I2C_WriteRegisters16 + + Description: set value to decive register through I2C. + + Arguments: reg : decive register + data : value to be written + + Returns: None + *---------------------------------------------------------------------------*/ +BOOL I2Ci_WriteRegisters16( I2CSlave id, u16 reg, const u16 *bufp, size_t size ); +static inline BOOL I2C_WriteRegisters16( I2CSlave id, u16 reg, const u16 *bufp, size_t size ) +{ + BOOL result; + (void)I2C_Lock(); + result = I2Ci_WriteRegisters16( id, reg, bufp, size ); + (void)I2C_Unlock(); + return result; +} + /*---------------------------------------------------------------------------* Name: I2C_ReadRegisters @@ -295,6 +418,25 @@ static inline BOOL I2C_ReadRegistersSC( I2CSlave id, u8 reg, u8 *bufp, size_t si return result; } +/*---------------------------------------------------------------------------* + Name: I2C_ReadRegisters16 + + Description: get value from decive register through I2C. + + Arguments: reg : decive register + + Returns: value which is read from specified decive register + *---------------------------------------------------------------------------*/ +BOOL I2Ci_ReadRegisters16( I2CSlave id, u16 reg, u16 *bufp, size_t size ); +static inline BOOL I2C_ReadRegisters16( I2CSlave id, u16 reg, u16 *bufp, size_t size ) +{ + BOOL result; + (void)I2C_Lock(); + result = I2Ci_ReadRegisters16( id, reg, bufp, size ); + (void)I2C_Unlock(); + return result; +} + /*---------------------------------------------------------------------------* Name: I2C_VerifyRegisters @@ -333,6 +475,26 @@ static inline BOOL I2C_VerifyRegistersSC( I2CSlave id, u8 reg, const u8 *bufp, s (void)I2C_Unlock(); return result; } + +/*---------------------------------------------------------------------------* + Name: I2C_VerifyRegisters16 + + Description: get and verify value from decive register through I2C. + + Arguments: reg : decive register + + Returns: value which is read from specified decive register + *---------------------------------------------------------------------------*/ +BOOL I2Ci_VerifyRegisters16( I2CSlave id, u16 reg, const u16 *bufp, size_t size ); +static inline BOOL I2C_VerifyRegisters16( I2CSlave id, u16 reg, const u16 *bufp, size_t size ) +{ + BOOL result; + (void)I2C_Lock(); + result = I2Ci_VerifyRegisters16( id, reg, bufp, size ); + (void)I2C_Unlock(); + return result; +} + #if 0 //================================================================================ // INTERRUPT