完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
嗨,大家好,
我对PSoC(和PSoC Creator)世界还很陌生:我想把我为STM32 MCU编写的一些库移植到PSoC上,但我对此有点怀疑。 我所写的库是用来与MEMS传感器(温度、压力和湿度)一起使用的,通过I2C与MCU通信。当我为STM32 MCU编写它们时,我希望它们独立于所选择的I2C接口(I2C1、I2C2、I2C3……),以便程序员可以选择。其中使用的I2C。因此,我的代码是这样的: //函数原型-I2CyTyPulff指针 空隙读取温度(I2CyTyPulfF*I2C,传感器结构传感器); 主(空) { 传感器结构; I2CKIIT(I2C1); (1) { 读写温度(I2C1,和MyStor); /做一些事 } } 在PSoC,我能做些类似的事情吗?我现在的问题是,如果我编写一个库,我需要使用一些I2C方法,但是这些方法必须用组件的名称来调用。因此,如果我更改组件的名称,我需要在代码中到处更改它,如下所示: //程序员使用I2C组件命名I2C I2CyMasksEngESTEnter(SLaveX地址,Read); //程序员使用I2C组件命名I2CY1 I2CY1IMASTESTESTESTART(SLaveX地址,Read); 你建议我采取什么样的方法? 先谢谢你, 达维德 以上来自于百度翻译 以下为原文 Hi all, I'm still new to PSoC (and PSoC Creator) world: I would like to port some libraries that I wrote for STM32 MCU to PSoC, but I have some doubts about it. The libraries that I wrote are intended to be used with MEMS sensors (temperature, pressure, and humidity) which communicate with the MCU over I2C. When I wrote them for STM32 MCU, I wanted them to be independent of the I2C interface chosen (I2C1, I2C2, I2C3,..), so that the programmer could choose which I2C to be used. Therefore, my code looked like this: // Function prototype - I2C_TypeDef pointervoid readTemperature(I2C_TypeDef *I2C, SensorStruct sensor);int main(void){ SensorStruct mySensor; I2C_Init(I2C1); while(1) { read_temperature(I2C1,&mySensor); // Do some stuff }} In PSoC, can I do something similar? My problem right now is that, if I write a library, I'll need to use some I2C methods, but these methods have to be called with the name of the component. So if I change the name of the component, I need to change it everywhere in my code, as follows: // Programmer used I2C component naming it I2CI2C_MasterSendStart(SLAVE_ADDRESS, READ);// Programmer used I2C component naming it I2C_1I2C_1_MasterSendStart(SLAVE_ADDRESS, READ); What kind of approach do you suggest me? Thank you in advance, Davide |
|
相关推荐
3个回答
|
|
Davide
PSoC的一种方法是将库封装到自定义组件中。在组件内部,可以有一个I2C的示意图,例如I2CY1和API(库代码)。然后在内部组件API代码中,你可以参考这个I2C唯一的名字,例如:‘$StassNoNo.``I2CY1’。每当组件名被更改时,I2C名称将自动更新。 用于组件创建查看 HTTP://www. CyPress .COM/DooptTys/CaseDeaSeTeSs/PSoC-CaltoCalor组件指南 ODISSEY1 以上来自于百度翻译 以下为原文 Davide, One way to do it with PSoC is to encapsulate your library into a custom component. Inside the component you can have a schematic with stock I2C, named e.g. I2C_1 and API (library code). Then inside component API code you can refer to this I2C unique name like this: `$INSTANCE_NAME`_I2C_1. Whenever the component name is changed, the I2C name will update automatically. For component creation look into http://www.cypress.com/documentation/component-datasheets/psoc-creator-component-author-guide /odissey1 |
|
|
|
nvwuwy 发表于 2018-9-12 11:46 嗨,奥迪西, 谢谢你的回复。我试图在组件原理图中构建一个集成了I2C的自定义组件,但我的怀疑是,这样做,定制组件的股票I2C不能用于其他目的:对吗? 谢谢, 达维德 以上来自于百度翻译 以下为原文 Hi odissey, thank you for your reply. I'm trying to build a custom component integrating a stock I2C in the component schematic, but my doubt is that, doing this, the stock I2C of the custom component cannot be used for other purposes: is it right? Thanks, Davide |
|
|
|
霍威电源 发表于 2018-9-12 11:59 Davide 是的,情况就是这样。一旦组件被合并,它就不再用于其他任务(AFAIK)。 ODISSEY1 以上来自于百度翻译 以下为原文 Davide, Yes this is the case. Once a component is Incorporated it is no longer useful for other tasks (AFAIK). /odissey1 |
|
|
|
只有小组成员才能发言,加入小组>>
752个成员聚集在这个小组
加入小组2071 浏览 1 评论
1827 浏览 1 评论
3642 浏览 1 评论
请问可以直接使用来自FX2LP固件的端点向主机FIFO写入数据吗?
1762 浏览 6 评论
1513 浏览 1 评论
CY8C4025LQI在程序中调用函数,通过示波器观察SCL引脚波形,无法将pin0.4(SCL)下拉是什么原因导致?
511浏览 2评论
CYUSB3065焊接到USB3.0 TYPE-B口的焊接触点就无法使用是什么原因导致的?
362浏览 2评论
CX3连接Camera修改分辨率之后,播放器无法播出camera的画面怎么解决?
410浏览 2评论
357浏览 2评论
使用stm32+cyw43438 wifi驱动whd,WHD驱动固件加载失败的原因?
860浏览 2评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-26 07:53 , Processed in 1.575309 second(s), Total 83, Slave 66 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号