Controlling multiple bidirectional pins through function parameter

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

I am working with DHT11 temperature/humidity sensors and have one working like a charm. It uses a one-wire interface, so I need to both read and write the data pin. At the moment I have a function written that calls the pin name directly, but I'm trying to extend this to be able to handle four sensors. Since I have multiple reads/writes within the function I don't want to do an if/else or switch every time I need to access the pin. THe problem is that I don't know how to go about making the function generic so I can pass in the sensor number and have it work only with the correct pin. I looked at the aliases available for pin names, but I can't figure out how (or if it's even possible) to use a function parameter to indicate the correct alias to use with the CyPins_setpin(<alias>) function(s). I also looked at the Mux/Demux, but they are unidirectional so I don't think they'll work. 

   

I don't feel like this post is very clear, but I'm having a difficult time coming up with better phrasing. I've attached a rough idea of what I'm trying to accomplish which will, hopefully, clarify things. 

   

Any guidance on the correct way to approach this would be great. 

   

Regards,

   

Matthew

0 Likes
3 Replies
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

This device has no address selection.  The way I would do this is use a tri-state bus and have a selection control for the devices.

0 Likes
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted
        Matthew, a way ago I made a component to read 1-wire temperature sensor DS18B20, what can handle up to 8 sensors simultaneously http://www.cypress.com/forum/psoc-community-components/component-read-ds18b20-digital-temperature-se... Take a look, maybe you can find something useful for your application. I believe that in your post you describing access to pins using a "pointer to a function" approach. In this case parameters passed to a function will be a pin name. I have no example for that, but I believe I has been discussed in the forums.   
0 Likes
EvPa_264126
Level 7
Level 7
500 replies posted 250 replies posted 100 likes received

Maybe so?

   

0 Likes