upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
es9257.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 ES9257_H_
27 #define ES9257_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 ES9257_MIN_PULSE_WIDTH 475
37 #define ES9257_MAX_PULSE_WIDTH 2100
38 #define ES9257_PERIOD 20000
39 #define ES9257_MAX_ANGLE 180.0
40 
49 /*
50  * device context
51  */
52 typedef struct _es9257_context {
53  mraa_pwm_context pwm;
54  uint16_t servo_pin;
55  uint32_t max_pulse_width;
56  uint32_t min_pulse_width;
58 
68 es9257_context es9257_init(int32_t pin, int32_t min_pulse_width,
69  int32_t max_pulse_width);
70 
74 void es9257_halt(es9257_context dev);
75 
82 upm_result_t es9257_set_angle(es9257_context dev, int32_t angle);
83 
84 /*
85  * Calculating relative pulse time to the value.
86  * */
87 upm_result_t es9257_calc_pulse_travelling(const es9257_context dev,
88  int32_t* ret_val,
89  int32_t value);
90 
96 void es9257_set_min_pulse_width (es9257_context dev, int width);
97 
103 void es9257_set_max_pulse_width (es9257_context dev, int width);
104 
111 
118 
119 #endif /* ES9257_H_ */
int es9257_get_min_pulse_width(es9257_context dev)
Definition: es9257.c:111
void es9257_set_max_pulse_width(es9257_context dev, int width)
Definition: es9257.c:107
void es9257_set_min_pulse_width(es9257_context dev, int width)
Definition: es9257.c:103
Definition: es9257.h:52
void es9257_halt(es9257_context dev)
Definition: es9257.c:62
upm_result_t es9257_set_angle(es9257_context dev, int32_t angle)
Definition: es9257.c:67
es9257_context es9257_init(int32_t pin, int32_t min_pulse_width, int32_t max_pulse_width)
Definition: es9257.c:28
int es9257_get_max_pulse_width(es9257_context dev)
Definition: es9257.c:115