summaryrefslogtreecommitdiff
path: root/cleopatre/application/managerd
diff options
context:
space:
mode:
authorCeline Buret2010-10-29 15:44:03 +0200
committerCeline Buret2010-10-29 15:59:44 +0200
commita92f102a1e7ed39a6982a8f0a1b4973837a08900 (patch)
tree948e2e203541194b899f43e403b70aa6223ee5d6 /cleopatre/application/managerd
parent35e1f9ad9686943d69c8fc895636c23ac5890d71 (diff)
cleo/app/mgrd: rename sc and led files into gpio_event, closes #2010
Diffstat (limited to 'cleopatre/application/managerd')
-rw-r--r--cleopatre/application/managerd/inc/gpio_event.h (renamed from cleopatre/application/managerd/inc/led.h)44
-rw-r--r--cleopatre/application/managerd/inc/simple_connect.h67
-rw-r--r--cleopatre/application/managerd/src/gpio_event.c (renamed from cleopatre/application/managerd/src/led.c)106
-rw-r--r--cleopatre/application/managerd/src/managerd.c4
-rw-r--r--cleopatre/application/managerd/src/simple_connect.c135
5 files changed, 143 insertions, 213 deletions
diff --git a/cleopatre/application/managerd/inc/led.h b/cleopatre/application/managerd/inc/gpio_event.h
index ba28b09125..422a52e3b8 100644
--- a/cleopatre/application/managerd/inc/led.h
+++ b/cleopatre/application/managerd/inc/gpio_event.h
@@ -1,13 +1,13 @@
/*
- * cleopatre/application/managerd/inc/led.h
+ * cleopatre/application/managerd/inc/gpio_event.h
*
* (C) Copyright 2010 SPiDCOM Technologies
- *
+ *
* 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
@@ -18,13 +18,16 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*/
-#ifndef LED_H
-#define LED_H
+#ifndef GPIO_EVENT_H
+#define GPIO_EVENT_H
#include "../../linux/autoconf.h"
struct managerd_ctx;
+/** GPIO number for SC button and it associated LED */
+#define SC_BUT_GPIO_NUM 1
+
/** LED GPIO numbers */
#define LED_ATTACHMENT_GPIO_NUM 3
#if (defined CONFIG_MACH_SPK300G || defined CONFIG_MACH_SPK300)
@@ -36,6 +39,35 @@ struct managerd_ctx;
#define LED_FAST_TIMER_US 100000
#define LED_LOW_TIMER_US 500000
+/** name of the gpio device */
+#define GPIO_DEVICE_NAME "/dev/gpio"
+
+/**
+ * Simple Connect detection event.
+ *
+ * \param ctx managerd context
+ * \return error code
+ */
+int
+simple_connect_event (struct managerd_ctx *ctx);
+
+/**
+ * Open and set GPIO direction.
+ *
+ * \param ctx managerd context
+ * \return error code
+ */
+int
+simple_connect_init (struct managerd_ctx *ctx);
+
+/**
+ * Close gpio device.
+ *
+ * \param ctx managerd context
+ */
+void
+simple_connect_uninit (struct managerd_ctx *ctx);
+
/**
* Handle SIGALRM reception.
*
@@ -100,4 +132,4 @@ led_init (struct managerd_ctx *ctx);
void
led_uninit (struct managerd_ctx *ctx);
-#endif /* LED_H */
+#endif /* GPIO_EVENT_H */
diff --git a/cleopatre/application/managerd/inc/simple_connect.h b/cleopatre/application/managerd/inc/simple_connect.h
deleted file mode 100644
index 8a06c4283b..0000000000
--- a/cleopatre/application/managerd/inc/simple_connect.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * cleopatre/application/managerd/inc/simple_connect.h
- *
- * (C) Copyright 2009 SPiDCOM Technologies
- *
- * 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
- */
-#ifndef SIMPLE_CONNECT_H
-#define SIMPLE_CONNECT_H
-
-#include "managerd.h"
-
-/** GPIO number for SC button and it associated LED */
-#define SC_BUT_GPIO_NUM 1
-
-/** name of the gpio device */
-#define GPIO_DEVICE_NAME "/dev/gpio"
-
-/**
- * Simple Connect detection event.
- *
- * \param ctx managerd context
- * \return error code
- */
-int
-simple_connect_event (struct managerd_ctx *ctx);
-
-/**
- * Simple Connect reset event.
- *
- * \param ctx managerd context
- * \return error code
- */
-int
-simple_connect_reset (struct managerd_ctx *ctx);
-
-/**
- * Open and set GPIO direction.
- *
- * \param ctx managerd context
- * \return error code
- */
-int
-simple_connect_init (struct managerd_ctx *ctx);
-
-/**
- * Close gpio device.
- *
- * \param ctx managerd context
- */
-void
-simple_connect_uninit (struct managerd_ctx *ctx);
-
-#endif /* SIMPLE_CONNECT_H */
diff --git a/cleopatre/application/managerd/src/led.c b/cleopatre/application/managerd/src/gpio_event.c
index 189ed87e6a..dd569257cb 100644
--- a/cleopatre/application/managerd/src/led.c
+++ b/cleopatre/application/managerd/src/gpio_event.c
@@ -1,5 +1,5 @@
/*
- * cleopatre/application/managerd/src/led.c
+ * cleopatre/application/managerd/src/gpio_event.c
*
* (C) Copyright 2010 SPiDCOM Technologies
*
@@ -33,13 +33,115 @@
#include "../../linux/gpio.h"
#include "managerd.h"
-#include "led.h"
+#include "gpio_event.h"
/* Global variable for "/dev/gpio" file descriptor
* needed during SIGALRM signal handling */
int gpio_fd = -1;
/**
+ * Simple Connect detection event.
+ *
+ * \param ctx managerd context
+ * \return error code
+ */
+int
+simple_connect_event (struct managerd_ctx *ctx)
+{
+ if (!ctx->is_sc_available)
+ return 0;
+
+ /* Write SC button GPIO status */
+ libspid_config_write_item (LIBSPID_HPAV_INFO_PATH,
+ LIBSPID_HPAV_INFO_LABEL_SC_BUTTON,
+ "yes");
+
+ /* plc daemon needs to be informed */
+ if (LIBSPID_SUCCESS != libspid_system_file_update_warn (getpid(),
+ LIBSPID_HPAV_INFO_PATH))
+ {
+ syslog (LOG_WARNING, "libspid system file update warn failed");
+ return -1;
+ }
+
+ return 0;
+}
+
+/**
+ * Open and set GPIO direction.
+ *
+ * \param ctx managerd context
+ * \return error code
+ */
+int
+simple_connect_init (struct managerd_ctx *ctx)
+{
+ /* Check arguments */
+ assert (ctx != NULL);
+
+ /* Set GPIO info for SC button */
+ ctx->sc_gpio.gpiodir.num = SC_BUT_GPIO_NUM;
+ ctx->sc_gpio.gpiodir.dir = SPC300_GPIO_DIRECTION_INPUT;
+
+ /* Set GPIO info for SC button interruption */
+ ctx->sc_it.gpioit.enable = 1;
+ ctx->sc_it.gpioit.mask = (1 << SC_BUT_GPIO_NUM);
+
+ /* Open GPIO device */
+ if (0 > (ctx->gpio_fd = open (GPIO_DEVICE_NAME, O_RDWR)))
+ {
+ syslog (LOG_WARNING, "cannot open gpio device (%s)", strerror (errno));
+ return -1;
+ }
+
+ /* Set gpio direction for Simple Connect */
+ if (0 > ioctl (ctx->gpio_fd, GPIOIOC_SETDIRECTION,
+ (unsigned long *) &ctx->sc_gpio))
+ {
+ syslog (LOG_WARNING, "cannot call ioctl for SC gpio (%s)", strerror (errno));
+ }
+ else
+ {
+ ctx->is_sc_available = 1;
+ }
+
+ /* Set GPIO interrupt for SC button */
+ if (0 > ioctl (ctx->gpio_fd, GPIOIOC_SETIT,
+ (unsigned long *) &ctx->sc_it))
+ {
+ syslog (LOG_WARNING, "cannot call ioctl for SC interruption (%s)", strerror (errno));
+ }
+
+ return 0;
+}
+
+/**
+ * Close gpio device.
+ *
+ * \param ctx managerd context
+ */
+void
+simple_connect_uninit (struct managerd_ctx *ctx)
+{
+ /* Check arguments */
+ assert (ctx != NULL);
+
+ /* Reet GPIO info for SC button interruption */
+ ctx->sc_it.gpioit.enable = 0;
+ ctx->sc_it.gpioit.mask = 0;
+
+ /* Reset GPIO interrupt for SC button */
+ if (0 > ioctl (ctx->gpio_fd, GPIOIOC_SETIT,
+ (unsigned long *) &ctx->sc_it))
+ {
+ syslog (LOG_WARNING, "cannot call ioctl for SC interruption (%s)", strerror (errno));
+ }
+
+ /* Close GPIO device */
+ close (ctx->gpio_fd);
+}
+
+/**
* Handle SIGALRM reception.
*
* \param signal_nb signal identifier
diff --git a/cleopatre/application/managerd/src/managerd.c b/cleopatre/application/managerd/src/managerd.c
index 28035c7012..e0949cd9bd 100644
--- a/cleopatre/application/managerd/src/managerd.c
+++ b/cleopatre/application/managerd/src/managerd.c
@@ -28,11 +28,9 @@
#include "bridge.h"
#include "mme_nl.h"
-#include "simple_connect.h"
-#include "led.h"
+#include "gpio_event.h"
#include "managerd.h"
-
/* Global variable indicating if a SIGHUP signal occurred,
* has been caught in managerd signal handler,
* and has now to be processed. */
diff --git a/cleopatre/application/managerd/src/simple_connect.c b/cleopatre/application/managerd/src/simple_connect.c
deleted file mode 100644
index b04edf91b3..0000000000
--- a/cleopatre/application/managerd/src/simple_connect.c
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * cleopatre/application/managerd/src/simple_connect.c
- *
- * (C) Copyright 2009 SPiDCOM Technologies
- *
- * 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 <stdio.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/ioctl.h>
-#include <syslog.h>
-#include <errno.h>
-#include <assert.h>
-#include <stdint.h>
-
-#include "nvram.h"
-#include "../../linux/gpio.h"
-
-#include "simple_connect.h"
-
-/**
- * Simple Connect detection event.
- *
- * \param ctx managerd context
- * \return error code
- */
-int
-simple_connect_event (struct managerd_ctx *ctx)
-{
- if (!ctx->is_sc_available)
- return 0;
-
- /* Write SC button GPIO status */
- libspid_config_write_item (LIBSPID_HPAV_INFO_PATH,
- LIBSPID_HPAV_INFO_LABEL_SC_BUTTON,
- "yes");
-
- /* plc daemon needs to be informed */
- if (LIBSPID_SUCCESS != libspid_system_file_update_warn (getpid(),
- LIBSPID_HPAV_INFO_PATH))
- {
- syslog (LOG_WARNING, "libspid system file update warn failed");
- return -1;
- }
-
- return 0;
-}
-
-/**
- * Open and set GPIO direction.
- *
- * \param ctx managerd context
- * \return error code
- */
-int
-simple_connect_init (struct managerd_ctx *ctx)
-{
- /* Check arguments */
- assert (ctx != NULL);
-
- /* Set GPIO info for SC button */
- ctx->sc_gpio.gpiodir.num = SC_BUT_GPIO_NUM;
- ctx->sc_gpio.gpiodir.dir = SPC300_GPIO_DIRECTION_INPUT;
-
- /* Set GPIO info for SC button interruption */
- ctx->sc_it.gpioit.enable = 1;
- ctx->sc_it.gpioit.mask = (1 << SC_BUT_GPIO_NUM);
-
- /* Open GPIO device */
- if (0 > (ctx->gpio_fd = open (GPIO_DEVICE_NAME, O_RDWR)))
- {
- syslog (LOG_WARNING, "cannot open gpio device (%s)", strerror (errno));
- return -1;
- }
-
- /* Set gpio direction for Simple Connect */
- if (0 > ioctl (ctx->gpio_fd, GPIOIOC_SETDIRECTION,
- (unsigned long *) &ctx->sc_gpio))
- {
- syslog (LOG_WARNING, "cannot call ioctl for SC gpio (%s)", strerror (errno));
- }
- else
- {
- ctx->is_sc_available = 1;
- }
-
- /* Set GPIO interrupt for SC button */
- if (0 > ioctl (ctx->gpio_fd, GPIOIOC_SETIT,
- (unsigned long *) &ctx->sc_it))
- {
- syslog (LOG_WARNING, "cannot call ioctl for SC interruption (%s)", strerror (errno));
- }
-
- return 0;
-}
-
-/**
- * Close gpio device.
- *
- * \param ctx managerd context
- */
-void
-simple_connect_uninit (struct managerd_ctx *ctx)
-{
- /* Check arguments */
- assert (ctx != NULL);
-
- /* Reet GPIO info for SC button interruption */
- ctx->sc_it.gpioit.enable = 0;
- ctx->sc_it.gpioit.mask = 0;
-
- /* Reset GPIO interrupt for SC button */
- if (0 > ioctl (ctx->gpio_fd, GPIOIOC_SETIT,
- (unsigned long *) &ctx->sc_it))
- {
- syslog (LOG_WARNING, "cannot call ioctl for SC interruption (%s)", strerror (errno));
- }
-
- /* Close GPIO device */
- close (ctx->gpio_fd);
-}