Paparazzi UAS  v4.0.4_stable-3-gf39211a
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
actuators_skiron.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2011 Gautier Hattenberger
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 
44  actuators_skiron.trans.len_w = ACTUATORS_SKIRON_NB;
47  const uint8_t actuators_idx[ACTUATORS_SKIRON_NB] = ACTUATORS_SKIRON_IDX;
48  for (uint8_t i=0; i<ACTUATORS_SKIRON_NB; i++) {
49  actuators_skiron.actuators_idx[i] = actuators_idx[i];
50  }
51 
52 #if defined ACTUATORS_START_DELAY && ! defined SITL
55 #else
58 #endif
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_SKIRON_NB; i++) {
73 #ifdef KILL_MOTORS
74  actuators_skiron.trans.buf[idx] = 0;
75 #else
77 #endif
78  }
79  i2c_submit(&ACTUATORS_SKIRON_DEVICE, &actuators_skiron.trans);
80 }
struct ActuatorsSkiron actuators_skiron
uint8_t actuators_idx[ACTUATORS_SKIRON_NB]
#define ACTUATORS_SKIRON_I2C_ADDR
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
uint32_t actuators_delay_time
#define FALSE
Definition: imu_chimu.h:141
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
void actuators_init(void)
#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:42
int32_t commands[SUPERVISION_NB_MOTOR]
Definition: supervision.h:35
void actuators_set(bool_t motors_on)
struct i2c_transaction trans
enum I2CTransactionType type
Definition: i2c.h:42
#define SysTimeTimerStart(_t)
Definition: sys_time_arch.h:70
Skiron motor speed controller by Michel.
struct Supervision supervision
Definition: supervision.c:66
bool_t actuators_delay_done
Definition: i2c.h:9