diff --git a/boards/msb-430-common/Makefile.include b/boards/msb-430-common/Makefile.include index 9a1c3860b5..4f5bb857d3 100644 --- a/boards/msb-430-common/Makefile.include +++ b/boards/msb-430-common/Makefile.include @@ -14,13 +14,26 @@ export SIZE = $(PREFIX)size export OBJCOPY = $(PREFIX)objcopy export LINKFLAGS = -mmcu=$(MCU) -lgcc $(RIOTBASE)/bin/startup.o TERMPROG = $(RIOTBASE)/dist/tools/pyterm/pyterm.py -export FLASHER = mspdebug +export HEXFILE = bin/$(PROJECT).hex + + +ifeq ($(strip $(FLASHER)),) + export FLASHER = mspdebug +endif + +# set programmer port in FFLAGS manually if needed like this: +# FFLAGS="-d /dev/ttyUSB0" PROGRAMMER="uif" make flash + +ifeq ($(strip $(PROGRAMMER)),) + export PROGRAMMER = olimex +endif +export FFLAGS += -j $(PROGRAMMER) + ifeq ($(strip $(PORT)),) export PORT = /dev/ttyUSB0 endif -export HEXFILE = bin/$(PROJECT).hex -#export FFLAGS = -d $(PORT) -j uif "prog $(HEXFILE)" -export FFLAGS = -j olimex "prog $(HEXFILE)" + +export FFLAGS += "prog $(HEXFILE)" export USEMODULE += msp430_common export INCLUDES += -I $(RIOTCPU)/msp430-common/include/ -I$(RIOTBOARD)/msb-430-common/include diff --git a/boards/msb-430-common/board_init.c b/boards/msb-430-common/board_init.c index 35ed8d946e..b85478765f 100644 --- a/boards/msb-430-common/board_init.c +++ b/boards/msb-430-common/board_init.c @@ -41,7 +41,7 @@ static void msb_ports_init(void) { /* Port 1: Free port, for energy saving all outputs are set to zero. */ P1SEL = 0x00; /* Port1 I/O Function */ - P1OUT = 0x00; /* Port1 Ausgangsregister: 00000000 = 0x00 */ + P1OUT = 0x00; /* Port1 Output register: 00000000 = 0x00 */ P1DIR = 0xFF; /* Port1 Direction: 11111111 = 0xFF */ P2SEL = 0x20; /* Port2 I/O Function */ diff --git a/core/include/lpm.h b/core/include/lpm.h index 7cb8a6325d..0910c5e5ff 100644 --- a/core/include/lpm.h +++ b/core/include/lpm.h @@ -44,6 +44,7 @@ void lpm_init(void); /** * @brief Switches the MCU to a new power mode * @param[in] target Target power mode + * @return The previous power mode */ enum lpm_mode lpm_set(enum lpm_mode target); diff --git a/cpu/msp430-common/cpu.c b/cpu/msp430-common/cpu.c index d853369315..504f637faf 100644 --- a/cpu/msp430-common/cpu.c +++ b/cpu/msp430-common/cpu.c @@ -14,6 +14,7 @@ See the file LICENSE in the top level directory for more details. #include "kernel.h" #include "kernel_internal.h" #include "sched.h" +#include "thread.h" volatile int __inISR = 0; @@ -39,12 +40,24 @@ void cpu_switch_context_exit(void) __restore_context(); } +/** + * mspgcc handles main specially - it does not return but falls + * through to section .fini9. + * To "fix" this, we put a return in section .fini9 to make main + * behave like a regular function. This enables a common + * thread_stack_init behavior. */ +__attribute__((section (".fini9"))) void __main_epilogue(void) { __asm__("ret"); } + //---------------------------------------------------------------------------- // Processor specific routine - here for MSP //---------------------------------------------------------------------------- char *thread_stack_init(void (*task_func)(void), void *stack_start, int stack_size) { unsigned short *stk; + + /* XXX: work around for misalignment, remove once solved properly in thread.c */ + stack_size--; + stk = (unsigned short *)(stack_start + stack_size); *stk = (unsigned short) sched_task_exit; diff --git a/cpu/msp430-common/include/cpu-conf.h b/cpu/msp430-common/include/cpu-conf.h index 11b9e15832..198223a768 100644 --- a/cpu/msp430-common/include/cpu-conf.h +++ b/cpu/msp430-common/include/cpu-conf.h @@ -23,8 +23,8 @@ See the file LICENSE in the top level directory for more details. #define KERNEL_CONF_STACKSIZE_DEFAULT (256) #endif -#define KERNEL_CONF_STACKSIZE_IDLE 96 -#define MSP430_ISR_STACK_SIZE 256 +#define KERNEL_CONF_STACKSIZE_IDLE (96) +#define MSP430_ISR_STACK_SIZE (256) #define RX_BUF_SIZE (3) #define TRANSCEIVER_BUFFER_SIZE (3) diff --git a/cpu/msp430-common/include/cpu.h b/cpu/msp430-common/include/cpu.h index 22175d303f..a8835f71b2 100644 --- a/cpu/msp430-common/include/cpu.h +++ b/cpu/msp430-common/include/cpu.h @@ -125,11 +125,6 @@ inline void dINT(void) dint(); } -#define lpm_set(...) - -void thread_yield(void); - - int inISR(void); void msp430_cpu_init(void); diff --git a/cpu/msp430-common/lpm_cpu.c b/cpu/msp430-common/lpm_cpu.c new file mode 100644 index 0000000000..26858ce9f0 --- /dev/null +++ b/cpu/msp430-common/lpm_cpu.c @@ -0,0 +1,26 @@ +#include + +#include "lpm.h" + +/* TODO: implement */ +enum lpm_mode lpm_set(enum lpm_mode target) +{ + enum lpm_mode last_mode; + + /* dummy value as lpm is not currently implemented */ + last_mode = LPM_ON; + + return last_mode; +} + + +/* TODO: implement */ +enum lpm_mode lpm_get() +{ + enum lpm_mode current_mode; + + /* dummy value as lpm is not currently implemented */ + current_mode = LPM_ON; + + return current_mode; +}