cleared some Warnings

This commit is contained in:
Olaf Rempel 2008-02-04 19:19:27 +01:00
parent 7b7c950b72
commit 5d47c871fa
3 changed files with 21 additions and 19 deletions

View File

@ -28,12 +28,12 @@ CFLAGS += -MD -MP -MF $(BUILD)/$(*D)/$(*F).d
CFLAGS += -Wall CFLAGS += -Wall
#CFLAGS += -Wextra #CFLAGS += -Wextra
#CFLAGS += -Wcast-align -Wimplicit -Wunused #CFLAGS += -Wcast-align -Wimplicit -Wunused
#CFLAGS += -Wpointer-arith -Wswitch CFLAGS += -Wpointer-arith -Wswitch
#CFLAGS += -Wredundant-decls -Wreturn-type -Wshadow CFLAGS += -Wredundant-decls -Wreturn-type -Wshadow
#CFLAGS += -Wbad-function-cast -Wsign-compare -Waggregate-return CFLAGS += -Wbad-function-cast -Wsign-compare -Waggregate-return
#CFLAGS += -Wcast-qual -Wnested-externs #CFLAGS += -Wcast-qual -Wnested-externs
#CFLAGS += -Wmissing-prototypes #CFLAGS += -Wmissing-prototypes -Wmissing-declarations
#CFLAGS += -Wstrict-prototypes -Wmissing-declarations CFLAGS += -Wstrict-prototypes
LDFLAGS = -nostartfiles -t ldscript.ld -Wl,-Map=$@.map,--cref LDFLAGS = -nostartfiles -t ldscript.ld -Wl,-Map=$@.map,--cref
LDFLAGS += $(patsubst %,-L%,$(LIBDIRS)) LDFLAGS += $(patsubst %,-L%,$(LIBDIRS))

View File

@ -50,19 +50,21 @@ struct channel_data {
}; };
static struct channel_data ch_data[MAX_CHANNELS]; 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 void ppm_isr(void)
{ {
static uint32_t i;
/* RC Compare -> no TIOA1 edge for 2.5ms */ /* RC Compare -> no TIOA1 edge for 2.5ms */
uint32_t status = *AT91C_TC1_SR; uint32_t status = *AT91C_TC1_SR;
if (status & AT91C_TC_CPCS) { if (status & AT91C_TC_CPCS) {
/* average channel count */ /* average channel count */
count = ((count * 7) + (index << 8)) / 8; count = ((count * 7) + (i << 8)) / 8;
/* at least 4 channels and a stable channel count */ /* 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) if (valid < 10)
valid++; valid++;
@ -71,7 +73,7 @@ static void ppm_isr(void)
} }
/* reset index */ /* reset index */
index = 0; i = 0;
} }
/* edge on TIOA1 */ /* edge on TIOA1 */
@ -81,19 +83,19 @@ static void ppm_isr(void)
/* valid range: 1 - 2ms */ /* valid range: 1 - 2ms */
if (width > PULSE_MIN && width < PULSE_MAX) { if (width > PULSE_MIN && width < PULSE_MAX) {
if (index < ARRAY_SIZE(ch_data)) { if (i < ARRAY_SIZE(ch_data)) {
/* calc both filters */ /* calc both filters */
ch_data[index].width = ((ch_data[index].width * (PULSE_FILTER_FAST -1)) + width) / PULSE_FILTER_FAST; ch_data[i].width = ((ch_data[i].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_slow = ((ch_data[i].width_slow * (PULSE_FILTER_SLOW -1)) + width) / PULSE_FILTER_SLOW;
if (cal_in_progress) { if (cal_in_progress) {
/* use slow filter values, calc center */ /* use slow filter values, calc center */
ch_data[index].min = MIN(ch_data[index].width_slow, ch_data[index].min); ch_data[i].min = MIN(ch_data[i].width_slow, ch_data[i].min);
ch_data[index].max = MAX(ch_data[index].width_slow, ch_data[index].max); ch_data[i].max = MAX(ch_data[i].width_slow, ch_data[i].max);
ch_data[index].mid = (ch_data[index].min + ch_data[index].max) / 2; ch_data[i].mid = (ch_data[i].min + ch_data[i].max) / 2;
} }
} }
index++; i++;
} }
} }
} }

View File

@ -29,13 +29,13 @@ int inline putchar(int c)
struct snprintf_data { struct snprintf_data {
char *bufstart; char *bufstart;
size_t buflen; size_t buflen;
int pos; size_t pos;
}; };
int snprintf_helper(void *base, const char *buf, size_t len) int snprintf_helper(void *base, const char *buf, size_t len)
{ {
struct snprintf_data *data = (struct snprintf_data *)base; struct snprintf_data *data = (struct snprintf_data *)base;
int count = 0; int count = 0;
while (len-- && (data->pos < data->buflen)) while (len-- && (data->pos < data->buflen))
data->bufstart[data->pos++] = *buf++; data->bufstart[data->pos++] = *buf++;
@ -50,7 +50,7 @@ int snprintf(char *buf, size_t len, const char *fmt, ...)
.buflen = len, .buflen = len,
.pos = 0, .pos = 0,
}; };
va_list ap; va_list ap;
va_start(ap, fmt); va_start(ap, fmt);
int rc = _putf(snprintf_helper, (void *)&data, fmt, ap); int rc = _putf(snprintf_helper, (void *)&data, fmt, ap);