static void store_permanent(void){ int tmp; signed char changeflag=1; lcd_clrscr(); if (eeprom_read_byte((uint8_t *)0x0) == 19){ changeflag=0; // ok magic number matches accept values tmp=eeprom_read_word((uint16_t *)0x04); if (tmp != set_val[1]){ changeflag=1; } tmp=eeprom_read_word((uint16_t *)0x02); if (tmp != set_val[0]){ changeflag=1; } } if (changeflag){ lcd_puts_P("setting stored"); eeprom_write_byte((uint8_t *)0x0,19); // magic number eeprom_write_word((uint16_t *)0x02,set_val[0]); eeprom_write_word((uint16_t *)0x04,set_val[1]); }else{ if (bpress> 5){ // display software version after long press lcd_puts_P(SWVERSION); lcd_gotoxy(0,1); lcd_puts_P("tuxgraphics.org"); }else{ lcd_puts_P("already stored"); } } delay_ms(200); }
void calibrate(void) { uint16_t min, max; // Timer/Counter0,1 Overflow Interrupt Enable - LED1 blinking TIMSK |= _BV(TOIE1); // Calibrate minimum value PORTA &= ~_BV(LED2); wait_for_prog(); min = pressure(); PORTA |= _BV(LED2); // Calibrate maximum value PORTA &= ~_BV(LED3); wait_for_prog(); max = pressure(); PORTA |= _BV(LED3) | _BV(LED1); // Save values in EEPROM eeprom_busy_wait(); eeprom_write_word(PMINIMUM, min); eeprom_busy_wait(); eeprom_write_word(PMAXIMUM, max); // Timer/Counter0,1 Overflow Interrupt Disable TIMSK &= ~_BV(TOIE1); }
/* * If there were MAX_WRONG_TRIES unsuccessful attempts to type the code, * block the execution for LOCKDOWN_WAIT seconds. */ void lock_device() { if (!eeprom_read_word(WAIT_TIMER)) { return; } avr_lcd_clear(); avr_lcd_puts("Device locked"); char buf[16]; for (uint16_t i = eeprom_read_word(WAIT_TIMER); i > 0; i--) { uint8_t min = i / 60; uint8_t sec = i % 60; snprintf(buf, 16, "Wait %02d m %02d s", min, sec); avr_lcd_set_cursor_pos(AVR_LCD_LINE1 + 0); avr_lcd_puts(buf); _delay_ms(1000); eeprom_write_word(WAIT_TIMER, i); } eeprom_write_word(WAIT_TIMER, 0); eeprom_write_byte(WRONG_TRIES, 0); }
void lcd_material_reset_defaults() { //Fill in the defaults SERIAL_ECHO_START; SERIAL_ECHOLNPGM("Materials reset"); char buffer[MATERIAL_NAME_LENGTH]; for (int a= 0; a< MATERIAL_PRESETS; a++) { strncpy_P(buffer, (char PROGMEM *) presets[a].name,MATERIAL_NAME_LENGTH); // this will pad out the whole length with 0 as needed. eeprom_write_block(buffer , EEPROM_MATERIAL_NAME_OFFSET(a), MATERIAL_NAME_LENGTH); material_preset temp; memcpy_P((void*) &temp,&presets[a],sizeof (material_preset)); eeprom_write_word(EEPROM_MATERIAL_TEMPERATURE_OFFSET(a) ,temp.temperature); eeprom_write_word(EEPROM_MATERIAL_BED_TEMPERATURE_OFFSET(a),temp.bed); eeprom_write_byte(EEPROM_MATERIAL_FAN_SPEED_OFFSET(a) ,temp.fan_speed); eeprom_write_word(EEPROM_MATERIAL_FLOW_OFFSET(a) ,temp.flow); eeprom_write_float(EEPROM_MATERIAL_DIAMETER_OFFSET(a) ,temp.diameter); } uint8_t e; for(e=0; e<EXTRUDERS; e++) { makeCustomName(e); strcpy(material_name[e],material_name_buf); lcd_material_store_current_material(); } eeprom_write_byte(EEPROM_MATERIAL_COUNT_OFFSET(), MATERIAL_PRESETS); lcd_lib_beep_ext(500,150); lcd_lib_beep_ext(750,100); }
void AlgorithmRepository::writeToEEPROM() { #ifndef DEBUGGING #ifdef ENABLE_DEBUG_UART Comm::printf_P( PSTR("Store in EEPROM")); #endif WORD addr= 0; eeprom_write_byte( (uint8_t *)addr++, 'J' ); eeprom_write_byte( (uint8_t *)addr++, 'P' ); eeprom_write_byte( (uint8_t *)addr++, ((RECEIVER_CHANNELS << 5) | OUTPUT_CHANNELS) ); eeprom_write_block( (const void *)&programArray, (void *)addr, (size_t)sizeof( programArray ) ); addr += sizeof( programArray ); eeprom_write_block( (const void *)&inputChannel, (void *)addr, (size_t)sizeof( inputChannel ) ); addr += sizeof( inputChannel ); for( BYTE i = 0; i < RECEIVER_CHANNELS; i++) { eeprom_write_word( (uint16_t *)addr, Receiver::getChannelMin( i )); addr += sizeof( WORD ); eeprom_write_word( (uint16_t *)addr, Receiver::getChannelMax( i )); addr += sizeof( WORD ); } eeprom_write_byte( (uint8_t *) addr, Receiver::getChannelModeByte( )); addr++; eeprom_write_word((uint16_t *) addr, Adc::getLimit()); #endif }
void saveConfig(){ uint16_t *__p=0; eeprom_write_word(__p,config_t_pomodoro); eeprom_write_word(__p+1,config_t_przerwa1); eeprom_write_word(__p+2,config_t_przerwa2); eeprom_write_word(__p+3,config_n_kr_przerw); }
void write32int (int inode, int offset, int32_t value) { uint16_t addr; uint16_t value1; uint32_t value2; value1 = (uint16_t)((*(uint32_t *)&value) >> 16); value2 = (uint16_t)((*(uint32_t *)&value) & 0x0000ffff); addr = inode*INODESIZE + offset; eeprom_busy_wait(); //value2 = *(uint16_t *)&value; eeprom_write_word((uint16_t *)addr, value2); addr = inode*INODESIZE + offset +2 ; eeprom_busy_wait(); //value2 = *(uint16_t *)&value; eeprom_write_word((uint16_t *)addr, value1); return; }
void gear_lern_count(int n, int address){ uint16_t high=0; uint16_t low=0; uint16_t current; int i; led_char(n); while(LEARN_SW); _delay_ms(100); while(!LEARN_SW); #ifdef DEBUG printf("START LEARN\r\n"); #endif current = read_puls_20(); low = current; high = current; for(i=0; i<10; i++){ current = read_puls_20(); // Read result for 10 pulses if(current < low){ // Set min & max value low = current; } if(current > high){ high = current; } #ifdef DEBUG printf("low, high > %d, %d\r\n",low, high); #endif } if((low <= 0)||(high > 1000)){ // Error condition #ifdef DEBUG printf(">%d-%d\r\n", low, high); #endif for(;;){ led_char('R'); _delay_ms(300); led_off(); _delay_ms(300); } } eeprom_write_word((uint16_t*)address,low); // Write low value address += 2; eeprom_write_word((uint16_t*)address, high); // Write high value for(i=0; i<3; i++){ led_off(); // Next giar number flash until _delay_ms(200); // clutch change position led_char(n); // _delay_ms(200); } led_off(); }
void lcd_material_store_material(uint8_t nr) { eeprom_write_word(EEPROM_MATERIAL_TEMPERATURE_OFFSET(nr), material[active_extruder].temperature); eeprom_write_word(EEPROM_MATERIAL_BED_TEMPERATURE_OFFSET(nr), material[active_extruder].bed_temperature); eeprom_write_word(EEPROM_MATERIAL_FLOW_OFFSET(nr), material[active_extruder].flow); eeprom_write_byte(EEPROM_MATERIAL_FAN_SPEED_OFFSET(nr), material[active_extruder].fan_speed); eeprom_write_float(EEPROM_MATERIAL_DIAMETER_OFFSET(nr), material[active_extruder].diameter); //eeprom_write_block(card.longFilename, EEPROM_MATERIAL_NAME_OFFSET(nr), 8); }
void lcd_material_store_current_material() { for(uint8_t e=0; e<EXTRUDERS; e++) { eeprom_write_word(EEPROM_MATERIAL_TEMPERATURE_OFFSET(EEPROM_MATERIAL_SETTINGS_MAX_COUNT+e), material[e].temperature); eeprom_write_word(EEPROM_MATERIAL_BED_TEMPERATURE_OFFSET(EEPROM_MATERIAL_SETTINGS_MAX_COUNT+e), material[e].bed_temperature); eeprom_write_byte(EEPROM_MATERIAL_FAN_SPEED_OFFSET(EEPROM_MATERIAL_SETTINGS_MAX_COUNT+e), material[e].fan_speed); eeprom_write_word(EEPROM_MATERIAL_FLOW_OFFSET(EEPROM_MATERIAL_SETTINGS_MAX_COUNT+e), material[e].flow); eeprom_write_float(EEPROM_MATERIAL_DIAMETER_OFFSET(EEPROM_MATERIAL_SETTINGS_MAX_COUNT+e), material[e].diameter); } }
void data2eeprom(void) { eeprom_write_byte((uint8_t *)40,19); // magic number eeprom_write_block((uint8_t *)gwip,(void *)41,sizeof(gwip)); eeprom_write_block((uint8_t *)udpsrvip,(void *)45,sizeof(udpsrvip)); eeprom_write_word((void *)49,udpsrvport); eeprom_write_byte((uint8_t *)51,alarmOn); eeprom_write_word((void *)52,heartbeat_timeout_sec); eeprom_write_byte((uint8_t *)54,dhcpOn); eeprom_write_block((uint8_t *)myip,(void *)55,sizeof(myip)); eeprom_write_block((uint8_t *)myname,(void *)59,sizeof(myname)); }
/// \brief Write PID factors to eeprom void heater_save_settings() { #ifndef BANG_BANG heater_t i; for (i = 0; i < NUM_HEATERS; i++) { eeprom_write_dword((uint32_t *) &EE_factors[i].EE_p_factor, heaters_pid[i].p_factor); eeprom_write_dword((uint32_t *) &EE_factors[i].EE_i_factor, heaters_pid[i].i_factor); eeprom_write_dword((uint32_t *) &EE_factors[i].EE_d_factor, heaters_pid[i].d_factor); eeprom_write_word((uint16_t *) &EE_factors[i].EE_i_limit, heaters_pid[i].i_limit); eeprom_write_word((uint16_t *) &EE_factors[i].crc, crc_block(&heaters_pid[i].p_factor, 14)); } #endif /* BANG_BANG */ }
/** * @brief Write given programming counter value to EEPROM * @param counter Programming counter value */ void counter_write(uint16_t counter) { uint8_t i; uint16_t * eeadr = 0; for (i = 0; i < COUNTER_REDUNCY; i++) { eeprom_write_word(eeadr++, counter); eeprom_write_word(eeadr++, ~counter); } }
void save_temp_eeprom(int word) { unsigned int ff_pointer = eeprom_pointer + mem_length; //öka ett steg, pekare till nästa slot if (ff_pointer >= eeprom_stop) { ff_pointer = eeprom_start; //slå runt minnet } eeprom_write_word(ff_pointer, mem_pointer_sign); //skriv alltid en mem_pointer_sign först för att garantera minnesplats eeprom_write_word(eeprom_pointer, word); //skriv till eeprom eeprom_pointer = ff_pointer; //avancera ett steg }
void update_eeprom() { if (dirty) { if (mode == mode_alarm) { eeprom_write_word(&eeprom_alarm_time, alarm_time); } else if (mode == mode_nap) { eeprom_write_word(&eeprom_nap_duration, nap_duration); } else if (mode == mode_adjustment) { eeprom_write_byte(&eeprom_adjustment, adjustment); } dirty = false; } }
void write_scale_preset(uint8_t preset_num, uint16_t scale_value){ unsigned int addr = 0; preset_info.scale_preset.record_flag |= (1<<preset_num); eeprom_busy_wait(); eeprom_write_word((uint16_t*)addr, preset_info.scale_preset.record_flag); addr+=2; preset_info.scale_preset.scales[preset_num] = scale_value; eeprom_busy_wait(); addr+=(preset_num*2); eeprom_write_word((uint16_t*)addr, preset_info.scale_preset.scales[preset_num]); update_scale_table(preset_info.scale_preset.scales); }
// check some EEprom values for correct values void EE_check_init(void) { #if (!defined(SamplingADC) || (PROCESSOR_TYP != 328)) && !defined(USE_EEPROM) uint8_t tt; // read test value tt = (uint8_t)eeprom_read_byte(&EE_ESR_ZEROtab[0]); // this value will never be changed by calibration if (tt != ESR_ZERO) goto init_ee; #ifdef AUTO_CAL uint8_t tt0; // value of first c_zero_tab uint8_t ww; // loop counter tt0 = tt; // init tt0 value for (ww=0;ww<7;ww++) { //checking loop tt = (uint8_t)eeprom_read_byte(&c_zero_tab[ww]); if (ww == 0) tt0 = tt; // save first value // for forth element, tt must be tt0 or tt0+1 if ((ww == 3) && ((tt != tt0) && (tt != (tt0+1)) && (tt != (tt0+2)) )) goto init_ee; if ((tt > 190) || (tt < 10)) goto init_ee; // value too low or too big } #endif return; init_ee: // init all EEprom values lcd_line1(); lcd_data('E'); lcd_data('E'); #ifdef AUTO_CAL // write the correction value for ADC internal 1.1V reference (void) eeprom_write_byte((uint8_t *)(&RefDiff), (uint8_t)REF_R_KORR); // offset for true reference Voltage // write the correction value for comparator 1.1V reference (void) eeprom_write_word((uint16_t *)(&ref_offset), REF_C_KORR); // hold zero offset + slew rate dependend offset // write all 7 c_zero_tab values (void) eeprom_write_word((uint16_t *)(&c_zero_tab[0]),((C_NULL)*256) + (C_NULL)); (void) eeprom_write_byte((uint8_t *)(&c_zero_tab[2]),(C_NULL+TP2_CAP_OFFSET)); (void) eeprom_write_byte((uint8_t *)(&c_zero_tab[3]),(C_NULL+2)); (void) eeprom_write_byte((uint8_t *)(&c_zero_tab[4]),(C_NULL+TP2_CAP_OFFSET)); (void) eeprom_write_word((uint16_t *)(&c_zero_tab[5]),((C_NULL)*256) + (C_NULL)); #endif // write 4 EE_ESR_ZEROtab values (void) eeprom_write_word((uint16_t *)(&EE_ESR_ZEROtab[0]),(ESR_ZERO*256)+ESR_ZERO); (void) eeprom_write_word((uint16_t *)(&EE_ESR_ZEROtab[2]),(ESR_ZERO*256)+ESR_ZERO); #if ((LCD_ST_TYPE == 7565) || (LCD_ST_TYPE == 1306)) (void) eeprom_write_byte((uint8_t *)(&EE_Volume_Value), VOLUME_VALUE); #endif #ifdef WITH_ROTARY_SWITCH // (void) eeprom_write_byte(&EE_RotarySwitch,0); // no switch is detected #endif wait_about1s(); // time to read the "EE" message, initialization of EEprom finished #endif }
void lcd_material_store_material(uint8_t nr) { eeprom_write_word(EEPROM_MATERIAL_TEMPERATURE_OFFSET(nr), material[active_extruder].temperature); #if TEMP_SENSOR_BED != 0 eeprom_write_word(EEPROM_MATERIAL_BED_TEMPERATURE_OFFSET(nr), material[active_extruder].bed_temperature); #endif eeprom_write_word(EEPROM_MATERIAL_FLOW_OFFSET(nr), material[active_extruder].flow); eeprom_write_byte(EEPROM_MATERIAL_FAN_SPEED_OFFSET(nr), material[active_extruder].fan_speed); eeprom_write_float(EEPROM_MATERIAL_DIAMETER_OFFSET(nr), material[active_extruder].diameter); //eeprom_write_block(card.longFilename, EEPROM_MATERIAL_NAME_OFFSET(nr), 8); eeprom_write_word(EEPROM_MATERIAL_CHANGE_TEMPERATURE(nr), material[active_extruder].change_temperature); eeprom_write_byte(EEPROM_MATERIAL_CHANGE_WAIT_TIME(nr), material[active_extruder].change_preheat_wait_time); }
uint8_t config_update(void) { uint8_t error = 0; uint8_t checksum; bool recalc_checksum = false; if (task != eeprom_read_word(&ee_task)) { recalc_checksum = true; eeprom_write_word(&ee_task, task); if (task != eeprom_read_word(&ee_task)) { error |= _BV(CONFIG_BAD_TASK_BIT); } } if (zone != eeprom_read_word(&ee_zone)) { recalc_checksum = true; eeprom_write_word(&ee_zone, zone); if (zone != eeprom_read_word(&ee_zone)) { error |= _BV(CONFIG_BAD_ZONE_BIT); } } if (brightness != eeprom_read_byte(&ee_brightness)) { recalc_checksum = true; eeprom_write_byte(&ee_brightness, brightness); if (brightness != eeprom_read_byte(&ee_brightness)) { error |= _BV(CONFIG_BAD_BRIGHTNESS_BIT); } } if (action != eeprom_read_byte(&ee_action)) { recalc_checksum = true; eeprom_write_byte(&ee_action, action); if (action != eeprom_read_byte(&ee_action)) { error |= _BV(CONFIG_BAD_ACTION_BIT); } } if (recalc_checksum) { checksum = config_calc_checksum(); eeprom_write_byte(&ee_checksum, checksum); if (checksum != eeprom_read_byte(&ee_checksum)) { error |= _BV(CONFIG_BAD_CHECKSUM_BIT); } } return error; }
void sendStats( boolean isStart ) { uint8_t tt = GetTemp(); uint16_t starts = eeprom_read_word(&eeprom_starts); uint8_t rid_low = eeprom_read_byte((unsigned char *)(EEPROM_ROBOT_ID_LOW*2)); uint8_t rid_high = eeprom_read_byte((unsigned char *)(EEPROM_ROBOT_ID_HIGH*2)); // RRS,VERSION,TEMP,STARTS,ROBOT_ID // RRS,4,60,3222,40,0,3 = version 4, TEMP = 60 somethings (not celsius or fahrenheits), starts 3222, robot_id_low = 40, robot_id_high = 0, pcb_type = 3 Serial.print("RRS,"); Serial.print(B2_VERSION, DEC ); Serial.print(","); Serial.print(tt, DEC); Serial.print(","); Serial.print(starts, DEC); Serial.print(","); Serial.print(rid_low, DEC); Serial.print(","); Serial.print(rid_high, DEC); Serial.print(","); Serial.print(pcb_type, DEC); // pcb type Serial.println(); if(isStart){ starts++; eeprom_write_word(&eeprom_starts, starts); } }
void do_time_monitor(void *dummy) { uint16_t seconds; seconds = eeprom_read_word(EEPROM_TIME_ADDRESS); seconds ++; eeprom_write_word(EEPROM_TIME_ADDRESS, seconds); }
void yacksave (void) /*! @brief Saves all permanent settings to EEPROM To save EEPROM write cycles, writing only happens when the flag DIRTYFLAG is set. After writing the flag is cleared @callergraph */ { if(volflags & DIRTYFLAG) // Dirty flag set? { eeprom_write_byte(&magic, MAGPAT); eeprom_write_word(&ctcstor, ctcvalue); eeprom_write_byte(&wpmstor, wpm); eeprom_write_byte(&flagstor, yackflags); eeprom_write_byte(&fwstor, farnsworth); volflags &= ~DIRTYFLAG; // Clear the dirty flag } }
void lcd_material_store_current_material() { for(uint8_t e=0; e<EXTRUDERS; e++) { eeprom_write_word(EEPROM_MATERIAL_TEMPERATURE_OFFSET(EEPROM_MATERIAL_SETTINGS_MAX_COUNT+e), material[e].temperature); #if TEMP_SENSOR_BED != 0 eeprom_write_word(EEPROM_MATERIAL_BED_TEMPERATURE_OFFSET(EEPROM_MATERIAL_SETTINGS_MAX_COUNT+e), material[e].bed_temperature); #endif eeprom_write_byte(EEPROM_MATERIAL_FAN_SPEED_OFFSET(EEPROM_MATERIAL_SETTINGS_MAX_COUNT+e), material[e].fan_speed); eeprom_write_word(EEPROM_MATERIAL_FLOW_OFFSET(EEPROM_MATERIAL_SETTINGS_MAX_COUNT+e), material[e].flow); eeprom_write_float(EEPROM_MATERIAL_DIAMETER_OFFSET(EEPROM_MATERIAL_SETTINGS_MAX_COUNT+e), material[e].diameter); eeprom_write_word(EEPROM_MATERIAL_CHANGE_TEMPERATURE(EEPROM_MATERIAL_SETTINGS_MAX_COUNT+e), material[e].change_temperature); eeprom_write_byte(EEPROM_MATERIAL_CHANGE_WAIT_TIME(EEPROM_MATERIAL_SETTINGS_MAX_COUNT+e), material[e].change_preheat_wait_time); } }
void deny_access() { /* * Store the failed attemps in the EEPROM * in order to prevent circumventing the security by unplugging the * AVR's supply wires... * (Same applies to the remaining wait time, see later.) */ eeprom_write_byte(WRONG_TRIES, eeprom_read_byte(WRONG_TRIES) + 1); avr_lcd_clear(); avr_lcd_puts("Access denied!"); char buf[16]; snprintf(buf, 16, "%d of %d tries", eeprom_read_byte(WRONG_TRIES), MAX_WRONG_TRIES); avr_lcd_set_cursor_pos(AVR_LCD_LINE1 + 0); avr_lcd_puts(buf); _delay_ms(2000); if (eeprom_read_byte(WRONG_TRIES) >= MAX_WRONG_TRIES) { eeprom_write_word(WAIT_TIMER, LOCKDOWN_WAIT); lock_device(); } }
/* sets calibration value for s0 meters */ void metering_set_s0_calibration(uint16_t value) { metering_stop(); eeprom_write_word((uint16_t*) EE_METERING_REF, ((3600000*CLOCK_SECOND)/(value*10))); metering_init(); metering_start(); }
void configSave(void) { configCalc(); eeprom_write_word((void*)ADR_FIRSTTIME, 0xEEEE); /*eeprom_write_block((void*)&LCD_BACKLIGHT, (void*)ADR_LCD_BACKLIGHT, 1); eeprom_write_block((void*)&LCD_CONTRAST, (void*)ADR_LCD_CONTRAST, 1); eeprom_write_block((void*)&BAUDRATE, (void*)ADR_BAUDRATE, 4); eeprom_write_block((void*)&MAX_POWER, (void*)ADR_MAX_POWER, 2); eeprom_write_block((void*)&DEBUG_MODE, (void*)ADR_DEBUG_MODE, 1); eeprom_write_block((void*)&EXTERNAL_INTENSITY_MODE, (void*)ADR_EXTERNAL_INTENSITY_MODE, 1); eeprom_write_block((void*)&EXTERNAL_ONOFF_MODE, (void*)ADR_EXTERNAL_ONOFF_MODE, 1); eeprom_write_block((void*)&EXTINTENSITY_MIN, (void*)ADR_EXTINTENSITY_MIN, 2); eeprom_write_block((void*)&EXTINTENSITY_MAX, (void*)ADR_EXTINTENSITY_MAX, 2);*/ SAVETOEEPROM(LCD_BACKLIGHT, ADR_LCD_BACKLIGHT, 1); SAVETOEEPROM(LCD_CONTRAST, ADR_LCD_CONTRAST, 1); SAVETOEEPROM(BAUDRATE, ADR_BAUDRATE, 4); SAVETOEEPROM(MAX_POWER, ADR_MAX_POWER, 2); SAVETOEEPROM(DEBUG_MODE, ADR_DEBUG_MODE, 1); SAVETOEEPROM(EXTERNAL_INTENSITY_MODE, ADR_EXTERNAL_INTENSITY_MODE, 1); SAVETOEEPROM(EXTERNAL_ONOFF_MODE, ADR_EXTERNAL_ONOFF_MODE, 1); SAVETOEEPROM(EXTINTENSITY_MIN, ADR_EXTINTENSITY_MIN, 2); SAVETOEEPROM(EXTINTENSITY_MAX, ADR_EXTINTENSITY_MAX, 2); SAVETOEEPROM(WAVELENGTH, ADR_WAVELENGTH, sizeof(WAVELENGTH)); SAVETOEEPROM(CHECK_LASERCONNECTED, ADR_CHECK_LASERCONNECTED, 1); #ifdef TWO_LASERS SAVETOEEPROM(MAX_POWER2, ADR_MAX_POWER2, 2); SAVETOEEPROM(WAVELENGTH2, ADR_WAVELENGTH2, sizeof(WAVELENGTH2)); #endif }
void eepromSaveWord(uint16_t pos, uint16_t value) { if (eepromReadWord(pos) != value) { eeprom_write_word((uint16_t*)pos, value); } }
void AoAPlug::store_maxval_threshold(uint16_t maxval_threshold) { if (MAX_VAL_THRESHOLD==maxval_threshold) { return; // skip writing if it is the same value } MAX_VAL_THRESHOLD = maxval_threshold; eeprom_write_word(MAXVALTHR_EEPROM_ADDR, MAX_VAL_THRESHOLD); }
void inc_reboot(void) /******************************************************************************/ { uint16_t reboots = eeprom_read_word(&reboot_counter_lo_ee); reboots++; eeprom_write_word(&reboot_counter_lo_ee, reboots); }
static void write_crc(void) { uint8_t *eeprom_addr = (uint8_t *)EEPROM_ADDR; uint16_t crc = ~0; for (uint16_t i=0; i<config_sz-2; i++) crc = _crc16_update(crc, eeprom_read_byte(eeprom_addr + i)); eeprom_write_word((uint16_t*)(eeprom_addr+config_sz-2), crc); }