int init(DelayCallable delay_callable, uavcan::uint32_t& inout_bitrate = BitRateAutoDetect) { if (inout_bitrate > 0) { return driver.init(inout_bitrate, CanIface::NormalMode); } else { static const uavcan::uint32_t StandardBitRates[] = { 1000000, 500000, 250000, 125000 }; for (uavcan::uint8_t br = 0; br < sizeof(StandardBitRates) / sizeof(StandardBitRates[0]); br++) { inout_bitrate = StandardBitRates[br]; const int res = driver.init(inout_bitrate, CanIface::SilentMode); delay_callable(); if (res >= 0) { for (uavcan::uint8_t iface = 0; iface < driver.getNumIfaces(); iface++) { if (!driver.getIface(iface)->isRxBufferEmpty()) { // Re-initializing in normal mode return driver.init(inout_bitrate, CanIface::NormalMode); } } } } return -ErrBitRateNotDetected; } }
/** * This overload simply configures the provided bitrate. * Auto bit rate detection will not be performed. * Bitrate value must be positive. * @return Negative value on error; non-negative on success. Refer to constants Err*. */ int init(uavcan::uint32_t bitrate) { return driver.init(bitrate, CanIface::NormalMode); }
int init(const uavcan::uint32_t bitrate, const CanIface::OperatingMode mode, uavcan::uint8_t can_number) { return driver.init(bitrate, mode, can_number); }
int init(uavcan::uint32_t bitrate) { return driver.init(bitrate); }