xiaojiefan / at24cxx Goto Github PK
View Code? Open in Web Editor NEWEEPROM AT24CXX driver library
Home Page: https://github.com/XiaojieFan/at24cxx
License: Apache License 2.0
EEPROM AT24CXX driver library
Home Page: https://github.com/XiaojieFan/at24cxx
License: Apache License 2.0
@cw339004111 小伙伴你好,我发现你 fork 了原作者仓库,并且修改了 rt-thread 软件包的索引仓库到新的地址。首先感谢你贡献代码,现在有一个问题是,rt-thread packages 机制不支持一个软件包的不同发布版本存放在不同的仓库中,最好是能重新提交一个软件包,保留作者原来的 licence 就行啦,下图所示的方式会导致 rt-thread 的软件包同步出现错误。
另外一个问题是,如果有发布版本,一定要进行 release,否则可能找不到下载链接。
at24cxx_device_t at24cxx_init(const char *i2c_bus_name) 这个函数参数是一个,源码的这个函数是两个参数,文档不更新?
在测试发现AT24C02无法正常写入EEPROM,只能正确写入几个不连续的字节,查看代码发现在写入成功的时候没有延时如下所示
rt_err_t at24cxx_write(at24cxx_device_t dev, uint32_t WriteAddr, uint8_t *pBuffer, uint16_t NumToWrite)
{
uint16_t i = 0;
rt_err_t result;
RT_ASSERT(dev);
if(WriteAddr + NumToWrite > AT24CXX_MAX_MEM_ADDRESS)
{
return RT_ERROR;
}
result = rt_mutex_take(dev->lock, RT_WAITING_FOREVER);
if (result == RT_EOK)
{
while (1) //NumToWrite--
{
if (at24cxx_write_one_byte(dev, WriteAddr, pBuffer[i]) != RT_EOK)
{
rt_thread_mdelay(EE_TWR);
}
else
{
WriteAddr++;
i++;
}
if (i == NumToWrite)
{
break;
}
}
}
else
{
LOG_E("The at24cxx could not respond at this time. Please try again");
}
rt_mutex_release(dev->lock);
return RT_EOK;
}
将这个函数改成下面即可成功写入
rt_err_t at24cxx_write(at24cxx_device_t dev, uint32_t WriteAddr, uint8_t *pBuffer, uint16_t NumToWrite)
{
uint16_t i = 0;
rt_err_t result;
RT_ASSERT(dev);
if(WriteAddr + NumToWrite > AT24CXX_MAX_MEM_ADDRESS)
{
return RT_ERROR;
}
result = rt_mutex_take(dev->lock, RT_WAITING_FOREVER);
if (result == RT_EOK)
{
while (1) //NumToWrite--
{
if (at24cxx_write_one_byte(dev, WriteAddr, pBuffer[i]) == RT_EOK)
{
WriteAddr++;
}
if (++i == NumToWrite)
{
break;
}
rt_thread_mdelay(EE_TWR);
}
}
else
{
LOG_E("The at24cxx could not respond at this time. Please try again");
}
rt_mutex_release(dev->lock);
return RT_EOK;
}
似乎不支持 at24c16 以上的
There is a EE_TYPE define in file "at24cxx.h". How to use it?
at24cxx_write函数有两个问题:1.rt_err_t at24cxx_write(at24cxx_device_t dev, uint16_t WriteAddr, uint8_t *pBuffer, uint16_t NumToWrite),NumToWrite是16位,uint8_t i = 0;i是8位,超过255个数据是无法写入的,应该改为uint16_t i = 0才匹配
2. if (WriteAddr == NumToWrite)
{
break;
}
对于从0地址开始写入没问题,非0地址写入,会多写入错误地址,应该改为
if (i == NumToWrite)
{
break;
}
你好,我是一个RTT的新手,在学习您的代码,对RTT也不太熟悉。
能不能添加一个完整点的具体的例子来表现 这个包如何调用啊。
不是做伸手党,而是希望这个包可以让更多的人易于上手。
建议增加页写算法,单个字节写入效率太低了
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.