mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-25 13:26:38 +08:00
Refactored debug() and log() in CDev
These functions used vprintf which is not available on all platforms. They also do not enable line and file debug output. Changed to macros that preserve the output format. Uses new macro that can be used to implement per object, runtime selectable logging Signed-off-by: Mark Charlebois <charlebm@gmail.com>
This commit is contained in:
@@ -90,7 +90,7 @@ I2C::set_bus_clock(unsigned bus, unsigned clock_hz)
|
||||
}
|
||||
|
||||
if (_bus_clocks[index] > 0) {
|
||||
// debug("overriding clock of %u with %u Hz\n", _bus_clocks[index], clock_hz);
|
||||
// DEVICE_DEBUG("overriding clock of %u with %u Hz\n", _bus_clocks[index], clock_hz);
|
||||
}
|
||||
_bus_clocks[index] = clock_hz;
|
||||
|
||||
@@ -107,7 +107,7 @@ I2C::init()
|
||||
_dev = up_i2cinitialize(_bus);
|
||||
|
||||
if (_dev == nullptr) {
|
||||
debug("failed to init I2C");
|
||||
DEVICE_DEBUG("failed to init I2C");
|
||||
ret = -ENOENT;
|
||||
goto out;
|
||||
}
|
||||
@@ -121,7 +121,7 @@ I2C::init()
|
||||
if (_bus_clocks[bus_index] > _frequency) {
|
||||
(void)up_i2cuninitialize(_dev);
|
||||
_dev = nullptr;
|
||||
log("FAIL: too slow for bus #%u: %u KHz, device max: %u KHz)",
|
||||
DEVICE_LOG("FAIL: too slow for bus #%u: %u KHz, device max: %u KHz)",
|
||||
_bus, _bus_clocks[bus_index] / 1000, _frequency / 1000);
|
||||
ret = -EINVAL;
|
||||
goto out;
|
||||
@@ -148,7 +148,7 @@ I2C::init()
|
||||
ret = probe();
|
||||
|
||||
if (ret != OK) {
|
||||
debug("probe failed");
|
||||
DEVICE_DEBUG("probe failed");
|
||||
goto out;
|
||||
}
|
||||
|
||||
@@ -156,12 +156,12 @@ I2C::init()
|
||||
ret = CDev::init();
|
||||
|
||||
if (ret != OK) {
|
||||
debug("cdev init failed");
|
||||
DEVICE_DEBUG("cdev init failed");
|
||||
goto out;
|
||||
}
|
||||
|
||||
// tell the world where we are
|
||||
log("on I2C bus %d at 0x%02x (bus: %u KHz, max: %u KHz)",
|
||||
DEVICE_LOG("on I2C bus %d at 0x%02x (bus: %u KHz, max: %u KHz)",
|
||||
_bus, _address, _bus_clocks[bus_index] / 1000, _frequency / 1000);
|
||||
|
||||
out:
|
||||
@@ -188,7 +188,7 @@ I2C::transfer(const uint8_t *send, unsigned send_len, uint8_t *recv, unsigned re
|
||||
unsigned retry_count = 0;
|
||||
|
||||
do {
|
||||
// debug("transfer out %p/%u in %p/%u", send, send_len, recv, recv_len);
|
||||
// DEVICE_DEBUG("transfer out %p/%u in %p/%u", send, send_len, recv, recv_len);
|
||||
|
||||
msgs = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user