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
gpio_cam_ctrl.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2010-2014 The Paparazzi Team
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 
36 #include "gpio_cam_ctrl.h"
37 #include "generated/airframe.h"
38 
39 // Include Standard Camera Control Interface
40 #include "dc.h"
41 
42 #include "mcu_periph/gpio.h"
43 
44 #ifndef DC_PUSH
45 #define DC_PUSH gpio_set
46 #endif
47 
48 #ifndef DC_RELEASE
49 #define DC_RELEASE gpio_clear
50 #endif
51 
52 #ifndef DC_SHUTTER_DELAY
53 #define DC_SHUTTER_DELAY 2 /* 4Hz -> 0.5s */
54 #endif
55 
56 #ifndef DC_POWER_OFF_DELAY
57 #define DC_POWER_OFF_DELAY 3
58 #endif
59 
60 #ifdef DC_SHUTTER_LED
61 #warning DC_SHUTTER_LED is obsolete, please use DC_SHUTTER_GPIO
62 #endif
63 #ifndef DC_SHUTTER_GPIO
64 #error DC: Please specify at least a DC_SHUTTER_GPIO (e.g. <define name="DC_SHUTTER_GPIO" value="GPIOC,GPIO12"/>)
65 #endif
66 
67 
68 // Button Timer
70 
72 {
73  // Call common DC init
74  dc_init();
75 
76  // Do gpio specific DC init
77  dc_timer = 0;
78 
79  gpio_setup_output(DC_SHUTTER_GPIO);
80  DC_RELEASE(DC_SHUTTER_GPIO);
81 #ifdef DC_ZOOM_IN_GPIO
82  gpio_setup_output(DC_ZOOM_IN_GPIO);
83  DC_RELEASE(DC_ZOOM_IN_GPIO);
84 #endif
85 #ifdef DC_ZOOM_OUT_GPIO
86  gpio_setup_output(DC_ZOOM_OUT_GPIO);
87  DC_RELEASE(DC_ZOOM_OUT_GPIO);
88 #endif
89 #ifdef DC_POWER_GPIO
90  gpio_setup_output(DC_POWER_GPIO);
91  DC_RELEASE(DC_POWER_GPIO);
92 #endif
93 #ifdef DC_POWER_OFF_GPIO
94  gpio_setup_output(DC_POWER_OFF_GPIO);
95  DC_RELEASE(DC_POWER_OFF_GPIO);
96 #endif
97 }
98 
100 {
101 #ifdef DC_SHOOT_ON_BUTTON_RELEASE
102  if (dc_timer==1) {
104  }
105 #endif
106 
107  if (dc_timer) {
108  dc_timer--;
109  } else {
110  DC_RELEASE(DC_SHUTTER_GPIO);
111 #ifdef DC_ZOOM_IN_GPIO
112  DC_RELEASE(DC_ZOOM_IN_GPIO);
113 #endif
114 #ifdef DC_ZOOM_OUT_GPIO
115  DC_RELEASE(DC_ZOOM_OUT_GPIO);
116 #endif
117 #ifdef DC_POWER_GPIO
118  DC_RELEASE(DC_POWER_GPIO);
119 #endif
120 #ifdef DC_POWER_OFF_GPIO
121  DC_RELEASE(DC_POWER_OFF_GPIO);
122 #endif
123  }
124 
125  // Common DC Periodic task
126  dc_periodic_4Hz();
127 }
128 
129 /* Command The Camera */
131 {
133  switch (cmd)
134  {
135  case DC_SHOOT:
136  DC_PUSH(DC_SHUTTER_GPIO);
137 #ifndef DC_SHOOT_ON_BUTTON_RELEASE
139 #endif
140  break;
141 #ifdef DC_ZOOM_IN_GPIO
142  case DC_TALLER:
143  DC_PUSH(DC_ZOOM_IN_GPIO);
144  break;
145 #endif
146 #ifdef DC_ZOOM_OUT_GPIO
147  case DC_WIDER:
148  DC_PUSH(DC_ZOOM_OUT_GPIO);
149  break;
150 #endif
151 #ifdef DC_POWER_GPIO
152  case DC_ON:
153  DC_PUSH(DC_POWER_GPIO);
154  break;
155 #endif
156 #ifdef DC_POWER_OFF_GPIO
157  case DC_OFF:
158  DC_PUSH(DC_POWER_OFF_GPIO);
160  break;
161 #endif
162  default:
163  break;
164  }
165 }
#define dc_send_shot_position()
Definition: dc.h:126
#define DC_RELEASE
void dc_send_command(uint8_t cmd)
Some architecture independent helper functions for GPIOs.
#define DC_PUSH
Definition: dc.h:82
Definition: dc.h:85
Standard Digital Camera Control Interface.
static void dc_periodic_4Hz(void)
Definition: dc.h:229
Definition: dc.h:84
Definition: dc.h:98
#define DC_SHUTTER_DELAY
unsigned char uint8_t
Definition: types.h:14
static void gpio_setup_output(uint32_t port, uint32_t gpios)
Setup one or more pins of the given GPIO port as outputs.
Definition: gpio_arch.h:76
void gpio_cam_ctrl_periodic(void)
4Hz Periodic
Definition: gpio_cam_ctrl.c:99
void gpio_cam_ctrl_init(void)
Definition: gpio_cam_ctrl.c:71
Digital Camera Control.
Definition: dc.h:97
#define DC_POWER_OFF_DELAY
Definition: gpio_cam_ctrl.c:57
static void dc_init(void)
Definition: dc.h:198
uint8_t dc_timer
Definition: gpio_cam_ctrl.c:69