Files

28 lines
752 B
C

/**
* @file eeprom.h
* @brief IAP (在应用编程) 模拟 EEPROM
* STC8H 的 IAP 允许读/写/擦除 Flash 的某个扇区 (512 字节)
* 我们用最后 1 个扇区 (512B @ IAP_EEPROM_BASE)
*
* 存储布局:
* [0..3] magic "L3" + 版本
* [4] mode (RxMode_e)
* [5] rf_channel
* [6..10] rf_address (5 字节)
* [11] checksum
*/
#ifndef __EEPROM_H
#define __EEPROM_H
#include "stc8h.h"
#include <stdint.h>
#define EEPROM_OK 0
#define EEPROM_ERR 1
uint8_t eeprom_init(void);
uint8_t eeprom_read(uint8_t *mode, uint8_t *ch, uint8_t addr[5]);
uint8_t eeprom_write(uint8_t mode, uint8_t ch, const uint8_t addr[5]);
uint8_t eeprom_format(void); /* 恢复默认 */
#endif