python生成xlsx
This commit is contained in:
@@ -0,0 +1,131 @@
|
||||
#ifndef __DRV_AT24CXX_H__
|
||||
#define __DRV_AT24CXX_H__
|
||||
|
||||
|
||||
#include "stm32f1xx_hal.h"
|
||||
#include "i2c.h"
|
||||
|
||||
|
||||
#define x24C256//器件名称,AT24C32、AT24C64、AT24C128、AT24C256、AT24C512
|
||||
|
||||
|
||||
|
||||
#ifdef x24C01
|
||||
#define PAGE_NUM 16 //页数
|
||||
#define PAGE_SIZE 8 //页面大小(字节)
|
||||
#define CAPACITY_SIZE (PAGE_NUM * PAGE_SIZE) //总容量(字节)
|
||||
#define ADDR_BYTE_NUM 1 //地址字节个数
|
||||
#endif
|
||||
|
||||
#ifdef x24C02
|
||||
#define PAGE_NUM 32 //页数
|
||||
#define PAGE_SIZE 8 //页面大小(字节)
|
||||
#define CAPACITY_SIZE (PAGE_NUM * PAGE_SIZE) //总容量(字节)
|
||||
#define ADDR_BYTE_NUM 1 //地址字节个数
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef x24C04
|
||||
#define PAGE_NUM 32 //页数
|
||||
#define PAGE_SIZE 16 //页面大小(字节)
|
||||
#define CAPACITY_SIZE (PAGE_NUM * PAGE_SIZE) //总容量(字节)
|
||||
#define ADDR_BYTE_NUM 1 //地址字节个数
|
||||
#endif
|
||||
|
||||
#ifdef x24C08
|
||||
#define PAGE_NUM 64 //页数
|
||||
#define PAGE_SIZE 16 //页面大小(字节)
|
||||
#define CAPACITY_SIZE (PAGE_NUM * PAGE_SIZE) //总容量(字节)
|
||||
#define ADDR_BYTE_NUM 1 //地址字节个数
|
||||
#endif
|
||||
|
||||
#ifdef x24C16
|
||||
#define PAGE_NUM 128 //页数
|
||||
#define PAGE_SIZE 16 //页面大小(字节)
|
||||
#define CAPACITY_SIZE (PAGE_NUM * PAGE_SIZE) //总容量(字节)
|
||||
#define ADDR_BYTE_NUM 1 //地址字节个数
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef x24C32
|
||||
#define PAGE_NUM 128 //页数
|
||||
#define PAGE_SIZE 32 //页面大小(字节)
|
||||
#define CAPACITY_SIZE (PAGE_NUM * PAGE_SIZE) //总容量(字节)
|
||||
#define ADDR_BYTE_NUM 2 //地址字节个数
|
||||
#endif
|
||||
|
||||
#ifdef x24C64
|
||||
#define PAGE_NUM 256 //页数
|
||||
#define PAGE_SIZE 32 //页面大小(字节)
|
||||
#define CAPACITY_SIZE (PAGE_NUM * PAGE_SIZE) //总容量(字节)
|
||||
#define ADDR_BYTE_NUM 2 //地址字节个数
|
||||
#endif
|
||||
|
||||
#ifdef x24C128
|
||||
#define PAGE_NUM 256 //页数
|
||||
#define PAGE_SIZE 64 //页面大小(字节)
|
||||
#define CAPACITY_SIZE (PAGE_NUM * PAGE_SIZE) //总容量(字节)
|
||||
#define ADDR_BYTE_NUM 2 //地址字节个数
|
||||
#endif
|
||||
|
||||
#ifdef x24C256
|
||||
#define PAGE_NUM 512 //页数
|
||||
#define PAGE_SIZE 64 //页面大小(字节)
|
||||
#define CAPACITY_SIZE (PAGE_NUM * PAGE_SIZE) //总容量(字节)
|
||||
#define ADDR_BYTE_NUM 2 //地址字节个数
|
||||
#endif
|
||||
|
||||
#ifdef x24C512
|
||||
#define PAGE_NUM 512 //页数
|
||||
#define PAGE_SIZE 128 //页面大小(字节)
|
||||
#define CAPACITY_SIZE (PAGE_NUM * PAGE_SIZE) //总容量(字节)
|
||||
#define ADDR_BYTE_NUM 2 //地址字节个数
|
||||
#endif
|
||||
|
||||
|
||||
#define DEV_ADDR 0xA0
|
||||
|
||||
|
||||
|
||||
typedef struct i2c_drv {
|
||||
I2C_HandleTypeDef *hi2c;
|
||||
uint16_t address;
|
||||
uint16_t addr_num;
|
||||
|
||||
uint32_t page_num;
|
||||
uint32_t page_size;
|
||||
uint16_t capacity;
|
||||
|
||||
|
||||
uint16_t delay;
|
||||
}I2C_t;
|
||||
|
||||
extern I2C_t drv_i2c;
|
||||
|
||||
I2C_t* AT24C_Init(I2C_HandleTypeDef *hi2c);
|
||||
|
||||
unsigned char AT24C_Write(uint16_t addr,uint8_t* buff,uint16_t len);
|
||||
|
||||
unsigned char AT24C_Read(uint16_t addr,uint8_t* buff,uint16_t len);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user