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
This commit is contained in:
parent
1aa2773ad0
commit
2a7941ee58
|
@ -19,10 +19,10 @@
|
||||||
|
|
||||||
#include <ch.h>
|
#include <ch.h>
|
||||||
|
|
||||||
#include <lpc214x.h>
|
#include "lpc214x.h"
|
||||||
#include <vic.h>
|
#include "vic.h"
|
||||||
#include <lpc214x_serial.h>
|
#include "lpc214x_serial.h"
|
||||||
//#include "lpc214x_ssp.h"
|
#include "lpc214x_ssp.h"
|
||||||
|
|
||||||
#include "board.h"
|
#include "board.h"
|
||||||
//#include "mmcsd.h"
|
//#include "mmcsd.h"
|
||||||
|
@ -103,10 +103,11 @@ void hwinit0(void) {
|
||||||
PINSEL0 = VAL_PINSEL0;
|
PINSEL0 = VAL_PINSEL0;
|
||||||
PINSEL1 = VAL_PINSEL1;
|
PINSEL1 = VAL_PINSEL1;
|
||||||
PINSEL2 = VAL_PINSEL2;
|
PINSEL2 = VAL_PINSEL2;
|
||||||
IO0DIR = VAL_FIO0DIR;
|
ioport_init_lld();
|
||||||
IO0SET = 0xFFFFFFFF;
|
ioport_lpc214x_set_direction_lld(IOPORT_A, VAL_FIO0DIR);
|
||||||
IO1DIR = VAL_FIO1DIR;
|
ioport_write_lld(IOPORT_A, 0xFFFFFFFF);
|
||||||
IO1SET = 0xFFFFFFFF;
|
ioport_lpc214x_set_direction_lld(IOPORT_B, VAL_FIO1DIR);
|
||||||
|
ioport_write_lld(IOPORT_B, 0xFFFFFFFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -20,6 +20,14 @@
|
||||||
#ifndef _BOARD_H_
|
#ifndef _BOARD_H_
|
||||||
#define _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
|
#define BOARD_OLIMEX_LCP_P2148
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -61,4 +69,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_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_ */
|
#endif /* _BOARD_H_ */
|
||||||
|
|
|
@ -18,11 +18,12 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <ch.hpp>
|
#include <ch.hpp>
|
||||||
|
#include <ioports.h>
|
||||||
|
|
||||||
#include <evtimer.h>
|
#include <evtimer.h>
|
||||||
#include <test.h>
|
#include <test.h>
|
||||||
|
|
||||||
#include <lpc214x.h>
|
#include <board.h>
|
||||||
#include <lpc214x_serial.h>
|
#include <lpc214x_serial.h>
|
||||||
|
|
||||||
using namespace chibios_rt;
|
using namespace chibios_rt;
|
||||||
|
@ -47,9 +48,9 @@ typedef struct {
|
||||||
// Flashing sequence for LED1.
|
// Flashing sequence for LED1.
|
||||||
static const seqop_t LED1_sequence[] =
|
static const seqop_t LED1_sequence[] =
|
||||||
{
|
{
|
||||||
{BITCLEAR, 0x00000400},
|
{BITCLEAR, PA_LED1},
|
||||||
{SLEEP, 200},
|
{SLEEP, 200},
|
||||||
{BITSET, 0x00000400},
|
{BITSET, PA_LED1},
|
||||||
{SLEEP, 1800},
|
{SLEEP, 1800},
|
||||||
{GOTO, 0}
|
{GOTO, 0}
|
||||||
};
|
};
|
||||||
|
@ -58,9 +59,9 @@ static const seqop_t LED1_sequence[] =
|
||||||
static const seqop_t LED2_sequence[] =
|
static const seqop_t LED2_sequence[] =
|
||||||
{
|
{
|
||||||
{SLEEP, 1000},
|
{SLEEP, 1000},
|
||||||
{BITCLEAR, 0x00000800},
|
{BITCLEAR, PA_LED2},
|
||||||
{SLEEP, 200},
|
{SLEEP, 200},
|
||||||
{BITSET, 0x00000800},
|
{BITSET, PA_LED2},
|
||||||
{SLEEP, 1800},
|
{SLEEP, 1800},
|
||||||
{GOTO, 1}
|
{GOTO, 1}
|
||||||
};
|
};
|
||||||
|
@ -68,9 +69,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, 0x80000000},
|
{BITCLEAR, PA_LEDUSB},
|
||||||
{SLEEP, 200},
|
{SLEEP, 200},
|
||||||
{BITSET, 0x80000000},
|
{BITSET, PA_LEDUSB},
|
||||||
{SLEEP, 300},
|
{SLEEP, 300},
|
||||||
{GOTO, 0}
|
{GOTO, 0}
|
||||||
};
|
};
|
||||||
|
@ -97,10 +98,10 @@ protected:
|
||||||
case STOP:
|
case STOP:
|
||||||
return 0;
|
return 0;
|
||||||
case BITCLEAR:
|
case BITCLEAR:
|
||||||
IO0CLR = curr->value;
|
chPortClear(IOPORT_A, curr->value);
|
||||||
break;
|
break;
|
||||||
case BITSET:
|
case BITSET:
|
||||||
IO0SET = curr->value;
|
chPortSet(IOPORT_A, curr->value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
curr++;
|
curr++;
|
||||||
|
@ -135,7 +136,7 @@ public:
|
||||||
*/
|
*/
|
||||||
static void TimerHandler(eventid_t id) {
|
static void TimerHandler(eventid_t id) {
|
||||||
|
|
||||||
if (!(IO0PIN & 0x00018000)) { // Both buttons
|
if (!(chPortRead(IOPORT_A) & (PA_BUTTON1 | PA_BUTTON2))) { // Both buttons
|
||||||
TesterThread tester;
|
TesterThread tester;
|
||||||
tester.Wait();
|
tester.Wait();
|
||||||
};
|
};
|
||||||
|
|
|
@ -103,10 +103,11 @@ void hwinit0(void) {
|
||||||
PINSEL0 = VAL_PINSEL0;
|
PINSEL0 = VAL_PINSEL0;
|
||||||
PINSEL1 = VAL_PINSEL1;
|
PINSEL1 = VAL_PINSEL1;
|
||||||
PINSEL2 = VAL_PINSEL2;
|
PINSEL2 = VAL_PINSEL2;
|
||||||
IO0DIR = VAL_FIO0DIR;
|
ioport_init_lld();
|
||||||
IO0SET = 0xFFFFFFFF;
|
ioport_lpc214x_set_direction_lld(IOPORT_A, VAL_FIO0DIR);
|
||||||
IO1DIR = VAL_FIO1DIR;
|
ioport_write_lld(IOPORT_A, 0xFFFFFFFF);
|
||||||
IO1SET = 0xFFFFFFFF;
|
ioport_lpc214x_set_direction_lld(IOPORT_B, VAL_FIO1DIR);
|
||||||
|
ioport_write_lld(IOPORT_B, 0xFFFFFFFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -20,6 +20,14 @@
|
||||||
#ifndef _BOARD_H_
|
#ifndef _BOARD_H_
|
||||||
#define _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
|
#define BOARD_OLIMEX_LCP_P2148
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -61,4 +69,16 @@
|
||||||
#define VAL_FIO0DIR 0xB0703C00
|
#define VAL_FIO0DIR 0xB0703C00
|
||||||
#define VAL_FIO1DIR 0x00000000
|
#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_ */
|
#endif /* _BOARD_H_ */
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
#include <ch.h>
|
#include <ch.h>
|
||||||
|
|
||||||
#include "lpc214x.h"
|
#include "board.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Red LEDs blinker thread, times are in milliseconds.
|
* Red LEDs blinker thread, times are in milliseconds.
|
||||||
|
@ -28,13 +28,13 @@ static WORKING_AREA(waThread1, 128);
|
||||||
static msg_t Thread1(void *arg) {
|
static msg_t Thread1(void *arg) {
|
||||||
|
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
IO0CLR = 0x00000800;
|
chPortClear(IOPORT_A, PA_LED2);
|
||||||
chThdSleepMilliseconds(200);
|
chThdSleepMilliseconds(200);
|
||||||
IO0SET = 0x00000C00;
|
chPortSet(IOPORT_A, PA_LED1 | PA_LED2);
|
||||||
chThdSleepMilliseconds(800);
|
chThdSleepMilliseconds(800);
|
||||||
IO0CLR = 0x00000400;
|
chPortClear(IOPORT_A, PA_LED1);
|
||||||
chThdSleepMilliseconds(200);
|
chThdSleepMilliseconds(200);
|
||||||
IO0SET = 0x00000C00;
|
chPortSet(IOPORT_A, PA_LED1 | PA_LED2);
|
||||||
chThdSleepMilliseconds(800);
|
chThdSleepMilliseconds(800);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -47,9 +47,9 @@ static WORKING_AREA(waThread2, 128);
|
||||||
static msg_t Thread2(void *arg) {
|
static msg_t Thread2(void *arg) {
|
||||||
|
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
IO0CLR = 0x80000000;
|
chPortClear(IOPORT_A, PA_LEDUSB);
|
||||||
chThdSleepMilliseconds(200);
|
chThdSleepMilliseconds(200);
|
||||||
IO0SET = 0x80000000;
|
chPortSet(IOPORT_A, PA_LEDUSB);
|
||||||
chThdSleepMilliseconds(300);
|
chThdSleepMilliseconds(300);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -103,10 +103,11 @@ void hwinit0(void) {
|
||||||
PINSEL0 = VAL_PINSEL0;
|
PINSEL0 = VAL_PINSEL0;
|
||||||
PINSEL1 = VAL_PINSEL1;
|
PINSEL1 = VAL_PINSEL1;
|
||||||
PINSEL2 = VAL_PINSEL2;
|
PINSEL2 = VAL_PINSEL2;
|
||||||
IO0DIR = VAL_FIO0DIR;
|
ioport_init_lld();
|
||||||
IO0SET = 0xFFFFFFFF;
|
ioport_lpc214x_set_direction_lld(IOPORT_A, VAL_FIO0DIR);
|
||||||
IO1DIR = VAL_FIO1DIR;
|
ioport_write_lld(IOPORT_A, 0xFFFFFFFF);
|
||||||
IO1SET = 0xFFFFFFFF;
|
ioport_lpc214x_set_direction_lld(IOPORT_B, VAL_FIO1DIR);
|
||||||
|
ioport_write_lld(IOPORT_B, 0xFFFFFFFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -20,6 +20,14 @@
|
||||||
#ifndef _BOARD_H_
|
#ifndef _BOARD_H_
|
||||||
#define _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
|
#define BOARD_OLIMEX_LCP_P2148
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -61,4 +69,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_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_ */
|
#endif /* _BOARD_H_ */
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#include <ch.h>
|
#include <ch.h>
|
||||||
#include <test.h>
|
#include <test.h>
|
||||||
|
|
||||||
#include "lpc214x.h"
|
#include "board.h"
|
||||||
#include "lpc214x_serial.h"
|
#include "lpc214x_serial.h"
|
||||||
#include "mmcsd.h"
|
#include "mmcsd.h"
|
||||||
#include "buzzer.h"
|
#include "buzzer.h"
|
||||||
|
@ -33,13 +33,13 @@ static WORKING_AREA(waThread1, 128);
|
||||||
static msg_t Thread1(void *arg) {
|
static msg_t Thread1(void *arg) {
|
||||||
|
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
IO0CLR = 0x00000800;
|
chPortClear(IOPORT_A, PA_LED2);
|
||||||
chThdSleepMilliseconds(200);
|
chThdSleepMilliseconds(200);
|
||||||
IO0SET = 0x00000C00;
|
chPortSet(IOPORT_A, PA_LED1 | PA_LED2);
|
||||||
chThdSleepMilliseconds(800);
|
chThdSleepMilliseconds(800);
|
||||||
IO0CLR = 0x00000400;
|
chPortClear(IOPORT_A, PA_LED1);
|
||||||
chThdSleepMilliseconds(200);
|
chThdSleepMilliseconds(200);
|
||||||
IO0SET = 0x00000C00;
|
chPortSet(IOPORT_A, PA_LED1 | PA_LED2);
|
||||||
chThdSleepMilliseconds(800);
|
chThdSleepMilliseconds(800);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -52,9 +52,9 @@ static WORKING_AREA(waThread2, 128);
|
||||||
static msg_t Thread2(void *arg) {
|
static msg_t Thread2(void *arg) {
|
||||||
|
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
IO0CLR = 0x80000000;
|
chPortClear(IOPORT_A, PA_LEDUSB);
|
||||||
chThdSleepMilliseconds(200);
|
chThdSleepMilliseconds(200);
|
||||||
IO0SET = 0x80000000;
|
chPortSet(IOPORT_A, PA_LEDUSB);
|
||||||
chThdSleepMilliseconds(300);
|
chThdSleepMilliseconds(300);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -67,16 +67,16 @@ static WORKING_AREA(waTestThread, 128);
|
||||||
*/
|
*/
|
||||||
static void TimerHandler(eventid_t id) {
|
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),
|
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 (!(IO0PIN & 0x00008000)) // Button 1
|
if (!(chPortRead(IOPORT_A) & PA_BUTTON1))
|
||||||
PlaySound(1000, MS2ST(100));
|
PlaySound(1000, MS2ST(100));
|
||||||
if (!(IO0PIN & 0x00010000)) { // Button 2
|
if (!(chPortRead(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 +129,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 ((IO0PIN & 0x00018000) == 0x00018000) {
|
if (chPortRead(IOPORT_A) && (PA_BUTTON1 | PA_BUTTON2) == (PA_BUTTON1 | PA_BUTTON2)) {
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
#include <ch.h>
|
#include <ch.h>
|
||||||
|
|
||||||
#include "lpc214x.h"
|
#include "board.h"
|
||||||
#include "lpc214x_ssp.h"
|
#include "lpc214x_ssp.h"
|
||||||
|
|
||||||
#include "mmcsd.h"
|
#include "mmcsd.h"
|
||||||
|
@ -42,7 +42,7 @@ void InitMMC(void) {
|
||||||
void tmrfunc(void *par) {
|
void tmrfunc(void *par) {
|
||||||
|
|
||||||
if (cnt) {
|
if (cnt) {
|
||||||
if (!(IO1PIN & (1 << 25))) {
|
if (!(chPortRead(IOPORT_B) & PB_CP1)) {
|
||||||
if (!--cnt)
|
if (!--cnt)
|
||||||
chEvtBroadcastI(&MMCInsertEventSource);
|
chEvtBroadcastI(&MMCInsertEventSource);
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ void tmrfunc(void *par) {
|
||||||
cnt = POLLING_INTERVAL;
|
cnt = POLLING_INTERVAL;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (IO1PIN & (1 << 25)) {
|
if (chPortRead(IOPORT_B) & PB_CP1) {
|
||||||
cnt = POLLING_INTERVAL;
|
cnt = POLLING_INTERVAL;
|
||||||
chEvtBroadcastI(&MMCRemoveEventSource);
|
chEvtBroadcastI(&MMCRemoveEventSource);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,174 @@
|
||||||
|
/*
|
||||||
|
ChibiOS/RT - Copyright (C) 2006-2007 Giovanni Di Sirio.
|
||||||
|
|
||||||
|
This file is part of ChibiOS/RT.
|
||||||
|
|
||||||
|
ChibiOS/RT is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
ChibiOS/RT is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file ports/ARM-LPC214x/ioports_lld.h
|
||||||
|
* @brief LPC214x FIO low level driver
|
||||||
|
* @addtogroup LPC214X_IOPORTS
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _IOPORTS_LLD_H_
|
||||||
|
#define _IOPORTS_LLD_H_
|
||||||
|
|
||||||
|
#ifndef _LPC214X_H_
|
||||||
|
#include "lpc214x.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* I/O Ports Types and constants. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Width, in bits, of an I/O port.
|
||||||
|
*/
|
||||||
|
#define IOPORTS_WIDTH 32
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Digital I/O port sized unsigned type.
|
||||||
|
*/
|
||||||
|
typedef uint32_t ioportmask_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Port Identifier.
|
||||||
|
*/
|
||||||
|
typedef FIO * ioportid_t;
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* I/O Ports Identifiers. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief FIO port 0 identifier.
|
||||||
|
*/
|
||||||
|
#define IOPORT_A FIO0Base
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief FIO port 1 identifier.
|
||||||
|
*/
|
||||||
|
#define IOPORT_B FIO1Base
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Implementation, some of the following macros could be implemented as */
|
||||||
|
/* functions, please put them in a file named ioports_lld.c if so. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief FIO subsystem initialization.
|
||||||
|
* @details Enables the access through the fast registers.
|
||||||
|
*/
|
||||||
|
#define ioport_init_lld() { \
|
||||||
|
SCS = 3; \
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Writes a bits mask on a I/O port.
|
||||||
|
*
|
||||||
|
* @param[in] port the port identifier
|
||||||
|
* @param[in] bits the bits to be written on the specified port
|
||||||
|
*
|
||||||
|
* @note This function is not meant to be invoked directly by the application
|
||||||
|
* code.
|
||||||
|
*/
|
||||||
|
#define ioport_write_lld(port, bits) ((port)->FIO_PIN = (bits))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Reads an I/O port.
|
||||||
|
*
|
||||||
|
* @param[in] port the port identifier
|
||||||
|
* @return the port bits
|
||||||
|
*
|
||||||
|
* @note This function is not meant to be invoked directly by the application
|
||||||
|
* code.
|
||||||
|
*/
|
||||||
|
#define ioport_read_lld(port) ((port)->FIO_PIN)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Sets a bits mask on a I/O port.
|
||||||
|
*
|
||||||
|
* @param[in] port the port identifier
|
||||||
|
* @param[in] bits the bits to be ORed on the specified port
|
||||||
|
*
|
||||||
|
* @note This function is not meant to be invoked directly by the application
|
||||||
|
* code.
|
||||||
|
*/
|
||||||
|
#define ioport_set_lld(port, bits) ((port)->FIO_SET = (bits))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Clears a bits mask on a I/O port.
|
||||||
|
*
|
||||||
|
* @param[in] port the port identifier
|
||||||
|
* @param[in] bits the bits to be cleared on the specified port
|
||||||
|
*
|
||||||
|
* @note This function is not meant to be invoked directly by the application
|
||||||
|
* code.
|
||||||
|
*/
|
||||||
|
#define ioport_clear_lld(port, bits) ((port)->FIO_CLR = (bits))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Toggles a bits mask on a I/O port.
|
||||||
|
*
|
||||||
|
* @param[in] port the port identifier
|
||||||
|
* @param[in] bits the bits to be XORed on the specified port
|
||||||
|
*
|
||||||
|
* @note This function is not meant to be invoked directly by the application
|
||||||
|
* code.
|
||||||
|
*/
|
||||||
|
#define ioport_toggle_lld(port, bits) ((port)->FIO_PIN ^= (bits))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Writes a value on an I/O bus.
|
||||||
|
*
|
||||||
|
* @param[in] bus the I/O bus, pointer to a @p IOBus structure
|
||||||
|
* @param[in] bits the bits to be written on the I/O bus. Values exceeding
|
||||||
|
* the bus width are masked so most significant bits are lost.
|
||||||
|
*
|
||||||
|
* @note This function is not meant to be invoked directly by the application
|
||||||
|
* code.
|
||||||
|
*/
|
||||||
|
#define ioport_writebus_lld(bus, bits) { \
|
||||||
|
(port)->FIO_MASK = (bus)->bus_mask; \
|
||||||
|
(port)->FIO_PIN = (bits) << (bus)->bus_offset; \
|
||||||
|
(port)->FIO_MASK = 0; \
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Reads a value from an I/O bus.
|
||||||
|
*
|
||||||
|
* @param[in] bus the I/O bus, pointer to a @p IOBus structure
|
||||||
|
* @return the bus bits
|
||||||
|
*
|
||||||
|
* @note This function is not meant to be invoked directly by the application
|
||||||
|
* code.
|
||||||
|
*/
|
||||||
|
#define ioport_readbus_lld(bus) \
|
||||||
|
(((bus)->bus_portid->FIO_PIN & (bus)->bus_mask) >> (bus)->bus_offset)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief FIO port setup.
|
||||||
|
* @details This function initializes a FIO port, note that this functionality
|
||||||
|
* is LPC214x specific and non portable.
|
||||||
|
*/
|
||||||
|
#define ioport_lpc214x_set_direction_lld(port, dir) { \
|
||||||
|
(port)->FIO_DIR = (dir); \
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* _IOPORTS_LLD_H_ */
|
||||||
|
|
||||||
|
/** @} */
|
|
@ -17,6 +17,11 @@
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file lpc214x.h
|
||||||
|
* @brief LPC214x register definitions
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef _LPC214X_H_
|
#ifndef _LPC214X_H_
|
||||||
#define _LPC214X_H_
|
#define _LPC214X_H_
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <ch.h>
|
#include <ch.h>
|
||||||
|
#include <ioports.h>
|
||||||
|
|
||||||
#include "lpc214x.h"
|
#include "lpc214x.h"
|
||||||
#include "lpc214x_ssp.h"
|
#include "lpc214x_ssp.h"
|
||||||
|
@ -43,7 +44,7 @@ void sspAcquireBus(void) {
|
||||||
#if LPC214x_SSP_USE_MUTEX
|
#if LPC214x_SSP_USE_MUTEX
|
||||||
chSemWait(&me);
|
chSemWait(&me);
|
||||||
#endif
|
#endif
|
||||||
IO0CLR = 1 << 20;
|
chPortClear(IOPORT_A, (1 << 20));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -53,7 +54,7 @@ void sspAcquireBus(void) {
|
||||||
*/
|
*/
|
||||||
void sspReleaseBus(void) {
|
void sspReleaseBus(void) {
|
||||||
|
|
||||||
IO0SET = 1 << 20;
|
chPortSet(IOPORT_A, (1 << 20));
|
||||||
#if LPC214x_SSP_USE_MUTEX
|
#if LPC214x_SSP_USE_MUTEX
|
||||||
chSemSignal(&me);
|
chSemSignal(&me);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
* @brief LPC214x specific support.
|
* @brief LPC214x specific support.
|
||||||
* @details The LPC214x support includes:
|
* @details The LPC214x support includes:
|
||||||
* - VIC support code.
|
* - VIC support code.
|
||||||
|
* - I/O ports driver.
|
||||||
* - Buffered, interrupt driven, serial driver.
|
* - Buffered, interrupt driven, serial driver.
|
||||||
* - SSP driver.
|
* - SSP driver.
|
||||||
* - A MMC/SD demo driver.
|
* - A MMC/SD demo driver.
|
||||||
|
@ -44,6 +45,21 @@
|
||||||
*/
|
*/
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @defgroup LPC214x_IOPORTS I/O Ports Support
|
||||||
|
* @brief I/O Ports peripherals support.
|
||||||
|
* @details This module supports the LPC214x FIO controller. The controller
|
||||||
|
* supports the following features (see @ref IOPorts):
|
||||||
|
* - 32 bits wide ports.
|
||||||
|
* - Atomic set/reset functions.
|
||||||
|
* - Atomic set+reset function (atomic bus operations).
|
||||||
|
* - Output latched regardless of the pad setting.
|
||||||
|
* - Direct read of input pads regardless of the pad setting.
|
||||||
|
* .
|
||||||
|
* The only non atomic operations are bit toggling and bus writing.
|
||||||
|
* @ingroup LPC214x
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @defgroup LPC214x_SERIAL UART Support
|
* @defgroup LPC214x_SERIAL UART Support
|
||||||
* @{
|
* @{
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
* @defgroup STM32F103 STM32F103 Support
|
* @defgroup STM32F103 STM32F103 Support
|
||||||
* @brief STM32F103 specific support.
|
* @brief STM32F103 specific support.
|
||||||
* @details The STM32F103 support includes:
|
* @details The STM32F103 support includes:
|
||||||
|
* - I/O ports driver.
|
||||||
* - Buffered, interrupt driven, serial driver.
|
* - Buffered, interrupt driven, serial driver.
|
||||||
* - A demo supporting the kernel test suite.
|
* - A demo supporting the kernel test suite.
|
||||||
* .
|
* .
|
||||||
|
|
|
@ -70,8 +70,8 @@ GNU-Linux-GCC - ChibiOS/RT simulator for x86 Linux systems, it is
|
||||||
interface for digital I/O operations, this should help to create more
|
interface for digital I/O operations, this should help to create more
|
||||||
portable applications and, in general, make easier to work with ChibiOS/RT
|
portable applications and, in general, make easier to work with ChibiOS/RT
|
||||||
on multiple architectures.
|
on multiple architectures.
|
||||||
- NEW: Port driver for STM32, cleaned up the initialization code in board.c to
|
- NEW: Port drivers for STM32 and LPC214x, cleaned up the initialization code
|
||||||
use the port driver macros.
|
in board.c to use the port driver macros.
|
||||||
- Documentation section reorganization and fixes.
|
- Documentation section reorganization and fixes.
|
||||||
- Changed the STM32 demo stack sizes, it was incorrectly adjusted in version
|
- Changed the STM32 demo stack sizes, it was incorrectly adjusted in version
|
||||||
1.3.0 but it did not create problems (not a bug).
|
1.3.0 but it did not create problems (not a bug).
|
||||||
|
|
Loading…
Reference in New Issue