Paparazzi UAS  v5.15_devel-81-gd13dafb
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces 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 #include "generated/modules.h"
39 
40 // Include Standard Camera Control Interface
41 #include "dc.h"
42 
43 #include "mcu_periph/gpio.h"
44 
45 #ifndef DC_PUSH
46 #define DC_PUSH gpio_set
47 #endif
48 
49 #ifndef DC_RELEASE
50 #define DC_RELEASE gpio_clear
51 #endif
52 
54 #ifndef DC_SHUTTER_DELAY
55 #define DC_SHUTTER_DELAY 0.5
56 #endif
57 
59 #ifndef DC_POWER_OFF_DELAY
60 #define DC_POWER_OFF_DELAY 0.75
61 #endif
62 
63 #ifdef DC_SHUTTER_LED
64 #warning DC_SHUTTER_LED is obsolete, please use DC_SHUTTER_GPIO
65 #endif
66 #ifndef DC_SHUTTER_GPIO
67 #error DC: Please specify at least a DC_SHUTTER_GPIO (e.g. <define name="DC_SHUTTER_GPIO" value="GPIOC,GPIO12"/>)
68 #endif
69 
70 
71 // Button Timer
73 
75 {
76  // Call common DC init
77  dc_init();
78 
79  // Do gpio specific DC init
80  dc_timer = 0;
81 
82  gpio_setup_output(DC_SHUTTER_GPIO);
83  DC_RELEASE(DC_SHUTTER_GPIO);
84 #ifdef DC_ZOOM_IN_GPIO
85  gpio_setup_output(DC_ZOOM_IN_GPIO);
86  DC_RELEASE(DC_ZOOM_IN_GPIO);
87 #endif
88 #ifdef DC_ZOOM_OUT_GPIO
89  gpio_setup_output(DC_ZOOM_OUT_GPIO);
90  DC_RELEASE(DC_ZOOM_OUT_GPIO);
91 #endif
92 #ifdef DC_POWER_GPIO
93  gpio_setup_output(DC_POWER_GPIO);
94  DC_RELEASE(DC_POWER_GPIO);
95 #endif
96 #ifdef DC_POWER_OFF_GPIO
97  gpio_setup_output(DC_POWER_OFF_GPIO);
98  DC_RELEASE(DC_POWER_OFF_GPIO);
99 #endif
100 }
101 
103 {
104 #ifdef DC_SHOOT_ON_BUTTON_RELEASE
105  if (dc_timer == 1) {
107  }
108 #endif
109 
110  if (dc_timer) {
111  dc_timer--;
112  } else {
113  DC_RELEASE(DC_SHUTTER_GPIO);
114 #ifdef DC_ZOOM_IN_GPIO
115  DC_RELEASE(DC_ZOOM_IN_GPIO);
116 #endif
117 #ifdef DC_ZOOM_OUT_GPIO
118  DC_RELEASE(DC_ZOOM_OUT_GPIO);
119 #endif
120 #ifdef DC_POWER_GPIO
121  DC_RELEASE(DC_POWER_GPIO);
122 #endif
123 #ifdef DC_POWER_OFF_GPIO
124  DC_RELEASE(DC_POWER_OFF_GPIO);
125 #endif
126  }
127 
128  // Common DC Periodic task
129  dc_periodic();
130 }
131 
132 /* Command The Camera */
134 {
135  dc_timer = DC_SHUTTER_DELAY * GPIO_CAM_CTRL_PERIODIC_FREQ;
136 
137  switch (cmd) {
138  case DC_SHOOT:
139  DC_PUSH(DC_SHUTTER_GPIO);
140 #ifndef DC_SHOOT_ON_BUTTON_RELEASE
142 #endif
143  break;
144 #ifdef DC_ZOOM_IN_GPIO
145  case DC_TALLER:
146  DC_PUSH(DC_ZOOM_IN_GPIO);
147  break;
148 #endif
149 #ifdef DC_ZOOM_OUT_GPIO
150  case DC_WIDER:
151  DC_PUSH(DC_ZOOM_OUT_GPIO);
152  break;
153 #endif
154 #ifdef DC_POWER_GPIO
155  case DC_ON:
156  DC_PUSH(DC_POWER_GPIO);
157  break;
158 #endif
159 #ifdef DC_POWER_OFF_GPIO
160  case DC_OFF:
161  DC_PUSH(DC_POWER_OFF_GPIO);
162  dc_timer = DC_POWER_OFF_DELAY * GPIO_CAM_CTRL_PERIODIC_FREQ;
163  break;
164 #endif
165  default:
166  break;
167  }
168 
169  // call command send_command function
171 }
#define DC_RELEASE
Definition: gpio_cam_ctrl.c:50
void dc_send_command(uint8_t cmd)
Send Command To Camera.
Some architecture independent helper functions for GPIOs.
#define DC_PUSH
Definition: gpio_cam_ctrl.c:46
void gpio_setup_output(ioportid_t port, uint16_t gpios)
Setup one or more pins of the given GPIO port as outputs.
Definition: gpio_arch.c:33
void dc_init(void)
initialize settings
Definition: dc.c:156
Definition: dc.h:100
Definition: dc.h:103
Standard Digital Camera Control Interface.
void dc_send_command_common(uint8_t cmd)
Command sending function.
Definition: dc.c:189
Definition: dc.h:102
Definition: dc.h:116
#define DC_SHUTTER_DELAY
how long to push shutter in seconds
Definition: gpio_cam_ctrl.c:55
unsigned char uint8_t
Definition: types.h:14
void dc_periodic(void)
periodic function
Definition: dc.c:273
void gpio_cam_ctrl_periodic(void)
Periodic.
void gpio_cam_ctrl_init(void)
Definition: gpio_cam_ctrl.c:74
Digital Camera Control.
Definition: dc.h:115
#define DC_POWER_OFF_DELAY
how long to send power off in seconds
Definition: gpio_cam_ctrl.c:60
void dc_send_shot_position(void)
Send Down the coordinates of where the photo was taken.
Definition: dc.c:104
uint8_t dc_timer
Definition: gpio_cam_ctrl.c:72