diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-11-04 16:08:02 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-11-04 16:08:02 +0000 |
commit | d619bef95e6e08dea3d15b52f991e056fb869ebf (patch) | |
tree | b21dd45a05f6450f4ab40a6eb78dfd10bba59ea8 /nuttx/configs/shenzhou/src/up_relays.c | |
parent | dec5edaa7fcf561f5538ca3ba0af07e402a6b55e (diff) | |
download | px4-nuttx-d619bef95e6e08dea3d15b52f991e056fb869ebf.tar.gz px4-nuttx-d619bef95e6e08dea3d15b52f991e056fb869ebf.tar.bz2 px4-nuttx-d619bef95e6e08dea3d15b52f991e056fb869ebf.zip |
Relay example from Darcy Gong
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5306 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/configs/shenzhou/src/up_relays.c')
-rw-r--r-- | nuttx/configs/shenzhou/src/up_relays.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/nuttx/configs/shenzhou/src/up_relays.c b/nuttx/configs/shenzhou/src/up_relays.c index 075c7d590..6916ee455 100644 --- a/nuttx/configs/shenzhou/src/up_relays.c +++ b/nuttx/configs/shenzhou/src/up_relays.c @@ -42,10 +42,12 @@ #include <stdint.h> #include <unistd.h> +#include <debug.h> +#include <nuttx/arch.h> #include <arch/board/board.h> + #include "shenzhou-internal.h" -#include <debug.h> #ifdef CONFIG_ARCH_RELAYS @@ -62,6 +64,7 @@ ****************************************************************************/ static uint32_t g_relays_stat = 0; +static bool g_relays_init = false; static const uint16_t g_relays[NUM_RELAYS] = { @@ -173,6 +176,11 @@ void up_relaysinit(void) { int i; + if (g_relays_init) + { + return; + } + /* Configure the GPIO pins as inputs. NOTE that EXTI interrupts are * configured for some pins but NOT used in this file */ @@ -180,7 +188,10 @@ void up_relaysinit(void) for (i = 0; i < NUM_RELAYS; i++) { stm32_configgpio(g_relays[i]); + stm32_gpiowrite(g_relays[i], false); } + + g_relays_init = true; } void relays_setstat(int relays,bool stat) |