mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-02 17:41:35 +08:00
Relay example from Darcy Gong
git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5306 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
@@ -393,9 +393,11 @@
|
||||
|
||||
/* Relays */
|
||||
|
||||
#define NUM_RELAYS 1
|
||||
#define NUM_RELAYS 2
|
||||
#define GPIO_RELAYS_R00 (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|\
|
||||
GPIO_OUTPUT_SET|GPIO_PORTE|GPIO_PIN0)
|
||||
#define GPIO_RELAYS_R01 (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|\
|
||||
GPIO_OUTPUT_SET|GPIO_PORTE|GPIO_PIN1)
|
||||
|
||||
/****************************************************************************************************
|
||||
* Public Types
|
||||
|
||||
@@ -42,11 +42,13 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <arch/board/board.h>
|
||||
#include "shenzhou-internal.h"
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#include "shenzhou-internal.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)
|
||||
|
||||
Reference in New Issue
Block a user