Skip to content

Commit 447a0bc

Browse files
starcatioxiaoxiang781216
authored andcommitted
make userleds work on Arduino Due
- makes the 'leds' example command work: - adds code to initialize the /dev/userleds device - adds defconfig and docs
1 parent 49fa611 commit 447a0bc

File tree

6 files changed

+80
-2
lines changed

6 files changed

+80
-2
lines changed

boards/arm/sam34/arduino-due/README.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,3 +861,9 @@ Configuration sub-directories
861861

862862
STATUS:
863863
2013-7-2: TSC is not responding. All 0's received on SPI.
864+
865+
nsh-leds:
866+
This configuration directory will build the NuttX Shell and enable the user
867+
LEDS (/dev/userleds). It will also enable the LED example program (leds).
868+
Running the leds command will start up an LED daemon which will light up the
869+
L (user), TX, and RX LEDs in a binary sequence.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#
2+
# This file is autogenerated: PLEASE DO NOT EDIT IT.
3+
#
4+
# You can use "make menuconfig" to make any modifications to the installed .config file.
5+
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
6+
# modifications.
7+
#
8+
# CONFIG_ARCH_LEDS is not set
9+
# CONFIG_ARCH_RAMFUNCS is not set
10+
# CONFIG_READLINE_ECHO is not set
11+
CONFIG_ARCH="arm"
12+
CONFIG_ARCH_BOARD="arduino-due"
13+
CONFIG_ARCH_BOARD_ARDUINO_DUE=y
14+
CONFIG_ARCH_CHIP="sam34"
15+
CONFIG_ARCH_CHIP_ATSAM3X8E=y
16+
CONFIG_ARCH_CHIP_SAM34=y
17+
CONFIG_ARCH_CHIP_SAM3X=y
18+
CONFIG_ARCH_STACKDUMP=y
19+
CONFIG_BOARD_LATE_INITIALIZE=y
20+
CONFIG_BOARD_LOOPSPERMSEC=6965
21+
CONFIG_BUILTIN=y
22+
CONFIG_DEV_ZERO=y
23+
CONFIG_EXAMPLES_LEDS=y
24+
CONFIG_FS_PROCFS=y
25+
CONFIG_HAVE_CXX=y
26+
CONFIG_HAVE_CXXINITIALIZE=y
27+
CONFIG_INIT_ENTRYPOINT="nsh_main"
28+
CONFIG_MM_REGIONS=3
29+
CONFIG_NSH_ARCHINIT=y
30+
CONFIG_NSH_BUILTIN_APPS=y
31+
CONFIG_NSH_DISABLE_IFUPDOWN=y
32+
CONFIG_NSH_FILEIOSIZE=512
33+
CONFIG_NSH_READLINE=y
34+
CONFIG_PREALLOC_TIMERS=4
35+
CONFIG_RAM_SIZE=65536
36+
CONFIG_RAM_START=0x20000000
37+
CONFIG_RAW_BINARY=y
38+
CONFIG_RR_INTERVAL=200
39+
CONFIG_SCHED_WAITPID=y
40+
CONFIG_START_DAY=28
41+
CONFIG_START_MONTH=6
42+
CONFIG_START_YEAR=2013
43+
CONFIG_SYSTEM_NSH=y
44+
CONFIG_TASK_NAME_SIZE=32
45+
CONFIG_UART0_SERIAL_CONSOLE=y
46+
CONFIG_USERLED=y
47+
CONFIG_USERLED_LOWER=y

boards/arm/sam34/arduino-due/include/board.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@
147147
* GPIO output to low.
148148
*/
149149

150+
#define LED_DRIVER_PATH "/dev/userleds"
151+
150152
/* LED index values for use with board_userled() */
151153

152154
#define BOARD_LED_L 0

boards/arm/sam34/arduino-due/src/sam_boot.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,5 @@ void board_late_initialize(void)
7474

7575
sam_bringup();
7676
}
77+
7778
#endif

boards/arm/sam34/arduino-due/src/sam_bringup.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,22 @@
2929

3030
#include <nuttx/board.h>
3131
#include <nuttx/fs/fs.h>
32+
#include <nuttx/leds/userled.h>
3233

3334
#include "arduino-due.h"
3435

36+
#include <arch/board/board.h>
37+
3538
/****************************************************************************
3639
* Pre-processor Definitions
3740
****************************************************************************/
3841

42+
#undef HAVE_LEDS
43+
44+
#if !defined(CONFIG_ARCH_LEDS) && defined(CONFIG_USERLED_LOWER)
45+
# define HAVE_LEDS 1
46+
#endif
47+
3948
#if defined(CONFIG_ARDUINO_ITHEAD_TFT) && defined(CONFIG_SPI_BITBANG) && \
4049
defined(CONFIG_MMCSD_SPI)
4150

@@ -116,6 +125,19 @@ int sam_bringup(void)
116125
}
117126
#endif
118127

128+
#ifdef HAVE_LEDS
129+
board_userled_initialize();
130+
131+
/* Register the LED driver */
132+
133+
ret = userled_lower_initialize(LED_DRIVER_PATH);
134+
if (ret < 0)
135+
{
136+
syslog(LOG_ERR, "ERROR: userled_lower_initialize() failed: %d\n", ret);
137+
return ret;
138+
}
139+
#endif
140+
119141
UNUSED(ret);
120142
return OK;
121143
}

boards/arm/sam34/arduino-due/src/sam_userleds.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@
2828
#include <stdbool.h>
2929
#include <debug.h>
3030

31-
#include <arch/board/board.h>
32-
3331
#include "chip.h"
3432
#include "sam_gpio.h"
3533
#include "arduino-due.h"
3634

35+
#include <arch/board/board.h>
36+
3737
#ifndef CONFIG_ARCH_LEDS
3838

3939
/****************************************************************************

0 commit comments

Comments
 (0)