49 lines
1.3 KiB
C
49 lines
1.3 KiB
C
|
#include "bsp_head.h"
|
||
|
|
||
|
#include "kit_data.h"
|
||
|
#include "kit_debug.h"
|
||
|
|
||
|
const uint32_t head_flag[kHeadStatus_None] = {0xEEEEEEEE, 0xAAAAAAAA};
|
||
|
|
||
|
kit_ret_e bsp_head_set_status(flash_Item_t *item, uint32_t addr, HeadStatus st)
|
||
|
{
|
||
|
kit_ret_e res = kKit_Ret_ParamErr;
|
||
|
KIT_ASSERT_PARAM((item != NULL) && (st < kHeadStatus_None));
|
||
|
|
||
|
if((item != NULL) && (st < kHeadStatus_None))
|
||
|
{
|
||
|
res = drv_flash_write_u32(item, addr + (st << 2), head_flag[st]);
|
||
|
}
|
||
|
return res;
|
||
|
}
|
||
|
|
||
|
HeadStatus bsp_head_get_status(flash_Item_t *item, uint32_t addr)
|
||
|
{
|
||
|
kit_ret_e res;
|
||
|
uint32_t head1, head2;
|
||
|
HeadStatus st = kHeadStatus_Other;
|
||
|
|
||
|
KIT_ASSERT_PARAM(item != NULL);
|
||
|
if(item != NULL)
|
||
|
{
|
||
|
res = drv_flash_read_u32(item, addr, &head1);
|
||
|
res |= drv_flash_read_u32(item, addr + 4, &head2);
|
||
|
if(res == kKit_Ret_Ok)
|
||
|
{
|
||
|
if((head1 == 0xEEEEEEEE) && (head2 == 0xAAAAAAAA))
|
||
|
{
|
||
|
st = kHeadStatus_Finsih;
|
||
|
}
|
||
|
else if((head1 == 0xEEEEEEEE) && (head2 == 0xFFFFFFFF))
|
||
|
{
|
||
|
st = kHeadStatus_Start;
|
||
|
}
|
||
|
else if((head1 == 0xFFFFFFFF) && (head2 == 0xFFFFFFFF))
|
||
|
{
|
||
|
st = kHeadStatus_None;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
return st;
|
||
|
}
|