aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2009-07-04 14:05:29 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2009-07-04 14:05:29 +0000
commit979da150361becdb50625d056915f81099710122 (patch)
tree0a97e0193abf096411c5dc7ee25f9d34ca4502f9
parent40b2d98d866cf7f779855160fb4fe1bed6428f8c (diff)
downloadChibiOS-979da150361becdb50625d056915f81099710122.tar.gz
ChibiOS-979da150361becdb50625d056915f81099710122.tar.bz2
ChibiOS-979da150361becdb50625d056915f81099710122.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1055 35acf78f-673a-0410-8e92-d51de3d6d3f4
-rw-r--r--demos/ARM7-LPC214x-GCC-minimal/Makefile1
-rw-r--r--demos/ARM7-LPC214x-GCC-minimal/board.c28
-rw-r--r--demos/ARM7-LPC214x-GCC-minimal/board.h2
-rw-r--r--demos/ARMCM3-STM32F103-GCC/board.c8
-rw-r--r--ports/ARM7-LPC214x/pal_lld.c19
-rw-r--r--ports/ARM7-LPC214x/pal_lld.h43
6 files changed, 83 insertions, 18 deletions
diff --git a/demos/ARM7-LPC214x-GCC-minimal/Makefile b/demos/ARM7-LPC214x-GCC-minimal/Makefile
index 2ea142e81..a00eb9c65 100644
--- a/demos/ARM7-LPC214x-GCC-minimal/Makefile
+++ b/demos/ARM7-LPC214x-GCC-minimal/Makefile
@@ -50,6 +50,7 @@ include ../../src/kernel.mk
# setting.
CSRC = ../../ports/ARM7/chcore.c \
../../ports/ARM7-LPC214x/vic.c \
+ ../../ports/ARM7-LPC214x/pal_lld.c \
${KERNSRC} \
board.c main.c
diff --git a/demos/ARM7-LPC214x-GCC-minimal/board.c b/demos/ARM7-LPC214x-GCC-minimal/board.c
index 2e56028cc..980626ab5 100644
--- a/demos/ARM7-LPC214x-GCC-minimal/board.c
+++ b/demos/ARM7-LPC214x-GCC-minimal/board.c
@@ -59,6 +59,18 @@ static CH_IRQ_HANDLER(T0IrqHandler) {
}
/*
+ * Digital I/O ports static configuration as defined in @p board.h.
+ */
+static const LPC214xFIOConfig config =
+{
+ VAL_PINSEL0,
+ VAL_PINSEL1,
+ VAL_PINSEL2,
+ {VAL_FIO0PIN, VAL_FIO0DIR},
+ {VAL_FIO1PIN, VAL_FIO1DIR}
+};
+
+/*
* Early initialization code.
* This initialization is performed just after reset before BSS and DATA
* segments initialization.
@@ -101,14 +113,14 @@ void hwinit0(void) {
/*
* I/O pins configuration.
*/
- PINSEL0 = VAL_PINSEL0;
- PINSEL1 = VAL_PINSEL1;
- PINSEL2 = VAL_PINSEL2;
- palInit();
- pal_lld_lpc214x_set_direction(IOPORT_A, VAL_FIO0DIR);
- palWritePort(IOPORT_A, 0xFFFFFFFF);
- pal_lld_lpc214x_set_direction(IOPORT_B, VAL_FIO1DIR);
- palWritePort(IOPORT_B, 0xFFFFFFFF);
+// PINSEL0 = VAL_PINSEL0;
+// PINSEL1 = VAL_PINSEL1;
+// PINSEL2 = VAL_PINSEL2;
+ palInit(&config);
+// pal_lld_lpc214x_set_direction(IOPORT_A, VAL_FIO0DIR);
+// palWritePort(IOPORT_A, 0xFFFFFFFF);
+// pal_lld_lpc214x_set_direction(IOPORT_B, VAL_FIO1DIR);
+// palWritePort(IOPORT_B, 0xFFFFFFFF);
}
/*
diff --git a/demos/ARM7-LPC214x-GCC-minimal/board.h b/demos/ARM7-LPC214x-GCC-minimal/board.h
index fee4baa61..ab4aa76f6 100644
--- a/demos/ARM7-LPC214x-GCC-minimal/board.h
+++ b/demos/ARM7-LPC214x-GCC-minimal/board.h
@@ -64,6 +64,8 @@
#define VAL_PINSEL2 0x00000004
#define VAL_FIO0DIR 0xB0703C00
#define VAL_FIO1DIR 0x00000000
+#define VAL_FIO0PIN 0x00000000
+#define VAL_FIO1PIN 0x00000000
#define PA_LED1 10
#define PA_LED2 11
diff --git a/demos/ARMCM3-STM32F103-GCC/board.c b/demos/ARMCM3-STM32F103-GCC/board.c
index 34349b827..0f6c5be6b 100644
--- a/demos/ARMCM3-STM32F103-GCC/board.c
+++ b/demos/ARMCM3-STM32F103-GCC/board.c
@@ -29,10 +29,10 @@
*/
static const STM32GPIOConfig config =
{
- {VAL_GPIOAODR, VAL_GPIOACRL, VAL_GPIOACRH},
- {VAL_GPIOBODR, VAL_GPIOBCRL, VAL_GPIOBCRH},
- {VAL_GPIOCODR, VAL_GPIOCCRL, VAL_GPIOCCRH},
- {VAL_GPIODODR, VAL_GPIODCRL, VAL_GPIODCRH},
+ {VAL_GPIOAODR, VAL_GPIOACRL, VAL_GPIOACRH},
+ {VAL_GPIOBODR, VAL_GPIOBCRL, VAL_GPIOBCRH},
+ {VAL_GPIOCODR, VAL_GPIOCCRL, VAL_GPIOCCRH},
+ {VAL_GPIODODR, VAL_GPIODCRL, VAL_GPIODCRH},
};
/*
diff --git a/ports/ARM7-LPC214x/pal_lld.c b/ports/ARM7-LPC214x/pal_lld.c
index 3c06f39ce..3d300bb55 100644
--- a/ports/ARM7-LPC214x/pal_lld.c
+++ b/ports/ARM7-LPC214x/pal_lld.c
@@ -29,11 +29,28 @@
/**
* @brief LPC214x I/O ports configuration.
- * @details Ports A-D clocks enabled, AFIO clock enabled.
+ * @details .
*
* @param[in] config the LPC214x ports configuration
*/
void _pal_lld_init(const LPC214xFIOConfig *config) {
+
+ /* Enables the access through the fast registers.*/
+ SCS = 3;
+
+ /* I/O pads initial assignment, device drivers may change this setup at a
+ * later time.*/
+ PINSEL0 = config->pinsel0;
+ PINSEL1 = config->pinsel1;
+ PINSEL2 = config->pinsel2;
+
+ /* I/O pads direction initial setting.*/
+ FIO0Base->FIO_MASK = 0;
+ FIO0Base->FIO_PIN = config->P0Data.pin;
+ FIO0Base->FIO_DIR = config->P0Data.dir;
+ FIO1Base->FIO_MASK = 0;
+ FIO1Base->FIO_PIN = config->P1Data.pin;
+ FIO1Base->FIO_DIR = config->P1Data.dir;
}
/**
diff --git a/ports/ARM7-LPC214x/pal_lld.h b/ports/ARM7-LPC214x/pal_lld.h
index bb0f2efac..2bbb0676b 100644
--- a/ports/ARM7-LPC214x/pal_lld.h
+++ b/ports/ARM7-LPC214x/pal_lld.h
@@ -44,6 +44,16 @@
/*===========================================================================*/
/**
+ * @brief FIO port setup info.
+ */
+typedef struct {
+ /** Initial value for FIO_PIN register.*/
+ uint32_t pin;
+ /** Initial value for FIO_DIR register.*/
+ uint32_t dir;
+} lpc214x_fio_setup_t;
+
+/**
* @brief LPC214x FIO static initializer.
* @details An instance of this structure must be passed to @p palInit() at
* system startup time in order to initialized the digital I/O
@@ -51,10 +61,16 @@
* or whole ports can be reprogrammed at later time.
*/
typedef struct {
+ /** @brief PINSEL0 initial value.*/
+ uint32_t pinsel0;
+ /** @brief PINSEL1 initial value.*/
+ uint32_t pinsel1;
+ /** @brief PINSEL2 initial value.*/
+ uint32_t pinsel2;
/** @brief Port 0 setup data.*/
- ioportmask_t P0Data;
+ lpc214x_fio_setup_t P0Data;
/** @brief Port 1 setup data.*/
- ioportmask_t P1Data;
+ lpc214x_fio_setup_t P1Data;
} LPC214xFIOConfig;
/**
@@ -95,9 +111,7 @@ typedef FIO * ioportid_t;
* @brief FIO subsystem initialization.
* @details Enables the access through the fast registers.
*/
-#define pal_lld_init() { \
- SCS = 3; \
-}
+#define pal_lld_init(config) _pal_lld_init(config)
/**
* @brief Reads an I/O port.
@@ -186,6 +200,25 @@ typedef FIO * ioportid_t;
}
/**
+ * @brief Pads group mode setup.
+ * @details This function programs a pads group belonging to the same port
+ * with the specified mode.
+ *
+ * @param[in] port the port identifier
+ * @param[in] mask the group mask
+ * @param[in] mode the mode
+ *
+ * @note This function is not meant to be invoked directly by the application
+ * code.
+ * @note @p PAL_MODE_UNCONNECTED is implemented as output as recommended by
+ * the MSP430x1xx Family User's Guide.
+ * @note This function does not alter the @p PxSEL registers. Alternate
+ * functions setup must be handled by device-specific code.
+ */
+#define pal_lld_setgroupmode(port, mask, mode) \
+ _pal_lld_setgroupmode(port, mask, mode)
+
+/**
* @brief Writes a logical state on an output pad.
*
* @param[in] port the port identifier