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 +#include #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 -#include +#include #include #include @@ -26,6 +26,8 @@ #include #include +#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 +#include #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 +#include #include #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 +#include #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 @@ -164,37 +164,6 @@ * @ingroup Kernel */ -/** - * @defgroup Memory Memory Management - * Memory Management services. - */ - -/** - * @defgroup Heap Heap - * Heap Allocator related APIs. - *

Operation mode

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

Operation mode

- * The Memory Pools APIs allow to allocate/free fixed size objects in - * constant time and reliably without memory fragmentation problems.
- * 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. @@ -344,6 +313,37 @@ * @ingroup Synchronization */ +/** + * @defgroup Memory Memory Management + * Memory Management services. + */ + +/** + * @defgroup Heap Heap + * Heap Allocator related APIs. + *

Operation mode

+ * 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.
+ * 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.
+ * 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. + *

Operation mode

+ * The Memory Pools APIs allow to allocate/free fixed size objects in + * constant time and reliably without memory fragmentation problems.
+ * 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. 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 -#include +#include #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