-
Notifications
You must be signed in to change notification settings - Fork 0
/
eeprom.c
43 lines (35 loc) · 1.17 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
// EEPROM functions
// Jason Losh
//-----------------------------------------------------------------------------
// Hardware Target
//-----------------------------------------------------------------------------
// Target uC: TM4C123GH6PM
// System Clock: -
//-----------------------------------------------------------------------------
// Device includes, defines, and assembler directives
//-----------------------------------------------------------------------------
#include <stdint.h>
#include "tm4c123gh6pm.h"
#include "eeprom.h"
//-----------------------------------------------------------------------------
// Subroutines
//-----------------------------------------------------------------------------
void initEeprom(void)
{
SYSCTL_RCGCEEPROM_R = 1;
_delay_cycles(3);
while (EEPROM_EEDONE_R & EEPROM_EEDONE_WORKING);
}
void writeEeprom(uint16_t add, uint32_t data)
{
EEPROM_EEBLOCK_R = add >> 4;
EEPROM_EEOFFSET_R = add & 0xF;
EEPROM_EERDWR_R = data;
while (EEPROM_EEDONE_R & EEPROM_EEDONE_WORKING);
}
uint32_t readEeprom(uint16_t add)
{
EEPROM_EEBLOCK_R = add >> 4;
EEPROM_EEOFFSET_R = add & 0xF;
return EEPROM_EERDWR_R;
}