| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433 |
- /**
- ******************************************************************************
- * @file EEPROM_Emulation/inc/eeprom.h
- * @author MCD Application Team
- * @version V3.1.0
- * @date 07/27/2009
- * @brief This file contains all the functions prototypes for the EEPROM
- * emulation firmware library.
- ******************************************************************************
- * @copy
- *
- * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
- * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
- * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
- * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
- * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
- * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
- *
- * <h2><center>© COPYRIGHT 2009 STMicroelectronics</center></h2>
- */
- /* Define to prevent recursive inclusion -------------------------------------*/
- #ifndef __EEPROM_H
- #define __EEPROM_H
- /* Includes ------------------------------------------------------------------*/
- #include "stm32f10x.h"
- //#define EEPROM_DEBUG_EN 1
- #ifdef EEPROM_DEBUG_EN
- #include <stdio.h>
- #define EEPROM_DEBUG(fmt, x...) \
- do \
- { \
- printf(fmt,##x); \
- }while(0)
- #define EEPROM_DEBUG1(fmt, x...) \
- do \
- { \
- printf("%s(Line %d): "fmt,__FUNCTION__,__LINE__, ##x); \
- }while(0)
- #define EEPROM_DEBUG_F(fmt, x...) \
- do \
- { \
- printf("%s %s(Line %d): "fmt,__FILE__,__FUNCTION__,__LINE__, ##x); \
- }while(0)
- #else
- #define EEPROM_DEBUG(fmt, x...)
- #define EEPROM_DEBUG1(fmt, x...)
- #define EEPROM_DEBUG_F(fmt, x...)
- #endif
- /* Exported constants --------------------------------------------------------*/
- /* Define the STM32F10Xxx Flash page size depending on the used STM32 device */
- #if defined (STM32F10X_LD) || defined (STM32F10X_MD)
- #define PAGE_SIZE (uint16_t)0x400 /* Page size = 1KByte */
- #elif defined (STM32F10X_HD) || defined (STM32F10X_CL)
- #define PAGE_SIZE (uint16_t)0x800 /* Page size = 2KByte */
- #endif
- /* EEPROM start address in Flash */
- #define EEPROM_START_ADDRESS ((uint32_t)0x0800F000) /* EEPROM emulation start address:
- after 64KByte of used Flash memory */
- /* Pages 0 and 1 base and end addresses */
- #define PAGE0_BASE_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + 0x000))
- #define PAGE0_END_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + (PAGE_SIZE - 1)))
- #define PAGE1_BASE_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + PAGE_SIZE))
- #define PAGE1_END_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + (2 * PAGE_SIZE - 1)))
- /* Used Flash pages for EEPROM emulation */
- #define PAGE0 ((uint16_t)0x0000)
- #define PAGE1 ((uint16_t)0x0001)
- /* No valid page define */
- #define NO_VALID_PAGE ((uint16_t)0x00AB)
- /* Page status definitions */
- #define ERASED ((uint16_t)0xFFFF) /* PAGE is empty */
- #define RECEIVE_DATA ((uint16_t)0xEEEE) /* PAGE is marked to receive data */
- #define VALID_PAGE ((uint16_t)0x0000) /* PAGE containing valid data */
- /* Valid pages in read and write defines */
- #define READ_FROM_VALID_PAGE ((uint8_t)0x00)
- #define WRITE_IN_VALID_PAGE ((uint8_t)0x01)
- /* Page full define */
- #define PAGE_FULL ((uint8_t)0x80)
- extern uint16_t VirtAddVarTab[];
- /* Variables' number */
- //#define NumbOfVar ((uint16_t)0x0041)
- #define NumbOfVar (sizeof(VirtAddVarTab)/sizeof(VirtAddVarTab[0]))
- /*复位次数*/
- #define CURSET_RESET_TIME 0x0000
- /*升级状态*/
- #define CURSET_UPDATE_STATE 0x0001
- /*set版本*/
- #define CURSET_SET_VER 0x0002
- /*预留*/
- #define CURSET_RESERVED1 0x0003
- /*预留*/
- #define CURSET_RESERVED2 0x0004
- /*预留*/
- #define CURSET_RESERVED3 0x0005
- /*设备唯一ID(MAC)(最低16位/共64位)*/
- #define CURSET_DEVICE_DevEUI0 0x0006
- /**/
- #define CURSET_DEVICE_DevEUI1 0x0007
- /**/
- #define CURSET_DEVICE_DevEUI2 0x0008
- /*设备唯一ID(MAC)(最高16位/共64位)*/
- #define CURSET_DEVICE_DevEUI3 0x0009
- /*设备地址(IP)(最低16位/共32位)*/
- #define CURSET_DEVICE_DevAddr0 0x000A
- /*设备地址(IP)(最高16位/共32位)*/
- #define CURSET_DEVICE_DevAddr1 0x000B
- /*设备类型:
- 0x01,网关
- 0x02,液位仪
- 0x03,采集器
- 0x04,NB油机
- 0x05,NB液位仪
- 0x09,英泰赛福模块*/
- #define CURSET_DEVICE_TYPE 0x000C
- /*硬件版本*/
- #define CURSET_DEVICE_HARD_VER 0x000D
- /*生产日期(2020)*/
- #define CURSET_DEVICE_MFD0 0x000E
- /*生产日期(08/08)*/
- #define CURSET_DEVICE_MFD1 0x000F
- /*所属网关ID(最低16位/共32位)*/
- #define CURSET_GW_ID0 0x0010
- /*所属网关ID(最高16位/共32位)*/
- #define CURSET_GW_ID1 0x0011
- /*Channel通道号*/
- #define CURSET_CHANNELL_NUM 0x0012
- /*BootLoader软件版本(最低16位/共32位)*/
- #define CURSET_BT_SOFT_VER0 0x0013
- /*BootLoader软件版本(最高16位/共32位)*/
- #define CURSET_BT_SOFT_VER1 0x0014
- /*协议版本(最低16位/共32位)*/
- #define CURSET_PROTOCOL_VER0 0x0015
- /*协议版本(最高16位/共32位)*/
- #define CURSET_PROTOCOL_VER1 0x0016
- /*app1起始地址(低16位)*/
- #define CURSET_APP1_START_ADDR0 0x0017
- /*app1起始地址(高16位)*/
- #define CURSET_APP1_START_ADDR1 0x0018
- /*app1版本存放地址(低16位)*/
- #define CURSET_APP1_VER_ADDR0 0x0019
- /*app1版本存放地址(高16位)*/
- #define CURSET_APP1_VER_ADDR1 0x001A
- /*app1长度存放地址(低16位)*/
- #define CURSET_APP1_LEN_ADDR0 0x001B
- /*app1长度存放地址(高16位)*/
- #define CURSET_APP1_LEN_ADDR1 0x001C
- /*app1CRC存放地址(低16位)*/
- #define CURSET_APP1_CRC_ADDR0 0x001D
- /*app1CRC存放地址(高16位)*/
- #define CURSET_APP1_CRC_ADDR1 0x001E
- /*app2起始地址(低16位)*/
- #define CURSET_APP2_START_ADDR0 0x001F
- /*app2起始地址(高16位)*/
- #define CURSET_APP2_START_ADDR1 0x0020
- /*app2版本存放地址(低16位)*/
- #define CURSET_APP2_VER_ADDR0 0x0021
- /*app2版本存放地址(高16位)*/
- #define CURSET_APP2_VER_ADDR1 0x0022
- /*app2长度存放地址(低16位)*/
- #define CURSET_APP2_LEN_ADDR0 0x0023
- /*app2长度存放地址(高16位)*/
- #define CURSET_APP2_LEN_ADDR1 0x0024
- /*app2CRC存放地址(低16位)*/
- #define CURSET_APP2_CRC_ADDR0 0x0025
- /*app2CRC存放地址(高16位)*/
- #define CURSET_APP2_CRC_ADDR1 0x0026
- /*app3起始地址(低16位)*/
- #define CURSET_APP3_START_ADDR0 0x0027
- /*app3起始地址(高16位)*/
- #define CURSET_APP3_START_ADDR1 0x0028
- /*app3版本存放地址(低16位)*/
- #define CURSET_APP3_VER_ADDR0 0x0029
- /*app3版本存放地址(高16位)*/
- #define CURSET_APP3_VER_ADDR1 0x002A
- /*app3长度存放地址(低16位)*/
- #define CURSET_APP3_LEN_ADDR0 0x002B
- /*app3长度存放地址(高16位)*/
- #define CURSET_APP3_LEN_ADDR1 0x002C
- /*app3CRC存放地址(低16位)*/
- #define CURSET_APP3_CRC_ADDR0 0x002D
- /*app3CRC存放地址(高16位)*/
- #define CURSET_APP3_CRC_ADDR1 0x002E
- /*app3固件类型*/
- #define CURSET_APP3_FIREWARE_TYPE 0x002F
- /*BASE_KEY0(最低16位/共128位)*/
- #define CURSET_BASE_KEY0 0x0030
- /**/
- #define CURSET_BASE_KEY1 0x0031
- /**/
- #define CURSET_BASE_KEY2 0x0032
- /**/
- #define CURSET_BASE_KEY3 0x0033
- /**/
- #define CURSET_BASE_KEY4 0x0034
- /**/
- #define CURSET_BASE_KEY5 0x0035
- /**/
- #define CURSET_BASE_KEY6 0x0036
- /*BASE_KEY7(最高16位/共128位)*/
- #define CURSET_BASE_KEY7 0x0037
- /*LORA 信道0 参数0
- [15]信道0使能,默认1b
- [14:08] Power,功率,默认20=0x14
- [07:00] (Freq/100)[07:00],默认0x88*/
- #define CURSET_LORA_CH0_PARM0 0x0038
- /*LORA 信道0 参数0
- [15:00] (Freq/100)[24:08],默认0x4A4B
- [07]信道0使能
- [06:00] Power*/
- #define CURSET_LORA_CH0_PARM1 0x0039
- /*LORA 信道0 参数1
- [15:08]SignalBw,默认9(500 kHz)
- [07:00]SpreadingFactor7(128)*/
- #define CURSET_LORA_CH0_PARM2 0x003A
- /*LORA 信道0 参数2
- [15:12]ErrorCoding,默认1(4/5)
- [11]CrcOn,默认1(on)
- [10]ImplicitHeaderOn,默认0(显示报头模式)
- [09]RxSingleOn,默认0(持续接收)
- [08]FreqHopOn,默认0
- [07:00]PayloadLength,默认128*/
- #define CURSET_LORA_CH0_PARM3 0x003B
- /*LORA 信道0参数3
- [15:08]TxPacketTimeout
- [07:00]RxPacketTimeout*/
- #define CURSET_LORA_CH0_PARM4 0x003C
- /*LORA 信道1 参数0
- [15]信道0使能,默认1b
- [14:08] Power,功率,默认20=0x14
- [07:00] (Freq/100)[07:00],默认0x68*/
- #define CURSET_LORA_CH1_PARM0 0x003D
- /*LORA 信道1 参数0
- [15:00] (Freq/100)[24:08],默认0x4D68
- [07]信道0使能
- [06:00] Power*/
- #define CURSET_LORA_CH1_PARM1 0x003E
- /*LORA 信道1 参数1
- [15:08]SignalBw,默认9(500 kHz)
- [07:00]SpreadingFactor7(128)*/
- #define CURSET_LORA_CH1_PARM2 0x003F
- /*LORA 信道1 参数2
- [15:12]ErrorCoding,默认1(4/5)
- [11]CrcOn,默认1(on)
- [10]ImplicitHeaderOn,默认0(显示报头模式)
- [09]RxSingleOn,默认0(持续接收)
- [08]FreqHopOn,默认0
- [07:00]PayloadLength,默认128*/
- #define CURSET_LORA_CH1_PARM3 0x0040
- /*LORA 信道1参数3
- [15:08]TxPacketTimeout
- [07:00]RxPacketTimeout*/
- #define CURSET_LORA_CH1_PARM4 0x0041
- /*税控口是否加解密,即英泰赛福模块是否使能*/
- #define CURSET_YTSF_EN 0x0042
- /*税控口轮询间隔*/
- #define CURSET_LOOP_PERIOD 0x0043
- /*税控口0参数
- [15:8] 税控口0有效标记,0为无效,非0有效
- [07] 枪7有效标记
- [06] 枪6有效标记
- [05] 枪5有效标记
- [04] 枪4有效标记
- [03] 枪3有效标记
- [02] 枪2有效标记
- [01] 枪1有效标记
- [00] 枪0有效标记*/
- #define CURSET_SKK_PORT0 0x0044
- /*税控口1参数
- [15:8] 税控口1有效标记,0为无效,非0有效
- [07] 枪7有效标记
- [06] 枪6有效标记
- [05] 枪5有效标记
- [04] 枪4有效标记
- [03] 枪3有效标记
- [02] 枪2有效标记
- [01] 枪1有效标记
- [00] 枪0有效标记*/
- #define CURSET_SKK_PORT1 0x0045
- /*税控口0序列号
- [15:08] SN第1个字节(首字节)ASCII格式
- [07:00] SN第1个字节(首字节)BCD格式*/
- #define CURSET_YTSF_PORT0_SN0 0x0046
- /*税控口0序列号
- [15:08] SN第2个字节BCD格式
- [07:00] SN第3个字节BCD格式*/
- #define CURSET_YTSF_PORT0_SN1 0x0047
- /*税控口0序列号
- [15:08] SN第4个字节BCD格式
- [07:00] SN第5个字节BCD格式*/
- #define CURSET_YTSF_PORT0_SN2 0x0048
- /*税控口1序列号
- [15:08] SN第1个字节(首字节)ASCII格式
- [07:00] SN第1个字节(首字节)BCD格式*/
- #define CURSET_YTSF_PORT1_SN0 0x0049
- /*税控口1序列号
- [15:08] SN第2个字节BCD格式
- [07:00] SN第3个字节BCD格式*/
- #define CURSET_YTSF_PORT1_SN1 0x004A
- /*税控口1序列号
- [15:08] SN第4个字节BCD格式
- [07:00] SN第5个字节BCD格式*/
- #define CURSET_YTSF_PORT1_SN2 0x004B
- /*除此字段以外所有参数做CRC(高16位)*/
- #define CURSET_CRC0 0x004C
- /*除此字段以外所有参数做CRC(低16位)*/
- #define CURSET_CRC1 0x004D
- /* Exported types ------------------------------------------------------------*/
- /* Exported macro ------------------------------------------------------------*/
- /* Exported functions ------------------------------------------------------- */
- uint16_t EE_Init(void);
- uint16_t EE_ReadVariable(uint16_t VirtAddress, uint16_t* Data);
- uint16_t EE_WriteVariable(uint16_t VirtAddress, uint16_t Data);
- uint16_t eeprom_test(void);
- #endif /* __EEPROM_H */
- /******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/
|