diff --git a/core/include/queue.h b/core/include/queue.h index 2e3cab39f8..fd8e5ccfea 100644 --- a/core/include/queue.h +++ b/core/include/queue.h @@ -9,12 +9,12 @@ #ifndef __QUEUE_H #define __QUEUE_H -#include "queue.h" +#include typedef struct queue_node_t { struct queue_node_t *next; unsigned int data; - unsigned int priority; + uint32_t priority; } queue_node_t; queue_node_t* queue_remove_head(queue_node_t* root); diff --git a/core/queue.c b/core/queue.c index bfc50b4ce0..ba5fc668a1 100644 --- a/core/queue.c +++ b/core/queue.c @@ -89,12 +89,12 @@ void queue_print(queue_node_t* node) { printf("queue:\n"); while (node->next != NULL) { node = node->next; - printf("Data: %u Priority: %u\n", node->data, node->priority); + printf("Data: %u Priority: %lu\n", node->data, node->priority); } } void queue_print_node(queue_node_t *node) { - printf("Data: %u Priority: %u Next: %u\n", (unsigned int)node->data, node->priority, (unsigned int)node->next); + printf("Data: %u Priority: %lu Next: %u\n", (unsigned int)node->data, node->priority, (unsigned int)node->next); } /* diff --git a/cpu/msp430-common/hwtimer_cpu.c b/cpu/msp430-common/hwtimer_cpu.c index 41024ac341..d8e0591061 100644 --- a/cpu/msp430-common/hwtimer_cpu.c +++ b/cpu/msp430-common/hwtimer_cpu.c @@ -36,6 +36,8 @@ and the mailinglist (subscription via web site) void (*int_handler)(int); extern void timerA_init(void); +uint16_t overflow_interrupt[ARCH_MAXTIMERS+1]; +uint16_t timer_round; static void TA0_disable_interrupt(short timer) { volatile unsigned int *ptr = &TA0CCTL0 + (timer); @@ -67,12 +69,13 @@ void TA0_unset(short timer) { } unsigned long hwtimer_arch_now() { - return TA0R; + return ((uint32_t)timer_round << 16)+TA0R; } void hwtimer_arch_init(void (*handler)(int), uint32_t fcpu) { timerA_init(); int_handler = handler; + TA0_enable_interrupt(0); } void hwtimer_arch_enable_interrupt(void) { @@ -88,12 +91,14 @@ void hwtimer_arch_disable_interrupt(void) { } void hwtimer_arch_set(unsigned long offset, short timer) { - unsigned int value = hwtimer_arch_now() + offset; + unsigned long value = hwtimer_arch_now() + offset; hwtimer_arch_set_absolute(value, timer); } void hwtimer_arch_set_absolute(unsigned long value, short timer) { - TA0_set(value,timer); + uint16_t small_value = value % 0xFFFF; + overflow_interrupt[timer] = (uint16_t)(value >> 16); + TA0_set(small_value,timer); } void hwtimer_arch_unset(short timer) { diff --git a/cpu/msp430-common/include/hwtimer_cpu.h b/cpu/msp430-common/include/hwtimer_cpu.h index b9db594f32..aa8d4fbcc0 100644 --- a/cpu/msp430-common/include/hwtimer_cpu.h +++ b/cpu/msp430-common/include/hwtimer_cpu.h @@ -51,6 +51,6 @@ and the mailinglist (subscription via web site) #endif #define HWTIMER_SPEED 32768 -#define HWTIMER_MAXTICKS (0xFFFF) +#define HWTIMER_MAXTICKS (0xFFFFFFFF) #endif // __HWTIMER_CPU_H diff --git a/cpu/msp430x16x/hwtimer_msp430.c b/cpu/msp430x16x/hwtimer_msp430.c index f208e82590..62287e61f6 100644 --- a/cpu/msp430x16x/hwtimer_msp430.c +++ b/cpu/msp430x16x/hwtimer_msp430.c @@ -7,17 +7,20 @@ static uint32_t ticks = 0; extern void (*int_handler)(int); extern void TA0_unset(short timer); +extern uint16_t overflow_interrupt[ARCH_MAXTIMERS+1]; +extern uint16_t timer_round; void timerA_init(void) { ticks = 0; // Set tick counter value to 0 + timer_round = 0; // Set to round 0 TA0CTL = TASSEL_1 + TACLR; // Clear the timer counter, set ACLK TA0CTL &= ~TAIFG; // Clear the IFG TA0CTL &= ~TAIE; // Clear the IFG - volatile unsigned int *ccr = &TA0CCR0; - volatile unsigned int *ctl = &TA0CCTL0; for (int i = 0; i < ARCH_MAXTIMERS; i++) { + volatile unsigned int *ccr = &TA0CCR0 + (i); + volatile unsigned int *ctl = &TA0CCTL0 + (i); *ccr = 0; *ctl &= ~(CCIFG); *ctl &= ~(CCIE); @@ -27,11 +30,11 @@ void timerA_init(void) interrupt(TIMERA0_VECTOR) __attribute__ ((naked)) timer_isr_ccr0(void) { __enter_isr(); - - TA0_unset(0); - int_handler(0); - + //TA0_unset(0); + //int_handler(0); + timer_round += 1; __exit_isr(); + } interrupt(TIMERA1_VECTOR) __attribute__ ((naked)) timer_isr(void) { @@ -42,13 +45,15 @@ interrupt(TIMERA1_VECTOR) __attribute__ ((naked)) timer_isr(void) { if (taiv & TAIFG) { // puts("msp430/hwtimer_cpu TAIFG set!"); // TA0CTL &= ~TAIFG; - // ticks += 0xFFFF; + // timer_round += 1; } else { short timer = (taiv/2); - TA0_unset(timer); - int_handler(timer); + if(overflow_interrupt[timer] == timer_round) + { + TA0_unset(timer); + int_handler(timer); + } } - __exit_isr(); } diff --git a/drivers/cc110x_ng/Makefile b/drivers/cc110x_ng/Makefile index 6fadf78ad4..e1f235d479 100644 --- a/drivers/cc110x_ng/Makefile +++ b/drivers/cc110x_ng/Makefile @@ -8,6 +8,9 @@ endif ifneq (,$(findstring msba2,$(BOARD))) DIRS += spi endif +ifneq (,$(findstring wsn430-v1_3b,$(BOARD))) + DIRS += spi +endif all: $(BINDIR)$(MODULE).a @for i in $(DIRS) ; do $(MAKE) -C $$i ; done ; diff --git a/sys/lib/hashtable.c b/sys/lib/hashtable.c index 80cbba9343..34ea28441e 100755 --- a/sys/lib/hashtable.c +++ b/sys/lib/hashtable.c @@ -34,7 +34,7 @@ create_hashtable(uint32_t minsize, struct hashtable *h; unsigned int pindex, size = primes[0]; /* Check requested hashtable isn't too large */ - if (minsize > (1u << 30)) return NULL; + if (minsize > (1UL << 30)) return NULL; /* Enforce size as prime */ for (pindex=0; pindex < prime_table_length; pindex++) { if (primes[pindex] > minsize) { size = primes[pindex]; break; } @@ -59,7 +59,7 @@ hash(struct hashtable *h, void *k) { /* Aim to protect against poor hash functions by adding logic here * - logic taken from java 1.4 hashtable source */ - unsigned int i = h->hashfn(k); + uint32_t i = h->hashfn(k); i += ~(i << 9); i ^= ((i >> 14) | (i << 18)); /* >>> */ i += (i << 4); diff --git a/sys/shell/commands/sc_cc110x_ng.c b/sys/shell/commands/sc_cc110x_ng.c index ed9aa45110..5363a07865 100644 --- a/sys/shell/commands/sc_cc110x_ng.c +++ b/sys/shell/commands/sc_cc110x_ng.c @@ -69,7 +69,7 @@ void _cc110x_ng_send_handler(char *pkt) { p.dst = addr; mesg.type = SND_PKT; mesg.content.ptr = (char*) &tcmd; - printf("[cc110x] Sending packet of length %u to %hu: %s\n", p.length, p.dst, (char*) p.data); + printf("[cc110x] Sending packet of length %u to %u: %s\n", p.length, p.dst, (char*) p.data); msg_send_receive(&mesg, &mesg, transceiver_pid); response = mesg.content.value; printf("[cc110x] Packet sent: %lu\n", response); diff --git a/sys/vtimer/vtimer.c b/sys/vtimer/vtimer.c index 4a88b128f6..9c085e5956 100644 --- a/sys/vtimer/vtimer.c +++ b/sys/vtimer/vtimer.c @@ -13,11 +13,11 @@ #include -#define VTIMER_THRESHOLD 20U -#define VTIMER_BACKOFF 10U +#define VTIMER_THRESHOLD 20UL +#define VTIMER_BACKOFF 10UL #define SECONDS_PER_TICK (4096U) -#define MICROSECONDS_PER_TICK (4096U * 1000000) +#define MICROSECONDS_PER_TICK (4096UL * 1000000) void vtimer_callback(void *ptr); void vtimer_tick(void *ptr); @@ -58,16 +58,16 @@ static int update_shortterm(void) { hwtimer_next_absolute = shortterm_queue_root.next->priority; - unsigned int next = hwtimer_next_absolute + longterm_tick_start; - unsigned int now = hwtimer_now(); + uint32_t next = hwtimer_next_absolute + longterm_tick_start; + uint32_t now = HWTIMER_TICKS_TO_US(hwtimer_now()); - if((next - VTIMER_THRESHOLD - now) > MICROSECONDS_PER_TICK ) { - next = now + VTIMER_BACKOFF; + if((next - HWTIMER_TICKS_TO_US(VTIMER_THRESHOLD) - now) > MICROSECONDS_PER_TICK ) { + next = now + HWTIMER_TICKS_TO_US(VTIMER_BACKOFF); } - hwtimer_id = hwtimer_set_absolute(next, vtimer_callback, NULL); + hwtimer_id = hwtimer_set_absolute(HWTIMER_TICKS(next), vtimer_callback, NULL); - DEBUG("update_shortterm: Set hwtimer to %lu (now=%lu)\n", hwtimer_next_absolute + longterm_tick_start, hwtimer_now()); + DEBUG("update_shortterm: Set hwtimer to %lu (now=%lu)\n", next, HWTIMER_TICKS_TO_US(hwtimer_now())); return 0; } @@ -150,6 +150,7 @@ static int vtimer_set(vtimer_t *timer) { normalize_to_tick(&(timer->absolute)); DEBUG("vtimer_set(): Absolute: %lu %lu\n", timer->absolute.seconds, timer->absolute.microseconds); + DEBUG("vtimer_set(): NOW: %lu %lu\n", vtimer_now().seconds, vtimer_now().microseconds); int result = 0; @@ -185,7 +186,7 @@ static int vtimer_set(vtimer_t *timer) { } timex_t vtimer_now() { - timex_t t = timex_set(seconds, hwtimer_now()-longterm_tick_start); + timex_t t = timex_set(seconds, HWTIMER_TICKS_TO_US(hwtimer_now())-longterm_tick_start); return t; } @@ -194,6 +195,8 @@ int vtimer_init() { int state = disableIRQ(); seconds = 0; + longterm_tick_start = 0; + longterm_tick_timer.action = vtimer_tick; longterm_tick_timer.arg = NULL;