Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
vl53l5cx_platform.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2024 Fabien-B <name.surname@gmail.com>
3  *
4  * This file is part of paparazzi
5  *
6  * paparazzi is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  */
11 
12 
13 #ifndef _PLATFORM_H_
14 #define _PLATFORM_H_
15 #pragma once
16 
17 #include <stdint.h>
18 #include <string.h>
19 #include "mcu_periph/i2c.h"
20 
21 #define VL53L5CX_I2C_BUF_SIZE 512
22 
23 
30 };
31 
40 typedef struct
41 {
42  /* To be filled with customer's platform. At least an I2C address/descriptor
43  * needs to be added */
44  /* Example for most standard platform : I2C address of sensor */
46  //I2CDriver* i2cp;
47  struct i2c_periph *i2cdev;
49  int16_t distances_mm[64];
50 
51  enum VL53L5CX_ERRORS error_code;
53  void* user_data;
54 
56 
57 /*
58  * @brief The macro below is used to define the number of target per zone sent
59  * through I2C. This value can be changed by user, in order to tune I2C
60  * transaction, and also the total memory size (a lower number of target per
61  * zone means a lower RAM). The value must be between 1 and 4.
62  */
63 
64 #define VL53L5CX_NB_TARGET_PER_ZONE 1U
65 
66 /*
67  * @brief The macro below can be used to avoid data conversion into the driver.
68  * By default there is a conversion between firmware and user data. Using this macro
69  * allows to use the firmware format instead of user format. The firmware format allows
70  * an increased precision.
71  */
72 
73 // #define VL53L5CX_USE_RAW_FORMAT
74 
75 /*
76  * @brief All macro below are used to configure the sensor output. User can
77  * define some macros if he wants to disable selected output, in order to reduce
78  * I2C access.
79  */
80 
81 // #define VL53L5CX_DISABLE_AMBIENT_PER_SPAD
82 // #define VL53L5CX_DISABLE_NB_SPADS_ENABLED
83 // #define VL53L5CX_DISABLE_NB_TARGET_DETECTED
84 // #define VL53L5CX_DISABLE_SIGNAL_PER_SPAD
85 // #define VL53L5CX_DISABLE_RANGE_SIGMA_MM
86 // #define VL53L5CX_DISABLE_DISTANCE_MM
87 // #define VL53L5CX_DISABLE_REFLECTANCE_PERCENT
88 // #define VL53L5CX_DISABLE_TARGET_STATUS
89 // #define VL53L5CX_DISABLE_MOTION_INDICATOR
90 
100  VL53L5CX_Platform *p_platform,
101  uint16_t RegisterAdress,
102  uint8_t *p_value);
103 
114  VL53L5CX_Platform *p_platform,
115  uint16_t RegisterAdress,
116  uint8_t value);
117 
129  VL53L5CX_Platform *p_platform,
130  uint16_t RegisterAdress,
131  uint8_t *p_values,
132  uint32_t size);
133 
145  VL53L5CX_Platform *p_platform,
146  uint16_t RegisterAdress,
147  uint8_t *p_values,
148  uint32_t size);
149 
160 // uint8_t Reset_Sensor(
161 // VL53L5CX_Platform *p_platform);
162 
170 void SwapBuffer(
171  uint8_t *buffer,
172  uint16_t size);
183  VL53L5CX_Platform *p_platform,
184  uint32_t TimeMs);
185 
186 #endif // _PLATFORM_H_
Architecture independent I2C (Inter-Integrated Circuit Bus) API.
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
Definition: vl53l1_types.h:88
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
Definition: vl53l1_types.h:78
short int16_t
Typedef defining 16 bit short type.
Definition: vl53l1_types.h:93
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
Definition: vl53l1_types.h:98
uint8_t RdByte(VL53L5CX_Platform *p_platform, uint16_t RegisterAdress, uint8_t *p_value)
struct i2c_periph * i2cdev
uint8_t WrByte(VL53L5CX_Platform *p_platform, uint16_t RegisterAdress, uint8_t value)
Mandatory function used to write one single byte.
VL53L5CX_ERRORS
@ VL53L5CX_SET_RESOLUTION_FAILED
@ VL53L5CX_NOT_DETECTED
@ VL53L5CX_NO_ERROR
@ VL53L5CX_ULD_LOADING_FAILED
@ VL53L5CX_RUNTIME_FAILURE
uint8_t WaitMs(VL53L5CX_Platform *p_platform, uint32_t TimeMs)
Mandatory function, used to wait during an amount of time.
uint8_t RdMulti(VL53L5CX_Platform *p_platform, uint16_t RegisterAdress, uint8_t *p_values, uint32_t size)
Mandatory function used to read multiples bytes.
uint8_t WrMulti(VL53L5CX_Platform *p_platform, uint16_t RegisterAdress, uint8_t *p_values, uint32_t size)
Mandatory function used to write multiples bytes.
#define VL53L5CX_I2C_BUF_SIZE
void SwapBuffer(uint8_t *buffer, uint16_t size)
Optional function, only used to perform an hardware reset of the sensor.
Structure VL53L5CX_Platform needs to be filled by the customer, depending on his platform.