ChibiOS 21.11.4
adxl355.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 adxl355.c
23 * @brief ADXL355 MEMS interface module code.
24 *
25 * @addtogroup ADXL355
26 * @ingroup EX_ADI
27 * @{
28 */
29
30#include "hal.h"
31#include "adxl355.h"
32#include "string.h"
33
34/*===========================================================================*/
35/* Driver local definitions. */
36/*===========================================================================*/
37
38/*===========================================================================*/
39/* Driver exported variables. */
40/*===========================================================================*/
41
42/*===========================================================================*/
43/* Driver local variables and types. */
44/*===========================================================================*/
45
46/*===========================================================================*/
47/* Driver local functions. */
48/*===========================================================================*/
49
50/**
51 * @brief Return the number of axes of the BaseAccelerometer.
52 *
53 * @param[in] ip pointer to @p BaseAccelerometer interface.
54 *
55 * @return the number of axes.
56 */
57static size_t acc_get_axes_number(void *ip) {
58 (void)ip;
59
61}
62
63/**
64 * @brief Retrieves raw data from the BaseAccelerometer.
65 * @note This data is retrieved from MEMS register without any algebraical
66 * manipulation.
67 * @note The axes array must be at least the same size of the
68 * BaseAccelerometer axes number.
69 *
70 * @param[in] ip pointer to @p BaseAccelerometer interface.
71 * @param[out] axes a buffer which would be filled with raw data.
72 *
73 * @return The operation status.
74 * @retval MSG_OK if the function succeeded.
75 * @retval MSG_RESET if one or more I2C errors occurred, the errors can
76 * be retrieved using @p i2cGetErrors().
77 * @retval MSG_TIMEOUT if a timeout occurred before operation end.
78 */
79static msg_t acc_read_raw(void *ip, int32_t axes[]) {
80 ADXL355Driver* devp;
81 uint8_t buff [ADXL355_ACC_NUMBER_OF_AXES * 3], i;
82 int32_t tmp;
83 msg_t msg = MSG_OK;
84
85 osalDbgCheck((ip != NULL) && (axes != NULL));
86
87 /* Getting parent instance pointer.*/
89 osalDbgAssert((devp->state == ADXL355_READY),
90 "acc_read_raw(), invalid state");
91
92#if ADXL355_USE_SPI
93#if ADXL355_SHARED_SPI
94 osalDbgAssert((devp->config->spip->state == SPI_READY),
95 "acc_read_raw(), channel not ready");
96
97 spiAcquireBus(devp->config->spip);
98 spiStart(devp->config->spip,
99 devp->config->spicfg);
100#endif /* ADXL355_SHARED_SPI */
101
104
105#if ADXL355_SHARED_SPI
106 spiReleaseBus(devp->config->spip);
107#endif /* ADXL355_SHARED_SPI */
108#endif /* ADXL355_USE_SPI */
109
110 for(i = 0; i < ADXL355_ACC_NUMBER_OF_AXES; i++) {
111 tmp = (buff[3 * i] << 12) | (buff[3 * i + 1] << 4) | (buff[3 * i + 2] >> 4);
112 if(tmp & 0x80000) {
113 tmp |= 0xFFF00000U;
114 }
115 axes[i] = tmp;
116 }
117 return msg;
118}
119
120/**
121 * @brief Retrieves cooked data from the BaseAccelerometer.
122 * @note This data is manipulated according to the formula
123 * cooked = (raw * sensitivity) - bias.
124 * @note Final data is expressed as milli-G.
125 * @note The axes array must be at least the same size of the
126 * BaseAccelerometer axes number.
127 *
128 * @param[in] ip pointer to @p BaseAccelerometer interface.
129 * @param[out] axes a buffer which would be filled with cooked data.
130 *
131 * @return The operation status.
132 * @retval MSG_OK if the function succeeded.
133 * @retval MSG_RESET if one or more I2C errors occurred, the errors can
134 * be retrieved using @p i2cGetErrors().
135 * @retval MSG_TIMEOUT if a timeout occurred before operation end.
136 */
137static msg_t acc_read_cooked(void *ip, float axes[]) {
138 ADXL355Driver* devp;
139 uint32_t i;
140 int32_t raw[ADXL355_ACC_NUMBER_OF_AXES];
141 msg_t msg = MSG_OK;
142
143 osalDbgCheck((ip != NULL) && (axes != NULL));
144
145 /* Getting parent instance pointer.*/
147
148 osalDbgAssert((devp->state == ADXL355_READY),
149 "acc_read_cooked(), invalid state");
150
151 msg = acc_read_raw(ip, raw);
152 for(i = 0; i < ADXL355_ACC_NUMBER_OF_AXES; i++) {
153 axes[i] = (raw[i] * devp->accsensitivity[i]) - devp->accbias[i];
154 }
155 return msg;
156}
157
158/**
159 * @brief Set bias values for the BaseAccelerometer.
160 * @note Bias must be expressed as milli-G.
161 * @note The bias buffer must be at least the same size of the
162 * BaseAccelerometer axes number.
163 *
164 * @param[in] ip pointer to @p BaseAccelerometer interface.
165 * @param[in] bp a buffer which contains biases.
166 *
167 * @return The operation status.
168 * @retval MSG_OK if the function succeeded.
169 */
170static msg_t acc_set_bias(void *ip, float *bp) {
171 ADXL355Driver* devp;
172 uint32_t i;
173 msg_t msg = MSG_OK;
174
175 osalDbgCheck((ip != NULL) && (bp != NULL));
176
177 /* Getting parent instance pointer.*/
179
180 osalDbgAssert((devp->state == ADXL355_READY),
181 "acc_set_bias(), invalid state");
182
183 for(i = 0; i < ADXL355_ACC_NUMBER_OF_AXES; i++) {
184 devp->accbias[i] = bp[i];
185 }
186 return msg;
187}
188
189/**
190 * @brief Reset bias values for the BaseAccelerometer.
191 * @note Default biases value are obtained from device datasheet when
192 * available otherwise they are considered zero.
193 *
194 * @param[in] ip pointer to @p BaseAccelerometer interface.
195 *
196 * @return The operation status.
197 * @retval MSG_OK if the function succeeded.
198 */
199static msg_t acc_reset_bias(void *ip) {
200 ADXL355Driver* devp;
201 uint32_t i;
202 msg_t msg = MSG_OK;
203
204 osalDbgCheck(ip != NULL);
205
206 /* Getting parent instance pointer.*/
208
209 osalDbgAssert((devp->state == ADXL355_READY),
210 "acc_reset_bias(), invalid state");
211
212 for(i = 0; i < ADXL355_ACC_NUMBER_OF_AXES; i++)
213 devp->accbias[i] = ADXL355_ACC_BIAS;
214 return msg;
215}
216
217/**
218 * @brief Set sensitivity values for the BaseAccelerometer.
219 * @note Sensitivity must be expressed as milli-G/LSB.
220 * @note The sensitivity buffer must be at least the same size of the
221 * BaseAccelerometer axes number.
222 *
223 * @param[in] ip pointer to @p BaseAccelerometer interface.
224 * @param[in] sp a buffer which contains sensitivities.
225 *
226 * @return The operation status.
227 * @retval MSG_OK if the function succeeded.
228 */
229static msg_t acc_set_sensivity(void *ip, float *sp) {
230 ADXL355Driver* devp;
231 uint32_t i;
232 msg_t msg = MSG_OK;
233
234 /* Getting parent instance pointer.*/
236
237 osalDbgCheck((ip != NULL) && (sp != NULL));
238
239 osalDbgAssert((devp->state == ADXL355_READY),
240 "acc_set_sensivity(), invalid state");
241
242 for(i = 0; i < ADXL355_ACC_NUMBER_OF_AXES; i++) {
243 devp->accsensitivity[i] = sp[i];
244 }
245 return msg;
246}
247
248/**
249 * @brief Reset sensitivity values for the BaseAccelerometer.
250 * @note Default sensitivities value are obtained from device datasheet.
251 *
252 * @param[in] ip pointer to @p BaseAccelerometer interface.
253 *
254 * @return The operation status.
255 * @retval MSG_OK if the function succeeded.
256 * @retval MSG_RESET otherwise.
257 */
258static msg_t acc_reset_sensivity(void *ip) {
259 ADXL355Driver* devp;
260 uint32_t i;
261 msg_t msg = MSG_OK;
262
263 osalDbgCheck(ip != NULL);
264
265 /* Getting parent instance pointer.*/
267
268 osalDbgAssert((devp->state == ADXL355_READY),
269 "acc_reset_sensivity(), invalid state");
270
271 if(devp->config->accfullscale == ADXL355_ACC_FS_2G)
272 for(i = 0; i < ADXL355_ACC_NUMBER_OF_AXES; i++)
273 devp->accsensitivity[i] = ADXL355_ACC_SENS_2G;
274 else if(devp->config->accfullscale == ADXL355_ACC_FS_4G)
275 for(i = 0; i < ADXL355_ACC_NUMBER_OF_AXES; i++)
276 devp->accsensitivity[i] = ADXL355_ACC_SENS_4G;
277 else if(devp->config->accfullscale == ADXL355_ACC_FS_8G)
278 for(i = 0; i < ADXL355_ACC_NUMBER_OF_AXES; i++)
279 devp->accsensitivity[i] = ADXL355_ACC_SENS_8G;
280 else {
282 "acc_reset_sensivity(), accelerometer full scale issue");
283 return MSG_RESET;
284 }
285 return msg;
286}
287
288/**
289 * @brief Changes the ADXL355Driver accelerometer fullscale value.
290 * @note This function also rescale sensitivities and biases based on
291 * previous and next fullscale value.
292 * @note A recalibration is highly suggested after calling this function.
293 *
294 * @param[in] devp pointer to @p ADXL355Driver interface.
295 * @param[in] fs new fullscale value.
296 *
297 * @return The operation status.
298 * @retval MSG_OK if the function succeeded.
299 * @retval MSG_RESET otherwise.
300 */
302 float newfs, scale;
303 uint8_t i, reg_val;
304 msg_t msg = MSG_OK;
305
306 osalDbgCheck(devp != NULL);
307
308 osalDbgAssert((devp->state == ADXL355_READY),
309 "acc_set_full_scale(), invalid state");
310 osalDbgAssert((devp->config->spip->state == SPI_READY),
311 "acc_set_full_scale(), channel not ready");
312
313 /* Computing new fullscale value.*/
314 if(fs == ADXL355_ACC_FS_2G) {
315 newfs = ADXL355_ACC_2G;
316 msg = MSG_OK;
317 }
318 else if(fs == ADXL355_ACC_FS_4G) {
319 newfs = ADXL355_ACC_4G;
320 msg = MSG_OK;
321 }
322 else if(fs == ADXL355_ACC_FS_8G) {
323 newfs = ADXL355_ACC_8G;
324 msg = MSG_OK;
325 }
326 else {
327 msg = MSG_RESET;
328 }
329
330 if((msg == MSG_OK) &&
331 (newfs != devp->accfullscale)) {
332 /* Computing scale value.*/
333 scale = newfs / devp->accfullscale;
334 devp->accfullscale = newfs;
335
336#if ADXL355_USE_SPI
337#if ADXL355_SHARED_SPI
338 spiAcquireBus(devp->config->spip);
339 spiStart(devp->config->spip,
340 devp->config->spicfg);
341#endif /* ADXL355_SHARED_SPI */
342
343 /* Getting data from register.*/
344 adxl355SPIReadRegister(devp, ADXL355_AD_RANGE, 1, &reg_val);
345
346#if ADXL355_SHARED_SPI
347 spiReleaseBus(devp->config->spip);
348#endif /* ADXL355_SHARED_SPI */
349#endif /* ADXL355_USE_SPI */
350
351 reg_val &= ~(ADXL355_RANGE_RANGE_MASK);
352 reg_val |= fs;
353
354#if ADXL355_USE_SPI
355#if ADXL355_SHARED_SPI
356 spiAcquireBus(devp->config->spip);
357 spiStart(devp->config->spip,
358 devp->config->spicfg);
359#endif /* ADXL355_SHARED_SPI */
360
361 /* Getting data from register.*/
362 adxl355SPIWriteRegister(devp, ADXL355_AD_RANGE, 1, &reg_val);
363
364#if ADXL355_SHARED_SPI
365 spiReleaseBus(devp->config->spip);
366#endif /* ADXL355_SHARED_SPI */
367#endif /* ADXL355_USE_SPI */
368
369 /* Scaling sensitivity and bias. Re-calibration is suggested anyway. */
370 for(i = 0; i < ADXL355_ACC_NUMBER_OF_AXES; i++) {
371 devp->accsensitivity[i] *= scale;
372 devp->accbias[i] *= scale;
373 }
374 }
375 return msg;
376}
377
378static const struct ADXL355VMT vmt_device = {
379 (size_t)0,
381};
382
388
389/*===========================================================================*/
390/* Driver exported functions. */
391/*===========================================================================*/
392
393#if (ADXL355_USE_SPI) || defined(__DOXYGEN__)
394/**
395 * @brief Reads a generic register value using SPI.
396 * @pre The SPI interface must be initialized and the driver started.
397 *
398 * @param[in] devp pointer to @p ADXL355Driver interface.
399 * @param[in] reg starting register address
400 * @param[in] n number of consecutive registers to read
401 * @param[in] b pointer to an output buffer.
402 */
403void adxl355SPIReadRegister(ADXL355Driver *devp, uint8_t reg, size_t n,
404 uint8_t* b) {
405
407
408 /* Preparing a read. */
409 devp->commtxp[0] = (reg << 1) | ADXL355_RW;
410
411 /* Reading. */
412 cacheBufferFlush(&devp->commtxp[0], sizeof(devp->commtxp));
413 spiSelect(devp->config->spip);
414 spiSend(devp->config->spip, 1, devp->commtxp);
415 spiReceive(devp->config->spip, n, devp->commrxp);
416 spiUnselect(devp->config->spip);
417 cacheBufferInvalidate(&devp->commrxp[0], sizeof(devp->commrxp));
418
419 /* Copying the data in the final buffer. */
420 memcpy(b, devp->commrxp, n);
421}
422
423/**
424 * @brief Writes a value into a generic register using SPI.
425 * @pre The SPI interface must be initialized and the driver started.
426 *
427 * @param[in] devp pointer to @p ADXL355Driver interface.
428 * @param[in] reg starting register address
429 * @param[in] n number of adjacent registers to write
430 * @param[in] b pointer to a buffer of values.
431 */
432void adxl355SPIWriteRegister(ADXL355Driver *devp, uint8_t reg, size_t n,
433 uint8_t* b) {
434 unsigned i;
435
437
438 /* Preparing a write. */
439 devp->commtxp[0] = (reg << 1);
440 for(i = 0; i < n; i++, b++) {
441 devp->commtxp[i + 1] = *b;
442 }
443
444 /* Writing. */
445 cacheBufferFlush(&devp->commtxp[0], sizeof(devp->commtxp));
446 spiSelect(devp->config->spip);
447 spiSend(devp->config->spip, n + 1, devp->commtxp);
448 spiUnselect(devp->config->spip);
449}
450#endif /* ADXL355_USE_SPI */
451
452/**
453 * @brief Initializes an instance.
454 * @details The buffer should be at least large @p ADXL355_COMM_BUFF_SIZE.
455 * @note The communication buffer could be used by DMAs.
456 *
457 * @param[out] devp pointer to the @p ADXL355Driver object
458 * @param[in] txbp pointer to a buffer used as communication tx buffer
459 * @param[in] rxbp pointer to a buffer used as communication rx buffer
460 *
461 * @init
462 */
463void adxl355ObjectInit(ADXL355Driver *devp, uint8_t* txbp, uint8_t* rxbp) {
464 devp->vmt = &vmt_device;
466
467 devp->config = NULL;
468 devp->commtxp = txbp;
469 devp->commrxp = rxbp;
470
471 devp->accaxes = ADXL355_ACC_NUMBER_OF_AXES;
472
473 devp->state = ADXL355_STOP;
474}
475
476/**
477 * @brief Configures and activates ADXL355 Complex Driver peripheral.
478 *
479 * @param[in] devp pointer to the @p ADXL355Driver object
480 * @param[in] config pointer to the @p ADXL355Config object
481 *
482 * @api
483 */
484void adxl355Start(ADXL355Driver *devp, const ADXL355Config *config) {
485 uint32_t i;
486 uint8_t reg_val;
487 osalDbgCheck((devp != NULL) && (config != NULL));
488
489 osalDbgAssert((devp->state == ADXL355_STOP) ||
490 (devp->state == ADXL355_READY),
491 "adxl355Start(), invalid state");
492
493 devp->config = config;
494
495 /* Checking the device ID.*/
496 {
497#if ADXL355_SHARED_SPI
498 spiAcquireBus(devp->config->spip);
499#endif /* ADXL355_SHARED_SPI */
500 spiStart(devp->config->spip, devp->config->spicfg);
502 osalDbgAssert((reg_val == ADXL355_DEVID_MST), "Invalid MEMS ID");
503#if ADXL355_SHARED_SPI
504 spiReleaseBus(devp->config->spip);
505#endif /* ADXL355_SHARED_SPI */
506 }
507
508 /* Range register configuration block.*/
509 {
510 reg_val = ADXL355_RANGE_I2C_HS | devp->config->accfullscale;
511
512#if ADXL355_USE_SPI
513#if ADXL355_SHARED_SPI
514 spiAcquireBus(devp->config->spip);
515 spiStart(devp->config->spip, devp->config->spicfg);
516#endif /* ADXL355_SHARED_SPI */
517
518 adxl355SPIWriteRegister(devp, ADXL355_AD_RANGE, 1, &reg_val);
519
520#if ADXL355_SHARED_SPI
521 spiReleaseBus(devp->config->spip);
522#endif /* ADXL355_SHARED_SPI */
523#endif /* ADXL355_USE_SPI */
524 }
525
526 /* Filter register configuration block.*/
527 {
528 reg_val = devp->config->accodr;
529#if ADXL355_USE_ADVANCED || defined(__DOXYGEN__)
530 reg_val |= devp->config->acchighpass;
531#endif
532
533#if ADXL355_USE_SPI
534#if ADXL355_SHARED_SPI
535 spiAcquireBus(devp->config->spip);
536 spiStart(devp->config->spip, devp->config->spicfg);
537#endif /* ADXL355_SHARED_SPI */
538
539 adxl355SPIWriteRegister(devp, ADXL355_AD_FILTER, 1, &reg_val);
540
541#if ADXL355_SHARED_SPI
542 spiReleaseBus(devp->config->spip);
543#endif /* ADXL355_SHARED_SPI */
544#endif /* ADXL355_USE_SPI */
545 }
546
547 /* Power control configuration block.*/
548 {
549 reg_val = 0;
550
551#if ADXL355_USE_SPI
552#if ADXL355_SHARED_SPI
553 spiAcquireBus(devp->config->spip);
554 spiStart(devp->config->spip, devp->config->spicfg);
555#endif /* ADXL355_SHARED_SPI */
556
558
559#if ADXL355_SHARED_SPI
560 spiReleaseBus(devp->config->spip);
561#endif /* ADXL355_SHARED_SPI */
562#endif /* ADXL355_USE_SPI */
563 }
564
565 /* Storing sensitivity information according to user setting */
566 if(devp->config->accfullscale == ADXL355_ACC_FS_2G) {
567 devp->accfullscale = ADXL355_ACC_2G;
568 if(devp->config->accsensitivity == NULL)
569 for(i = 0; i < ADXL355_ACC_NUMBER_OF_AXES; i++)
570 devp->accsensitivity[i] = ADXL355_ACC_SENS_2G;
571 else
572 for(i = 0; i < ADXL355_ACC_NUMBER_OF_AXES; i++)
573 devp->accsensitivity[i] = devp->config->accsensitivity[i];
574 }
575 else if(devp->config->accfullscale == ADXL355_ACC_FS_4G) {
576 devp->accfullscale = ADXL355_ACC_4G;
577 if(devp->config->accsensitivity == NULL)
578 for(i = 0; i < ADXL355_ACC_NUMBER_OF_AXES; i++)
579 devp->accsensitivity[i] = ADXL355_ACC_SENS_4G;
580 else
581 for(i = 0; i < ADXL355_ACC_NUMBER_OF_AXES; i++)
582 devp->accsensitivity[i] = devp->config->accsensitivity[i];
583 }
584 else if(devp->config->accfullscale == ADXL355_ACC_FS_8G) {
585 devp->accfullscale = ADXL355_ACC_8G;
586 if(devp->config->accsensitivity == NULL)
587 for(i = 0; i < ADXL355_ACC_NUMBER_OF_AXES; i++)
588 devp->accsensitivity[i] = ADXL355_ACC_SENS_8G;
589 else
590 for(i = 0; i < ADXL355_ACC_NUMBER_OF_AXES; i++)
591 devp->accsensitivity[i] = devp->config->accsensitivity[i];
592 }
593 else {
594 osalDbgAssert(FALSE, "adxl355Start(), accelerometer full scale issue");
595 }
596
597 /* Storing bias information according to user setting */
598 if(devp->config->accbias != NULL)
599 for(i = 0; i < ADXL355_ACC_NUMBER_OF_AXES; i++)
600 devp->accbias[i] = devp->config->accbias[i];
601 else
602 for(i = 0; i < ADXL355_ACC_NUMBER_OF_AXES; i++)
603 devp->accbias[i] = ADXL355_ACC_BIAS;
604
605 /* This is the Accelerometer transient recovery time */
607
608 devp->state = ADXL355_READY;
609}
610
611/**
612 * @brief Deactivates the ADXL355 Complex Driver peripheral.
613 *
614 * @param[in] devp pointer to the @p ADXL355Driver object
615 *
616 * @api
617 */
619 uint8_t reg_val;
620 osalDbgCheck(devp != NULL);
621
622 osalDbgAssert((devp->state == ADXL355_STOP) ||
623 (devp->state == ADXL355_READY),
624 "adxl355Stop(), invalid state");
625
626 if (devp->state == ADXL355_READY) {
627#if (ADXL355_USE_SPI)
628#if ADXL355_SHARED_SPI
629 spiAcquireBus(devp->config->spip);
630 spiStart(devp->config->spip,
631 devp->config->spicfg);
632#endif /* ADXL355_SHARED_SPI */
633 /* Disabling all axes and enabling power down mode.*/
634 reg_val = 1;
636
637 spiStop(devp->config->spip);
638#if ADXL355_SHARED_SPI
639 spiReleaseBus(devp->config->spip);
640#endif /* ADXL355_SHARED_SPI */
641#endif /* ADXL355_USE_SPI */
642 }
643 devp->state = ADXL355_STOP;
644}
645/** @} */
ADXL355 MEMS interface module header.
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
#define ADXL355_AD_DEVID_MST
Definition adxl355.h:101
void adxl355SPIWriteRegister(ADXL355Driver *devp, uint8_t reg, size_t n, uint8_t *b)
Writes a value into a generic register using SPI.
Definition adxl355.c:432
#define ADXL355_ACC_BIAS
Definition adxl355.h:82
#define ADXL355_AD_XDATA3
Definition adxl355.h:108
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 ADXL355_ACC_SENS_8G
Definition adxl355.h:80
static size_t acc_get_axes_number(void *ip)
Return the number of axes of the BaseAccelerometer.
Definition adxl355.c:57
#define ADXL355_RW
Definition adxl355.h:92
#define ADXL355_AD_RANGE
Definition adxl355.h:132
#define ADXL355_AD_POWER_CTL
Definition adxl355.h:133
adxl355_acc_fs_t
ADXL355 full scale.
Definition adxl355.h:340
static msg_t acc_reset_sensivity(void *ip)
Reset sensitivity values for the BaseAccelerometer.
Definition adxl355.c:258
static msg_t acc_set_bias(void *ip, float *bp)
Set bias values for the BaseAccelerometer.
Definition adxl355.c:170
#define ADXL355_AD_FILTER
Definition adxl355.h:128
void adxl355Start(ADXL355Driver *devp, const ADXL355Config *config)
Configures and activates ADXL355 Complex Driver peripheral.
Definition adxl355.c:484
#define ADXL355_ACC_2G
Definition adxl355.h:74
static msg_t acc_reset_bias(void *ip)
Reset bias values for the BaseAccelerometer.
Definition adxl355.c:199
#define ADXL355_ACC_4G
Definition adxl355.h:75
void adxl355SPIReadRegister(ADXL355Driver *devp, uint8_t reg, size_t n, uint8_t *b)
Reads a generic register value using SPI.
Definition adxl355.c:403
#define ADXL355_ACC_8G
Definition adxl355.h:76
static msg_t acc_set_sensivity(void *ip, float *sp)
Set sensitivity values for the BaseAccelerometer.
Definition adxl355.c:229
static msg_t acc_read_cooked(void *ip, float axes[])
Retrieves cooked data from the BaseAccelerometer.
Definition adxl355.c:137
void adxl355ObjectInit(ADXL355Driver *devp, uint8_t *txbp, uint8_t *rxbp)
Initializes an instance.
Definition adxl355.c:463
static msg_t acc_read_raw(void *ip, int32_t axes[])
Retrieves raw data from the BaseAccelerometer.
Definition adxl355.c:79
#define ADXL355_DEVID_MST
Definition adxl355.h:142
#define ADXL355_ACC_SENS_2G
Definition adxl355.h:78
#define ADXL355_COMM_BUFF_SIZE
ADXL355 internal communication buffer sizes.
Definition adxl355.h:289
#define ADXL355_RANGE_RANGE_MASK
Definition adxl355.h:203
#define ADXL355_ACC_SENS_4G
Definition adxl355.h:79
void adxl355Stop(ADXL355Driver *devp)
Deactivates the ADXL355 Complex Driver peripheral.
Definition adxl355.c:618
#define ADXL355_RANGE_I2C_HS
Definition adxl355.h:208
#define ADXL355_ACC_NUMBER_OF_AXES
ADXL355 accelerometer subsystem characteristics.
Definition adxl355.h:72
@ ADXL355_ACC_FS_4G
Definition adxl355.h:342
@ ADXL355_ACC_FS_8G
Definition adxl355.h:343
@ ADXL355_ACC_FS_2G
Definition adxl355.h:341
@ ADXL355_READY
Definition adxl355.h:382
@ ADXL355_STOP
Definition adxl355.h:381
#define objGetInstance(type, ip)
Returns the instance pointer starting from an interface pointer.
Definition hal_objects.h:78
#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.
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.
ADXL355 configuration structure.
Definition adxl355.h:388
ADXL355 3-axis accelerometer class.
Definition adxl355.h:483
BaseAccelerometer acc_if
Base accelerometer interface.
Definition adxl355.h:487
const struct ADXL355VMT * vmt
Virtual Methods Table.
Definition adxl355.h:485
ADXL355 virtual methods table.
Definition adxl355.h:454
Base accelerometer class.
const struct BaseAccelerometerVMT * vmt
Virtual Methods Table.
BaseAccelerometer virtual methods table.