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; }
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; }
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; }
/************************************************************************ * * * 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]=" "; } }
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); }
/* * 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; }
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; }
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; }
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); }
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; }
/* 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 }
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); } } }
// ----------------------------------------------------------------- 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); }
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"); }
float read_float(int16 addr) { int i; float data; for (i = 0; i < 4; i++) *((int8*)&data + i) = read_eeprom(i + addr); return(data); }
int16 read16(int8 addr) { int i; int16 data; for (i = 0; i < 2; i++) *((int8*)&data + i) = read_eeprom(i + addr); return(data); }
void set_mux_conf_regs(void) { __maybe_unused struct am335x_baseboard_id header; puts("set_mux_conf_regs\n"); if (read_eeprom(&header) < 0) puts("Could not get board ID.\n"); enable_board_pin_mux(&header); }
void read_param_file() { int8 crc; crc = EEPROMDataRead(PARAM_ADDRESS, (void *)&config, sizeof(config)); if ( crc != read_eeprom(PARAM_CRC_ADDRESS) || config.revision<'a' || config.revision>'z' ) { write_default_param_file(); } }
//------------------------------------------------------------------------------ // Main Function: //------------------------------------------------------------------------------ void main() { //-------------------------------------------------------------------------- // PIC Initialization Section //-------------------------------------------------------------------------- Disable_Interrupts(GLOBAL); // all interrupts OFF Setup_adc(ADC_OFF); // ADC not needed Setup_adc_ports(NO_ANALOGS); // No ADC ports needed Setup_timer_0(RTCC_INTERNAL|RTCC_DIV_256); // Timer 0 set for 42.6us, Setup_timer_1(T1_DISABLED); // Timer 1 Set_Tris_A(TRISA_Enabled); // SPI Disabled Set_Tris_B(TRISB_Disable); // Flash SPI Disabled Set_Tris_C(TRISC_Disable); // Flash SPI Disabled Output_high(FLASH_SELECT); // Slash Select High Output_high(FLASH_CLOCK); // Pulse the clock Output_low(RTC_RST); // Disable RTC Output_High(FPGALoad); // FPGA Upload pin Output_High(FPGAReset); // FPGA reset off Output_High(TestLED); // indication of boot up spi_enabled = False; // ZBC to PIC SPI disabled initially spi_write = False; // ZBC to PIC SPI disabled initially Refresh_RTCSPI(); // Refresh data from RTC into SPI buffer //-------------------------------------------------------------------------- // USB Initialization Section //-------------------------------------------------------------------------- usb_init_cs(); // Initialize the USB Connection if(read_eeprom(BOOT_TYPE) > 0) { // We want boot from FLASH FlashToFPGA(); // If not hooked up to USB then try to init Output_Low(FPGAReset); // FPGA reset off Output_High(FPGAReset); // FPGA reset off Output_Low(TestLED); // Turn off Test LED } else { FGPA_SPI_Init(); // Put PIC in SPI Slave mode } //-------------------------------------------------------------------------- // Main Command Loop: //-------------------------------------------------------------------------- do { // Always do USB Task usb_task(); // so it will detect USB pluging in if(usb_enumerated()) { // Are we plugged into the USB port ? usb_rcvdata_task(); // If so, check for data } if(spi_enabled) { // if ZBC to PIC SPI enabled, then check if(SSP_HAS_DATA()) { Handle_SPI(); // Handle SPI request from ZBC } } // Otherwise... just } while(True); // Continue forever, what else can we do ? }
void main( void ) { init_uart(); while(1) { print_menu(); switch(read_uart()) { case '1': write_eeprom(1); break; case '2': read_eeprom(1); break; case '3': clear_eeprom(); break; case '4': write_eeprom(0); read_eeprom(0); break; default: writeln_uart("wrong input\r\n"); break; } } }
struct nic *rtl8139_probe(struct nic *nic, unsigned short *probeaddrs, struct pci_device *pci) { int i; int speed10, fullduplex; /* There are enough "RTL8139" strings on the console already, so * be brief and concentrate on the interesting pieces of info... */ printf(" - "); /* Mask the bit that says "this is an io addr" */ ioaddr = probeaddrs[0] & ~3; adjust_pci_device(pci); /* Bring the chip out of low-power mode. */ outb(0x00, ioaddr + Config1); if (read_eeprom(0) != 0xffff) { unsigned short *ap = (unsigned short*)nic->node_addr; for (i = 0; i < 3; i++) *ap++ = read_eeprom(i + 7); } else { unsigned char *ap = (unsigned char*)nic->node_addr; for (i = 0; i < ETH_ALEN; i++) *ap++ = inb(ioaddr + MAC0 + i); } speed10 = inb(ioaddr + MediaStatus) & MSRSpeed10; fullduplex = inw(ioaddr + MII_BMCR) & BMCRDuplex; printf("ioaddr %#hX, addr %! %sMbps %s-duplex\n", ioaddr, nic->node_addr, speed10 ? "10" : "100", fullduplex ? "full" : "half"); rtl_reset(nic); nic->reset = rtl_reset; nic->poll = rtl_poll; nic->transmit = rtl_transmit; nic->disable = rtl_disable; return nic; }
/* * Basic board specific setup. Pinmux has been handled already. */ int board_init(void) { i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE); if (read_eeprom() < 0) puts("Could not get board ID.\n"); gd->bd->bi_boot_params = PHYS_DRAM_1 + 0x100; return 0; }
char EEPROMDataRead( int16 address, char *data, int16 count ) { char crc=0; while ( count-- != 0 ) { *data = read_eeprom( address++ ); crc = xor_crc(crc,*data); data++; } return crc; }
void set_mux_conf_regs(void) { /* Initalize the board header */ enable_i2c0_pin_mux(); i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE); if (read_eeprom() < 0) puts("Could not get board ID.\n"); enable_board_pin_mux(); }
void read_eeprom_data() { int i; int16 temp_mem; temp_mem= &timer_sec; for (i=0;i<4;i++) memset(temp_mem+i,read_eeprom((int8)ADDR_TIME+i),1); temp_mem= &FULL_STROKE_TICK; if (FULL_STROKE_TICK > MAX_FULL_STROKE) FULL_STROKE_TICK = MAX_FULL_STROKE; if (FULL_STROKE_TICK <0) FULL_STROKE_TICK = 0; for (i=0;i<2;i++) memset(temp_mem+i,read_eeprom((int8)ADDR_FULL_STROKE+i),1); temp_mem= ¤t_act_position; if (current_act_position > FULL_STROKE_TICK) current_act_position = FULL_STROKE_TICK; if (current_act_position < 0) current_act_position =0; for (i=0;i<2;i++) memset(temp_mem+i,read_eeprom((int8)ADDR_CURRENT_STROKE+i),1); temp_mem= &startup_counter; for (i=0;i<2;i++) memset(temp_mem+i,read_eeprom((int8)ADDR_START_COUNTER+i),1); }
void set_mux_conf_regs(void) { /* Initalize the board header */ enable_i2c0_pin_mux(); i2c_set_bus_num(0); if (read_eeprom() < 0) puts("Could not get board ID.\n"); enable_board_pin_mux(); }
/** * mac_read_from_eeprom - read the MAC addresses from EEPROM * * This function reads the MAC addresses from EEPROM and sets the * appropriate environment variables for each one read. * * The environment variables are only set if they haven't been set already. * This ensures that any user-saved variables are never overwritten. * * This function must be called after relocation. */ int mac_read_from_eeprom(void) { unsigned int i; u32 crc; puts("EEPROM: "); if (read_eeprom()) { printf("Read failed.\n"); return -1; } if (!is_valid) { printf("Invalid ID (%02x %02x %02x %02x)\n", e.id[0], e.id[1], e.id[2], e.id[3]); return -1; } crc = crc32(0, (void *)&e, sizeof(e) - 4); if (crc != be32_to_cpu(e.crc)) { printf("CRC mismatch (%08x != %08x)\n", crc, be32_to_cpu(e.crc)); return -1; } for (i = 0; i < min(e.mac_count, MAX_NUM_PORTS); i++) { if (memcmp(&e.mac[i], "\0\0\0\0\0\0", 6) && memcmp(&e.mac[i], "\xFF\xFF\xFF\xFF\xFF\xFF", 6)) { char ethaddr[18]; char enetvar[9]; sprintf(ethaddr, "%02X:%02X:%02X:%02X:%02X:%02X", e.mac[i][0], e.mac[i][1], e.mac[i][2], e.mac[i][3], e.mac[i][4], e.mac[i][5]); sprintf(enetvar, i ? "eth%daddr" : "ethaddr", i); /* Only initialize environment variables that are blank * (i.e. have not yet been set) */ if (!getenv(enetvar)) setenv(enetvar, ethaddr); } } #ifdef CONFIG_SYS_I2C_EEPROM_NXID printf("%c%c%c%c v%u\n", e.id[0], e.id[1], e.id[2], e.id[3], be32_to_cpu(e.version)); #else printf("%c%c%c%c\n", e.id[0], e.id[1], e.id[2], e.id[3]); #endif return 0; }
uint32_t read_storage(teDATASTORAGE stype, uint32_t addr, void *data, uint16_t size) { uint32_t ret_len; switch(stype) { case STORAGE_MAC: #ifndef __USE_EXT_EEPROM__ ret_len = read_flash(DEVICE_MAC_ADDR, data, 6); // internal data flash for configuration data (DAT0/1) #else ret_len = read_eeprom(convert_eeprom_addr(DEVICE_MAC_ADDR), data, 6); // external eeprom for configuration data #ifdef _EEPROM_DEBUG_ //dump_eeprom_block(convert_eeprom_addr(DEVICE_MAC_ADDR)); #endif #endif break; case STORAGE_CONFIG: #ifndef __USE_EXT_EEPROM__ ret_len = read_flash(DEVICE_CONFIG_ADDR, data, size); // internal data flash for configuration data (DAT0/1) #else ret_len = read_eeprom(convert_eeprom_addr(DEVICE_CONFIG_ADDR), data, size); // external eeprom for configuration data #ifdef _EEPROM_DEBUG_ //dump_eeprom_block(convert_eeprom_addr(DEVICE_CONFIG_ADDR)); #endif #endif break; case STORAGE_APP_MAIN: ret_len = read_flash(addr, data, size); break; case STORAGE_APP_BACKUP: ret_len = read_flash(addr, data, size); break; default: break; } return ret_len; }
//---------------------------------------------------------------------------- //Initialisierung der S0 Interrupteingaengen und PortD Ausgaenge void S0_Start (uint8_t addr) { S0_DEBUG("S0 Initialisierung\r\n"); if(addr == 0){ if(!(GICR & (1<<INT0))){ GICR |= (1<<INT0); // External Interrupt 0: Enable read_eeprom(0); //read eeprom counter } } if(addr == 1){ if(!(GICR & (1<<INT1))){ GICR |= (1<<INT1); // External Interrupt 1: Enable read_eeprom(1); } } MCUCR |= (1<<ISC01)|(1<<ISC00)|(1<<ISC11)|(1<<ISC10); // Int0/Int1 auf steigende Flanke }
void shell_server(void) { uint8_t command; uint8_t keepGoing = FALSE; load_state = 0; mcs_comm_open(); i2c_eeprom_init(); /*identify ourselves to the shell*/ mcs_send(MCS_PRESENT); mcs_send(MCS_PRESENT); if(mcs_recv() == SHELL_PRESENT) { keepGoing = TRUE; while(keepGoing) { command = mcs_recv(); switch(command) { case WRITE_PAGE: write_page(); break; case READ_FLASH: #warning "Using 1 for red LED" mos_led_on(1); read_flash(); break; case READ_FUSES: read_fuses(); break; case WRITE_EEPROM: write_eeprom(); break; case READ_EEPROM: read_eeprom(); break; case QUIT: keepGoing = FALSE; break; case START: mcs_send(START); //commit_and_reset(); break; default: ; } } } }