Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Ov7740_cmos_image_sensor_group

Low-level driver for the OV7740 CMOS image sensor.

This driver provides access to the main features of the OV7740 CMOS image sensor.

Modules

 

Functions

uint32_t ov_configure (Twi *const p_twi, const e_ov7740_format format)
 Configure the OV7740 sensor for a specified image size (pixel format). More...
 
uint32_t ov_configure_finish (Twi *const p_twi)
 Complete the OV7740 sensor configuration. More...
 
uint32_t ov_configure_manual (Twi *const p_twi)
 Configure the OV7740 sensor manually. More...
 
void ov_dump_registers (Twi *const p_twi, ov_reg *p_regs)
 Dump all registers. More...
 
static uint32_t ov_id (Twi *const p_twi)
 Read PID and VER. More...
 
uint32_t ov_init (Twi *const p_twi)
 Initialize the OV7740 sensor. More...
 
static uint32_t ov_manufacturer (Twi *const p_twi)
 Read Manufacturer. More...
 
void ov_power (uint32_t ul_on_off, Pio *const p_pio, const uint32_t ul_mask)
 Turn OV7740 sensor on/off using power pin. More...
 
uint32_t ov_read_reg (Twi *const p_twi, twi_packet_t *const p_packet)
 Read a value from a register in an OV7740 sensor device. More...
 
void ov_reset (Pio *const p_pio, const uint32_t ul_mask)
 Reset OV7740 sensor using power pin. More...
 
uint32_t ov_restore_manual (volatile uint32_t *p_backup_addr, uint32_t ul_size)
 Restore backup register manually. More...
 
static void ov_retrieve_manual (Twi *const p_twi)
 Retrieve register manually. More...
 
uint32_t ov_store_manual (Twi *const p_twi, volatile uint32_t *p_backup_addr, uint32_t ul_size)
 Store back up register manually. More...
 
static uint32_t ov_test_write (Twi *const p_twi)
 OV7740 test write. More...
 
uint32_t ov_write_reg (Twi *const p_twi, twi_packet_t *const p_packet)
 Write a specified value to a register of the OV7740 sensor. More...
 
uint32_t ov_write_regs (Twi *const p_twi, const ov_reg *p_reg_list)
 Initialize a list of OV7740 registers. More...
 

Variables

static ov_reg regs_manual []
 Register array for manual operation (given by OmniVision toolkit). More...
 

uint32_t ov_configure ( Twi *const  p_twi,
const e_ov7740_format  format 
)

Configure the OV7740 sensor for a specified image size (pixel format).

Parameters
p_twiTWI interface.
formatSpecific format to configure.
Returns
0 on success, 1 otherwise.

References NULL, OV7740_QQVGA_RGB888, OV7740_QQVGA_YUV422, OV7740_QVGA_RGB888, OV7740_QVGA_YUV422_10FPS, OV7740_QVGA_YUV422_15FPS, OV7740_QVGA_YUV422_20FPS, OV7740_QVGA_YUV422_30FPS, OV7740_TEST_PATTERN, OV7740_VGA_YUV422_20FPS, ov_write_regs(), QQVGA_RGB888, QQVGA_YUV422, QVGA_RGB888, QVGA_YUV422_10FPS, QVGA_YUV422_15FPS, QVGA_YUV422_20FPS, QVGA_YUV422_30FPS, TEST_PATTERN, and VGA_YUV422_20FPS.

Referenced by capture_init().

uint32_t ov_configure_finish ( Twi *const  p_twi)

Complete the OV7740 sensor configuration.

Parameters
p_twiTWI interface.

References twi_packet::addr, twi_packet::addr_length, twi_packet::buffer, twi_packet::chip, twi_packet::length, OV_I2C_SENSOR_ADDRESS, and ov_write_reg().

uint32_t ov_configure_manual ( Twi *const  p_twi)

Configure the OV7740 sensor manually.

Parameters
p_twiTWI interface.

References ov_write_regs().

void ov_dump_registers ( Twi *const  p_twi,
ov_reg p_regs 
)

Dump all registers.

Parameters
p_twiTWI interface.
p_regsRegister list to be dumped.

References twi_packet::addr, twi_packet::addr_length, twi_packet::buffer, twi_packet::chip, twi_packet::length, NULL, OV7740_YUV422CTRL, OV_I2C_SENSOR_ADDRESS, ov_read_reg(), _ov_reg::reg, and _ov_reg::val.

static uint32_t ov_id ( Twi *const  p_twi)
static

Read PID and VER.

Parameters
p_twiTWI interface.
Returns
PID and VER.

References twi_packet::addr, twi_packet::addr_length, twi_packet::buffer, twi_packet::chip, twi_packet::length, OV7740_PIDH, OV7740_PIDL, OV_I2C_SENSOR_ADDRESS, and ov_read_reg().

Referenced by ov_init().

uint32_t ov_init ( Twi *const  p_twi)

Initialize the OV7740 sensor.

Parameters
p_twiTWI interface.
Returns
0 on success, 1 otherwise.

References OV7740_PIDH_DEFAULT, ov_id(), ov_manufacturer(), and ov_test_write().

Referenced by capture_init().

static uint32_t ov_manufacturer ( Twi *const  p_twi)
static

Read Manufacturer.

Parameters
p_twiTWI interface.
Returns
0 if the sensor is present, 1 otherwise.

References twi_packet::addr, twi_packet::addr_length, twi_packet::buffer, twi_packet::chip, twi_packet::length, OV7740_MIDH, OV7740_MIDH_DEFAULT, OV7740_MIDL, OV7740_MIDL_DEFAULT, OV_I2C_SENSOR_ADDRESS, and ov_read_reg().

Referenced by ov_init().

void ov_power ( uint32_t  ul_on_off,
Pio *const  p_pio,
const uint32_t  ul_mask 
)

Turn OV7740 sensor on/off using power pin.

Parameters
on_off1 to turn on OV7740 sensor and 0 to turn off.
p_pioPointer to the PIO instance which control OV7740 sensor power.
ul_maskBitmask of OV7740 sensor power pin.

References pio_clear(), and pio_set().

Referenced by capture_init().

uint32_t ov_read_reg ( Twi *const  p_twi,
twi_packet_t *const  p_packet 
)

Read a value from a register in an OV7740 sensor device.

Parameters
p_twiTWI interface.
p_packetTWI packet.
Returns
0 on success, TWID_ERROR_BUSY otherwise.

References twi_master_read().

Referenced by ov_dump_registers(), ov_id(), ov_manufacturer(), ov_retrieve_manual(), and ov_test_write().

void ov_reset ( Pio *const  p_pio,
const uint32_t  ul_mask 
)

Reset OV7740 sensor using power pin.

Parameters
p_pioPointer to the PIO instance which controls the OV7740 sensor power pin.
ul_maskBitmask of the OV7740 sensor power pin.

References delay_ms, and pio_clear().

uint32_t ov_restore_manual ( volatile uint32_t *  p_backup_addr,
uint32_t  ul_size 
)

Restore backup register manually.

Parameters
p_backup_addrBackup register address.
Returns
ul_size on success, 0 otherwise.
static void ov_retrieve_manual ( Twi *const  p_twi)
static
uint32_t ov_store_manual ( Twi *const  p_twi,
volatile uint32_t *  p_backup_addr,
uint32_t  ul_size 
)

Store back up register manually.

Parameters
p_twiTWI interface.
p_backup_addrBackup register address.
Returns
ul_size on success, 0 otherwise.

References ov_retrieve_manual(), and _ov_reg::val.

static uint32_t ov_test_write ( Twi *const  p_twi)
static

OV7740 test write.

Parameters
p_twiTWI interface.
Returns
0 on success, 1 otherwise.

References twi_packet::addr, twi_packet::addr_length, twi_packet::buffer, twi_packet::chip, twi_packet::length, OV_I2C_SENSOR_ADDRESS, ov_read_reg(), and ov_write_reg().

Referenced by ov_init().

uint32_t ov_write_reg ( Twi *const  p_twi,
twi_packet_t *const  p_packet 
)

Write a specified value to a register of the OV7740 sensor.

Parameters
p_twiTWI interface.
p_packetTWI packet.
Returns
0 on success, TWID_ERROR_BUSY otherwise.

References twi_master_write().

Referenced by ov_configure_finish(), ov_test_write(), and ov_write_regs().

uint32_t ov_write_regs ( Twi *const  p_twi,
const ov_reg p_reg_list 
)

Initialize a list of OV7740 registers.

The list of registers is terminated by the pair of values {OV_REG_TERM, OV_VAL_TERM}.

Parameters
p_twiTWI interface.
p_reg_listRegister list to be written.
Returns
0 on success, TWID_ERROR_BUSY otherwise.

References twi_packet::addr, twi_packet::addr_length, twi_packet::buffer, twi_packet::chip, delay_ms, twi_packet::length, OV_I2C_SENSOR_ADDRESS, OV_REG_TERM, OV_VAL_TERM, ov_write_reg(), _ov_reg::reg, TWI_BUSY, and _ov_reg::val.

Referenced by ov_configure(), and ov_configure_manual().

ov_reg regs_manual[]
static
Initial value:
= {
{0x13, 0x0},
{0x0f, 0x0},
{0x10, 0x0},
{0x80, 0x0},
{0x01, 0x0},
{0x02, 0x0},
{0x03, 0x0},
{0xff, 0xff}
}

Register array for manual operation (given by OmniVision toolkit).

Referenced by ov_retrieve_manual().