s test/main: changed num from int to unsigned

This commit is contained in:
Hauke Petersen 2015-09-17 13:57:35 +02:00
parent 8739a2a319
commit 002985db1d

View File

@ -45,7 +45,7 @@ static void cb(int chan)
fired++; fired++;
} }
static int test_timer(int num) static int test_timer(unsigned num)
{ {
int set = 0; int set = 0;
@ -58,14 +58,14 @@ static int test_timer(int num)
/* initialize and halt timer */ /* initialize and halt timer */
if (timer_init(TIMER_DEV(num), TIM_SPEED, cb) < 0) { if (timer_init(TIMER_DEV(num), TIM_SPEED, cb) < 0) {
printf("TIMER_%i: ERROR on initialization - skipping\n\n", num); printf("TIMER_%u: ERROR on initialization - skipping\n\n", num);
return 0; return 0;
} }
else { else {
printf("TIMER_%i: initialization successful\n", num); printf("TIMER_%u: initialization successful\n", num);
} }
timer_stop(TIMER_DEV(num)); timer_stop(TIMER_DEV(num));
printf("TIMER_%i: stopped\n", num); printf("TIMER_%u: stopped\n", num);
/* set each available channel */ /* set each available channel */
for (unsigned i = 0; i < MAX_CHANNELS; i++) { for (unsigned i = 0; i < MAX_CHANNELS; i++) {
unsigned timeout = ((i + 1) * CHAN_OFFSET); unsigned timeout = ((i + 1) * CHAN_OFFSET);
@ -74,15 +74,15 @@ static int test_timer(int num)
} }
else { else {
++set; ++set;
printf("TIMER_%i: set channel %u to %u\n", num, i, timeout); printf("TIMER_%u: set channel %u to %u\n", num, i, timeout);
} }
} }
if (set == 0) { if (set == 0) {
printf("TIMER_%i: ERROR setting any channel\n\n", num); printf("TIMER_%u: ERROR setting any channel\n\n", num);
return 0; return 0;
} }
/* start the timer */ /* start the timer */
printf("TIMER_%i: starting\n", num); printf("TIMER_%u: starting\n", num);
timer_start(TIMER_DEV(num)); timer_start(TIMER_DEV(num));
/* wait for all channels to fire */ /* wait for all channels to fire */
do { do {
@ -90,7 +90,7 @@ static int test_timer(int num)
} while (fired != set); } while (fired != set);
/* collect results */ /* collect results */
for (int i = 0; i < fired; i++) { for (int i = 0; i < fired; i++) {
printf("TIMER_%i: channel %i fired at SW count %8u", printf("TIMER_%u: channel %i fired at SW count %8u",
num, i, (unsigned)timeouts[i]); num, i, (unsigned)timeouts[i]);
if (i == 0) { if (i == 0) {
printf(" - init: %8u\n", (unsigned)timeouts[i]); printf(" - init: %8u\n", (unsigned)timeouts[i]);