diff --git a/Makefile b/Makefile index cc9951e..c8c015f 100644 --- a/Makefile +++ b/Makefile @@ -28,12 +28,12 @@ CFLAGS += -MD -MP -MF $(BUILD)/$(*D)/$(*F).d CFLAGS += -Wall #CFLAGS += -Wextra #CFLAGS += -Wcast-align -Wimplicit -Wunused -#CFLAGS += -Wpointer-arith -Wswitch -#CFLAGS += -Wredundant-decls -Wreturn-type -Wshadow -#CFLAGS += -Wbad-function-cast -Wsign-compare -Waggregate-return +CFLAGS += -Wpointer-arith -Wswitch +CFLAGS += -Wredundant-decls -Wreturn-type -Wshadow +CFLAGS += -Wbad-function-cast -Wsign-compare -Waggregate-return #CFLAGS += -Wcast-qual -Wnested-externs -#CFLAGS += -Wmissing-prototypes -#CFLAGS += -Wstrict-prototypes -Wmissing-declarations +#CFLAGS += -Wmissing-prototypes -Wmissing-declarations +CFLAGS += -Wstrict-prototypes LDFLAGS = -nostartfiles -t ldscript.ld -Wl,-Map=$@.map,--cref LDFLAGS += $(patsubst %,-L%,$(LIBDIRS)) diff --git a/src/at91_tc1.c b/src/at91_tc1.c index 7ec5f62..99a2870 100644 --- a/src/at91_tc1.c +++ b/src/at91_tc1.c @@ -50,19 +50,21 @@ struct channel_data { }; static struct channel_data ch_data[MAX_CHANNELS]; -static uint32_t index, count, valid, cal_in_progress; +static uint32_t count, valid, cal_in_progress; static void ppm_isr(void) { + static uint32_t i; + /* RC Compare -> no TIOA1 edge for 2.5ms */ uint32_t status = *AT91C_TC1_SR; if (status & AT91C_TC_CPCS) { /* average channel count */ - count = ((count * 7) + (index << 8)) / 8; + count = ((count * 7) + (i << 8)) / 8; /* at least 4 channels and a stable channel count */ - if ((ROUND_DIV256(count) == index) && (index >= 4)) { + if ((ROUND_DIV256(count) == i) && (i >= 4)) { if (valid < 10) valid++; @@ -71,7 +73,7 @@ static void ppm_isr(void) } /* reset index */ - index = 0; + i = 0; } /* edge on TIOA1 */ @@ -81,19 +83,19 @@ static void ppm_isr(void) /* valid range: 1 - 2ms */ if (width > PULSE_MIN && width < PULSE_MAX) { - if (index < ARRAY_SIZE(ch_data)) { + if (i < ARRAY_SIZE(ch_data)) { /* calc both filters */ - ch_data[index].width = ((ch_data[index].width * (PULSE_FILTER_FAST -1)) + width) / PULSE_FILTER_FAST; - ch_data[index].width_slow = ((ch_data[index].width_slow * (PULSE_FILTER_SLOW -1)) + width) / PULSE_FILTER_SLOW; + ch_data[i].width = ((ch_data[i].width * (PULSE_FILTER_FAST -1)) + width) / PULSE_FILTER_FAST; + ch_data[i].width_slow = ((ch_data[i].width_slow * (PULSE_FILTER_SLOW -1)) + width) / PULSE_FILTER_SLOW; if (cal_in_progress) { /* use slow filter values, calc center */ - ch_data[index].min = MIN(ch_data[index].width_slow, ch_data[index].min); - ch_data[index].max = MAX(ch_data[index].width_slow, ch_data[index].max); - ch_data[index].mid = (ch_data[index].min + ch_data[index].max) / 2; + ch_data[i].min = MIN(ch_data[i].width_slow, ch_data[i].min); + ch_data[i].max = MAX(ch_data[i].width_slow, ch_data[i].max); + ch_data[i].mid = (ch_data[i].min + ch_data[i].max) / 2; } } - index++; + i++; } } } diff --git a/src/stdio/printf.c b/src/stdio/printf.c index 13674d6..1e668f0 100644 --- a/src/stdio/printf.c +++ b/src/stdio/printf.c @@ -29,13 +29,13 @@ int inline putchar(int c) struct snprintf_data { char *bufstart; size_t buflen; - int pos; + size_t pos; }; int snprintf_helper(void *base, const char *buf, size_t len) { struct snprintf_data *data = (struct snprintf_data *)base; - + int count = 0; while (len-- && (data->pos < data->buflen)) data->bufstart[data->pos++] = *buf++; @@ -50,7 +50,7 @@ int snprintf(char *buf, size_t len, const char *fmt, ...) .buflen = len, .pos = 0, }; - + va_list ap; va_start(ap, fmt); int rc = _putf(snprintf_helper, (void *)&data, fmt, ap);