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

📄 ap1000.c

📁 gumstiz u-boot loader in linux
💻 C
📖 第 1 页 / 共 2 页
字号:
	udelay (1000);	*((unsigned char *) AP1000_CPLD_BASE) = 1;	return 0;}#define GET_DECIMAL(low_byte) ((low_byte >> 5) * 125)#define TEMP_BUSY_BIT   0x80#define TEMP_LHIGH_BIT  0x40#define TEMP_LLOW_BIT   0x20#define TEMP_EHIGH_BIT  0x10#define TEMP_ELOW_BIT   0x08#define TEMP_OPEN_BIT   0x04#define TEMP_ETHERM_BIT 0x02#define TEMP_LTHERM_BIT 0x01int do_temp_sensor (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]){	char cmd;	int ret_val = 0;	unsigned char temp_byte;	int temp;	int temp_low;	int low;	int low_low;	int high;	int high_low;	int therm;	unsigned char user_data[4] = { 0 };	int user_data_count = 0;	int ii;	if (argc > 1) {		cmd = argv[1][0];	} else {		cmd = 's';	/* default to status */	}	user_data_count = argc - 2;	for (ii = 0; ii < user_data_count; ii++) {		user_data[ii] = simple_strtoul (argv[2 + ii], NULL, 0);	}	switch (cmd) {	case 's':		if (I2CAccess		    (0x2, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL,		     &temp_byte, I2C_READ) != 0) {			goto fail;		}		printf ("Status    : 0x%02x  ", temp_byte);		if (temp_byte & TEMP_BUSY_BIT)			printf ("BUSY ");		if (temp_byte & TEMP_LHIGH_BIT)			printf ("LHIGH ");		if (temp_byte & TEMP_LLOW_BIT)			printf ("LLOW ");		if (temp_byte & TEMP_EHIGH_BIT)			printf ("EHIGH ");		if (temp_byte & TEMP_ELOW_BIT)			printf ("ELOW ");		if (temp_byte & TEMP_OPEN_BIT)			printf ("OPEN ");		if (temp_byte & TEMP_ETHERM_BIT)			printf ("ETHERM ");		if (temp_byte & TEMP_LTHERM_BIT)			printf ("LTHERM");		printf ("\n");		if (I2CAccess		    (0x3, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL,		     &temp_byte, I2C_READ) != 0) {			goto fail;		}		printf ("Config    : 0x%02x  ", temp_byte);		if (I2CAccess		    (0x4, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL,		     &temp_byte, I2C_READ) != 0) {			printf ("\n");			goto fail;		}		printf ("Conversion: 0x%02x\n", temp_byte);		if (I2CAccess		    (0x22, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL,		     &temp_byte, I2C_READ) != 0) {			goto fail;		}		printf ("Cons Alert: 0x%02x  ", temp_byte);		if (I2CAccess		    (0x21, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL,		     &temp_byte, I2C_READ) != 0) {			printf ("\n");			goto fail;		}		printf ("Therm Hyst: %d\n", temp_byte);		if (I2CAccess		    (0x0, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL,		     &temp_byte, I2C_READ) != 0) {			goto fail;		}		temp = temp_byte;		if (I2CAccess		    (0x6, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL,		     &temp_byte, I2C_READ) != 0) {			goto fail;		}		low = temp_byte;		if (I2CAccess		    (0x5, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL,		     &temp_byte, I2C_READ) != 0) {			goto fail;		}		high = temp_byte;		if (I2CAccess		    (0x20, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL,		     &temp_byte, I2C_READ) != 0) {			goto fail;		}		therm = temp_byte;		printf ("Local Temp: %2d     Low: %2d     High: %2d     THERM: %2d\n", temp, low, high, therm);		if (I2CAccess		    (0x1, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL,		     &temp_byte, I2C_READ) != 0) {			goto fail;		}		temp = temp_byte;		if (I2CAccess		    (0x10, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL,		     &temp_byte, I2C_READ) != 0) {			goto fail;		}		temp_low = temp_byte;		if (I2CAccess		    (0x8, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL,		     &temp_byte, I2C_READ) != 0) {			goto fail;		}		low = temp_byte;		if (I2CAccess		    (0x14, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL,		     &temp_byte, I2C_READ) != 0) {			goto fail;		}		low_low = temp_byte;		if (I2CAccess		    (0x7, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL,		     &temp_byte, I2C_READ) != 0) {			goto fail;		}		high = temp_byte;		if (I2CAccess		    (0x13, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL,		     &temp_byte, I2C_READ) != 0) {			goto fail;		}		high_low = temp_byte;		if (I2CAccess		    (0x19, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL,		     &temp_byte, I2C_READ) != 0) {			goto fail;		}		therm = temp_byte;		if (I2CAccess		    (0x11, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL,		     &temp_byte, I2C_READ) != 0) {			goto fail;		}		printf ("Ext Temp  : %2d.%03d Low: %2d.%03d High: %2d.%03d THERM: %2d Offset: %2d\n", temp, GET_DECIMAL (temp_low), low, GET_DECIMAL (low_low), high, GET_DECIMAL (high_low), therm, temp_byte);		break;	case 'l':		/* alter local limits : low, high, therm */		if (argc < 3) {			goto usage;		}		/* low */		if (I2CAccess		    (0xC, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL,		     &user_data[0], I2C_WRITE) != 0) {			goto fail;		}		if (user_data_count > 1) {			/* high */			if (I2CAccess			    (0xB, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL,			     &user_data[1], I2C_WRITE) != 0) {				goto fail;			}		}		if (user_data_count > 2) {			/* therm */			if (I2CAccess			    (0x20, I2C_SENSOR_DEV,			     I2C_SENSOR_CHIP_SEL, &user_data[2],			     I2C_WRITE) != 0) {				goto fail;			}		}		break;	case 'e':		/* alter external limits: low, high, therm, offset */		if (argc < 3) {			goto usage;		}		/* low */		if (I2CAccess		    (0xE, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL,		     &user_data[0], I2C_WRITE) != 0) {			goto fail;		}		if (user_data_count > 1) {			/* high */			if (I2CAccess			    (0xD, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL,			     &user_data[1], I2C_WRITE) != 0) {				goto fail;			}		}		if (user_data_count > 2) {			/* therm */			if (I2CAccess			    (0x19, I2C_SENSOR_DEV,			     I2C_SENSOR_CHIP_SEL, &user_data[2],			     I2C_WRITE) != 0) {				goto fail;			}		}		if (user_data_count > 3) {			/* offset */			if (I2CAccess			    (0x11, I2C_SENSOR_DEV,			     I2C_SENSOR_CHIP_SEL, &user_data[3],			     I2C_WRITE) != 0) {				goto fail;			}		}		break;	case 'c':		/* alter config settings: config, conv, cons alert, therm hyst */		if (argc < 3) {			goto usage;		}		/* config */		if (I2CAccess		    (0x9, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL,		     &user_data[0], I2C_WRITE) != 0) {			goto fail;		}		if (user_data_count > 1) {			/* conversion */			if (I2CAccess			    (0xA, I2C_SENSOR_DEV, I2C_SENSOR_CHIP_SEL,			     &user_data[1], I2C_WRITE) != 0) {				goto fail;			}		}		if (user_data_count > 2) {			/* cons alert */			if (I2CAccess			    (0x22, I2C_SENSOR_DEV,			     I2C_SENSOR_CHIP_SEL, &user_data[2],			     I2C_WRITE) != 0) {				goto fail;			}		}		if (user_data_count > 3) {			/* therm hyst */			if (I2CAccess			    (0x21, I2C_SENSOR_DEV,			     I2C_SENSOR_CHIP_SEL, &user_data[3],			     I2C_WRITE) != 0) {				goto fail;			}		}		break;	default:		goto usage;	}	goto done;fail:	printf ("Access to sensor failed\n");	ret_val = -1;	goto done;usage:	printf ("Usage:\n%s\n", cmdtp->help);done:	return ret_val;}U_BOOT_CMD (temp, 6, 0, do_temp_sensor,	    "temp    - interact with the temperature sensor\n",	    "temp [s]\n"	    "        - Show status.\n"	    "temp l LOW [HIGH] [THERM]\n"	    "        - Set local limits.\n"	    "temp e LOW [HIGH] [THERM] [OFFSET]\n"	    "        - Set external limits.\n"	    "temp c CONFIG [CONVERSION] [CONS. ALERT] [THERM HYST]\n"	    "        - Set config options.\n"	    "\n"	    "All values can be decimal or hex (hex preceded with 0x).\n"	    "Only whole numbers are supported for external limits.\n");#if 0U_BOOT_CMD (loadace, 2, 0, do_loadace,	    "loadace - load fpga configuration from System ACE compact flash\n",	    "N\n"	    "    - Load configuration N (0-7) from System ACE compact flash\n"	    "loadace\n" "    - loads default configuration\n");#endifU_BOOT_CMD (swconfig, 2, 0, do_swconfigbyte,	    "swconfig- display or modify the software configuration byte\n",	    "N [ADDRESS]\n"	    "    - set software configuration byte to N, optionally use ADDRESS as\n"	    "      location of buffer for flash copy\n"	    "swconfig\n" "    - display software configuration byte\n");U_BOOT_CMD (pause, 2, 0, do_pause,	    "pause   - sleep processor until any key is pressed with poll time of N seconds\n",	    "N\n"	    "    - sleep processor until any key is pressed with poll time of N seconds\n"	    "pause\n"	    "    - sleep processor until any key is pressed with poll time of 1 second\n");U_BOOT_CMD (swrecon, 1, 0, do_swreconfig,	    "swrecon - trigger a board reconfigure to the software selected configuration\n",	    "\n"	    "    - trigger a board reconfigure to the software selected configuration\n");

⌨️ 快捷键说明

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