49#if (LIS3DSH_USE_SPI) || defined(__DOXYGEN__)
132 "acc_read_raw(), invalid state");
135#if LIS3DSH_SHARED_SPI
137 "acc_read_raw(), channel not ready");
141 devp->config->spicfg);
147#if LIS3DSH_SHARED_SPI
153 tmp = buff[2 * i] + (buff[2 * i + 1] << 8);
154 axes[i] = (int32_t)tmp;
188 "acc_read_cooked(), invalid state");
192 axes[i] = (raw[i] * devp->accsensitivity[i]) - devp->accbias[i];
220 "acc_set_bias(), invalid state");
223 devp->accbias[i] = bp[i];
249 "acc_reset_bias(), invalid state");
279 "acc_set_sensivity(), invalid state");
282 devp->accsensitivity[i] = sp[i];
308 "acc_reset_sensivity(), invalid state");
327 "acc_reset_sensivity(), accelerometer full scale issue");
354 "acc_set_full_scale(), invalid state");
356 "acc_set_full_scale(), channel not ready");
384 (newfs != devp->accfullscale)) {
386 scale = newfs / devp->accfullscale;
387 devp->accfullscale = newfs;
390#if LIS3DSH_SHARED_SPI
393 devp->config->spicfg);
399#if LIS3DSH_SHARED_SPI
408#if LIS3DSH_SHARED_SPI
411 devp->config->spicfg);
417#if LIS3DSH_SHARED_SPI
424 devp->accsensitivity[i] *= scale;
425 devp->accbias[i] *= scale;
479 "lis3dshStart(), invalid state");
481 devp->config = config;
486 devp->config->accodr;
487#if LIS3DSH_USE_ADVANCED || defined(__DOXYGEN__)
488 cr |= devp->config->accbdu;
493#if LIS3DSH_SHARED_SPI
496 spiStart(devp->config->spip, devp->config->spicfg);
500#if LIS3DSH_SHARED_SPI
507 cr = devp->config->accfullscale;
508#if LIS3DSH_USE_ADVANCED || defined(__DOXYGEN__)
509 cr |= devp->config->accantialiasing;
514#if LIS3DSH_SHARED_SPI
516 spiStart(devp->config->spip, devp->config->spicfg);
521#if LIS3DSH_SHARED_SPI
529#if LIS3DSH_USE_ADVANCED || defined(__DOXYGEN__)
530 cr |= devp->config->accbdu;
535#if LIS3DSH_SHARED_SPI
537 spiStart(devp->config->spip, devp->config->spicfg);
542#if LIS3DSH_SHARED_SPI
550 if(devp->config->accsensitivity == NULL)
555 devp->accsensitivity[i] = devp->config->accsensitivity[i];
559 if(devp->config->accsensitivity == NULL)
564 devp->accsensitivity[i] = devp->config->accsensitivity[i];
568 if(devp->config->accsensitivity == NULL)
573 devp->accsensitivity[i] = devp->config->accsensitivity[i];
577 if(devp->config->accsensitivity == NULL)
582 devp->accsensitivity[i] = devp->config->accsensitivity[i];
586 if(devp->config->accsensitivity == NULL)
591 devp->accsensitivity[i] = devp->config->accsensitivity[i];
598 if(devp->config->accbias != NULL)
600 devp->accbias[i] = devp->config->accbias[i];
624 "lis3dshStop(), invalid state");
628#if LIS3DSH_SHARED_SPI
631 devp->config->spicfg);
639#if LIS3DSH_SHARED_SPI
static size_t acc_get_axes_number(void *ip)
Return the number of axes of the BaseAccelerometer.
static msg_t acc_reset_sensivity(void *ip)
Reset sensitivity values for the BaseAccelerometer.
static msg_t acc_set_bias(void *ip, float *bp)
Set bias values for the BaseAccelerometer.
static msg_t acc_reset_bias(void *ip)
Reset bias values for the BaseAccelerometer.
static msg_t acc_set_sensivity(void *ip, float *sp)
Set sensitivity values for the BaseAccelerometer.
static msg_t acc_read_cooked(void *ip, float axes[])
Retrieves cooked data from the BaseAccelerometer.
static msg_t acc_read_raw(void *ip, int32_t axes[])
Retrieves raw data from the BaseAccelerometer.
static const struct BaseAccelerometerVMT vmt_accelerometer
static const struct ADXL317VMT vmt_device
static msg_t acc_set_full_scale(ADXL355Driver *devp, adxl355_acc_fs_t fs)
Changes the ADXL355Driver accelerometer fullscale value.
#define objGetInstance(type, ip)
Returns the instance pointer starting from an interface pointer.
#define LIS3DSH_ACC_NUMBER_OF_AXES
LIS3DSH accelerometer subsystem characteristics.
static size_t acc_get_axes_number(void *ip)
Return the number of axes of the BaseAccelerometer.
#define LIS3DSH_AD_CTRL_REG5
#define LIS3DSH_ACC_SENS_8G
#define LIS3DSH_CTRL_REG4_ZEN
#define LIS3DSH_ACC_SENS_16G
static void lis3dshSPIWriteRegister(SPIDriver *spip, uint8_t reg, size_t n, uint8_t *b)
Writes a value into a generic register using SPI.
static msg_t acc_reset_sensivity(void *ip)
Reset sensitivity values for the BaseAccelerometer.
void lis3dshStart(LIS3DSHDriver *devp, const LIS3DSHConfig *config)
Configures and activates LIS3DSH Complex Driver peripheral.
static msg_t acc_set_bias(void *ip, float *bp)
Set bias values for the BaseAccelerometer.
#define LIS3DSH_AD_CTRL_REG6
#define LIS3DSH_ACC_SENS_4G
#define LIS3DSH_CTRL_REG6_ADD_INC
#define LIS3DSH_CTRL_REG4_XEN
static void lis3dshSPIReadRegister(SPIDriver *spip, uint8_t reg, size_t n, uint8_t *b)
Reads a generic register value using SPI.
#define LIS3DSH_ACC_SENS_2G
lis3dsh_acc_fs_t
LIS3DSH full scale.
static msg_t acc_reset_bias(void *ip)
Reset bias values for the BaseAccelerometer.
#define LIS3DSH_CTRL_REG5_FS_MASK
static msg_t acc_set_sensivity(void *ip, float *sp)
Set sensitivity values for the BaseAccelerometer.
static msg_t acc_read_cooked(void *ip, float axes[])
Retrieves cooked data from the BaseAccelerometer.
static msg_t acc_read_raw(void *ip, int32_t axes[])
Retrieves raw data from the BaseAccelerometer.
static msg_t acc_set_full_scale(LIS3DSHDriver *devp, lis3dsh_acc_fs_t fs)
Changes the LIS3DSHDriver accelerometer fullscale value.
#define LIS3DSH_AD_CTRL_REG4
void lis3dshStop(LIS3DSHDriver *devp)
Deactivates the LIS3DSH Complex Driver peripheral.
#define LIS3DSH_AD_OUT_X_L
#define LIS3DSH_CTRL_REG4_YEN
void lis3dshObjectInit(LIS3DSHDriver *devp)
Initializes an instance.
#define LIS3DSH_ACC_SENS_6G
#define osalDbgAssert(c, remark)
Condition assertion.
#define osalDbgCheck(c)
Function parameters check.
#define osalThreadSleepMilliseconds(msecs)
Delays the invoking thread for the specified number of milliseconds.
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.
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.
#define FALSE
Generic 'false' preprocessor boolean constant.
#define MSG_OK
Normal wakeup message.
#define MSG_RESET
Wakeup caused by a reset condition.
LIS3DSH MEMS interface module header.
Base accelerometer class.
const struct BaseAccelerometerVMT * vmt
Virtual Methods Table.
BaseAccelerometer virtual methods table.
LIS3DSH configuration structure.
LIS3DSH 3-axis accelerometer class.
const struct LIS3DSHVMT * vmt
Virtual Methods Table.
BaseAccelerometer acc_if
Base accelerometer interface.
LIS3DSH virtual methods table.