/** * \file * Resource for hardware timer handling * \author * Ralf Schlatterbeck * * \brief get/put pwm for LED pin */ #include #include #include #include "contiki.h" #include "jsonparse.h" #include "er-coap.h" #include "hw_timer.h" #include "generic_resource.h" #define DEBUG 1 #if DEBUG #define PRINTF(...) printf(__VA_ARGS__) #else #define PRINTF(...) #endif static uint16_t max_ticks = 0, pwm = 0; void led_pwm_init (void) { int8_t result = hwtimer_pwm_ini (3, 20, HWT_PWM_PHASE_CORRECT, 0); PRINTF ("HWTIMER init: %d\n", result); max_ticks = hwtimer_pwm_max_ticks (3); pwm = max_ticks / 2; hwtimer_set_pwm (3, HWT_CHANNEL_C, pwm); hwtimer_pwm_inverse (3, HWT_CHANNEL_C); DDRE |= (1< max_ticks) { pwm = max_ticks; } PRINTF ("Setting: %d (max=%d)\n", pwm, max_ticks); hwtimer_pwm_inverse (3, HWT_CHANNEL_C); DDRE |= (1<