📄 adcm2650_hw.c
字号:
// 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 adcm2650_viewfinder_off(void){ // 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 adcm2650_power_low(void){ // Enables low power mode bit LPE WO( CMD_1, CMD_1_LPE ); return ADCM_ERR_NONE;}int adcm2650_power_normal(void){ // Returns to normal power mode WA( CMD_1, ~CMD_1_LPE ); return ADCM_ERR_NONE;}int adcm2650_suspend(void){ // 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 adcm2650_wakeup(void){ // 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 adcm2650_abort_image(void){ // 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 adcm2650_snapshot_trigger(void){ // Requests a capture snapshot WO( CMD_2, CMD_2_SNAP ); return ADCM_ERR_NONE;}int adcm2650_snapshot_complete(void){ // Waits until the snapshot is complete RL( CMD_2, CMD_2_SNAP, 0x0000 ); return ADCM_ERR_NONE;}int adcm2650_snapshot_status(u16 *status){ R( CMD_2, status ); return ADCM_ERR_NONE;}int adcm2650_image_flip_v(u16 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 adcm2650_image_flip_h(u16 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 adcm2650_image_flip_vh(u16 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 adcm2650_pll_active(void){ // 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 adcm2650_pll_deactive(void){ // 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 adcm2650_pll_configuration(void){ return ADCM_ERR_NONE;}int adcm2650_pll_synchronized(void){ // Waits until normal operation RL( S_PLL_CTRL_0, S_PLL_CTRL_0_S_PLL_SE, 0x00 ); return ADCM_ERR_NONE;}int adcm2650_factory_overwrite(void){ // Disable the packet code WO( BYPASS_CTRL, BYPASS_CTRL_PCD ); // Free running VCLK W( OUTPUT_CTRL, 0x0 ); return ADCM_ERR_NONE;}int adcm2650_master_clock( u8 clk ){ W( MASTER_CLK_FREQ, ((u16)clk) << 8 ); return ADCM_ERR_NONE;}int adcm2650_sensor_voltage( u8 vltg ){ // Changes the sensor voltage to 2.8 //???? WS( 0x001c, 0xa0 ); return ADCM_ERR_NONE; }int adcm2650_viewfinder_input_size( adcm_window_size * window ){ // Input size width - viewfinder mode W( SZR_IN_W_VID, window->width ); // Input size height - viewfinder mode W( SZR_IN_H_VID, window->height ); return ADCM_ERR_NONE;}int adcm2650_stillframe_input_size( adcm_window_size * window ){ // Input size width - still frame mode W( SZR_IN_W_STL, window->width ); // Input size height - still frame mode W( SZR_IN_H_STL, window->height ); return ADCM_ERR_NONE;}int adcm2650_viewfinder_output_size(adcm_window_size * window){ // Output size width W( SZR_OUT_W_VID, window->width ); // Output size height W( SZR_OUT_H_VID, window->height); return ADCM_ERR_NONE;}int adcm2650_stillframe_output_size(adcm_window_size * window){ // Output size width W( SZR_OUT_W_STL, window->width ); // Output size height W( SZR_OUT_H_STL, window->height); return ADCM_ERR_NONE;}int adcm2650_flicker_rate(u16 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 adcm2650_low_light(void){ // Sets the bit to 60 Hz; sample duration is 25 WS( 0x0e, 0x19); return ADCM_ERR_NONE; }int adcm2650_normal_light(void){ // Sets the bit back to normal mode; sample duration is 4 WS( 0x0e, 0x04 ); return ADCM_ERR_NONE;}int adcm2650_discard_viewfinder_image_data(void){ // 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 adcm2650_stillframe_cfg_output(u16 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 adcm2650_viewfinder_cfg_output(u16 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 adcm2650_switch_to_jpeg(u16 mode){ if( mode == STILLFRAME_MODE ) { // Switches to JPEG output mode WO( STILL_CONFIG, STILL_CONFIG_JPEG_MASK ); } else if( mode == VIEWFINDER_MODE ) { //Changes still frame output mode to JPEG WO( VIDEO_CONFIG, VIDEO_CONFIG_JPEG_MASK ); } else { return ADCM_ERR_PARAMETER; } return ADCM_ERR_NONE;}int adcm2650_switch_to_normal(u16 mode){ if( mode == STILLFRAME_MODE ) { // Switches to Normal output mode WA( STILL_CONFIG, ~STILL_CONFIG_JPEG_MASK ); } else if( mode == VIEWFINDER_MODE ) { //Changes still frame output mode to NORMAL WA( VIDEO_CONFIG, ~VIDEO_CONFIG_JPEG_MASK ); } else { return ADCM_ERR_PARAMETER; } return ADCM_ERR_NONE;}int adcm2650_gamma_correction(void){ return ADCM_ERR_NONE;}int adcm2650_get_output_frame_rate(u16 * pfps){ u16 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 adcm2650_detect_camera_mode(u16 *mode){ u16 status; // Note!! Document is wrong. 0x0076 shall be 0x0074 instead. // Reads the Status_flag R( STATUS_FLAGS, &status ); if( (status & 0x08) == 0x08 ) { *mode = STILLFRAME_MODE; } else { *mode = VIEWFINDER_MODE; } return ADCM_ERR_NONE; }int adcm2650_wait_till_in_stillframe_mode(void){ // Note!! Document is wrong. 0x0076 shall be 0x0074 instead. RL( STATUS_FLAGS, 0x0008, 0x0008 ); return ADCM_ERR_NONE; }int adcm2650_camera_ready(void){ RL(AF_STATUS, 0x0008, 0x0008 ); return ADCM_ERR_NONE; }int adcm2650_halt_video_output(void){ // Halts the viewfinder output W( UART_CREDITS, 0x0000 ); return ADCM_ERR_NONE;}int adcm2650_get_single_image(void){ //Outputs a single frame W( UART_CREDITS, 0x001 ); return ADCM_ERR_NONE;}int adcm2650_resume_to_full_output_mode(void){ // Output still frames continuously W( UART_CREDITS, 0x0100 ); return ADCM_ERR_NONE;}int adcm2650_manual_q_table(void){ return ADCM_ERR_NONE;}void adcm2650_dump_pipeline_register(u16 startRegAddr, u16 endRegAddr, u16* buffer){ u16 addr; for(addr=startRegAddr; addr<=endRegAddr; addr+=2) adcm2650_pipeline_read( addr, buffer++ );}void adcm2650_dump_sensor_register(u16 startRegAddr, u16 endRegAddr, u8* buffer){ u16 addr; for(addr=startRegAddr; addr<=endRegAddr; addr++) adcm2650_sensor_read_rs((u8) addr, buffer++ );}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -