Paparazzi UAS  v5.14.0_stable-0-g3f680d1
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 // parameters for undistortion
107 #ifndef MT9F002_FOCAL_X
108 #define MT9F002_FOCAL_X 311.59304538f
109 #endif
110 #ifndef MT9F002_FOCAL_Y
111 #define MT9F002_FOCAL_Y 313.01338397f
112 #endif
113 #ifndef MT9F002_CENTER_X
114 #define MT9F002_CENTER_X 158.37457814f
115 #endif
116 #ifndef MT9F002_CENTER_Y
117 #define MT9F002_CENTER_Y 326.49375925f
118 #endif
119 #ifndef MT9F002_DHANE_K
120 #define MT9F002_DHANE_K 1.25f
121 #endif
122 
123 /* Interface types for the MT9F002 connection */
128 };
129 
130 /* Main configuration structure */
131 struct mt9f002_t {
143  float vt_pix_clk;
144  float op_pix_clk;
147 
148  float target_fps;
149  float real_fps;
152 
153  float gain_green1;
154  float gain_blue;
155  float gain_red;
156  float gain_green2;
157 
163  float offset_x;
164  float offset_y;
165 
168 
171 };
172 
173 void mt9f002_init(struct mt9f002_t *mt);
174 void mt9f002_set_resolution(struct mt9f002_t *mt);
175 void mt9f002_set_exposure(struct mt9f002_t *mt);
176 void mt9f002_set_gains(struct mt9f002_t *mt);
177 
178 #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:166
uint16_t output_height
Output height.
Definition: mt9f002.h:159
uint16_t op_sys_clk_div
Fixed PLL config from calculator tool.
Definition: mt9f002.h:139
uint8_t rowSpeed_2_0
Fixed PLL config from calculator tool.
Definition: mt9f002.h:141
uint16_t vt_pix_clk_div
Fixed PLL config from calculator tool.
Definition: mt9f002.h:134
uint16_t pll_multiplier
Fixed PLL config from calculator tool.
Definition: mt9f002.h:137
void mt9f002_set_exposure(struct mt9f002_t *mt)
Set the exposure configuration Depends on the blanking (and therefore the FPS)
Definition: mt9f002.c:666
uint16_t scaled_width
Width after corrected scaling.
Definition: mt9f002.h:161
float gain_blue
Gain for the Blue pixels [1.5 -> 63.50].
Definition: mt9f002.h:154
HiSPi type connection.
Definition: mt9f002.h:126
float offset_y
Offset from top in pixels.
Definition: mt9f002.h:164
uint8_t y_odd_inc
Y increment for subsampling (1,3,7 accepted)
Definition: mt9f002.h:167
uint16_t vt_sys_clk_div
Fixed PLL config from calculator tool.
Definition: mt9f002.h:135
void mt9f002_init(struct mt9f002_t *mt)
Initialisation of the Aptina MT9F002 CMOS sensor (front camera)
Definition: mt9f002.c:863
float offset_x
Offset from left in pixels.
Definition: mt9f002.h:163
float output_scaler
Output scale.
Definition: mt9f002.h:160
uint8_t shift_vt_pix_clk_div
Fixed PLL config from calculator tool.
Definition: mt9f002.h:140
uint8_t row_speed_10_8
Fixed PLL config from calculator tool.
Definition: mt9f002.h:142
void mt9f002_set_resolution(struct mt9f002_t *mt)
Definition: mt9f002.c:780
enum mt9f002_interface interface
Interface used to connect.
Definition: mt9f002.h:132
uint16_t line_length
Calculated line length of blanking.
Definition: mt9f002.h:145
float real_fps
Real calculated FPS.
Definition: mt9f002.h:149
float gain_green1
Gain for the GreenR pixels [1.5 -> 63.50].
Definition: mt9f002.h:153
uint16_t output_width
Output width.
Definition: mt9f002.h:158
float vt_pix_clk
Calculated based on PLL.
Definition: mt9f002.h:143
mt9f002_interface
Definition: mt9f002.h:124
float target_fps
FPS wanted.
Definition: mt9f002.h:148
float gain_red
Gain for the Red pixels [1.5 -> 63.50].
Definition: mt9f002.h:155
I2C transaction structure.
Definition: i2c.h:93
struct i2c_periph * i2c_periph
I2C peripheral used to communicate over.
Definition: mt9f002.h:169
float gain_green2
Gain for the GreenB pixels [1.5 -> 63.50].
Definition: mt9f002.h:156
float real_exposure
Real exposure time in ms.
Definition: mt9f002.h:151
I2C peripheral structure.
Definition: i2c.h:138
struct i2c_transaction i2c_trans
I2C transaction for comminication with CMOS chip.
Definition: mt9f002.h:170
unsigned char uint8_t
Definition: types.h:14
uint16_t op_pix_clk_div
Fixed PLL config from calculator tool.
Definition: mt9f002.h:138
float op_pix_clk
Calculated based on PLL.
Definition: mt9f002.h:144
uint16_t pre_pll_clk_div
Fixed PLL config from calculator tool.
Definition: mt9f002.h:136
Parallel type connection.
Definition: mt9f002.h:127
uint16_t scaled_height
Height after corrected scaling.
Definition: mt9f002.h:162
uint16_t frame_length
Calculated frame length of blanking.
Definition: mt9f002.h:146
float input_clk_freq
Input clock frequency.
Definition: mt9f002.h:133
MIPI type connection.
Definition: mt9f002.h:125
float target_exposure
Target exposure time in ms.
Definition: mt9f002.h:150
void mt9f002_set_gains(struct mt9f002_t *mt)
Sets the GreenR, Blue, Red and GreenB gains.
Definition: mt9f002.c:772
Architecture independent I2C (Inter-Integrated Circuit Bus) API.