From 1d5f1596fa709ff172886e7472ecf9b5a908fa52 Mon Sep 17 00:00:00 2001 From: David Sidrane Date: Wed, 24 Feb 2016 13:49:35 -1000 Subject: [PATCH 1/5] This is needed to work with the latest upstream nuttx --- libuavcan_drivers/stm32/driver/src/internal.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libuavcan_drivers/stm32/driver/src/internal.hpp b/libuavcan_drivers/stm32/driver/src/internal.hpp index 80e3864b06..eba9a17bb3 100644 --- a/libuavcan_drivers/stm32/driver/src/internal.hpp +++ b/libuavcan_drivers/stm32/driver/src/internal.hpp @@ -109,12 +109,12 @@ struct CriticalSectionLocker const irqstate_t flags_; CriticalSectionLocker() - : flags_(irqsave()) + : flags_(enter_critical_section()) { } ~CriticalSectionLocker() { - irqrestore(flags_); + leave_critical_section(flags_); } }; From 534b8686f1a0bcfd12b7b7de07338b001af1d8be Mon Sep 17 00:00:00 2001 From: David Sidrane Date: Wed, 8 Jun 2016 13:28:45 -1000 Subject: [PATCH 2/5] This is needed to work with the latest upstream nuttx 7.16+ --- libuavcan_drivers/stm32/driver/src/uc_stm32_clock.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libuavcan_drivers/stm32/driver/src/uc_stm32_clock.cpp b/libuavcan_drivers/stm32/driver/src/uc_stm32_clock.cpp index 42a51da079..97762423a6 100644 --- a/libuavcan_drivers/stm32/driver/src/uc_stm32_clock.cpp +++ b/libuavcan_drivers/stm32/driver/src/uc_stm32_clock.cpp @@ -32,7 +32,7 @@ # if UAVCAN_STM32_NUTTX # define TIMX UAVCAN_STM32_GLUE3(STM32_TIM, UAVCAN_STM32_TIMER_NUMBER, _BASE) # define TMR_REG(o) (TIMX + (o)) -# define TIMX_INPUT_CLOCK STM32_TIM27_FREQUENCY +# define TIMX_INPUT_CLOCK UAVCAN_STM32_GLUE3(STM32_APB1_TIM, UAVCAN_STM32_TIMER_NUMBER, _CLKIN) # define TIMX_IRQn UAVCAN_STM32_GLUE2(STM32_IRQ_TIM, UAVCAN_STM32_TIMER_NUMBER) # endif From c1b6451b9c990ef7a5a63718887366ce63e4ed69 Mon Sep 17 00:00:00 2001 From: David Sidrane Date: Mon, 20 Jun 2016 13:25:13 -1000 Subject: [PATCH 3/5] his is needed to work with the latest upstream nuttx 7.16+ Logger changes --- .../stm32/driver/src/internal.hpp | 4 +-- .../stm32/driver/src/uc_stm32_clock.cpp | 2 +- .../stm32/test_stm32f107/src/board/board.cpp | 2 +- .../stm32/test_stm32f107/src/main.cpp | 32 +++++++++---------- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/libuavcan_drivers/stm32/driver/src/internal.hpp b/libuavcan_drivers/stm32/driver/src/internal.hpp index eba9a17bb3..eaf61c78b4 100644 --- a/libuavcan_drivers/stm32/driver/src/internal.hpp +++ b/libuavcan_drivers/stm32/driver/src/internal.hpp @@ -26,10 +26,10 @@ * Debug output */ #ifndef UAVCAN_STM32_LOG -// lowsyslog() crashes the system in this context +// syslog() crashes the system in this context // # if UAVCAN_STM32_NUTTX && CONFIG_ARCH_LOWPUTC # if 0 -# define UAVCAN_STM32_LOG(fmt, ...) lowsyslog("uavcan_stm32: " fmt "\n", ##__VA_ARGS__) +# define UAVCAN_STM32_LOG(fmt, ...) syslog("uavcan_stm32: " fmt "\n", ##__VA_ARGS__) # else # define UAVCAN_STM32_LOG(...) ((void)0) # endif diff --git a/libuavcan_drivers/stm32/driver/src/uc_stm32_clock.cpp b/libuavcan_drivers/stm32/driver/src/uc_stm32_clock.cpp index 97762423a6..80798c70a3 100644 --- a/libuavcan_drivers/stm32/driver/src/uc_stm32_clock.cpp +++ b/libuavcan_drivers/stm32/driver/src/uc_stm32_clock.cpp @@ -329,7 +329,7 @@ static void updateRatePID(uavcan::UtcDuration adjustment) utc_correction_nsec_per_overflow = uavcan::int32_t((USecPerOverflow * 1000) * (total_rate_correction_ppm / 1e6F)); -// lowsyslog("$ adj=%f rel_rate=%f rel_rate_eint=%f tgt_rel_rate=%f ppm=%f\n", +// syslog("$ adj=%f rel_rate=%f rel_rate_eint=%f tgt_rel_rate=%f ppm=%f\n", // adj_usec, utc_rel_rate_ppm, utc_rel_rate_error_integral, target_rel_rate_ppm, // total_rate_correction_ppm); } diff --git a/libuavcan_drivers/stm32/test_stm32f107/src/board/board.cpp b/libuavcan_drivers/stm32/test_stm32f107/src/board/board.cpp index 3f9bdd86ba..03d8c6f80a 100644 --- a/libuavcan_drivers/stm32/test_stm32f107/src/board/board.cpp +++ b/libuavcan_drivers/stm32/test_stm32f107/src/board/board.cpp @@ -37,7 +37,7 @@ void init() __attribute__((noreturn)) void die(int error) { - lowsyslog("Fatal error %i\n", error); + syslog("Fatal error %i\n", error); while (1) { setLed(false); diff --git a/libuavcan_drivers/stm32/test_stm32f107/src/main.cpp b/libuavcan_drivers/stm32/test_stm32f107/src/main.cpp index 5cf2921c9a..218acc124a 100644 --- a/libuavcan_drivers/stm32/test_stm32f107/src/main.cpp +++ b/libuavcan_drivers/stm32/test_stm32f107/src/main.cpp @@ -39,13 +39,13 @@ void init() do { ::sleep(1); - ::lowsyslog("CAN auto bit rate detection...\n"); + ::syslog("CAN auto bit rate detection...\n"); std::uint32_t bitrate = 0; res = can.init([]() { ::usleep(can.getRecommendedListeningDelay().toUSec()); }, bitrate); if (res >= 0) { - ::lowsyslog("CAN inited at %u bps\n", unsigned(bitrate)); + ::syslog("CAN inited at %u bps\n", unsigned(bitrate)); } } while (res < 0); @@ -68,7 +68,7 @@ class : public chibios_rt::BaseStaticThread<8192> getNode().setSoftwareVersion(swver); - lowsyslog("Git commit hash: 0x%08x\n", GIT_HASH); + syslog("Git commit hash: 0x%08x\n", GIT_HASH); /* * Hardware version @@ -82,12 +82,12 @@ class : public chibios_rt::BaseStaticThread<8192> getNode().setHardwareVersion(hwver); - lowsyslog("UDID:"); + syslog("UDID:"); for (auto b : hwver.unique_id) { - lowsyslog(" %02x", unsigned(b)); + syslog(" %02x", unsigned(b)); } - lowsyslog("\n"); + syslog("\n"); } void performDynamicNodeIDAllocation() @@ -100,17 +100,17 @@ class : public chibios_rt::BaseStaticThread<8192> board::die(client_start_res); } - lowsyslog("Waiting for dynamic node ID allocation...\n"); + syslog("Waiting for dynamic node ID allocation...\n"); while (!client.isAllocationComplete()) { const int spin_res = getNode().spin(uavcan::MonotonicDuration::fromMSec(100)); if (spin_res < 0) { - lowsyslog("Spin failure: %i\n", spin_res); + syslog("Spin failure: %i\n", spin_res); } } - lowsyslog("Dynamic node ID %d allocated by %d\n", + syslog("Dynamic node ID %d allocated by %d\n", int(client.getAllocatedNodeID().get()), int(client.getAllocatorNodeID().get())); @@ -154,24 +154,24 @@ public: /* * Main loop */ - lowsyslog("UAVCAN node started\n"); + syslog("UAVCAN node started\n"); getNode().setModeOperational(); while (true) { const int spin_res = getNode().spin(uavcan::MonotonicDuration::fromMSec(5000)); if (spin_res < 0) { - lowsyslog("Spin failure: %i\n", spin_res); + syslog("Spin failure: %i\n", spin_res); } - lowsyslog("Time sync master: %u\n", unsigned(time_sync_slave.getMasterNodeID().get())); + syslog("Time sync master: %u\n", unsigned(time_sync_slave.getMasterNodeID().get())); - lowsyslog("Memory usage: free=%u used=%u worst=%u\n", + syslog("Memory usage: free=%u used=%u worst=%u\n", getNode().getAllocator().getNumFreeBlocks(), getNode().getAllocator().getNumUsedBlocks(), getNode().getAllocator().getPeakNumUsedBlocks()); - lowsyslog("CAN errors: %lu %lu\n", + syslog("CAN errors: %lu %lu\n", static_cast(can.driver.getIface(0)->getErrorCount()), static_cast(can.driver.getIface(1)->getErrorCount())); @@ -194,7 +194,7 @@ int main() { app::init(); - lowsyslog("Starting the UAVCAN thread\n"); + syslog("Starting the UAVCAN thread\n"); app::uavcan_node_thread.start(LOWPRIO); while (true) @@ -206,7 +206,7 @@ int main() } const uavcan::UtcTime utc = uavcan_stm32::clock::getUtc(); - lowsyslog("UTC %lu sec Rate corr: %fPPM Jumps: %lu Locked: %i\n", + syslog("UTC %lu sec Rate corr: %fPPM Jumps: %lu Locked: %i\n", static_cast(utc.toMSec() / 1000), uavcan_stm32::clock::getUtcRateCorrectionPPM(), uavcan_stm32::clock::getUtcJumpCount(), From e031a0e93f723ce2a1eb86b365d6529bb57bb7c2 Mon Sep 17 00:00:00 2001 From: David Sidrane Date: Wed, 22 Jun 2016 11:25:04 -1000 Subject: [PATCH 4/5] Back out upstream changes from test_stm32f107/src/main.cpp --- .../stm32/test_stm32f107/src/main.cpp | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/libuavcan_drivers/stm32/test_stm32f107/src/main.cpp b/libuavcan_drivers/stm32/test_stm32f107/src/main.cpp index 218acc124a..5cf2921c9a 100644 --- a/libuavcan_drivers/stm32/test_stm32f107/src/main.cpp +++ b/libuavcan_drivers/stm32/test_stm32f107/src/main.cpp @@ -39,13 +39,13 @@ void init() do { ::sleep(1); - ::syslog("CAN auto bit rate detection...\n"); + ::lowsyslog("CAN auto bit rate detection...\n"); std::uint32_t bitrate = 0; res = can.init([]() { ::usleep(can.getRecommendedListeningDelay().toUSec()); }, bitrate); if (res >= 0) { - ::syslog("CAN inited at %u bps\n", unsigned(bitrate)); + ::lowsyslog("CAN inited at %u bps\n", unsigned(bitrate)); } } while (res < 0); @@ -68,7 +68,7 @@ class : public chibios_rt::BaseStaticThread<8192> getNode().setSoftwareVersion(swver); - syslog("Git commit hash: 0x%08x\n", GIT_HASH); + lowsyslog("Git commit hash: 0x%08x\n", GIT_HASH); /* * Hardware version @@ -82,12 +82,12 @@ class : public chibios_rt::BaseStaticThread<8192> getNode().setHardwareVersion(hwver); - syslog("UDID:"); + lowsyslog("UDID:"); for (auto b : hwver.unique_id) { - syslog(" %02x", unsigned(b)); + lowsyslog(" %02x", unsigned(b)); } - syslog("\n"); + lowsyslog("\n"); } void performDynamicNodeIDAllocation() @@ -100,17 +100,17 @@ class : public chibios_rt::BaseStaticThread<8192> board::die(client_start_res); } - syslog("Waiting for dynamic node ID allocation...\n"); + lowsyslog("Waiting for dynamic node ID allocation...\n"); while (!client.isAllocationComplete()) { const int spin_res = getNode().spin(uavcan::MonotonicDuration::fromMSec(100)); if (spin_res < 0) { - syslog("Spin failure: %i\n", spin_res); + lowsyslog("Spin failure: %i\n", spin_res); } } - syslog("Dynamic node ID %d allocated by %d\n", + lowsyslog("Dynamic node ID %d allocated by %d\n", int(client.getAllocatedNodeID().get()), int(client.getAllocatorNodeID().get())); @@ -154,24 +154,24 @@ public: /* * Main loop */ - syslog("UAVCAN node started\n"); + lowsyslog("UAVCAN node started\n"); getNode().setModeOperational(); while (true) { const int spin_res = getNode().spin(uavcan::MonotonicDuration::fromMSec(5000)); if (spin_res < 0) { - syslog("Spin failure: %i\n", spin_res); + lowsyslog("Spin failure: %i\n", spin_res); } - syslog("Time sync master: %u\n", unsigned(time_sync_slave.getMasterNodeID().get())); + lowsyslog("Time sync master: %u\n", unsigned(time_sync_slave.getMasterNodeID().get())); - syslog("Memory usage: free=%u used=%u worst=%u\n", + lowsyslog("Memory usage: free=%u used=%u worst=%u\n", getNode().getAllocator().getNumFreeBlocks(), getNode().getAllocator().getNumUsedBlocks(), getNode().getAllocator().getPeakNumUsedBlocks()); - syslog("CAN errors: %lu %lu\n", + lowsyslog("CAN errors: %lu %lu\n", static_cast(can.driver.getIface(0)->getErrorCount()), static_cast(can.driver.getIface(1)->getErrorCount())); @@ -194,7 +194,7 @@ int main() { app::init(); - syslog("Starting the UAVCAN thread\n"); + lowsyslog("Starting the UAVCAN thread\n"); app::uavcan_node_thread.start(LOWPRIO); while (true) @@ -206,7 +206,7 @@ int main() } const uavcan::UtcTime utc = uavcan_stm32::clock::getUtc(); - syslog("UTC %lu sec Rate corr: %fPPM Jumps: %lu Locked: %i\n", + lowsyslog("UTC %lu sec Rate corr: %fPPM Jumps: %lu Locked: %i\n", static_cast(utc.toMSec() / 1000), uavcan_stm32::clock::getUtcRateCorrectionPPM(), uavcan_stm32::clock::getUtcJumpCount(), From ed47da5b2af550fd353680c3a9c03b774d0017fd Mon Sep 17 00:00:00 2001 From: David Sidrane Date: Thu, 12 Jan 2017 06:05:45 -1000 Subject: [PATCH 5/5] Back out upstream changes from test_stm32f107/src/board/board.cpp --- libuavcan_drivers/stm32/test_stm32f107/src/board/board.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libuavcan_drivers/stm32/test_stm32f107/src/board/board.cpp b/libuavcan_drivers/stm32/test_stm32f107/src/board/board.cpp index 03d8c6f80a..3f9bdd86ba 100644 --- a/libuavcan_drivers/stm32/test_stm32f107/src/board/board.cpp +++ b/libuavcan_drivers/stm32/test_stm32f107/src/board/board.cpp @@ -37,7 +37,7 @@ void init() __attribute__((noreturn)) void die(int error) { - syslog("Fatal error %i\n", error); + lowsyslog("Fatal error %i\n", error); while (1) { setLed(false);