Paparazzi UAS  v5.2.2_stable-0-gd6b9f29
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
deploy_sonar_buoy.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2010 Eric Parsonage
3  *
4  * This file is part of paparazzi.
5  *
6  * paparazzi is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * paparazzi is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with paparazzi; see the file COPYING. If not, write to
18  * the Free Software Foundation, 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  */
21 #include <stm32/gpio.h>
22 #include <stm32/rcc.h>
23 #include "deploy_sonar_buoy.h"
24 #include "generated/airframe.h"
25 
26 /* simple module to toggle two gpio pins on Lisa.
27  * The application in this was written for drops
28  * two sonar buoys. TODO extend to a generalised
29  * GPIO module
30  */
31 
32 bool_t buoy_1;
33 bool_t buoy_2;
34 
35 /* initialises GPIO pins */
37  /* initialise peripheral clock for port C */
38  RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOC, ENABLE);
39  GPIO_InitTypeDef GPIO_InitStructure;
40  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;
41  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
42  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
43  GPIO_Init(GPIOC, &GPIO_InitStructure);
44  /* set port C pin 5 to be low */
45  GPIO_WriteBit(GPIOC, GPIO_Pin_5 , Bit_RESET );
46 
47  /* initialise peripheral clock for port B */
48  RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOB, ENABLE);
49  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
50  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
51  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
52  GPIO_Init(GPIOB, &GPIO_InitStructure);
53  /* set port B pin 0 to be low */
54  GPIO_WriteBit(GPIOB, GPIO_Pin_0 , Bit_RESET );
55 
56  /* set the variables of interest to be FALSE */
57  buoy_1 = FALSE;
58  buoy_2 = FALSE;
60 }
61 
62 /* sets GPIO pins */
64  GPIO_WriteBit(GPIOC, GPIO_Pin_5 , buoy_1 ? Bit_SET : Bit_RESET );
65  GPIO_WriteBit(GPIOB, GPIO_Pin_0 , buoy_2 ? Bit_SET : Bit_RESET );
66 }
bool_t buoy_1
#define GPIOC
Definition: gpio_arch.h:34
#define GPIOB
Definition: gpio_arch.h:35
#define FALSE
Definition: imu_chimu.h:141
void deploy_sonar_buoy_init(void)
void deploy_sonar_buoy_periodic(void)
bool_t buoy_2