// Setup the registers and read settings from EEPROM int main(){ // Read settings from EEPROM off_time = ((unsigned int )eeprom_read_word(OFF_TIME_ADDR )); ramp_time = ((unsigned char )eeprom_read_byte(RAMP_TIME_ADDR))*(unsigned int)100; fade_time = ((unsigned char )eeprom_read_byte(FADE_TIME_ADDR)); dim_level = ((unsigned char)eeprom_read_byte(DIM_LVL_ADDR)); DDRB |= PWM; // Set SWITCH to output DDRB &= ~(ON | DIM | OFF | SENSE); // Set ON, OFF, DIM, SENSE to input PORTB |= (ON | DIM | OFF ); // Enable Pull Up resistors TIMSK0 |= 0x02; // Enable timer overflow interrupts GIMSK |= 0x20; // Enable Pin Change interrupts PCMSK |= 0x1A; // Interupt on 1, 3, 4 // Enable PWM on OCR0A TCCR0B |= 0x03; // Divide clock by 64 TCCR0A |= 0x83; // Fast PWM current_level = 255; target_level = 255; OCR0A = 255; // Start lights at full sei(); // Enable global interrupts while(1); }
// *************** RDM Reception Initialisation **************** void init_RDM(void) { if (!eeprom_read_byte((uint8_t*)EEPROM_STATUS)) { //use DevID from EEPROM if set eeprom_read_block(&DevID, (uint16_t*)EEPROM_DEVICE_ID, 6); } DmxAddress= eeprom_read_word((uint16_t*)EEPROM_DMX_ADDRESS); //moved from check_RDM, doesn't need to be done every time label i s read if(eeprom_read_byte((uint8_t*)EEPROM_LABEL_LEN) > 32) eeprom_write_byte((uint8_t*)EEPROM_LABEL_LEN , 0); DDRD |= (1<<PD2)|(1<<PD1); PORTD &= ~(1<<PD2); //enable reception PORTD |= (1<<PD1); UBRRH = 0; UBRRL = ((F_OSC/4000)-1); //250kbaud, 8N2 UCSRC = (3<<UCSZ0)|(1<<USBS); UCSRB = (1<<RXEN)|(1<<RXCIE); RxState= IDLE; uint8_t i; for (i=0; i<sizeof(DmxField); i++) { DmxField[i]= 0; } }
int main(void) { initUSART(); char ramString[STRING_LEN]; uint8_t counter; while (1) { printString("\r\n------------------\r\n"); eeprom_read_block(ramString, eepromString, STRING_LEN); printString(ramString); printString("\r\nThe counter reads: "); counter = eeprom_read_byte(&eepromCounter); printByte(counter); printString("\r\nMy uint16_t value is: "); printWord(eeprom_read_word(&eepromWord)); printString("\r\n Enter a new introduction string below:\r\n"); readString(ramString, STRING_LEN); eeprom_update_block(ramString, eepromString, STRING_LEN); counter++; eeprom_update_byte(&eepromCounter, counter); } return 0; }
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 setup(void) { g_press_down_timer = 0; g_idle_timer = 0; g_rom_select = eeprom_read_word(EEPROM_DEFAULT_ROM_SEL_ADDR); DDRB = ROM_SELECT_PIN | POWER_ENABLE_PIN | UART_TX_PIN; PORTB = (g_power_enabled?0:POWER_ENABLE_PIN) | RESTORE_KEY_PIN; PCMSK = RESTORE_KEY_PIN; softuart_init(); // Configure OCR1B output for 60Hz TCCR1 = _BV(CTC1) | _BV(CS13) | _BV(CS11) | _BV(CS10); // Prescale select CK/1024 GTCCR = _BV(PWM1B) | _BV(COM1B1); // Enable PWM on OCB1 OCR1A = 0; OCR1B = 66; OCR1C = 132; TIMSK |= _BV(TOV1); // Interrupt on Timer 1 Overflow (used for button) GIMSK |= _BV(PCIE); // Interrupt on pin change for Restore Key (used to wake from sleep) sei(); // Enable interrupts }
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); } }
int main(void) { DDRD = 0xff; DDRB = 0xff; DDRC = 0; PORTC = _BV(2) | _BV(3) | _BV(4) | _BV(5); // keyboard pull-up TCCR1A = 0; TCCR1B = _BV(CS11) | _BV(CS10); TIMSK = _BV(OCIE1A); sei(); enableLed(false); enablePower(false); displayOutTime(0); timer_interval = eeprom_read_word(EEPROM_OFFSET_TIME); if (timer_interval > MAX_TIME_INTERVAL_MINUTES || timer_interval == 0) { timer_interval = 10; } while(1) { keyboardCheck(); if (timer_mode == TIMER_MODE_WAIT) { if (key_pressed[KEY_PLUS] == 0xff && timer_interval < MAX_TIME_INTERVAL_MINUTES) { timer_interval++; key_pressed[KEY_PLUS] = 220; } else if (key_pressed[KEY_MINUS] == 0xff && timer_interval > 0) { timer_interval--; key_pressed[KEY_MINUS] = 220; } } for (uint8_t i = 0; i < 8; i++) { displayUpdate(i); if (timer_mode == TIMER_MODE_RUN) { displayOutTime(time); displayOutSeparator(hsec < 50); if (time < 30) { enableLed(hsec < 25 || (hsec > 50 && hsec < 75)); } else if (time < 60) { enableLed(hsec < 75); } } else { displayOutTime(timer_interval); displayOutSeparator(true); //displayOutSeparator(hsec < 25 || (hsec > 50 && hsec < 75)); //if (hsec < 25 || (hsec > 50 && hsec < 75)) { //displayOutTime(timer_interval); //displayOutSeparator(true); //} else { //displayClear(); //} } _delay_us(500); } } }
static void trigger_jog_timer(const struct reg *reg) { struct storage s; s=reg_storage(reg); cli(); jog_timer=eeprom_read_word((void *)s.loc.eeprom.start); sei(); }
void lcd_material_read_current_material() { for(uint8_t e=0; e<EXTRUDERS; e++) { material[e].temperature = eeprom_read_word(EEPROM_MATERIAL_TEMPERATURE_OFFSET(EEPROM_MATERIAL_SETTINGS_MAX_COUNT+e)); material[e].bed_temperature = eeprom_read_word(EEPROM_MATERIAL_BED_TEMPERATURE_OFFSET(EEPROM_MATERIAL_SETTINGS_MAX_COUNT+e)); material[e].flow = eeprom_read_word(EEPROM_MATERIAL_FLOW_OFFSET(EEPROM_MATERIAL_SETTINGS_MAX_COUNT+e)); material[e].fan_speed = eeprom_read_byte(EEPROM_MATERIAL_FAN_SPEED_OFFSET(EEPROM_MATERIAL_SETTINGS_MAX_COUNT+e)); material[e].diameter = eeprom_read_float(EEPROM_MATERIAL_DIAMETER_OFFSET(EEPROM_MATERIAL_SETTINGS_MAX_COUNT+e)); strcpy_P(material_name[e],PSTR("???")); eeprom_read_block(material_name[e], EEPROM_MATERIAL_NAME_OFFSET(EEPROM_MATERIAL_SETTINGS_MAX_COUNT+e), MATERIAL_NAME_LENGTH); material_name[e][MATERIAL_NAME_LENGTH] = '\0'; } }
inline static void init_rand() { uint16_t srand_seed_value; srand_seed_value = eeprom_read_word((void*) EEPROM_SRAND_ADDR); srand(srand_seed_value); eeprom_write_word((void*)EEPROM_SRAND_ADDR, rand()); }
void lcd_material_set_material(uint8_t nr, uint8_t e) { material[e].temperature = eeprom_read_word(EEPROM_MATERIAL_TEMPERATURE_OFFSET(nr)); material[e].bed_temperature = eeprom_read_word(EEPROM_MATERIAL_BED_TEMPERATURE_OFFSET(nr)); material[e].flow = eeprom_read_word(EEPROM_MATERIAL_FLOW_OFFSET(nr)); material[e].fan_speed = eeprom_read_byte(EEPROM_MATERIAL_FAN_SPEED_OFFSET(nr)); material[e].diameter = eeprom_read_float(EEPROM_MATERIAL_DIAMETER_OFFSET(nr)); eeprom_read_block(card.longFilename, EEPROM_MATERIAL_NAME_OFFSET(nr), 8); card.longFilename[8] = '\0'; if (material[e].temperature > HEATER_0_MAXTEMP - 15) material[e].temperature = HEATER_0_MAXTEMP - 15; if (material[e].bed_temperature > BED_MAXTEMP - 15) material[e].bed_temperature = BED_MAXTEMP - 15; lcd_material_store_current_material(); }
void sns_power_Init(void) { #ifdef sns_power_USEEEPROM if (EEDATA_OK) { ///TODO: Use stored data to set initial values for the module sns_power_ReportInterval = eeprom_read_byte(EEDATA.reportInterval); EnergyCounter = eeprom_read_word(EEDATA16.EnergyCounterLower); EnergyCounter += (((uint32_t)(eeprom_read_word(EEDATA16.EnergyCounterUpper)))<<16); #ifdef POWER_SNS_PIN_ch2 EnergyCounter_ch2 = eeprom_read_word(EEDATA16.EnergyCounterLower_ch2); EnergyCounter_ch2 += (((uint32_t)(eeprom_read_word(EEDATA16.EnergyCounterUpper_ch2)))<<16); #endif } else { //The CRC of the EEPROM is not correct, store default values and update CRC eeprom_write_byte_crc(EEDATA.reportInterval, sns_power_SEND_PERIOD, WITHOUT_CRC); eeprom_write_word_crc(EEDATA16.EnergyCounterUpper, 0, WITHOUT_CRC); eeprom_write_word_crc(EEDATA16.EnergyCounterLower, 0, WITHOUT_CRC); #ifdef POWER_SNS_PIN_ch2 eeprom_write_word_crc(EEDATA16.EnergyCounterUpper_ch2, 0, WITHOUT_CRC); eeprom_write_word_crc(EEDATA16.EnergyCounterLower_ch2, 0, WITHOUT_CRC); #endif EEDATA_UPDATE_CRC; sns_power_ReportInterval = eeprom_read_byte(EEDATA.reportInterval); } #endif ///Initialize hardware etc gpio_set_in(POWER_SNS_PIN); // Set to input gpio_set_pin(POWER_SNS_PIN); // Enable pull-up Pcint_SetCallbackPin(sns_power_PCINT, POWER_SNS_PIN, &sns_power_pcint_callback); MeasurmentBufferPointer = 0; #ifdef POWER_SNS_PIN_ch2 gpio_set_in(POWER_SNS_PIN_ch2); // Set to input gpio_set_pin(POWER_SNS_PIN_ch2); // Enable pull-up Pcint_SetCallbackPin(sns_power_PCINT_ch2, POWER_SNS_PIN_ch2, &sns_power_pcint_callback_ch2); MeasurmentBufferPointer_ch2 = 0; #endif Timer_SetTimeout(sns_power_SEND_TIMER, sns_power_ReportInterval*1000 , TimerTypeFreeRunning, 0); #if sns_power_SEND_1_MIN_AVG == 1 Timer_SetTimeout(sns_power_SEND_TIMER_1_MIN_AVG, 60000-10 , TimerTypeFreeRunning, &sns_power_timer_callback); #endif }
bool was_bootloader_requested() { bool requested = (eeprom_read_word((uint16_t *)Board::kConfigMagic) == Board::kBLMagic); eeprom_update_word((uint16_t *)Board::kConfigMagic, 0xffff); return requested; }
inline void init() { uint16_t wfc_timeout = eeprom_read_word(U16P(eeprom::WFC_TIMEOUT)); cmdProcessor::init(wfc_timeout); pwm::init(); transceiver::init(cmdProcessor::processCommand); sei(); }
uint16_t settings_get_word(uint8_t key) { if (key < WordSettingsKeyCount) { return eeprom_read_word(&eeWordSettings[key]); } return 0; }
void read_eeprom(void){ backlight = eeprom_read_byte(ADDR_BACKLT); volume = eeprom_read_byte(ADDR_VOLUME); battery = eeprom_read_byte(ADDR_BATTERY); freq_wave = eeprom_read_word(ADDR_FREQWV); level_wave = eeprom_read_byte(ADDR_LEVELWV); type_wave = eeprom_read_byte(ADDR_TYPEWV); wave_out = eeprom_read_byte(ADDR_STATEWV); }
/** Main program entry point. This routine configures the hardware required by the bootloader, then continuously * runs the bootloader processing routine until it times out or is instructed to exit. */ int main(void) { /* Save the value of the boot key memory before it is overwritten */ uint16_t bootKeyPtrVal = *bootKeyPtr; *bootKeyPtr = 0; /* Check the reason for the reset so we can act accordingly */ uint8_t mcusr_state = MCUSR; // store the initial state of the Status register MCUSR = 0; // clear all reset flags /* Watchdog may be configured with a 15 ms period so must disable it before going any further */ wdt_disable(); /* Jump to bootloader only if correct key is present in eeprom */ if ((eeprom_read_word((uint16_t*)EEP_BOOTKEY_ADDR) != BOOTLOADER_BOOTKEY) && (eeprom_read_word((uint16_t*)EEP_BACKUP_BOOTKEY_ADDR) != BOOTLOADER_BOOTKEY)) { StartSketch(); } /* Setup hardware required for the bootloader */ SetupHardware(); /* Enable global interrupts so that the USB stack can function */ sei(); Timeout = 0; while (RunBootloader) { CDC_Task(); USB_USBTask(); /* Time out and start the sketch if one is present */ if (Timeout > TIMEOUT_PERIOD) RunBootloader = false; LEDPulse(); } /* Disconnect from the host - USB interface will be reset later along with the AVR */ USB_Detach(); /* Jump to beginning of application space to run the sketch - do not reset */ StartSketch(); }
void game_over(uint8_t i) { if (game.mode == 2 || game.mode == 3) { connect_put(CONN_GAMEOVER); connect_put(i); if (connect_get() != CONN_READY) { game_connFailed(); return; } } sound_freq(SOUND_FAILED); game_record(i); RECTANGLE(GAME_OVER); tft_setZoom(2); STRING(GAME_OVER_STR); tft_setXY(GAME_OVER_LOST_X, GAME_OVER_LOST_Y); tft_setColour(GAME_OVER_LOST_FGC, GAME_OVER_LOST_BGC); tft_print_string("Player"); tft_print_uint16(i + 1); tft_print_string(" LOST"); tft_setXY(GAME_OVER_HIGH_X, GAME_OVER_HIGH_Y); tft_setColour(GAME_OVER_HIGH_FGC, GAME_OVER_HIGH_BGC); tft_print_uint16(eeprom_read_word(&NVScore[0])); tft_print_string("/"); tft_print_uint16(eeprom_read_word(&NVScore[1])); tft_setXY(GAME_OVER_REC_X, GAME_OVER_REC_Y); tft_setColour(GAME_OVER_REC_FGC, GAME_OVER_REC_BGC); tft_print_uint16(eeprom_read_word(&NVOverCnt[0])); tft_print_string("/"); tft_print_uint16(eeprom_read_word(&NVOverCnt[1])); STRING(GAME_OVER_CLN); get: switch (ROE_get()) { case ROE_SW2: case ROE_SW1: game_record(2); sound_freq(SOUND_CONF); break; case ROE_N: goto get; } sound_freq(SOUND_CANCEL); while (ROE_get() != ROE_N); }
void RefVoltage(void) { // RefVoltage interpolates table RHtab corresponding to voltage ref_mv_offs . // RHtab contain the factors to get capacity from load time with 470k for // different Band gab reference voltages. // for remember: //resistor 470000 Ohm 1000 1050 1100 1150 1200 1250 1300 1350 1400 mV //uint16_t RHTAB[] MEM_TEXT = { 954, 903, 856, 814, 775, 740, 707, 676, 648}; #define Ref_Tab_Abstand 50 // displacement of table is 50mV #define Ref_Tab_Beginn 1000 // begin of table is 1000mV unsigned int referenz; unsigned int y1, y2; uint8_t tabind; uint8_t tabres; #ifdef AUTO_CAL referenz = ref_mv + (int16_t)eeprom_read_word((uint16_t *)(&ref_offset)); #else referenz = ref_mv + REF_C_KORR; #endif ref_mv_offs = referenz; #ifdef AUTO_RH if (referenz >= Ref_Tab_Beginn) { referenz -= Ref_Tab_Beginn; } else { referenz = 0; // limit to begin of table } tabind = referenz / Ref_Tab_Abstand; tabres = referenz % Ref_Tab_Abstand; tabres = Ref_Tab_Abstand-tabres; if (tabind > 7) { tabind = 7; // limit to end of table } // interpolate the table of factors y1 = pgm_read_word(&RHtab[tabind]); y2 = pgm_read_word(&RHtab[tabind+1]); // RHmultip is the interpolated factor to compute capacity from load time with 470k RHmultip = ((y1 - y2) * tabres + (Ref_Tab_Abstand/2)) / Ref_Tab_Abstand + y2; //######################################## #else RHmultip = DEFAULT_RH_FAKT; // default Multiplier for capacity measurement with R_H (470KOhm) #endif #if PROCESSOR_TYP == 8 referenz = 2560; // use defined internal ADC Voltage #else referenz = ref_mv; // use the read out internal Reference voltage #endif #ifdef AUTO_CAL ADCconfig.U_Bandgap = (ref_mv + (int8_t)eeprom_read_byte((uint8_t *)&RefDiff)); #else ADCconfig.U_Bandgap = (ref_mv + REF_R_KORR); #endif adc_internal_reference = ADCconfig.U_Bandgap; }
void lcd_material_read_current_material() { for(uint8_t e=0; e<EXTRUDERS; e++) { material[e].temperature = eeprom_read_word(EEPROM_MATERIAL_TEMPERATURE_OFFSET(EEPROM_MATERIAL_SETTINGS_MAX_COUNT+e)); #if TEMP_SENSOR_BED != 0 material[e].bed_temperature = eeprom_read_word(EEPROM_MATERIAL_BED_TEMPERATURE_OFFSET(EEPROM_MATERIAL_SETTINGS_MAX_COUNT+e)); #endif material[e].flow = eeprom_read_word(EEPROM_MATERIAL_FLOW_OFFSET(EEPROM_MATERIAL_SETTINGS_MAX_COUNT+e)); material[e].fan_speed = eeprom_read_byte(EEPROM_MATERIAL_FAN_SPEED_OFFSET(EEPROM_MATERIAL_SETTINGS_MAX_COUNT+e)); material[e].diameter = eeprom_read_float(EEPROM_MATERIAL_DIAMETER_OFFSET(EEPROM_MATERIAL_SETTINGS_MAX_COUNT+e)); material[e].change_temperature = eeprom_read_word(EEPROM_MATERIAL_CHANGE_TEMPERATURE(EEPROM_MATERIAL_SETTINGS_MAX_COUNT+e)); material[e].change_preheat_wait_time = eeprom_read_byte(EEPROM_MATERIAL_CHANGE_WAIT_TIME(EEPROM_MATERIAL_SETTINGS_MAX_COUNT+e)); if (material[e].change_temperature < 10) material[e].change_temperature = material[e].temperature; } }
static void lcd_material_select_details_callback(uint8_t nr) { uint8_t count = eeprom_read_byte(EEPROM_MATERIAL_COUNT_OFFSET()); if (nr == 0) { } else if (nr <= count) { char buffer[32]; char* c = buffer; nr -= 1; if (led_glow_dir) { c = float_to_string(eeprom_read_float(EEPROM_MATERIAL_DIAMETER_OFFSET(nr)), c, PSTR("mm")); while(c < buffer + 10) *c++ = ' '; strcpy_P(c, PSTR("Flow:")); c += 5; c = int_to_string(eeprom_read_word(EEPROM_MATERIAL_FLOW_OFFSET(nr)), c, PSTR("%")); }else{ c = int_to_string(eeprom_read_word(EEPROM_MATERIAL_TEMPERATURE_OFFSET(nr)), c, PSTR("C")); #if TEMP_SENSOR_BED != 0 *c++ = ' '; c = int_to_string(eeprom_read_word(EEPROM_MATERIAL_BED_TEMPERATURE_OFFSET(nr)), c, PSTR("C")); #endif while(c < buffer + 10) *c++ = ' '; strcpy_P(c, PSTR("Fan: ")); c += 5; c = int_to_string(eeprom_read_byte(EEPROM_MATERIAL_FAN_SPEED_OFFSET(nr)), c, PSTR("%")); } lcd_lib_draw_string(5, 53, buffer); }else if (nr == count + 1) { lcd_lib_draw_string_centerP(53, PSTR("Modify the settings")); }else if (nr == count + 2) { lcd_lib_draw_string_centerP(53, PSTR("Saves all materials")); }else if (nr == count + 3) { lcd_lib_draw_string_centerP(53, PSTR("Loads all materials")); } }
uint16_t read16uint(int inode, int offset) { int16_t addr; addr = inode*INODESIZE + offset; eeprom_busy_wait(); return eeprom_read_word((uint16_t *)addr); }
void read_highscores(void){ if (eeprom_read_word(&save_sig) == SIG) { eeprom_read_block((void*)&high_scores, (void*)&ee_high_scores, BYTES); } else { for (int i = 0; i<SCORES; i++){ high_scores[i] = blank_score; } } }
void init () { _current_sensor = eeprom_read_byte (ADC_BATTERY_EEPROM_CURRENT_SENSOR); _voltage_multiplier = eeprom_read_float (ADC_BATTERY_EEPROM_VOLTAGE_MULTIPLIER); if (_current_sensor) _current_multiplier = eeprom_read_float (ADC_BATTERY_EEPROM_CURRENT_MULTIPLIER); _interval = eeprom_read_word (ADC_BATTERY_EEPROM_UPDATE_INTERVAL); _voltage_channel = eeprom_read_byte (ADC_BATTERY_EEPROM_VOLTAGE_CHANNEL); _current_channel = eeprom_read_byte (ADC_BATTERY_EEPROM_CURRENT_CHANNEL); }
bool lcd_material_verify_material_settings() { SERIAL_ECHO_START; uint8_t max_mats = eeprom_read_byte(EEPROM_MATERIAL_COUNT_OFFSET()); SERIAL_ECHOPAIR("Checking ", (unsigned long) max_mats); SERIAL_ECHOPAIR(" presets and ", (unsigned long) EXTRUDERS); SERIAL_ECHOLNPGM (" extruder settings:"); if (max_mats < 2 || max_mats > EEPROM_MATERIAL_SETTINGS_MAX_COUNT) return false; byte cnt =0; while(cnt < max_mats+EXTRUDERS) { SERIAL_ECHOPAIR("Checking preset # ",(unsigned long) cnt); if (eeprom_read_word(EEPROM_MATERIAL_TEMPERATURE_OFFSET(cnt)) > HEATER_0_MAXTEMP) return false; if (eeprom_read_word(EEPROM_MATERIAL_BED_TEMPERATURE_OFFSET(cnt)) > BED_MAXTEMP) return false; if (eeprom_read_byte(EEPROM_MATERIAL_FAN_SPEED_OFFSET(cnt)) > 100) return false; if (eeprom_read_word(EEPROM_MATERIAL_FLOW_OFFSET(cnt)) > 1000) return false; if (eeprom_read_float(EEPROM_MATERIAL_DIAMETER_OFFSET(cnt)) > 10.0) return false; if (eeprom_read_float(EEPROM_MATERIAL_DIAMETER_OFFSET(cnt)) < 0.1) return false; strcpy_P (material_name_buf,"???"); eeprom_read_block(material_name_buf, EEPROM_MATERIAL_NAME_OFFSET(cnt), MATERIAL_NAME_LENGTH); material_name_buf[MATERIAL_NAME_LENGTH] = '\0'; if (cnt >= max_mats ) { SERIAL_ECHOPAIR(".....verified extruder setting # ",(unsigned long) cnt-max_mats);} else { SERIAL_ECHOPAIR(".....verified preset # ",(unsigned long) cnt);} SERIAL_ECHO(" ("); SERIAL_ECHO(material_name_buf); SERIAL_ECHO(")"); SERIAL_ECHOLN(""); cnt++; } return true; }
void eeprom_read_buffer(struct sample_buffer* buffer, uint16_t pos) { eeprom_busy_wait(); uint16_t length = eeprom_read_word((uint16_t*) pos); pos += 2; for (uint16_t i = 0; i < length; i++) { eeprom_busy_wait(); push_sample(buffer, eeprom_read_byte((uint8_t*) pos + i)); } }
// ----------------------------------------------------------------------------- uint16_t usAvrXReadEEPromWord (const uint16_t * pusAddress) { uint16_t usWord; vAvrXWaitSemaphore (&xEEPromSem); usWord = eeprom_read_word (pusAddress); vAvrXSetSemaphore (&xEEPromSem); return usWord; }
void yackinit (void) /*! @brief Initializes the YACK library This function initializes the keyer hardware according to configurations in the .h file. Then it attempts to read saved configuration settings from EEPROM. If not possible, it will reset all values to their defaults. This function must be called once before the remaining fuctions can be used. */ { byte magval; // Configure DDR. Make OUT and ST output ports SETBIT (OUTDDR,OUTPIN); SETBIT (STDDR,STPIN); // Raise internal pullups for all inputs SETBIT (KEYPORT,DITPIN); SETBIT (KEYPORT,DAHPIN); SETBIT (BTNPORT,BTNPIN); magval = eeprom_read_byte(&magic); // Retrieve magic value if (magval == MAGPAT) // Is memory valid { ctcvalue = eeprom_read_word(&ctcstor); // Retrieve last ctc setting wpm = eeprom_read_byte(&wpmstor); // Retrieve last wpm setting wpmcnt=(1200/YACKBEAT)/wpm; // Calculate speed farnsworth = eeprom_read_byte(&fwstor); // Retrieve last wpm setting yackflags = eeprom_read_byte(&flagstor); // Retrieve last flags } else { yackreset(); } yackinhibit(OFF); #ifdef POWERSAVE PCMSK |= PWRWAKE; // Define which keys wake us up GIMSK |= (1<<PCIE); // Enable pin change interrupt #endif // Initialize timer1 to serve as the system heartbeat // CK runs at 1MHz. Prescaling by 64 makes that 15625 Hz. // Counting 78 cycles of that generates an overflow every 5ms OCR1C = 78; // 77 counts per cycle TCCR1 |= (1<<CTC1) | 0b00000111 ; // Clear Timer on match, prescale ck by 64 OCR1A = 1; // CTC mode does not create an overflow so we use OCR1A }
void load_preset(){ try_reset_eeprom(); unsigned int addr; addr = 0; eeprom_busy_wait(); preset_info.scale_preset.record_flag = eeprom_read_word((uint16_t *)addr); addr += 2; for (uint8_t i=0; i<16; ++i) { eeprom_busy_wait(); preset_info.scale_preset.scales[i] = eeprom_read_word((uint16_t *)addr); addr += 2; } eeprom_busy_wait(); preset_info.pattern_preset.record_flag = eeprom_read_word((uint16_t *)addr); addr += 2; for (uint8_t i=0; i<16; ++i) { for (uint8_t j=0; j<16; ++j) { eeprom_busy_wait(); preset_info.pattern_preset.patterns[i][j] = eeprom_read_byte((uint8_t *)addr); ++addr; } } for (uint8_t i=0; i<16; ++i) { if (!(preset_info.scale_preset.record_flag & (1<<i))) { preset_info.scale_preset.scales[i] = pgm_read_word(&(scale_defs[i])); } if (!(preset_info.pattern_preset.record_flag & (1<<i))) { for (uint8_t j=0; j<16; ++j) { preset_info.pattern_preset.patterns[i][j] = pgm_read_byte(&(scale_patterns[i][j])); } } } update_scale_table(preset_info.scale_preset.scales); }
bool lcd_material_verify_material_settings() { bool hasUPET = false; uint8_t cnt = eeprom_read_byte(EEPROM_MATERIAL_COUNT_OFFSET()); if (cnt < 2 || cnt > EEPROM_MATERIAL_SETTINGS_MAX_COUNT) return false; while(cnt > 0) { cnt --; if (eeprom_read_word(EEPROM_MATERIAL_TEMPERATURE_OFFSET(cnt)) > HEATER_0_MAXTEMP) return false; // if (eeprom_read_word(EEPROM_MATERIAL_BED_TEMPERATURE_OFFSET(cnt)) > BED_MAXTEMP) // return false; if (eeprom_read_byte(EEPROM_MATERIAL_FAN_SPEED_OFFSET(cnt)) > 100) return false; if (eeprom_read_word(EEPROM_MATERIAL_FLOW_OFFSET(cnt)) > 1000) return false; if (eeprom_read_float(EEPROM_MATERIAL_DIAMETER_OFFSET(cnt)) > 10.0) return false; if (eeprom_read_float(EEPROM_MATERIAL_DIAMETER_OFFSET(cnt)) < 0.1) return false; eeprom_read_block(card.longFilename, EEPROM_MATERIAL_NAME_OFFSET(cnt), 8); if (strcmp_P(card.longFilename, PSTR("UPET")) == 0) hasUPET = true; } cnt = eeprom_read_byte(EEPROM_MATERIAL_COUNT_OFFSET()); if (!hasUPET && cnt < EEPROM_MATERIAL_SETTINGS_MAX_COUNT) { strcpy_P(card.longFilename, PSTR("UPET")); eeprom_write_block(card.longFilename, EEPROM_MATERIAL_NAME_OFFSET(cnt), 5); eeprom_write_word(EEPROM_MATERIAL_TEMPERATURE_OFFSET(cnt), 250); // eeprom_write_word(EEPROM_MATERIAL_BED_TEMPERATURE_OFFSET(cnt), 60); eeprom_write_byte(EEPROM_MATERIAL_FAN_SPEED_OFFSET(cnt), 50); eeprom_write_word(EEPROM_MATERIAL_FLOW_OFFSET(cnt), 100); eeprom_write_float(EEPROM_MATERIAL_DIAMETER_OFFSET(cnt), 2.85); eeprom_write_byte(EEPROM_MATERIAL_COUNT_OFFSET(), cnt + 1); } return true; }