CLEON
Version 1
Cloud-Offloaded GPS Receiver
Main Page
Related Pages
Data Structures
Files
File List
Globals
hal_flash.c
Go to the documentation of this file.
1
7
#include "
cleon_conf.h
"
8
#include "
app_define.h
"
9
#include "
sys_define.h
"
10
#include "
hal_define.h
"
11
#include "
fs_define.h
"
12
13
/*----------------------------------------------------------------------------*/
21
void
HAL_FLASH_Init
(
void
)
22
{
23
#if ERASE_INTERNAL_FLASH_ON_RESET == _ENABLE_
24
HAL_FLASH_EraseBank
((
unsigned
long
*)
MSP430_INTERNAL_FLASH_BANK1_ADDRESS
);
25
HAL_FLASH_EraseBank
((
unsigned
long
*)
MSP430_INTERNAL_FLASH_BANK2_ADDRESS
);
26
HAL_FLASH_EraseBank
((
unsigned
long
*)
MSP430_INTERNAL_FLASH_BANK3_ADDRESS
);
27
#endif
28
}
29
30
/*----------------------------------------------------------------------------*/
40
void
HAL_FLASH_Write
(
unsigned
int
uiSize,
unsigned
char
*ptrucSource,
unsigned
char
*ptrucDestination)
41
{
42
FCTL3 = FWKEY;
// Clear Lock bit
43
FCTL1 = FWKEY + WRT;
// Enable byte/word write mode
44
45
while
(uiSize > 0) {
46
while
(FCTL3 & BUSY);
// test busy
47
*ptrucDestination++ = *ptrucSource++;
// Write to Flash
48
uiSize--;
49
}
50
51
FCTL1 = FWKEY;
// Clear Erase bit
52
FCTL3 = FWKEY + LOCK;
// Set LOCK bit
53
}
54
55
/*----------------------------------------------------------------------------*/
63
void
HAL_FLASH_EraseSegment
(
unsigned
long
*ptrulDestination)
64
{
65
FCTL3 = FWKEY;
// Clear Lock bit
66
FCTL1 = FWKEY + ERASE;
// Set Erase bit
67
*ptrulDestination = 0;
// Dummy write to erase Flash seg
68
while
(FCTL3 & BUSY);
// test busy
69
FCTL1 = FWKEY;
// Clear WRT bit
70
FCTL3 = FWKEY + LOCK;
// Set LOCK bit
71
}
72
73
/*----------------------------------------------------------------------------*/
81
void
HAL_FLASH_EraseBank
(
unsigned
long
*ptrulDestination)
82
{
83
FCTL3 = FWKEY;
// Clear Lock bit
84
FCTL1 = FWKEY + MERAS;
// Set Erase bit
85
*ptrulDestination = 0;
// Dummy write to erase Flash seg
86
while
(FCTL3 & BUSY);
// test busy
87
FCTL1 = FWKEY;
// Clear WRT bit
88
FCTL3 = FWKEY + LOCK;
// Set LOCK bit
89
}
hal
hal_flash.c
Generated on Tue May 28 2013 15:17:19 for CLEON by
1.8.2