aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Buesch <m@bues.ch>2018-07-29 17:39:28 +0200
committerMichael Buesch <m@bues.ch>2018-07-29 17:39:28 +0200
commitce5c5296d6197468c813d82f3160c081b5ab09be (patch)
treee7b1e938ee87a94bf9563ebc1550b7b5d2ed32bb
parentadb2700b03c7a68bb4e1994c2df904008a65a983 (diff)
downloadxytronic-lf-ce5c5296d6197468c813d82f3160c081b5ab09be.tar.xz
xytronic-lf-ce5c5296d6197468c813d82f3160c081b5ab09be.zip
Add debug helper for fixpt_t
Signed-off-by: Michael Buesch <m@bues.ch>
-rw-r--r--firmware/controller_current.c11
-rw-r--r--firmware/controller_temp.c12
-rw-r--r--firmware/debug_uart.c15
-rw-r--r--firmware/debug_uart.h17
4 files changed, 41 insertions, 14 deletions
diff --git a/firmware/controller_current.c b/firmware/controller_current.c
index b0e40a6..47de396 100644
--- a/firmware/controller_current.c
+++ b/firmware/controller_current.c
@@ -134,8 +134,7 @@ static void contrcurr_run(fixpt_t real_r)
debug_report_int8(PSTR("rs"), &contrcurr.old_r_state,
(int8_t)contrcurr.r_state);
- debug_report_int24(PSTR("cr2"), &contrcurr.old_current_used_feedback,
- (int24_t)r);
+ debug_report_fixpt(PSTR("cr2"), &contrcurr.old_current_used_feedback, r);
/* Run the PID controller */
y = pid_run(&contrcurr.pid, dt, r);
@@ -147,8 +146,7 @@ static void contrcurr_run(fixpt_t real_r)
y = float_to_fixpt(CONTRCURR_RESTRICT_MAXCURR);
}
- debug_report_int24(PSTR("cy"), &contrcurr.old_current_control,
- (int24_t)y);
+ debug_report_fixpt(PSTR("cy"), &contrcurr.old_current_control, y);
/* Reconfigure the PWM unit to output the
* requested heater current (y). */
@@ -160,9 +158,8 @@ void contrcurr_set_feedback(fixpt_t r)
{
if (r != contrcurr.feedback) {
contrcurr.feedback = r;
- debug_report_int24(PSTR("cr1"),
- &contrcurr.old_current_real_feedback,
- (int24_t)r);
+ debug_report_fixpt(PSTR("cr1"),
+ &contrcurr.old_current_real_feedback, r);
}
/* Run the controller. */
diff --git a/firmware/controller_temp.c b/firmware/controller_temp.c
index 5651847..4540229 100644
--- a/firmware/controller_temp.c
+++ b/firmware/controller_temp.c
@@ -135,8 +135,7 @@ static void contrtemp_run(fixpt_t r)
/* Run the PID controller */
y = pid_run(&contrtemp.pid, dt, r);
- debug_report_int24(PSTR("ty1"), &contrtemp.old_temp_control1,
- (int24_t)y);
+ debug_report_fixpt(PSTR("ty1"), &contrtemp.old_temp_control1, y);
/* Map the requested temperature to a heater current. */
y_current = temp_to_amps(y);
@@ -155,8 +154,8 @@ static void contrtemp_run(fixpt_t r)
}
contrcurr_set_emerg(emergency_flags);
- debug_report_int24(PSTR("ty2"), &contrtemp.old_temp_control2,
- (int24_t)y_current);
+ debug_report_fixpt(PSTR("ty2"), &contrtemp.old_temp_control2,
+ y_current);
/* Set the current controller setpoint to the requested current. */
contrcurr_set_setpoint(y_current);
@@ -166,9 +165,8 @@ void contrtemp_set_feedback(fixpt_t r)
{
if (r != contrtemp.feedback) {
contrtemp.feedback = r;
- debug_report_int24(PSTR("tr"),
- &contrtemp.old_temp_feedback,
- (int24_t)r);
+ debug_report_fixpt(PSTR("tr"),
+ &contrtemp.old_temp_feedback, r);
menu_request_display_update();
}
diff --git a/firmware/debug_uart.c b/firmware/debug_uart.c
index 9b6880c..82e2eeb 100644
--- a/firmware/debug_uart.c
+++ b/firmware/debug_uart.c
@@ -129,6 +129,11 @@ void debug_print_int8(const char __flash *prefix, int8_t value)
debug_print_int32(prefix, value);
}
+void debug_print_fixpt(const char __flash *prefix, fixpt_t value)
+{
+ debug_print_int32(prefix, value);
+}
+
void debug_report_int32(const char __flash *prefix,
int32_t *old_value,
int32_t new_value)
@@ -169,6 +174,16 @@ void debug_report_int8(const char __flash *prefix,
}
}
+void debug_report_fixpt(const char __flash *prefix,
+ fixpt_t *old_value,
+ fixpt_t new_value)
+{
+ if (*old_value != new_value) {
+ *old_value = new_value;
+ debug_print_fixpt(prefix, new_value);
+ }
+}
+
void debug_enable(bool enable)
{
bool display_en;
diff --git a/firmware/debug_uart.h b/firmware/debug_uart.h
index b71379e..f792ec0 100644
--- a/firmware/debug_uart.h
+++ b/firmware/debug_uart.h
@@ -2,6 +2,7 @@
#define DEBUG_UART_H_
#include "util.h"
+#include "fixpt.h"
#include <stdint.h>
@@ -13,6 +14,7 @@ void debug_print_int32(const char __flash *prefix, int32_t value);
void debug_print_int24(const char __flash *prefix, int24_t value);
void debug_print_int16(const char __flash *prefix, int16_t value);
void debug_print_int8(const char __flash *prefix, int8_t value);
+void debug_print_fixpt(const char __flash *prefix, fixpt_t value);
void debug_report_int32(const char __flash *prefix,
int32_t *old_value,
@@ -26,6 +28,9 @@ void debug_report_int16(const char __flash *prefix,
void debug_report_int8(const char __flash *prefix,
int8_t *old_value,
int8_t new_value);
+void debug_report_fixpt(const char __flash *prefix,
+ fixpt_t *old_value,
+ fixpt_t new_value);
void debug_enable(bool enable);
bool debug_is_enabled(void);
@@ -57,6 +62,11 @@ void debug_print_int8(const char __flash *prefix, int8_t value)
}
static inline
+void debug_print_fixpt(const char __flash *prefix, fixpt_t value)
+{
+}
+
+static inline
void debug_report_int32(const char __flash *prefix,
int32_t *old_value,
int32_t new_value)
@@ -85,6 +95,13 @@ void debug_report_int8(const char __flash *prefix,
}
static inline
+void debug_report_fixpt(const char __flash *prefix,
+ fixpt_t *old_value,
+ fixpt_t new_value)
+{
+}
+
+static inline
void debug_enable(bool enable)
{
}
bues.ch cgit interface