コード例 #1
0
ファイル: Waypoints.cpp プロジェクト: AhLeeYong/x-drone
Waypoints::WP
Waypoints::get_waypoint_with_index(uint8_t i)
{
	Waypoints::WP wp;

	i = constrain(i, 0, _total);
	uint32_t mem = _start_byte + (i * _wp_size);
	
	eeprom_busy_wait();
	wp.id = eeprom_read_byte((uint8_t *)mem);

	mem++;
	eeprom_busy_wait();
	wp.p1 = eeprom_read_byte((uint8_t *)mem);

	mem++;
	eeprom_busy_wait();
	wp.alt = (long)eeprom_read_dword((uint32_t *)mem);

	mem += 4;
	eeprom_busy_wait();
	wp.lat = (long)eeprom_read_dword((uint32_t *)mem);

	mem += 4;
	eeprom_busy_wait();
	wp.lng = (long)eeprom_read_dword((uint32_t *)mem);
}
コード例 #2
0
ファイル: heater.c プロジェクト: Traumflug/Teacup_Firmware
/** Inititalise PID data structures.

  \param i Index of the heater to initialise by Teacup numbering.
*/
void pid_init() {
  uint8_t i;

  for (i = 0; i < NUM_HEATERS; i++) {
    #ifdef HEATER_SANITY_CHECK
      // 0 is a "sane" temperature when we're trying to cool down.
      heaters_runtime[i].sane_temperature = 0;
    #endif

    #ifndef BANG_BANG
      #ifdef EECONFIG
        // Read factors from EEPROM.
        heaters_pid[i].p_factor =
          eeprom_read_dword((uint32_t *)&EE_factors[i].EE_p_factor);
        heaters_pid[i].i_factor =
          eeprom_read_dword((uint32_t *)&EE_factors[i].EE_i_factor);
        heaters_pid[i].d_factor =
          eeprom_read_dword((uint32_t *)&EE_factors[i].EE_d_factor);
        heaters_pid[i].i_limit =
          eeprom_read_word((uint16_t *)&EE_factors[i].EE_i_limit);

      if (crc_block(&heaters_pid[i].p_factor, 14) !=
          eeprom_read_word((uint16_t *)&EE_factors[i].crc))
      #endif /* EECONFIG */
      {
        heaters_pid[i].p_factor = DEFAULT_P;
        heaters_pid[i].i_factor = DEFAULT_I;
        heaters_pid[i].d_factor = DEFAULT_D;
        heaters_pid[i].i_limit = DEFAULT_I_LIMIT;
      }
    #endif /* BANG_BANG */
  }
}
コード例 #3
0
ファイル: page_linear_sweep.c プロジェクト: elmo2k3/dds_one
void page_linear_sweep_load_parameters(struct menuitem *self)
{
	f1 = eeprom_read_dword(&f1_eeprom);
	if(f1 == 0xFFFFFFFF) // cell after erase cycle
		f1 = 0;
	f2 = eeprom_read_dword(&f2_eeprom);
	if(f2 == 0xFFFFFFFF) // cell after erase cycle
		f2 = 0;
	time = eeprom_read_dword(&time_eeprom);
	if(time == 0xFFFFFFFF) // cell after erase cycle
		time = 50;
}
コード例 #4
0
ファイル: temp.c プロジェクト: eduveiga/ATmega-Skeleton
void temp_init() {
	p_factor = eeprom_read_dword((uint32_t *) &EE_p_factor);
	i_factor = eeprom_read_dword((uint32_t *) &EE_i_factor);
	d_factor = eeprom_read_dword((uint32_t *) &EE_d_factor);
	i_limit = eeprom_read_word((uint16_t *) &EE_i_limit);

	if ((p_factor == 0) && (i_factor == 0) && (d_factor == 0) && (i_limit == 0)) {
		p_factor = DEFAULT_P;
		i_factor = DEFAULT_I;
		d_factor = DEFAULT_D;
		i_limit = DEFAULT_I_LIMIT;
	}
}
コード例 #5
0
ファイル: rgblight.c プロジェクト: Xyverz/qmk_firmware
uint32_t eeconfig_read_rgblight(void) {
  #if defined(__AVR__) || defined(STM32_EEPROM_ENABLE) || defined(PROTOCOL_ARM_ATSAM) || defined(EEPROM_SIZE)
    return eeprom_read_dword(EECONFIG_RGBLIGHT);
  #else
    return 0;
  #endif
}
コード例 #6
0
ファイル: seed_eeprom.c プロジェクト: jiser/avrsnippets
uint32_t get_seed(uint32_t* eeprom_begin, uint32_t* eeprom_end)
{
  uint32_t* ptr;
  uint32_t seed = eeprom_read_dword(eeprom_begin);

  for (ptr=eeprom_begin+1; ptr<eeprom_end; ++ptr)
    if (++seed != eeprom_read_dword(ptr)) break;

  if (ptr >= eeprom_end) ptr = eeprom_begin;

  eeprom_write_dword(ptr, seed);

  if (seed == 0) seed = 0xaaaaaaaa;

  return seed;
}
コード例 #7
0
static void load_lifetime_stats()
{
    unsigned long magic = eeprom_read_dword((uint32_t*)(LIFETIME_EEPROM_OFFSET + 0));
    if (magic == LIFETIME_MAGIC)
    {
        lifetime_minutes = eeprom_read_dword((uint32_t*)(LIFETIME_EEPROM_OFFSET + 4));
        lifetime_print_minutes = eeprom_read_dword((uint32_t*)(LIFETIME_EEPROM_OFFSET + 8));
        triptime_minutes = eeprom_read_dword((uint32_t*)(LIFETIME_EEPROM_OFFSET + 12));
        triptime_print_minutes = eeprom_read_dword((uint32_t*)(LIFETIME_EEPROM_OFFSET + 16));
    }else{
        lifetime_minutes = 0;
        lifetime_print_minutes = 0;
        triptime_minutes = 0;
        triptime_print_minutes = 0;
    }
}
コード例 #8
0
ファイル: eeprom.cpp プロジェクト: juansta/intiController
/**
 * Read a single 32 bits integer
 */
uint32_t Eeprom::readLong(int address)
{
    if (!isReadOk(address + sizeof(uint32_t)))
        return 0;

    return eeprom_read_dword((unsigned long *) address);
}
コード例 #9
0
ファイル: zoSms.c プロジェクト: rkammela/SupermodifiedServo
void zoSmsInitSettingsFromEeprom(void)
{
	Sms.Settings.NodeID = eeprom_read_byte((u08*)ZO_EEPROM_ADDRESS_NODE_ID);
	Sms.Pid.GainP = eeprom_read_word((u16*)ZO_EEPROM_ADDRESS_GAIN_P);
	Sms.Pid.GainI = eeprom_read_word((u16*)ZO_EEPROM_ADDRESS_GAIN_I);
	Sms.Pid.GainD = eeprom_read_word((u16*)ZO_EEPROM_ADDRESS_GAIN_D);
	Sms.Settings.CurrentLimit = eeprom_read_word((u16*)ZO_EEPROM_ADDRESS_CURRENT_LIMIT);
	Sms.Settings.CurrentLimitDuration = eeprom_read_word((u16*)ZO_EEPROM_ADDRESS_CURRENT_LIMIT_DURATION);
	Sms.Settings.DigitalIoConfig = eeprom_read_byte((u08*)ZO_EEPROM_ADDRESS_DIGITAL_IO_CONFIG);
	Sms.Settings.BaudUart = eeprom_read_dword((u32*)ZO_EEPROM_ADDRESS_BAUD_UART);
	Sms.Settings.BaudI2C = eeprom_read_dword((u32*)ZO_EEPROM_ADDRESS_BAUD_I2C);
	Sms.Profile.DesiredAcceleration = eeprom_read_word((u16*)ZO_EEPROM_ADDRESS_PROFILE_ACCELERATION);
	Sms.Profile.DesiredVelocity = eeprom_read_word((u16*)ZO_EEPROM_ADDRESS_PROFILE_VELOCITY);
	Sms.Settings.localAcceptanceMask = eeprom_read_byte((u08*)ZO_EEPROM_ADDRESS_LAM);
	Sms.Settings.errorReportingLevel = eeprom_read_byte((u08*)ZO_EEPROM_ADDRESS_ERROR_REPORTING_LVL);
}
コード例 #10
0
ファイル: rgblight.c プロジェクト: anechiporuk/qmk_firmware
uint32_t eeconfig_read_rgblight(void) {
  #ifdef __AVR__
    return eeprom_read_dword(EECONFIG_RGBLIGHT);
  #else
    return 0;
  #endif
}
コード例 #11
0
ファイル: heater.c プロジェクト: jgilmore/FiveD_on_Arduino
void heater_init() {
	heater_t i;
	// setup pins
	for (i = 0; i < NUM_HEATERS; i++) {
		*(heaters[i].heater_port) &= ~MASK(heaters[i].heater_pin);
		// DDR is always 1 address below PORT. ugly code but saves ram and an extra field in heaters[] which will never be used anywhere but here
		*(heaters[i].heater_port - 1) |= MASK(heaters[i].heater_pin);
		if (heaters[i].heater_pwm) {
			*heaters[i].heater_pwm = 0;
			// this is somewhat ugly too, but switch() won't accept pointers for reasons unknown
			switch((uint16_t) heaters[i].heater_pwm) {
				case (uint16_t) &OCR0A:
					TCCR0A |= MASK(COM0A1);
					break;
				case (uint16_t) &OCR0B:
					TCCR0A |= MASK(COM0B1);
					break;
				case (uint16_t) &OCR2A:
					TCCR2A |= MASK(COM2A1);
					break;
				case (uint16_t) &OCR2B:
					TCCR2A |= MASK(COM2B1);
					break;
			}
		}

		#ifdef	HEATER_SANITY_CHECK
			// 0 is a "sane" temperature when we're trying to cool down
			heaters_runtime[i].sane_temperature = 0;
		#endif

		#ifndef BANG_BANG
			// read factors from eeprom
			heaters_pid[i].p_factor = eeprom_read_dword((uint32_t *) &EE_factors[i].EE_p_factor);
			heaters_pid[i].i_factor = eeprom_read_dword((uint32_t *) &EE_factors[i].EE_i_factor);
			heaters_pid[i].d_factor = eeprom_read_dword((uint32_t *) &EE_factors[i].EE_d_factor);
			heaters_pid[i].i_limit = eeprom_read_word((uint16_t *) &EE_factors[i].EE_i_limit);

			if ((heaters_pid[i].p_factor == 0) && (heaters_pid[i].i_factor == 0) && (heaters_pid[i].d_factor == 0) && (heaters_pid[i].i_limit == 0)) {
				heaters_pid[i].p_factor = DEFAULT_P;
				heaters_pid[i].i_factor = DEFAULT_I;
				heaters_pid[i].d_factor = DEFAULT_D;
				heaters_pid[i].i_limit = DEFAULT_I_LIMIT;
			}
		#endif /* BANG_BANG */
	}
}
コード例 #12
0
ファイル: flamingo.c プロジェクト: AaronLK/flamingos
void seed_rand()
{
	uint32_t next_seed = eeprom_read_dword( (uint32_t*)SEED_ADDR );
	
	srandom( next_seed );
	
	eeprom_write_dword( (uint32_t*)SEED_ADDR, random() );
}
コード例 #13
0
int main()
{
  stdout = &mystdout;

  // read the eeprom value
  uint32_t c = eeprom_read_dword((void*)&value);
  printf("Read from eeprom 0x%08lx -- should be 0xdeadbeef\n", c);
  // change the eeprom
  eeprom_write_dword((void*)&value, 0xcafef00d);
  // re-read it
  c = eeprom_read_dword((void*)&value);
  printf("Read from eeprom 0x%08lx -- should be 0xcafef00d\n", c);

  // this quits the simulator, since interupts are off
  // this is a "feature" that allows running tests cases and exit
  sleep_cpu();
}
コード例 #14
0
ファイル: AP_Limit_Geofence.cpp プロジェクト: icer1/QuadPID
/*
  fence boundaries fetch/store
 */
Vector2l AP_Limit_Geofence::get_fence_point_with_index(uint8_t i)
{
    uint32_t mem;
    Vector2l ret;

    if (i > (unsigned) fence_total()) {
        return Vector2l(0,0);
    }

    // read fence point
    mem = _eeprom_fence_start + (i * _fence_wp_size);
    ret.x = eeprom_read_dword((uint32_t *)mem);
    mem += sizeof(uint32_t);
    ret.y = eeprom_read_dword((uint32_t *)mem);

    return ret;
}
コード例 #15
0
/**
 @brief	Replace HTML's variables to system configuration value
*/
static uint16_t replace_sys_env_value(
	uint8_t* base, 	/**< pointer to html buffer */
	uint16_t len
	)
{
	uint8_t sys_string[16]; // if there are more characters to substituted in response file, then make this bigger
	uint8_t *tptr, *ptr;
	time_t time_stamp;
	tm local_time;

	tptr = ptr = base;

	while((ptr = (uint8_t*)strchr((char*)tptr, '$')))
	{
		if((tptr = (uint8_t*)strstr((char*)ptr, EVB_PAGES_SERVED)))
		{
			memset(tptr,0x20,14); // erase system variable trigger string
			if( eeprom_is_ready() )
				sprintf_P((char *)sys_string, PSTR("%08u"), eeprom_read_dword(&pagesServed) ); // number of pages served by the http server.
			memcpy(tptr,sys_string,8); // copy the characters, but don't copy the /0
			tptr+=8;
		}

#if defined (portRTC_DEFINED)
		else if((tptr = (uint8_t*)strstr((char*)ptr, EVB_RTC)))
		{
			memset(tptr,0x20,11); // erase system variable trigger string
			if ( getDateTimeDS1307( (tm*)&local_time ) == pdTRUE)
				sprintf_P((char *)sys_string, PSTR("%02u:%02u:%02u"), local_time.tm_hour, local_time.tm_min, local_time.tm_sec);
			memcpy(tptr,sys_string,8);  // copy the characters, but don't copy the /0
			tptr+=8;
		}
#else
		else if((tptr = (uint8_t*)strstr((char*)ptr, EVB_RTC)))
		{
			memset(tptr,0x20,11); // erase system variable trigger string
	    	time(&time_stamp);
	    	localtime_r( &time_stamp, &local_time);
			sprintf_P((char *)sys_string, PSTR("%02d:%02d:%02d"), local_time.tm_hour, local_time.tm_min, local_time.tm_sec);
			memcpy(tptr,sys_string,8);  // copy the characters, but don't copy the /0
			tptr+=8;
		}
#endif
		else	// tptr == 0 && ptr!=0;
		{
			if(ptr==base)
			{
//				xSerialPrint_P(PSTR("$ Character"));
				return len;
			}
//			xSerialPrint_P(PSTR("REPLACE CONTINUE"));
			tptr = ptr;
			break;
		}
	}
	if(!ptr) return len;
	return (uint16_t)(tptr-base);
}
コード例 #16
0
//Arduino IDE compatibility, lacks the eeprom_read_float function
float inline eeprom_read_float(float* addr)
{
    union {
        uint32_t i;
        float f;
    } n;
    n.i = eeprom_read_dword((uint32_t*)addr);
    return n.f;
}
コード例 #17
0
ファイル: eeprom_test.c プロジェクト: getting/nfc-smart-tag
static void test_simple_increment() {
  test("test_simple_increment");
  uint32_t *memory = (uint32_t *)100;

  eeprom_write_dword(memory, 1);
  uint32_t result = increment_eeprom_uint32(memory);
  assert(result == 2);
  assert(eeprom_read_dword(memory) == 2);
}
コード例 #18
0
ファイル: eeprom_test.c プロジェクト: getting/nfc-smart-tag
static void test_overflow_into_4th_byte() {
  test("test_overflow_into_4th_byte");
  uint32_t *memory = (uint32_t *)108;

  eeprom_write_dword(memory, 0x00FFFFFF);
  uint32_t result = increment_eeprom_uint32(memory);
  assert(result == 0x01000000);
  assert(eeprom_read_dword(memory) == 0x01000000);
}
コード例 #19
0
ファイル: eeprom_test.c プロジェクト: getting/nfc-smart-tag
static void test_byte_overflow() {
  test("test_byte_overflow");
  uint32_t *memory = (uint32_t *)104;

  eeprom_write_dword(memory, 0xFF);
  uint32_t result = increment_eeprom_uint32(memory);
  assert(result == 0x100);
  assert(eeprom_read_dword(memory) == 0x100);
}
コード例 #20
0
ファイル: eeprom.c プロジェクト: kmzbrnoI/posilaci-systemy-fw
void eeprom_init()
{
  int i;
  for (i = 0; i < EEPROM_LEN; i++)
  {
    eeprom_busy_wait();
    eeprom_data[i] = eeprom_read_dword(&EEPROM[i]);
    if (eeprom_data[i]+1 == 0) __UPDATE_EEPROM(i, 0);   // bacause of default EEPROM
  }
}
コード例 #21
0
ファイル: dispenser.c プロジェクト: npahucki/peesco-8
void get_saved_tick_count(void)
{
    uint32_t ticks;

    cli();
    ticks = g_ticks;
    sei();

    send_packet16(PACKET_SAVED_TICK_COUNT, ticks + eeprom_read_dword((uint32_t *)ee_run_time_ticks_offset), 0);
}
コード例 #22
0
ファイル: Descriptors.c プロジェクト: johandc/bluebox
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
                                    const uint8_t wIndex,
                                    const void **const DescriptorAddress,
                                    uint8_t *DescriptorMemorySpace)
{
    uint32_t snum;
    const uint8_t DescriptorType   = (wValue >> 8);
    const uint8_t DescriptorNumber = (wValue & 0xFF);

    const void *Address = NULL;
    uint16_t Size = NO_DESCRIPTOR;

    *DescriptorMemorySpace = MEMSPACE_FLASH;

    switch (DescriptorType) {
    case DTYPE_Device:
        Address = &BlueBox_DeviceDescriptor;
        Size    = sizeof(USB_Descriptor_Device_t);
        break;
    case DTYPE_Configuration:
        Address = &BlueBox_ConfigurationDescriptor;
        Size    = sizeof(USB_Descriptor_Configuration_t);
        break;
    case DTYPE_String:
        switch (DescriptorNumber)
        {
        case 0x00:
            Address = &BlueBox_LanguageString;
            Size    = pgm_read_byte(&BlueBox_LanguageString.Header.Size);
            break;
        case 0x01:
            Address = &BlueBox_ManufacturerString;
            Size    = pgm_read_byte(&BlueBox_ManufacturerString.Header.Size);
            break;
        case 0x02:
            Address = &BlueBox_ProductString;
            Size    = pgm_read_byte(&BlueBox_ProductString.Header.Size);
            break;
        case 0x03:
            Address = &BlueBox_SerialString;
            Size    = BlueBox_SerialString.Header.Size;

            snum = eeprom_read_dword(&serialno);
            format_serial(snum, ((uint16_t *) &BlueBox_SerialString.UnicodeString));

            *DescriptorMemorySpace = MEMSPACE_RAM;
            break;
        }

        break;
    }

    *DescriptorAddress = Address;
    return Size;
}
コード例 #23
0
ファイル: intercom.c プロジェクト: ClusterM/intercom
int main (void)
{
	clunet_init();  
	clunet_set_on_data_received(data_received);	
	time_init();
	sei();
	//eeprom_write_dword((void*)0, 0);
	record_num = eeprom_read_dword((void*)0); // Читаем кол-во записей
	mode_current = eeprom_read_byte((void*)4); // Режим 
	mode_temp = eeprom_read_byte((void*)5); // Временный режим

	disk_initialize(0);	

	unset_bit(DDRA, 3); set_bit(PORTA, 3);	 // Определение сигнала в линии	
	//unset_bit(DDRA, 4);	unset_bit(PORTA, 4); // Открывалка двери, напрямую
	set_bit(DDRA, 4);	unset_bit(PORTA, 4); // Открывалка двери, через реле
	set_bit(DDRA, 5); HANGUP; // Реле снимания трубки
	set_bit(DDRA, 6); MODE_NORMAL; // Реле выбора режима
	unset_bit(DDRG, 0); set_bit(PORTG, 0); // Определение, лежит ли трубка	
	set_bit(DDRD, 6); set_bit(DDRD, 7); // Светодиоды
	unset_bit(DDRA, 7); set_bit(PORTA, 7); // Счётчик оборотов диска

	unset_bit(DDRF, 0); // ADC+
	unset_bit(PORTF, 0);
	unset_bit(DDRF, 1); // ADC-
	unset_bit(PORTF, 1);

	beep(500, 200);
	beep(1500, 200);
	beep(3000, 200);
	_delay_ms(1000);
	if (play_wav_pgm(STARTED_WAV) == 0)
	{
		LED_GREEN_ON;
		while (sound_read() >= 0) ;
		LED_GREEN_OFF;
		sound_stop();
	} else {
		LED_RED_ON;
		beep(3000, 200);
		beep(1500, 200);
		beep(500, 200);
		LED_RED_OFF;
	}
	
	send_current_mode(CLUNET_BROADCAST_ADDRESS);

	while(1)
	{
		if (is_LINE_POWER()) incoming_ring();
		if (OFFHOOK) control_mode();
		transfer_data(); // Передаём данные на досуге.
	}
}
コード例 #24
0
/** \brief function for incrementing the value of msgAuthoritativeEngineBoots, called at startup */
u8t incMsgAuthoritativeEngineBoots()
{
	/*Increments the Value of MsgAuthoritativeEngineBoots when booting.*/
	/*Checks if the maximum value of 2147483647 (RFC3414) is reached.*/
	if((eeprom_read_dword(&MsgAuthoritativeEngineBoots))<2147483647)
	{
		eeprom_update_dword(&MsgAuthoritativeEngineBoots, (eeprom_read_dword(&MsgAuthoritativeEngineBoots)+1));
	}
	else
	{
#if PDEBUG
		printf("Maximum Number of MsgAuthoritativeEngineBoots reached, please reconfigure all secret values and reinstall SNMP Agent\n");
#endif
	}
#if PDEBUG
	printf("MsgAuthoritativeEngineBoots = %lu\n",eeprom_read_dword(&MsgAuthoritativeEngineBoots));
#endif

	return 0;
}
コード例 #25
0
ファイル: si5351.cpp プロジェクト: yangkkokk/Teensy_SDR
/*
 * init(uint8_t xtal_load_c)
 *
 * Setup communications to the Si5351 and set the crystal
 * load capacitance.
 *
 * xtal_load_c - Crystal load capacitance. Use the SI5351_CRYSTAL_LOAD_*PF
 * defines in the header file
 *
 */
void Si5351::init(uint8_t xtal_load_c)
{
	// Start I2C comms
	Wire.begin();

	// Set crystal load capacitance
	si5351_write(SI5351_CRYSTAL_LOAD, xtal_load_c);

	// Get the correction factor from EEPROM
	ref_correction = eeprom_read_dword(&ee_ref_correction);
}
コード例 #26
0
ファイル: eeprom_test.c プロジェクト: getting/nfc-smart-tag
static void test_rollover_to_zero() {
  test("test_rollover_to_zero");
  uint32_t *memory = (uint32_t *)112;

  eeprom_write_dword(memory, 0xFFFFFFFF);
  eeprom_write_byte((uint8_t *)memory + 4, 0xa5);
  uint32_t result = increment_eeprom_uint32(memory);
  assert(result == 0x00000000);
  assert(eeprom_read_dword(memory) == 0x00000000);
  assert(eeprom_read_byte((uint8_t *)memory + 4) == 0xa5);
}
コード例 #27
0
ALWBase::ALWBase() {
  /*
   * XXX: For some reason, this messes things up if it runs in init().
   * It must have something to do with the timing: Calling it before
   * Arduino's core init code is okay, but after is not. Bizarre.
   * One thread suggested it's the WDT, but I don't think so.
   */
  static uint32_t EEMEM storedRandomSeed;
  uint32_t randomSeed = eeprom_read_dword(&storedRandomSeed);
  srandom(randomSeed);
  eeprom_write_dword(&storedRandomSeed, random());
}
コード例 #28
0
ファイル: bluebox.c プロジェクト: johandc/bluebox
static void do_serialnumber(int direction, unsigned int vWalue)
{
	uint32_t snum;

	if (direction == ENDPOINT_DIR_OUT) {
		Endpoint_Read_Control_Stream_LE(&snum, sizeof(snum));
		eeprom_write_dword(&serialno, snum);
	} else if (direction == ENDPOINT_DIR_IN) {
		snum = eeprom_read_dword(&serialno);
		Endpoint_Write_Control_Stream_LE(&snum, sizeof(snum));
	}
}
コード例 #29
0
ファイル: program.c プロジェクト: theFork/uMIDI
char* export_bank(const uint8_t bank)
{
    // Allocate static (!) string buffer:
    // 2 characters for hexadecimal encoding of each byte of the program plus string termination
    static char result_string[2*sizeof(uint32_t)*PROGRAMS_PER_BANK+1] = "";

    // Format programs
    uint8_t offset = bank * PROGRAMS_PER_BANK;
    char* write_pointer = result_string;
    for (uint8_t i=0; i < PROGRAMS_PER_BANK; ++i) {
        snprintf(write_pointer, 9, "%08lx", eeprom_read_dword(&program_data_storage[offset+i]));
        write_pointer += 8;
    }
    return result_string;
}
コード例 #30
0
ファイル: dispenser.c プロジェクト: npahucki/peesco-8
void flush_saved_tick_count(uint8_t force)
{
    uint8_t is_dispensing;
    uint32_t ticks_to_save;

    cli();
    is_dispensing = g_is_dispensing;
    ticks_to_save = g_ticks;
    sei();

    if (is_dispensing && !force)
        return;

    if (ticks_to_save > TICKS_SAVE_THRESHOLD || (force && ticks_to_save > 0))
    {
        cli();
        g_ticks = 0;
        sei();

        ticks_to_save += eeprom_read_dword((uint32_t *)ee_run_time_ticks_offset);
        eeprom_update_dword((uint32_t *)ee_run_time_ticks_offset, ticks_to_save);
    }
}