Paparazzi UAS  v5.12_stable-4-g9b43e9b
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
mt9f002.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) Freek van Tienen <freek.v.tienen@gmail.com>
3  *
4  * This file is part of paparazzi
5  *
6  * paparazzi is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * paparazzi is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with paparazzi; see the file COPYING. If not, see
18  * <http://www.gnu.org/licenses/>.
19  */
20 
27 #ifndef MT9F002H
28 #define MT9F002H
29 
30 #include "std.h"
31 #include "mcu_periph/i2c.h"
32 
33 /* define required ouput image size */
34 #ifndef MT9F002_OUTPUT_HEIGHT
35 #define MT9F002_OUTPUT_HEIGHT 822 // full resolution 3288
36 #endif
37 
38 #ifndef MT9F002_OUTPUT_WIDTH
39 #define MT9F002_OUTPUT_WIDTH 1152 // full resolution 4608
40 #endif
41 
42 #ifndef MT9F002_INITIAL_OFFSET_X
43 #define MT9F002_INITIAL_OFFSET_X 0. // signed fractional offset from centre of image of original sensor [-0.5,0.5]
44 #endif
45 
46 #ifndef MT9F002_INITIAL_OFFSET_Y
47 #define MT9F002_INITIAL_OFFSET_Y 0. // signed fractional offset from centre of image of original sensor [-0.5,0.5]
48 #endif
49 
61 #ifndef MT9F002_OUTPUT_SCALER
62 #define MT9F002_OUTPUT_SCALER 1.
63 #endif
64 
70 #ifndef MT9F002_TARGET_EXPOSURE
71 #define MT9F002_TARGET_EXPOSURE 30
72 #endif
73 
74 #ifndef MT9F002_TARGET_FPS
75 #define MT9F002_TARGET_FPS 15
76 #endif
77 
78 /* Set the colour balance gains */
79 #ifndef MT9F002_GAIN_GREEN1
80 #define MT9F002_GAIN_GREEN1 3.0
81 #endif
82 
83 #ifndef MT9F002_GAIN_GREEN2
84 #define MT9F002_GAIN_GREEN2 3.0
85 #endif
86 
87 #ifndef MT9F002_GAIN_RED
88 #define MT9F002_GAIN_RED 3.0
89 #endif
90 
91 #ifndef MT9F002_GAIN_BLUE
92 #define MT9F002_GAIN_BLUE 4.0
93 #endif
94 
95 /* Set pixel increment value to implement subsampling */
96 /* Supported values for MT9F002_X_ODD_INC_VAL are 3, 7, 15 and 31 */
97 #ifndef MT9F002_X_ODD_INC_VAL
98 #define MT9F002_X_ODD_INC_VAL 1
99 #endif
100 
101 /* Supported values for MT9F002_Y_ODD_INC_VAL are 1, 3 and 7 */
102 #ifndef MT9F002_Y_ODD_INC_VAL
103 #define MT9F002_Y_ODD_INC_VAL 1
104 #endif
105 
106 /* Interface types for the MT9F002 connection */
111 };
112 
113 /* Main configuration structure */
114 struct mt9f002_t {
126  float vt_pix_clk;
127  float op_pix_clk;
130 
131  float target_fps;
132  float real_fps;
135 
136  float gain_green1;
137  float gain_blue;
138  float gain_red;
139  float gain_green2;
140 
146  float offset_x;
147  float offset_y;
148 
151 
154 };
155 
156 void mt9f002_init(struct mt9f002_t *mt);
157 void mt9f002_set_resolution(struct mt9f002_t *mt);
158 void mt9f002_set_exposure(struct mt9f002_t *mt);
159 void mt9f002_set_gains(struct mt9f002_t *mt);
160 
161 #endif /* MT9F002_H */
unsigned short uint16_t
Definition: types.h:16
uint8_t x_odd_inc
X increment for subsampling (1,3,7,15,31 accepted)
Definition: mt9f002.h:149
uint16_t output_height
Output height.
Definition: mt9f002.h:142
uint16_t op_sys_clk_div
Fixed PLL config from calculator tool.
Definition: mt9f002.h:122
uint8_t rowSpeed_2_0
Fixed PLL config from calculator tool.
Definition: mt9f002.h:124
uint16_t vt_pix_clk_div
Fixed PLL config from calculator tool.
Definition: mt9f002.h:117
uint16_t pll_multiplier
Fixed PLL config from calculator tool.
Definition: mt9f002.h:120
void mt9f002_set_exposure(struct mt9f002_t *mt)
Set the exposure configuration Depends on the blanking (and therefore the FPS)
Definition: mt9f002.c:659
uint16_t scaled_width
Width after corrected scaling.
Definition: mt9f002.h:144
float gain_blue
Gain for the Blue pixels [1.5 -> 63.50].
Definition: mt9f002.h:137
HiSPi type connection.
Definition: mt9f002.h:109
float offset_y
Offset from top in pixels.
Definition: mt9f002.h:147
uint8_t y_odd_inc
Y increment for subsampling (1,3,7 accepted)
Definition: mt9f002.h:150
uint16_t vt_sys_clk_div
Fixed PLL config from calculator tool.
Definition: mt9f002.h:118
void mt9f002_init(struct mt9f002_t *mt)
Initialisation of the Aptina MT9F002 CMOS sensor (front camera)
Definition: mt9f002.c:856
float offset_x
Offset from left in pixels.
Definition: mt9f002.h:146
float output_scaler
Output scale.
Definition: mt9f002.h:143
uint8_t shift_vt_pix_clk_div
Fixed PLL config from calculator tool.
Definition: mt9f002.h:123
uint8_t row_speed_10_8
Fixed PLL config from calculator tool.
Definition: mt9f002.h:125
void mt9f002_set_resolution(struct mt9f002_t *mt)
Definition: mt9f002.c:773
enum mt9f002_interface interface
Interface used to connect.
Definition: mt9f002.h:115
uint16_t line_length
Calculated line length of blanking.
Definition: mt9f002.h:128
float real_fps
Real calculated FPS.
Definition: mt9f002.h:132
float gain_green1
Gain for the GreenR pixels [1.5 -> 63.50].
Definition: mt9f002.h:136
uint16_t output_width
Output width.
Definition: mt9f002.h:141
float vt_pix_clk
Calculated based on PLL.
Definition: mt9f002.h:126
mt9f002_interface
Definition: mt9f002.h:107
float target_fps
FPS wanted.
Definition: mt9f002.h:131
float gain_red
Gain for the Red pixels [1.5 -> 63.50].
Definition: mt9f002.h:138
I2C transaction structure.
Definition: i2c.h:93
struct i2c_periph * i2c_periph
I2C peripheral used to communicate over.
Definition: mt9f002.h:152
float gain_green2
Gain for the GreenB pixels [1.5 -> 63.50].
Definition: mt9f002.h:139
float real_exposure
Real exposure time in ms.
Definition: mt9f002.h:134
I2C peripheral structure.
Definition: i2c.h:138
struct i2c_transaction i2c_trans
I2C transaction for comminication with CMOS chip.
Definition: mt9f002.h:153
unsigned char uint8_t
Definition: types.h:14
uint16_t op_pix_clk_div
Fixed PLL config from calculator tool.
Definition: mt9f002.h:121
float op_pix_clk
Calculated based on PLL.
Definition: mt9f002.h:127
uint16_t pre_pll_clk_div
Fixed PLL config from calculator tool.
Definition: mt9f002.h:119
Parallel type connection.
Definition: mt9f002.h:110
uint16_t scaled_height
Height after corrected scaling.
Definition: mt9f002.h:145
uint16_t frame_length
Calculated frame length of blanking.
Definition: mt9f002.h:129
float input_clk_freq
Input clock frequency.
Definition: mt9f002.h:116
MIPI type connection.
Definition: mt9f002.h:108
float target_exposure
Target exposure time in ms.
Definition: mt9f002.h:133
void mt9f002_set_gains(struct mt9f002_t *mt)
Sets the GreenR, Blue, Red and GreenB gains.
Definition: mt9f002.c:765
Architecture independent I2C (Inter-Integrated Circuit Bus) API.