upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
es08a.h
Go to the documentation of this file.
1 /*
2  * Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com>
3  * Abhishek Malik <abhishek.malik@intel.com>
4  * Copyright (c) 2016 Intel Corporation.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining
7  * a copy of this software and associated documentation files (the
8  * "Software"), to deal in the Software without restriction, including
9  * without limitation the rights to use, copy, modify, merge, publish,
10  * distribute, sublicense, and/or sell copies of the Software, and to
11  * permit persons to whom the Software is furnished to do so, subject to
12  * the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be
15  * included in all copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24  */
25 
26 #ifndef ES08A_H_
27 #define ES08A_H_
28 
29 #include <string.h>
30 #include <stdlib.h>
31 #include <unistd.h>
32 
33 #include "upm.h"
34 #include "mraa/pwm.h"
35 
36 #define ES08A_MIN_PULSE_WIDTH 600
37 #define ES08A_MAX_PULSE_WIDTH 2200
38 #define ES08A_PERIOD 20000
39 #define ES08A_MAX_ANGLE 180.0
40 
52 typedef struct _es08a_context {
53  mraa_pwm_context pwm;
54  uint16_t servo_pin;
55  uint32_t max_pulse_width;
56  uint32_t min_pulse_width;
57 } *es08a_context;
58 
71 es08a_context es08a_init(int32_t pin, int32_t min_pulse_width,
72  int32_t max_pulse_width);
73 
77 void es08a_halt(es08a_context dev);
78 
85 upm_result_t es08a_set_angle(es08a_context dev, int32_t angle);
86 
87 /*
88  * Calculating relative pulse time to the value.
89  * */
90 upm_result_t es08a_calc_pulse_travelling(const es08a_context dev,
91  int32_t* ret_val,
92  int32_t value);
93 
99 void es08a_set_min_pulse_width (es08a_context dev, int width);
100 
106 void es08a_set_max_pulse_width (es08a_context dev, int width);
107 
114 
121 
122 #endif /* ES08A_H_ */
es08a_context es08a_init(int32_t pin, int32_t min_pulse_width, int32_t max_pulse_width)
Definition: es08a.c:28
void es08a_set_min_pulse_width(es08a_context dev, int width)
Definition: es08a.c:102
void es08a_halt(es08a_context dev)
Definition: es08a.c:61
upm_result_t es08a_set_angle(es08a_context dev, int32_t angle)
Definition: es08a.c:66
Definition: es08a.h:52
void es08a_set_max_pulse_width(es08a_context dev, int width)
Definition: es08a.c:106
int es08a_get_min_pulse_width(es08a_context dev)
Definition: es08a.c:110
struct _es08a_context * es08a_context
int es08a_get_max_pulse_width(es08a_context dev)
Definition: es08a.c:114