aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2009-06-07 17:53:23 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2009-06-07 17:53:23 +0000
commitbe1e6b03d4a49b6fa16c3368435089f8706fb566 (patch)
treeea4aca882019de105a00451e379ca55955c38dfb
parentb2e6f6a6a5ee0af322472c151565be6cba0e1fa0 (diff)
downloadChibiOS-be1e6b03d4a49b6fa16c3368435089f8706fb566.tar.gz
ChibiOS-be1e6b03d4a49b6fa16c3368435089f8706fb566.tar.bz2
ChibiOS-be1e6b03d4a49b6fa16c3368435089f8706fb566.zip
Adjusted PAL support for LPC214x.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1026 35acf78f-673a-0410-8e92-d51de3d6d3f4
-rw-r--r--demos/ARM7-LPC214x-G++/board.c11
-rw-r--r--demos/ARM7-LPC214x-G++/board.h26
-rw-r--r--demos/ARM7-LPC214x-G++/main.cpp22
-rw-r--r--demos/ARM7-LPC214x-GCC-minimal/board.h5
-rw-r--r--demos/ARM7-LPC214x-GCC/Makefile1
-rw-r--r--demos/ARM7-LPC214x-GCC/board.c11
-rw-r--r--demos/ARM7-LPC214x-GCC/board.h26
-rw-r--r--demos/ARM7-LPC214x-GCC/main.c23
-rw-r--r--demos/ARM7-LPC214x-GCC/mmcsd.c5
-rw-r--r--docs/src/main.dox62
-rw-r--r--ports/ARM7-LPC214x/lpc214x_ssp.c6
11 files changed, 100 insertions, 98 deletions
diff --git a/demos/ARM7-LPC214x-G++/board.c b/demos/ARM7-LPC214x-G++/board.c
index f188372b3..c3c39a5a9 100644
--- a/demos/ARM7-LPC214x-G++/board.c
+++ b/demos/ARM7-LPC214x-G++/board.c
@@ -18,6 +18,7 @@
*/
#include <ch.h>
+#include <pal.h>
#include "lpc214x.h"
#include "vic.h"
@@ -103,11 +104,11 @@ void hwinit0(void) {
PINSEL0 = VAL_PINSEL0;
PINSEL1 = VAL_PINSEL1;
PINSEL2 = VAL_PINSEL2;
- ioport_init_lld();
- ioport_lpc214x_set_direction_lld(IOPORT_A, VAL_FIO0DIR);
- ioport_write_lld(IOPORT_A, 0xFFFFFFFF);
- ioport_lpc214x_set_direction_lld(IOPORT_B, VAL_FIO1DIR);
- ioport_write_lld(IOPORT_B, 0xFFFFFFFF);
+ 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);
}
/*
diff --git a/demos/ARM7-LPC214x-G++/board.h b/demos/ARM7-LPC214x-G++/board.h
index ee30559c8..fee4baa61 100644
--- a/demos/ARM7-LPC214x-G++/board.h
+++ b/demos/ARM7-LPC214x-G++/board.h
@@ -24,10 +24,6 @@
#include "lpc214x.h"
#endif
-#ifndef _IOPORTS_LLD_H_
-#include "ioports.h"
-#endif
-
#define BOARD_OLIMEX_LCP_P2148
/*
@@ -69,17 +65,17 @@
#define VAL_FIO0DIR 0xB0703C00
#define VAL_FIO1DIR 0x00000000
-#define PA_LED1 IOPORT_BIT(10)
-#define PA_LED2 IOPORT_BIT(11)
-#define PA_BUZZ1 IOPORT_BIT(12)
-#define PA_BUZZ2 IOPORT_BIT(13)
-#define PA_BSL IOPORT_BIT(14)
-#define PA_BUTTON1 IOPORT_BIT(15)
-#define PA_BUTTON2 IOPORT_BIT(16)
-#define PA_SSEL1 IOPORT_BIT(20)
-#define PA_LEDUSB IOPORT_BIT(31)
+#define PA_LED1 10
+#define PA_LED2 11
+#define PA_BUZZ1 12
+#define PA_BUZZ2 13
+#define PA_BSL 14
+#define PA_BUTTON1 15
+#define PA_BUTTON2 16
+#define PA_SSEL1 20
+#define PA_LEDUSB 31
-#define PB_WP1 IOPORT_BIT(24)
-#define PB_CP1 IOPORT_BIT(25)
+#define PB_WP1 24
+#define PB_CP1 25
#endif /* _BOARD_H_ */
diff --git a/demos/ARM7-LPC214x-G++/main.cpp b/demos/ARM7-LPC214x-G++/main.cpp
index 1a50f5936..683c2675d 100644
--- a/demos/ARM7-LPC214x-G++/main.cpp
+++ b/demos/ARM7-LPC214x-G++/main.cpp
@@ -18,7 +18,7 @@
*/
#include <ch.hpp>
-#include <ioports.h>
+#include <pal.h>
#include <evtimer.h>
#include <test.h>
@@ -26,6 +26,8 @@
#include <board.h>
#include <lpc214x_serial.h>
+#define BOTH_BUTTONS (PAL_PORT_BIT(PA_BUTTON1) | PAL_PORT_BIT(PA_BUTTON2))
+
using namespace chibios_rt;
/*
@@ -48,9 +50,9 @@ typedef struct {
// Flashing sequence for LED1.
static const seqop_t LED1_sequence[] =
{
- {BITCLEAR, PA_LED1},
+ {BITCLEAR, PAL_PORT_BIT(PA_LED1)},
{SLEEP, 200},
- {BITSET, PA_LED1},
+ {BITSET, PAL_PORT_BIT(PA_LED1)},
{SLEEP, 1800},
{GOTO, 0}
};
@@ -59,9 +61,9 @@ static const seqop_t LED1_sequence[] =
static const seqop_t LED2_sequence[] =
{
{SLEEP, 1000},
- {BITCLEAR, PA_LED2},
+ {BITCLEAR, PAL_PORT_BIT(PA_LED2)},
{SLEEP, 200},
- {BITSET, PA_LED2},
+ {BITSET, PAL_PORT_BIT(PA_LED2)},
{SLEEP, 1800},
{GOTO, 1}
};
@@ -69,9 +71,9 @@ static const seqop_t LED2_sequence[] =
// Flashing sequence for LED3.
static const seqop_t LED3_sequence[] =
{
- {BITCLEAR, PA_LEDUSB},
+ {BITCLEAR, PAL_PORT_BIT(PA_LEDUSB)},
{SLEEP, 200},
- {BITSET, PA_LEDUSB},
+ {BITSET, PAL_PORT_BIT(PA_LEDUSB)},
{SLEEP, 300},
{GOTO, 0}
};
@@ -98,10 +100,10 @@ protected:
case STOP:
return 0;
case BITCLEAR:
- chPortClear(IOPORT_A, curr->value);
+ palClearPort(IOPORT_A, curr->value);
break;
case BITSET:
- chPortSet(IOPORT_A, curr->value);
+ palSetPort(IOPORT_A, curr->value);
break;
}
curr++;
@@ -136,7 +138,7 @@ public:
*/
static void TimerHandler(eventid_t id) {
- if (!(chPortRead(IOPORT_A) & (PA_BUTTON1 | PA_BUTTON2))) { // Both buttons
+ if (!(palReadPort(IOPORT_A) & BOTH_BUTTONS)) { // Both buttons
TesterThread tester;
tester.Wait();
};
diff --git a/demos/ARM7-LPC214x-GCC-minimal/board.h b/demos/ARM7-LPC214x-GCC-minimal/board.h
index 8cee52946..fee4baa61 100644
--- a/demos/ARM7-LPC214x-GCC-minimal/board.h
+++ b/demos/ARM7-LPC214x-GCC-minimal/board.h
@@ -73,8 +73,9 @@
#define PA_BUTTON1 15
#define PA_BUTTON2 16
#define PA_SSEL1 20
-#define PA_WP1 24
-#define PA_CP1 25
#define PA_LEDUSB 31
+#define PB_WP1 24
+#define PB_CP1 25
+
#endif /* _BOARD_H_ */
diff --git a/demos/ARM7-LPC214x-GCC/Makefile b/demos/ARM7-LPC214x-GCC/Makefile
index 6b3620e8a..c7bf868ef 100644
--- a/demos/ARM7-LPC214x-GCC/Makefile
+++ b/demos/ARM7-LPC214x-GCC/Makefile
@@ -55,6 +55,7 @@ CSRC = ../../ports/ARM7/chcore.c \
${KERNSRC} \
${TESTSRC} \
../../src/lib/evtimer.c \
+ ../../src/lib/pal.c \
board.c buzzer.c mmcsd.c main.c
# C++ sources that can be compiled in ARM or THUMB mode depending on the global
diff --git a/demos/ARM7-LPC214x-GCC/board.c b/demos/ARM7-LPC214x-GCC/board.c
index e1bf9369f..9eec8b06d 100644
--- a/demos/ARM7-LPC214x-GCC/board.c
+++ b/demos/ARM7-LPC214x-GCC/board.c
@@ -18,6 +18,7 @@
*/
#include <ch.h>
+#include <pal.h>
#include "lpc214x.h"
#include "vic.h"
@@ -103,11 +104,11 @@ void hwinit0(void) {
PINSEL0 = VAL_PINSEL0;
PINSEL1 = VAL_PINSEL1;
PINSEL2 = VAL_PINSEL2;
- ioport_init_lld();
- ioport_lpc214x_set_direction_lld(IOPORT_A, VAL_FIO0DIR);
- ioport_write_lld(IOPORT_A, 0xFFFFFFFF);
- ioport_lpc214x_set_direction_lld(IOPORT_B, VAL_FIO1DIR);
- ioport_write_lld(IOPORT_B, 0xFFFFFFFF);
+ 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);
}
/*
diff --git a/demos/ARM7-LPC214x-GCC/board.h b/demos/ARM7-LPC214x-GCC/board.h
index ee30559c8..fee4baa61 100644
--- a/demos/ARM7-LPC214x-GCC/board.h
+++ b/demos/ARM7-LPC214x-GCC/board.h
@@ -24,10 +24,6 @@
#include "lpc214x.h"
#endif
-#ifndef _IOPORTS_LLD_H_
-#include "ioports.h"
-#endif
-
#define BOARD_OLIMEX_LCP_P2148
/*
@@ -69,17 +65,17 @@
#define VAL_FIO0DIR 0xB0703C00
#define VAL_FIO1DIR 0x00000000
-#define PA_LED1 IOPORT_BIT(10)
-#define PA_LED2 IOPORT_BIT(11)
-#define PA_BUZZ1 IOPORT_BIT(12)
-#define PA_BUZZ2 IOPORT_BIT(13)
-#define PA_BSL IOPORT_BIT(14)
-#define PA_BUTTON1 IOPORT_BIT(15)
-#define PA_BUTTON2 IOPORT_BIT(16)
-#define PA_SSEL1 IOPORT_BIT(20)
-#define PA_LEDUSB IOPORT_BIT(31)
+#define PA_LED1 10
+#define PA_LED2 11
+#define PA_BUZZ1 12
+#define PA_BUZZ2 13
+#define PA_BSL 14
+#define PA_BUTTON1 15
+#define PA_BUTTON2 16
+#define PA_SSEL1 20
+#define PA_LEDUSB 31
-#define PB_WP1 IOPORT_BIT(24)
-#define PB_CP1 IOPORT_BIT(25)
+#define PB_WP1 24
+#define PB_CP1 25
#endif /* _BOARD_H_ */
diff --git a/demos/ARM7-LPC214x-GCC/main.c b/demos/ARM7-LPC214x-GCC/main.c
index 3eafdba61..61ad4ea77 100644
--- a/demos/ARM7-LPC214x-GCC/main.c
+++ b/demos/ARM7-LPC214x-GCC/main.c
@@ -18,6 +18,7 @@
*/
#include <ch.h>
+#include <pal.h>
#include <test.h>
#include "board.h"
@@ -26,6 +27,8 @@
#include "buzzer.h"
#include "evtimer.h"
+#define BOTH_BUTTONS (PAL_PORT_BIT(PA_BUTTON1) | PAL_PORT_BIT(PA_BUTTON2))
+
/*
* Red LEDs blinker thread, times are in milliseconds.
*/
@@ -33,13 +36,13 @@ static WORKING_AREA(waThread1, 128);
static msg_t Thread1(void *arg) {
while (TRUE) {
- chPortClear(IOPORT_A, PA_LED2);
+ palClearPort(IOPORT_A, PAL_PORT_BIT(PA_LED2));
chThdSleepMilliseconds(200);
- chPortSet(IOPORT_A, PA_LED1 | PA_LED2);
+ palSetPort(IOPORT_A, PAL_PORT_BIT(PA_LED1) | PAL_PORT_BIT(PA_LED2));
chThdSleepMilliseconds(800);
- chPortClear(IOPORT_A, PA_LED1);
+ palClearPort(IOPORT_A, PAL_PORT_BIT(PA_LED1));
chThdSleepMilliseconds(200);
- chPortSet(IOPORT_A, PA_LED1 | PA_LED2);
+ palSetPort(IOPORT_A, PAL_PORT_BIT(PA_LED1) | PAL_PORT_BIT(PA_LED2));
chThdSleepMilliseconds(800);
}
return 0;
@@ -52,9 +55,9 @@ static WORKING_AREA(waThread2, 128);
static msg_t Thread2(void *arg) {
while (TRUE) {
- chPortClear(IOPORT_A, PA_LEDUSB);
+ palClearPad(IOPORT_A, PA_LEDUSB);
chThdSleepMilliseconds(200);
- chPortSet(IOPORT_A, PA_LEDUSB);
+ palSetPad(IOPORT_A, PA_LEDUSB);
chThdSleepMilliseconds(300);
}
return 0;
@@ -67,16 +70,16 @@ static WORKING_AREA(waTestThread, 128);
*/
static void TimerHandler(eventid_t id) {
- if (!(chPortRead(IOPORT_A) & (PA_BUTTON1 | PA_BUTTON2))) {
+ if (!(palReadPort(IOPORT_A) & BOTH_BUTTONS)) {
Thread *tp = chThdCreateStatic(waTestThread, sizeof(waTestThread),
NORMALPRIO, TestThread, &COM1);
chThdWait(tp);
PlaySound(500, MS2ST(100));
}
else {
- if (!(chPortRead(IOPORT_A) & PA_BUTTON1))
+ if (!palReadPad(IOPORT_A, PA_BUTTON1))
PlaySound(1000, MS2ST(100));
- if (!(chPortRead(IOPORT_A) & PA_BUTTON2)) {
+ if (!palReadPad(IOPORT_A, PA_BUTTON2)) {
chFDDWrite(&COM1, (uint8_t *)"Hello World!\r\n", 14);
PlaySound(2000, MS2ST(100));
}
@@ -129,7 +132,7 @@ int main(int argc, char **argv) {
* If a button is pressed during the reset then the blinking leds threads
* are not started in order to make accurate benchmarks.
*/
- if (chPortRead(IOPORT_A) && (PA_BUTTON1 | PA_BUTTON2) == (PA_BUTTON1 | PA_BUTTON2)) {
+ if ((palReadPort(IOPORT_A) & BOTH_BUTTONS) == BOTH_BUTTONS) {
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
chThdCreateStatic(waThread2, sizeof(waThread2), NORMALPRIO, Thread2, NULL);
}
diff --git a/demos/ARM7-LPC214x-GCC/mmcsd.c b/demos/ARM7-LPC214x-GCC/mmcsd.c
index bff2967d9..98ff2a23b 100644
--- a/demos/ARM7-LPC214x-GCC/mmcsd.c
+++ b/demos/ARM7-LPC214x-GCC/mmcsd.c
@@ -18,6 +18,7 @@
*/
#include <ch.h>
+#include <pal.h>
#include "board.h"
#include "lpc214x_ssp.h"
@@ -42,7 +43,7 @@ void InitMMC(void) {
void tmrfunc(void *par) {
if (cnt) {
- if (!(chPortRead(IOPORT_B) & PB_CP1)) {
+ if (!palReadPad(IOPORT_B, PB_CP1)) {
if (!--cnt)
chEvtBroadcastI(&MMCInsertEventSource);
}
@@ -50,7 +51,7 @@ void tmrfunc(void *par) {
cnt = POLLING_INTERVAL;
}
else {
- if (chPortRead(IOPORT_B) & PB_CP1) {
+ if (palReadPad(IOPORT_B, PB_CP1)) {
cnt = POLLING_INTERVAL;
chEvtBroadcastI(&MMCRemoveEventSource);
}
diff --git a/docs/src/main.dox b/docs/src/main.dox
index 3a38d7115..fecca64f9 100644
--- a/docs/src/main.dox
+++ b/docs/src/main.dox
@@ -165,37 +165,6 @@
*/
/**
- * @defgroup Memory Memory Management
- * Memory Management services.
- */
-
-/**
- * @defgroup Heap Heap
- * Heap Allocator related APIs.
- * <h2>Operation mode</h2>
- * The heap allocator implements a first-fit strategy and its APIs are
- * functionally equivalent to the usual @p malloc() and @p free(). The main
- * difference is that the heap APIs are thread safe.<br>
- * By enabling the @p CH_USE_MALLOC_HEAP option the heap manager will use the
- * runtime-provided @p malloc() and @p free() as backend for the heap APIs
- * instead of the system provided allocator.<br>
- * In order to use the heap APIs the @p CH_USE_HEAP option must be specified
- * in @p chconf.h.
- * @ingroup Memory
- */
-
-/**
- * @defgroup MemoryPools Memory Pools
- * Memory Pools related APIs.
- * <h2>Operation mode</h2>
- * The Memory Pools APIs allow to allocate/free fixed size objects in
- * <b>constant time</b> and reliably without memory fragmentation problems.<br>
- * In order to use the Time APIs the @p CH_USE_MEMPOOLS option must be
- * specified in @p chconf.h.
- * @ingroup Memory
- */
-
-/**
* @defgroup Synchronization Synchronization
* Synchronization services.
*/
@@ -345,6 +314,37 @@
*/
/**
+ * @defgroup Memory Memory Management
+ * Memory Management services.
+ */
+
+/**
+ * @defgroup Heap Heap
+ * Heap Allocator related APIs.
+ * <h2>Operation mode</h2>
+ * The heap allocator implements a first-fit strategy and its APIs are
+ * functionally equivalent to the usual @p malloc() and @p free(). The main
+ * difference is that the heap APIs are thread safe.<br>
+ * By enabling the @p CH_USE_MALLOC_HEAP option the heap manager will use the
+ * runtime-provided @p malloc() and @p free() as backend for the heap APIs
+ * instead of the system provided allocator.<br>
+ * In order to use the heap APIs the @p CH_USE_HEAP option must be specified
+ * in @p chconf.h.
+ * @ingroup Memory
+ */
+
+/**
+ * @defgroup MemoryPools Memory Pools
+ * Memory Pools related APIs.
+ * <h2>Operation mode</h2>
+ * The Memory Pools APIs allow to allocate/free fixed size objects in
+ * <b>constant time</b> and reliably without memory fragmentation problems.<br>
+ * In order to use the Time APIs the @p CH_USE_MEMPOOLS option must be
+ * specified in @p chconf.h.
+ * @ingroup Memory
+ */
+
+/**
* @defgroup IO I/O Support
* @brief I/O related services.
* @details This section contains the I/O related services. Note that no
diff --git a/ports/ARM7-LPC214x/lpc214x_ssp.c b/ports/ARM7-LPC214x/lpc214x_ssp.c
index 00db41cbf..790182576 100644
--- a/ports/ARM7-LPC214x/lpc214x_ssp.c
+++ b/ports/ARM7-LPC214x/lpc214x_ssp.c
@@ -25,7 +25,7 @@
*/
#include <ch.h>
-#include <ioports.h>
+#include <pal.h>
#include "lpc214x.h"
#include "lpc214x_ssp.h"
@@ -44,7 +44,7 @@ void sspAcquireBus(void) {
#if LPC214x_SSP_USE_MUTEX
chSemWait(&me);
#endif
- chPortClear(IOPORT_A, (1 << 20));
+ palClearPad(IOPORT_A, 20);
}
/**
@@ -54,7 +54,7 @@ void sspAcquireBus(void) {
*/
void sspReleaseBus(void) {
- chPortSet(IOPORT_A, (1 << 20));
+ palClearPad(IOPORT_A, 20);
#if LPC214x_SSP_USE_MUTEX
chSemSignal(&me);
#endif