MAV'RIC
servos.h
1 /*******************************************************************************
2  * Copyright (c) 2009-2014, MAV'RIC Development Team
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  *
15  * 3. Neither the name of the copyright holder nor the names of its contributors
16  * may be used to endorse or promote products derived from this software without
17  * specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  ******************************************************************************/
31 
32 /*******************************************************************************
33  * \file servos.h
34  *
35  * \author MAV'RIC Team
36  * \author Julien Lecoeur
37  *
38  * \brief Abstraction layer for servomotors. This module does not write to
39  * hardware, it just holds data and configuration for servos.
40  *
41  ******************************************************************************/
42 
43 
44 #ifndef SERVOS_H_
45 #define SERVOS_H_
46 
47 #ifdef __cplusplus
48  extern "C" {
49 #endif
50 
51 #include <stdint.h>
52 #include "scheduler.h"
53 
54 #define MAX_SERVO_COUNT 8
55 
56 
60 typedef struct
61 {
62  float value;
63  float trim;
64  float min;
65  float max;
66  float failsafe;
67  uint32_t repeat_freq;
69 
73 typedef struct
74 {
75  uint32_t servos_count;
76  servo_entry_t servo[MAX_SERVO_COUNT];
78 
82 typedef struct
83 {
84  uint32_t servos_count;
85  servo_entry_t servo[MAX_SERVO_COUNT];
86 } servos_t;
87 
88 
97 bool servos_init(servos_t* servos, const servos_conf_t* config);
98 
99 
107 void servos_set_value(servos_t* servos, uint32_t servo_id, float value);
108 
109 
115 void servos_set_value_failsafe(servos_t* servos);
116 
117 
118 #ifdef __cplusplus
119  }
120 #endif
121 
122 #endif
float trim
Trim value (between -1 and 1)
Definition: servos.h:63
float max
Max value (between -1 and 1)
Definition: servos.h:65
Define the servos structure.
Definition: servos.h:82
Define the servos entry structure.
Definition: servos.h:60
uint32_t repeat_freq
Update frequency of the servo (in Hz)
Definition: servos.h:67
Define the configuration servos structure.
Definition: servos.h:73
float value
Normalized value of the servo (between -1 and 1)
Definition: servos.h:62
float min
Minimum value (between -1 and 1)
Definition: servos.h:64
float failsafe
Failsafe position of the servo (between -1 and 1)
Definition: servos.h:66
uint32_t servos_count
Servos counter.
Definition: servos.h:84
uint32_t servos_count
Servos counter.
Definition: servos.h:75