drivers/analog: fix nxstyle warnings
This commit is contained in:
parent
0b4ffa20a8
commit
b6fd522699
|
@ -39,6 +39,10 @@
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
@ -53,6 +57,10 @@
|
|||
#include <nuttx/analog/dac.h>
|
||||
#include <nuttx/spi/spi.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_DAC_AD5410)
|
||||
|
||||
#define AD5410_REG_NOP 0x00
|
||||
|
@ -72,7 +80,7 @@
|
|||
#define AD5410_CMD_024MA 0x07
|
||||
|
||||
/****************************************************************************
|
||||
* ad_private Types
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
struct up_dev_s
|
||||
|
@ -82,7 +90,7 @@ struct up_dev_s
|
|||
};
|
||||
|
||||
/****************************************************************************
|
||||
* ad_private Function Prototypes
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
static void dac_lock(FAR struct spi_dev_s *spi);
|
||||
|
@ -99,7 +107,7 @@ static int dac_ioctl(FAR struct dac_dev_s *dev, int cmd, unsigned long arg);
|
|||
static int dac_interrupt(int irq, void *context, FAR void *arg);
|
||||
|
||||
/****************************************************************************
|
||||
* ad_private Data
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
static const struct dac_ops_s g_dacops =
|
||||
|
@ -121,7 +129,7 @@ static struct dac_dev_s g_dacdev =
|
|||
};
|
||||
|
||||
/****************************************************************************
|
||||
* ad_private Functions
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -173,7 +181,7 @@ static void dac_reset(FAR struct dac_dev_s *dev)
|
|||
* Description:
|
||||
* Configure the DAC. This method is called the first time that the DAC
|
||||
* device is opened. This will occur when the port is first opened.
|
||||
* This setup includes configuring and attaching DAC interrupts. Interrupts
|
||||
* This setup includes configuring and attaching DAC interrupts. Interrupts
|
||||
* are all disabled upon return.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
|
|
@ -98,7 +98,8 @@ static void ads1242_set_negative_input(FAR struct ads1242_dev_s *dev,
|
|||
static bool ads1242_is_data_ready(FAR struct ads1242_dev_s *dev);
|
||||
|
||||
#if defined(CONFIG_DEBUG_FEATURES) && defined(CONFIG_DEBUG_INFO)
|
||||
static void ads1242_print_regs(FAR struct ads1242_dev_s *dev, char const *msg);
|
||||
static void ads1242_print_regs(FAR struct ads1242_dev_s *dev,
|
||||
char const *msg);
|
||||
#endif /* CONFIG_DEBUG_FEATURES && CONFIG_DEBUG_INFO */
|
||||
|
||||
/* Character driver methods */
|
||||
|
@ -183,7 +184,8 @@ static void ads1242_reset(FAR struct ads1242_dev_s *dev)
|
|||
* Name: ads1242_perform_selfgain_calibration
|
||||
****************************************************************************/
|
||||
|
||||
static void ads1242_perform_selfgain_calibration(FAR struct ads1242_dev_s *dev)
|
||||
static void ads1242_perform_selfgain_calibration(FAR struct ads1242_dev_s
|
||||
*dev)
|
||||
{
|
||||
ads1242_lock(dev->spi);
|
||||
|
||||
|
@ -198,7 +200,8 @@ static void ads1242_perform_selfgain_calibration(FAR struct ads1242_dev_s *dev)
|
|||
* Name: ads1242_perform_selfoffset_calibration
|
||||
****************************************************************************/
|
||||
|
||||
static void ads1242_perform_selfoffset_calibration(FAR struct ads1242_dev_s *dev)
|
||||
static void ads1242_perform_selfoffset_calibration(FAR struct ads1242_dev_s
|
||||
*dev)
|
||||
{
|
||||
ads1242_lock(dev->spi);
|
||||
|
||||
|
@ -270,7 +273,8 @@ static void ads1242_read_conversion_result(FAR struct ads1242_dev_s *dev,
|
|||
****************************************************************************/
|
||||
|
||||
static void ads1242_write_reg(FAR struct ads1242_dev_s *dev,
|
||||
uint8_t const reg_addr, uint8_t const reg_value)
|
||||
uint8_t const reg_addr,
|
||||
uint8_t const reg_value)
|
||||
{
|
||||
ads1242_lock(dev->spi);
|
||||
|
||||
|
@ -345,9 +349,8 @@ static void ads1242_set_gain(FAR struct ads1242_dev_s *dev,
|
|||
* Name: ads1242_set_positive_input
|
||||
****************************************************************************/
|
||||
|
||||
static void
|
||||
ads1242_set_positive_input(FAR struct ads1242_dev_s *dev,
|
||||
ADS1242_POSITIVE_INPUT_SELECTION const pos_in_sel)
|
||||
static void ads1242_set_positive_input(FAR struct ads1242_dev_s *dev,
|
||||
ADS1242_POSITIVE_INPUT_SELECTION const pos_in_sel)
|
||||
{
|
||||
uint8_t mux_reg_value = 0;
|
||||
|
||||
|
@ -366,9 +369,8 @@ static void
|
|||
* Name: ads1242_set_negative_input
|
||||
****************************************************************************/
|
||||
|
||||
static void
|
||||
ads1242_set_negative_input(FAR struct ads1242_dev_s *dev,
|
||||
ADS1242_NEGATIVE_INPUT_SELECTION const neg_in_sel)
|
||||
static void ads1242_set_negative_input(FAR struct ads1242_dev_s *dev,
|
||||
ADS1242_NEGATIVE_INPUT_SELECTION const neg_in_sel)
|
||||
{
|
||||
uint8_t mux_reg_value = 0;
|
||||
|
||||
|
@ -392,7 +394,7 @@ static bool ads1242_is_data_ready(FAR struct ads1242_dev_s *dev)
|
|||
uint8_t acr_reg_value = 0xff;
|
||||
|
||||
ads1242_read_reg(dev, ADS1242_REG_ACR, &acr_reg_value);
|
||||
return (acr_reg_value & ADS1242_REG_ACR_BIT_nDRDY) == 0;
|
||||
return (acr_reg_value & ADS1242_REG_ACR_BIT_NDRDY) == 0;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -400,7 +402,8 @@ static bool ads1242_is_data_ready(FAR struct ads1242_dev_s *dev)
|
|||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_DEBUG_FEATURES) && defined(CONFIG_DEBUG_INFO)
|
||||
static void ads1242_print_regs(FAR struct ads1242_dev_s *dev, char const *msg)
|
||||
static void ads1242_print_regs(FAR struct ads1242_dev_s *dev,
|
||||
char const *msg)
|
||||
{
|
||||
uint8_t setup_reg_value = 0;
|
||||
uint8_t mux_reg_value = 0;
|
||||
|
@ -576,9 +579,11 @@ static int ads1242_ioctl (FAR struct file *filep, int cmd, unsigned long arg)
|
|||
*
|
||||
* Input Parameters:
|
||||
* devpath - The full path to the driver to register. E.g., "/dev/ads1242"
|
||||
* spi - An instance of the SPI interface to use to communicate with ADS1242
|
||||
* osc_freq_hz - The frequency of the ADS1242 oscillator in Hz. Required for
|
||||
* calculating the minimum delay periods when accessing the device via SPI.
|
||||
* spi - An instance of the SPI interface to use to communicate with
|
||||
* ADS1242
|
||||
* osc_freq_hz - The frequency of the ADS1242 oscillator in Hz. Required
|
||||
* for calculating the minimum delay periods when accessing
|
||||
* the device via SPI.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
|
@ -597,7 +602,8 @@ int ads1242_register(FAR const char *devpath, FAR struct spi_dev_s *spi,
|
|||
|
||||
/* Initialize the ADS1242 device structure */
|
||||
|
||||
priv = (FAR struct ads1242_dev_s *)kmm_malloc(sizeof(struct ads1242_dev_s));
|
||||
priv =
|
||||
(FAR struct ads1242_dev_s *)kmm_malloc(sizeof(struct ads1242_dev_s));
|
||||
if (priv == NULL)
|
||||
{
|
||||
_err("ERROR: Failed to allocate instance\n");
|
||||
|
|
|
@ -250,8 +250,8 @@ static void adc_unlock(FAR struct spi_dev_s *spi)
|
|||
* Name: adc_bind
|
||||
*
|
||||
* Description:
|
||||
* Bind the upper-half driver callbacks to the lower-half implementation. This
|
||||
* must be called early in order to receive ADC event notifications.
|
||||
* Bind the upper-half driver callbacks to the lower-half implementation.
|
||||
* This must be called early in order to receive ADC event notifications.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
@ -286,7 +286,7 @@ static void adc_reset(FAR struct adc_dev_s *dev)
|
|||
nxsig_usleep(1000);
|
||||
|
||||
SPI_SELECT(spi, priv->devno, true);
|
||||
SPI_SEND(spi, ADS125X_WREG + 0x03); /* WRITE SPS REG */
|
||||
SPI_SEND(spi, ADS125X_WREG + 0x03); /* WRITE SPS REG */
|
||||
SPI_SEND(spi, 0x00); /* count=1 */
|
||||
SPI_SEND(spi, 0x63);
|
||||
SPI_SELECT(spi, priv->devno, false);
|
||||
|
@ -300,7 +300,7 @@ static void adc_reset(FAR struct adc_dev_s *dev)
|
|||
* Description:
|
||||
* Configure the ADC. This method is called the first time that the ADC
|
||||
* device is opened. This will occur when the port is first opened.
|
||||
* This setup includes configuring and attaching ADC interrupts. Interrupts
|
||||
* This setup includes configuring and attaching ADC interrupts. Interrupts
|
||||
* are all disabled upon return.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
@ -477,7 +477,8 @@ static void adc_worker(FAR void *arg)
|
|||
|
||||
static int adc_interrupt(int irq, void *context, FAR void *arg)
|
||||
{
|
||||
FAR struct ads1255_dev_s *priv = (FAR struct ads1255_dev_s *)g_adcdev.ad_priv;
|
||||
FAR struct ads1255_dev_s *priv =
|
||||
(FAR struct ads1255_dev_s *)g_adcdev.ad_priv;
|
||||
|
||||
DEBUGASSERT(priv != NULL);
|
||||
|
||||
|
@ -514,7 +515,8 @@ static int adc_interrupt(int irq, void *context, FAR void *arg)
|
|||
FAR struct adc_dev_s *up_ads1255initialize(FAR struct spi_dev_s *spi,
|
||||
unsigned int devno)
|
||||
{
|
||||
FAR struct ads1255_dev_s *priv = (FAR struct ads1255_dev_s *)g_adcdev.ad_priv;
|
||||
FAR struct ads1255_dev_s *priv =
|
||||
(FAR struct ads1255_dev_s *)g_adcdev.ad_priv;
|
||||
|
||||
DEBUGASSERT(spi != NULL);
|
||||
|
||||
|
|
|
@ -61,7 +61,8 @@ static int comp_open(FAR struct file *filep);
|
|||
static int comp_close(FAR struct file *filep);
|
||||
static ssize_t comp_read(FAR struct file *filep, FAR char *buffer,
|
||||
size_t buflen);
|
||||
static int comp_ioctl(FAR struct file *filep, int cmd, unsigned long arg);
|
||||
static int comp_ioctl(FAR struct file *filep, int cmd,
|
||||
unsigned long arg);
|
||||
static int comp_poll(FAR struct file *filep, FAR struct pollfd *fds,
|
||||
bool setup);
|
||||
static int comp_notify(FAR struct comp_dev_s *dev, uint8_t val);
|
||||
|
@ -255,8 +256,8 @@ static int comp_open(FAR struct file *filep)
|
|||
if (ret >= 0)
|
||||
{
|
||||
/* Increment the count of references to the device. If this the first
|
||||
* time that the driver has been opened for this device, then initialize
|
||||
* the device.
|
||||
* time that the driver has been opened for this device, then
|
||||
* initialize the device.
|
||||
*/
|
||||
|
||||
tmp = dev->ad_ocount + 1;
|
||||
|
@ -344,7 +345,8 @@ static int comp_close(FAR struct file *filep)
|
|||
* Name: comp_read
|
||||
****************************************************************************/
|
||||
|
||||
static ssize_t comp_read(FAR struct file *filep, FAR char *buffer, size_t buflen)
|
||||
static ssize_t comp_read(FAR struct file *filep, FAR char *buffer,
|
||||
size_t buflen)
|
||||
{
|
||||
FAR struct inode *inode = filep->f_inode;
|
||||
FAR struct comp_dev_s *dev = inode->i_private;
|
||||
|
|
|
@ -99,13 +99,13 @@ static const struct file_operations dac_fops =
|
|||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* Name: dac_open
|
||||
*
|
||||
* Description:
|
||||
* This function is called whenever the DAC device is opened.
|
||||
*
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
static int dac_open(FAR struct file *filep)
|
||||
{
|
||||
|
@ -120,8 +120,8 @@ static int dac_open(FAR struct file *filep)
|
|||
if (ret >= 0)
|
||||
{
|
||||
/* Increment the count of references to the device. If this the first
|
||||
* time that the driver has been opened for this device, then initialize
|
||||
* the device.
|
||||
* time that the driver has been opened for this device, then
|
||||
* initialize the device.
|
||||
*/
|
||||
|
||||
tmp = dev->ad_ocount + 1;
|
||||
|
@ -163,14 +163,14 @@ static int dac_open(FAR struct file *filep)
|
|||
return ret;
|
||||
}
|
||||
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* Name: dac_close
|
||||
*
|
||||
* Description:
|
||||
* This routine is called when the DAC device is closed.
|
||||
* It waits for the last remaining data to be sent.
|
||||
*
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
static int dac_close(FAR struct file *filep)
|
||||
{
|
||||
|
@ -206,7 +206,7 @@ static int dac_close(FAR struct file *filep)
|
|||
|
||||
/* Free the IRQ and disable the DAC device */
|
||||
|
||||
flags = enter_critical_section(); /* Disable interrupts */
|
||||
flags = enter_critical_section(); /* Disable interrupts */
|
||||
dev->ad_ops->ao_shutdown(dev); /* Disable the DAC */
|
||||
leave_critical_section(flags);
|
||||
|
||||
|
@ -221,12 +221,13 @@ static int dac_close(FAR struct file *filep)
|
|||
* Name: dac_read
|
||||
****************************************************************************/
|
||||
|
||||
static ssize_t dac_read(FAR struct file *filep, FAR char *buffer, size_t buflen)
|
||||
static ssize_t dac_read(FAR struct file *filep, FAR char *buffer,
|
||||
size_t buflen)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* Name: dac_xmit
|
||||
*
|
||||
* Description:
|
||||
|
@ -235,7 +236,7 @@ static ssize_t dac_read(FAR struct file *filep, FAR char *buffer, size_t buflen)
|
|||
* Assumptions:
|
||||
* Called with interrupts disabled
|
||||
*
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
static int dac_xmit(FAR struct dac_dev_s *dev)
|
||||
{
|
||||
|
@ -248,7 +249,8 @@ static int dac_xmit(FAR struct dac_dev_s *dev)
|
|||
{
|
||||
/* Send the next message at the head of the FIFO */
|
||||
|
||||
ret = dev->ad_ops->ao_send(dev, &dev->ad_xmit.af_buffer[dev->ad_xmit.af_head]);
|
||||
ret = dev->ad_ops->ao_send(dev,
|
||||
&dev->ad_xmit.af_buffer[dev->ad_xmit.af_head]);
|
||||
|
||||
/* Make sure the TX done interrupts are enabled */
|
||||
|
||||
|
@ -259,9 +261,9 @@ static int dac_xmit(FAR struct dac_dev_s *dev)
|
|||
return ret;
|
||||
}
|
||||
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* Name: dac_write
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
static ssize_t dac_write(FAR struct file *filep, FAR const char *buffer,
|
||||
size_t buflen)
|
||||
|
@ -281,8 +283,8 @@ static ssize_t dac_write(FAR struct file *filep, FAR const char *buffer,
|
|||
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Check if the TX FIFO was empty when we started. That is a clue that we have
|
||||
* to kick off a new TX sequence.
|
||||
/* Check if the TX FIFO was empty when we started. That is a clue that we
|
||||
* have to kick off a new TX sequence.
|
||||
*/
|
||||
|
||||
empty = (fifo->af_head == fifo->af_tail);
|
||||
|
@ -434,9 +436,9 @@ return_with_irqdisabled:
|
|||
return ret;
|
||||
}
|
||||
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* Name: dac_ioctl
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
static int dac_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
||||
{
|
||||
|
@ -452,16 +454,17 @@ static int dac_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
|||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* Name: dac_txdone
|
||||
*
|
||||
* Description:
|
||||
* Called from the DAC interrupt handler at the completion of a send operation.
|
||||
* Called from the DAC interrupt handler at the completion of a send
|
||||
* operation.
|
||||
*
|
||||
* Returned Value:
|
||||
* OK on success; a negated errno on failure.
|
||||
*
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
int dac_txdone(FAR struct dac_dev_s *dev)
|
||||
{
|
||||
|
|
|
@ -153,7 +153,7 @@ static void dac7554_reset(FAR struct dac_dev_s *dev)
|
|||
* Description:
|
||||
* Configure the DAC. This method is called the first time that the DAC
|
||||
* device is opened. This will occur when the port is first opened.
|
||||
* This setup includes configuring and attaching DAC interrupts. Interrupts
|
||||
* This setup includes configuring and attaching DAC interrupts. Interrupts
|
||||
* are all disabled upon return.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
@ -265,7 +265,8 @@ FAR struct dac_dev_s *dac7554_initialize(FAR struct spi_dev_s *spi,
|
|||
|
||||
/* Initialize the DAC7554 device structure */
|
||||
|
||||
priv = (FAR struct dac7554_dev_s *)kmm_malloc(sizeof(struct dac7554_dev_s));
|
||||
priv =
|
||||
(FAR struct dac7554_dev_s *)kmm_malloc(sizeof(struct dac7554_dev_s));
|
||||
priv->spi = spi;
|
||||
priv->spidev = spidev;
|
||||
|
||||
|
|
|
@ -155,7 +155,7 @@ static void dac7571_reset(FAR struct dac_dev_s *dev)
|
|||
* Description:
|
||||
* Configure the DAC. This method is called the first time that the DAC
|
||||
* device is opened. This will occur when the port is first opened.
|
||||
* This setup includes configuring and attaching DAC interrupts. Interrupts
|
||||
* This setup includes configuring and attaching DAC interrupts. Interrupts
|
||||
* are all disabled upon return.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
|
|
@ -152,15 +152,16 @@ static void adc_unlock(FAR struct spi_dev_s *spi)
|
|||
* Name: adc_bind
|
||||
*
|
||||
* Description:
|
||||
* Bind the upper-half driver callbacks to the lower-half implementation. This
|
||||
* must be called early in order to receive ADC event notifications.
|
||||
* Bind the upper-half driver callbacks to the lower-half implementation.
|
||||
* This must be called early in order to receive ADC event notifications.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int adc_bind(FAR struct adc_dev_s *dev,
|
||||
FAR const struct adc_callback_s *callback)
|
||||
{
|
||||
FAR struct ltc1867l_dev_s *priv = (FAR struct ltc1867l_dev_s *)dev->ad_priv;
|
||||
FAR struct ltc1867l_dev_s *priv =
|
||||
(FAR struct ltc1867l_dev_s *)dev->ad_priv;
|
||||
priv->cb = callback;
|
||||
return OK;
|
||||
}
|
||||
|
@ -184,7 +185,7 @@ static void adc_reset(FAR struct adc_dev_s *dev)
|
|||
* Description:
|
||||
* Configure the ADC. This method is called the first time that the ADC
|
||||
* device is opened. This will occur when the port is first opened.
|
||||
* This setup includes configuring and attaching ADC interrupts. Interrupts
|
||||
* This setup includes configuring and attaching ADC interrupts. Interrupts
|
||||
* are all disabled upon return.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
@ -229,7 +230,8 @@ static void adc_rxint(FAR struct adc_dev_s *dev, bool enable)
|
|||
|
||||
static int adc_ioctl(FAR struct adc_dev_s *dev, int cmd, unsigned long arg)
|
||||
{
|
||||
FAR struct ltc1867l_dev_s *priv = (FAR struct ltc1867l_dev_s *)dev->ad_priv;
|
||||
FAR struct ltc1867l_dev_s *priv =
|
||||
(FAR struct ltc1867l_dev_s *)dev->ad_priv;
|
||||
FAR struct spi_dev_s *spi = priv->spi;
|
||||
int i;
|
||||
uint16_t command;
|
||||
|
@ -335,7 +337,8 @@ int ltc1867l_register(FAR const char *devpath, FAR struct spi_dev_s *spi,
|
|||
|
||||
/* Initialize the LTC1867L device structure */
|
||||
|
||||
adcpriv = (FAR struct ltc1867l_dev_s *)kmm_malloc(sizeof(struct ltc1867l_dev_s));
|
||||
adcpriv =
|
||||
(FAR struct ltc1867l_dev_s *)kmm_malloc(sizeof(struct ltc1867l_dev_s));
|
||||
if (adcpriv == NULL)
|
||||
{
|
||||
aerr("ERROR: Failed to allocate ltc1867l_dev_s instance\n");
|
||||
|
|
|
@ -58,7 +58,8 @@
|
|||
|
||||
static int opamp_open(FAR struct file *filep);
|
||||
static int opamp_close(FAR struct file *filep);
|
||||
static int opamp_ioctl(FAR struct file *filep, int cmd, unsigned long arg);
|
||||
static int opamp_ioctl(FAR struct file *filep, int cmd,
|
||||
unsigned long arg);
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
|
@ -103,8 +104,8 @@ static int opamp_open(FAR struct file *filep)
|
|||
if (ret >= 0)
|
||||
{
|
||||
/* Increment the count of references to the device. If this the first
|
||||
* time that the driver has been opened for this device, then initialize
|
||||
* the device.
|
||||
* time that the driver has been opened for this device, then
|
||||
* initialize the device.
|
||||
*/
|
||||
|
||||
tmp = dev->ad_ocount + 1;
|
||||
|
|
|
@ -58,8 +58,9 @@
|
|||
|
||||
/* The PGA112/PGA113 have a three-wire SPI digital interface; the
|
||||
* PGA116/PGA117 have a four-wire SPI digital interface. The PGA116/117 also
|
||||
* have daisy-chain capability (The PGA112/PGA113 can be used as the last device
|
||||
* in a daisy-chain as shown if write-only communication is acceptable).
|
||||
* have daisy-chain capability (The PGA112/PGA113 can be used as the last
|
||||
* device in a daisy-chain as shown if write-only communication is
|
||||
* acceptable).
|
||||
*/
|
||||
|
||||
/* PGA11x commands (PGA112/PGA113) */
|
||||
|
@ -82,11 +83,11 @@
|
|||
/* Write command Gain Selection Bits (PGA112/PGA113)
|
||||
*
|
||||
* the PGA112 and PGA116 provide binary gain selections (1, 2, 4, 8, 16, 32,
|
||||
* 64, 128); the PGA113 and PGA117 provide scope gain selections (1, 2, 5, 10,
|
||||
* 20, 50, 100, 200).
|
||||
* 64, 128); the PGA113 and PGA117 provide scope gain selections (1, 2, 5,
|
||||
* 10, 20, 50, 100, 200).
|
||||
*/
|
||||
|
||||
#define PGA11X_GAIN_SHIFT (4) /* Bits 4-7: Gain Selection Bits */
|
||||
#define PGA11X_GAIN_SHIFT (4) /* Bits 4-7: Gain Selection Bits */
|
||||
#define PGA11X_GAIN_MASK (15 << PGA11X_GAIN_SHIFT)
|
||||
|
||||
/* Write command Mux Channel Selection Bits
|
||||
|
@ -95,10 +96,10 @@
|
|||
* 10-channel input MUX.
|
||||
*/
|
||||
|
||||
#define PGA11X_CHAN_SHIFT (0) /* Bits 0-3: Channel Selection Bits */
|
||||
#define PGA11X_CHAN_SHIFT (0) /* Bits 0-3: Channel Selection Bits */
|
||||
#define PGA11X_CHAN_MASK (15 << PGA11X_CHAN_SHIFT)
|
||||
|
||||
/* Other definitions ********************************************************/
|
||||
/* Other definitions */
|
||||
|
||||
#define SPI_DUMMY 0xff
|
||||
|
||||
|
@ -149,18 +150,19 @@ static void pga11x_lock(FAR struct spi_dev_s *spi)
|
|||
|
||||
/* On SPI busses where there are multiple devices, it will be necessary to
|
||||
* lock SPI to have exclusive access to the busses for a sequence of
|
||||
* transfers. The bus should be locked before the chip is selected.
|
||||
* transfers. The bus should be locked before the chip is selected.
|
||||
*
|
||||
* This is a blocking call and will not return until we have exclusiv access to
|
||||
* the SPI buss. We will retain that exclusive access until the bus is unlocked.
|
||||
* This is a blocking call and will not return until we have exclusive
|
||||
* access to the SPI bus. We will retain that exclusive access until the
|
||||
* bus is unlocked.
|
||||
*/
|
||||
|
||||
SPI_LOCK(spi, true);
|
||||
|
||||
/* After locking the SPI bus, the we also need call the setfrequency, setbits, and
|
||||
* setmode methods to make sure that the SPI is properly configured for the device.
|
||||
* If the SPI buss is being shared, then it may have been left in an incompatible
|
||||
* state.
|
||||
/* After locking the SPI bus, the we also need call the setfrequency,
|
||||
* setbits, and setmode methods to make sure that the SPI is properly
|
||||
* configured for the device. If the SPI buss is being shared, then it may
|
||||
* have been left in an incompatible state.
|
||||
*/
|
||||
|
||||
pga11x_configure(spi);
|
||||
|
@ -285,12 +287,13 @@ static void pga11x_write(FAR struct spi_dev_s *spi, uint16_t cmd)
|
|||
pga11x_unlock(spi);
|
||||
}
|
||||
#else
|
||||
static void pga11x_write(FAR struct spi_dev_s *spi, uint16_t u1cmd, uint16_t u2cmd)
|
||||
static void pga11x_write(FAR struct spi_dev_s *spi, uint16_t u1cmd,
|
||||
uint16_t u2cmd)
|
||||
{
|
||||
spiinfo("U1 cmd: %04x U2 cmd: %04x\n", u1cmd, u2cmd);
|
||||
|
||||
/* Lock, select, send the U2 16-bit command, the U1 16-bit command, de-select,
|
||||
* and un-lock.
|
||||
/* Lock, select, send the U2 16-bit command, the U1 16-bit command,
|
||||
* de-select, and un-lock.
|
||||
*/
|
||||
|
||||
pga11x_lock(spi);
|
||||
|
@ -379,8 +382,10 @@ int pga11x_select(PGA11X_HANDLE handle,
|
|||
uint16_t u2cmd;
|
||||
|
||||
DEBUGASSERT(handle && settings);
|
||||
spiinfo("U1 channel: %d gain: %d\n", settings->u1.channel, settings->u1.gain);
|
||||
spiinfo("U1 channel: %d gain: %d\n", settings->u1.channel, settings->u1.gain);
|
||||
spiinfo("U1 channel: %d gain: %d\n", settings->u1.channel,
|
||||
settings->u1.gain);
|
||||
spiinfo("U1 channel: %d gain: %d\n", settings->u1.channel,
|
||||
settings->u1.gain);
|
||||
|
||||
/* Format the commands */
|
||||
|
||||
|
@ -508,10 +513,14 @@ int pga11x_read(PGA11X_HANDLE handle, FAR struct pga11x_settings_s *settings)
|
|||
/* Decode the returned value */
|
||||
|
||||
spiinfo("Returning %04x %04x\n", u2value, u1value);
|
||||
settings->u1.channel = (uint8_t)((u1value & PGA11X_CHAN_MASK) >> PGA11X_CHAN_SHIFT);
|
||||
settings->u1.gain = (uint8_t)((u1value & PGA11X_GAIN_MASK) >> PGA11X_GAIN_SHIFT);
|
||||
settings->u2.channel = (uint8_t)((u2value & PGA11X_CHAN_MASK) >> PGA11X_CHAN_SHIFT);
|
||||
settings->u2.gain = (uint8_t)((u2value & PGA11X_GAIN_MASK) >> PGA11X_GAIN_SHIFT);
|
||||
settings->u1.channel =
|
||||
(uint8_t)((u1value & PGA11X_CHAN_MASK) >> PGA11X_CHAN_SHIFT);
|
||||
settings->u1.gain =
|
||||
(uint8_t)((u1value & PGA11X_GAIN_MASK) >> PGA11X_GAIN_SHIFT);
|
||||
settings->u2.channel =
|
||||
(uint8_t)((u2value & PGA11X_CHAN_MASK) >> PGA11X_CHAN_SHIFT);
|
||||
settings->u2.gain =
|
||||
(uint8_t)((u2value & PGA11X_GAIN_MASK) >> PGA11X_GAIN_SHIFT);
|
||||
return OK;
|
||||
#else
|
||||
FAR struct spi_dev_s *spi = (FAR struct spi_dev_s *)handle;
|
||||
|
@ -524,8 +533,8 @@ int pga11x_read(PGA11X_HANDLE handle, FAR struct pga11x_settings_s *settings)
|
|||
|
||||
pga11x_lock(spi);
|
||||
|
||||
/* Select, send the 16-bit PGA11X_CMD_READ command, and de-select. I do
|
||||
* not know if de-selection between word transfers is required. However,
|
||||
/* Select, send the 16-bit PGA11X_CMD_READ command, and de-select. I do
|
||||
* not know if de-selection between word transfers is required. However,
|
||||
* it is shown in the timing diagrams for the part.
|
||||
*/
|
||||
|
||||
|
@ -543,8 +552,10 @@ int pga11x_read(PGA11X_HANDLE handle, FAR struct pga11x_settings_s *settings)
|
|||
/* Decode the returned value */
|
||||
|
||||
spiinfo("Returning: %04x\n", value);
|
||||
settings->channel = (uint8_t)((value & PGA11X_CHAN_MASK) >> PGA11X_CHAN_SHIFT);
|
||||
settings->gain = (uint8_t)((value & PGA11X_GAIN_MASK) >> PGA11X_GAIN_SHIFT);
|
||||
settings->channel =
|
||||
(uint8_t)((value & PGA11X_CHAN_MASK) >> PGA11X_CHAN_SHIFT);
|
||||
settings->gain =
|
||||
(uint8_t)((value & PGA11X_GAIN_MASK) >> PGA11X_GAIN_SHIFT);
|
||||
return OK;
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@
|
|||
#define ADS1242_REG_MUX_BIT_NSEL1 (1 << 1)
|
||||
#define ADS1242_REG_MUX_BIT_NSEL0 (1 << 0)
|
||||
/* ACR */
|
||||
#define ADS1242_REG_ACR_BIT_nDRDY (1 << 7)
|
||||
#define ADS1242_REG_ACR_BIT_NDRDY (1 << 7)
|
||||
#define ADS1242_REG_ACR_BIT_UnB (1 << 6)
|
||||
#define ADS1242_REG_ACR_BIT_SPEED (1 << 5)
|
||||
#define ADS1242_REG_ACR_BIT_BUFEN (1 << 4)
|
||||
|
|
Loading…
Reference in New Issue