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.

Functions

uint32_t ov_configure (Twihs *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 (Twihs *const p_twi)
 Complete the OV7740 sensor configuration. More...
 
uint32_t ov_configure_manual (Twihs *const p_twi)
 Configure the OV7740 sensor manually. More...
 
void ov_dump_registers (Twihs *const p_twi, ov_reg *p_regs)
 Dump all registers. More...
 
static uint32_t ov_id (Twihs *const p_twi)
 Read PID and VER. More...
 
uint32_t ov_init (Twihs *const p_twi)
 Initialize the OV7740 sensor. More...
 
static uint32_t ov_manufacturer (Twihs *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 (Twihs *const p_twi, twihs_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 (Twihs *const p_twi)
 Retrieve register manually. More...
 
uint32_t ov_store_manual (Twihs *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 (Twihs *const p_twi)
 OV7740 test write. More...
 
uint32_t ov_write_reg (Twihs *const p_twi, twihs_packet_t *const p_packet)
 Write a specified value to a register of the OV7740 sensor. More...
 
uint32_t ov_write_regs (Twihs *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 ( Twihs *const  p_twi,
const e_ov7740_format  format 
)
uint32_t ov_configure_finish ( Twihs *const  p_twi)

Complete the OV7740 sensor configuration.

Parameters
p_twiTWI interface.

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

uint32_t ov_configure_manual ( Twihs *const  p_twi)

Configure the OV7740 sensor manually.

Parameters
p_twiTWI interface.

References ov_write_regs().

void ov_dump_registers ( Twihs *const  p_twi,
ov_reg p_regs 
)

Dump all registers.

Parameters
p_twiTWI interface.
p_regsRegister list to be dumped.

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

static uint32_t ov_id ( Twihs *const  p_twi)
static

Read PID and VER.

Parameters
p_twiTWI interface.
Returns
PID and VER.

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

Referenced by ov_init().

uint32_t ov_init ( Twihs *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().

static uint32_t ov_manufacturer ( Twihs *const  p_twi)
static

Read Manufacturer.

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

References twihs_packet::addr, twihs_packet::addr_length, twihs_packet::buffer, twihs_packet::chip, twihs_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().

uint32_t ov_read_reg ( Twihs *const  p_twi,
twihs_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 twihs_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, pio_clear(), and pio_set().

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 ( Twihs *const  p_twi)
static
uint32_t ov_store_manual ( Twihs *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 ( Twihs *const  p_twi)
static

OV7740 test write.

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

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

Referenced by ov_init().

uint32_t ov_write_reg ( Twihs *const  p_twi,
twihs_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 twihs_master_write().

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

uint32_t ov_write_regs ( Twihs *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 twihs_packet::addr, twihs_packet::addr_length, twihs_packet::buffer, twihs_packet::chip, delay_ms, twihs_packet::length, OV_I2C_SENSOR_ADDRESS, OV_REG_TERM, OV_VAL_TERM, ov_write_reg(), _ov_reg::reg, TWIHS_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().