summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2022-06-05 15:18:37 +0200
committerlonkaars <loek@pipeframe.xyz>2022-06-05 15:18:37 +0200
commit1f8a640303976ddcc3605a9b6af8fb398dc7c300 (patch)
tree0b94783ee69909c46e7272a8160ee441ea7cb0cf
parent8b2d83a74c7d23b8c745aa147836c257ded110a7 (diff)
`make format`
-rw-r--r--robot/errcatch.c13
-rw-r--r--robot/hypervisor.c8
-rw-r--r--robot/hypervisor.h1
-rw-r--r--robot/mode_dirc.c17
-rw-r--r--robot/sercomm.c20
5 files changed, 31 insertions, 28 deletions
diff --git a/robot/errcatch.c b/robot/errcatch.c
index 77fcfd3..17c96fa 100644
--- a/robot/errcatch.c
+++ b/robot/errcatch.c
@@ -20,17 +20,20 @@ void w2_errcatch_handle_error(w2_s_error *error) {
g_w2_error_uncaught = true;
#ifdef W2_SIM
simwarn("Uncaught/unhandled error found with code 0x%02x", error->code);
- if (error->message_length > 0) fprintf(stderr, " and message \"%.*s\"", error->message_length, error->message);
+ if (error->message_length > 0)
+ fprintf(stderr, " and message \"%.*s\"", error->message_length, error->message);
fprintf(stderr, "\n");
#endif
}
}
// forward error to sercomm
- W2_CREATE_MSG_SIZE_BIN(w2_s_cmd_expt_tx, sizeof(w2_s_cmd_expt_tx) + sizeof(uint8_t) * error->message_length, msg, msg_bin);
- msg->opcode = W2_CMD_EXPT | W2_CMDDIR_TX;
- msg->error = error->code;
- msg->length = error->message_length;
+ W2_CREATE_MSG_SIZE_BIN(w2_s_cmd_expt_tx,
+ sizeof(w2_s_cmd_expt_tx) + sizeof(uint8_t) * error->message_length, msg,
+ msg_bin);
+ msg->opcode = W2_CMD_EXPT | W2_CMDDIR_TX;
+ msg->error = error->code;
+ msg->length = error->message_length;
memcpy(msg->message, error->message, error->message_length);
w2_sercomm_append_msg(msg_bin);
diff --git a/robot/hypervisor.c b/robot/hypervisor.c
index efdceec..2a6120b 100644
--- a/robot/hypervisor.c
+++ b/robot/hypervisor.c
@@ -15,10 +15,10 @@ unsigned long g_w2_hypervisor_ema_mode_ms = 0;
uint64_t g_w2_hypervisor_timers[W2_HYPERVISOR_TIMER_COUNT] = {0};
unsigned int g_w2_ping_ms = 0;
-uint8_t g_w2_ping_id = 0;
-bool g_w2_ping_received = true;
-bool g_w2_ping_timeout = false;
-bool g_w2_connected = false;
+uint8_t g_w2_ping_id = 0;
+bool g_w2_ping_received = true;
+bool g_w2_ping_timeout = false;
+bool g_w2_connected = false;
void w2_hypervisor_main() {
#ifdef W2_SIM
diff --git a/robot/hypervisor.h b/robot/hypervisor.h
index 59398c6..4b1ed9b 100644
--- a/robot/hypervisor.h
+++ b/robot/hypervisor.h
@@ -36,4 +36,3 @@ void w2_hypervisor_main();
void w2_hypervisor_time_start(uint8_t label);
/** stop timer with label `label` */
uint64_t w2_hypervisor_time_end(uint8_t label);
-
diff --git a/robot/mode_dirc.c b/robot/mode_dirc.c
index b7df974..7021721 100644
--- a/robot/mode_dirc.c
+++ b/robot/mode_dirc.c
@@ -1,22 +1,25 @@
#include "mode_dirc.h"
-#include "io.h"
+#include "../shared/util.h"
#include "hypervisor.h"
+#include "io.h"
#include "modes.h"
-#include "../shared/util.h"
#include "orangutan_shim.h"
-#include <string.h>
#include "../shared/errcatch.h"
+#include <string.h>
int16_t g_w2_mode_dirc_motor_l = 0;
int16_t g_w2_mode_dirc_motor_r = 0;
-uint8_t g_w2_mode_dirc_power = 100;
+uint8_t g_w2_mode_dirc_power = 100;
void w2_mode_dirc() {
- if (g_w2_connected == 1) g_w2_mode_dirc_power = 100;
- else g_w2_mode_dirc_power = W2_MAX(0, g_w2_mode_dirc_power - 1);
+ if (g_w2_connected == 1)
+ g_w2_mode_dirc_power = 100;
+ else
+ g_w2_mode_dirc_power = W2_MAX(0, g_w2_mode_dirc_power - 1);
if (g_w2_mode_dirc_power == 0) w2_modes_call(W2_M_HALT);
- set_motors(g_w2_mode_dirc_motor_l * g_w2_mode_dirc_power / 100, g_w2_mode_dirc_motor_r * g_w2_mode_dirc_power / 100);
+ set_motors(g_w2_mode_dirc_motor_l * g_w2_mode_dirc_power / 100,
+ g_w2_mode_dirc_motor_r * g_w2_mode_dirc_power / 100);
}
diff --git a/robot/sercomm.c b/robot/sercomm.c
index f14832a..c50dd15 100644
--- a/robot/sercomm.c
+++ b/robot/sercomm.c
@@ -34,14 +34,15 @@ void w2_sercomm_main() {
// check time-out
if (!g_w2_ping_received && w2_hypervisor_time_end(W2_TIMER_PING) > W2_PING_TIMEOUT) {
g_w2_ping_timeout = true;
- g_w2_connected = false;
+ g_w2_connected = false;
w2_errcatch_throw(W2_E_WARN_PING_TIMEOUT);
}
// send ping every W2_TIMER_PING ms
- if ((g_w2_ping_received && w2_hypervisor_time_end(W2_TIMER_PING) > W2_PING_FREQUENCY) || g_w2_ping_timeout) {
- g_w2_ping_timeout = false;
+ if ((g_w2_ping_received && w2_hypervisor_time_end(W2_TIMER_PING) > W2_PING_FREQUENCY) ||
+ g_w2_ping_timeout) {
+ g_w2_ping_timeout = false;
g_w2_ping_received = false;
- g_w2_ping_id = (uint8_t) rand();
+ g_w2_ping_id = (uint8_t)rand();
W2_CREATE_MSG_BIN(w2_s_cmd_ping_tx, msg, bin);
msg->opcode = W2_CMD_PING | W2_CMDDIR_TX;
@@ -87,17 +88,14 @@ void w2_sercomm_append_msg(w2_s_bin *data) {
#include <stdlib.h>
#include <string.h>
-
void w2_cmd_ping_tx(w2_s_bin *data) {
- g_w2_ping_ms = w2_hypervisor_time_end(W2_TIMER_PING);
+ g_w2_ping_ms = w2_hypervisor_time_end(W2_TIMER_PING);
g_w2_ping_received = true;
- g_w2_ping_timeout = false;
- g_w2_connected = true;
+ g_w2_ping_timeout = false;
+ g_w2_connected = true;
}
-void w2_cmd_ping_rx(w2_s_bin *data) {
- w2_sercomm_append_msg(data);
-}
+void w2_cmd_ping_rx(w2_s_bin *data) { w2_sercomm_append_msg(data); }
void w2_cmd_mode_rx(w2_s_bin *data) {
W2_CAST_BIN(w2_s_cmd_mode_rx, data, req);