Paparazzi UAS  v4.2.2_stable-4-gcc32f65
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
actuators_mkk.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2009 Antoine Drouin <poinix@gmail.com>
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 
28 
30 #include "mcu_periph/i2c.h"
31 #include "mcu_periph/sys_time.h"
32 
33 
35 
36 
39 
40 void actuators_init(void) {
41 
43  const uint8_t actuators_addr[ACTUATORS_MKK_NB] = ACTUATORS_MKK_ADDR;
44  for (uint8_t i=0; i<ACTUATORS_MKK_NB; i++) {
46  actuators_mkk.trans[i].len_w = 1;
47  actuators_mkk.trans[i].slave_addr = actuators_addr[i];
49  }
50 
51 #if defined ACTUATORS_START_DELAY && ! defined SITL
54 #else
57 #endif
58 
59 }
60 
61 
62 void actuators_set(bool_t motors_on) {
63 #if defined ACTUATORS_START_DELAY && ! defined SITL
64  if (!actuators_delay_done) {
65  if (SysTimeTimer(actuators_delay_time) < USEC_OF_SEC(ACTUATORS_START_DELAY)) return;
67  }
68 #endif
69 
70  supervision_run(motors_on, FALSE, commands);
71  for (uint8_t i=0; i<ACTUATORS_MKK_NB; i++) {
72 #ifdef KILL_MOTORS
73  actuators_mkk.trans[i].buf[0] = 0;
74 #else
76 #endif
77  i2c_submit(&ACTUATORS_MKK_DEVICE, &actuators_mkk.trans[i]);
78  }
79 }
struct i2c_transaction trans[ACTUATORS_MKK_NB]
Definition: actuators_mkk.h:36
void actuators_init(void)
Definition: actuators_mkk.c:40
void actuators_set(bool_t motors_on)
Definition: actuators_mkk.c:62
struct ActuatorsMkk actuators_mkk
Definition: actuators_mkk.c:34
void supervision_run(bool_t motors_on, bool_t override_on, int32_t in_cmd[])
Definition: supervision.c:142
uint8_t slave_addr
Definition: i2c.h:43
#define FALSE
Definition: imu_chimu.h:141
uint32_t actuators_delay_time
Definition: actuators_mkk.c:37
bool_t actuators_delay_done
Definition: actuators_mkk.c:38
Actuators driver for Mikrokopter motor controllers.
bool_t i2c_submit(struct i2c_periph *p, struct i2c_transaction *t)
Definition: i2c_arch.c:321
Architecture independent timing functions.
void supervision_init(void)
Definition: supervision.c:68
unsigned long uint32_t
Definition: types.h:18
#define SysTimeTimer(_t)
Definition: sys_time_arch.h:71
enum I2CTransactionStatus status
Definition: i2c.h:47
#define USEC_OF_SEC(sec)
Definition: sys_time.h:124
#define TRUE
Definition: imu_chimu.h:144
volatile uint8_t buf[I2C_BUF_LEN]
Definition: i2c.h:46
uint8_t len_w
Definition: i2c.h:45
unsigned char uint8_t
Definition: types.h:14
pprz_t commands[COMMANDS_NB]
Definition: commands.c:48
int32_t commands[SUPERVISION_NB_MOTOR]
Definition: supervision.h:35
enum I2CTransactionType type
Definition: i2c.h:42
#define SysTimeTimerStart(_t)
Definition: sys_time_arch.h:70
struct Supervision supervision
Definition: supervision.c:66
Definition: i2c.h:9