Skip to content

Commit 296a190

Browse files
committed
Enabled leds on FMU again
1 parent 44df8db commit 296a190

File tree

5 files changed

+54
-26
lines changed

5 files changed

+54
-26
lines changed

makefiles/config_px4fmu_default.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ MODULES += drivers/device
1414
MODULES += drivers/stm32
1515
MODULES += drivers/stm32/adc
1616
MODULES += drivers/stm32/tone_alarm
17+
MODULES += drivers/led
1718
MODULES += drivers/px4io
1819
MODULES += drivers/px4fmu
1920
MODULES += drivers/boards/px4fmu

src/drivers/boards/px4fmu/module.mk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ SRCS = px4fmu_can.c \
66
px4fmu_init.c \
77
px4fmu_pwm_servo.c \
88
px4fmu_spi.c \
9-
px4fmu_usb.c
9+
px4fmu_usb.c \
10+
px4fmu_led.c

src/drivers/boards/px4fmu/px4fmu_init.c

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/****************************************************************************
22
*
3-
* Copyright (C) 2012 PX4 Development Team. All rights reserved.
3+
* Copyright (c) 2012, 2013 PX4 Development Team. All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
66
* modification, are permitted provided that the following conditions
@@ -91,6 +91,19 @@
9191
# endif
9292
#endif
9393

94+
/*
95+
* Ideally we'd be able to get these from up_internal.h,
96+
* but since we want to be able to disable the NuttX use
97+
* of leds for system indication at will and there is no
98+
* separate switch, we need to build independent of the
99+
* CONFIG_ARCH_LEDS configuration switch.
100+
*/
101+
__BEGIN_DECLS
102+
extern void led_init();
103+
extern void led_on(int led);
104+
extern void led_off(int led);
105+
__END_DECLS
106+
94107
/****************************************************************************
95108
* Protected Functions
96109
****************************************************************************/
@@ -114,7 +127,7 @@ __EXPORT void stm32_boardinitialize(void)
114127
/* configure SPI interfaces */
115128
stm32_spiinitialize();
116129

117-
/* configure LEDs */
130+
/* configure LEDs (empty call to NuttX' ledinit) */
118131
up_ledinit();
119132
}
120133

@@ -178,11 +191,11 @@ __EXPORT int nsh_archinitialize(void)
178191
(hrt_callout)stm32_serial_dma_poll,
179192
NULL);
180193

181-
// initial LED state
182-
// drv_led_start();
183-
up_ledoff(LED_BLUE);
184-
up_ledoff(LED_AMBER);
185-
up_ledon(LED_BLUE);
194+
/* initial LED state */
195+
drv_led_start();
196+
led_off(LED_AMBER);
197+
led_on(LED_BLUE);
198+
186199

187200
/* Configure SPI-based devices */
188201

src/drivers/boards/px4fmu/px4fmu_led.c

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,27 +39,35 @@
3939

4040
#include <nuttx/config.h>
4141

42-
#include <stdint.h>
4342
#include <stdbool.h>
44-
#include <debug.h>
4543

46-
#include <arch/board/board.h>
47-
48-
#include "chip.h"
49-
#include "up_arch.h"
50-
#include "up_internal.h"
5144
#include "stm32_internal.h"
5245
#include "px4fmu_internal.h"
5346

54-
__EXPORT void up_ledinit()
47+
#include <arch/board/board.h>
48+
49+
/*
50+
* Ideally we'd be able to get these from up_internal.h,
51+
* but since we want to be able to disable the NuttX use
52+
* of leds for system indication at will and there is no
53+
* separate switch, we need to build independent of the
54+
* CONFIG_ARCH_LEDS configuration switch.
55+
*/
56+
__BEGIN_DECLS
57+
extern void led_init();
58+
extern void led_on(int led);
59+
extern void led_off(int led);
60+
__END_DECLS
61+
62+
__EXPORT void led_init()
5563
{
5664
/* Configure LED1-2 GPIOs for output */
5765

5866
stm32_configgpio(GPIO_LED1);
5967
stm32_configgpio(GPIO_LED2);
6068
}
6169

62-
__EXPORT void up_ledon(int led)
70+
__EXPORT void led_on(int led)
6371
{
6472
if (led == 0)
6573
{
@@ -73,7 +81,7 @@ __EXPORT void up_ledon(int led)
7381
}
7482
}
7583

76-
__EXPORT void up_ledoff(int led)
84+
__EXPORT void led_off(int led)
7785
{
7886
if (led == 0)
7987
{

src/drivers/led/led.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,17 @@
4141
#include <drivers/device/device.h>
4242
#include <drivers/drv_led.h>
4343

44-
/* Ideally we'd be able to get these from up_internal.h */
45-
//#include <up_internal.h>
44+
/*
45+
* Ideally we'd be able to get these from up_internal.h,
46+
* but since we want to be able to disable the NuttX use
47+
* of leds for system indication at will and there is no
48+
* separate switch, we need to build independent of the
49+
* CONFIG_ARCH_LEDS configuration switch.
50+
*/
4651
__BEGIN_DECLS
47-
extern void up_ledinit();
48-
extern void up_ledon(int led);
49-
extern void up_ledoff(int led);
52+
extern void led_init();
53+
extern void led_on(int led);
54+
extern void led_off(int led);
5055
__END_DECLS
5156

5257
class LED : device::CDev
@@ -74,7 +79,7 @@ int
7479
LED::init()
7580
{
7681
CDev::init();
77-
up_ledinit();
82+
led_init();
7883

7984
return 0;
8085
}
@@ -86,11 +91,11 @@ LED::ioctl(struct file *filp, int cmd, unsigned long arg)
8691

8792
switch (cmd) {
8893
case LED_ON:
89-
up_ledon(arg);
94+
led_on(arg);
9095
break;
9196

9297
case LED_OFF:
93-
up_ledoff(arg);
98+
led_off(arg);
9499
break;
95100

96101
default:

0 commit comments

Comments
 (0)