ChibiOS 21.11.4
lis302dl.c
Go to the documentation of this file.
1/*
2 ChibiOS - Copyright (C) 2016..2023 Rocco Marco Guglielmi
3
4 This file is part of ChibiOS.
5
6 ChibiOS 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 3 of the License, or
9 (at your option) any later version.
10
11 ChibiOS is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18
19*/
20
21/**
22 * @file lis302dl.c
23 * @brief LIS302DL MEMS interface module code.
24 *
25 * @addtogroup LIS302DL
26 * @ingroup EX_ST
27 * @{
28 */
29
30#include "hal.h"
31#include "lis302dl.h"
32
33/*===========================================================================*/
34/* Driver local definitions. */
35/*===========================================================================*/
36
37/*===========================================================================*/
38/* Driver exported variables. */
39/*===========================================================================*/
40
41/*===========================================================================*/
42/* Driver local variables and types. */
43/*===========================================================================*/
44
45/*===========================================================================*/
46/* Driver local functions. */
47/*===========================================================================*/
48
49#if (LIS302DL_USE_SPI) || defined(__DOXYGEN__)
50/**
51 * @brief Reads a generic register value using SPI.
52 * @pre The SPI interface must be initialized and the driver started.
53 *
54 * @param[in] spip pointer to the SPI interface
55 * @param[in] reg starting register address
56 * @param[in] n number of adjacent registers to write
57 * @param[in] b pointer to a buffer.
58 */
59static void lis302dlSPIReadRegister(SPIDriver *spip, uint8_t reg, size_t n,
60 uint8_t* b) {
61 uint8_t cmd;
62 (n == 1) ? (cmd = reg | LIS302DL_RW) : (cmd = reg | LIS302DL_RW | LIS302DL_MS);
63 spiSelect(spip);
64 spiSend(spip, 1, &cmd);
65 spiReceive(spip, n, b);
66 spiUnselect(spip);
67}
68
69/**
70 * @brief Writes a value into a generic register using SPI.
71 * @pre The SPI interface must be initialized and the driver started.
72 *
73 * @param[in] spip pointer to the SPI interface
74 * @param[in] reg starting register address
75 * @param[in] n number of adjacent registers to write
76 * @param[in] b pointer to a buffer of values.
77 */
78static void lis302dlSPIWriteRegister(SPIDriver *spip, uint8_t reg, size_t n,
79 uint8_t* b) {
80 uint8_t cmd;
81 (n == 1) ? (cmd = reg) : (cmd = reg | LIS302DL_MS);
82 spiSelect(spip);
83 spiSend(spip, 1, &cmd);
84 spiSend(spip, n, b);
85 spiUnselect(spip);
86}
87#endif /* LIS302DL_USE_SPI */
88
89/**
90 * @brief Return the number of axes of the BaseAccelerometer.
91 *
92 * @param[in] ip pointer to @p BaseAccelerometer interface.
93 *
94 * @return the number of axes.
95 */
96static size_t acc_get_axes_number(void *ip) {
97 (void)ip;
98
100}
101
102/**
103 * @brief Retrieves raw data from the BaseAccelerometer.
104 * @note This data is retrieved from MEMS register without any algebraical
105 * manipulation.
106 * @note The axes array must be at least the same size of the
107 * BaseAccelerometer axes number.
108 *
109 * @param[in] ip pointer to @p BaseAccelerometer interface.
110 * @param[out] axes a buffer which would be filled with raw data.
111 *
112 * @return The operation status.
113 * @retval MSG_OK if the function succeeded.
114 * @retval MSG_RESET if one or more I2C errors occurred, the errors can
115 * be retrieved using @p i2cGetErrors().
116 * @retval MSG_TIMEOUT if a timeout occurred before operation end.
117 */
118static msg_t acc_read_raw(void *ip, int32_t axes[]) {
119 LIS302DLDriver* devp;
120 uint8_t i, tmp;
121 msg_t msg = MSG_OK;
122
123 osalDbgCheck((ip != NULL) && (axes != NULL));
124
125 /* Getting parent instance pointer.*/
127
128 osalDbgAssert((devp->state == LIS302DL_READY),
129 "acc_read_raw(), invalid state");
130
131#if LIS302DL_USE_SPI
132#if LIS302DL_SHARED_SPI
133 osalDbgAssert((devp->config->spip->state == SPI_READY),
134 "acc_read_raw(), channel not ready");
135
136 spiAcquireBus(devp->config->spip);
137 spiStart(devp->config->spip,
138 devp->config->spicfg);
139#endif /* LIS302DL_SHARED_SPI */
140
141 for(i = 0; i < LIS302DL_ACC_NUMBER_OF_AXES; i++) {
142 lis302dlSPIReadRegister(devp->config->spip,
143 LIS302DL_AD_OUT_X + (i * 2), 1, &tmp);
144 axes[i] = (int32_t)((int8_t)tmp);
145 }
146
147#if LIS302DL_SHARED_SPI
148 spiReleaseBus(devp->config->spip);
149#endif /* LIS302DL_SHARED_SPI */
150#endif /* LIS302DL_USE_SPI */
151 return msg;
152}
153
154/**
155 * @brief Retrieves cooked data from the BaseAccelerometer.
156 * @note This data is manipulated according to the formula
157 * cooked = (raw * sensitivity) - bias.
158 * @note Final data is expressed as milli-G.
159 * @note The axes array must be at least the same size of the
160 * BaseAccelerometer axes number.
161 *
162 * @param[in] ip pointer to @p BaseAccelerometer interface.
163 * @param[out] axes a buffer which would be filled with cooked data.
164 *
165 * @return The operation status.
166 * @retval MSG_OK if the function succeeded.
167 * @retval MSG_RESET if one or more I2C errors occurred, the errors can
168 * be retrieved using @p i2cGetErrors().
169 * @retval MSG_TIMEOUT if a timeout occurred before operation end.
170 */
171static msg_t acc_read_cooked(void *ip, float axes[]) {
172 LIS302DLDriver* devp;
173 uint32_t i;
174 int32_t raw[LIS302DL_ACC_NUMBER_OF_AXES];
175 msg_t msg;
176
177 osalDbgCheck((ip != NULL) && (axes != NULL));
178
179 /* Getting parent instance pointer.*/
181
182 osalDbgAssert((devp->state == LIS302DL_READY),
183 "acc_read_cooked(), invalid state");
184
185 msg = acc_read_raw(ip, raw);
186 for(i = 0; i < LIS302DL_ACC_NUMBER_OF_AXES; i++) {
187 axes[i] = (raw[i] * devp->accsensitivity[i]) - devp->accbias[i];
188 }
189 return msg;
190}
191
192/**
193 * @brief Set bias values for the BaseAccelerometer.
194 * @note Bias must be expressed as milli-G.
195 * @note The bias buffer must be at least the same size of the
196 * BaseAccelerometer axes number.
197 *
198 * @param[in] ip pointer to @p BaseAccelerometer interface.
199 * @param[in] bp a buffer which contains biases.
200 *
201 * @return The operation status.
202 * @retval MSG_OK if the function succeeded.
203 */
204static msg_t acc_set_bias(void *ip, float *bp) {
205 LIS302DLDriver* devp;
206 uint32_t i;
207 msg_t msg = MSG_OK;
208
209 osalDbgCheck((ip != NULL) && (bp != NULL));
210
211 /* Getting parent instance pointer.*/
213
214 osalDbgAssert((devp->state == LIS302DL_READY),
215 "acc_set_bias(), invalid state");
216
217 for(i = 0; i < LIS302DL_ACC_NUMBER_OF_AXES; i++) {
218 devp->accbias[i] = bp[i];
219 }
220 return msg;
221}
222
223/**
224 * @brief Reset bias values for the BaseAccelerometer.
225 * @note Default biases value are obtained from device datasheet when
226 * available otherwise they are considered zero.
227 *
228 * @param[in] ip pointer to @p BaseAccelerometer interface.
229 *
230 * @return The operation status.
231 * @retval MSG_OK if the function succeeded.
232 */
233static msg_t acc_reset_bias(void *ip) {
234 LIS302DLDriver* devp;
235 uint32_t i;
236 msg_t msg = MSG_OK;
237
238 osalDbgCheck(ip != NULL);
239
240 /* Getting parent instance pointer.*/
242
243 osalDbgAssert((devp->state == LIS302DL_READY),
244 "acc_reset_bias(), invalid state");
245
246 for(i = 0; i < LIS302DL_ACC_NUMBER_OF_AXES; i++)
247 devp->accbias[i] = LIS302DL_ACC_BIAS;
248 return msg;
249}
250
251/**
252 * @brief Set sensitivity values for the BaseAccelerometer.
253 * @note Sensitivity must be expressed as milli-G/LSB.
254 * @note The sensitivity buffer must be at least the same size of the
255 * BaseAccelerometer axes number.
256 *
257 * @param[in] ip pointer to @p BaseAccelerometer interface.
258 * @param[in] sp a buffer which contains sensitivities.
259 *
260 * @return The operation status.
261 * @retval MSG_OK if the function succeeded.
262 */
263static msg_t acc_set_sensivity(void *ip, float *sp) {
264 LIS302DLDriver* devp;
265 uint32_t i;
266 msg_t msg = MSG_OK;
267
268 /* Getting parent instance pointer.*/
270
271 osalDbgCheck((ip != NULL) && (sp != NULL));
272
273 osalDbgAssert((devp->state == LIS302DL_READY),
274 "acc_set_sensivity(), invalid state");
275
276 for(i = 0; i < LIS302DL_ACC_NUMBER_OF_AXES; i++) {
277 devp->accsensitivity[i] = sp[i];
278 }
279 return msg;
280}
281
282/**
283 * @brief Reset sensitivity values for the BaseAccelerometer.
284 * @note Default sensitivities value are obtained from device datasheet.
285 *
286 * @param[in] ip pointer to @p BaseAccelerometer interface.
287 *
288 * @return The operation status.
289 * @retval MSG_OK if the function succeeded.
290 * @retval MSG_RESET otherwise.
291 */
292static msg_t acc_reset_sensivity(void *ip) {
293 LIS302DLDriver* devp;
294 uint32_t i;
295 msg_t msg = MSG_OK;
296
297 osalDbgCheck(ip != NULL);
298
299 /* Getting parent instance pointer.*/
301
302 osalDbgAssert((devp->state == LIS302DL_READY),
303 "acc_reset_sensivity(), invalid state");
304
305 if(devp->config->accfullscale == LIS302DL_ACC_FS_2G)
306 for(i = 0; i < LIS302DL_ACC_NUMBER_OF_AXES; i++)
307 devp->accsensitivity[i] = LIS302DL_ACC_SENS_2G;
308 else if(devp->config->accfullscale == LIS302DL_ACC_FS_8G)
309 for(i = 0; i < LIS302DL_ACC_NUMBER_OF_AXES; i++)
310 devp->accsensitivity[i] = LIS302DL_ACC_SENS_8G;
311 else {
313 "acc_reset_sensivity(), accelerometer full scale issue");
314 return MSG_RESET;
315 }
316 return msg;
317}
318
319/**
320 * @brief Changes the LIS302DLDriver accelerometer fullscale value.
321 * @note This function also rescale sensitivities and biases based on
322 * previous and next fullscale value.
323 * @note A recalibration is highly suggested after calling this function.
324 *
325 * @param[in] devp pointer to @p LIS302DLDriver interface.
326 * @param[in] fs new fullscale value.
327 *
328 * @return The operation status.
329 * @retval MSG_OK if the function succeeded.
330 * @retval MSG_RESET otherwise.
331 */
333 float newfs, scale;
334 uint8_t i, cr;
335 msg_t msg;
336
337 osalDbgCheck(devp != NULL);
338
339 osalDbgAssert((devp->state == LIS302DL_READY),
340 "acc_set_full_scale(), invalid state");
341 osalDbgAssert((devp->config->spip->state == SPI_READY),
342 "acc_set_full_scale(), channel not ready");
343
344 /* Computing new fullscale value.*/
345 if(fs == LIS302DL_ACC_FS_2G) {
346 newfs = LIS302DL_ACC_2G;
347 msg = MSG_OK;
348 }
349 else if(fs == LIS302DL_ACC_FS_8G) {
350 newfs = LIS302DL_ACC_8G;
351 msg = MSG_OK;
352 }
353 else {
354 msg = MSG_RESET;
355 }
356
357 if((msg == MSG_OK) &&
358 (newfs != devp->accfullscale)) {
359 /* Computing scale value.*/
360 scale = newfs / devp->accfullscale;
361 devp->accfullscale = newfs;
362
363#if LIS302DL_USE_SPI
364#if LIS302DL_SHARED_SPI
365 spiAcquireBus(devp->config->spip);
366 spiStart(devp->config->spip,
367 devp->config->spicfg);
368#endif /* LIS302DL_SHARED_SPI */
369
370 /* Getting data from register.*/
371 lis302dlSPIReadRegister(devp->config->spip, LIS302DL_AD_CTRL_REG1, 1, &cr);
372
373#if LIS302DL_SHARED_SPI
374 spiReleaseBus(devp->config->spip);
375#endif /* LIS302DL_SHARED_SPI */
376#endif /* LIS302DL_USE_SPI */
377
379 cr |= fs;
380
381#if LIS302DL_USE_SPI
382#if LIS302DL_SHARED_SPI
383 spiAcquireBus(devp->config->spip);
384 spiStart(devp->config->spip,
385 devp->config->spicfg);
386#endif /* LIS302DL_SHARED_SPI */
387
388 /* Getting data from register.*/
389 lis302dlSPIWriteRegister(devp->config->spip, LIS302DL_AD_CTRL_REG1, 1, &cr);
390
391#if LIS302DL_SHARED_SPI
392 spiReleaseBus(devp->config->spip);
393#endif /* LIS302DL_SHARED_SPI */
394#endif /* LIS302DL_USE_SPI */
395
396 /* Scaling sensitivity and bias. Re-calibration is suggested anyway. */
397 for(i = 0; i < LIS302DL_ACC_NUMBER_OF_AXES; i++) {
398 devp->accsensitivity[i] *= scale;
399 devp->accbias[i] *= scale;
400 }
401 }
402 return msg;
403}
404
405static const struct LIS302DLVMT vmt_device = {
406 (size_t)0,
408};
409
415
416/*===========================================================================*/
417/* Driver exported functions. */
418/*===========================================================================*/
419
420/**
421 * @brief Initializes an instance.
422 *
423 * @param[out] devp pointer to the @p LIS302DLDriver object
424 *
425 * @init
426 */
428 devp->vmt = &vmt_device;
430
431 devp->config = NULL;
432
433 devp->accaxes = LIS302DL_ACC_NUMBER_OF_AXES;
434
435 devp->state = LIS302DL_STOP;
436}
437
438/**
439 * @brief Configures and activates LIS302DL Complex Driver peripheral.
440 *
441 * @param[in] devp pointer to the @p LIS302DLDriver object
442 * @param[in] config pointer to the @p LIS302DLConfig object
443 *
444 * @api
445 */
446void lis302dlStart(LIS302DLDriver *devp, const LIS302DLConfig *config) {
447 uint32_t i;
448 uint8_t cr[2] = {0, 0};
449 osalDbgCheck((devp != NULL) && (config != NULL));
450
451 osalDbgAssert((devp->state == LIS302DL_STOP) || (devp->state == LIS302DL_READY),
452 "lis302dlStart(), invalid state");
453
454 devp->config = config;
455
456 /* Control register 1 configuration block.*/
457 {
460 devp->config->accodr |
461 devp->config->accfullscale;
462 }
463
464 /* Control register 2 configuration block.*/
465 {
466#if LIS302DL_USE_ADVANCED || defined(__DOXYGEN__)
467 if(devp->config->hpmode != LIS302DL_HPM_BYPASSED)
468 cr[1] = devp->config->acchighpass;
469#endif
470 }
471
472#if LIS302DL_USE_SPI
473#if LIS302DL_SHARED_SPI
474 spiAcquireBus((devp)->config->spip);
475#endif /* LIS302DL_SHARED_SPI */
476 spiStart((devp)->config->spip, (devp)->config->spicfg);
477
479 2, cr);
480
481#if LIS302DL_SHARED_SPI
482 spiReleaseBus((devp)->config->spip);
483#endif /* LIS302DL_SHARED_SPI */
484#endif /* LIS302DL_USE_SPI */
485
486 /* Storing sensitivity information according to full scale value */
487 if(devp->config->accfullscale == LIS302DL_ACC_FS_2G) {
488 devp->accfullscale = LIS302DL_ACC_2G;
489 if(devp->config->accsensitivity == NULL)
490 for(i = 0; i < LIS302DL_ACC_NUMBER_OF_AXES; i++)
491 devp->accsensitivity[i] = LIS302DL_ACC_SENS_2G;
492 else
493 for(i = 0; i < LIS302DL_ACC_NUMBER_OF_AXES; i++)
494 devp->accsensitivity[i] = devp->config->accsensitivity[i];
495 }
496 else if(devp->config->accfullscale == LIS302DL_ACC_FS_8G) {
497 devp->accfullscale = LIS302DL_ACC_8G;
498 if(devp->config->accsensitivity == NULL)
499 for(i = 0; i < LIS302DL_ACC_NUMBER_OF_AXES; i++)
500 devp->accsensitivity[i] = LIS302DL_ACC_SENS_8G;
501 else
502 for(i = 0; i < LIS302DL_ACC_NUMBER_OF_AXES; i++)
503 devp->accsensitivity[i] = devp->config->accsensitivity[i];
504 }
505 else {
506 osalDbgAssert(FALSE, "lis302dlStart(), accelerometer full scale issue");
507 }
508
509 /* Storing bias information according to user setting */
510 if(devp->config->accbias != NULL)
511 for(i = 0; i < LIS302DL_ACC_NUMBER_OF_AXES; i++)
512 devp->accbias[i] = devp->config->accbias[i];
513 else
514 for(i = 0; i < LIS302DL_ACC_NUMBER_OF_AXES; i++)
515 devp->accbias[i] = LIS302DL_ACC_BIAS;
516
517 /* This is the Accelerometer transient recovery time */
519
520 devp->state = LIS302DL_READY;
521}
522
523/**
524 * @brief Deactivates the LIS302DL Complex Driver peripheral.
525 *
526 * @param[in] devp pointer to the @p LIS302DLDriver object
527 *
528 * @api
529 */
531 uint8_t cr1;
532 osalDbgCheck(devp != NULL);
533
534 osalDbgAssert((devp->state == LIS302DL_STOP) ||
535 (devp->state == LIS302DL_READY),
536 "lis302dlStop(), invalid state");
537
538 if (devp->state == LIS302DL_READY) {
539#if LIS302DL_USE_SPI
540#if LIS302DL_SHARED_SPI
541 spiAcquireBus((devp)->config->spip);
542 spiStart((devp)->config->spip,
543 (devp)->config->spicfg);
544#endif /* LIS302DL_SHARED_SPI */
545 /* Disabling all axes and enabling power down mode.*/
546 cr1 = 0;
547 lis302dlSPIWriteRegister(devp->config->spip, LIS302DL_AD_CTRL_REG1, 1, &cr1);
548 spiStop((devp)->config->spip);
549#if LIS302DL_SHARED_SPI
550 spiReleaseBus((devp)->config->spip);
551#endif /* LIS302DL_SHARED_SPI */
552#endif /* LIS302DL_USE_SPI */
553 }
554 devp->state = LIS302DL_STOP;
555}
556/** @} */
static size_t acc_get_axes_number(void *ip)
Return the number of axes of the BaseAccelerometer.
Definition adxl317.c:115
static msg_t acc_reset_sensivity(void *ip)
Reset sensitivity values for the BaseAccelerometer.
Definition adxl317.c:310
static msg_t acc_set_bias(void *ip, float *bp)
Set bias values for the BaseAccelerometer.
Definition adxl317.c:222
static msg_t acc_reset_bias(void *ip)
Reset bias values for the BaseAccelerometer.
Definition adxl317.c:251
static msg_t acc_set_sensivity(void *ip, float *sp)
Set sensitivity values for the BaseAccelerometer.
Definition adxl317.c:281
static msg_t acc_read_cooked(void *ip, float axes[])
Retrieves cooked data from the BaseAccelerometer.
Definition adxl317.c:185
static msg_t acc_read_raw(void *ip, int32_t axes[])
Retrieves raw data from the BaseAccelerometer.
Definition adxl317.c:137
static const struct BaseAccelerometerVMT vmt_accelerometer
Definition adxl317.c:332
static const struct ADXL317VMT vmt_device
Definition adxl317.c:328
static msg_t acc_set_full_scale(ADXL355Driver *devp, adxl355_acc_fs_t fs)
Changes the ADXL355Driver accelerometer fullscale value.
Definition adxl355.c:301
#define objGetInstance(type, ip)
Returns the instance pointer starting from an interface pointer.
Definition hal_objects.h:78
#define LIS302DL_AD_CTRL_REG1
Definition lis302dl.h:100
#define LIS302DL_CTRL_REG1_YEN
Definition lis302dl.h:131
void lis302dlStart(LIS302DLDriver *devp, const LIS302DLConfig *config)
Configures and activates LIS302DL Complex Driver peripheral.
Definition lis302dl.c:446
static size_t acc_get_axes_number(void *ip)
Return the number of axes of the BaseAccelerometer.
Definition lis302dl.c:96
void lis302dlStop(LIS302DLDriver *devp)
Deactivates the LIS302DL Complex Driver peripheral.
Definition lis302dl.c:530
#define LIS302DL_ACC_NUMBER_OF_AXES
LIS302DL accelerometer subsystem characteristics.
Definition lis302dl.h:72
#define LIS302DL_AD_OUT_X
Definition lis302dl.h:105
static msg_t acc_reset_sensivity(void *ip)
Reset sensitivity values for the BaseAccelerometer.
Definition lis302dl.c:292
static msg_t acc_set_bias(void *ip, float *bp)
Set bias values for the BaseAccelerometer.
Definition lis302dl.c:204
#define LIS302DL_ACC_SENS_8G
Definition lis302dl.h:78
lis302dl_acc_fs_t
LIS302DL full scale.
Definition lis302dl.h:273
static msg_t acc_set_full_scale(LIS302DLDriver *devp, lis302dl_acc_fs_t fs)
Changes the LIS302DLDriver accelerometer fullscale value.
Definition lis302dl.c:332
#define LIS302DL_CTRL_REG1_XEN
Definition lis302dl.h:130
#define LIS302DL_RW
Definition lis302dl.h:92
#define LIS302DL_ACC_BIAS
Definition lis302dl.h:80
void lis302dlObjectInit(LIS302DLDriver *devp)
Initializes an instance.
Definition lis302dl.c:427
static msg_t acc_reset_bias(void *ip)
Reset bias values for the BaseAccelerometer.
Definition lis302dl.c:233
#define LIS302DL_CTRL_REG1_ZEN
Definition lis302dl.h:132
static msg_t acc_set_sensivity(void *ip, float *sp)
Set sensitivity values for the BaseAccelerometer.
Definition lis302dl.c:263
#define LIS302DL_ACC_SENS_2G
Definition lis302dl.h:77
static msg_t acc_read_cooked(void *ip, float axes[])
Retrieves cooked data from the BaseAccelerometer.
Definition lis302dl.c:171
#define LIS302DL_CTRL_REG1_PD
Definition lis302dl.h:137
static msg_t acc_read_raw(void *ip, int32_t axes[])
Retrieves raw data from the BaseAccelerometer.
Definition lis302dl.c:118
static void lis302dlSPIWriteRegister(SPIDriver *spip, uint8_t reg, size_t n, uint8_t *b)
Writes a value into a generic register using SPI.
Definition lis302dl.c:78
#define LIS302DL_ACC_2G
Definition lis302dl.h:74
static void lis302dlSPIReadRegister(SPIDriver *spip, uint8_t reg, size_t n, uint8_t *b)
Reads a generic register value using SPI.
Definition lis302dl.c:59
#define LIS302DL_CTRL_REG1_FS_MASK
Definition lis302dl.h:135
#define LIS302DL_ACC_8G
Definition lis302dl.h:75
#define LIS302DL_MS
Definition lis302dl.h:91
@ LIS302DL_STOP
Definition lis302dl.h:302
@ LIS302DL_READY
Definition lis302dl.h:303
@ LIS302DL_ACC_FS_8G
Definition lis302dl.h:275
@ LIS302DL_ACC_FS_2G
Definition lis302dl.h:274
#define osalDbgAssert(c, remark)
Condition assertion.
Definition osal.h:264
#define osalDbgCheck(c)
Function parameters check.
Definition osal.h:284
#define osalThreadSleepMilliseconds(msecs)
Delays the invoking thread for the specified number of milliseconds.
Definition osal.h:522
void spiSelect(SPIDriver *spip)
Asserts the slave select signal and prepares for transfers.
void spiReleaseBus(SPIDriver *spip)
Releases exclusive access to the SPI bus.
void spiSend(SPIDriver *spip, size_t n, const void *txbuf)
Sends data over the SPI bus.
void spiAcquireBus(SPIDriver *spip)
Gains exclusive access to the SPI bus.
msg_t spiStart(SPIDriver *spip, const SPIConfig *config)
Configures and activates the SPI peripheral.
struct hal_spi_driver SPIDriver
Type of a structure representing an SPI driver.
Definition hal_spi_v1.h:117
void spiStop(SPIDriver *spip)
Deactivates the SPI peripheral.
void spiReceive(SPIDriver *spip, size_t n, void *rxbuf)
Receives data from the SPI bus.
void spiUnselect(SPIDriver *spip)
Deasserts the slave select signal.
@ SPI_READY
Definition hal_spi_v1.h:109
#define FALSE
Generic 'false' preprocessor boolean constant.
int32_t msg_t
Definition chearly.h:88
#define MSG_OK
Normal wakeup message.
Definition chschd.h:39
#define MSG_RESET
Wakeup caused by a reset condition.
Definition chschd.h:42
HAL subsystem header.
LIS302DL MEMS interface module header.
Base accelerometer class.
const struct BaseAccelerometerVMT * vmt
Virtual Methods Table.
BaseAccelerometer virtual methods table.
LIS302DL configuration structure.
Definition lis302dl.h:309
SPIDriver * spip
SPI driver associated to this LIS302DL.
Definition lis302dl.h:315
LIS302DL 3-axis accelerometer class.
Definition lis302dl.h:399
BaseAccelerometer acc_if
Base accelerometer interface.
Definition lis302dl.h:403
const struct LIS302DLVMT * vmt
Virtual Methods Table.
Definition lis302dl.h:401
LIS302DL accelerometer virtual methods table.
Definition lis302dl.h:375
const SPIConfig * config
Current configuration data.
Definition hal_spi_v1.h:190