📄 adcm2650_hw.c
字号:
}
int ADCM2650FirmwareUpgrade()
{
int i;
FIRMUPDATE *pfu;
pfu = firmUpdate;
for( i = 0; i < 152; i++ )
{
W(pfu->addr, pfu->value);
pfu++;
}
return ADCM_ERR_NONE;
}
int ADCM2650VersionRevision(XLLP_UINT16_T * pCmRevision, XLLP_UINT8_T *pSensorRevision)
{
// Camera module version is 0x0600
R( REV, pCmRevision );
// Image sensor version is 0x60
RS( IDENT, pSensorRevision );
return ADCM_ERR_NONE;
}
int ADCM2650ViewfinderOn()
{
// Enables the viewfinder bits in VE
WO( CMD_1, CMD_1_VE );
// Once the viewfinder is turned on, wait until the camera
// module is ready to produce quality images.
RL( AF_STATUS, AF_STATUS_CC, AF_STATUS_CC );
return ADCM_ERR_NONE;
}
int ADCM2650ViewfinderOff()
{
// Turns the viewfinder off
WA( CMD_1, ~CMD_1_VE );
// Resets the converged bit
WA( AF_STATUS, ~AF_STATUS_CC );
return ADCM_ERR_NONE;
}
int ADCM2650PowerLow()
{
// Enables low power mode bit LPE
WO( CMD_1, CMD_1_LPE );
return ADCM_ERR_NONE;
}
int ADCM2650PowerNormal()
{
// Returns to normal power mode
WA( CMD_1, ~CMD_1_LPE );
return ADCM_ERR_NONE;
}
int ADCM2650Suspend()
{
// 1 Stops viewfinder mode
W( CMD_1, 0x0000 );
// 2 turn off M_CLK Turns off the clock
// 3 for 150 ms
WAIT( 150 );
return ADCM_ERR_NONE;
}
int ADCM2650Wakeup()
{
// 1 Turns on the clock M_CLK
// 2 Waits for 150 ms
WAIT( 150 );
// 3 Turns on viewfinder mode
W( CMD_1, 0x0001 );
return ADCM_ERR_NONE;
}
int ADCM2650AbortImage()
{
// 1 Aborts the progressive viewfinder image bit IA
WO( CMD_2, CMD_2_IA );
// 2 Waits until the IA bit is auto cleared
RL( CMD_2, CMD_2_IA, 0x0000 );
return ADCM_ERR_NONE;
}
int ADCM2650SnapshotTrigger()
{
// Requests a capture snapshot
WO( CMD_2, CMD_2_SNAP );
return ADCM_ERR_NONE;
}
int ADCM2650SnapshotComplete()
{
// Waits until the snapshot is complete
RL( CMD_2, CMD_2_SNAP, 0x0000 );
return ADCM_ERR_NONE;
}
int ADCM2650SnapshotStatus(XLLP_UINT16_T *pStatus)
{
R( CMD_2, pStatus );
return ADCM_ERR_NONE;
}
int ADCM2650ImageFlipV(XLLP_UINT16_T mode)
{
if( mode == VIEWFINDER_MODE )
{
WO( VIDEO_CONFIG, VIDEO_CONFIG_V_MIRROR );
}
else if( mode == STILLFRAME_MODE )
{
WO( STILL_CONFIG, STILL_CONFIG_V_MIRROR );
}
else
{
return ADCM_ERR_PARAMETER;
}
return ADCM_ERR_NONE;
}
int ADCM2650ImageFlipH(XLLP_UINT16_T mode)
{
if( mode == VIEWFINDER_MODE )
{
WO( VIDEO_CONFIG, VIDEO_CONFIG_H_MIRROR );
}
else if( mode == STILLFRAME_MODE )
{
WO( STILL_CONFIG, STILL_CONFIG_H_MIRROR );
}
else
{
return ADCM_ERR_PARAMETER;
}
return ADCM_ERR_NONE;
}
int ADCM2650ImageFlipVH(XLLP_UINT16_T mode)
{
if( mode == VIEWFINDER_MODE )
{
WO( VIDEO_CONFIG, VIDEO_CONFIG_H_MIRROR|VIDEO_CONFIG_V_MIRROR );
}
else if( mode == STILLFRAME_MODE )
{
WO( STILL_CONFIG, STILL_CONFIG_H_MIRROR|STILL_CONFIG_V_MIRROR );
}
else
{
return ADCM_ERR_PARAMETER;
}
return ADCM_ERR_NONE;
}
int ADCM2650PllActive()
{
// Starts PLL request
WO( CMD_2, CMD_2_PLL_ON | CMD_2_UCGS );
// Checks PLL request is complete
RL( CMD_2, CMD_2_PLL_ON | CMD_2_UCGS, 0x0 );
return ADCM_ERR_NONE;
}
int ADCM2650PllDeactive()
{
// Disables PLL
WO( CMD_2, CMD_2_PLL_OFF );
// Checks PLL disable request is complete
RL( CMD_2, CMD_2_PLL_OFF, 0x0 );
return ADCM_ERR_NONE;
}
int ADCM2650PllConfiguration()
{
return ADCM_ERR_NONE;
}
int ADCM2650PllSynchronized()
{
// Waits until normal operation
RL( S_PLL_CTRL_0, S_PLL_CTRL_0_S_PLL_SE, 0x00 );
return ADCM_ERR_NONE;
}
int ADCM2650FactoryOverwrite()
{
// Disable the packet code
WO( BYPASS_CTRL, BYPASS_CTRL_PCD );
// Free running VCLK
W( OUTPUT_CTRL, 0x0 );
return ADCM_ERR_NONE;
}
int ADCM2650MasterClock( XLLP_UINT8_T clk )
{
W( MASTER_CLK_FREQ, ((XLLP_UINT16_T)clk) << 8 );
return ADCM_ERR_NONE;
}
int ADCM2650SensorVoltage( XLLP_UINT8_T vltg )
{
// Changes the sensor voltage to 2.8 //????
WS( 0x001c, 0xa0 );
return ADCM_ERR_NONE;
}
int ADCM2650ViewfinderInputSize( ADCM_WINDOWSIZE * pWindow )
{
// Input size width - viewfinder mode
W( SZR_IN_W_VID, pWindow->width );
// Input size height - viewfinder mode
W( SZR_IN_H_VID, pWindow->height );
return ADCM_ERR_NONE;
}
int ADCM2650StillframeInputSize( ADCM_WINDOWSIZE * pWindow )
{
// Input size width - still frame mode
W( SZR_IN_W_STL, pWindow->width );
// Input size height - still frame mode
W( SZR_IN_H_STL, pWindow->height );
return ADCM_ERR_NONE;
}
int ADCM2650ViewfinderOutputSize(ADCM_WINDOWSIZE * pWindow)
{
// Output size width
W( SZR_OUT_W_VID, pWindow->width );
// Output size height
W( SZR_OUT_H_VID, pWindow->height);
return ADCM_ERR_NONE;
}
int ADCM2650StillframeOutputSize(ADCM_WINDOWSIZE * pWindow)
{
// Output size width
W( SZR_OUT_W_STL, pWindow->width );
// Output size height
W( SZR_OUT_H_STL, pWindow->height);
return ADCM_ERR_NONE;
}
int ADCM2650FlickerRate(XLLP_UINT16_T rate)
{
if( rate == AEF_50HZ )
{
// Clears the AE_F bit and sets it to 50 Hz
WA( 0x2022, 0xfffd );
}
else if( rate == AEF_60HZ )
{
// Sets the AE_F bit to 60 Hz
WO( 0x2022, 0x0002 );
}
else
{
return ADCM_ERR_PARAMETER;
}
return ADCM_ERR_NONE;
}
int ADCM2650LowLight()
{
// Sets the bit to 60 Hz; sample duration is 25
WS( 0x0e, 0x19);
return ADCM_ERR_NONE;
}
int ADCM2650NormalLight()
{
// Sets the bit back to normal mode; sample duration is 4
WS( 0x0e, 0x04 );
return ADCM_ERR_NONE;
}
int ADCM2650DiscardViewfinderImageData()
{
// Discards the current image viewfinder data
W( 0x0004, 0x1000 );
// Waits until the image abort is complete
RL(0x0004, 0x1000, 0x0000 );
return ADCM_ERR_NONE;
}
int ADCM2650StillFrameCfgOutput(XLLP_UINT16_T format)
{
//Clear bits 8..11
WA( STILL_CONFIG, ~STILL_CONFIG_O_FORMAT_MASK );
// Where format is bits 8..11
WO( STILL_CONFIG, format << STILL_CONFIG_O_FORMAT_SHIFT );
return ADCM_ERR_NONE;
}
int ADCM2650ViewfinderCfgOutput(XLLP_UINT16_T format)
{
//Clear bits 8..11
WA( VIDEO_CONFIG, ~VIDEO_CONFIG_O_FORMAT_MASK );
// Where format is bits 8..11
WO( VIDEO_CONFIG, format << VIDEO_CONFIG_O_FORMAT_SHIFT );
return ADCM_ERR_NONE;
}
int ADCM2650SwitchToJpeg(XLLP_UINT16_T mode)
{
if( mode == STILLFRAME_MODE )
{
// Switches to JPEG output mode
WO( STILL_CONFIG, STILL_CONFIG_JPEG_MASK );
}
else if( mode == VIEWFINDER_MODE )
{
//Turns the viewfinder off
// ADCM2650ViewfinderOff();
//Changes still frame output mode to JPEG
WO( VIDEO_CONFIG, VIDEO_CONFIG_JPEG_MASK );
//Turns the viewfinder back on
// ADCM2650ViewfinderOn();
}
else
{
return ADCM_ERR_PARAMETER;
}
return ADCM_ERR_NONE;
}
int ADCM2650SwitchToNormal(XLLP_UINT16_T mode)
{
if( mode == STILLFRAME_MODE )
{
// Switches to Normal output mode
WA( STILL_CONFIG, ~STILL_CONFIG_JPEG_MASK );
}
else if( mode == VIEWFINDER_MODE )
{
//Turns the viewfinder off
// ADCM2650ViewfinderOff();
//Changes still frame output mode to NORMAL
WA( VIDEO_CONFIG, ~VIDEO_CONFIG_JPEG_MASK );
//Turns the viewfinder back on
// ADCM2650ViewfinderOn();
}
else
{
return ADCM_ERR_PARAMETER;
}
return ADCM_ERR_NONE;
}
int ADCM2650GammaCorrection()
{
return ADCM_ERR_NONE;
}
int ADCM2650GetOutputFrameRate(XLLP_UINT16_T * pfps)
{
XLLP_UINT16_T fps;
// Resets the frame counter
W( OUT_FRAME_CNT, 0x0000 );
// Waits for one second
WAIT( 1000 );
// Number of frames outputting the lower 8 bits
R( OUT_FRAME_CNT, &fps );
*pfps = fps & 0xFF;
return ADCM_ERR_NONE;
}
int ADCM2650DetectCameraMode(XLLP_UINT16_T *pMode)
{
XLLP_UINT16_T status;
// Note!! Document is wrong. 0x0076 shall be 0x0074 instead.
// Reads the Status_flag
R( STATUS_FLAGS, &status );
if( (status & 0x08) == 0x08 )
{
*pMode = STILLFRAME_MODE;
}
else
{
*pMode = VIEWFINDER_MODE;
}
return ADCM_ERR_NONE;
}
int ADCM2650WaitTillInStillFrameMode()
{
// Note!! Document is wrong. 0x0076 shall be 0x0074 instead.
RL( STATUS_FLAGS, 0x0008, 0x0008 );
return ADCM_ERR_NONE;
}
int ADCM2650CameraReady()
{
RL(AF_STATUS, 0x0008, 0x0008 );
return ADCM_ERR_NONE;
}
int ADCM2650HaltVideoOutput()
{
// Halts the viewfinder output
W( UART_CREDITS, 0x0000 );
return ADCM_ERR_NONE;
}
int ADCM2650GetSingleImage()
{
//Outputs a single frame
W( UART_CREDITS, 0x001 );
return ADCM_ERR_NONE;
}
int ADCM2650ResumetoFullOutputMode()
{
// Output still frames continuously
W( UART_CREDITS, 0x0100 );
return ADCM_ERR_NONE;
}
int ADCM2650ManualQTable()
{
return ADCM_ERR_NONE;
}
void ADCM2650DumpPipelineRegister(XLLP_UINT16_T startRegAddr, XLLP_UINT16_T endRegAddr, XLLP_UINT16_T* buffer)
{
XLLP_UINT16_T addr;
for(addr=startRegAddr; addr<=endRegAddr; addr+=2)
ADCM2650PipelineRead( addr, buffer++ );
}
void ADCM2650DumpSensorRegister(XLLP_UINT16_T startRegAddr, XLLP_UINT16_T endRegAddr, XLLP_UINT8_T* buffer)
{
XLLP_UINT16_T addr;
for(addr=startRegAddr; addr<=endRegAddr; addr++)
ADCM2650SensorReadRS((XLLP_UINT8_T) addr, buffer++ );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -