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

📄 camproset.c

📁 wince bsp 原文件, 在s3c2442上使用
💻 C
字号:
/****************************************************************************** Filename:	camproset.c Descriptions		 - Camera Processor Initialization code using SCCB. - SCCB(Serial Camera Contol Bus) H/W dependent code. - Camera Processor Initialization code using IIC. History  - July 23, 2003. Draft Version 0.0 by purnnamu  - Janualy 15, 2004. Modifed by Boaz  - Feb. 10, 2004. Modified by junon for S3C2440A  Copyright (c) 2003 SAMSUNG Electronics. # However, Anybody can use this code without our permission.   ******************************************************************************/#include <stdlib.h>#include <stdarg.h>#include "def.h"#include "2440addr.h"#define CAMIICBUFSIZE 0x20#define WRDATA      (1)#define POLLACK     (2)#define RDDATA      (3)#define SETRDADDR   (4)#define IICBUFSIZE 0x20void Run_IicPoll(void); void IicPoll(void);static U8 _iicData[IICBUFSIZE];static volatile int _iicDataCount;static volatile int _iicStatus;static volatile int _iicMode;static int _iicPt;volatile U32 save_GPECON;void Wr_CamIICx(U32 slvAddr, U32 n, ...){  va_list ap;  U32 i;  va_start(ap, n);  for (i = 0; i < n; ++i) {    _iicData[i] = va_arg(ap, int);  }  va_end(ap);  _iicMode      = WRDATA;  _iicPt        = 0;  _iicDataCount = n;  rIICDS        = slvAddr;  rIICSTAT      = 0xf0;  rIICCON       = 0xe0; //Resumes IIC operation.     while (_iicDataCount != -1) Run_IicPoll();}void Rd_CamIICx(U32 slvAddr, U32 addr, U32 n, U8 data[]){  U32 i;  _iicMode      = SETRDADDR;  _iicPt        = 0;  _iicData[0]   = (U8)addr;  _iicDataCount = 1;  rIICDS   = slvAddr;  rIICSTAT = 0xf0;   //Master Tx, Start  rIICCON  = 0xe0;                    //Resumes IIC operation.     while (_iicDataCount != -1) Run_IicPoll();  _iicMode      = RDDATA;  _iicPt        = 0;  _iicDataCount = n;  ///HXM 1--5      rIICDS   = slvAddr;  rIICSTAT = 0xb0;                    //Master Rx,Start  rIICCON  = 0xe0;                    //Resumes IIC operation.     while (_iicDataCount != -1) Run_IicPoll();  for (i = 0; i < n; ++i) {    data[i] = _iicData[i + 1];  }}void IicPortSet(void){  save_GPECON = rGPECON;  rGPECON = rGPECON & ~(0xf<<28) | (0xa<<28);	//GPE15:IICSDA , GPE14:IICSCL 	 }void IicPortReturn(void){  rGPECON = save_GPECON;}void Run_IicPoll(void){  if(rIICCON & 0x10)                  //Tx/Rx Interrupt Enable    IicPoll();}//**********************[IicPoll ]**************************************void IicPoll(void){  U32 iicSt,i;      iicSt = rIICSTAT;   if(iicSt & 0x8){}                   //When bus arbitration is failed.  if(iicSt & 0x4){}                   //When a slave address is matched with IICADD  if(iicSt & 0x2){}                   //When a slave address is 0000000b  if(iicSt & 0x1){}                   //When ACK isn't received  switch(_iicMode) {  case POLLACK:    _iicStatus = iicSt;    break;  case RDDATA:    if(_iicDataCount--) {      _iicData[_iicPt++] = rIICDS;      //The last data has to be read with no ack.      if((_iicDataCount)==0)	rIICCON = 0x60;   // 0x2f;                 //Resumes IIC operation with NOACK.        else 	rIICCON = 0xe0;   // 0xaf;                 //Resumes IIC operation with ACK    } else {      _iicData[_iicPt++] = rIICDS;      rIICSTAT = 0x90;           //Stop MasRx condition       rIICCON  = 0xe0;           //Resumes IIC operation.      for (i = 0; i < 50 ;i++) continue; // Wait until stop condtion is in effect.    }    break;  case WRDATA:    if(_iicDataCount--) {      rIICDS = _iicData[_iicPt++];        //_iicData[0] has dummy.      for (i = 0; i < 10; i++) continue; //for setup time until rising edge of IICSCL      rIICCON = 0xe0;     //resumes IIC operation.    } else {      rIICSTAT = 0xd0;    //stop MasTx condition       rIICCON  = 0xe0;    //resumes IIC operation. 9.20 xm.h ...si a      for (i = 0; i < 50 ;i++) continue; //Wait until stop condtion is in effect.    }    break;  case SETRDADDR:    if(_iicDataCount--) {      rIICDS = _iicData[_iicPt++];      for (i = 0; i < 10; i++) continue; //for setup time until rising edge of IICSCL      rIICCON = 0xe0;  //resumes IIC operation.    }    break;  }}

⌨️ 快捷键说明

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