Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
firmware
boards
breezy
breezystm32
examples
hmc5883l
hmc5883l_read.c
Go to the documentation of this file.
1
/*
2
hmc5883l_read.c : report magnetometer measurements
3
4
Copyright (C) 2016 James Jackson
5
6
This file is part of BreezySTM32.
7
8
BreezySTM32 is free software: you can redistribute it and/or modify
9
it under the terms of the GNU General Public License as published by
10
the Free Software Foundation, either version 3 of the License, or
11
(at your option) any later version.
12
13
BreezySTM32 is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
GNU General Public License for more details.
17
18
You should have received a copy of the GNU General Public License
19
along with BreezySTM32. If not, see <http://www.gnu.org/licenses/>.
20
*/
21
22
#include <
breezystm32.h
>
23
24
#define BOARD_REV 2
25
26
27
volatile
uint8_t
mag_status
= 0;
28
int16_t
mag_data
[3] = {0.0, 0.0, 0.0};
29
30
void
setup
(
void
)
31
{
32
delay
(500);
33
i2cInit
(
I2CDEV_2
);
34
35
// Initialize the Magnetometer
36
hmc5883lInit
(
BOARD_REV
);
37
hmc5883l_request_async_update
();
38
}
39
40
void
loop
(
void
)
41
{
42
hmc5883l_request_async_update
();
43
hmc5883l_async_read
(
mag_data
);
44
printf
(
"%d\t %d\t %d\n"
,
45
(int32_t)(
mag_data
[0]),
46
(int32_t)(
mag_data
[1]),
47
(int32_t)(
mag_data
[2]));
48
delay
(6);
49
50
51
}
52
hmc5883lInit
bool hmc5883lInit()
Definition:
drv_hmc5883l.c:83
i2cInit
void i2cInit(I2CDevice index)
Definition:
drv_i2c.c:420
printf
#define printf
Definition:
printf.h:119
setup
void setup(void)
Definition:
hmc5883l_read.c:30
hmc5883l_async_read
void hmc5883l_async_read(float *mag_data)
Definition:
drv_hmc5883l.c:138
breezystm32.h
loop
void loop(void)
Definition:
hmc5883l_read.c:40
BOARD_REV
#define BOARD_REV
Definition:
hmc5883l_read.c:24
mag_data
int16_t mag_data[3]
Definition:
hmc5883l_read.c:28
hmc5883l_request_async_update
void hmc5883l_request_async_update()
Definition:
drv_hmc5883l.c:118
I2CDEV_2
Definition:
drv_i2c.h:26
mag_status
volatile uint8_t mag_status
Definition:
hmc5883l_read.c:27
delay
void delay(uint32_t ms)
Definition:
system.c:98
rosflight_firmware
Author(s): Daniel Koch
, James Jackson
autogenerated on Wed Jul 3 2019 19:59:24