#ifndef _DRV_FLASH_
#define _DRV_FLASH_

#ifdef __cplusplus
extern "C" {
#endif

#include "kit_core.h"
typedef struct
{
    uint32_t start_page;
    uint32_t page_cnt;
}FlashItem;

#define FLASH_STATIC_INIT(_name, _start_page, _page_cnt)  \
    FlashItem _name = \
    {   \
        (_start_page),     \
        (_page_cnt),    \
    }



KitResult flash_read_u16(FlashItem *item, uint32_t addr, uint16_t *data);
KitResult flash_read_u32(FlashItem *item, uint32_t addr, uint32_t *data);

KitResult flash_write_u32(FlashItem *item, uint32_t addr, uint32_t value);
KitResult flash_write_buf(FlashItem *item, uint32_t addr, uint8_t *buff, uint32_t len);
KitResult flash_series_erase_page(FlashItem *item, uint32_t addr, uint32_t cnt); 

uint32_t flash_get_page_size(FlashItem *item);



void flashJump(uint32_t dest_addr, NoArgCall call);
void flashJumpNew(uint32_t dest_addr, NoArgCall call);

#ifdef __cplusplus
}
#endif

#endif
