Library for use with VL53L0X, cut 1.1, based on mass-market API v1.1.
Dependencies: ST_INTERFACES X_NUCLEO_COMMON
Dependents: ConcorsoFinal HelloWorld_IHM01A1 m3pi_BT m3pi_LIDAR ... more
Fork of X_NUCLEO_53L0A1 by
X-NUCLEO-53L0A1 Proximity Sensor Expansion Board Firmware Package
Introduction
This firmware package includes Component Device Drivers and the Board Support Package for STMicroelectronics' X-NUCLEO-53L0A1 Proximity sensor expansion board based on VL53L0X.
Firmware Library
Class X_NUCLEO_53L0A1 is intended to represent the Proximity sensor expansion board with the same name.
The expansion board provides support for the following components:
- on-board VL53L0X proximity sensor,
- up to two additional VL53L0X Satellites,
- on-board 4-digit display
It is intentionally implemented as a singleton because only one X-NUCLEO-VL53L0A1 may be deployed at a time in a HW component stack. In order to get the singleton instance you have to call class method `Instance()`, e.g.:
// Sensors expansion board singleton instance static X_NUCLEO_53L0A1 *board = X_NUCLEO_53L0A1::Instance(device_i2c, A2, D8, D2);
Example Applications
- Hello World 53L0
- Display 53L0A1
- Display 53L0A1 Interrupts
- Display 53L0A1 with satellites
- 53L0A1 Satellites with Interrupts
- 53L0A1_HandGestureRecognition
The library and sample application code were tested against mbed revision 143, dated 26th May 2017.
Components/VL53L0X/vl53l0x_platform_log.h@0:c523920bcc09, 2016-11-28 (annotated)
- Committer:
- johnAlexander
- Date:
- Mon Nov 28 11:25:33 2016 +0000
- Revision:
- 0:c523920bcc09
Singleshot, polled ranging example using central VL53L0X sensor.; Compatible with mass-market v1.1 C API.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| johnAlexander | 0:c523920bcc09 | 1 | /******************************************************************************* |
| johnAlexander | 0:c523920bcc09 | 2 | Copyright © 2015, STMicroelectronics International N.V. |
| johnAlexander | 0:c523920bcc09 | 3 | All rights reserved. |
| johnAlexander | 0:c523920bcc09 | 4 | |
| johnAlexander | 0:c523920bcc09 | 5 | Redistribution and use in source and binary forms, with or without |
| johnAlexander | 0:c523920bcc09 | 6 | modification, are permitted provided that the following conditions are met: |
| johnAlexander | 0:c523920bcc09 | 7 | * Redistributions of source code must retain the above copyright |
| johnAlexander | 0:c523920bcc09 | 8 | notice, this list of conditions and the following disclaimer. |
| johnAlexander | 0:c523920bcc09 | 9 | * Redistributions in binary form must reproduce the above copyright |
| johnAlexander | 0:c523920bcc09 | 10 | notice, this list of conditions and the following disclaimer in the |
| johnAlexander | 0:c523920bcc09 | 11 | documentation and/or other materials provided with the distribution. |
| johnAlexander | 0:c523920bcc09 | 12 | * Neither the name of STMicroelectronics nor the |
| johnAlexander | 0:c523920bcc09 | 13 | names of its contributors may be used to endorse or promote products |
| johnAlexander | 0:c523920bcc09 | 14 | derived from this software without specific prior written permission. |
| johnAlexander | 0:c523920bcc09 | 15 | |
| johnAlexander | 0:c523920bcc09 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
| johnAlexander | 0:c523920bcc09 | 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| johnAlexander | 0:c523920bcc09 | 18 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND |
| johnAlexander | 0:c523920bcc09 | 19 | NON-INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS ARE DISCLAIMED. |
| johnAlexander | 0:c523920bcc09 | 20 | IN NO EVENT SHALL STMICROELECTRONICS INTERNATIONAL N.V. BE LIABLE FOR ANY |
| johnAlexander | 0:c523920bcc09 | 21 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| johnAlexander | 0:c523920bcc09 | 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| johnAlexander | 0:c523920bcc09 | 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| johnAlexander | 0:c523920bcc09 | 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| johnAlexander | 0:c523920bcc09 | 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| johnAlexander | 0:c523920bcc09 | 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| johnAlexander | 0:c523920bcc09 | 27 | ********************************************************************************/ |
| johnAlexander | 0:c523920bcc09 | 28 | |
| johnAlexander | 0:c523920bcc09 | 29 | |
| johnAlexander | 0:c523920bcc09 | 30 | #ifndef _VL53L0X_PLATFORM_LOG_H_ |
| johnAlexander | 0:c523920bcc09 | 31 | #define _VL53L0X_PLATFORM_LOG_H_ |
| johnAlexander | 0:c523920bcc09 | 32 | |
| johnAlexander | 0:c523920bcc09 | 33 | #include <stdio.h> |
| johnAlexander | 0:c523920bcc09 | 34 | #include <string.h> |
| johnAlexander | 0:c523920bcc09 | 35 | /* LOG Functions */ |
| johnAlexander | 0:c523920bcc09 | 36 | |
| johnAlexander | 0:c523920bcc09 | 37 | #ifdef __cplusplus |
| johnAlexander | 0:c523920bcc09 | 38 | extern "C" { |
| johnAlexander | 0:c523920bcc09 | 39 | #endif |
| johnAlexander | 0:c523920bcc09 | 40 | |
| johnAlexander | 0:c523920bcc09 | 41 | /** |
| johnAlexander | 0:c523920bcc09 | 42 | * @file vl53l0_platform_log.h |
| johnAlexander | 0:c523920bcc09 | 43 | * |
| johnAlexander | 0:c523920bcc09 | 44 | * @brief platform log function definition |
| johnAlexander | 0:c523920bcc09 | 45 | */ |
| johnAlexander | 0:c523920bcc09 | 46 | |
| johnAlexander | 0:c523920bcc09 | 47 | //#define VL53L0X_LOG_ENABLE 0 |
| johnAlexander | 0:c523920bcc09 | 48 | |
| johnAlexander | 0:c523920bcc09 | 49 | enum { |
| johnAlexander | 0:c523920bcc09 | 50 | TRACE_LEVEL_NONE, |
| johnAlexander | 0:c523920bcc09 | 51 | TRACE_LEVEL_ERRORS, |
| johnAlexander | 0:c523920bcc09 | 52 | TRACE_LEVEL_WARNING, |
| johnAlexander | 0:c523920bcc09 | 53 | TRACE_LEVEL_INFO, |
| johnAlexander | 0:c523920bcc09 | 54 | TRACE_LEVEL_DEBUG, |
| johnAlexander | 0:c523920bcc09 | 55 | TRACE_LEVEL_ALL, |
| johnAlexander | 0:c523920bcc09 | 56 | TRACE_LEVEL_IGNORE |
| johnAlexander | 0:c523920bcc09 | 57 | }; |
| johnAlexander | 0:c523920bcc09 | 58 | |
| johnAlexander | 0:c523920bcc09 | 59 | enum { |
| johnAlexander | 0:c523920bcc09 | 60 | TRACE_FUNCTION_NONE = 0, |
| johnAlexander | 0:c523920bcc09 | 61 | TRACE_FUNCTION_I2C = 1, |
| johnAlexander | 0:c523920bcc09 | 62 | TRACE_FUNCTION_ALL = 0x7fffffff //all bits except sign |
| johnAlexander | 0:c523920bcc09 | 63 | }; |
| johnAlexander | 0:c523920bcc09 | 64 | |
| johnAlexander | 0:c523920bcc09 | 65 | enum { |
| johnAlexander | 0:c523920bcc09 | 66 | TRACE_MODULE_NONE = 0x0, |
| johnAlexander | 0:c523920bcc09 | 67 | TRACE_MODULE_API = 0x1, |
| johnAlexander | 0:c523920bcc09 | 68 | TRACE_MODULE_PLATFORM = 0x2, |
| johnAlexander | 0:c523920bcc09 | 69 | TRACE_MODULE_ALL = 0x7fffffff //all bits except sign |
| johnAlexander | 0:c523920bcc09 | 70 | }; |
| johnAlexander | 0:c523920bcc09 | 71 | |
| johnAlexander | 0:c523920bcc09 | 72 | |
| johnAlexander | 0:c523920bcc09 | 73 | #ifdef VL53L0X_LOG_ENABLE |
| johnAlexander | 0:c523920bcc09 | 74 | |
| johnAlexander | 0:c523920bcc09 | 75 | #include <sys/time.h> |
| johnAlexander | 0:c523920bcc09 | 76 | |
| johnAlexander | 0:c523920bcc09 | 77 | extern uint32_t _trace_level; |
| johnAlexander | 0:c523920bcc09 | 78 | |
| johnAlexander | 0:c523920bcc09 | 79 | |
| johnAlexander | 0:c523920bcc09 | 80 | |
| johnAlexander | 0:c523920bcc09 | 81 | int32_t VL53L0X_trace_config(char *filename, uint32_t modules, uint32_t level, uint32_t functions); |
| johnAlexander | 0:c523920bcc09 | 82 | |
| johnAlexander | 0:c523920bcc09 | 83 | void trace_print_module_function(uint32_t module, uint32_t level, uint32_t function, const char *format, ...); |
| johnAlexander | 0:c523920bcc09 | 84 | |
| johnAlexander | 0:c523920bcc09 | 85 | |
| johnAlexander | 0:c523920bcc09 | 86 | //extern FILE * log_file; |
| johnAlexander | 0:c523920bcc09 | 87 | |
| johnAlexander | 0:c523920bcc09 | 88 | #define LOG_GET_TIME() (int)clock() |
| johnAlexander | 0:c523920bcc09 | 89 | |
| johnAlexander | 0:c523920bcc09 | 90 | #define _LOG_FUNCTION_START(module, fmt, ... ) \ |
| johnAlexander | 0:c523920bcc09 | 91 | trace_print_module_function(module, _trace_level, TRACE_FUNCTION_ALL, "%ld <START> %s "fmt"\n", LOG_GET_TIME(), __FUNCTION__, ##__VA_ARGS__); |
| johnAlexander | 0:c523920bcc09 | 92 | |
| johnAlexander | 0:c523920bcc09 | 93 | #define _LOG_FUNCTION_END(module, status, ... )\ |
| johnAlexander | 0:c523920bcc09 | 94 | trace_print_module_function(module, _trace_level, TRACE_FUNCTION_ALL, "%ld <END> %s %d\n", LOG_GET_TIME(), __FUNCTION__, (int)status, ##__VA_ARGS__) |
| johnAlexander | 0:c523920bcc09 | 95 | |
| johnAlexander | 0:c523920bcc09 | 96 | #define _LOG_FUNCTION_END_FMT(module, status, fmt, ... )\ |
| johnAlexander | 0:c523920bcc09 | 97 | trace_print_module_function(module, _trace_level, TRACE_FUNCTION_ALL, "%ld <END> %s %d "fmt"\n", LOG_GET_TIME(), __FUNCTION__, (int)status,##__VA_ARGS__) |
| johnAlexander | 0:c523920bcc09 | 98 | |
| johnAlexander | 0:c523920bcc09 | 99 | // __func__ is gcc only |
| johnAlexander | 0:c523920bcc09 | 100 | #define VL53L0X_ErrLog( fmt, ...) fprintf(stderr, "VL53L0X_ErrLog %s" fmt "\n", __func__, ##__VA_ARGS__) |
| johnAlexander | 0:c523920bcc09 | 101 | |
| johnAlexander | 0:c523920bcc09 | 102 | #else /* VL53L0X_LOG_ENABLE no logging */ |
| johnAlexander | 0:c523920bcc09 | 103 | #define VL53L0X_ErrLog(...) (void)0 |
| johnAlexander | 0:c523920bcc09 | 104 | #define _LOG_FUNCTION_START(module, fmt, ... ) (void)0 |
| johnAlexander | 0:c523920bcc09 | 105 | #define _LOG_FUNCTION_END(module, status, ... ) (void)0 |
| johnAlexander | 0:c523920bcc09 | 106 | #define _LOG_FUNCTION_END_FMT(module, status, fmt, ... ) (void)0 |
| johnAlexander | 0:c523920bcc09 | 107 | #endif /* else */ |
| johnAlexander | 0:c523920bcc09 | 108 | |
| johnAlexander | 0:c523920bcc09 | 109 | #define VL53L0X_COPYSTRING(str, ...) strcpy(str, ##__VA_ARGS__) |
| johnAlexander | 0:c523920bcc09 | 110 | |
| johnAlexander | 0:c523920bcc09 | 111 | #ifdef __cplusplus |
| johnAlexander | 0:c523920bcc09 | 112 | } |
| johnAlexander | 0:c523920bcc09 | 113 | #endif |
| johnAlexander | 0:c523920bcc09 | 114 | |
| johnAlexander | 0:c523920bcc09 | 115 | #endif /* _VL53L0X_PLATFORM_LOG_H_ */ |
| johnAlexander | 0:c523920bcc09 | 116 | |
| johnAlexander | 0:c523920bcc09 | 117 | |
| johnAlexander | 0:c523920bcc09 | 118 | |
| johnAlexander | 0:c523920bcc09 | 119 |

X-NUCLEO-53L0A1 Ranging Sensor Expansion Board