- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 similar I2C-Components on my PSOC4 are polling sensors.
The I2C components are named I2C_1, I2C_2, I2C_3, I2C_4.
Today i do something like this:
poll I2C_1;
poll I2C_2;
poll I2C_3;
poll I2C_4;
in detail:
i2cstatus_1 = I2C_1_I2CMasterSendStart(a,0,100);
i2cstatus_2 = I2C_2_I2CMasterSendStart(a,0,100);
i2cstatus_3 = I2C_3_I2CMasterSendStart(a,0,100);
i2cstatus_4 = I2C_4_I2CMasterSendStart(a,0,100);
but i want to do in a loop:
for (componentnumber = 1; componentnumber <= 4; componentnumber ++)
{
i2cstatus_componentnumber = I2C_componentnumber _I2CMasterSendStart(i,0,100);
...
}
How can i put the named component into an indexed access?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Why not passing said "componentnumber" as argument to the I2CMasterSendStart() function, and differenciate there ?
I use to avoid function pointers, because they are a real pain with our test tool.