From 8c8732d0517af815a4a19cd26ab73964b3842e93 Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Mon, 5 May 2014 16:15:22 +0400 Subject: [PATCH] Collateral fixes --- libuavcan/include/uavcan/dynamic_memory.hpp | 1 + libuavcan/include/uavcan/util/lazy_constructor.hpp | 1 + libuavcan/src/transport/uc_transfer_buffer.cpp | 1 + libuavcan_drivers/lpc11c24/driver/src/can.cpp | 5 +++-- libuavcan_drivers/lpc11c24/driver/src/clock.cpp | 7 +++++-- libuavcan_drivers/stm32/driver/src/uc_stm32_clock.cpp | 10 ++++++---- 6 files changed, 17 insertions(+), 8 deletions(-) diff --git a/libuavcan/include/uavcan/dynamic_memory.hpp b/libuavcan/include/uavcan/dynamic_memory.hpp index ff0ef2af14..151a6e20dd 100644 --- a/libuavcan/include/uavcan/dynamic_memory.hpp +++ b/libuavcan/include/uavcan/dynamic_memory.hpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include diff --git a/libuavcan/include/uavcan/util/lazy_constructor.hpp b/libuavcan/include/uavcan/util/lazy_constructor.hpp index bea0b4f7ac..c91e83f371 100644 --- a/libuavcan/include/uavcan/util/lazy_constructor.hpp +++ b/libuavcan/include/uavcan/util/lazy_constructor.hpp @@ -5,6 +5,7 @@ #pragma once #include +#include #include #include #include diff --git a/libuavcan/src/transport/uc_transfer_buffer.cpp b/libuavcan/src/transport/uc_transfer_buffer.cpp index ae5d4b8c45..7be655be4a 100644 --- a/libuavcan/src/transport/uc_transfer_buffer.cpp +++ b/libuavcan/src/transport/uc_transfer_buffer.cpp @@ -5,6 +5,7 @@ #include #include #include +#include namespace uavcan { diff --git a/libuavcan_drivers/lpc11c24/driver/src/can.cpp b/libuavcan_drivers/lpc11c24/driver/src/can.cpp index 43f00e77f2..9e655a066a 100644 --- a/libuavcan_drivers/lpc11c24/driver/src/can.cpp +++ b/libuavcan_drivers/lpc11c24/driver/src/can.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include "internal.hpp" @@ -254,7 +255,7 @@ uavcan::int16_t CanDriver::send(const uavcan::CanFrame& frame, uavcan::Monotonic msgobj.mode_id |= CAN_MSGOBJ_RTR; } msgobj.dlc = frame.dlc; - std::copy(frame.data, frame.data + frame.dlc, msgobj.data); + uavcan::copy(frame.data, frame.data + frame.dlc, msgobj.data); /* * Transmission @@ -387,7 +388,7 @@ void canRxCallback(uint8_t msg_obj_num) // Payload frame.dlc = msg_obj.dlc; - std::copy(msg_obj.data, msg_obj.data + msg_obj.dlc, frame.data); + uavcan::copy(msg_obj.data, msg_obj.data + msg_obj.dlc, frame.data); uavcan_lpc11c24::rx_queue.push(frame, uavcan_lpc11c24::last_irq_utc_timestamp); uavcan_lpc11c24::had_activity = true; diff --git a/libuavcan_drivers/lpc11c24/driver/src/clock.cpp b/libuavcan_drivers/lpc11c24/driver/src/clock.cpp index f32215ba4b..7a51d1be0c 100644 --- a/libuavcan_drivers/lpc11c24/driver/src/clock.cpp +++ b/libuavcan_drivers/lpc11c24/driver/src/clock.cpp @@ -3,6 +3,7 @@ */ #include +#include #include #include "internal.hpp" @@ -113,8 +114,10 @@ void adjustUtc(uavcan::UtcDuration adjustment) utc_correction_usec_per_overflow_x16 += adjustment.isPositive() ? 1 : -1; // I utc_correction_usec_per_overflow_x16 += (adj_delta > 0) ? 1 : -1; // P - utc_correction_usec_per_overflow_x16 = std::max(utc_correction_usec_per_overflow_x16, -MaxUtcSpeedCorrectionX16); - utc_correction_usec_per_overflow_x16 = std::min(utc_correction_usec_per_overflow_x16, MaxUtcSpeedCorrectionX16); + utc_correction_usec_per_overflow_x16 = + uavcan::max(utc_correction_usec_per_overflow_x16, -MaxUtcSpeedCorrectionX16); + utc_correction_usec_per_overflow_x16 = + uavcan::min(utc_correction_usec_per_overflow_x16, MaxUtcSpeedCorrectionX16); if (adjustment.getAbs().toMSec() > 9 || !utc_set) { diff --git a/libuavcan_drivers/stm32/driver/src/uc_stm32_clock.cpp b/libuavcan_drivers/stm32/driver/src/uc_stm32_clock.cpp index 2d4b8e5f11..6ab92d5238 100644 --- a/libuavcan_drivers/stm32/driver/src/uc_stm32_clock.cpp +++ b/libuavcan_drivers/stm32/driver/src/uc_stm32_clock.cpp @@ -180,16 +180,18 @@ static void updateRatePID(uavcan::UtcDuration adjustment) else { utc_rel_rate_error_integral += rel_rate_error * dt * utc_sync_params.rate_i; - utc_rel_rate_error_integral = std::max(utc_rel_rate_error_integral, -utc_sync_params.max_rate_correction_ppm); - utc_rel_rate_error_integral = std::min(utc_rel_rate_error_integral, utc_sync_params.max_rate_correction_ppm); + utc_rel_rate_error_integral = + uavcan::max(utc_rel_rate_error_integral, -utc_sync_params.max_rate_correction_ppm); + utc_rel_rate_error_integral = + uavcan::min(utc_rel_rate_error_integral, utc_sync_params.max_rate_correction_ppm); } /* * Rate controller */ float total_rate_correction_ppm = rel_rate_error + utc_rel_rate_error_integral; - total_rate_correction_ppm = std::max(total_rate_correction_ppm, -utc_sync_params.max_rate_correction_ppm); - total_rate_correction_ppm = std::min(total_rate_correction_ppm, utc_sync_params.max_rate_correction_ppm); + total_rate_correction_ppm = uavcan::max(total_rate_correction_ppm, -utc_sync_params.max_rate_correction_ppm); + total_rate_correction_ppm = uavcan::min(total_rate_correction_ppm, utc_sync_params.max_rate_correction_ppm); utc_correction_nsec_per_overflow = (USecPerOverflow * 1000) * (total_rate_correction_ppm / 1e6F);