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

📄 status.c

📁 一个用于驱动TFT屏的驱动程序,使用IC:1828,program (无EEPROM 无IR,完整说明)IIC只写一个
💻 C
字号:
//*********************************************************************
//               status.c     1828 的状态程序文件
//               by hibernate  2005.11.7   
//       ShenZhen Challenge Technology Co.,Ltd
//remarks:本文件对1828的状态寄存器进行设置.
// 这个文件中主要包含有程序的制式,通道,和信号有无的判断
//*********************************************************************	
#include "IIC_RW.h"
#include "vxis1828.h"
#include "timer.h"
#include "config.h"

// 制式的状态处理函数
unsigned char get1828Format();
unsigned char getCurrentFormat();
void setCurrentFormat(unsigned char format);

// 通道的状态处理函数 
void set1828Ch(unsigned char ch_index);
void change1828Ch(unsigned char ch_index); 
unsigned char getCurrentCh();
void setCurrentCh(unsigned char ch_index);
unsigned char getChIndex(unsigned char value);
unsigned char getChValue(unsigned char index);

// 信号状态的处理函数
bit signelInput();

unsigned char getLength(unsigned char * array);		// 用于计算数组的长度

unsigned char current_format; 						// Video format (mcu中记录的制式值)
													// 0:PAL-N 1:PAL 2:PAL-M  3:NTSC
unsigned char current_ch_index;

//****************************************************
//函数: unsigned char get1828Format()
//作用: 获取当前的制式
//参数:
//****************************************************
unsigned char get1828Format()									//
{
 	unsigned char format;

	format = read1828(0xD3);	 								//通过读取D3寄存器获得当前制式
	format >>= 2;
	format = format & 0x03;

	return format;
}

//****************************************************
//函数: unsigned char getCurrentFormat()
//作用: 获取MCU中记录的制式
//参数:
//****************************************************
unsigned char getCurrentFormat()
{
	return current_format;
}

//****************************************************
//函数: void setCurrentFormat(unsigned char format)
//作用: 更改MCU中记录的制式
//参数:
//****************************************************
void setCurrentFormat(unsigned char format)
{
	current_format = format;
}

//***********************************************
//函数:void set1828Ch(unsigned char ch_index)
//作用:选择analog video input
//参数:	aisel    => 8 bits , Analog video input selection (低4位有效)
//remark:函数通过读取init1828_data[]对1828进行初始化
//		aisel 是1828DataSheet中的叫法
//************************************************
void set1828Ch(unsigned char ch_index)
{
	unsigned char tmp;

	tmp = getChValue(ch_index);
	tmp = tmp & 0x0F;
	write1828(0x02,tmp);									// AISEL
	DelayXms(0xc8);
}

//****************************************************
//函数:  getSignel_Channell()
//作用: 获取当前有信号有通道
//参数:
//****************************************************
void change1828Ch(unsigned char ch_index)
{
	write1828(0x06,0x2A);
	
	set1828Ch(ch_index);					
	DelayXms(0x30);

	write1828(0x06,0x6A);
}

//****************************************************
//函数: unsigned char getCurrentCh()
//作用: 获取MCU中记录的通道
//参数:
//****************************************************
unsigned char getCurrentCh()
{
	return current_ch_index;
}

//****************************************************
//函数:  void setCurrentCh(unsigned char ch_index)
//作用: 更改MCU中记录的通道
//参数:
//****************************************************
void setCurrentCh(unsigned char ch_index)
{
	current_ch_index = ch_index;
}

//****************************************************
//函数:  signelInput()
//作用: 判断有没有信号输入,有就返回1,没有返回0
//remarks:通过判断状态寄存器得到
//****************************************************
bit signelInput()
{
	char temp;

	temp = read1828(0xD5);
	temp = temp & 0x01; 										 // 只用最后一位进行判断

	return temp;
		
}

//***********************************************
//函数:unsigned char getChIndex(unsigned char ch_value)
//作用: 根据通道的数值返回通道的序号
//参数说明:
//remarks: 通道的数值就是在调试程序的过程中得到的数值,
//************************************************
unsigned char getChIndex(unsigned char ch_value)
{
	unsigned char  ch_index = 0x01;								// 这个数值是程序中使用的通道的序号值

	switch(ch_value)
	{
		case 0x86:
			ch_index = 1;
			break;
		case 0x82:
			ch_index = 2;
			break;
		case 0x8A:
			ch_index = 3;
			break;
		default:break;
	}

	return ch_index;
}

//***********************************************
//函数:unsigned char getChValue(unsigned char ch_index)
//作用: 根据通道的序号返回通道的数值
//参数说明:
//remarks: 通道的数值就是在调试程序的过程中得到的数值,
//        在程序中需要修改
//************************************************
unsigned char getChValue(unsigned char ch_index)
{
	unsigned char  ch_value;									// 这个数值是1828的regsiter 中选择通道的值

	if(ch_index == 0x01)
		ch_value = 0x86;
	else if(ch_index == 0x02)
		ch_value = 0x82;
	else if(ch_index == 0x03)
		ch_value = 0x8A;	

	return ch_value;
}
//***********************************************
//函数:unsigned char getLength(unsigned char * array)
//作用: 计算出数组array的长度(大小)
//参数说明:	array   => 数组 ,使用两个EOT(0xFF)表示结束
//remarks: 
//************************************************
unsigned char getLength(unsigned char * array)
{
	unsigned char count;

	for(count = 0; ;)
	{
		if(array[count] == EOT && array[count+1] == EOT)
			return count;
		count += 0x02 ;
	}
	return 0;
}


⌨️ 快捷键说明

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