I have “inherited” some code and some method calls don’t make sense to me. The method is of type uint16_t. Sometimes the method is called expecting a return parameter. Sometimes the method is called as if it were void. There is no error generated, the code compiles just fine. Can a method of type uint16_t be called as if it were void? Why wouldn’t this cause an error? Thanks
Main Program--- -- -- -- --- -- -- -- -- -- -- -- -- ---
…
#include <IMU.h>
cIMU IMU;
uint16_t tIMU;
…
tIMU = IMU.update(); //sometimes called as type uint16_t
…
while( IMU.SEN.acc_cali_get_done() == false )
{
IMU.update(); //sometimes called as void ???
}
…
IMU Class file --- ---- --- --- ---- -- --- -- ---
uint16_t cIMU::update( uint32_t priod_us )
{
uint16_t ret_time = 0;
static uint32_t tTime;
if( (micros()-tTime) >= priod_us )
{
ret_time = micros()-tTime;
computeIMU();
gyroData[0] = SEN.gyroData[0];
gyroData[1] = SEN.gyroData[1];
gyroData[2] = SEN.gyroData[2];
}
return ret_time;
}