-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEEPROM.c
49 lines (46 loc) · 1.35 KB
/
EEPROM.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
* EEPROM.c
*
* Created on: Apr 21, 2020
* Author: tho
*/
#include "STD_Types.h"
#include "BIT_CALC.h"
#include "DIO_Interface.h"
#define F_CPU 8000000
#include "avr/delay.h"
#include "LCD_interface.h"
#include "avr/eeprom.h"
#include "EEPROM.h"
void Map_Write(u8 Map[11],u8 Map_add)
{
eeprom_update_block((const void*) Map, (void*) EEPROM_Map_Start_add + Map_add*Map_Size, Map_Size);
}
void Map_Read(u8 Number,u8 Map_add)
{
if ( Number < 10) // 1 digit
{
LCD_Void_Write_Data(eeprom_read_byte((u8*) EEPROM_Map_Start_add + Map_add*Map_Size + Number ));
}
else if (Number <100) // 2 digits
{
LCD_Void_Write_Data(eeprom_read_byte((u8*) EEPROM_Map_Start_add + Map_add*Map_Size + Number / 10 ));
LCD_Void_Write_Data(eeprom_read_byte((u8*) EEPROM_Map_Start_add + Map_add*Map_Size + Number % 10));
}
else // 3 digits
{
LCD_Void_Write_Data(eeprom_read_byte((u8*) EEPROM_Map_Start_add + Map_add*Map_Size + Number / 100));
LCD_Void_Write_Data(eeprom_read_byte((u8*) EEPROM_Map_Start_add + Map_add*Map_Size + (Number/10) % 10));
LCD_Void_Write_Data(eeprom_read_byte((u8*) EEPROM_Map_Start_add + Map_add*Map_Size + Number % 10));
}
}
/*
* burns maps, the maps are stored in a 2D array of strings
*/
void Maps_Burner(u8 Maps[Maps_Number][Map_Size+1])
{
for (u8 maps_ind = 0;maps_ind < Maps_Number ; maps_ind++)
{
Map_Write(Maps[maps_ind],maps_ind);
}
}