diff --git a/core/thread.c b/core/thread.c index 31fcde282e..d9a922aec9 100644 --- a/core/thread.c +++ b/core/thread.c @@ -84,7 +84,18 @@ int thread_create(char *stack, int stacksize, char priority, int flags, void (*f /* allocate our thread control block at the top of our stackspace */ int total_stacksize = stacksize; stacksize -= sizeof(tcb); - tcb *cb = (tcb*) (stack + stacksize); + + /* align tcb address on 32bit boundary */ + unsigned int tcb_address = (unsigned int) stack + stacksize; + if ( tcb_address & 1 ) { + tcb_address--; + stacksize--; + } + if ( tcb_address & 2 ) { + tcb_address-=2; + stacksize-=2; + } + tcb *cb = (tcb*) tcb_address; if (priority >= SCHED_PRIO_LEVELS) { return -EINVAL; diff --git a/drivers/cc110x/cc1100_phy.c b/drivers/cc110x/cc1100_phy.c index 4723bfa172..441b7d6a28 100644 --- a/drivers/cc110x/cc1100_phy.c +++ b/drivers/cc110x/cc1100_phy.c @@ -60,7 +60,7 @@ and the mailinglist (subscription via web site) #include "msg.h" #include "debug.h" -#define PRIORITY_CC1100 PRIORITY_MIN-9 +#define PRIORITY_CC1100 PRIORITY_MAIN-1 #define MSG_POLL 12346 @@ -97,7 +97,7 @@ static const char *cc1100_event_handler_name = "cc1100_event_handler"; static mutex_t cc1100_mutex; volatile int cc1100_mutex_pid; static swtimer_t cc1100_watch_dog; -static uint64_t cc1100_watch_dog_period = 0; +static swtime_t cc1100_watch_dog_period = 0; static uint16_t cc1100_event_handler_pid; static void cc1100_event_handler_function(void); diff --git a/projects/default/Jamfile b/projects/default/Jamfile index 2820d752cf..2c8d376edc 100644 --- a/projects/default/Jamfile +++ b/projects/default/Jamfile @@ -6,6 +6,6 @@ SubDir TOP projects default ; -Module default_project : main.c : shell posix_io uart0 shell_commands ps rtc sht11 ltc4150 auto_init ; +Module default_project : main.c : shell posix_io uart0 shell_commands ps rtc sht11 ltc4150 cc110x auto_init ; UseModule default_project ; diff --git a/sys/shell/Jamfile b/sys/shell/Jamfile index e6ae372ebb..cc0eec2e45 100644 --- a/sys/shell/Jamfile +++ b/sys/shell/Jamfile @@ -28,7 +28,7 @@ SubDir TOP sys shell ; Module shell : shell.c ; -Module shell_commands : shell_commands.c rtc.c sht11.c ltc4150.c : shell ; +Module shell_commands : shell_commands.c rtc.c sht11.c ltc4150.c cc1100.c : shell ; Module ps : ps.c ; diff --git a/sys/shell/cc1100.c b/sys/shell/cc1100.c new file mode 100644 index 0000000000..4236f517da --- /dev/null +++ b/sys/shell/cc1100.c @@ -0,0 +1,24 @@ +#include +#include + +void _cc1100_get_address_handler(char *str) { + radio_address_t addr = cc1100_get_address(); + printf("cc1100 address: %i\n", addr); +} + +void _cc1100_set_address_handler(char *str) { + int addr; + int res = sscanf(str, "cc1100_set_address %i", &addr); + if (res == 1) { + cc1100_set_address((radio_address_t)addr); + printf("Setting cc1100 address to %i: ", addr); + if (cc1100_get_address() == (radio_address_t)addr) { + puts("OK"); + } else { + puts("Error!"); + } + } else { + puts("usage: cc1100_set_address
"); + } +} + diff --git a/sys/shell/shell_commands.c b/sys/shell/shell_commands.c index 123f0f4f09..41f152ce99 100644 --- a/sys/shell/shell_commands.c +++ b/sys/shell/shell_commands.c @@ -21,6 +21,11 @@ extern void _get_current_handler(char* unused); extern void _reset_current_handler(char* unused); #endif +#ifdef MODULE_CC110X +extern void _cc1100_get_address_handler(char *unused); +extern void _cc1100_set_address_handler(char *ptr); +#endif + const shell_command_t _shell_command_list[] = { #ifdef MODULE_PS {"ps", "Prints information about running threads.", _ps_handler}, @@ -37,6 +42,10 @@ const shell_command_t _shell_command_list[] = { #ifdef MODULE_LTC4150 {"cur", "Prints current and average power consumption.", _get_current_handler}, {"rstcur", "Resets coulomb counter.", _reset_current_handler}, +#endif +#ifdef MODULE_CC110X + {"cc1100_get_address", "", _cc1100_get_address_handler}, + {"cc1100_set_address", "", _cc1100_set_address_handler}, #endif {NULL, NULL, NULL} };