2015-02-12 19:18:43 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* drivers/sensors/mpl115a.c
|
|
|
|
*
|
2021-03-13 10:55:07 +01:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2015-02-12 19:18:43 +01:00
|
|
|
*
|
2021-03-13 10:55:07 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2015-02-12 19:18:43 +01:00
|
|
|
*
|
2021-03-13 10:55:07 +01:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2015-02-12 19:18:43 +01:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2021-03-13 10:55:07 +01:00
|
|
|
/* Character driver for the Freescale MPL115A1 Barometer Sensor */
|
|
|
|
|
2015-02-12 19:18:43 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <fixedmath.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <debug.h>
|
|
|
|
|
|
|
|
#include <nuttx/kmalloc.h>
|
2017-10-06 18:15:01 +02:00
|
|
|
#include <nuttx/signal.h>
|
|
|
|
#include <nuttx/random.h>
|
2015-02-12 19:18:43 +01:00
|
|
|
#include <nuttx/fs/fs.h>
|
|
|
|
#include <nuttx/spi/spi.h>
|
|
|
|
#include <nuttx/sensors/mpl115a.h>
|
|
|
|
|
2017-08-24 18:48:20 +02:00
|
|
|
#if defined(CONFIG_SPI) && defined(CONFIG_SENSORS_MPL115A)
|
2015-02-12 19:18:43 +01:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Pre-processor Definitions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Private
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
struct mpl115a_dev_s
|
|
|
|
{
|
|
|
|
FAR struct spi_dev_s *spi; /* SPI interface */
|
|
|
|
int16_t mpl115a_cal_a0;
|
|
|
|
int16_t mpl115a_cal_b1;
|
|
|
|
int16_t mpl115a_cal_b2;
|
|
|
|
int16_t mpl115a_cal_c12;
|
|
|
|
uint16_t mpl115a_temperature;
|
|
|
|
uint16_t mpl115a_pressure;
|
|
|
|
};
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Private Function Prototypes
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static inline void mpl115a_configspi(FAR struct spi_dev_s *spi);
|
2019-12-07 02:07:34 +01:00
|
|
|
static uint8_t mpl115a_getreg8(FAR struct mpl115a_dev_s *priv,
|
|
|
|
uint8_t regaddr);
|
2015-02-12 19:18:43 +01:00
|
|
|
static void mpl115a_updatecaldata(FAR struct mpl115a_dev_s *priv);
|
|
|
|
static void mpl115a_read_press_temp(FAR struct mpl115a_dev_s *priv);
|
|
|
|
static int mpl115a_getpressure(FAR struct mpl115a_dev_s *priv);
|
|
|
|
|
|
|
|
/* Character driver methods */
|
|
|
|
|
|
|
|
static int mpl115a_open(FAR struct file *filep);
|
|
|
|
static int mpl115a_close(FAR struct file *filep);
|
2015-10-10 18:41:00 +02:00
|
|
|
static ssize_t mpl115a_read(FAR struct file *filep, FAR char *buffer,
|
|
|
|
size_t buflen);
|
2019-12-07 02:07:34 +01:00
|
|
|
static ssize_t mpl115a_write(FAR struct file *filep, FAR const char *buffer,
|
|
|
|
size_t buflen);
|
2015-02-12 19:18:43 +01:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Private Data
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static const struct file_operations g_mpl115afops =
|
|
|
|
{
|
2015-02-12 19:21:05 +01:00
|
|
|
mpl115a_open, /* open */
|
|
|
|
mpl115a_close, /* close */
|
|
|
|
mpl115a_read, /* read */
|
|
|
|
mpl115a_write, /* write */
|
2019-05-22 02:57:54 +02:00
|
|
|
NULL, /* seek */
|
|
|
|
NULL, /* ioctl */
|
|
|
|
NULL, /* poll */
|
|
|
|
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
|
|
|
|
NULL /* unlink */
|
2015-02-12 19:18:43 +01:00
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Private Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static inline void mpl115a_configspi(FAR struct spi_dev_s *spi)
|
|
|
|
{
|
|
|
|
/* Configure SPI for the MPL115A */
|
|
|
|
|
|
|
|
SPI_SETMODE(spi, SPIDEV_MODE0);
|
|
|
|
SPI_SETBITS(spi, 8);
|
2020-01-02 17:49:34 +01:00
|
|
|
SPI_HWFEATURES(spi, 0);
|
|
|
|
SPI_SETFREQUENCY(spi, MPL115A_SPI_MAXFREQUENCY);
|
2015-02-12 19:18:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: mpl115a_getreg8
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Read from an 8-bit MPL115A register
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2021-03-13 11:55:37 +01:00
|
|
|
static uint8_t mpl115a_getreg8(FAR struct mpl115a_dev_s *priv,
|
|
|
|
uint8_t regaddr)
|
2015-02-12 19:18:43 +01:00
|
|
|
{
|
|
|
|
uint8_t regval;
|
|
|
|
|
|
|
|
/* If SPI bus is shared then lock and configure it */
|
|
|
|
|
2020-01-02 17:49:34 +01:00
|
|
|
SPI_LOCK(priv->spi, true);
|
2015-02-12 19:18:43 +01:00
|
|
|
mpl115a_configspi(priv->spi);
|
|
|
|
|
|
|
|
/* Select the MPL115A */
|
|
|
|
|
2017-04-29 20:26:52 +02:00
|
|
|
SPI_SELECT(priv->spi, SPIDEV_BAROMETER(0), true);
|
2015-02-12 19:18:43 +01:00
|
|
|
|
|
|
|
/* Send register to read and get the next byte */
|
|
|
|
|
2020-01-02 17:49:34 +01:00
|
|
|
SPI_SEND(priv->spi, regaddr);
|
2015-02-12 19:18:43 +01:00
|
|
|
SPI_RECVBLOCK(priv->spi, ®val, 1);
|
|
|
|
|
|
|
|
/* Deselect the MPL115A */
|
|
|
|
|
2017-04-29 20:26:52 +02:00
|
|
|
SPI_SELECT(priv->spi, SPIDEV_BAROMETER(0), false);
|
2015-02-12 19:18:43 +01:00
|
|
|
|
|
|
|
/* Unlock bus */
|
|
|
|
|
2020-01-02 17:49:34 +01:00
|
|
|
SPI_LOCK(priv->spi, false);
|
2015-02-12 19:18:43 +01:00
|
|
|
|
|
|
|
#ifdef CONFIG_MPL115A_REGDEBUG
|
2016-06-16 20:33:32 +02:00
|
|
|
_err("%02x->%02x\n", regaddr, regval);
|
2015-02-12 19:18:43 +01:00
|
|
|
#endif
|
|
|
|
return regval;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: mpl115a_updatecaldata
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Update Calibration Coefficient Data
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static void mpl115a_updatecaldata(FAR struct mpl115a_dev_s *priv)
|
|
|
|
{
|
|
|
|
/* Get a0 coefficient */
|
2015-02-12 19:21:05 +01:00
|
|
|
|
2019-12-07 02:07:34 +01:00
|
|
|
priv->mpl115a_cal_a0 =
|
|
|
|
mpl115a_getreg8(priv, MPL115A_BASE_CMD | (MPL115A_A0_MSB << 1)) << 8;
|
|
|
|
priv->mpl115a_cal_a0 |=
|
|
|
|
mpl115a_getreg8(priv, MPL115A_BASE_CMD | (MPL115A_A0_LSB << 1));
|
|
|
|
|
2016-06-12 02:05:29 +02:00
|
|
|
sninfo("a0 = %d\n", priv->mpl115a_cal_a0);
|
2015-02-12 19:18:43 +01:00
|
|
|
|
|
|
|
/* Get b1 coefficient */
|
2015-02-12 19:21:05 +01:00
|
|
|
|
2019-12-07 02:07:34 +01:00
|
|
|
priv->mpl115a_cal_b1 =
|
|
|
|
mpl115a_getreg8(priv, MPL115A_BASE_CMD | (MPL115A_B1_MSB << 1)) << 8;
|
|
|
|
priv->mpl115a_cal_b1 |=
|
|
|
|
mpl115a_getreg8(priv, MPL115A_BASE_CMD | (MPL115A_B1_LSB << 1));
|
|
|
|
|
2016-06-12 02:05:29 +02:00
|
|
|
sninfo("b1 = %d\n", priv->mpl115a_cal_b1);
|
2015-02-12 19:18:43 +01:00
|
|
|
|
|
|
|
/* Get b2 coefficient */
|
2015-02-12 19:21:05 +01:00
|
|
|
|
2019-12-07 02:07:34 +01:00
|
|
|
priv->mpl115a_cal_b2 =
|
|
|
|
mpl115a_getreg8(priv, MPL115A_BASE_CMD | (MPL115A_B2_MSB << 1)) << 8;
|
|
|
|
priv->mpl115a_cal_b2 |=
|
|
|
|
mpl115a_getreg8(priv, MPL115A_BASE_CMD | (MPL115A_B2_LSB << 1));
|
|
|
|
|
2016-06-12 02:05:29 +02:00
|
|
|
sninfo("b2 = %d\n", priv->mpl115a_cal_b2);
|
2015-02-12 19:18:43 +01:00
|
|
|
|
|
|
|
/* Get c12 coefficient */
|
2015-02-12 19:21:05 +01:00
|
|
|
|
2019-12-07 02:07:34 +01:00
|
|
|
priv->mpl115a_cal_c12 =
|
|
|
|
mpl115a_getreg8(priv, MPL115A_BASE_CMD | (MPL115A_C12_MSB << 1)) << 8;
|
|
|
|
priv->mpl115a_cal_c12 |=
|
|
|
|
mpl115a_getreg8(priv, MPL115A_BASE_CMD | (MPL115A_C12_LSB << 1));
|
|
|
|
|
2016-06-12 02:05:29 +02:00
|
|
|
sninfo("c12 = %d\n", priv->mpl115a_cal_c12);
|
2015-02-12 19:18:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: mpl115a_read_press_temp
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Read raw pressure and temperature from MPL115A and store it in the
|
|
|
|
* mpl115a_dev_s structure.
|
2015-02-12 19:21:05 +01:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2015-02-12 19:18:43 +01:00
|
|
|
static void mpl115a_read_press_temp(FAR struct mpl115a_dev_s *priv)
|
|
|
|
{
|
2015-02-12 19:21:05 +01:00
|
|
|
/* Start a new conversion */
|
|
|
|
|
2015-02-12 19:18:43 +01:00
|
|
|
mpl115a_getreg8(priv, (MPL115A_CONVERT << 1));
|
|
|
|
|
|
|
|
/* Delay 5ms */
|
2015-02-12 19:21:05 +01:00
|
|
|
|
2017-10-06 18:15:01 +02:00
|
|
|
nxsig_usleep(5000);
|
2015-02-12 19:18:43 +01:00
|
|
|
|
2019-12-07 02:07:34 +01:00
|
|
|
priv->mpl115a_pressure =
|
|
|
|
mpl115a_getreg8(priv, MPL115A_BASE_CMD | (MPL115A_PADC_MSB << 1)) << 8;
|
|
|
|
priv->mpl115a_pressure |=
|
|
|
|
mpl115a_getreg8(priv, MPL115A_BASE_CMD | (MPL115A_PADC_LSB << 1));
|
2015-02-12 19:18:43 +01:00
|
|
|
priv->mpl115a_pressure >>= 6; /* Padc is 10bit unsigned */
|
|
|
|
|
2016-06-12 02:05:29 +02:00
|
|
|
sninfo("Pressure = %d\n", priv->mpl115a_pressure);
|
2015-02-12 19:18:43 +01:00
|
|
|
|
2019-12-07 02:07:34 +01:00
|
|
|
priv->mpl115a_temperature =
|
|
|
|
mpl115a_getreg8(priv, MPL115A_BASE_CMD | (MPL115A_TADC_MSB << 1)) << 8;
|
|
|
|
priv->mpl115a_temperature |=
|
|
|
|
mpl115a_getreg8(priv, MPL115A_BASE_CMD | (MPL115A_TADC_LSB << 1));
|
2015-02-12 19:18:43 +01:00
|
|
|
priv->mpl115a_temperature >>= 6; /* Tadc is 10bit unsigned */
|
|
|
|
|
2016-06-12 02:05:29 +02:00
|
|
|
sninfo("Temperature = %d\n", priv->mpl115a_temperature);
|
2017-03-30 15:38:37 +02:00
|
|
|
|
|
|
|
/* Feed sensor data to entropy pool */
|
|
|
|
|
|
|
|
add_sensor_randomness((priv->mpl115a_pressure << 16) ^
|
|
|
|
priv->mpl115a_temperature);
|
2015-02-12 19:18:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: mpl115a_getpressure
|
|
|
|
*
|
|
|
|
* Description:
|
2015-02-12 19:21:05 +01:00
|
|
|
* Calculate the Barometric Pressure using the temperature compensated
|
|
|
|
* See Freescale AN3785 and MPL115A1 data sheet for details
|
2015-02-12 19:18:43 +01:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static int mpl115a_getpressure(FAR struct mpl115a_dev_s *priv)
|
|
|
|
{
|
2019-12-07 02:07:34 +01:00
|
|
|
int32_t c12x2;
|
|
|
|
int32_t a1;
|
|
|
|
int32_t a1x1;
|
|
|
|
int32_t y1;
|
|
|
|
int32_t a2x2;
|
|
|
|
int32_t pcomp;
|
|
|
|
uint16_t padc;
|
|
|
|
uint16_t tadc;
|
|
|
|
uint16_t pressure;
|
2015-02-12 19:18:43 +01:00
|
|
|
|
|
|
|
/* Check if coefficient data were read correctly */
|
2015-02-12 19:21:05 +01:00
|
|
|
|
2015-10-10 18:41:00 +02:00
|
|
|
if ((priv->mpl115a_cal_a0 == 0) || (priv->mpl115a_cal_b1 == 0) ||
|
|
|
|
(priv->mpl115a_cal_b2 == 0) || (priv->mpl115a_cal_c12 == 0))
|
2015-02-12 19:18:43 +01:00
|
|
|
{
|
|
|
|
mpl115a_updatecaldata(priv);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Read temperature and pressure */
|
2015-02-12 19:21:05 +01:00
|
|
|
|
2015-02-12 19:18:43 +01:00
|
|
|
mpl115a_read_press_temp(priv);
|
|
|
|
padc = priv->mpl115a_pressure;
|
|
|
|
tadc = priv->mpl115a_temperature;
|
|
|
|
|
|
|
|
/* These code are from Freescale AN3785 */
|
2015-02-12 19:21:05 +01:00
|
|
|
|
2015-02-12 19:18:43 +01:00
|
|
|
c12x2 = ((int32_t)priv->mpl115a_cal_c12 * tadc) >> 11;
|
|
|
|
a1 = (int32_t) (priv->mpl115a_cal_b1 + c12x2);
|
|
|
|
a1x1 = a1 * padc;
|
|
|
|
y1 = (((int32_t)priv->mpl115a_cal_a0) << 10) + a1x1;
|
|
|
|
a2x2 = (((int32_t)priv->mpl115a_cal_b2) * tadc) >> 1;
|
|
|
|
pcomp = (y1 + a2x2) >> 9;
|
|
|
|
|
|
|
|
/* Calculate the pressure in 1/16 kPa from compensated */
|
2015-02-12 19:21:05 +01:00
|
|
|
|
2015-02-12 19:18:43 +01:00
|
|
|
pressure = (((((int32_t)pcomp) * 1041) >> 14) + 800);
|
|
|
|
|
|
|
|
/* Note that the final pressure value is reported with 4 bit fractional
|
|
|
|
* This may be eliminated by right shifting the result 4 bits.
|
|
|
|
*/
|
2015-02-12 19:21:05 +01:00
|
|
|
|
2016-06-12 02:05:29 +02:00
|
|
|
sninfo("Final Pressure = %d\n", pressure >> 4);
|
2015-02-12 19:18:43 +01:00
|
|
|
return pressure;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: mpl115a_open
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* This function is called whenever the MPL115A1 device is opened.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static int mpl115a_open(FAR struct file *filep)
|
|
|
|
{
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: mpl115a_close
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* This routine is called when the LM-75 device is closed.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static int mpl115a_close(FAR struct file *filep)
|
|
|
|
{
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: mpl115a_read
|
|
|
|
****************************************************************************/
|
|
|
|
|
2021-03-13 11:55:37 +01:00
|
|
|
static ssize_t mpl115a_read(FAR struct file *filep,
|
|
|
|
FAR char *buffer, size_t buflen)
|
2015-02-12 19:18:43 +01:00
|
|
|
{
|
|
|
|
FAR struct inode *inode = filep->f_inode;
|
|
|
|
FAR struct mpl115a_dev_s *priv = inode->i_private;
|
|
|
|
FAR uint16_t *press = (FAR uint16_t *) buffer;
|
|
|
|
|
|
|
|
if (!buffer)
|
|
|
|
{
|
2016-06-12 02:05:29 +02:00
|
|
|
snerr("ERROR: Buffer is null\n");
|
2015-02-12 19:18:43 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2015-10-10 18:41:00 +02:00
|
|
|
if (buflen != 2)
|
2015-02-12 19:18:43 +01:00
|
|
|
{
|
2021-03-13 11:55:37 +01:00
|
|
|
snerr("ERROR:");
|
|
|
|
snerr(" You can't read something other than 16 bits (2 bytes)\n");
|
2015-02-12 19:18:43 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the pressure compensated */
|
2015-02-12 19:21:05 +01:00
|
|
|
|
2015-02-12 19:18:43 +01:00
|
|
|
*press = mpl115a_getpressure(priv);
|
|
|
|
|
|
|
|
/* Return size of uint16_t (2 bytes) */
|
2015-02-12 19:21:05 +01:00
|
|
|
|
2015-02-12 19:18:43 +01:00
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: mpl115a_write
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static ssize_t mpl115a_write(FAR struct file *filep, FAR const char *buffer,
|
|
|
|
size_t buflen)
|
|
|
|
{
|
|
|
|
return -ENOSYS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: mpl115a_register
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Register the MPL115A character device as 'devpath'
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* devpath - The full path to the driver to register. E.g., "/dev/temp0"
|
2015-02-12 19:21:05 +01:00
|
|
|
* i2c - An instance of the I2C interface to use to communicate with
|
|
|
|
* MPL115A
|
|
|
|
* addr - The I2C address of the LM-75. The base I2C address of the
|
|
|
|
* MPL115A is 0x48. Bits 0-3 can be controlled to get 8 unique
|
|
|
|
* addresses from 0x48 through 0x4f.
|
2015-02-12 19:18:43 +01:00
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* Zero (OK) on success; a negated errno value on failure.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
int mpl115a_register(FAR const char *devpath, FAR struct spi_dev_s *spi)
|
|
|
|
{
|
|
|
|
FAR struct mpl115a_dev_s *priv;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* Initialize the MPL115A device structure */
|
|
|
|
|
2021-03-13 11:55:37 +01:00
|
|
|
priv = (FAR struct mpl115a_dev_s *)
|
|
|
|
kmm_malloc(sizeof(struct mpl115a_dev_s));
|
2015-02-12 19:18:43 +01:00
|
|
|
if (!priv)
|
|
|
|
{
|
2016-06-12 02:05:29 +02:00
|
|
|
snerr("ERROR: Failed to allocate instance\n");
|
2015-02-12 19:18:43 +01:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
priv->spi = spi;
|
|
|
|
priv->mpl115a_cal_a0 = 0;
|
|
|
|
priv->mpl115a_cal_b1 = 0;
|
|
|
|
priv->mpl115a_cal_b2 = 0;
|
|
|
|
priv->mpl115a_cal_c12 = 0;
|
|
|
|
|
|
|
|
/* Read the coefficient value */
|
2015-02-12 19:21:05 +01:00
|
|
|
|
2015-02-12 19:18:43 +01:00
|
|
|
mpl115a_updatecaldata(priv);
|
|
|
|
|
|
|
|
/* Register the character driver */
|
|
|
|
|
|
|
|
ret = register_driver(devpath, &g_mpl115afops, 0666, priv);
|
|
|
|
if (ret < 0)
|
|
|
|
{
|
2016-06-12 02:05:29 +02:00
|
|
|
snerr("ERROR: Failed to register driver: %d\n", ret);
|
2015-02-12 19:18:43 +01:00
|
|
|
kmm_free(priv);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2017-08-24 18:48:20 +02:00
|
|
|
#endif /* CONFIG_SPI && CONFIG_SENSORS_MPL115A */
|