Make Arduino timer stuff work on Contiki

New discovery: Contiki also uses timer 0. With almost the same interface
as Arduino. So we now completely get rid of wiring.c (only the main
file, the other wiring_xxx stay) and implement Arduino timer, delay, etc
in terms of the corresponding Contiki routines. Verified that now delay
works as expected. The LED in examples/osd/arduino-sketch blinks!

Before this, the arduino_init routine in wiring.c destroyed the timer-0
initialization of contiki, making both, contiki timer implementation
*and* contiki timer implementation fail if the arduino_init routine was
called. Now both work.

Squashed with following bug-fix commit.
This commit is contained in:
Ralf Schlatterbeck 2014-06-26 18:37:13 +02:00
parent 08abd8807d
commit c46d6afa39
7 changed files with 61 additions and 273 deletions

View file

@ -62,6 +62,7 @@ led_pwm_handler
const uint16_t *accept = NULL;
uint16_t a_ctype = REST.type.APPLICATION_JSON;
uint16_t c_ctype = REST.get_header_content_type (request);
uint32_t tmp = 0;
/* Seems like accepted type is currently unsupported? */
n_acc = REST.get_header_accept (request, &accept);
@ -136,7 +137,11 @@ led_pwm_handler
temp [sizeof (temp) - 1] = 0;
}
PRINTF ("GOT: %s\n", temp);
pwm = atoi (temp);
tmp = strtoul (temp, NULL, 10);
if (tmp > 255) {
tmp = 255;
}
pwm = tmp;
PRINTF ("Setting: %d\n", pwm);
REST.set_response_status(response, REST.status.CHANGED);
} else {
@ -181,6 +186,7 @@ led_period_handler
const uint16_t *accept = NULL;
uint16_t a_ctype = REST.type.APPLICATION_JSON;
uint16_t c_ctype = REST.get_header_content_type (request);
uint32_t tmp = 0;
/* Seems like accepted type is currently unsupported? */
n_acc = REST.get_header_accept (request, &accept);
@ -255,7 +261,14 @@ led_period_handler
temp [sizeof (temp) - 1] = 0;
}
PRINTF ("GOT: %s\n", temp);
period_100ms = (atoi (temp) + 50) / 100;
tmp = (strtoul (temp, NULL, 10) + 50) / 100;
if (tmp > 10) {
tmp = 10;
}
if (tmp == 0) {
tmp = 1;
}
period_100ms = tmp;
PRINTF ("Setting: %dms\n", period_100ms * 100);
REST.set_response_status(response, REST.status.CHANGED);
} else {