upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
urm37.h
Go to the documentation of this file.
1 /*
2  * Author: Jon Trulson <jtrulson@ics.com>
3  * Abhishek Malik <abhishek.malik@intel.com>
4  * Copyright (c) 2016 Intel Corporation.
5  *
6  * Thanks to Adafruit for supplying a google translated version of the
7  * Chinese datasheet and some clues in their code.
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining
10  * a copy of this software and associated documentation files (the
11  * "Software"), to deal in the Software without restriction, including
12  * without limitation the rights to use, copy, modify, merge, publish,
13  * distribute, sublicense, and/or sell copies of the Software, and to
14  * permit persons to whom the Software is furnished to do so, subject to
15  * the following conditions:
16  *
17  * The above copyright notice and this permission notice shall be
18  * included in all copies or substantial portions of the Software.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27  */
28 
29 #ifndef URM37_H_
30 #define URM37_H_
31 
32 #include <stdint.h>
33 #include "upm.h"
34 #include "mraa/aio.h"
35 #include "mraa/gpio.h"
36 #include "mraa/uart.h"
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
56 typedef struct _urm37_context {
57  mraa_aio_context aio;
58  mraa_gpio_context gpio_reset;
59  mraa_gpio_context gpio_trigger;
60  mraa_uart_context uart;
61 
62  bool is_analog_mode;
63 
64  float a_ref;
65  float a_res;
66 } *urm37_context;
67 
79 urm37_context urm37_init(int a_pin, int reset_pin,
80  int trigger_pin, float a_ref,
81  int uart, bool analog_mode);
82 
86 void urm37_close(urm37_context dev);
87 
94 upm_result_t urm37_reset(urm37_context dev);
95 
109 upm_result_t urm37_get_distance(urm37_context dev, float *distance,
110  int degrees);
111 
121 upm_result_t urm37_get_temperature(urm37_context dev, float* temperature);
122 
132 upm_result_t urm37_read_eeprom(urm37_context dev, uint8_t addr, uint8_t* value);
133 
143 upm_result_t urm37_write_eeprom(urm37_context dev, uint8_t addr, uint8_t value);
144 
153 upm_result_t urm37_send_command(urm37_context dev, char* cmd, char* response);
154 
155 #ifdef __cplusplus
156 }
157 #endif
158 
159 #endif /* URM37_H_ */
upm_result_t urm37_send_command(urm37_context dev, char *cmd, char *response)
Definition: urm37.c:173
upm_result_t urm37_reset(urm37_context dev)
Definition: urm37.c:139
upm_result_t urm37_write_eeprom(urm37_context dev, uint8_t addr, uint8_t value)
Definition: urm37.c:363
upm_result_t urm37_get_temperature(urm37_context dev, float *temperature)
Definition: urm37.c:293
upm_result_t urm37_get_distance(urm37_context dev, float *distance, int degrees)
Definition: urm37.c:238
Definition: urm37.h:56
upm_result_t urm37_read_eeprom(urm37_context dev, uint8_t addr, uint8_t *value)
Definition: urm37.c:329
urm37_context urm37_init(int a_pin, int reset_pin, int trigger_pin, float a_ref, int uart, bool analog_mode)
Definition: urm37.c:39
struct _urm37_context * urm37_context
void urm37_close(urm37_context dev)
Definition: urm37.c:125