Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
firmware
boards
breezy
breezystm32
examples
sen13680
sen13680read.c
Go to the documentation of this file.
1
/*
2
sen13680read.c : read values from Sparkfun SEN13680 LIDAR-Lite v2 I^2C lidar
3
4
Don't forget to supply external power to the board!
5
6
Copyright (C) 2016 Simon D. Levy
7
8
This file is part of BreezySTM32.
9
10
BreezySTM32 is free software: you can redistribute it and/or modify
11
it under the terms of the GNU General Public License as published by
12
the Free Software Foundation, either version 3 of the License, or
13
(at your option) any later version.
14
15
BreezySTM32 is distributed in the hope that it will be useful,
16
but WITHOUT ANY WARRANTY; without even the implied warranty of
17
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
GNU General Public License for more details.
19
20
You should have received a copy of the GNU General Public License
21
along with BreezySTM32. If not, see <http://www.gnu.org/licenses/>.
22
*/
23
24
#include <
breezystm32.h
>
25
26
static
bool
lidar_present
;
27
28
// initialize i2c
29
void
setup
(
void
)
30
{
31
i2cInit
(
I2CDEV_2
);
32
i2cWrite
(0, 0, 0);
33
}
34
35
// look for the lidar and then read measurements
36
void
loop
(
void
)
37
{
38
if
(
lidar_present
)
39
{
40
sen13680_update
();
41
float
distance
=
sen13680_read
();
42
printf
(
"distance = %d.%dm\n"
, (uint32_t)distance, (uint32_t)(distance*1000)%1000);
43
}
44
else
45
{
46
printf
(
"No lidar present. Reinitializing.\n"
);
47
lidar_present
=
sen13680_init
();
48
}
49
delay
(100);
50
LED1_TOGGLE
;
51
}
i2cInit
void i2cInit(I2CDevice index)
Definition:
drv_i2c.c:420
printf
#define printf
Definition:
printf.h:119
sen13680_update
void sen13680_update()
Definition:
drv_sen13680.c:70
lidar_present
static bool lidar_present
Definition:
sen13680read.c:26
sen13680_read
float sen13680_read()
Definition:
drv_sen13680.c:94
sen13680_init
bool sen13680_init()
Definition:
drv_sen13680.c:38
distance
static float distance
Definition:
drv_sen13680.c:34
i2cWrite
bool i2cWrite(uint8_t addr_, uint8_t reg_, uint8_t data)
Definition:
drv_i2c.c:152
breezystm32.h
setup
void setup(void)
Definition:
sen13680read.c:29
LED1_TOGGLE
#define LED1_TOGGLE
Definition:
drv_system.h:51
loop
void loop(void)
Definition:
sen13680read.c:36
I2CDEV_2
Definition:
drv_i2c.h:26
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:25