⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 camera.c

📁 嵌入式linuxMX21开发板数据采集程序
💻 C
字号:
/*
 * MX21 Camera Library API
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * Copyright (C) 2004 Motorola Semiconductors Hong Kong.
 *
 */

#include <stdlib.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <linux/fb.h>
#include <asm/mman.h>
#include <sys/mman.h>
#include <string.h>

#include "csi.h"
#include "csilib.h"
#include "ov9640.h"
#include "ov9640lib.h"
#include "camera.h"

static CSI_CFG g_csi_cfg;
static OV9640_CFG g_ov9640_cfg;

extern void ov9640_get_config(OV9640_CFG * _cfg, FILE * _fp);


void camera_run(void)
{
	ov9640_standby(0);

	return;
}


void camera_stop(void)
{
	ov9640_standby(1);

	return;	
}


int camera_init(FILE * _sensor_cfg_file)
{
//csi config
	csi_open();
	csi_select_config(TIMING_IMAGIC_RGB_PRP, &g_csi_cfg);
	csi_config(&g_csi_cfg);
	csi_dump_config();

//sensor config
	ov9640_open();
	ov9640_i2c_test();
	ov9640_select_config(OV9640_RGB_QVGA, &g_ov9640_cfg);
	if(_sensor_cfg_file)
		//in case using config file
		ov9640_get_config(&g_ov9640_cfg, _sensor_cfg_file);
	ov9640_config(&g_ov9640_cfg);

//printf("camera init done\n");

	return 0;
}


void camera_exit(void)
{
	ov9640_close();
	csi_close();	

//printf("camera exit\n");

	return;
}


void camera_set_preview_mode(void)
{
	ov9640_set_preview_mode();

//elapse for 1 frame
	csi_poll_sof();
	
	return;
}


void camera_set_capture_mode(void)
{
	ov9640_set_capture_mode();

//elapse for 1 frame
	csi_poll_sof();
	
	return;	
}




⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -