Statistics
| Branch: | Tag: | Revision:

amiro-lld / drivers / VL53L1X / v1 / api / core / vl53l1_api_strings.c @ 4dba9195

History | View | Annotate | Download (7.729 KB)

1

    
2
/*
3
* Copyright (c) 2017, STMicroelectronics - All Rights Reserved
4
*
5
* This file is part of VL53L1 Core and is dual licensed,
6
* either 'STMicroelectronics
7
* Proprietary license'
8
* or 'BSD 3-clause "New" or "Revised" License' , at your option.
9
*
10
********************************************************************************
11
*
12
* 'STMicroelectronics Proprietary license'
13
*
14
********************************************************************************
15
*
16
* License terms: STMicroelectronics Proprietary in accordance with licensing
17
* terms at www.st.com/sla0081
18
*
19
* STMicroelectronics confidential
20
* Reproduction and Communication of this document is strictly prohibited unless
21
* specifically authorized in writing by STMicroelectronics.
22
*
23
*
24
********************************************************************************
25
*
26
* Alternatively, VL53L1 Core may be distributed under the terms of
27
* 'BSD 3-clause "New" or "Revised" License', in which case the following
28
* provisions apply instead of the ones mentioned above :
29
*
30
********************************************************************************
31
*
32
* License terms: BSD 3-clause "New" or "Revised" License.
33
*
34
* Redistribution and use in source and binary forms, with or without
35
* modification, are permitted provided that the following conditions are met:
36
*
37
* 1. Redistributions of source code must retain the above copyright notice, this
38
* list of conditions and the following disclaimer.
39
*
40
* 2. Redistributions in binary form must reproduce the above copyright notice,
41
* this list of conditions and the following disclaimer in the documentation
42
* and/or other materials provided with the distribution.
43
*
44
* 3. Neither the name of the copyright holder nor the names of its contributors
45
* may be used to endorse or promote products derived from this software
46
* without specific prior written permission.
47
*
48
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
49
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
50
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
51
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
52
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
53
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
54
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
55
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
56
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
57
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
58
*
59
*
60
********************************************************************************
61
*
62
*/
63

    
64
/**
65
 * @file   vl53l1_api_strings.c
66
 * @brief  VL53L1 API functions for decoding error codes to a text string
67
 */
68

    
69
#include "vl53l1_api_core.h"
70
#include "vl53l1_api_strings.h"
71
#include "vl53l1_error_codes.h"
72
#include "vl53l1_error_strings.h"
73

    
74
#define LOG_FUNCTION_START(fmt, ...) \
75
        _LOG_FUNCTION_START(VL53L1_TRACE_MODULE_API, fmt, ##__VA_ARGS__)
76
#define LOG_FUNCTION_END(status, ...) \
77
        _LOG_FUNCTION_END(VL53L1_TRACE_MODULE_API, status, ##__VA_ARGS__)
78
#define LOG_FUNCTION_END_FMT(status, fmt, ...) \
79
        _LOG_FUNCTION_END_FMT(VL53L1_TRACE_MODULE_API, status, fmt, \
80
                        ##__VA_ARGS__)
81

    
82

    
83
VL53L1_Error VL53L1_get_range_status_string(
84
        uint8_t   RangeStatus,
85
        char    *pRangeStatusString)
86
{
87
        VL53L1_Error status = VL53L1_ERROR_NONE;
88

    
89
        LOG_FUNCTION_START("");
90

    
91
#ifdef VL53L1_USE_EMPTY_STRING
92
        VL53L1_COPYSTRING(pRangeStatusString, "");
93
#else
94
        switch (RangeStatus) {
95
        case 0:
96
                VL53L1_COPYSTRING(pRangeStatusString,
97
                        VL53L1_STRING_RANGESTATUS_RANGEVALID);
98
        break;
99
        case 1:
100
                VL53L1_COPYSTRING(pRangeStatusString,
101
                        VL53L1_STRING_RANGESTATUS_SIGMA);
102
        break;
103
        case 2:
104
                VL53L1_COPYSTRING(pRangeStatusString,
105
                        VL53L1_STRING_RANGESTATUS_SIGNAL);
106
        break;
107
        case 3:
108
                VL53L1_COPYSTRING(pRangeStatusString,
109
                        VL53L1_STRING_RANGESTATUS_MINRANGE);
110
        break;
111
        case 4:
112
                VL53L1_COPYSTRING(pRangeStatusString,
113
                        VL53L1_STRING_RANGESTATUS_PHASE);
114
        break;
115
        case 5:
116
                VL53L1_COPYSTRING(pRangeStatusString,
117
                        VL53L1_STRING_RANGESTATUS_HW);
118
        break;
119

    
120
        default: /**/
121
                VL53L1_COPYSTRING(pRangeStatusString,
122
                        VL53L1_STRING_RANGESTATUS_NONE);
123
        }
124
#endif
125

    
126
        LOG_FUNCTION_END(status);
127
        return status;
128
}
129

    
130

    
131
VL53L1_Error VL53L1_get_pal_state_string(
132
        VL53L1_State PalStateCode,
133
        char *pPalStateString)
134
{
135
        VL53L1_Error status = VL53L1_ERROR_NONE;
136

    
137
        LOG_FUNCTION_START("");
138

    
139
#ifdef VL53L1_USE_EMPTY_STRING
140
        VL53L1_COPYSTRING(pPalStateString, "");
141
#else
142
        switch (PalStateCode) {
143
        case VL53L1_STATE_POWERDOWN:
144
                VL53L1_COPYSTRING(pPalStateString,
145
                        VL53L1_STRING_STATE_POWERDOWN);
146
        break;
147
        case VL53L1_STATE_WAIT_STATICINIT:
148
                VL53L1_COPYSTRING(pPalStateString,
149
                        VL53L1_STRING_STATE_WAIT_STATICINIT);
150
        break;
151
        case VL53L1_STATE_STANDBY:
152
                VL53L1_COPYSTRING(pPalStateString,
153
                        VL53L1_STRING_STATE_STANDBY);
154
        break;
155
        case VL53L1_STATE_IDLE:
156
                VL53L1_COPYSTRING(pPalStateString,
157
                        VL53L1_STRING_STATE_IDLE);
158
        break;
159
        case VL53L1_STATE_RUNNING:
160
                VL53L1_COPYSTRING(pPalStateString,
161
                        VL53L1_STRING_STATE_RUNNING);
162
        break;
163
        case VL53L1_STATE_RESET:
164
                VL53L1_COPYSTRING(pPalStateString,
165
                        VL53L1_STRING_STATE_RESET);
166
        break;
167
        case VL53L1_STATE_UNKNOWN:
168
                VL53L1_COPYSTRING(pPalStateString,
169
                        VL53L1_STRING_STATE_UNKNOWN);
170
        break;
171
        case VL53L1_STATE_ERROR:
172
                VL53L1_COPYSTRING(pPalStateString,
173
                        VL53L1_STRING_STATE_ERROR);
174
        break;
175

    
176
        default:
177
                VL53L1_COPYSTRING(pPalStateString,
178
                        VL53L1_STRING_STATE_UNKNOWN);
179
        }
180
#endif
181

    
182
        LOG_FUNCTION_END(status);
183
        return status;
184
}
185

    
186
VL53L1_Error VL53L1_get_sequence_steps_info(
187
                VL53L1_SequenceStepId SequenceStepId,
188
                char *pSequenceStepsString)
189
{
190
        VL53L1_Error Status = VL53L1_ERROR_NONE;
191

    
192
        LOG_FUNCTION_START("");
193

    
194
#ifdef VL53L1_USE_EMPTY_STRING
195
        VL53L1_COPYSTRING(pSequenceStepsString, "");
196
#else
197
        switch (SequenceStepId) {
198
        case VL53L1_SEQUENCESTEP_VHV:
199
                VL53L1_COPYSTRING(pSequenceStepsString,
200
                                VL53L1_STRING_SEQUENCESTEP_VHV);
201
        break;
202
        case VL53L1_SEQUENCESTEP_PHASECAL:
203
                VL53L1_COPYSTRING(pSequenceStepsString,
204
                                VL53L1_STRING_SEQUENCESTEP_PHASECAL);
205
        break;
206
        case VL53L1_SEQUENCESTEP_REFPHASE:
207
                VL53L1_COPYSTRING(pSequenceStepsString,
208
                                VL53L1_STRING_SEQUENCESTEP_DSS1);
209
        break;
210
        case VL53L1_SEQUENCESTEP_DSS1:
211
                VL53L1_COPYSTRING(pSequenceStepsString,
212
                                VL53L1_STRING_SEQUENCESTEP_DSS1);
213
        break;
214
        case VL53L1_SEQUENCESTEP_DSS2:
215
                VL53L1_COPYSTRING(pSequenceStepsString,
216
                                VL53L1_STRING_SEQUENCESTEP_DSS2);
217
        break;
218
        case VL53L1_SEQUENCESTEP_MM1:
219
                VL53L1_COPYSTRING(pSequenceStepsString,
220
                                VL53L1_STRING_SEQUENCESTEP_MM1);
221
        break;
222
        case VL53L1_SEQUENCESTEP_MM2:
223
                VL53L1_COPYSTRING(pSequenceStepsString,
224
                                VL53L1_STRING_SEQUENCESTEP_MM2);
225
        break;
226
        case VL53L1_SEQUENCESTEP_RANGE:
227
                VL53L1_COPYSTRING(pSequenceStepsString,
228
                                VL53L1_STRING_SEQUENCESTEP_RANGE);
229
        break;
230
        default:
231
                Status = VL53L1_ERROR_INVALID_PARAMS;
232
        }
233
#endif
234

    
235
        LOG_FUNCTION_END(Status);
236

    
237
        return Status;
238
}
239

    
240
VL53L1_Error VL53L1_get_limit_check_info(uint16_t LimitCheckId,
241
        char *pLimitCheckString)
242
{
243
        VL53L1_Error Status = VL53L1_ERROR_NONE;
244

    
245
        LOG_FUNCTION_START("");
246

    
247
#ifdef VL53L1_USE_EMPTY_STRING
248
        VL53L1_COPYSTRING(pLimitCheckString, "");
249
#else
250
        switch (LimitCheckId) {
251
        case VL53L1_CHECKENABLE_SIGMA_FINAL_RANGE:
252
                VL53L1_COPYSTRING(pLimitCheckString,
253
                        VL53L1_STRING_CHECKENABLE_SIGMA_FINAL_RANGE);
254
        break;
255
        case VL53L1_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE:
256
                VL53L1_COPYSTRING(pLimitCheckString,
257
                        VL53L1_STRING_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE);
258
        break;
259
        default:
260
                VL53L1_COPYSTRING(pLimitCheckString,
261
                        VL53L1_STRING_UNKNOW_ERROR_CODE);
262
        }
263
#endif
264

    
265
        LOG_FUNCTION_END(Status);
266
        return Status;
267
}
268