upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
hmc5883l.h
Go to the documentation of this file.
1 /*
2  * Author: Jon Trulson <jtrulson@ics.com>
3  * Copyright (c) 2017 Intel Corporation.
4  *
5  * Ported based on original C++ code by:
6  * Author: Brendan Le Foll <brendan.le.foll@intel.com>
7  * Contributions: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
8  * Copyright (c) 2014 Intel Corporation.
9  *
10  * Permission is hereby granted, free of charge, to any person obtaining
11  * a copy of this software and associated documentation files (the
12  * "Software"), to deal in the Software without restriction, including
13  * without limitation the rights to use, copy, modify, merge, publish,
14  * distribute, sublicense, and/or sell copies of the Software, and to
15  * permit persons to whom the Software is furnished to do so, subject to
16  * the following conditions:
17  *
18  * The above copyright notice and this permission notice shall be
19  * included in all copies or substantial portions of the Software.
20  *
21  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28  */
29 #pragma once
30 
31 #include <stdint.h>
32 #include <stdlib.h>
33 #include <unistd.h>
34 
35 #include <upm.h>
36 #include <mraa/i2c.h>
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
52  typedef struct _hmc5883l_context {
53  mraa_i2c_context i2c;
54 
55  int16_t coords[3];
56  float declination;
58 
59 
67 
74 
81  upm_result_t hmc5883l_update(const hmc5883l_context dev);
82 
83  /*
84  * Returns the direction. hmc5883l_update() must have been called
85  * prior to calling this function.
86  *
87  * @param Device context
88  * @return Direction
89  */
90  float hmc5883l_direction(const hmc5883l_context dev);
91 
92  /*
93  * Returns the heading. hmc5883l_update() must have been called
94  * prior to calling this function.
95  *
96  * @param Device context
97  * @return Heading
98  */
99  float hmc5883l_heading(const hmc5883l_context dev);
100 
109  const int16_t *hmc5883l_coordinates(const hmc5883l_context dev);
110 
119  void hmc5883l_set_declination(const hmc5883l_context dev, float dec);
120 
129 
130 #ifdef __cplusplus
131 }
132 #endif
struct _hmc5883l_context * hmc5883l_context
Definition: hmc5883l.h:52
float hmc5883l_get_declination(const hmc5883l_context dev)
Definition: hmc5883l.c:241
upm_result_t hmc5883l_update(const hmc5883l_context dev)
Definition: hmc5883l.c:168
const int16_t * hmc5883l_coordinates(const hmc5883l_context dev)
Definition: hmc5883l.c:227
void hmc5883l_set_declination(const hmc5883l_context dev, float dec)
Definition: hmc5883l.c:234
hmc5883l_context hmc5883l_init(int bus)
Definition: hmc5883l.c:89
void hmc5883l_close(hmc5883l_context dev)
Definition: hmc5883l.c:158