#ifndef __APP_EEPROM_H
#define __APP_EEPROM_H

#include "dev_at24cxx.h"
#include <stdint.h>

extern uint8_t app_eeprom_read_buf[520];
extern uint8_t app_eeprom_write_buf[520];
extern uint8_t read_buf[50];

#define APP_EEPROM_READ_STEP  PAGESIZE
#define APP_EEPROM_WRITE_STEP PAGESIZE

typedef uint8_t (*app_eeprom_read_callback)(void);
typedef uint8_t (*app_eeprom_write_callback)(void);

typedef struct
{
    uint8_t                 *buffer;
    uint16_t                 addr;
    uint16_t                 len;
    uint16_t                 cur;
    uint8_t                  save_id;
    app_eeprom_read_callback pfun;
    uint8_t                  used;
} app_eeprom_read_cache_t;

typedef struct
{
    uint8_t                  *buffer;
    uint16_t                  addr;
    uint16_t                  len;
    uint16_t                  cur;
    uint8_t                   save_id;
    uint8_t                   count;
    app_eeprom_write_callback pfun;
    uint8_t                   used;
} app_eeprom_write_cache_t;

void app_eeprom_read_task(void);
void app_eeprom_write_task(void);

uint8_t app_eeprom_read_50_zhuzu(void);
uint8_t app_eeprom_write_50_zhuzu(void);

#endif // __APP_EEPROM_H
