我有以下几点:有没有一个简单的方法来做这件事呢?当做。
以上来自于百度翻译
以下为原文
I have the following:
typedef enum {cntrl, status, fault, minPower, maxADIN,
powerThreshold} td_i2cRegisters;
unsigned char i2cReadRegister (td_i2cRegisters i2cReg)
{
// stuff
i2cSendCommand( *****); // Want to pass i2cReg (enum)
// stuff
}
void i2cSendCommand (td_i2cRegisters i2cReg)
{
switch(i2cReg)
{
case cntrl: // 0x00 address
I2C1TRN = 0b00000000;
while(I2C1STATbits.TRSTAT);
break;
case powerThreshold: // 0x0e
I2C1TRN = 0x0e;
while(I2C1STATbits.TRSTAT);
break;
default:
break;
}
}
Is there an easy way to do this or am i barking up the wrong tree?
Regards.