我试图弄清楚我在做什么错。我将问题归结为几行代码。使用代码时,程序将冻结或行为不正确。 只是想知道我是否为数组正确传递了此信息?
void callFunction(uint8_t &channel)
{
uint8_t address[8]; //1wire wire address and CRC
uint8_t scratchPad[8]; //holding for onewire capture
readScratchPad(address,scratchPad,channel);
}
void Temperature::readScratchPad(uint8_t rom[8],uint8_t data[8],const uint8_t &channel)
{
//read temperature data.
wireReset(); //reset();
selectChannel(channel); //necessary on -800
wireSelect(rom);
wireWriteByte(0xbe); // Read Scratchpad command
//display hex values of scratchpad
for ( int i = 0; i < 8; i++) { // we need 9 bytes
data[i] = wireReadByte();
}
}
唯一可能的另一件事是我像这样错误地传递了指向函数的指针:
function getNext()
{
uint8_t address[8];
getNextAddress(address);
}
bool Temperature::getNextAddress(uint8_t *vAddress)
{
if ( !wireSearch(vAddress))
{
wireResetSearch();
wireReset();
wireSkip();
return false;
}
return true;
}
我将指针传递为getNext(&address [8]),但它也不起作用。 谢谢,