FAQ
Which register read/write routines should I use?
In older versions of midlib the only register read/write routines were in the pCamera structure. For example pCamera->readSensorRegisters. With the addition of new address space types (MI_MCU_ADDR, MI_SFR_ADDR) with more recent sensors, higher level API calls were added.
The transport read/write register routines:
mi_readRegister and mi_writeRegister read and write one register at a time. This is the most basic request. It can be used for any type of SHIP or I2C register access, not just sensor registers.
mi_readRegisters and mi_writeRegisters can read and write to multiple sequential SHIP or I2C registers. If possible it will make the request in a single transaction in order to improve I/O performance.
mi_readSensorRegisters and mi_writeSensorRegisters are meant to be used for sensor registers only. Like mi_readRegisters and mi_writeRegisters, they will perform multiple sequential reads and writes. The address space is passed into this routine so that the address space register can be set to this value prior to reading or writing the register. These routines can only be used with MI_REG_ADDR sensor registers.
mi_readSensorRegisterList allows the user to read a non-sequential list of registers. It only has limited support and is not recommended for general use.
The "high level" read/write register functions:
mi_ReadSensorReg and mi_WriteSensorReg will read a sensor register given a pointer to the mi_reg_data_t structure. This can be used to read or write any type of sensor register (MCU variable, SFR register, multi-span register) as long it is defined in the sensor data file.
mi_ReadSensorRegStr and mi_WriteSensorRegStr are similar to the previous two function except that the Register name and bitfield name are passed into the function. This function can read any register defined in the sensor data file. Internally the routine will call the find functions to get the mi_reg_data_t structure and then call the above functions.
mi_ReadSensorRegAddr and mi_WriteSensorRegAddr are similar to the previous functions except that they require the user to pass in all of the relevant information, such as addrType and width. This function is only recommended to be used when the register is not defined in the sensor data file.
When to call the function mi_updateFrameSize(...)
mi_updateFrameSize() should be called whenever the output format of the sensor changes with respect to one or more of the following parameters: image width, height, bits per pixel, or number of clocks per pixel.
Midlib does not maintain the state of the sensor internally. This means that Midlib does not know about sensor output format changes that might occur because of a change that the host application has requested through a register settings operation.
It is the responsibility of the host application to maintain the state of the sensor, and to update Midlib whenever the frame output format changes.
If the amount of data that Midlib receives when mi_grabF rame() Aptina Imaging Device Library API#_mi_grabFrame() is called is smaller than the expected amount of data based these parameters the call will return MI_NOT_ENOUGH_DATA_ERROR.
Refer to the section mi_up d ateFrameSize() Aptina Imaging Device Library API#_mi_updateFrameSize() for more details about the use of this function.
Why does the field frameCounter equal 0?
The field frameNumber is part of the structure mi_frame_data_t which is returned by the call to mi_getFrameData().
The validity of this field depends on which camera hardware you are using. DEMO1 has a frame counter and would transmit the count in an additional USB packet after the image pixels. DEMO2 and DEMO2X do not have this capability, so frameNumber is always 0. DevWare's frame counter is not from the hardware; it is a variable incremented after grabFrame().
               pCamera->grabFrame();
               ++frameCount;
Sensors supporting SMIA embedded data can embed some register data including the frame counter register into the first two rows of image data. Embedded data must be enabled on the sensor, usually register 0x3064 bit 8.