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

@ -28,20 +28,10 @@ void setup (void)
void loop (void)
{
static uint8_t last_pwm = 0;
if (last_pwm != pwm) {
last_pwm = pwm;
analogWrite (LED_PIN, pwm);
printf
( "TCNT3: %04X TCCR3A: %04X TCCR3B: %04X TCCR3C: %04X OCR3C: %04X\n"
, TCNT3, TCCR3A, TCCR3B, TCCR3C, OCR3C
);
}
// Originally I wanted to sleep here to make the LED blink.
// Sleeping currently doesn't work, something turns off the chip.
// Maybe a mechanism to guard agains proto-threads taking too long?
//clock_wait (CLOCK_SECOND * period_100ms / 10);
//analogWrite (LED_PIN, 0);
//printf ("After write\n");
/* Use 255 - pwm, LED on merkur-board is wired to +3.3V */
analogWrite (LED_PIN, 255 - pwm);
printf ("clock : %u\nmillis: %lu\n", clock_time (), millis ());
delay (period_100ms * 100);
analogWrite (LED_PIN, 255); /* OFF: LED on merkur-board is wired to +3.3V */
delay (period_100ms * 100);
}