Paparazzi UAS  v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
atmega_i2c_cam_ctrl.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2010 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  */
22 
23 
31 #include "atmega_i2c_cam_ctrl.h"
32 
33 #include "mcu_periph/i2c.h"
34 #include "led.h"
35 
36 #include "mcu_periph/uart.h"
37 #include "pprzlink/messages.h"
39 
40 // In I2C mode we can not inline this function:
42 {
44 
45  // call command send_command function
47 }
48 
50 
51 #ifndef ATMEGA_I2C_DEV
52 #define ATMEGA_I2C_DEV i2c0
53 #endif
54 
55 
56 #ifndef ATMEGA_SLAVE_ADDR
57 #define ATMEGA_SLAVE_ADDR 0x68
58 #endif
59 
61 
63 {
65  dc_init();
66 }
67 
69 {
71  dc_periodic();
72 
73  // Request Status
76  }
77 }
78 
79 
80 
82 {
84 
85  // Send Command
88 
89  if (cmd == DC_SHOOT) {
91  }
92 }
93 
95 {
97  unsigned char cam_ret[1];
98  cam_ret[0] = atmega_i2c_cam_ctrl_trans.buf[0];
99  RunOnceEvery(6, DOWNLINK_SEND_PAYLOAD(DefaultChannel, DefaultDevice, 1, cam_ret));
101  }
102 }
dc_send_command_common
void dc_send_command_common(uint8_t cmd)
Command sending function.
Definition: dc.c:189
i2c_transaction::buf
volatile uint8_t buf[I2C_BUF_LEN]
Transaction buffer With I2C_BUF_LEN number of bytes.
Definition: i2c.h:122
atmega_i2c_cam_ctrl_trans
static struct i2c_transaction atmega_i2c_cam_ctrl_trans
Definition: atmega_i2c_cam_ctrl.c:49
atmega_i2c_cam_ctrl_periodic
void atmega_i2c_cam_ctrl_periodic(void)
Definition: atmega_i2c_cam_ctrl.c:68
atmega_i2c_cam_ctrl_send
void atmega_i2c_cam_ctrl_send(uint8_t cmd)
Definition: atmega_i2c_cam_ctrl.c:81
atmega_i2c_cam_ctrl_event
void atmega_i2c_cam_ctrl_event(void)
Definition: atmega_i2c_cam_ctrl.c:94
I2CTransSuccess
@ I2CTransSuccess
transaction successfully finished by I2C driver
Definition: i2c.h:57
uart.h
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
dc_send_command
void dc_send_command(uint8_t cmd)
Send Command To Camera.
Definition: atmega_i2c_cam_ctrl.c:41
i2c_transceive
bool i2c_transceive(struct i2c_periph *p, struct i2c_transaction *t, uint8_t s_addr, uint8_t len_w, uint16_t len_r)
Submit a write/read transaction.
Definition: i2c.c:344
uint8_t
unsigned char uint8_t
Definition: types.h:14
dc_send_shot_position
void dc_send_shot_position(void)
Send Down the coordinates of where the photo was taken.
Definition: dc.c:104
i2c_transaction::status
enum I2CTransactionStatus status
Transaction status.
Definition: i2c.h:126
led.h
arch independent LED (Light Emitting Diodes) API
atmega_i2c_cam_ctrl_init
void atmega_i2c_cam_ctrl_init(void)
Definition: atmega_i2c_cam_ctrl.c:62
i2c_transaction
I2C transaction structure.
Definition: i2c.h:93
ATMEGA_I2C_DEV
#define ATMEGA_I2C_DEV
Definition: atmega_i2c_cam_ctrl.c:52
atmega_i2c_cam_ctrl_just_sent_command
uint8_t atmega_i2c_cam_ctrl_just_sent_command
Definition: atmega_i2c_cam_ctrl.c:60
DC_GET_STATUS
@ DC_GET_STATUS
Definition: dc.h:97
DC_SHOOT
@ DC_SHOOT
Definition: dc.h:100
atmega_i2c_cam_ctrl.h
I2CTransDone
@ I2CTransDone
transaction set to done by user level
Definition: i2c.h:59
ATMEGA_SLAVE_ADDR
#define ATMEGA_SLAVE_ADDR
Definition: atmega_i2c_cam_ctrl.c:57
dc_init
void dc_init(void)
initialize settings
Definition: dc.c:156
dc_periodic
void dc_periodic(void)
periodic function
Definition: dc.c:273
i2c.h