Paparazzi UAS  v5.8.2_stable-0-g6260b7c
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules 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 
26 #include "subsystems/actuators.h"
28 
29 #include "mcu_periph/i2c.h"
30 #include "mcu_periph/sys_time.h"
31 
32 PRINT_CONFIG_VAR(ACTUATORS_SKIRON_I2C_DEV)
33 
35 
36 
38 {
39 
40  actuators_skiron.trans.type = I2CTransTx;
41  actuators_skiron.trans.len_w = SERVOS_SKIRON_NB;
42  actuators_skiron.trans.slave_addr = ACTUATORS_SKIRON_I2C_ADDR;
43  actuators_skiron.trans.status = I2CTransDone;
44 
45 }
46 
48 {
49 #if defined ACTUATORS_START_DELAY && ! defined SITL
50  if (!actuators_delay_done) {
51  if (SysTimeTimer(actuators_delay_time) < USEC_OF_SEC(ACTUATORS_START_DELAY)) { return; }
52  else { actuators_delay_done = TRUE; }
53  }
54 #endif
55 
56 #ifdef KILL_MOTORS
57  for (uint8_t i = 0; i < ACTUATORS_SKIRON_NB; i++) {
58  actuators_skiron.trans.buf[i] = 0;
59  }
60 #endif
61 
62  i2c_submit(&ACTUATORS_SKIRON_I2C_DEV, &actuators_skiron.trans);
63 }
struct ActuatorsSkiron actuators_skiron
bool_t i2c_submit(struct i2c_periph *p, struct i2c_transaction *t)
Submit a I2C transaction.
Definition: i2c_arch.c:52
volatile uint8_t buf[I2C_BUF_LEN]
Transaction buffer With I2C_BUF_LEN number of bytes.
Definition: i2c.h:122
#define ACTUATORS_SKIRON_I2C_ADDR
void actuators_skiron_init(void)
uint8_t len_w
Number of bytes to write/transmit.
Definition: i2c.h:116
Hardware independent API for actuators (servos, motor controllers).
#define TRUE
Definition: std.h:4
transaction set to done by user level
Definition: i2c.h:59
Architecture independent timing functions.
enum I2CTransactionStatus status
Transaction status.
Definition: i2c.h:126
#define USEC_OF_SEC(sec)
Definition: sys_time.h:205
#define SysTimeTimer(_t)
Definition: sys_time.h:214
void actuators_skiron_set(void)
uint8_t slave_addr
Slave address.
Definition: i2c.h:104
unsigned char uint8_t
Definition: types.h:14
transmit only transaction
Definition: i2c.h:47
Skiron motor speed controller by Michel.
enum I2CTransactionType type
Transaction type.
Definition: i2c.h:98
struct i2c_transaction trans
Architecture independent I2C (Inter-Integrated Circuit Bus) API.