* Wiselib update for the linekrscript
* some minor changes in vtimer
This commit is contained in:
parent
d9d46800bb
commit
15d27d8244
@ -75,7 +75,17 @@ SECTIONS
|
||||
*(.cfgspec) /* configuration spec table */
|
||||
__cfgspec_end = .;
|
||||
. = ALIGN(4);
|
||||
|
||||
|
||||
__ctors_start = .;
|
||||
PROVIDE (_os_ctor_start = .);
|
||||
*(.ctors);
|
||||
KEEP (*(.init_array))
|
||||
PROVIDE (_os_ctor_end = .);
|
||||
__ctors_end = .;
|
||||
*(.dtors);
|
||||
LONG (0);
|
||||
|
||||
|
||||
*(.rodata .rodata.*) /* all .rodata sections (constants, strings, etc.) */
|
||||
*(.gnu.linkonce.r.*)
|
||||
*(.glue_7) /* all .glue_7 sections (no idea what these are) */
|
||||
@ -109,6 +119,40 @@ SECTIONS
|
||||
/**************************************************************************
|
||||
* RAM
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
.ctors (NOLOAD) :
|
||||
|
||||
{
|
||||
|
||||
. = ALIGN(4096);
|
||||
|
||||
start_ctors = .;
|
||||
|
||||
*(.init_array);
|
||||
|
||||
*(.ctors);
|
||||
|
||||
end_ctors = .;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
.dtors (NOLOAD) :
|
||||
|
||||
{
|
||||
|
||||
. = ALIGN(4096);
|
||||
|
||||
start_dtors = .;
|
||||
|
||||
*(.fini_array);
|
||||
|
||||
*(.dtors);
|
||||
|
||||
end_dtors = .;
|
||||
}
|
||||
|
||||
/*
|
||||
* collect all uninitialized sections that go into RAM
|
||||
@ -130,7 +174,8 @@ SECTIONS
|
||||
{
|
||||
. = ALIGN(4); /* ensure data is aligned so relocation can use 4-byte operations */
|
||||
__bss_start = .; /* define a global symbol marking the start of the .bss section */
|
||||
*(.bss) /* all .bss sections */
|
||||
*(.bss) /* all .bss sections */
|
||||
*(.bss*) /* all .bss sections */
|
||||
*(COMMON)
|
||||
} > ram /* put all the above in RAM (it will be cleared in the startup code */
|
||||
. = ALIGN(4); /* ensure data is aligned so relocation can use 4-byte operations */
|
||||
|
||||
@ -34,9 +34,13 @@
|
||||
#include "weather_protocol.h"
|
||||
#include "protocol_msg_gateway.h"
|
||||
|
||||
/* some local defines */
|
||||
#define SECOND (1000 * 1000)
|
||||
#define MINUTE (1 * SECOND)
|
||||
#define MINUTE (60 * SECOND)
|
||||
|
||||
#define SENDING_INTERVAL (1 * SECOND)
|
||||
|
||||
#define SHELL_STACK_SIZE (2048)
|
||||
#define PH_STACK_SIZE (2048)
|
||||
|
||||
/* size of weather data packet without hop list */
|
||||
#define EMPTY_WDP_SIZE (sizeof(weather_data_pkt_t) - MAX_HOP_LIST)
|
||||
|
||||
@ -22,6 +22,8 @@
|
||||
#include <queue.h>
|
||||
#include <timex.h>
|
||||
|
||||
#define MSG_TIMER 12345
|
||||
|
||||
/**
|
||||
* A vtimer object.
|
||||
*
|
||||
@ -34,6 +36,7 @@ typedef struct vtimer_t {
|
||||
timex_t absolute;
|
||||
void(*action)(void*);
|
||||
void* arg;
|
||||
int pid;
|
||||
} vtimer_t;
|
||||
|
||||
/**
|
||||
|
||||
37
sys/vtimer.c
37
sys/vtimer.c
@ -4,7 +4,7 @@
|
||||
#include <queue.h>
|
||||
#include <timex.h>
|
||||
#include <hwtimer.h>
|
||||
|
||||
#include <msg.h>
|
||||
#include <thread.h>
|
||||
|
||||
#include <vtimer.h>
|
||||
@ -51,7 +51,6 @@ static int update_shortterm() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
hwtimer_next_absolute = shortterm_queue_root.next->priority;
|
||||
|
||||
unsigned int next = hwtimer_next_absolute + longterm_tick_start;
|
||||
@ -60,9 +59,10 @@ static int update_shortterm() {
|
||||
if((next - VTIMER_THRESHOLD - now) > NANOSECONDS_PER_TICK ) {
|
||||
next = now + VTIMER_BACKOFF;
|
||||
}
|
||||
|
||||
|
||||
|
||||
hwtimer_id = hwtimer_set_absolute(next, vtimer_callback, NULL);
|
||||
|
||||
printf("hw_id: %i\n", hwtimer_id);
|
||||
DEBUG("update_shortterm: Set hwtimer to %lu (now=%lu)\n", hwtimer_next_absolute + longterm_tick_start, hwtimer_now());
|
||||
return 0;
|
||||
}
|
||||
@ -104,8 +104,17 @@ void vtimer_callback(void *ptr) {
|
||||
|
||||
DEBUG("vtimer_callback(): Shooting %lu.\n", timer->absolute.nanoseconds);
|
||||
|
||||
printf("timer pid: %i\n", timer->pid);
|
||||
|
||||
/* shoot timer */
|
||||
timer->action(timer->arg);
|
||||
if(timer->pid != 0){
|
||||
/* ugly*/
|
||||
msg_t msg;
|
||||
msg.content.value = (unsigned int) timer->arg;
|
||||
msg_send_int(&msg, timer->pid);
|
||||
} else {
|
||||
timer->action(timer->arg);
|
||||
}
|
||||
|
||||
in_callback = false;
|
||||
update_shortterm();
|
||||
@ -220,3 +229,21 @@ int vtimer_set_cb(vtimer_t *t, timex_t interval, void (*f_ptr)(void *), void *pt
|
||||
return vtimer_set(t);
|
||||
}
|
||||
|
||||
int vtimer_remove(vtimer_t *t){
|
||||
queue_remove(&shortterm_queue_root, (queue_node_t*)t);
|
||||
queue_remove(&longterm_queue_root, (queue_node_t*)t);
|
||||
|
||||
update_shortterm();
|
||||
|
||||
if (! inISR() ) eINT();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int vtimer_set_msg(vtimer_t *t, timex_t interval, int pid, void *ptr){
|
||||
t->action = (void* ) msg_send_int;
|
||||
t->arg = (void*) ptr;
|
||||
t->absolute = interval;
|
||||
t->pid = pid;
|
||||
vtimer_set(t);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user