32#include "generated/airframe.h" 
   34#define CFG_SCALER_M_MIN 16 
   35#define CFG_SCALER_M_MAX 128 
   36#define CFG_MT9F002_WINDOW_WIDTH_MIN 1 
   37#define CFG_MT9F002_WINDOW_HEIGHT_MIN 1 
   38#define CFG_MT9F002_PIXEL_ARRAY_HEIGHT 3288 
   39#define CFG_MT9F002_PIXEL_ARRAY_WIDTH 4608 
   40#define CFG_MT9F002_X_ADDR_MIN 24 
   41#define CFG_MT9F002_X_ADDR_MAX 4647 
   42#define CFG_MT9F002_Y_ADDR_MIN 0 
   43#define CFG_MT9F002_Y_ADDR_MAX CFG_MT9F002_PIXEL_ARRAY_HEIGHT 
   49#define RES_1080p_4_3  4 
   52#ifdef MT9F002_RESOLUTION 
   53#if MT9F002_RESOLUTION == RES_VGA 
   54#define MT9F002_OUTPUT_WIDTH 640 
   55#define MT9F002_OUTPUT_HEIGHT 480 
   56#elif MT9F002_RESOLUTION == RES_720p 
   57#define MT9F002_OUTPUT_WIDTH 1280 
   58#define MT9F002_OUTPUT_HEIGHT 720 
   59#elif MT9F002_RESOLUTION == RES_720p_4_3 
   60#define MT9F002_OUTPUT_WIDTH 960 
   61#define MT9F002_OUTPUT_HEIGHT 720 
   62#elif MT9F002_RESOLUTION == RES_1080p 
   63#define MT9F002_OUTPUT_WIDTH 1920 
   64#define MT9F002_OUTPUT_HEIGHT 1080 
   65#elif MT9F002_RESOLUTION == RES_1080p_4_3 
   66#define MT9F002_OUTPUT_WIDTH 1440 
   67#define MT9F002_OUTPUT_HEIGHT 1080 
   68#elif MT9F002_RESOLUTION == RES_FULL 
   72#define MT9F002_OUTPUT_WIDTH 2048 
   73#define MT9F002_OUTPUT_HEIGHT 2048 
   75#define MT9F002_OUTPUT_WIDTH 640 
   76#define MT9F002_OUTPUT_HEIGHT 640 
   81#ifndef MT9F002_OUTPUT_WIDTH 
   82#define MT9F002_OUTPUT_WIDTH 640 
   84#ifndef MT9F002_OUTPUT_HEIGHT 
   85#define MT9F002_OUTPUT_HEIGHT 640 
   90#ifndef MT9F002_OFFSET_X 
   91#define MT9F002_OFFSET_X 0. 
   95#ifndef MT9F002_OFFSET_Y 
   96#define MT9F002_OFFSET_Y 0. 
  101#define MT9F002_ZOOM 1. 
  104#ifndef MT9F002_TARGET_FPS 
  105#define MT9F002_TARGET_FPS 30 
  109#ifndef MT9F002_FOCAL_X 
  110#define MT9F002_FOCAL_X (MT9F002_ZOOM * MT9F002_OUTPUT_WIDTH / 2.f) 
  112#ifndef MT9F002_FOCAL_Y 
  113#define MT9F002_FOCAL_Y (MT9F002_ZOOM * MT9F002_OUTPUT_HEIGHT / 2.f) 
  115#ifndef MT9F002_CENTER_X 
  116#define MT9F002_CENTER_X (MT9F002_OUTPUT_WIDTH * (.5f - MT9F002_ZOOM * MT9F002_OFFSET_X)) 
  118#ifndef MT9F002_CENTER_Y 
  119#define MT9F002_CENTER_Y (MT9F002_OUTPUT_HEIGHT * (.5f - MT9F002_ZOOM * MT9F002_OFFSET_Y)) 
  121#ifndef MT9F002_DHANE_K 
  122#define MT9F002_DHANE_K 1.25f 
I2C transaction structure.
Architecture independent I2C (Inter-Integrated Circuit Bus) API.
uint16_t op_sys_clk_div
Fixed PLL config from calculator tool.
float target_exposure
Target exposure time in ms.
void mt9f002_reset_exposure(struct mt9f002_t *mt)
uint16_t scaled_height
Height after corrected scaling.
enum mt9f002_interface interface
Interface used to connect.
uint16_t op_pix_clk_div
Fixed PLL config from calculator tool.
void mt9f002_setting_update_color(float in)
uint8_t x_odd_inc
X increment for subsampling (1,3,7,15,31 accepted)
float input_clk_freq
Input clock frequency.
void mt9f002_set_gains(struct mt9f002_t *mt)
Sets the GreenR, Blue, Red and GreenB gains.
float gain_red
Gain for the Red pixels [1., 63.50].
uint16_t offset_x
Offset from left in pixels.
float gain_green2
Gain for the GreenB pixels [1., 63.50].
float target_fps
FPS wanted.
uint16_t output_width
Output width.
float set_zoom
Image zoom set point.
float vt_pix_clk
Calculated based on PLL.
float gain_green1
Gain for the GreenR pixels [1., 63.50].
uint8_t shift_vt_pix_clk_div
Fixed PLL config from calculator tool.
float set_offset_y
Signed fractional offset from centre of image of original sensor [-0.5,0.5].
uint16_t frame_length
Calculated frame length of blanking.
@ MT9F002_PARALLEL
Parallel type connection.
@ MT9F002_HiSPi
HiSPi type connection.
@ MT9F002_MIPI
MIPI type connection.
uint16_t pre_pll_clk_div
Fixed PLL config from calculator tool.
uint16_t output_height
Output height.
uint8_t row_speed_10_8
Fixed PLL config from calculator tool.
float op_pix_clk
Calculated based on PLL.
uint16_t scaled_width
Width after corrected scaling.
uint8_t rowSpeed_2_0
Fixed PLL config from calculator tool.
void mt9f002_init(struct mt9f002_t *mt)
Initialisation of the Aptina MT9F002 CMOS sensor (front camera)
uint16_t offset_y
Offset from top in pixels.
uint8_t y_odd_inc
Y increment for subsampling (1,3,7,15,31 accepted)
uint16_t vt_sys_clk_div
Fixed PLL config from calculator tool.
float gain_blue
Gain for the Blue pixels [1., 63.50].
float mt9f002_send_resolution
void mt9f002_setting_update_resolution(float in)
uint16_t output_scaler
Output scaler.
uint16_t vt_pix_clk_div
Fixed PLL config from calculator tool.
struct i2c_periph * i2c_periph
I2C peripheral used to communicate over.
void mt9f002_set_exposure(struct mt9f002_t *mt)
Set the exposure configuration Depends on the blanking (and therefore the FPS)
float mt9f002_send_exposure
void mt9f002_reset_color(struct mt9f002_t *mt)
uint16_t pll_multiplier
Fixed PLL config from calculator tool.
float real_exposure
Real exposure time in ms.
float set_offset_x
Signed fractional offset from centre of image of original sensor [-0.5,0.5].
uint16_t line_length
Calculated line length of blanking.
struct i2c_transaction i2c_trans
I2C transaction for communication with CMOS chip.
void mt9f002_setting_update_exposure(float in)
float real_fps
Real calculated FPS.
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.