Added eeprom dump. Fixed incorrect reading of EEPROM
This commit is contained in:
parent
2bbbeec873
commit
d6fa80e21f
@ -2,7 +2,10 @@ all:
|
||||
make build
|
||||
make program
|
||||
build:
|
||||
avr-gcc main.c i2c_master.c -o counter -mmcu=attiny85
|
||||
avr-gcc main.c i2c_master.c -o counter -mmcu=attiny85 -Wall -Wextra
|
||||
|
||||
program:
|
||||
avrdude -p attiny85 -c usbtiny -U flash:w:counter
|
||||
|
||||
eeprom:
|
||||
avrdude -p attiny85 -c usbtiny -U eeprom:r:eeprom.hex
|
||||
|
||||
@ -336,7 +336,7 @@ int main()
|
||||
{
|
||||
++eeprom_idx;
|
||||
eeprom_idx %= EEPROM_SIZE;
|
||||
write_eeprom_val(eeprom_idx, (uint32_t)count_value_fine, move_dir);
|
||||
write_eeprom_val(eeprom_idx, (uint32_t) count_value_fine, move_dir);
|
||||
}
|
||||
count_value = (uint32_t) count_value_fine;
|
||||
|
||||
@ -855,7 +855,7 @@ uint16_t find_eeprom_idx()
|
||||
{
|
||||
// Check Last byte for value
|
||||
// FF XX ... FF ??
|
||||
if (0xFF != eeprom_read_byte((uint8_t *) EEPROM_SIZE - 1))
|
||||
if (0xFF != eeprom_read_byte((uint8_t *) (EEPROM_SIZE - 1)))
|
||||
{
|
||||
idx = EEPROM_SIZE - 1;
|
||||
}
|
||||
@ -891,7 +891,8 @@ void read_eeprom_val(uint16_t idx, uint32_t *value, uint8_t *dir)
|
||||
for (i = 0; i < 4; ++i)
|
||||
{
|
||||
curr_byte = eeprom_read_byte((uint8_t *) idx);
|
||||
(*value) |= (curr_byte << (24 - 8 * i));
|
||||
(*value) <<= 8;
|
||||
(*value) |= curr_byte;
|
||||
++idx;
|
||||
idx %= EEPROM_SIZE;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user