From 6ab7ea31f114af0e0d98494156d456279dd5ecd4 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 14 Jun 2009 13:10:38 +0000 Subject: PAL support for MSP430, various other fixes. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1037 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/MSP430-MSP430x1611-GCC/board.c | 36 +++++++++++++++++------------------- demos/MSP430-MSP430x1611-GCC/board.h | 36 ++++++++++++++++++++---------------- demos/MSP430-MSP430x1611-GCC/main.c | 7 ++++--- 3 files changed, 41 insertions(+), 38 deletions(-) (limited to 'demos') diff --git a/demos/MSP430-MSP430x1611-GCC/board.c b/demos/MSP430-MSP430x1611-GCC/board.c index 794070803..c94b4141b 100644 --- a/demos/MSP430-MSP430x1611-GCC/board.c +++ b/demos/MSP430-MSP430x1611-GCC/board.c @@ -18,6 +18,8 @@ */ #include +#include + #include #include "board.h" @@ -45,31 +47,27 @@ void hwinit(void) { BCSCTL2 = VAL_BCSCTL2; /* - * I/O ports initialization. + * I/O ports initialization. PxSEL registers are assumed to be cleared after + * the reset. */ - P1OUT = VAL_P1OUT; - P1DIR = VAL_P1DIR; - P1SEL = VAL_P1SEL; + palInit(); + palWritePort(IOPORT_A, VAL_P1OUT); + pal_lld_msp430_set_direction(IOPORT_A, VAL_P1DIR); - P2OUT = VAL_P2OUT; - P2DIR = VAL_P2DIR; - P2SEL = VAL_P2SEL; + palWritePort(IOPORT_B, VAL_P2OUT); + pal_lld_msp430_set_direction(IOPORT_B, VAL_P2DIR); - P3OUT = VAL_P3OUT; - P3DIR = VAL_P3DIR; - P3SEL = VAL_P3SEL; + palWritePort(IOPORT_C, VAL_P3OUT); + pal_lld_msp430_set_direction(IOPORT_C, VAL_P3DIR); - P4OUT = VAL_P4OUT; - P4DIR = VAL_P4DIR; - P4SEL = VAL_P4SEL; + palWritePort(IOPORT_D, VAL_P4OUT); + pal_lld_msp430_set_direction(IOPORT_D, VAL_P4DIR); - P5OUT = VAL_P5OUT; - P5DIR = VAL_P5DIR; - P5SEL = VAL_P5SEL; + palWritePort(IOPORT_E, VAL_P5OUT); + pal_lld_msp430_set_direction(IOPORT_E, VAL_P5DIR); - P6OUT = VAL_P6OUT; - P6DIR = VAL_P6DIR; - P6SEL = VAL_P6SEL; + palWritePort(IOPORT_F, VAL_P6OUT); + pal_lld_msp430_set_direction(IOPORT_F, VAL_P6DIR); /* * Timer 0 setup, uses SMCLK as source. diff --git a/demos/MSP430-MSP430x1611-GCC/board.h b/demos/MSP430-MSP430x1611-GCC/board.h index f7173f712..235a8303a 100644 --- a/demos/MSP430-MSP430x1611-GCC/board.h +++ b/demos/MSP430-MSP430x1611-GCC/board.h @@ -58,40 +58,44 @@ #endif /* - * Pin definitionsfor the Olimex MSP430-P1611 board. + * Pin definitions for 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) +#define P3_O_TXD0 4 +#define P3_O_TXD0_MASK (1 << P3_O_TXD0) +#define P3_I_RXD0 5 +#define P3_I_RXD0_MASK (1 << P3_I_RXD0) +#define P6_O_LED 0 +#define P6_O_LED_MASK (1 << P6_O_LED) +#define P6_I_BUTTON 1 +#define P6_I_BUTTON_MASK (1 << P6_I_BUTTON) /* * 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_P3OUT P3_O_TXD0_MASK +#define VAL_P3DIR ~P3_I_RXD0_MASK #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 +#define VAL_P6OUT P6_O_LED_MASK +#define VAL_P6DIR ~P6_I_BUTTON_MASK -void hwinit(void); +#ifdef __cplusplus +extern "C" { +#endif + void hwinit(void); +#ifdef __cplusplus +} +#endif #endif /* _BOARD_H_ */ diff --git a/demos/MSP430-MSP430x1611-GCC/main.c b/demos/MSP430-MSP430x1611-GCC/main.c index 4bc7d9895..2f9f6d8b9 100644 --- a/demos/MSP430-MSP430x1611-GCC/main.c +++ b/demos/MSP430-MSP430x1611-GCC/main.c @@ -18,6 +18,7 @@ */ #include +#include #include #include "board.h" @@ -30,9 +31,9 @@ static WORKING_AREA(waThread1, 64); static msg_t Thread1(void *arg) { while (TRUE) { - P6OUT |= P6_O_LED; + palSetPad(IOPORT_F, P6_O_LED); chThdSleepMilliseconds(500); - P6OUT &= ~P6_O_LED; + palClearPad(IOPORT_F, P6_O_LED); chThdSleepMilliseconds(500); } return 0; @@ -64,7 +65,7 @@ int main(int argc, char **argv) { * sleeping in a loop. */ while (TRUE) { - if (!(P6IN & P6_I_BUTTON)) + if (!palReadPad(IOPORT_F, P6_I_BUTTON)) TestThread(&COM1); chThdSleepMilliseconds(500); } -- cgit v1.2.3