- Main Page
- Modules
- Data Structures
- Files
- Directories

# e_po3030k.h File Reference

PO3030k library header (two timers). More...

## Defines
#define | PO3030K_FULL 1
#define | ARRAY_WIDTH 640
#define | ARRAY_HEIGHT 480
#define | GREY_SCALE_MODE 0
#define | RGB_565_MODE 1
#define | YUV_MODE 2
#define | MODE_VGA 0x44
#define | MODE_QVGA 0x11
#define | MODE_QQVGA 0x33
#define | SPEED_2 0x00
#define | SPEED_2_3 0x10
#define | SPEED_4 0x20
#define | SPEED_8 0x30
#define | SPEED_16 0x40
#define | SPEED_32 0x50
#define | SPEED_64 0x60
#define | SPEED_128 0x70
## Functions
int | e_po3030k_config_cam (unsigned int sensor_x1, unsigned int sensor_y1, unsigned int sensor_width, unsigned int sensor_height, unsigned int zoom_fact_width, unsigned int zoom_fact_height, int color_mode)
int | e_po3030k_get_bytes_per_pixel (int color_mode)
void | e_po3030k_init_cam (void)
void | e_po3030k_write_cam_registers (void)
void | e_po3030k_launch_capture (char *buf)
int | e_po3030k_apply_timer_config (int pixel_row, int pixel_col, int bpp, int pbp, int bbl)
int | e_po3030k_is_img_ready (void)
int | e_po3030k_set_color_mode (int mode)
int | e_po3030k_set_sampling_mode (int mode)
int | e_po3030k_set_speed (int mode)
int | e_po3030k_set_wx (unsigned int start, unsigned int stop)
int | e_po3030k_set_wy (unsigned int start, unsigned int stop)
int | e_po3030k_set_vsync (unsigned int start, unsigned int stop, unsigned int col)
void | e_po3030k_set_mirror (int vertical, int horizontal)
void | e_po3030k_read_cam_registers (void)
int | e_po3030k_set_register (unsigned char adr, unsigned char value)
int | e_po3030k_get_register (unsigned char adr, unsigned char *value)
void | e_po3030k_set_bias (unsigned char pixbias, unsigned char opbias)
void | e_po3030k_set_integr_time (unsigned long time)
void | e_po3030k_set_adc_offset (unsigned char offset)
void | e_po3030k_set_sepia (int status)
void | e_po3030k_set_lens_gain (unsigned char red, unsigned char green, unsigned char blue)
void | e_po3030k_set_edge_prop (unsigned char gain, unsigned char tresh)
void | e_po3030k_set_gamma_coef (unsigned char array[12], char color)
void | e_po3030k_write_gamma_coef (void)
int | e_po3030k_sync_register_array (unsigned char start, unsigned char stop)
void | e_po3030k_set_color_matrix (unsigned char array[3 *3])
void | e_po3030k_set_cb_cr_gain (unsigned char cg11c, unsigned char cg22c)
void | e_po3030k_set_brigh_contr (unsigned char bright, unsigned char contrast)
void | e_po3030k_set_sepia_tone (unsigned char cb, unsigned char cr)
void | e_po3030k_set_ww (unsigned char ww)
void | e_po3030k_set_awb_ae_tol (unsigned char awbm, unsigned char aem)
void | e_po3030k_set_ae_speed (unsigned char b, unsigned char d)
void | e_po3030k_set_exposure (long t)
void | e_po3030k_set_ref_exposure (unsigned char exp)
void | e_po3030k_set_max_min_exp (unsigned int min, unsigned int max)
void | e_po3030k_set_max_min_awb (unsigned char minb, unsigned char maxb, unsigned char minr, unsigned char maxr, unsigned char ratior, unsigned char ratiob)
int | e_po3030k_set_weight_win (unsigned int x1, unsigned int x2, unsigned int y1, unsigned int y2)
void | e_po3030k_set_awb_ae (int awb, int ae)
int | e_po3030k_set_color_gain (unsigned char global, unsigned char red, unsigned char green1, unsigned char green2, unsigned char blue)
void | e_po3030k_set_flicker_mode (int manual)
void | e_po3030k_set_flicker_detection (int hz50, int hz60)
int | e_po3030k_set_flicker_man_set (int hz50, int hz60, int fdm, int fk, int tol)

## Detailed Description

PO3030k library header (two timers).

Author:
  Philippe Rétornaz

## Define Documentation

#define ARRAY_HEIGHT 480

#define ARRAY_WIDTH 640

#define GREY_SCALE_MODE 0

#define MODE_QQVGA 0x33

#define MODE_QVGA 0x11

#define MODE_VGA 0x44

#define PO3030K_FULL 1

If you set this at 0, you save about 168 bytes of memory But you loose all advanced camera functions

#define RGB_565_MODE 1

#define SPEED_128 0x70

#define SPEED_16 0x40

#define SPEED_2 0x00

#define SPEED_2_3 0x10

#define SPEED_32 0x50

#define SPEED_4 0x20

#define SPEED_64 0x60

#define SPEED_8 0x30

#define YUV_MODE 2

## Function Documentation

int e_po3030k_apply_timer_config | ( | int | pixel_row,
|  | int | pixel_col,
|  | int | bpp,
|  | int | pbp,
|  | int | bbl |
| ) |  |  |

Modify the interrupt configuration

Warning:
  This is an internal function, use e_po3030k_config_cam

Parameters:

  | pixel_row | The number of row to take
  | pixel_col | The number of pixel to take each pixel_row
  | bpp | The number of byte per pixel
  | pbp | The number of pixel to ignore between each pixel
  | bbl | The number of row to ignore between each line

Returns:
  Zero if OK, non-zero if the mode exceed internal data representation

See also:
  e_po3030k_get_bytes_per_pixel and e_po3030k_config_cam

Modify the interrupt configuration

Warning:
  This is an internal function, use e_po3030k_config_cam

Parameters:

  | pixel_row | The number of row to take
  | pixel_col | The number of pixel to take each pixel_row
  | bpp | The number of byte per pixel
  | pbp | The number of pixel to ignore between each pixel
  | bbl | The number of row to ignore between each line

See also:
  e_po3030k_get_bytes_per_pixel and e_po3030k_config_cam

int e_po3030k_config_cam | ( | unsigned int | sensor_x1,
|  | unsigned int | sensor_y1,
|  | unsigned int | sensor_width,
|  | unsigned int | sensor_height,
|  | unsigned int | zoom_fact_width,
|  | unsigned int | zoom_fact_height,
|  | int | color_mode |
| ) |  |  |

This function setup the internal timing of the camera to match the zoom, color mode and interest area.

Warning:
  If the common deniminator of both zoom factor is 4 or 2, part of the subsampling is done by the camera ( QQVGA = 4, QVGA = 2 ). This increase the framerate by respectivly 4 or 2. Moreover greyscale is twice faster than color mode.

Parameters:

  | sensor_x1 | The X coordinate of the window's corner
  | sensor_y1 | The Y coordinate of the window's corner
  | sensor_width | the Width of the interest area, in FULL sampling scale
  | sensor_height | The Height of the insterest area, in FULL sampling scale
  | zoom_fact_width | The subsampling to apply for the window's Width
  | zoom_fact_height | The subsampling to apply for the window's Height
  | color_mode | The color mode in which the camera should be configured

Returns:
  Zero if the settings are correct, non-zero if an error occur

See also:
  e_po3030k_write_cam_registers

This function setup the internal timing of the camera to match the zoom, color mode and interest area.

Warning:
  If the common deniminator of both zoom factor is 4 or 2, part of the subsampling is done by the camera ( QQVGA = 4, QVGA = 2 ). This increase the framerate by respectivly 4 or 2.

Parameters:

  | sensor_x1 | The X coordinate of the window's corner
  | sensor_y1 | The Y coordinate of the window's corner
  | sensor_width | the Width of the interest area, in FULL sampling scale
  | sensor_height | The Height of the insterest area, in FULL sampling scale
  | zoom_fact_width | The subsampling to apply for the window's Width
  | zoom_fact_height | The subsampling to apply for the window's Height
  | color_mode | The color mode in which the camera should be configured

Returns:
  Zero if the settings are correct, non-zero if an error occur

See also:
  e_po3030k_write_cam_registers

int e_po3030k_get_bytes_per_pixel | ( | int | color_mode | ) |

Return the number of bytes per pixel in the given color mode

Parameters:

  | color_mode | The given color mode

Returns:
  The number of bytes per pixel in the given color mode

int e_po3030k_get_register | ( | unsigned char | adr,
|  | unsigned char * | value |
| ) |  |  |

Get the register adr value

Parameters:

  | adr | The address
  | value | The pointer to the value to write to

Returns:
  Zero if register found, non-zero if not found

Warning:
  This function is sub-optimal, if you use it heavly add an internal function to register.c

See also:
  e_po3030k_set_register

void e_po3030k_init_cam | ( | void |  | ) |

Initialize the camera, must be called before any other function

int e_po3030k_is_img_ready | ( | void |  | ) |

Check if the current capture is finished

Returns:
  Zero if the current capture is in progress, non-zero if the capture is done.

See also:
  e_po3030k_launch_capture

void e_po3030k_launch_capture | ( | char * | buf | ) |

Launch a capture in the buf buffer

Parameters:

  | buf | The buffer to write to

See also:
  e_po3030k_config_cam and e_po3030k_is_img_ready

void e_po3030k_read_cam_registers | ( | void |  | ) |

Read the camera register

See also:
  e_po3030k_write_cam_registers

void e_po3030k_set_adc_offset | ( | unsigned char | offset | ) |

Set the Analog to Digital Converter offset

Parameters:

  | offset | The offset

See also:
  Datasheet p.28

void e_po3030k_set_ae_speed | ( | unsigned char | b,
|  | unsigned char | d |
| ) |  |  |

Set AE speed

Parameters:

  | b | AE speed factor when exposure time is decreasing ( 4 lower bits only )
  | d | AE speed factor when exposure time is increasing ( 4 lower bits only )

See also:
  Datasheet p.44

void e_po3030k_set_awb_ae | ( | int | awb,
|  | int | ae |
| ) |  |  |

Enable/Disable AWB and AE

Parameters:

  | awb | 1 mean AWB enabled, 0 mean disabled
  | ae | 1 mean AE enabled, 0 mean disabled

See also:
  Datasheet p. 50

void e_po3030k_set_awb_ae_tol | ( | unsigned char | awbm,
|  | unsigned char | aem |
| ) |  |  |

Set AWB/AE tolerence margin

Parameters:

  | awbm | AWV Margin ( 4 lower bits only )
  | aem | AW Margin ( 4 lower bits only )

See also:
  Datasheet p.44

void e_po3030k_set_bias | ( | unsigned char | pixbias,
|  | unsigned char | opbias |
| ) |  |  |

Set the Pixel and amplificator bias Increasing the bias produce better image quality, but increase camera's power consumption

Parameters:

  | pixbias | The pixel bias
  | opbias | The Amplificator bias

See also:
  Datasheet p.22

void e_po3030k_set_brigh_contr | ( | unsigned char | bright,
|  | unsigned char | contrast |
| ) |  |  |

Set the Brightness & Contrast

Parameters:

  | bright | The Brightness ( signed 1+7bits fixed point format )
  | contrast | The Contrast

See also:
  Datasheet p. 40

void e_po3030k_set_cb_cr_gain | ( | unsigned char | cg11c,
|  | unsigned char | cg22c |
| ) |  |  |

Set The color gain ( Cb/Cr )

Parameters:

  | cg11c | Cb gain ( Sign[7] | Integer[6:5] | fractional[4:0] )
  | cg22c | Cr gain ( Sign[7] | Integer[6:5] | fractional[4:0] )

See also:
  Datasheet p. 40

int e_po3030k_set_color_gain | ( | unsigned char | global,
|  | unsigned char | red,
|  | unsigned char | green1,
|  | unsigned char | green2,
|  | unsigned char | blue |
| ) |  |  |

Set the gains of the camera

Parameters:

  | global | The global gain
  | red | The red pixel's gain (fixed point [2:6] format)
  | green1 | The green pixel near read one gain ([2:6] format)
  | green2 | The green pixel near blue one gain ([2:6] format)
  | blue | The blue pixel's gain ([2:6] format)

Returns:
  Zero if OK, non-zero if an error occur

See also:
  Datasheet p.23-24

void e_po3030k_set_color_matrix | ( | unsigned char | array[3 *3] | ) |

int e_po3030k_set_color_mode | ( | int | mode | ) |

Set the camera color mode

Warning:
  This is an internal function, use e_po3030k_config_cam

Parameters:

  | mode | The color mode

Returns:
  Zero if OK, non-zero if an error occur

See also:
  Datasheet p. 31, e_po3030k_write_cam_registers and e_po3030k_config_cam

void e_po3030k_set_edge_prop | ( | unsigned char | gain,
|  | unsigned char | tresh |
| ) |  |  |

Set Edge properties

Parameters:

  | gain | Edge gain & moire factor (fixed point [2:3] format)
  | tresh | Edge Enhancement threshold

See also:
  Datasheet p.36

void e_po3030k_set_exposure | ( | long | t | ) |

Set exposure time

Parameters:

  | t | Exposure time, LSB is in 1/64 line time

Warning:
  Only writable if AE is disabled

See also:
  Datasheet p.45

void e_po3030k_set_flicker_detection | ( | int | hz50,
|  | int | hz60 |
| ) |  |  |

Set the 50/60Hz flicker detection

Parameters:

  | hz50 | Non-zero mean 50Hz flicker detection enabled (default disabled)
  | hz60 | Non-zero mean 60Hz flicker detection enabled (default disabled)

Warning:
  If Automatic mode is enabled and both 50Hz and 60Hz are disabled, camera will enable both. By default, the camera automatically detect 50 and 60Hz flicker.

See also:
  Datasheet p.29 e_po3030k_set_flicker_mode() e_po3030k_set_flicker_man_set()

int e_po3030k_set_flicker_man_set | ( | int | hz50,
|  | int | hz60,
|  | int | fdm,
|  | int | fk,
|  | int | tol |
| ) |  |  |

Set the camera's manual flicker's detection setting

Parameters:

  | hz50 | The Hz for the 50Hz detection
  | hz60 | The Hz for the 60Hz detection
  | fdm | Flicker duration mode
  | fk | Flicker count step
  | tol | Flicker tolerance

Warning:
  You must have set the mode ( image size, color ) before calling this function

Returns:
  Non-zero if an error occur, 0 if OK

See also:
  Datasheet p.29-30 e_po3030k_set_flicker_detection() e_po3030k_set_flicker_mode()

void e_po3030k_set_flicker_mode | ( | int | manual | ) |

Set flicker detection mode

Parameters:

  | manual | Non-zero mean manual mode is enabled ( default automatic mode enabled )

See also:
  Datasheet p.29 e_po3030k_set_flicker_detection() e_po3030k_set_flicker_man_set()

void e_po3030k_set_gamma_coef | ( | unsigned char | array[12],
|  | char | color |
| ) |  |  |

Set gamma coefficient

Warning:
  This feature need extra care from the user

Parameters:

  | array | Gamma coefficient array
  | color | First two bytes : - 0b01 => Green 0b00 => Red else => Blue

See also:
  Datasheet p. 38, 50, 57-58 and e_po3030k_WriteGammaCoef

void e_po3030k_set_integr_time | ( | unsigned long | time | ) |

Set the pixel intergration time This is counted in line-time interval. See dataseet p.25 for more information

Parameters:

  | time | The integration time ( fixed point [14:6] format )

See also:
  Datasheet p.25

void e_po3030k_set_lens_gain | ( | unsigned char | red,
|  | unsigned char | green,
|  | unsigned char | blue |
| ) |  |  |

Set lens shading gain

Parameters:

  | red | Lens gain for red pixel
  | green | Lens gain for green pixel
  | blue | Lens gain for blue pixel

See also:
  Datasheet p.36

void e_po3030k_set_max_min_awb | ( | unsigned char | minb,
|  | unsigned char | maxb,
|  | unsigned char | minr,
|  | unsigned char | maxr,
|  | unsigned char | ratior,
|  | unsigned char | ratiob |
| ) |  |  |

Set the minimum and maximum red and blue gain in AWB mode

Parameters:

  | minb | The minimum blue gain
  | maxb | The maximum blue gain
  | minr | The minimum red gain
  | maxr | The maximum red gain
  | ratior | The red gain ratio
  | ratiob | The blue gain ratio

See also:
  Datasheet p. 47-48

void e_po3030k_set_max_min_exp | ( | unsigned int | max,
|  | unsigned int | min |
| ) |  |  |

Set the minimum and maximum exposure time in AE mode

Parameters:

  | min | The minimum exposure time
  | max | The maximum exposure time

See also:
  Datasheet p.46-47

void e_po3030k_set_mirror | ( | int | vertical,
|  | int | horizontal |
| ) |  |  |

Enable/Disable horizontal or vertical mirror

Parameters:

  | vertical | Set to 1 when vertical mirror is enabled, 0 if disabled
  | horizontal | Set to 1 when horizontal mirror is enabled, 0 if disabled

See also:
  Datasheet p.27

void e_po3030k_set_ref_exposure | ( | unsigned char | exp | ) |

Set the reference exposure. The average brightness which the AE should have

Parameters:

  | exp | The target exposure level

See also:
  Datasheet p.45

int e_po3030k_set_register | ( | unsigned char | adr,
|  | unsigned char | value |
| ) |  |  |

Set the register adr to value value

Parameters:

  | adr | The address
  | value | The value

Returns:
  Zero if register found, non-zero if not found

Warning:
  This function is sub-optimal, if you use it heavly add an internal function to register.c

See also:
  e_po3030k_get_register

int e_po3030k_set_sampling_mode | ( | int | mode | ) |

Set the camera sampling mode

Warning:
  This is an internal function, use e_po3030k_config_cam

Parameters:

  | mode | The given sampling mode

Returns:
  Zero if OK, non-zero if an error occur

See also:
  Datasheet p. 28 and e_po3030k_config_cam

void e_po3030k_set_sepia | ( | int | status | ) |

Enable/Disable Sepia color

Parameters:

  | status | Set status to 1 to enable, 0 to disable

See also:
  Datasheet p.34 and 74

void e_po3030k_set_sepia_tone | ( | unsigned char | cb,
|  | unsigned char | cr |
| ) |  |  |

Set The color tone at sepia color condition

Parameters:

  | cb | Cb tone
  | cr | Cr tone

See also:
  e_po3030k_set_sepia and Datasheet p. 41 and 74

int e_po3030k_set_speed | ( | int | mode | ) |

Set the camera speed

Warning:
  This is an internal function, use e_po3030k_config_cam

Parameters:

  | mode | The given speed

Returns:
  Zero if OK, non-zero if unknow mode

See also:
  Datasheet p. 26 and e_po3030k_config_cam

int e_po3030k_set_vsync | ( | unsigned int | start,
|  | unsigned int | stop,
|  | unsigned int | col |
| ) |  |  |

Set the camera window VSYNC coordinate

Warning:
  This is an internal function, use e_po3030k_ConfigCam

Parameters:

  | start | The start row
  | stop | The stop row
  | col | The start/stop column

Returns:
  Zero if OK, non-zero if an error occur

See also:
  Datasheet p.42-43, e_po3030k_write_cam_registers and e_po3030k_config_cam

int e_po3030k_set_weight_win | ( | unsigned int | x1,
|  | unsigned int | x2,
|  | unsigned int | y1,
|  | unsigned int | y2 |
| ) |  |  |

Set the Weighting Window coordinate

Parameters:

  | x1 | The X1 coordinate
  | x2 | The X2 coordinate
  | y1 | The Y1 coordinate
  | y2 | The Y2 coordinate

Returns:
  Zero if OK, non-zero if an error occur

See also:
  Datasheet p. 49

void e_po3030k_set_ww | ( | unsigned char | ww | ) |

Set the Center weight (Back Light compensation) Control parameter

Parameters:

  | ww | Center weight ( 4 lower bits only )

See also:
  Datasheet p.44

int e_po3030k_set_wx | ( | unsigned int | start,
|  | unsigned int | stop |
| ) |  |  |

Set the camera window X coordinate

Warning:
  This is an internal function, use e_po3030k_ConfigCam

Parameters:

  | start | The start column
  | stop | The stop column

Returns:
  Zero if OK, non-zero if an error occur

See also:
  Datasheet p.20-21, e_po3030k_write_cam_registers, e_po3030k_set_wy and e_po3030k_config_cam

int e_po3030k_set_wy | ( | unsigned int | start,
|  | unsigned int | stop |
| ) |  |  |

Set the camera window Y coordinate

Warning:
  This is an internal function, use e_po3030k_ConfigCam

Parameters:

  | start | The start row
  | stop | The stop row

Returns:
  Zero if OK, non-zero if an error occur

See also:
  Datasheet p.20-21, e_po3030k_WriteCamRegisters, e_po3030k_SetWX and e_po3030k_ConfigCam

int e_po3030k_sync_register_array | ( | unsigned char | start,
|  | unsigned char | stop |
| ) |  |  |

Write every known register between address start and stop (inclusivly).

Warning:
  It's better to set the configuration with appropriate functions and then write all registers with e_po3030k_WriteCamRegisters

Parameters:

  | start | The beginning address of the write
  | stop | The last write address

Returns:
  The number of register written

See also:
  e_po3030k_write_cam_registers

void e_po3030k_write_cam_registers | ( | void |  | ) |

The Po3030k module keep in memory the state of each register the camera has. When you configure the camera, it only alter the internal register state, not the camera one. This function write the internal register state in the camera.

See also:
  e_po3030k_read_cam_registers

void e_po3030k_write_gamma_coef | ( | void |  | ) |

This special function write directly the Gamma coefficient and Gamma color select into camera register.

Warning:
  This function need extra care from the user

See also:
  e_po3030k_set_gamma_coef