aboutsummaryrefslogtreecommitdiffstats
path: root/demos
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2009-06-02 13:41:38 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2009-06-02 13:41:38 +0000
commit2a7941ee58016ce7641ab8010aff5fe711e0bedc (patch)
tree4ac467770e31cbf9245936b998d47e0809bf28b7 /demos
parent1aa2773ad03807e3d5c9822ea108bc2e280281db (diff)
downloadChibiOS-2a7941ee58016ce7641ab8010aff5fe711e0bedc.tar.gz
ChibiOS-2a7941ee58016ce7641ab8010aff5fe711e0bedc.tar.bz2
ChibiOS-2a7941ee58016ce7641ab8010aff5fe711e0bedc.zip
I/O port driver for LPC214x added.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1016 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'demos')
-rw-r--r--demos/ARM7-LPC214x-G++/board.c17
-rw-r--r--demos/ARM7-LPC214x-G++/board.h21
-rw-r--r--demos/ARM7-LPC214x-G++/main.cpp21
-rw-r--r--demos/ARM7-LPC214x-GCC-minimal/board.c9
-rw-r--r--demos/ARM7-LPC214x-GCC-minimal/board.h20
-rw-r--r--demos/ARM7-LPC214x-GCC-minimal/main.c14
-rw-r--r--demos/ARM7-LPC214x-GCC/board.c9
-rw-r--r--demos/ARM7-LPC214x-GCC/board.h21
-rw-r--r--demos/ARM7-LPC214x-GCC/main.c22
-rw-r--r--demos/ARM7-LPC214x-GCC/mmcsd.c6
10 files changed, 113 insertions, 47 deletions
diff --git a/demos/ARM7-LPC214x-G++/board.c b/demos/ARM7-LPC214x-G++/board.c
index dc0cfb4f9..f188372b3 100644
--- a/demos/ARM7-LPC214x-G++/board.c
+++ b/demos/ARM7-LPC214x-G++/board.c
@@ -19,10 +19,10 @@
#include <ch.h>
-#include <lpc214x.h>
-#include <vic.h>
-#include <lpc214x_serial.h>
-//#include "lpc214x_ssp.h"
+#include "lpc214x.h"
+#include "vic.h"
+#include "lpc214x_serial.h"
+#include "lpc214x_ssp.h"
#include "board.h"
//#include "mmcsd.h"
@@ -103,10 +103,11 @@ void hwinit0(void) {
PINSEL0 = VAL_PINSEL0;
PINSEL1 = VAL_PINSEL1;
PINSEL2 = VAL_PINSEL2;
- IO0DIR = VAL_FIO0DIR;
- IO0SET = 0xFFFFFFFF;
- IO1DIR = VAL_FIO1DIR;
- IO1SET = 0xFFFFFFFF;
+ 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);
}
/*
diff --git a/demos/ARM7-LPC214x-G++/board.h b/demos/ARM7-LPC214x-G++/board.h
index c9d3f01b3..ee30559c8 100644
--- a/demos/ARM7-LPC214x-G++/board.h
+++ b/demos/ARM7-LPC214x-G++/board.h
@@ -20,6 +20,14 @@
#ifndef _BOARD_H_
#define _BOARD_H_
+#ifndef _LPC214X_H_
+#include "lpc214x.h"
+#endif
+
+#ifndef _IOPORTS_LLD_H_
+#include "ioports.h"
+#endif
+
#define BOARD_OLIMEX_LCP_P2148
/*
@@ -61,4 +69,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 PB_WP1 IOPORT_BIT(24)
+#define PB_CP1 IOPORT_BIT(25)
+
#endif /* _BOARD_H_ */
diff --git a/demos/ARM7-LPC214x-G++/main.cpp b/demos/ARM7-LPC214x-G++/main.cpp
index 647dee8a3..1a50f5936 100644
--- a/demos/ARM7-LPC214x-G++/main.cpp
+++ b/demos/ARM7-LPC214x-G++/main.cpp
@@ -18,11 +18,12 @@
*/
#include <ch.hpp>
+#include <ioports.h>
#include <evtimer.h>
#include <test.h>
-#include <lpc214x.h>
+#include <board.h>
#include <lpc214x_serial.h>
using namespace chibios_rt;
@@ -47,9 +48,9 @@ typedef struct {
// Flashing sequence for LED1.
static const seqop_t LED1_sequence[] =
{
- {BITCLEAR, 0x00000400},
+ {BITCLEAR, PA_LED1},
{SLEEP, 200},
- {BITSET, 0x00000400},
+ {BITSET, PA_LED1},
{SLEEP, 1800},
{GOTO, 0}
};
@@ -58,9 +59,9 @@ static const seqop_t LED1_sequence[] =
static const seqop_t LED2_sequence[] =
{
{SLEEP, 1000},
- {BITCLEAR, 0x00000800},
+ {BITCLEAR, PA_LED2},
{SLEEP, 200},
- {BITSET, 0x00000800},
+ {BITSET, PA_LED2},
{SLEEP, 1800},
{GOTO, 1}
};
@@ -68,9 +69,9 @@ static const seqop_t LED2_sequence[] =
// Flashing sequence for LED3.
static const seqop_t LED3_sequence[] =
{
- {BITCLEAR, 0x80000000},
+ {BITCLEAR, PA_LEDUSB},
{SLEEP, 200},
- {BITSET, 0x80000000},
+ {BITSET, PA_LEDUSB},
{SLEEP, 300},
{GOTO, 0}
};
@@ -97,10 +98,10 @@ protected:
case STOP:
return 0;
case BITCLEAR:
- IO0CLR = curr->value;
+ chPortClear(IOPORT_A, curr->value);
break;
case BITSET:
- IO0SET = curr->value;
+ chPortSet(IOPORT_A, curr->value);
break;
}
curr++;
@@ -135,7 +136,7 @@ public:
*/
static void TimerHandler(eventid_t id) {
- if (!(IO0PIN & 0x00018000)) { // Both buttons
+ if (!(chPortRead(IOPORT_A) & (PA_BUTTON1 | PA_BUTTON2))) { // Both buttons
TesterThread tester;
tester.Wait();
};
diff --git a/demos/ARM7-LPC214x-GCC-minimal/board.c b/demos/ARM7-LPC214x-GCC-minimal/board.c
index 50f553fa3..a06b24291 100644
--- a/demos/ARM7-LPC214x-GCC-minimal/board.c
+++ b/demos/ARM7-LPC214x-GCC-minimal/board.c
@@ -103,10 +103,11 @@ void hwinit0(void) {
PINSEL0 = VAL_PINSEL0;
PINSEL1 = VAL_PINSEL1;
PINSEL2 = VAL_PINSEL2;
- IO0DIR = VAL_FIO0DIR;
- IO0SET = 0xFFFFFFFF;
- IO1DIR = VAL_FIO1DIR;
- IO1SET = 0xFFFFFFFF;
+ 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);
}
/*
diff --git a/demos/ARM7-LPC214x-GCC-minimal/board.h b/demos/ARM7-LPC214x-GCC-minimal/board.h
index c9d3f01b3..3cdc2a9af 100644
--- a/demos/ARM7-LPC214x-GCC-minimal/board.h
+++ b/demos/ARM7-LPC214x-GCC-minimal/board.h
@@ -20,6 +20,14 @@
#ifndef _BOARD_H_
#define _BOARD_H_
+#ifndef _LPC214X_H_
+#include "lpc214x.h"
+#endif
+
+#ifndef _IOPORTS_LLD_H_
+#include "ioports.h"
+#endif
+
#define BOARD_OLIMEX_LCP_P2148
/*
@@ -61,4 +69,16 @@
#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_WP1 IOPORT_BIT(24)
+#define PA_CP1 IOPORT_BIT(25)
+#define PA_LEDUSB IOPORT_BIT(31)
+
#endif /* _BOARD_H_ */
diff --git a/demos/ARM7-LPC214x-GCC-minimal/main.c b/demos/ARM7-LPC214x-GCC-minimal/main.c
index 59dc04158..60035ffb7 100644
--- a/demos/ARM7-LPC214x-GCC-minimal/main.c
+++ b/demos/ARM7-LPC214x-GCC-minimal/main.c
@@ -19,7 +19,7 @@
#include <ch.h>
-#include "lpc214x.h"
+#include "board.h"
/*
* Red LEDs blinker thread, times are in milliseconds.
@@ -28,13 +28,13 @@ static WORKING_AREA(waThread1, 128);
static msg_t Thread1(void *arg) {
while (TRUE) {
- IO0CLR = 0x00000800;
+ chPortClear(IOPORT_A, PA_LED2);
chThdSleepMilliseconds(200);
- IO0SET = 0x00000C00;
+ chPortSet(IOPORT_A, PA_LED1 | PA_LED2);
chThdSleepMilliseconds(800);
- IO0CLR = 0x00000400;
+ chPortClear(IOPORT_A, PA_LED1);
chThdSleepMilliseconds(200);
- IO0SET = 0x00000C00;
+ chPortSet(IOPORT_A, PA_LED1 | PA_LED2);
chThdSleepMilliseconds(800);
}
return 0;
@@ -47,9 +47,9 @@ static WORKING_AREA(waThread2, 128);
static msg_t Thread2(void *arg) {
while (TRUE) {
- IO0CLR = 0x80000000;
+ chPortClear(IOPORT_A, PA_LEDUSB);
chThdSleepMilliseconds(200);
- IO0SET = 0x80000000;
+ chPortSet(IOPORT_A, PA_LEDUSB);
chThdSleepMilliseconds(300);
}
return 0;
diff --git a/demos/ARM7-LPC214x-GCC/board.c b/demos/ARM7-LPC214x-GCC/board.c
index 0db657b29..e1bf9369f 100644
--- a/demos/ARM7-LPC214x-GCC/board.c
+++ b/demos/ARM7-LPC214x-GCC/board.c
@@ -103,10 +103,11 @@ void hwinit0(void) {
PINSEL0 = VAL_PINSEL0;
PINSEL1 = VAL_PINSEL1;
PINSEL2 = VAL_PINSEL2;
- IO0DIR = VAL_FIO0DIR;
- IO0SET = 0xFFFFFFFF;
- IO1DIR = VAL_FIO1DIR;
- IO1SET = 0xFFFFFFFF;
+ 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);
}
/*
diff --git a/demos/ARM7-LPC214x-GCC/board.h b/demos/ARM7-LPC214x-GCC/board.h
index c9d3f01b3..ee30559c8 100644
--- a/demos/ARM7-LPC214x-GCC/board.h
+++ b/demos/ARM7-LPC214x-GCC/board.h
@@ -20,6 +20,14 @@
#ifndef _BOARD_H_
#define _BOARD_H_
+#ifndef _LPC214X_H_
+#include "lpc214x.h"
+#endif
+
+#ifndef _IOPORTS_LLD_H_
+#include "ioports.h"
+#endif
+
#define BOARD_OLIMEX_LCP_P2148
/*
@@ -61,4 +69,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 PB_WP1 IOPORT_BIT(24)
+#define PB_CP1 IOPORT_BIT(25)
+
#endif /* _BOARD_H_ */
diff --git a/demos/ARM7-LPC214x-GCC/main.c b/demos/ARM7-LPC214x-GCC/main.c
index c83d9a419..3eafdba61 100644
--- a/demos/ARM7-LPC214x-GCC/main.c
+++ b/demos/ARM7-LPC214x-GCC/main.c
@@ -20,7 +20,7 @@
#include <ch.h>
#include <test.h>
-#include "lpc214x.h"
+#include "board.h"
#include "lpc214x_serial.h"
#include "mmcsd.h"
#include "buzzer.h"
@@ -33,13 +33,13 @@ static WORKING_AREA(waThread1, 128);
static msg_t Thread1(void *arg) {
while (TRUE) {
- IO0CLR = 0x00000800;
+ chPortClear(IOPORT_A, PA_LED2);
chThdSleepMilliseconds(200);
- IO0SET = 0x00000C00;
+ chPortSet(IOPORT_A, PA_LED1 | PA_LED2);
chThdSleepMilliseconds(800);
- IO0CLR = 0x00000400;
+ chPortClear(IOPORT_A, PA_LED1);
chThdSleepMilliseconds(200);
- IO0SET = 0x00000C00;
+ chPortSet(IOPORT_A, PA_LED1 | PA_LED2);
chThdSleepMilliseconds(800);
}
return 0;
@@ -52,9 +52,9 @@ static WORKING_AREA(waThread2, 128);
static msg_t Thread2(void *arg) {
while (TRUE) {
- IO0CLR = 0x80000000;
+ chPortClear(IOPORT_A, PA_LEDUSB);
chThdSleepMilliseconds(200);
- IO0SET = 0x80000000;
+ chPortSet(IOPORT_A, PA_LEDUSB);
chThdSleepMilliseconds(300);
}
return 0;
@@ -67,16 +67,16 @@ static WORKING_AREA(waTestThread, 128);
*/
static void TimerHandler(eventid_t id) {
- if (!(IO0PIN & 0x00018000)) { // Both buttons
+ if (!(chPortRead(IOPORT_A) & (PA_BUTTON1 | PA_BUTTON2))) {
Thread *tp = chThdCreateStatic(waTestThread, sizeof(waTestThread),
NORMALPRIO, TestThread, &COM1);
chThdWait(tp);
PlaySound(500, MS2ST(100));
}
else {
- if (!(IO0PIN & 0x00008000)) // Button 1
+ if (!(chPortRead(IOPORT_A) & PA_BUTTON1))
PlaySound(1000, MS2ST(100));
- if (!(IO0PIN & 0x00010000)) { // Button 2
+ if (!(chPortRead(IOPORT_A) & PA_BUTTON2)) {
chFDDWrite(&COM1, (uint8_t *)"Hello World!\r\n", 14);
PlaySound(2000, MS2ST(100));
}
@@ -129,7 +129,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 ((IO0PIN & 0x00018000) == 0x00018000) {
+ if (chPortRead(IOPORT_A) && (PA_BUTTON1 | PA_BUTTON2) == (PA_BUTTON1 | PA_BUTTON2)) {
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 292b450d5..bff2967d9 100644
--- a/demos/ARM7-LPC214x-GCC/mmcsd.c
+++ b/demos/ARM7-LPC214x-GCC/mmcsd.c
@@ -19,7 +19,7 @@
#include <ch.h>
-#include "lpc214x.h"
+#include "board.h"
#include "lpc214x_ssp.h"
#include "mmcsd.h"
@@ -42,7 +42,7 @@ void InitMMC(void) {
void tmrfunc(void *par) {
if (cnt) {
- if (!(IO1PIN & (1 << 25))) {
+ if (!(chPortRead(IOPORT_B) & PB_CP1)) {
if (!--cnt)
chEvtBroadcastI(&MMCInsertEventSource);
}
@@ -50,7 +50,7 @@ void tmrfunc(void *par) {
cnt = POLLING_INTERVAL;
}
else {
- if (IO1PIN & (1 << 25)) {
+ if (chPortRead(IOPORT_B) & PB_CP1) {
cnt = POLLING_INTERVAL;
chEvtBroadcastI(&MMCRemoveEventSource);
}