On 21:09 Wed 07 Jan , Ulf Samuelsson wrote: > This patch allows any board implementing the coloured LED API > to control the LEDs from the console. > > led [green | yellow | red | all ] [ on | off ] > > or > > led [ 1 | 2 | 3 | all ] [ on | off ] > > > Adds configuration item CONFIG_CMD_LED enabling the command. > > The coloured led API is available as part of the status_led API. > Not every board with the coloured LED support implements the > status led, so the coloured LED API is separated out > from include/status_led. h to "include/coloured_led.h". > From > > ------------------------------------------------------------------------------- > Patch [1/1] Updates to include/asm-arm/arch.at91rm9200 > > > [1/5] AFFECTS > common/cmd_led.c > common/Makefile > include/coloured_led.h > include/status_led.h to here should be after the ---
please use git format-patch to generate the patch also > > > > Signed-off-by: Ulf Samuelsson <ulf.samuels...@atmel.com> > --- > diff -urN u-boot-2009.01-0rig//common/cmd_led.c > u-boot-2009.01/common/cmd_led.c > --- u-boot-2009.01-0rig//common/cmd_led.c 1970-01-01 01:00:00.000000000 > +0100 > +++ u-boot-2009.01/common/cmd_led.c 2009-01-03 23:39:57.000000000 +0100 > @@ -0,0 +1,84 @@ > +/* > + * (C) Copyright 2008 > + * Ulf Samuelsson <ulf.samuels...@atmel.com> > + * > + * See file CREDITS for list of people who contributed to this > + * project. > + * > + * 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 > + */ > + > +/* > + * This file provides a shell like 'test' function to return > + * true/false from an integer or string compare of two memory > + * locations or a location and a scalar/literal. > + * A few parts were lifted from bash 'test' command > + */ > + > +#include <common.h> > +#include <config.h> > +#include <command.h> > +#include <coloured_led.h> > + > +int do_led ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[] ) please use thie int do_led(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) > +{ > + int led; please add an empty line > + /* Validate arguments */ > + if ((argc != 3)){ please add a spece before '{' > + printf("Usage:\n%s\n", cmdtp->usage); > + return 1; > + } > + if (strcmp(argv[1], "1") == 0) { > + led = (1 << 0); > + } else if (strcmp(argv[1], "2") == 0) { > + led = (1 << 1); > + } else if (strcmp(argv[1], "3") == 0) { > + led = (1 << 2); > + } else if (strcmp(argv[1], "green") == 0) { > + led = (1 << 0); > + } else if (strcmp(argv[1], "yellow") == 0) { > + led = (1 << 1); > + } else if (strcmp(argv[1], "red") == 0) { > + led = (1 << 2); > + } else if (strcmp(argv[1], "all") == 0) { > + led = 7; > + } else { > + printf ("Usage:\n%s\n", cmdtp->usage); > + return 1; > + } > + > + if (strcmp(argv[2], "off") == 0) { > + if(led & 1) green_LED_off(); please use switch > + if(led & 2) yellow_LED_off(); > + if(led & 4) red_LED_off(); > + } else if (strcmp(argv[2], "on") == 0) { > + if(led & 1) green_LED_on(); please use switch > + if(led & 2) yellow_LED_on(); > + if(led & 4) red_LED_on(); > + } else { > + printf ("Usage:\n%s\n", cmdtp->usage); > + return 1; > + } > + > + return 0; > +} > + > +U_BOOT_CMD( > + led, 3, 1, do_led, > + "led\t- [1|2|3|green|yellow|red|all] [on|off]\n", > + "led [1|2|3|green|yellow|red|all] [on|off] sets /clears led 1,2,3\n" > +); > + > diff -urN u-boot-2009.01-0rig//common/Makefile > u-boot-2009.01/common/Makefile > --- u-boot-2009.01-0rig//common/Makefile 2009-01-02 21:18:24.000000000 > +0100 > +++ u-boot-2009.01/common/Makefile 2009-01-03 23:41:53.000000000 +0100 > @@ -99,6 +99,7 @@ > COBJS-$(CONFIG_CMD_IRQ) += cmd_irq.o > COBJS-$(CONFIG_CMD_ITEST) += cmd_itest.o > COBJS-$(CONFIG_CMD_JFFS2) += cmd_jffs2.o > +COBJS-$(CONFIG_CMD_LED) += cmd_led.o > COBJS-$(CONFIG_CMD_LICENSE) += cmd_license.o > COBJS-y += cmd_load.o > COBJS-$(CONFIG_LOGBUFFER) += cmd_log.o > diff -urN u-boot-2009.01-0rig//include/coloured_led.h > u-boot-2009.01/include/coloured_led.h > --- u-boot-2009.01-0rig//include/coloured_led.h 1970-01-01 > 01:00:00.000000000 +0100 > +++ u-boot-2009.01/include/coloured_led.h 2009-01-03 23:39:19.000000000 > +0100 > @@ -0,0 +1,62 @@ > +#ifndef _COLOURED_LED_H_ > +#define _COLOURED_LED_H_ > + > +#ifdef CONFIG_COLOURED_LED > + > +/* > + * Coloured LEDs API > + */ > +#ifndef __ASSEMBLY__ > +extern void coloured_LED_init (void); > +extern void red_LED_on(void); > +extern void red_LED_off(void); > +extern void green_LED_on(void); > +extern void green_LED_off(void); > +extern void yellow_LED_on(void); > +extern void yellow_LED_off(void); > +#else > + .extern LED_init > + .extern red_LED_on > + .extern red_LED_off > + .extern yellow_LED_on > + .extern yellow_LED_off > + .extern green_LED_on > + .extern green_LED_off > +#endif > + > +#endif /* CONFIG_COLOURED_LED */ > + > +#endif /* _STATUS_COLOURED_H_ */ > + > diff -urN u-boot-2009.01-0rig//include/status_led.h > u-boot-2009.01/include/status_led.h > --- u-boot-2009.01-0rig//include/status_led.h 2008-12-16 > 23:48:27.000000000 +0100 > +++ u-boot-2009.01/include/status_led.h 2009-01-03 23:44:40.000000000 > +0100 > @@ -383,27 +383,6 @@ > # include <asm/status_led.h> > #endif > > -/* > - * Coloured LEDs API > - */ > -#ifndef __ASSEMBLY__ > -extern void coloured_LED_init (void); > -extern void red_LED_on(void); > -extern void red_LED_off(void); > -extern void green_LED_on(void); > -extern void green_LED_off(void); > -extern void yellow_LED_on(void); > -extern void yellow_LED_off(void); > -#else > - .extern LED_init > - .extern red_LED_on > - .extern red_LED_off > - .extern yellow_LED_on > - .extern yellow_LED_off > - .extern green_LED_on > - .extern green_LED_off > -#endif > - > #endif /* CONFIG_STATUS_LED */ > > #endif /* _STATUS_LED_H_ */ > after --- > Best Regards > Ulf Samuelsson > please add a READMRE too Best Regards, J. _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot