Adjusted PAL support for LPC214x.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1026 35acf78f-673a-0410-8e92-d51de3d6d3f4
master
gdisirio 2009-06-07 17:53:23 +00:00
parent b2e6f6a6a5
commit be1e6b03d4
11 changed files with 100 additions and 98 deletions

View File

@ -18,6 +18,7 @@
*/ */
#include <ch.h> #include <ch.h>
#include <pal.h>
#include "lpc214x.h" #include "lpc214x.h"
#include "vic.h" #include "vic.h"
@ -103,11 +104,11 @@ void hwinit0(void) {
PINSEL0 = VAL_PINSEL0; PINSEL0 = VAL_PINSEL0;
PINSEL1 = VAL_PINSEL1; PINSEL1 = VAL_PINSEL1;
PINSEL2 = VAL_PINSEL2; PINSEL2 = VAL_PINSEL2;
ioport_init_lld(); palInit();
ioport_lpc214x_set_direction_lld(IOPORT_A, VAL_FIO0DIR); pal_lld_lpc214x_set_direction(IOPORT_A, VAL_FIO0DIR);
ioport_write_lld(IOPORT_A, 0xFFFFFFFF); palWritePort(IOPORT_A, 0xFFFFFFFF);
ioport_lpc214x_set_direction_lld(IOPORT_B, VAL_FIO1DIR); pal_lld_lpc214x_set_direction(IOPORT_B, VAL_FIO1DIR);
ioport_write_lld(IOPORT_B, 0xFFFFFFFF); palWritePort(IOPORT_B, 0xFFFFFFFF);
} }
/* /*

View File

@ -24,10 +24,6 @@
#include "lpc214x.h" #include "lpc214x.h"
#endif #endif
#ifndef _IOPORTS_LLD_H_
#include "ioports.h"
#endif
#define BOARD_OLIMEX_LCP_P2148 #define BOARD_OLIMEX_LCP_P2148
/* /*
@ -69,17 +65,17 @@
#define VAL_FIO0DIR 0xB0703C00 #define VAL_FIO0DIR 0xB0703C00
#define VAL_FIO1DIR 0x00000000 #define VAL_FIO1DIR 0x00000000
#define PA_LED1 IOPORT_BIT(10) #define PA_LED1 10
#define PA_LED2 IOPORT_BIT(11) #define PA_LED2 11
#define PA_BUZZ1 IOPORT_BIT(12) #define PA_BUZZ1 12
#define PA_BUZZ2 IOPORT_BIT(13) #define PA_BUZZ2 13
#define PA_BSL IOPORT_BIT(14) #define PA_BSL 14
#define PA_BUTTON1 IOPORT_BIT(15) #define PA_BUTTON1 15
#define PA_BUTTON2 IOPORT_BIT(16) #define PA_BUTTON2 16
#define PA_SSEL1 IOPORT_BIT(20) #define PA_SSEL1 20
#define PA_LEDUSB IOPORT_BIT(31) #define PA_LEDUSB 31
#define PB_WP1 IOPORT_BIT(24) #define PB_WP1 24
#define PB_CP1 IOPORT_BIT(25) #define PB_CP1 25
#endif /* _BOARD_H_ */ #endif /* _BOARD_H_ */

View File

@ -18,7 +18,7 @@
*/ */
#include <ch.hpp> #include <ch.hpp>
#include <ioports.h> #include <pal.h>
#include <evtimer.h> #include <evtimer.h>
#include <test.h> #include <test.h>
@ -26,6 +26,8 @@
#include <board.h> #include <board.h>
#include <lpc214x_serial.h> #include <lpc214x_serial.h>
#define BOTH_BUTTONS (PAL_PORT_BIT(PA_BUTTON1) | PAL_PORT_BIT(PA_BUTTON2))
using namespace chibios_rt; using namespace chibios_rt;
/* /*
@ -48,9 +50,9 @@ typedef struct {
// Flashing sequence for LED1. // Flashing sequence for LED1.
static const seqop_t LED1_sequence[] = static const seqop_t LED1_sequence[] =
{ {
{BITCLEAR, PA_LED1}, {BITCLEAR, PAL_PORT_BIT(PA_LED1)},
{SLEEP, 200}, {SLEEP, 200},
{BITSET, PA_LED1}, {BITSET, PAL_PORT_BIT(PA_LED1)},
{SLEEP, 1800}, {SLEEP, 1800},
{GOTO, 0} {GOTO, 0}
}; };
@ -59,9 +61,9 @@ static const seqop_t LED1_sequence[] =
static const seqop_t LED2_sequence[] = static const seqop_t LED2_sequence[] =
{ {
{SLEEP, 1000}, {SLEEP, 1000},
{BITCLEAR, PA_LED2}, {BITCLEAR, PAL_PORT_BIT(PA_LED2)},
{SLEEP, 200}, {SLEEP, 200},
{BITSET, PA_LED2}, {BITSET, PAL_PORT_BIT(PA_LED2)},
{SLEEP, 1800}, {SLEEP, 1800},
{GOTO, 1} {GOTO, 1}
}; };
@ -69,9 +71,9 @@ static const seqop_t LED2_sequence[] =
// Flashing sequence for LED3. // Flashing sequence for LED3.
static const seqop_t LED3_sequence[] = static const seqop_t LED3_sequence[] =
{ {
{BITCLEAR, PA_LEDUSB}, {BITCLEAR, PAL_PORT_BIT(PA_LEDUSB)},
{SLEEP, 200}, {SLEEP, 200},
{BITSET, PA_LEDUSB}, {BITSET, PAL_PORT_BIT(PA_LEDUSB)},
{SLEEP, 300}, {SLEEP, 300},
{GOTO, 0} {GOTO, 0}
}; };
@ -98,10 +100,10 @@ protected:
case STOP: case STOP:
return 0; return 0;
case BITCLEAR: case BITCLEAR:
chPortClear(IOPORT_A, curr->value); palClearPort(IOPORT_A, curr->value);
break; break;
case BITSET: case BITSET:
chPortSet(IOPORT_A, curr->value); palSetPort(IOPORT_A, curr->value);
break; break;
} }
curr++; curr++;
@ -136,7 +138,7 @@ public:
*/ */
static void TimerHandler(eventid_t id) { 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; TesterThread tester;
tester.Wait(); tester.Wait();
}; };

View File

@ -73,8 +73,9 @@
#define PA_BUTTON1 15 #define PA_BUTTON1 15
#define PA_BUTTON2 16 #define PA_BUTTON2 16
#define PA_SSEL1 20 #define PA_SSEL1 20
#define PA_WP1 24
#define PA_CP1 25
#define PA_LEDUSB 31 #define PA_LEDUSB 31
#define PB_WP1 24
#define PB_CP1 25
#endif /* _BOARD_H_ */ #endif /* _BOARD_H_ */

View File

@ -55,6 +55,7 @@ CSRC = ../../ports/ARM7/chcore.c \
${KERNSRC} \ ${KERNSRC} \
${TESTSRC} \ ${TESTSRC} \
../../src/lib/evtimer.c \ ../../src/lib/evtimer.c \
../../src/lib/pal.c \
board.c buzzer.c mmcsd.c main.c board.c buzzer.c mmcsd.c main.c
# C++ sources that can be compiled in ARM or THUMB mode depending on the global # C++ sources that can be compiled in ARM or THUMB mode depending on the global

View File

@ -18,6 +18,7 @@
*/ */
#include <ch.h> #include <ch.h>
#include <pal.h>
#include "lpc214x.h" #include "lpc214x.h"
#include "vic.h" #include "vic.h"
@ -103,11 +104,11 @@ void hwinit0(void) {
PINSEL0 = VAL_PINSEL0; PINSEL0 = VAL_PINSEL0;
PINSEL1 = VAL_PINSEL1; PINSEL1 = VAL_PINSEL1;
PINSEL2 = VAL_PINSEL2; PINSEL2 = VAL_PINSEL2;
ioport_init_lld(); palInit();
ioport_lpc214x_set_direction_lld(IOPORT_A, VAL_FIO0DIR); pal_lld_lpc214x_set_direction(IOPORT_A, VAL_FIO0DIR);
ioport_write_lld(IOPORT_A, 0xFFFFFFFF); palWritePort(IOPORT_A, 0xFFFFFFFF);
ioport_lpc214x_set_direction_lld(IOPORT_B, VAL_FIO1DIR); pal_lld_lpc214x_set_direction(IOPORT_B, VAL_FIO1DIR);
ioport_write_lld(IOPORT_B, 0xFFFFFFFF); palWritePort(IOPORT_B, 0xFFFFFFFF);
} }
/* /*

View File

@ -24,10 +24,6 @@
#include "lpc214x.h" #include "lpc214x.h"
#endif #endif
#ifndef _IOPORTS_LLD_H_
#include "ioports.h"
#endif
#define BOARD_OLIMEX_LCP_P2148 #define BOARD_OLIMEX_LCP_P2148
/* /*
@ -69,17 +65,17 @@
#define VAL_FIO0DIR 0xB0703C00 #define VAL_FIO0DIR 0xB0703C00
#define VAL_FIO1DIR 0x00000000 #define VAL_FIO1DIR 0x00000000
#define PA_LED1 IOPORT_BIT(10) #define PA_LED1 10
#define PA_LED2 IOPORT_BIT(11) #define PA_LED2 11
#define PA_BUZZ1 IOPORT_BIT(12) #define PA_BUZZ1 12
#define PA_BUZZ2 IOPORT_BIT(13) #define PA_BUZZ2 13
#define PA_BSL IOPORT_BIT(14) #define PA_BSL 14
#define PA_BUTTON1 IOPORT_BIT(15) #define PA_BUTTON1 15
#define PA_BUTTON2 IOPORT_BIT(16) #define PA_BUTTON2 16
#define PA_SSEL1 IOPORT_BIT(20) #define PA_SSEL1 20
#define PA_LEDUSB IOPORT_BIT(31) #define PA_LEDUSB 31
#define PB_WP1 IOPORT_BIT(24) #define PB_WP1 24
#define PB_CP1 IOPORT_BIT(25) #define PB_CP1 25
#endif /* _BOARD_H_ */ #endif /* _BOARD_H_ */

View File

@ -18,6 +18,7 @@
*/ */
#include <ch.h> #include <ch.h>
#include <pal.h>
#include <test.h> #include <test.h>
#include "board.h" #include "board.h"
@ -26,6 +27,8 @@
#include "buzzer.h" #include "buzzer.h"
#include "evtimer.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. * Red LEDs blinker thread, times are in milliseconds.
*/ */
@ -33,13 +36,13 @@ static WORKING_AREA(waThread1, 128);
static msg_t Thread1(void *arg) { static msg_t Thread1(void *arg) {
while (TRUE) { while (TRUE) {
chPortClear(IOPORT_A, PA_LED2); palClearPort(IOPORT_A, PAL_PORT_BIT(PA_LED2));
chThdSleepMilliseconds(200); chThdSleepMilliseconds(200);
chPortSet(IOPORT_A, PA_LED1 | PA_LED2); palSetPort(IOPORT_A, PAL_PORT_BIT(PA_LED1) | PAL_PORT_BIT(PA_LED2));
chThdSleepMilliseconds(800); chThdSleepMilliseconds(800);
chPortClear(IOPORT_A, PA_LED1); palClearPort(IOPORT_A, PAL_PORT_BIT(PA_LED1));
chThdSleepMilliseconds(200); chThdSleepMilliseconds(200);
chPortSet(IOPORT_A, PA_LED1 | PA_LED2); palSetPort(IOPORT_A, PAL_PORT_BIT(PA_LED1) | PAL_PORT_BIT(PA_LED2));
chThdSleepMilliseconds(800); chThdSleepMilliseconds(800);
} }
return 0; return 0;
@ -52,9 +55,9 @@ static WORKING_AREA(waThread2, 128);
static msg_t Thread2(void *arg) { static msg_t Thread2(void *arg) {
while (TRUE) { while (TRUE) {
chPortClear(IOPORT_A, PA_LEDUSB); palClearPad(IOPORT_A, PA_LEDUSB);
chThdSleepMilliseconds(200); chThdSleepMilliseconds(200);
chPortSet(IOPORT_A, PA_LEDUSB); palSetPad(IOPORT_A, PA_LEDUSB);
chThdSleepMilliseconds(300); chThdSleepMilliseconds(300);
} }
return 0; return 0;
@ -67,16 +70,16 @@ static WORKING_AREA(waTestThread, 128);
*/ */
static void TimerHandler(eventid_t id) { 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), Thread *tp = chThdCreateStatic(waTestThread, sizeof(waTestThread),
NORMALPRIO, TestThread, &COM1); NORMALPRIO, TestThread, &COM1);
chThdWait(tp); chThdWait(tp);
PlaySound(500, MS2ST(100)); PlaySound(500, MS2ST(100));
} }
else { else {
if (!(chPortRead(IOPORT_A) & PA_BUTTON1)) if (!palReadPad(IOPORT_A, PA_BUTTON1))
PlaySound(1000, MS2ST(100)); 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); chFDDWrite(&COM1, (uint8_t *)"Hello World!\r\n", 14);
PlaySound(2000, MS2ST(100)); 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 * If a button is pressed during the reset then the blinking leds threads
* are not started in order to make accurate benchmarks. * 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(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
chThdCreateStatic(waThread2, sizeof(waThread2), NORMALPRIO, Thread2, NULL); chThdCreateStatic(waThread2, sizeof(waThread2), NORMALPRIO, Thread2, NULL);
} }

View File

@ -18,6 +18,7 @@
*/ */
#include <ch.h> #include <ch.h>
#include <pal.h>
#include "board.h" #include "board.h"
#include "lpc214x_ssp.h" #include "lpc214x_ssp.h"
@ -42,7 +43,7 @@ void InitMMC(void) {
void tmrfunc(void *par) { void tmrfunc(void *par) {
if (cnt) { if (cnt) {
if (!(chPortRead(IOPORT_B) & PB_CP1)) { if (!palReadPad(IOPORT_B, PB_CP1)) {
if (!--cnt) if (!--cnt)
chEvtBroadcastI(&MMCInsertEventSource); chEvtBroadcastI(&MMCInsertEventSource);
} }
@ -50,7 +51,7 @@ void tmrfunc(void *par) {
cnt = POLLING_INTERVAL; cnt = POLLING_INTERVAL;
} }
else { else {
if (chPortRead(IOPORT_B) & PB_CP1) { if (palReadPad(IOPORT_B, PB_CP1)) {
cnt = POLLING_INTERVAL; cnt = POLLING_INTERVAL;
chEvtBroadcastI(&MMCRemoveEventSource); chEvtBroadcastI(&MMCRemoveEventSource);
} }

View File

@ -164,37 +164,6 @@
* @ingroup Kernel * @ingroup Kernel
*/ */
/**
* @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 * @defgroup Synchronization Synchronization
* Synchronization services. * Synchronization services.
@ -344,6 +313,37 @@
* @ingroup Synchronization * @ingroup Synchronization
*/ */
/**
* @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 * @defgroup IO I/O Support
* @brief I/O related services. * @brief I/O related services.

View File

@ -25,7 +25,7 @@
*/ */
#include <ch.h> #include <ch.h>
#include <ioports.h> #include <pal.h>
#include "lpc214x.h" #include "lpc214x.h"
#include "lpc214x_ssp.h" #include "lpc214x_ssp.h"
@ -44,7 +44,7 @@ void sspAcquireBus(void) {
#if LPC214x_SSP_USE_MUTEX #if LPC214x_SSP_USE_MUTEX
chSemWait(&me); chSemWait(&me);
#endif #endif
chPortClear(IOPORT_A, (1 << 20)); palClearPad(IOPORT_A, 20);
} }
/** /**
@ -54,7 +54,7 @@ void sspAcquireBus(void) {
*/ */
void sspReleaseBus(void) { void sspReleaseBus(void) {
chPortSet(IOPORT_A, (1 << 20)); palClearPad(IOPORT_A, 20);
#if LPC214x_SSP_USE_MUTEX #if LPC214x_SSP_USE_MUTEX
chSemSignal(&me); chSemSignal(&me);
#endif #endif