From 73699e73ed3dfedbba08daa6fbf55ba181cb3a3f Mon Sep 17 00:00:00 2001 From: Ludwig Ortmann Date: Mon, 16 Dec 2013 11:09:42 +0100 Subject: [PATCH 1/8] translate german comment --- boards/msb-430-common/board_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 */ From 69f6748a7c47a01cd8d975bdb0c48c75224ee806 Mon Sep 17 00:00:00 2001 From: Ludwig Ortmann Date: Mon, 16 Dec 2013 11:22:42 +0100 Subject: [PATCH 2/8] clean up msp430 cpu-conf.h --- cpu/msp430-common/include/cpu-conf.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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) From 2a8411b6a3d35ec7e4093086d0bd7f7e2575035c Mon Sep 17 00:00:00 2001 From: Ludwig Ortmann Date: Wed, 18 Dec 2013 02:25:48 +0100 Subject: [PATCH 3/8] fix main return for msp430 mspgcc handles main specially, this introduces code to make main behave normally --- cpu/msp430-common/cpu.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cpu/msp430-common/cpu.c b/cpu/msp430-common/cpu.c index d853369315..c9e854c430 100644 --- a/cpu/msp430-common/cpu.c +++ b/cpu/msp430-common/cpu.c @@ -39,6 +39,14 @@ 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 //---------------------------------------------------------------------------- From 76cfdc33b19e48e684a85ef2df4c576191c9a6ff Mon Sep 17 00:00:00 2001 From: Ludwig Ortmann Date: Thu, 19 Dec 2013 11:34:59 +0100 Subject: [PATCH 4/8] stack alignment workaround Should be fixed in thread.c instead, this is just a temporary workaround to enable msp-430 threads in the mean time. --- cpu/msp430-common/cpu.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cpu/msp430-common/cpu.c b/cpu/msp430-common/cpu.c index c9e854c430..93db47410b 100644 --- a/cpu/msp430-common/cpu.c +++ b/cpu/msp430-common/cpu.c @@ -53,6 +53,10 @@ __attribute__((section (".fini9"))) void __main_epilogue(void) { __asm__("ret"); 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; From 6b8d7cb3fcc590fd4badad93bf454b22aefa3645 Mon Sep 17 00:00:00 2001 From: Ludwig Ortmann Date: Thu, 19 Dec 2013 12:02:23 +0100 Subject: [PATCH 5/8] improve programmer handling in msb-430-common --- boards/msb-430-common/Makefile.include | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) 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 From 437c0ee5c938bdbc25cc48028f7cdca7982a098a Mon Sep 17 00:00:00 2001 From: Ludwig Ortmann Date: Thu, 19 Dec 2013 12:34:55 +0100 Subject: [PATCH 6/8] msp430 lpm stub --- cpu/msp430-common/include/cpu.h | 2 -- cpu/msp430-common/lpm_cpu.c | 26 ++++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 cpu/msp430-common/lpm_cpu.c diff --git a/cpu/msp430-common/include/cpu.h b/cpu/msp430-common/include/cpu.h index 22175d303f..b887346ed5 100644 --- a/cpu/msp430-common/include/cpu.h +++ b/cpu/msp430-common/include/cpu.h @@ -125,8 +125,6 @@ inline void dINT(void) dint(); } -#define lpm_set(...) - void thread_yield(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; +} From 8dd9db3c456fbe531e080b2932f08e674a08cf6b Mon Sep 17 00:00:00 2001 From: Ludwig Ortmann Date: Thu, 19 Dec 2013 12:35:04 +0100 Subject: [PATCH 7/8] add some documentation to lpm.h --- core/include/lpm.h | 1 + 1 file changed, 1 insertion(+) 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); From 50d488e6bc8b759913074dba8d5b088a3a54f9a6 Mon Sep 17 00:00:00 2001 From: Ludwig Ortmann Date: Thu, 19 Dec 2013 13:04:04 +0100 Subject: [PATCH 8/8] remove suprerfluous thread_yield declaration --- cpu/msp430-common/cpu.c | 1 + cpu/msp430-common/include/cpu.h | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/cpu/msp430-common/cpu.c b/cpu/msp430-common/cpu.c index 93db47410b..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; diff --git a/cpu/msp430-common/include/cpu.h b/cpu/msp430-common/include/cpu.h index b887346ed5..a8835f71b2 100644 --- a/cpu/msp430-common/include/cpu.h +++ b/cpu/msp430-common/include/cpu.h @@ -125,9 +125,6 @@ inline void dINT(void) dint(); } -void thread_yield(void); - - int inISR(void); void msp430_cpu_init(void);