aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--demos/MSP430-MSP430x1611-GCC/board.c32
-rw-r--r--demos/MSP430-MSP430x1611-GCC/board.h60
-rw-r--r--demos/MSP430-MSP430x1611-GCC/main.c4
-rw-r--r--demos/MSP430-MSP430x1611-GCC/readme.txt4
-rw-r--r--ports/MSP430/chcore.c10
-rw-r--r--ports/MSP430/chcore.h5
-rw-r--r--readme.txt7
7 files changed, 109 insertions, 13 deletions
diff --git a/demos/MSP430-MSP430x1611-GCC/board.c b/demos/MSP430-MSP430x1611-GCC/board.c
index 09f93075a..b591ec3d6 100644
--- a/demos/MSP430-MSP430x1611-GCC/board.c
+++ b/demos/MSP430-MSP430x1611-GCC/board.c
@@ -29,13 +29,43 @@
void hwinit(void) {
/*
+ * Clock sources setup.
+ */
+ DCOCTL = VAL_DCOCTL;
+ BCSCTL1 = VAL_BCSCTL1;
+ BCSCTL2 = VAL_BCSCTL2;
+
+ /*
* I/O ports initialization.
*/
+ P1OUT = VAL_P1OUT;
+ P1DIR = VAL_P1DIR;
+ P1SEL = VAL_P1SEL;
+
+ P2OUT = VAL_P2OUT;
+ P2DIR = VAL_P2DIR;
+ P2SEL = VAL_P2SEL;
+
+ P3OUT = VAL_P3OUT;
+ P3DIR = VAL_P3DIR;
+ P3SEL = VAL_P3SEL;
+
+ P4OUT = VAL_P4OUT;
+ P4DIR = VAL_P4DIR;
+ P4SEL = VAL_P4SEL;
+
+ P5OUT = VAL_P5OUT;
+ P5DIR = VAL_P5DIR;
+ P5SEL = VAL_P5SEL;
+
+ P6OUT = VAL_P6OUT;
+ P6DIR = VAL_P6DIR;
+ P6SEL = VAL_P6SEL;
/*
* Timer 0 setup.
*/
- TACCR0 = ACLK / CH_FREQUENCY; /* Counter limit. */
+ TACCR0 = ACLK / CH_FREQUENCY - 1; /* Counter limit. */
TACTL = TACLR; /* Clean start. */
TACTL = TASSEL_1 | MC_1; /* Src=ACLK, cmp=TACCR0. */
TACCTL0 = CCIE; /* Interrupt on compare. */
diff --git a/demos/MSP430-MSP430x1611-GCC/board.h b/demos/MSP430-MSP430x1611-GCC/board.h
index 005b019a9..fe4523b6a 100644
--- a/demos/MSP430-MSP430x1611-GCC/board.h
+++ b/demos/MSP430-MSP430x1611-GCC/board.h
@@ -20,12 +20,66 @@
#ifndef _BOARD_H_
#define _BOARD_H_
-#ifndef __msp430x16x
#include <msp430x16x.h>
+
+#define MSP_USE_XT2CLK
+
+#define LFXT1CLK 32768
+#define XT2CLK 8000000
+#define DCOCLK 1000000
+
+#define ACLK LFXT1CLK
+#ifdef MSP_USE_XT2CLK
+#define MCLK XT2CLK
+#define SMCLK (XT2CLK / 8)
+#else
+#define MCLK DCOCLK
+#define SMCLK LFXT1CLK
#endif
-#define MCLK 8000000
-#define ACLK 8000000
+#define VAL_DCOCTL (DCO0 | DCO1)
+#ifdef MSP_USE_XT2CLK
+#define VAL_BCSCTL1 (RSEL2)
+#define VAL_BCSCTL2 (SELM_2 | DIVM_0 | DIVS_3 | SELS)
+#else
+#define VAL_BCSCTL1 (XT2OFF | RSEL2)
+#define VAL_BCSCTL2 (SELM_0 | DIVM_0 | DIVS_0)
+#endif
+
+/*
+ * Pin definitionsfor the Olimex MSP430-P1611 board.
+ */
+#define P3_O_TXD0 (1 << 4)
+#define P3_I_RXD0 (1 << 5)
+#define P6_O_LED (1 << 0)
+#define P6_I_BUTTON (1 << 1)
+
+/*
+ * Initial I/O ports settings.
+ */
+#define VAL_P1OUT 0x00
+#define VAL_P1DIR 0xFF
+#define VAL_P1SEL 0x00
+
+#define VAL_P2OUT 0x00
+#define VAL_P2DIR 0xFF
+#define VAL_P2SEL 0x00
+
+#define VAL_P3OUT P3_O_TXD0
+#define VAL_P3DIR ~P3_I_RXD0
+#define VAL_P3SEL 0x00
+
+#define VAL_P4OUT 0x00
+#define VAL_P4DIR 0xFF
+#define VAL_P4SEL 0x00
+
+#define VAL_P5OUT 0x00
+#define VAL_P5DIR 0xFF
+#define VAL_P5SEL 0x00
+
+#define VAL_P6OUT P6_O_LED
+#define VAL_P6DIR ~P6_I_BUTTON
+#define VAL_P6SEL 0x00
void hwinit(void);
diff --git a/demos/MSP430-MSP430x1611-GCC/main.c b/demos/MSP430-MSP430x1611-GCC/main.c
index c1d9c86bb..6790720ef 100644
--- a/demos/MSP430-MSP430x1611-GCC/main.c
+++ b/demos/MSP430-MSP430x1611-GCC/main.c
@@ -29,7 +29,9 @@ static WorkingArea(waThread1, 64);
static msg_t Thread1(void *arg) {
while (TRUE) {
+ P6OUT |= P6_O_LED;
chThdSleep(500);
+ P6OUT &= ~P6_O_LED;
chThdSleep(500);
}
return 0;
@@ -61,6 +63,8 @@ int main(int argc, char **argv) {
* sleeping in a loop.
*/
while (TRUE) {
+// if (!(P6IN & P6_I_BUTTON))
+// TestThread(&COM1);
chThdSleep(500);
}
return 0;
diff --git a/demos/MSP430-MSP430x1611-GCC/readme.txt b/demos/MSP430-MSP430x1611-GCC/readme.txt
index 5533287ff..0fd0c5a7b 100644
--- a/demos/MSP430-MSP430x1611-GCC/readme.txt
+++ b/demos/MSP430-MSP430x1611-GCC/readme.txt
@@ -4,11 +4,11 @@
** TARGET **
-This is an abstract demo. it is not tested on real hardware yet.
+The demo runs on an Olimex MSP430-P1611 board but it is still untested.
** The Demo **
-Creates a thread that just sleeps in a continuous loop.
+The demo flashes the board LED using a thread.
** Build Procedure **
diff --git a/ports/MSP430/chcore.c b/ports/MSP430/chcore.c
index 86765c675..b87953ef0 100644
--- a/ports/MSP430/chcore.c
+++ b/ports/MSP430/chcore.c
@@ -46,10 +46,12 @@ void chSysHalt(void) {
/**
* Context switch.
*/
+__attribute__((naked))
void chSysSwitchI(Thread *otp, Thread *ntp) {
register struct intctx *sp asm("r1");
- asm volatile ("push r11 \n\t" \
+ asm volatile ("push r2 \n\t" \
+ "push r11 \n\t" \
"push r10 \n\t" \
"push r9 \n\t" \
"push r8 \n\t" \
@@ -66,7 +68,8 @@ void chSysSwitchI(Thread *otp, Thread *ntp) {
"pop r8 \n\t" \
"pop r9 \n\t" \
"pop r10 \n\t" \
- "pop r11" : : "r" (sp));
+ "pop r11 \n\t" \
+ "reti" : : "r" (sp));
}
/**
@@ -77,8 +80,7 @@ void chSysPuts(char *msg) {
void threadstart(void) {
- asm volatile ("eint \n\t" \
- "mov r11, r15 \n\t" \
+ asm volatile ("mov r11, r15 \n\t" \
"call r10 \n\t" \
"call #chThdExit");
}
diff --git a/ports/MSP430/chcore.h b/ports/MSP430/chcore.h
index b6991baa2..3a9d587b8 100644
--- a/ports/MSP430/chcore.h
+++ b/ports/MSP430/chcore.h
@@ -20,6 +20,9 @@
#ifndef _CHCORE_H_
#define _CHCORE_H_
+#include <iomacros.h>
+#include <msp430/common.h>
+
#define CH_ARCHITECTURE_MSP430
typedef void *regmsp;
@@ -48,6 +51,7 @@ struct intctx {
regmsp r9;
regmsp r10;
regmsp r11;
+ regmsp sr;
regmsp pc;
};
@@ -61,6 +65,7 @@ typedef struct {
sizeof(struct intctx)); \
tp->p_ctx.sp->r10 = pf; \
tp->p_ctx.sp->r11 = arg; \
+ tp->p_ctx.sp->sr = (regmsp)GIE; \
tp->p_ctx.sp->pc = threadstart; \
}
diff --git a/readme.txt b/readme.txt
index c7b2a8b39..7c7a9d81f 100644
--- a/readme.txt
+++ b/readme.txt
@@ -43,8 +43,9 @@ AVR-AVRmega128-GCC - Port on AVRmega128. A special thanks to Vladimir for
the work done on the AVR port. The demo program
targets the Olimex AVR-MT-128 mini terminal board.
AVR-AT90CANx-GCC - Port on AVR AT90CAN128, not tested on hardware yet.
-MSP430-MSP430x1611-GCC - Port on Texas Instruments MSP430F1611, not tested on
- hardware yet, consider it work in progress.
+MSP430-MSP430x1611-GCC - Port on Texas Instruments MSP430F1611, the demo
+ targets the Olimex MSP430-P1611 board. It is not
+ tested on hardware yet, consider it work in progress.
Win32-MinGW - ChibiOS/RT simulator and demo into a WIN32 process,
MinGW version.
@@ -55,7 +56,7 @@ Win32-MinGW - ChibiOS/RT simulator and demo into a WIN32 process,
- Look into importing *or* implementing a TCP/IP stack and a File System.
- Evaluate other architectures for a possible ChibiOS/RT port. An important
selection parameter will be the availability of FOSS toolchains. Currently
- we are evaluating the MSP430 and the MicroBlaze.
+ we are evaluating the MicroBlaze.
- Creation of a reduced ChibiOS/RT kernel targeted to lesser 8bit micros and
educational purposes, the name will probably be ChibiOS/SX, we are still
discussing it.