#ifndef __X5045_H__
#define __X5045_H__
//X5045
#define WREN 0x06 //写允许
#define WRDI 0x04 //写禁止
#define RDSR 0x05 //读状态寄存器
#define WRSR 0x01 //写状态寄存器,看门狗和块锁定
#define READ 0x03 //从选定的开始地址单元中读数据 0 0 0 0 A8 0 1 1
#define WRITE 0x02 //向选定的开始地址单元写入数据,1~16字节 0 0 0 0 A8 0 1 0
#define WIP 0x01 //状态寄存器0位,器件忙标志,为1器件忙
#define WEL 0x02 //状态寄存器1位,写允许标志,为1允许
#define BL_DIABLE 0x00 //块锁定位,状态寄存器2、3位,00不保护
#define BL_14 0x04 //块锁定位,状态寄存器2、3位,01保护$180H-$1FFH
#define BL_12 0x08 //块锁定位,状态寄存器2、3位,10保护$100H-$1FFH
#define BL_FULL 0x0C //块锁定位,状态寄存器2、3位,00保护$000H-$1FFH
#define WD_14 0x00 //看门狗控制位,状态寄存器4、5位,00为1.4s
#define WD_06 0x10 //看门狗控制位,状态寄存器4、5位,01为600ms
#define WD_02 0x20 //看门狗控制位,状态寄存器4、5位,10为200ms
#define WD_DISABLE 0x30 //看门狗控制位,状态寄存器4、5位,11禁止
#define RESET_X5045_WATCHDOG() {X5045_CS = 1; X5045_CS = 0; X5045_CS = 1;}
sbit X5045_SCK = P2^5; //25045时钟
sbit X5045_DI = P2^4; //25045输入
sbit X5045_DO = P2^6; //25045输出
sbit X5045_CS = P3^5; //25045片选
extern void x5045_out_byte(unsigned char byte);
extern unsigned char x5045_in_byte();
extern unsigned char x5045_read_register();
extern void x5045_write_register(unsigned char command);
extern void x5045_write_bytes(unsigned char idata * ptr, unsigned char bytes, unsigned char first_address, unsigned char is_upper);
extern void x5045_read_bytes(unsigned char idata * ptr, unsigned char bytes, unsigned char first_address, unsigned char is_upper);
#endif
文章评论(0条评论)
登录后参与讨论