From 39d58838d968b6a79bbae61380836dfbbd292b6e Mon Sep 17 00:00:00 2001 From: xiangfu Date: Thu, 12 Jun 2008 18:22:49 -0400 Subject: [PATCH] blink led --- qiboot/Makefile | 25 +++++++++++++++++++++++++ qiboot/README | 0 qiboot/config.mk | 11 +++++++++++ qiboot/src/Makefile | 35 +++++++++++++++++++++++++++++++++++ qiboot/src/led.S | 12 ++++++++++++ qiboot/src/led.c | 29 +++++++++++++++++++++++++++++ 6 files changed, 112 insertions(+) create mode 100644 qiboot/Makefile create mode 100644 qiboot/README create mode 100644 qiboot/config.mk create mode 100644 qiboot/src/Makefile create mode 100644 qiboot/src/led.S create mode 100644 qiboot/src/led.c diff --git a/qiboot/Makefile b/qiboot/Makefile new file mode 100644 index 0000000..b49ee49 --- /dev/null +++ b/qiboot/Makefile @@ -0,0 +1,25 @@ +# This program 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 2 of +# the License, or (at your option) any later version. +# +# This program 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, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# + +include ./config.mk + +all : + cd src ; make all + +clean: + cd src ; make clean + + diff --git a/qiboot/README b/qiboot/README new file mode 100644 index 0000000..e69de29 diff --git a/qiboot/config.mk b/qiboot/config.mk new file mode 100644 index 0000000..c475739 --- /dev/null +++ b/qiboot/config.mk @@ -0,0 +1,11 @@ +# +# Include the make variables (CC, etc...) +# +CROSS_COMPILE=arm-angstrom-linux-gnueabi- + +AS = $(CROSS_COMPILE)as +LD = $(CROSS_COMPILE)ld +CC = $(CROSS_COMPILE)gcc +OBJCOPY = $(CROSS_COMPILE)objcopy + +export CROSS_COMPILE AD LD CC OBJCOPY diff --git a/qiboot/src/Makefile b/qiboot/src/Makefile new file mode 100644 index 0000000..39d2d0d --- /dev/null +++ b/qiboot/src/Makefile @@ -0,0 +1,35 @@ +# This program 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 2 of +# the License, or (at your option) any later version. +# +# This program 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, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# + + + +TEXT_BASE =0x0000000 + +INCLUDE =../include +IMAGE =../image +CFLAGS =-I $(INCLUDE) -g -c -o + +all:led.S led.c + $(CC) $(CFLAGS) led_S.o led.S + $(CC) $(CFLAGS) led_C.o led.c + $(LD) -Ttext $(TEXT_BASE) -g led_S.o led_C.o -o led.o + $(OBJCOPY) -O binary -S led.o $(IMAGE)/led_on + +clean: + rm -f *.o + rm -f led_on + rm -f $(IMAGE)/* + diff --git a/qiboot/src/led.S b/qiboot/src/led.S new file mode 100644 index 0000000..8e539df --- /dev/null +++ b/qiboot/src/led.S @@ -0,0 +1,12 @@ +.global _start +_start: + ldr sp,=1024*4 + +.extern main + bl main +.global delay +delay: + subs r0,r0,#0x1 + bne delay + mov pc,lr + diff --git a/qiboot/src/led.c b/qiboot/src/led.c new file mode 100644 index 0000000..5e8447b --- /dev/null +++ b/qiboot/src/led.c @@ -0,0 +1,29 @@ +#define GPBCON (*(volatile unsigned *)0x56000010) +#define GPBDAT (*(volatile unsigned *)0x56000014) +#define GPBDW (*(volatile unsigned *)0x56000018) +#define LED3_ON() (GPBDAT &= ~(0x1)) +#define LED4_ON() (GPBDAT &= ~(0x2)) +#define LED3_OFF() (GPBDAT |= (0x1)) +#define LED4_OFF() (GPBDAT |= (0x2)) + +extern void delay(int time); + +int main() +{ + GPBCON = 0x5; + GPBDW = 0xffff; + while(1) + { + LED3_ON(); + delay(0xffff); + LED3_OFF() ; + delay(0xffff); + + LED4_ON(); + delay(0xffff); + LED4_OFF(); + delay(0xffff); + } + return 1; +} +