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 {
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  {
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");
48  }
49  delay(100);
51 }
void i2cInit(I2CDevice index)
Definition: drv_i2c.c:420
void sen13680_update()
Definition: drv_sen13680.c:70
static bool lidar_present
Definition: sen13680read.c:26
float sen13680_read()
Definition: drv_sen13680.c:94
bool sen13680_init()
Definition: drv_sen13680.c:38
static float distance
Definition: drv_sen13680.c:34
bool i2cWrite(uint8_t addr_, uint8_t reg_, uint8_t data)
Definition: drv_i2c.c:152
void setup(void)
Definition: sen13680read.c:29
#define LED1_TOGGLE
Definition: drv_system.h:51
void loop(void)
Definition: sen13680read.c:36
void delay(uint32_t ms)
Definition: system.c:101


rosflight_firmware
Author(s): Daniel Koch , James Jackson
autogenerated on Thu Apr 15 2021 05:07:47