亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? i2c.c

?? AT9260的BOOTLOADER,還有幾個版本的,需要的我再放
?? C
字號:
/* * (C) Copyright 2000 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. * * See file CREDITS for list of people who contributed to this * project. * * 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 * * Hacked for the DB64360 board by Ingo.Assmus@keymile.com * extra improvments by Brain Waite * for cpci750 by reinhard.arlt@esd-electronics.com */#include <common.h>#include <mpc8xx.h>#include <malloc.h>#include "../../Marvell/include/mv_gen_reg.h"#include "../../Marvell/include/core.h"#define I2C_DELAY	    100#undef	DEBUG_I2C#ifdef DEBUG_I2C#define DP(x) x#else#define DP(x)#endif/* Assuming that there is only one master on the bus (us) */static void i2c_init (int speed, int slaveaddr){	unsigned int n, m, freq, margin, power;	unsigned int actualN = 0, actualM = 0;	unsigned int minMargin = 0xffffffff;	unsigned int tclk = CFG_TCLK;	unsigned int i2cFreq = speed;	/* 100000 max. Fast mode not supported */	DP (puts ("i2c_init\n"));/* gtI2cMasterInit */	for (n = 0; n < 8; n++) {		for (m = 0; m < 16; m++) {			power = 2 << n;	/* power = 2^(n+1) */			freq = tclk / (10 * (m + 1) * power);			if (i2cFreq > freq)				margin = i2cFreq - freq;			else				margin = freq - i2cFreq;			if (margin < minMargin) {				minMargin = margin;				actualN = n;				actualM = m;			}		}	}	DP (puts ("setup i2c bus\n"));	/* Setup bus */	/* gtI2cReset */	GT_REG_WRITE (I2C_SOFT_RESET, 0);	asm(" sync");	GT_REG_WRITE (I2C_CONTROL, 0);	asm(" sync");	DP (puts ("set baudrate\n"));	GT_REG_WRITE (I2C_STATUS_BAUDE_RATE, (actualM << 3) | actualN);	asm(" sync");	DP (puts ("udelay...\n"));	udelay (I2C_DELAY);	GT_REG_WRITE (I2C_CONTROL, (0x1 << 2) | (0x1 << 6));	asm(" sync");}static uchar i2c_select_device (uchar dev_addr, uchar read, int ten_bit){	unsigned int status, data, bits = 7;	unsigned int control;	int count = 0;	DP (puts ("i2c_select_device\n"));	/* Output slave address */	if (ten_bit) {		bits = 10;	}	GT_REG_READ (I2C_CONTROL, &control);	control |=  (0x1 << 2);	GT_REG_WRITE (I2C_CONTROL, control);	asm(" sync");	GT_REG_READ (I2C_CONTROL, &control);	control |= (0x1 << 5);	/* generate the I2C_START_BIT */	GT_REG_WRITE (I2C_CONTROL, control);	asm(" sync");	RESET_REG_BITS (I2C_CONTROL, (0x01 << 3));	asm(" sync");	GT_REG_READ (I2C_CONTROL, &status);	while ((status & 0x08) != 0x08) {		GT_REG_READ (I2C_CONTROL, &status);		}	count = 0;	GT_REG_READ (I2C_STATUS_BAUDE_RATE, &status);	while (((status & 0xff) != 0x08) && ((status & 0xff) != 0x10)){		if (count > 200) {#ifdef DEBUG_I2C			printf ("Failed to set startbit: 0x%02x\n", status);#endif			GT_REG_WRITE (I2C_CONTROL, (0x1 << 4));	/*stop */			asm(" sync");			return (status);		}		GT_REG_READ (I2C_STATUS_BAUDE_RATE, &status);		count++;	}	DP (puts ("i2c_select_device:write addr byte\n"));	/* assert the address */	data = (dev_addr << 1);	/* set the read bit */	data |= read;	GT_REG_WRITE (I2C_DATA, data);	asm(" sync");	RESET_REG_BITS (I2C_CONTROL, BIT3);	asm(" sync");	GT_REG_READ (I2C_CONTROL, &status);	while ((status & 0x08) != 0x08) {		GT_REG_READ (I2C_CONTROL, &status);		}	GT_REG_READ (I2C_STATUS_BAUDE_RATE, &status);	count = 0;	while (((status & 0xff) != 0x40) && ((status & 0xff) != 0x18)) {		if (count > 200) {#ifdef DEBUG_I2C			printf ("Failed to write address: 0x%02x\n", status);#endif			GT_REG_WRITE (I2C_CONTROL, (0x1 << 4));	/*stop */			return (status);		}		GT_REG_READ (I2C_STATUS_BAUDE_RATE, &status);		asm(" sync");		count++;	}	if (bits == 10) {		printf ("10 bit I2C addressing not yet implemented\n");		return (0xff);	}	return (0);}static uchar i2c_get_data (uchar * return_data, int len){	unsigned int data, status;	int count = 0;	DP (puts ("i2c_get_data\n"));	while (len) {		RESET_REG_BITS (I2C_CONTROL, BIT3);		asm(" sync");		/* Get and return the data */		GT_REG_READ (I2C_CONTROL, &status);		while ((status & 0x08) != 0x08) {			GT_REG_READ (I2C_CONTROL, &status);			}		GT_REG_READ (I2C_STATUS_BAUDE_RATE, &status);		count++;		while ((status & 0xff) != 0x50) {			if (count > 20) {#ifdef DEBUG_I2C				printf ("Failed to get data len status: 0x%02x\n", status);#endif				GT_REG_WRITE (I2C_CONTROL, (0x1 << 4));	/*stop */				asm(" sync");				return 0;			}			GT_REG_READ (I2C_STATUS_BAUDE_RATE, &status);			count++;		}		GT_REG_READ (I2C_DATA, &data);		len--;		*return_data = (uchar) data;		return_data++;	}	RESET_REG_BITS (I2C_CONTROL, BIT2 | BIT3);	asm(" sync");	count = 0;	GT_REG_READ (I2C_CONTROL, &status);	while ((status & 0x08) != 0x08) {		GT_REG_READ (I2C_CONTROL, &status);		}	while ((status & 0xff) != 0x58) {		if (count > 2000) {			GT_REG_WRITE (I2C_CONTROL, (0x1 << 4));	/*stop */			return (status);		}		GT_REG_READ (I2C_STATUS_BAUDE_RATE, &status);		count++;	}	GT_REG_WRITE (I2C_CONTROL, (0x1 << 4));	/* stop */	asm(" sync");	RESET_REG_BITS (I2C_CONTROL, (0x1 << 3));	asm(" sync");	return (0);}static uchar i2c_write_data (unsigned int *data, int len){	unsigned int status;	int count;	unsigned int temp;	unsigned int *temp_ptr = data;	DP (puts ("i2c_write_data\n"));	while (len) {		count = 0;		temp = (unsigned int) (*temp_ptr);		GT_REG_WRITE (I2C_DATA, temp);		asm(" sync");		RESET_REG_BITS (I2C_CONTROL, (0x1 << 3));		asm(" sync");		GT_REG_READ (I2C_CONTROL, &status);		while ((status & 0x08) != 0x08) {			GT_REG_READ (I2C_CONTROL, &status);			}		GT_REG_READ (I2C_STATUS_BAUDE_RATE, &status);		count++;		while ((status & 0xff) != 0x28) {			if (count > 200) {				GT_REG_WRITE (I2C_CONTROL, (0x1 << 4));	/*stop */				asm(" sync");				return (status);			}			GT_REG_READ (I2C_STATUS_BAUDE_RATE, &status);			count++;		}		len--;		temp_ptr++;	}	return (0);}static uchar i2c_write_byte (unsigned char *data, int len){	unsigned int status;	int count;	unsigned int temp;	unsigned char *temp_ptr = data;	DP (puts ("i2c_write_byte\n"));	while (len) {		count = 0;		/* Set and assert the data */		temp = *temp_ptr;		GT_REG_WRITE (I2C_DATA, temp);		asm(" sync");		RESET_REG_BITS (I2C_CONTROL, (0x1 << 3));		asm(" sync");		GT_REG_READ (I2C_CONTROL, &status);		while ((status & 0x08) != 0x08) {			GT_REG_READ (I2C_CONTROL, &status);			}		GT_REG_READ (I2C_STATUS_BAUDE_RATE, &status);		count++;		while ((status & 0xff) != 0x28) {			if (count > 200) {				GT_REG_WRITE (I2C_CONTROL, (0x1 << 4));	/*stop */				asm(" sync");				return (status);			}			GT_REG_READ (I2C_STATUS_BAUDE_RATE, &status);			count++;		}		len--;		temp_ptr++;	}	return (0);}static uchari2c_set_dev_offset (uchar dev_addr, unsigned int offset, int ten_bit,		    int alen){	uchar status;	unsigned int table[2];	table[1] = (offset     ) & 0x0ff;	/* low byte */	table[0] = (offset >> 8) & 0x0ff;	/* high byte */	DP (puts ("i2c_set_dev_offset\n"));	status = i2c_select_device (dev_addr, 0, ten_bit);	if (status) {#ifdef DEBUG_I2C22		printf ("Failed to select device setting offset: 0x%02x\n",			status);#endif		return status;	}/* check the address offset length */	if (alen == 0)		/* no address offset */		return (0);	else if (alen == 1) {		/* 1 byte address offset */		status = i2c_write_data (&offset, 1);		if (status) {#ifdef DEBUG_I2C			printf ("Failed to write data: 0x%02x\n", status);#endif			return status;		}	} else if (alen == 2) {		/* 2 bytes address offset */		status = i2c_write_data (table, 2);		if (status) {#ifdef DEBUG_I2C			printf ("Failed to write data: 0x%02x\n", status);#endif			return status;		}	} else {		/* address offset unknown or not supported */		printf ("Address length offset %d is not supported\n", alen);		return 1;	}	return 0;		/* sucessful completion */}uchari2c_read (uchar dev_addr, unsigned int offset, int alen, uchar * data,	  int len){	uchar status = 0;	unsigned int i2cFreq = CFG_I2C_SPEED;	DP (puts ("i2c_read\n"));	i2c_init (i2cFreq, 0);	/* set the i2c frequency */	status = i2c_set_dev_offset (dev_addr, offset, 0, alen);	/* send the slave address + offset */	if (status) {#ifdef DEBUG_I2C		printf ("Failed to set slave address & offset: 0x%02x\n",			status);#endif		return status;	}	status = i2c_select_device (dev_addr, 1, 0);	if (status) {#ifdef DEBUG_I2C		printf ("Failed to select device for data read: 0x%02x\n",			status);#endif		return status;	}	status = i2c_get_data (data, len);	if (status) {#ifdef DEBUG_I2C		printf ("Data not read: 0x%02x\n", status);#endif		return status;	}	return 0;}void i2c_stop (void){	GT_REG_WRITE (I2C_CONTROL, (0x1 << 4));	asm(" sync");}uchari2c_write (uchar dev_addr, unsigned int offset, int alen, uchar * data,	   int len){	uchar status = 0;	unsigned int i2cFreq = CFG_I2C_SPEED;	DP (puts ("i2c_write\n"));	i2c_init (i2cFreq, 0);	/* set the i2c frequency */	status = i2c_set_dev_offset (dev_addr, offset, 0, alen);	/* send the slave address + offset */	if (status) {#ifdef DEBUG_I2C		printf ("Failed to set slave address & offset: 0x%02x\n",			status);#endif		return status;		}	status = i2c_write_byte (data, len);	/* write the data */	if (status) {#ifdef DEBUG_I2C		printf ("Data not written: 0x%02x\n", status);#endif		return status;		}	/* issue a stop bit */	i2c_stop ();	return 0;}int i2c_probe (uchar chip){#ifdef DEBUG_I2C	unsigned int i2c_status;#endif	uchar status = 0;	unsigned int i2cFreq = CFG_I2C_SPEED;	DP (puts ("i2c_probe\n"));	i2c_init (i2cFreq, 0);	/* set the i2c frequency */	status = i2c_set_dev_offset (chip, 0, 0, 0);	/* send the slave address + no offset */	if (status) {#ifdef DEBUG_I2C		printf ("Failed to set slave address: 0x%02x\n", status);#endif		return (int) status;	}#ifdef DEBUG_I2C	GT_REG_READ (I2C_STATUS_BAUDE_RATE, &i2c_status);	printf ("address %#x returned %#x\n", chip, i2c_status);#endif	/* issue a stop bit */	i2c_stop ();	return 0;		/* successful completion */}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩一区二区电影网| 亚洲线精品一区二区三区八戒| 久久久久久久久久久99999| 中文成人综合网| 日韩精品国产欧美| av电影在线观看一区| 日韩欧美中文字幕一区| 亚洲视频狠狠干| 国产精品一二三区| 欧美一区二区视频在线观看2022| 国产精品久久久久久亚洲伦| 久草在线在线精品观看| 欧美三级韩国三级日本三斤| 国产精品久久久久一区| 精品一区二区国语对白| 欧美日韩精品免费| 一区二区三区四区乱视频| 粉嫩嫩av羞羞动漫久久久| 日韩欧美高清一区| 麻豆国产一区二区| 欧美日韩电影一区| 亚洲成人免费观看| 色综合久久九月婷婷色综合| 国产精品美女久久久久高潮| 国产一区二区三区蝌蚪| 2欧美一区二区三区在线观看视频 337p粉嫩大胆噜噜噜噜噜91av | 亚洲一区二区偷拍精品| 国产成人av一区二区三区在线| 日韩一区二区三免费高清| 日韩av成人高清| 欧美人妖巨大在线| 天天综合日日夜夜精品| 欧美日本免费一区二区三区| 亚洲小说春色综合另类电影| 91福利小视频| 亚洲成av人影院| 在线综合视频播放| 蜜乳av一区二区| 久久久综合精品| 成人动漫一区二区三区| 国产精品成人免费| 精品毛片乱码1区2区3区 | 亚洲国产成人91porn| 91女厕偷拍女厕偷拍高清| 综合欧美一区二区三区| 色综合欧美在线视频区| 一区二区三区视频在线看| 在线视频国产一区| 日韩va亚洲va欧美va久久| 精品少妇一区二区三区免费观看| 激情小说欧美图片| 国产精品热久久久久夜色精品三区| 国产一区视频导航| 亚洲视频 欧洲视频| 欧美日韩亚洲综合一区二区三区| 天堂午夜影视日韩欧美一区二区| 欧美一级欧美一级在线播放| 国内精品国产三级国产a久久 | 日韩视频国产视频| 国产乱码精品一区二区三区av| 欧美激情中文不卡| 色伊人久久综合中文字幕| 午夜亚洲福利老司机| 久久综合色综合88| 色综合天天综合在线视频| 日韩精品一区第一页| 国产日产欧产精品推荐色 | 国产成人小视频| 自拍偷拍亚洲欧美日韩| 在线综合+亚洲+欧美中文字幕| 国产精品123| 亚洲va天堂va国产va久| 久久看人人爽人人| 欧美色窝79yyyycom| 国产精品88888| 亚洲最大色网站| 国产偷国产偷精品高清尤物| 欧美私人免费视频| 国产成人一区在线| 日本伊人色综合网| 国产精品成人在线观看| 精品成人免费观看| 欧美理论在线播放| 91在线播放网址| 国产综合久久久久久久久久久久| 亚洲综合一区二区三区| 国产欧美一区视频| 欧美一区二区三区四区久久| 99久久久国产精品| 国产精品一区专区| 日韩av一区二区三区四区| 自拍偷在线精品自拍偷无码专区 | 欧美高清视频一二三区 | 99精品国产99久久久久久白柏 | 91蜜桃在线观看| 国产麻豆精品theporn| 日韩成人伦理电影在线观看| 亚洲欧洲日韩一区二区三区| 精品少妇一区二区三区视频免付费 | 亚洲摸摸操操av| 久久久久9999亚洲精品| 日韩一卡二卡三卡| 91精品国产综合久久小美女| 色嗨嗨av一区二区三区| 波多野结衣一区二区三区| 精品一区二区免费| 精品在线免费视频| 美女网站色91| 久久精品99国产精品日本| 午夜精品福利久久久| 亚洲综合一区二区三区| 亚洲自拍都市欧美小说| 一区二区三区国产豹纹内裤在线| 中文字幕久久午夜不卡| 国产精品天天摸av网| 久久精品水蜜桃av综合天堂| xfplay精品久久| 久久理论电影网| 国产精品久久网站| 亚洲欧美日韩国产成人精品影院| **欧美大码日韩| 亚洲精品综合在线| 亚洲图片欧美综合| 午夜亚洲福利老司机| 美女脱光内衣内裤视频久久影院| 另类专区欧美蜜桃臀第一页| 麻豆精品在线看| 韩国精品在线观看| www.日韩在线| 欧洲一区在线电影| 欧美老人xxxx18| 亚洲精品一线二线三线无人区| 久久午夜老司机| 国产精品福利影院| 一区二区三区日韩欧美| 亚洲成人黄色小说| 另类小说综合欧美亚洲| 国产成人综合视频| 91色|porny| 9191国产精品| 国产偷v国产偷v亚洲高清| 亚洲免费观看高清完整版在线观看熊| 亚洲激情第一区| 蜜臀av性久久久久蜜臀av麻豆| 国产自产v一区二区三区c| 不卡一区二区三区四区| 在线观看av不卡| www久久精品| 一区二区三区四区国产精品| 美女视频一区在线观看| 处破女av一区二区| 69久久夜色精品国产69蝌蚪网| 精品成人在线观看| 亚洲伦理在线免费看| 精品一区二区三区在线播放视频| 不卡的av在线播放| 欧美久久一区二区| 欧美国产激情一区二区三区蜜月| 亚洲最新视频在线播放| 日韩不卡一二三区| 色一区在线观看| av在线不卡免费看| 99国产精品国产精品久久| 91久久国产最好的精华液| 日韩欧美亚洲国产另类 | 欧美激情综合网| 亚洲成a人v欧美综合天堂下载| 国产aⅴ综合色| 3d动漫精品啪啪1区2区免费| 亚洲国产精品激情在线观看| 日日摸夜夜添夜夜添国产精品| 国产成人福利片| 日韩午夜中文字幕| 亚洲精品欧美综合四区| 国产精品一区二区三区四区 | 久久久久88色偷偷免费| 肉色丝袜一区二区| 97se亚洲国产综合自在线 | 欧美一级艳片视频免费观看| 中文字幕一区二区视频| 韩国视频一区二区| 欧美一区二区三区人| 亚洲一区二区偷拍精品| 不卡电影免费在线播放一区| 欧美成人福利视频| 日本欧美在线看| 欧美日韩国产三级| 亚洲综合区在线| 91浏览器打开| 亚洲欧美日韩成人高清在线一区| 国产美女视频一区| 精品国产乱码久久久久久浪潮| 亚洲成人av电影| 欧美性色欧美a在线播放| 亚洲同性同志一二三专区| 成人国产视频在线观看| 日本一区二区综合亚洲| 国产精品99久久久久久久vr| 精品国产凹凸成av人导航| 九九国产精品视频|