From 70b082c8c62a0351339a8fce539ba8b0163e62dd Mon Sep 17 00:00:00 2001 From: Benjamin Vedder Date: Fri, 9 Oct 2015 12:27:26 +0200 Subject: [PATCH] Made the code build with the C89 standard and changed to tickless kernel mode --- Makefile | 2 +- bldc_interface.c | 3 ++- chconf.h | 4 ++-- packet.c | 3 ++- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 9bbf844..ac9b796 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ # Compiler options here. ifeq ($(USE_OPT),) - USE_OPT = -O2 -ggdb -fomit-frame-pointer -falign-functions=16 -std=gnu99 + USE_OPT = -O2 -ggdb -fomit-frame-pointer -falign-functions=16 endif # C specific options here (added to USE_OPT). diff --git a/bldc_interface.c b/bldc_interface.c index a20e112..ae5f3f1 100644 --- a/bldc_interface.c +++ b/bldc_interface.c @@ -109,6 +109,7 @@ void bldc_interface_process_packet(unsigned char *data, unsigned int len) { } int32_t ind = 0; + int i = 0; unsigned char id = data[0]; data++; len--; @@ -304,7 +305,7 @@ void bldc_interface_process_packet(unsigned char *data, unsigned int len) { ind = 0; detect_cycle_int_limit = buffer_get_float32(data, 1000.0, &ind); detect_coupling_k = buffer_get_float32(data, 1000.0, &ind); - for (int i = 0;i < 8;i++) { + for (i = 0;i < 8;i++) { detect_hall_table[i] = (const signed char)(data[ind++]); } detect_hall_res = (const signed char)(data[ind++]); diff --git a/chconf.h b/chconf.h index 668d3b2..9711b83 100644 --- a/chconf.h +++ b/chconf.h @@ -59,7 +59,7 @@ * The value one is not valid, timeouts are rounded up to * this value. */ -#define CH_CFG_ST_TIMEDELTA 0 +#define CH_CFG_ST_TIMEDELTA 2 /** @} */ @@ -82,7 +82,7 @@ * @note The round robin preemption is not supported in tickless mode and * must be set to zero in that case. */ -#define CH_CFG_TIME_QUANTUM 4 +#define CH_CFG_TIME_QUANTUM 0 /** * @brief Managed RAM size. diff --git a/packet.c b/packet.c index fb61adf..f4292db 100644 --- a/packet.c +++ b/packet.c @@ -80,7 +80,8 @@ void packet_send_packet(unsigned char *data, unsigned int len, int handler_num) * Call this function every millisecond. */ void packet_timerfunc(void) { - for (int i = 0;i < PACKET_HANDLERS;i++) { + int i = 0; + for (i = 0;i < PACKET_HANDLERS;i++) { if (handler_states[i].rx_timeout) { handler_states[i].rx_timeout--; } else { -- 2.24.1