当前位置: 首页>>代码示例>>C++>>正文


C++ read_eeprom函数代码示例

本文整理汇总了C++中read_eeprom函数的典型用法代码示例。如果您正苦于以下问题:C++ read_eeprom函数的具体用法?C++ read_eeprom怎么用?C++ read_eeprom使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了read_eeprom函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: rtl8139_probe

static int rtl8139_probe(struct eth_device *dev, bd_t *bis)
{
	int i;
	int speed10, fullduplex;
	int addr_len;
	unsigned short *ap = (unsigned short *)dev->enetaddr;

	ioaddr = dev->iobase;

	/* Bring the chip out of low-power mode. */
	outb(0x00, ioaddr + Config1);

	addr_len = read_eeprom(0,8) == 0x8129 ? 8 : 6;
	for (i = 0; i < 3; i++)
		*ap++ = le16_to_cpu (read_eeprom(i + 7, addr_len));

	speed10 = inb(ioaddr + MediaStatus) & MSRSpeed10;
	fullduplex = inw(ioaddr + MII_BMCR) & BMCRDuplex;

	rtl_reset(dev);

	if (inb(ioaddr + MediaStatus) & MSRLinkFail) {
		printf("Cable not connected or other link failure\n");
		return(0);
	}

	return 1;
}
开发者ID:WhitePatches,项目名称:snake-os,代码行数:28,代码来源:rtl8139.c

示例2: restart

static void restart(void)
{
  uint8_t id;
  uint8_t addr;
  uint8_t minutes;
  uint8_t seconds;
  addr = 0;
  for (id = 0; id < NUM_COUNTDOWNS; id++)
  {
    minutes = read_eeprom(addr);
    addr++;
    seconds = read_eeprom(addr);
    addr++;

    if (minutes > 99)
    {
      minutes = 10; /* a sensible arbitrary default */
    }
    if (seconds > 59)
    {
      seconds = 0; /* a sensible arbitrary default */
    }
    set_countdown(id, minutes, seconds);
    turnled_off(id);
  }
  was_running = 0;
  update_display = 1;
}
开发者ID:aravind2,项目名称:mwtp,代码行数:28,代码来源:clock.c

示例3: atl1e_set_eeprom

static int
atl1e_set_eeprom(struct net_device *netdev,
                      struct ethtool_eeprom *eeprom, u8 *bytes)
{
    struct atl1e_adapter *adapter = netdev_priv(netdev);
    struct atl1e_hw *hw = &adapter->hw;
    u32 *eeprom_buff;
    u32 *ptr;
    int max_len, first_dword, last_dword, ret_val = 0;
    int i;

    if (eeprom->len == 0)
        return -EOPNOTSUPP;

    if (eeprom->magic != (hw->vendor_id | (hw->device_id << 16)))
        return -EFAULT;

    max_len = 512;

    first_dword = eeprom->offset >> 2;
    last_dword = (eeprom->offset + eeprom->len - 1) >> 2;
    eeprom_buff = kmalloc(max_len, GFP_KERNEL);
    if (!eeprom_buff)
        return -ENOMEM;

    ptr = (u32 *)eeprom_buff;

    if (eeprom->offset & 3) {
        /* need read/modify/write of first changed EEPROM word */
        /* only the second byte of the word is being modified */
        if (!read_eeprom(hw, first_dword*4, &(eeprom_buff[0])))
            return -EIO;
        ptr++;
    }
    if (((eeprom->offset + eeprom->len) & 3) ) {
        /* need read/modify/write of last changed EEPROM word */
        /* only the first byte of the word is being modified */
        
        if (!read_eeprom(hw, last_dword*4, &(eeprom_buff[last_dword - first_dword])))
            return -EIO;
    }

    /* Device's eeprom is always little-endian, word addressable */
    memcpy(ptr, bytes, eeprom->len);

    for (i = 0; i < last_dword - first_dword + 1; i++) {
        if (!write_eeprom(hw, ((first_dword+i)*4), eeprom_buff[i]))
            return -EIO;
    }

    kfree(eeprom_buff);
    return ret_val;
}
开发者ID:jiangchengbin,项目名称:src,代码行数:53,代码来源:atl1e_ethtool.c

示例4: readconfig

/************************************************************************
*                                                                       *
*  Purpose:    *
*                                                                       *
*  Proposito:  *
*                                                                       *
*  Passed:     *
*  Argumento:  *
*  Returned:   *
*  Retorno:    *
*  Note:       *
*                                                                       *
*                                                                       *
************************************************************************/
void readconfig(void)
{
   firstrun = read_eeprom(0x00);

   int8 axt,axp,axv;
   axt = read_eeprom(0x01);
   axp = read_eeprom(0x02);
   axv = read_eeprom(0x03);

   if(axt==1)
   {
      UniTemp[0]="C";
   }
   if(axt==2)
   {
      UniTemp[0]="F";
   }
   if(axp==1)
   {
      UniPres[0]="m";
      UniPres[1]="B";
      UniPres[2]="a";
   }
   if(axp==2)
   {
      UniPres[0]="P";
      UniPres[1]="a";
      UniPres[2]=" ";
   }
   if(axv==1)
   {
      UniVel[0]="N";
      UniVel[1]="u";
      UniVel[2]="d";
      UniVel[3]=" ";
   }
   if(axv==2)
   {
      UniVel[0]="k";
      UniVel[1]="m";
      UniVel[2]="/";
      UniVel[3]="h";
   }
   if(axv==3)
   {
      UniVel[0]="m";
      UniVel[1]="/";
      UniVel[2]="s";
      UniVel[3]=" ";
   }
}
开发者ID:castro732,项目名称:X-Weather,代码行数:65,代码来源:rx.c

示例5: sdram_init

void sdram_init(void)
{
	__maybe_unused struct am335x_baseboard_id header;
	puts("sdram_init \n");
	if (read_eeprom(&header) < 0)
		puts("Could not get board ID.\n");

	if (board_is_evm_sk(&header)) {
		/*
		 * EVM SK 1.2A and later use gpio0_7 to enable DDR3.
		 * This is safe enough to do on older revs.
		 */
		gpio_request(GPIO_DDR_VTT_EN, "ddr_vtt_en");
		gpio_direction_output(GPIO_DDR_VTT_EN, 1);
	}

	if (board_is_evm_sk(&header))
		config_ddr(303, MT41J128MJT125_IOCTRL_VALUE, &ddr3_data,
			   &ddr3_cmd_ctrl_data, &ddr3_emif_reg_data, 0);
	else if (board_is_bone_lt(&header))
		config_ddr(400, MT41K256M16HA125E_IOCTRL_VALUE,
			   &ddr3_beagleblack_data,
			   &ddr3_beagleblack_cmd_ctrl_data,
			   &ddr3_beagleblack_emif_reg_data, 0);
	else if (board_is_evm_15_or_later(&header))
		config_ddr(303, MT41J512M8RH125_IOCTRL_VALUE, &ddr3_evm_data,
			   &ddr3_evm_cmd_ctrl_data, &ddr3_evm_emif_reg_data, 0);
	else
		config_ddr(266, MT47H128M16RT25E_IOCTRL_VALUE, &ddr2_data,
			   &ddr2_cmd_ctrl_data, &ddr2_emif_reg_data, 0);


                udelay(500);
}
开发者ID:flexibity-team,项目名称:u-boot-2013.10-ti2013.12.01-am3352_som,代码行数:34,代码来源:board.c

示例6: board_init

/*
 * Basic board specific setup.  Pinmux has been handled already.
 */
int board_init(void)
{
#if defined(CONFIG_HW_WATCHDOG)
	hw_watchdog_init();
#endif /* defined(CONFIG_HW_WATCHDOG) */
	i2c_set_bus_num(0);
	if (read_eeprom() < 0)
		puts("Could not get board ID.\n");
#ifdef CONFIG_MACH_TYPE
	gd->bd->bi_arch_number = CONFIG_MACH_TYPE;
#endif
	gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;

#ifdef CONFIG_FACTORYSET
	factoryset_read_eeprom(CONFIG_SYS_I2C_EEPROM_ADDR);
#endif

	gpmc_init();

#ifdef CONFIG_NAND_CS_INIT
	board_nand_cs_init();
#endif
#ifdef CONFIG_VIDEO
	board_video_init();
#endif

	return 0;
}
开发者ID:0xFelix,项目名称:u-boot-edminiv2,代码行数:31,代码来源:board.c

示例7: min

int Usb3Camera::download_firmware (std::vector<unsigned char>& firmware, std::function<void(int)> progress)
{
    int ret = -1;
    unsigned int size = 4096;

    unsigned char* data = new unsigned char[size];
    unsigned int max = firmware.size();
    for (unsigned int addr = 0; addr < max; addr += size)
    {
        size_t block_size = min( firmware.size() - addr, size );

        ret = read_eeprom(addr, firmware.data() + addr, block_size);

        if (ret < 0)
        {
            throw std::runtime_error("Unable to read data. Libusb returned " + std::to_string(ret) + ".");
        }
        else
        {
            progress( addr * 100 / max );
        }
    }

    delete[] data;
    return ret;
}
开发者ID:mtmEngg00,项目名称:tiscamera,代码行数:26,代码来源:Usb3Camera.cpp

示例8: erase_ok

uint8_t erase_ok(void)
{
	uint16_t waddr, addr;

	for (waddr = 0; waddr < SPM_SZ_WORDS; waddr++)
	{
		if (read_pgm_mem_word(waddr) != 0xFFFF)
		{
			break;
		}
	}
	if (waddr != SPM_SZ_WORDS)
	{
		return 0;
	}
	for (addr = 0; addr < EEP_SZ; addr++)
	{
		if (read_eeprom(addr) != 0xFF)
		{
			break;
		}
	}
	if (addr != EEP_SZ)
	{
		return 0;
	}
	return 1;
}
开发者ID:esrijan,项目名称:ddk-software,代码行数:28,代码来源:parallel_programmer.c

示例9: read_mac_addr

static Retcode
read_mac_addr(Environ *e, Package *pkg, Self *s, Pci_device_info *devinfo)
{
	Retcode ret;
	uByte mac_addr[MAC_ADDR];

	ret = read_eeprom(e, s, (uShort*)mac_addr, 0, 3);

	if (ret != NO_ERROR)
		return ret;

	// If the MAC address is all F's then we do not have a legit MAC addr
	if ((mac_addr[0] == 0xFF) && (mac_addr[1] == 0xFF) &&
			(mac_addr[2] == 0xFF) && (mac_addr[3] == 0xFF) &&
			(mac_addr[4] == 0xFF) && (mac_addr[5] == 0xFF))
		return E_BAD_ARGUMENT;

	/* may need to swap the two halves of data */
#ifdef BIG_ENDIAN
	s->mac_addr[0] = mac_addr[1];
	s->mac_addr[1] = mac_addr[0];
	s->mac_addr[2] = mac_addr[3];
	s->mac_addr[3] = mac_addr[2];
	s->mac_addr[4] = mac_addr[5];
	s->mac_addr[5] = mac_addr[4];
#else
	memcpy(s->mac_addr, mac_addr, sizeof mac_addr);
#endif

	if (ret != NO_ERROR)
		return ret;

	return set_property(pkg->props, "local-mac-address", CSTR,
			(Byte *)s->mac_addr, MAC_ADDR);
}
开发者ID:cstrotm,项目名称:smartfirmware,代码行数:35,代码来源:ethexpro.c

示例10: mac_read_from_eeprom

int mac_read_from_eeprom(void)
{
	const u8 *mac;

	if (read_eeprom()) {
		printf("I2C EEPROM read failed.\n");
		return -1;
	}

	if (!eeprom_is_valid) {
		printf("I2C EEPROM content not valid\n");
		return -1;
	}

	mac = NULL;
	switch (eeprom_version) {
	case 1:
	case 2:
		mac = (const u8 *)&eeprom_content.macaddress;
		break;
	}

	if (mac && is_valid_ether_addr(mac)) {
		eth_setenv_enetaddr("ethaddr", mac);
		printf("DIAG: %s() MAC value [%s]\n",
			__func__, getenv("ethaddr"));
	}

	return 0;
}
开发者ID:JamesAng,项目名称:ub,代码行数:30,代码来源:ac14xx.c

示例11: init_persist_data

/* Verify checksum.  If invalid, initialize all locations to zero. */
void init_persist_data()
{        
#ifdef PDATA_CHECKSUM
    u8 i, csum;
    
    /* The checksum is stored in negative form.
     * thus the sum of 0 .. PDATA_CHECKSUM should
     * be zero.  This allows an all-zero EEPROM to be valid.
     * That is fine, since EEPROM values are defined with
     * a default value of zero. */
    csum = 0;
    for (i=0; i<=PDATA_CHECKSUM; i++)
    {
        csum += read_eeprom(PERSIST_DATA_OFFSET+i);
    }

    if (csum != 0)
    {
        for(i=0; i<=PDATA_CHECKSUM; i++)
        {
            write_eeprom(PERSIST_DATA_OFFSET+i, 0);
        }
    }
#endif
}
开发者ID:layeka,项目名称:2can,代码行数:26,代码来源:persist.c

示例12: main

void main()
{
clock_int_4MHz(); //Função necessária para habilitar o dual clock (48MHz para USB e 4MHz para CPU)

   disparo=read_eeprom(10);  //carrega o último valo ajustado
   if (disparo==0xff) {disparo=0; write_eeprom(10,0);} //inicio de operação após gravação

   enable_interrupts(GLOBAL);
   enable_interrupts(INT_EXT);
   //enable_interrupts(INT_EXT1);
   ext_int_edge(L_TO_H);

 while(true)
   {
   ++i; if (i>=50000) {i=0; output_toggle(pin_b7);} //Led de visualização

      if(!input(botao))//botão de incremento de fase
      {  delay_ms(100);   while(!input(botao))  delay_ms(100); //filtro botão
         disparo++; // na prática está identificando o zero só uma vez por ciclo
         if(disparo>=7) {disparo=7;} //o botão no pino E3 regula o ângulo de disparo
         write_eeprom(10, disparo);
         
      }

    if(!input(botao1))
      {  delay_ms(100);   while(!input(botao1))  delay_ms(100);
         disparo--;
         if(disparo<=1) {disparo=1;}
         write_eeprom(10, disparo);
        }

   }
}
开发者ID:SanUSB-grupo,项目名称:Exemplos-CCS,代码行数:33,代码来源:DIR1.c

示例13: main

// -----------------------------------------------------------------
int main() {
    // Initialize the lcd
    lcd_init();
    fdev_setup_stream(&lcd_stream, lcd_putchar, 0, _FDEV_SETUP_WRITE); 
    lcd_clear_and_home();
 
    // initialize eeprom and TWI/I2C
    eeprom_init();
 
    // specify 7 bit device address of eeprom chip
    #define EEPROM_DEVICE_ID 0b1010000
    fprintf_P(&lcd_stream, PSTR("24LC256 ADDR: %02X"), EEPROM_DEVICE_ID);
 
    // specify eeprom memory address for data storage
    #define EEPROM_DATA_ADDRESS 0x0000
 
    // create local copy of eeprom data
    EEPROM_DATA e_data;
 
    // read eeprom contents at location 0000
    e_data = read_eeprom(0);
 
    // show what we read from the eeprom -
    // note: the very first read on a new eeprom
    // will show uninitalized data
    show_eeprom_data(&e_data);
 
    // process data
    if(e_data.need_initalization){
        // set all data item values if first time
        e_data.need_initalization = false;
        strcpy_P(e_data.author, PSTR("Noter"));
        e_data.read_count = 1;
        e_data.brightness = 0x33;
        e_data.version = 1.01;
    } else {
        // check contents against the values written when initializing
        if((e_data.version != 1.01)||
            (strcmp_P(e_data.author, PSTR("Noter")) !=0)||
            (e_data.brightness != 0x33)){
                    lcd_line_four();
                    fprintf_P(&lcd_stream, PSTR("DATA ERROR - ")); 
                    while(true);    // and freeze
                } else {
                    // increment read_count 
                    e_data.read_count += 1;
                }
    }
 
    // write data to eeprom memory at location 0000
    write_eeprom(0, &e_data);
 
    // and show the read count
    lcd_line_two();
    fprintf_P(&lcd_stream, PSTR("READ COUNT = %d"), e_data.read_count);
 
    // done
    while(true);
}
开发者ID:byrnedawg,项目名称:Polska,代码行数:60,代码来源:24LC256_eeprom.c

示例14: printEEPROMInfo

static void __init printEEPROMInfo(struct net_device *dev)
{
	struct eepro_local *lp = netdev_priv(dev);
	int ioaddr = dev->base_addr;
	unsigned short Word;
	int i,j;

	j = ee_Checksum;
	for (i = 0; i < 8; i++)
		j += lp->word[i];
	for ( ; i < ee_SIZE; i++)
		j += read_eeprom(ioaddr, i, dev);

	printk(KERN_DEBUG "Checksum: %#x\n",j&0xffff);

	Word = lp->word[0];
	printk(KERN_DEBUG "Word0:\n");
	printk(KERN_DEBUG " Plug 'n Pray: %d\n",GetBit(Word,ee_PnP));
	printk(KERN_DEBUG " Buswidth: %d\n",(GetBit(Word,ee_BusWidth)+1)*8 );
	printk(KERN_DEBUG " AutoNegotiation: %d\n",GetBit(Word,ee_AutoNeg));
	printk(KERN_DEBUG " IO Address: %#x\n", (Word>>ee_IO0)<<4);

	if (net_debug>4)  {
		Word = lp->word[1];
		printk(KERN_DEBUG "Word1:\n");
		printk(KERN_DEBUG " INT: %d\n", Word & ee_IntMask);
		printk(KERN_DEBUG " LI: %d\n", GetBit(Word,ee_LI));
		printk(KERN_DEBUG " PC: %d\n", GetBit(Word,ee_PC));
		printk(KERN_DEBUG " TPE/AUI: %d\n", GetBit(Word,ee_TPE_AUI));
		printk(KERN_DEBUG " Jabber: %d\n", GetBit(Word,ee_Jabber));
		printk(KERN_DEBUG " AutoPort: %d\n", !GetBit(Word,ee_AutoPort));
		printk(KERN_DEBUG " Duplex: %d\n", GetBit(Word,ee_Duplex));
	}

	Word = lp->word[5];
	printk(KERN_DEBUG "Word5:\n");
	printk(KERN_DEBUG " BNC: %d\n",GetBit(Word,ee_BNC_TPE));
	printk(KERN_DEBUG " NumConnectors: %d\n",GetBit(Word,ee_NumConn));
	printk(KERN_DEBUG " Has ");
	if (GetBit(Word,ee_PortTPE)) printk(KERN_DEBUG "TPE ");
	if (GetBit(Word,ee_PortBNC)) printk(KERN_DEBUG "BNC ");
	if (GetBit(Word,ee_PortAUI)) printk(KERN_DEBUG "AUI ");
	printk(KERN_DEBUG "port(s)\n");

	Word = lp->word[6];
	printk(KERN_DEBUG "Word6:\n");
	printk(KERN_DEBUG " Stepping: %d\n",Word & ee_StepMask);
	printk(KERN_DEBUG " BoardID: %d\n",Word>>ee_BoardID);

	Word = lp->word[7];
	printk(KERN_DEBUG "Word7:\n");
	printk(KERN_DEBUG " INT to IRQ:\n");

	for (i=0, j=0; i<15; i++)
		if (GetBit(Word,i)) printk(KERN_DEBUG " INT%d -> IRQ %d;",j++,i);

	printk(KERN_DEBUG "\n");
}
开发者ID:birui,项目名称:Xiaomi_Kernel_OpenSource,代码行数:58,代码来源:eepro.c

示例15: read_float

float read_float(int16 addr) { 
   int i; 
   float data;

   for (i = 0; i < 4; i++) 
      *((int8*)&data + i) = read_eeprom(i + addr);

   return(data); 
}
开发者ID:frazahod,项目名称:SUBGEN-NuLAB-EcoLAB-,代码行数:9,代码来源:eeprom.c


注:本文中的read_eeprom函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。