手机版

模拟I2C控制24C02(7)

发布时间:2021-06-06   来源:未知    
字号:

使用STM32红牛开发的GPIO模拟I2C控制八个AT24C02的读写

/* Includes ------------------------------------------------------------------*/

#include "i2c_ee.h"

/* Private typedef -----------------------------------------------------------*/

typedef enum {FAILED = 0, PASSED = !FAILED} TestStatus;

/* Private define ------------------------------------------------------------*/

#define EEPROM_WriteAddress1 0xa6

#define EEPROM_ReadAddress1 0xa6

#define BufferSize1 countof(Tx1_Buffer)

/* Private macro -------------------------------------------------------------*/

#define countof(a) (sizeof(a) / sizeof(*(a)))

u8 Tx1_Buffer[] = {

1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,

1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,

1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,

1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,

1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,

1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,

1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,

1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,

1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,

1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,

1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,

1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,

1,2,3,4,5,6,7,8,9,10 //共写入250字节

};

u8 Tx2_Buffer[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};

u8 Rx1_Buffer[BufferSize1];

volatile TestStatus TransferStatus1 = FAILED, TransferStatus2 = FAILED;

ErrorStatus HSEStartUpStatus;

/* Private functions ---------------------------------------------------------*/

void RCC_Configuration(void);

void NVIC_Configuration(void);

TestStatus Buffercmp(u8* pBuffer1, u8* pBuffer2, u16 BufferLength);

int main(void)

{

#ifdef DEBUG

debug();

#endif

模拟I2C控制24C02(7).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
×
二维码
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)