Hello Everyone,
I’ve recently purchased the Sparkfun Artemis ATP (DEV-15442) along with the LIDAR Lite v3HP (SEN-14599).
Upon compiling, I get the following error log:
C:\Users\Me\Documents\Arduino\libraries\LIDARLite_Arduino_Library\src\LIDARLite_v4LED.cpp: In member function 'void LIDARLite_v4LED::read(uint8_t, uint8_t*, uint8_t, uint8_t)':
C:\Users\Me\Documents\Arduino\libraries\LIDARLite_Arduino_Library\src\LIDARLite_v4LED.cpp:374:5: error: no matching function for call to 'TwoWire::requestFrom(uint8_t&, uint8_t&, uint8_t&, int, bool)'
);
^
In file included from C:\Users\Me\Documents\Arduino\libraries\LIDARLite_Arduino_Library\src\LIDARLite_v4LED.cpp:27:
C:\Users\Me\AppData\Local\Arduino15\packages\SparkFun\hardware\apollo3\1.2.1\libraries\Wire\src/Wire.h:51:11: note: candidate: 'uint8_t TwoWire::requestFrom(uint8_t, size_t, bool)'
uint8_t requestFrom(uint8_t address, size_t quantity, bool stopBit = true);
^~~~~~~~~~~
C:\Users\Me\AppData\Local\Arduino15\packages\SparkFun\hardware\apollo3\1.2.1\libraries\Wire\src/Wire.h:51:11: note: candidate expects 3 arguments, 5 provided
C:\Users\Me\Documents\Arduino\libraries\LIDARLite_Arduino_Library\src\LIDARLite_v3HP.cpp: In member function 'void LIDARLite_v3HP::read(uint8_t, uint8_t*, uint8_t, uint8_t)':
C:\Users\Me\Documents\Arduino\libraries\LIDARLite_Arduino_Library\src\LIDARLite_v3HP.cpp:400:5: error: no matching function for call to 'TwoWire::requestFrom(uint8_t&, uint8_t&, uint8_t&, int, bool)'
);
^
In file included from C:\Users\Me\Documents\Arduino\libraries\LIDARLite_Arduino_Library\src\LIDARLite_v3HP.cpp:27:
C:\Users\Me\AppData\Local\Arduino15\packages\SparkFun\hardware\apollo3\1.2.1\libraries\Wire\src/Wire.h:51:11: note: candidate: 'uint8_t TwoWire::requestFrom(uint8_t, size_t, bool)'
uint8_t requestFrom(uint8_t address, size_t quantity, bool stopBit = true);
^~~~~~~~~~~
C:\Users\Me\AppData\Local\Arduino15\packages\SparkFun\hardware\apollo3\1.2.1\libraries\Wire\src/Wire.h:51:11: note: candidate expects 3 arguments, 5 provided
exit status 1
Error compiling for board SparkFun RedBoard Artemis ATP.
Which boils down to the fact that the Sparkfun Artemis Wire library does not implement an overload function of requestFrom that accepts these inputs:
Excerpt from Arduino Wire.cpp
uint8_t TwoWire::requestFrom(uint8_t address, uint8_t quantity, uint32_t iaddress, uint8_t isize, uint8_t sendStop)
{
if (isize > 0) {
// send internal address; this mode allows sending a repeated start to access
// some devices' internal registers. This function is executed by the hardware
// TWI module on other processors (for example Due's TWI_IADR and TWI_MMR registers)
beginTransmission(address);
// the maximum size of internal address is 3 bytes
if (isize > 3){
isize = 3;
}
// write internal register address - most significant byte first
while (isize-- > 0)
write((uint8_t)(iaddress >> (isize*8)));
endTransmission(false);
}
// clamp to buffer length
if(quantity > BUFFER_LENGTH){
quantity = BUFFER_LENGTH;
}
// perform blocking read into buffer
uint8_t read = twi_readFrom(address, rxBuffer, quantity, sendStop);
// set rx buffer iterator vars
rxBufferIndex = 0;
rxBufferLength = read;
return read;
}
uint8_t TwoWire::requestFrom(uint8_t address, uint8_t quantity, uint8_t sendStop) {
return requestFrom((uint8_t)address, (uint8_t)quantity, (uint32_t)0, (uint8_t)0, (uint8_t)sendStop);
}
uint8_t TwoWire::requestFrom(uint8_t address, uint8_t quantity)
{
return requestFrom((uint8_t)address, (uint8_t)quantity, (uint8_t)true);
}
uint8_t TwoWire::requestFrom(int address, int quantity)
{
return requestFrom((uint8_t)address, (uint8_t)quantity, (uint8_t)true);
}
uint8_t TwoWire::requestFrom(int address, int quantity, int sendStop)
{
return requestFrom((uint8_t)address, (uint8_t)quantity, (uint8_t)sendStop);
}
Excerpt from Artemis Wire.cpp library:
uint8_t TwoWire::requestFrom(uint8_t address, size_t quantity, bool stopBit)
{
if (quantity == 0)
{
return 0;
}
size_t byteRead = 0;
_rxBuffer.clear();
am_hal_iom_transfer_t iomTransfer = {0};
iomTransfer.uPeerInfo.ui32I2CDevAddr = address;
iomTransfer.ui32InstrLen = 0; // 8-bit transfers
iomTransfer.ui32Instr = 0; // Offset;
iomTransfer.ui32NumBytes = quantity; // How many bytes to receive
iomTransfer.eDirection = AM_HAL_IOM_RX;
iomTransfer.pui32TxBuffer = NULL;
iomTransfer.pui32RxBuffer = (uint32_t *)_linearBugger; // Link in the RX buffer
iomTransfer.bContinue = stopBit ? false : true;
iomTransfer.ui8RepeatCount = 0; // ?
iomTransfer.ui8Priority = 1; // ?
iomTransfer.ui32PauseCondition = 0; // ?
iomTransfer.ui32StatusSetClr = 0; // ?
uint32_t retVal32 = am_hal_iom_blocking_transfer(_handle, &iomTransfer);
if (retVal32 != 0)
{
// Serial.println("got an error on requestFrom");
return retVal32;
}
// Copy the bytes into the rx buffer
for (byteRead = 0; byteRead < quantity; byteRead++)
{
_rxBuffer.store_char(_linearBugger[byteRead]); // Read data and send the ACK
}
return byteRead;
}
How can I edit the library/code to accommodate this incompatibility?
Thanks
Moath