git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@285 35acf78f-673a-0410-8e92-d51de3d6d3f4

master
gdisirio 2008-05-08 10:12:19 +00:00
parent 3f9aac327b
commit 83bbc0a6c6
7 changed files with 109 additions and 13 deletions

View File

@ -28,14 +28,44 @@
*/
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. */

View File

@ -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);

View File

@ -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;

View File

@ -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 **

View File

@ -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");
}

View File

@ -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; \
}

View File

@ -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.