drivers/analog: fix nxstyle warnings

This commit is contained in:
Pelle Windestam 2020-03-10 13:25:22 +01:00 committed by patacongo
parent 0b4ffa20a8
commit b6fd522699
11 changed files with 128 additions and 91 deletions

View File

@ -39,6 +39,10 @@
* *
****************************************************************************/ ****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h> #include <nuttx/config.h>
#include <stdio.h> #include <stdio.h>
@ -53,6 +57,10 @@
#include <nuttx/analog/dac.h> #include <nuttx/analog/dac.h>
#include <nuttx/spi/spi.h> #include <nuttx/spi/spi.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#if defined(CONFIG_DAC_AD5410) #if defined(CONFIG_DAC_AD5410)
#define AD5410_REG_NOP 0x00 #define AD5410_REG_NOP 0x00
@ -72,7 +80,7 @@
#define AD5410_CMD_024MA 0x07 #define AD5410_CMD_024MA 0x07
/**************************************************************************** /****************************************************************************
* ad_private Types * Private Types
****************************************************************************/ ****************************************************************************/
struct up_dev_s 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); 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); static int dac_interrupt(int irq, void *context, FAR void *arg);
/**************************************************************************** /****************************************************************************
* ad_private Data * Private Data
****************************************************************************/ ****************************************************************************/
static const struct dac_ops_s g_dacops = static const struct dac_ops_s g_dacops =
@ -121,7 +129,7 @@ static struct dac_dev_s g_dacdev =
}; };
/**************************************************************************** /****************************************************************************
* ad_private Functions * Private Functions
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************

View File

@ -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); static bool ads1242_is_data_ready(FAR struct ads1242_dev_s *dev);
#if defined(CONFIG_DEBUG_FEATURES) && defined(CONFIG_DEBUG_INFO) #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 */ #endif /* CONFIG_DEBUG_FEATURES && CONFIG_DEBUG_INFO */
/* Character driver methods */ /* Character driver methods */
@ -183,7 +184,8 @@ static void ads1242_reset(FAR struct ads1242_dev_s *dev)
* Name: ads1242_perform_selfgain_calibration * 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); 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 * 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); 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, 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); ads1242_lock(dev->spi);
@ -345,8 +349,7 @@ static void ads1242_set_gain(FAR struct ads1242_dev_s *dev,
* Name: ads1242_set_positive_input * Name: ads1242_set_positive_input
****************************************************************************/ ****************************************************************************/
static void static void ads1242_set_positive_input(FAR struct ads1242_dev_s *dev,
ads1242_set_positive_input(FAR struct ads1242_dev_s *dev,
ADS1242_POSITIVE_INPUT_SELECTION const pos_in_sel) ADS1242_POSITIVE_INPUT_SELECTION const pos_in_sel)
{ {
uint8_t mux_reg_value = 0; uint8_t mux_reg_value = 0;
@ -366,8 +369,7 @@ static void
* Name: ads1242_set_negative_input * Name: ads1242_set_negative_input
****************************************************************************/ ****************************************************************************/
static void static void ads1242_set_negative_input(FAR struct ads1242_dev_s *dev,
ads1242_set_negative_input(FAR struct ads1242_dev_s *dev,
ADS1242_NEGATIVE_INPUT_SELECTION const neg_in_sel) ADS1242_NEGATIVE_INPUT_SELECTION const neg_in_sel)
{ {
uint8_t mux_reg_value = 0; 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; uint8_t acr_reg_value = 0xff;
ads1242_read_reg(dev, ADS1242_REG_ACR, &acr_reg_value); 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) #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 setup_reg_value = 0;
uint8_t mux_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: * Input Parameters:
* devpath - The full path to the driver to register. E.g., "/dev/ads1242" * 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 * spi - An instance of the SPI interface to use to communicate with
* osc_freq_hz - The frequency of the ADS1242 oscillator in Hz. Required for * ADS1242
* calculating the minimum delay periods when accessing the device via SPI. * 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: * Returned Value:
* Zero (OK) on success; a negated errno value on failure. * 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 */ /* 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) if (priv == NULL)
{ {
_err("ERROR: Failed to allocate instance\n"); _err("ERROR: Failed to allocate instance\n");

View File

@ -250,8 +250,8 @@ static void adc_unlock(FAR struct spi_dev_s *spi)
* Name: adc_bind * Name: adc_bind
* *
* Description: * Description:
* Bind the upper-half driver callbacks to the lower-half implementation. This * Bind the upper-half driver callbacks to the lower-half implementation.
* must be called early in order to receive ADC event notifications. * This must be called early in order to receive ADC event notifications.
* *
****************************************************************************/ ****************************************************************************/
@ -477,7 +477,8 @@ static void adc_worker(FAR void *arg)
static int adc_interrupt(int irq, void *context, 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); 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, FAR struct adc_dev_s *up_ads1255initialize(FAR struct spi_dev_s *spi,
unsigned int devno) 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); DEBUGASSERT(spi != NULL);

View File

@ -61,7 +61,8 @@ static int comp_open(FAR struct file *filep);
static int comp_close(FAR struct file *filep); static int comp_close(FAR struct file *filep);
static ssize_t comp_read(FAR struct file *filep, FAR char *buffer, static ssize_t comp_read(FAR struct file *filep, FAR char *buffer,
size_t buflen); 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, static int comp_poll(FAR struct file *filep, FAR struct pollfd *fds,
bool setup); bool setup);
static int comp_notify(FAR struct comp_dev_s *dev, uint8_t val); 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) if (ret >= 0)
{ {
/* Increment the count of references to the device. If this the first /* Increment the count of references to the device. If this the first
* time that the driver has been opened for this device, then initialize * time that the driver has been opened for this device, then
* the device. * initialize the device.
*/ */
tmp = dev->ad_ocount + 1; tmp = dev->ad_ocount + 1;
@ -344,7 +345,8 @@ static int comp_close(FAR struct file *filep)
* Name: comp_read * 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 inode *inode = filep->f_inode;
FAR struct comp_dev_s *dev = inode->i_private; FAR struct comp_dev_s *dev = inode->i_private;

View File

@ -99,13 +99,13 @@ static const struct file_operations dac_fops =
* Private Functions * Private Functions
****************************************************************************/ ****************************************************************************/
/************************************************************************************ /****************************************************************************
* Name: dac_open * Name: dac_open
* *
* Description: * Description:
* This function is called whenever the DAC device is opened. * This function is called whenever the DAC device is opened.
* *
************************************************************************************/ ****************************************************************************/
static int dac_open(FAR struct file *filep) static int dac_open(FAR struct file *filep)
{ {
@ -120,8 +120,8 @@ static int dac_open(FAR struct file *filep)
if (ret >= 0) if (ret >= 0)
{ {
/* Increment the count of references to the device. If this the first /* Increment the count of references to the device. If this the first
* time that the driver has been opened for this device, then initialize * time that the driver has been opened for this device, then
* the device. * initialize the device.
*/ */
tmp = dev->ad_ocount + 1; tmp = dev->ad_ocount + 1;
@ -163,14 +163,14 @@ static int dac_open(FAR struct file *filep)
return ret; return ret;
} }
/************************************************************************************ /****************************************************************************
* Name: dac_close * Name: dac_close
* *
* Description: * Description:
* This routine is called when the DAC device is closed. * This routine is called when the DAC device is closed.
* It waits for the last remaining data to be sent. * It waits for the last remaining data to be sent.
* *
************************************************************************************/ ****************************************************************************/
static int dac_close(FAR struct file *filep) static int dac_close(FAR struct file *filep)
{ {
@ -221,12 +221,13 @@ static int dac_close(FAR struct file *filep)
* Name: dac_read * 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; return 0;
} }
/************************************************************************************ /****************************************************************************
* Name: dac_xmit * Name: dac_xmit
* *
* Description: * Description:
@ -235,7 +236,7 @@ static ssize_t dac_read(FAR struct file *filep, FAR char *buffer, size_t buflen)
* Assumptions: * Assumptions:
* Called with interrupts disabled * Called with interrupts disabled
* *
************************************************************************************/ ****************************************************************************/
static int dac_xmit(FAR struct dac_dev_s *dev) 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 */ /* 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 */ /* Make sure the TX done interrupts are enabled */
@ -259,9 +261,9 @@ static int dac_xmit(FAR struct dac_dev_s *dev)
return ret; return ret;
} }
/************************************************************************************ /****************************************************************************
* Name: dac_write * Name: dac_write
************************************************************************************/ ****************************************************************************/
static ssize_t dac_write(FAR struct file *filep, FAR const char *buffer, static ssize_t dac_write(FAR struct file *filep, FAR const char *buffer,
size_t buflen) size_t buflen)
@ -281,8 +283,8 @@ static ssize_t dac_write(FAR struct file *filep, FAR const char *buffer,
flags = enter_critical_section(); flags = enter_critical_section();
/* Check if the TX FIFO was empty when we started. That is a clue that we have /* Check if the TX FIFO was empty when we started. That is a clue that we
* to kick off a new TX sequence. * have to kick off a new TX sequence.
*/ */
empty = (fifo->af_head == fifo->af_tail); empty = (fifo->af_head == fifo->af_tail);
@ -434,9 +436,9 @@ return_with_irqdisabled:
return ret; return ret;
} }
/************************************************************************************ /****************************************************************************
* Name: dac_ioctl * Name: dac_ioctl
************************************************************************************/ ****************************************************************************/
static int dac_ioctl(FAR struct file *filep, int cmd, unsigned long arg) 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 * Public Functions
****************************************************************************/ ****************************************************************************/
/************************************************************************************ /****************************************************************************
* Name: dac_txdone * Name: dac_txdone
* *
* Description: * 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: * Returned Value:
* OK on success; a negated errno on failure. * OK on success; a negated errno on failure.
* *
************************************************************************************/ ****************************************************************************/
int dac_txdone(FAR struct dac_dev_s *dev) int dac_txdone(FAR struct dac_dev_s *dev)
{ {

View File

@ -265,7 +265,8 @@ FAR struct dac_dev_s *dac7554_initialize(FAR struct spi_dev_s *spi,
/* Initialize the DAC7554 device structure */ /* 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->spi = spi;
priv->spidev = spidev; priv->spidev = spidev;

View File

@ -152,15 +152,16 @@ static void adc_unlock(FAR struct spi_dev_s *spi)
* Name: adc_bind * Name: adc_bind
* *
* Description: * Description:
* Bind the upper-half driver callbacks to the lower-half implementation. This * Bind the upper-half driver callbacks to the lower-half implementation.
* must be called early in order to receive ADC event notifications. * This must be called early in order to receive ADC event notifications.
* *
****************************************************************************/ ****************************************************************************/
static int adc_bind(FAR struct adc_dev_s *dev, static int adc_bind(FAR struct adc_dev_s *dev,
FAR const struct adc_callback_s *callback) 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; priv->cb = callback;
return OK; return OK;
} }
@ -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) 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; FAR struct spi_dev_s *spi = priv->spi;
int i; int i;
uint16_t command; 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 */ /* 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) if (adcpriv == NULL)
{ {
aerr("ERROR: Failed to allocate ltc1867l_dev_s instance\n"); aerr("ERROR: Failed to allocate ltc1867l_dev_s instance\n");

View File

@ -58,7 +58,8 @@
static int opamp_open(FAR struct file *filep); static int opamp_open(FAR struct file *filep);
static int opamp_close(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 * Private Data
@ -103,8 +104,8 @@ static int opamp_open(FAR struct file *filep)
if (ret >= 0) if (ret >= 0)
{ {
/* Increment the count of references to the device. If this the first /* Increment the count of references to the device. If this the first
* time that the driver has been opened for this device, then initialize * time that the driver has been opened for this device, then
* the device. * initialize the device.
*/ */
tmp = dev->ad_ocount + 1; tmp = dev->ad_ocount + 1;

View File

@ -58,8 +58,9 @@
/* The PGA112/PGA113 have a three-wire SPI digital interface; the /* The PGA112/PGA113 have a three-wire SPI digital interface; the
* PGA116/PGA117 have a four-wire SPI digital interface. The PGA116/117 also * 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 * have daisy-chain capability (The PGA112/PGA113 can be used as the last
* in a daisy-chain as shown if write-only communication is acceptable). * device in a daisy-chain as shown if write-only communication is
* acceptable).
*/ */
/* PGA11x commands (PGA112/PGA113) */ /* PGA11x commands (PGA112/PGA113) */
@ -82,8 +83,8 @@
/* Write command Gain Selection Bits (PGA112/PGA113) /* Write command Gain Selection Bits (PGA112/PGA113)
* *
* the PGA112 and PGA116 provide binary gain selections (1, 2, 4, 8, 16, 32, * 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, * 64, 128); the PGA113 and PGA117 provide scope gain selections (1, 2, 5,
* 20, 50, 100, 200). * 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 */
@ -98,7 +99,7 @@
#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) #define PGA11X_CHAN_MASK (15 << PGA11X_CHAN_SHIFT)
/* Other definitions ********************************************************/ /* Other definitions */
#define SPI_DUMMY 0xff #define SPI_DUMMY 0xff
@ -151,16 +152,17 @@ static void pga11x_lock(FAR struct spi_dev_s *spi)
* lock SPI to have exclusive access to the busses for a sequence of * 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 * This is a blocking call and will not return until we have exclusive
* the SPI buss. We will retain that exclusive access until the bus is unlocked. * access to the SPI bus. We will retain that exclusive access until the
* bus is unlocked.
*/ */
SPI_LOCK(spi, true); SPI_LOCK(spi, true);
/* After locking the SPI bus, the we also need call the setfrequency, setbits, and /* After locking the SPI bus, the we also need call the setfrequency,
* setmode methods to make sure that the SPI is properly configured for the device. * setbits, and setmode methods to make sure that the SPI is properly
* If the SPI buss is being shared, then it may have been left in an incompatible * configured for the device. If the SPI buss is being shared, then it may
* state. * have been left in an incompatible state.
*/ */
pga11x_configure(spi); pga11x_configure(spi);
@ -285,12 +287,13 @@ static void pga11x_write(FAR struct spi_dev_s *spi, uint16_t cmd)
pga11x_unlock(spi); pga11x_unlock(spi);
} }
#else #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); 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, /* Lock, select, send the U2 16-bit command, the U1 16-bit command,
* and un-lock. * de-select, and un-lock.
*/ */
pga11x_lock(spi); pga11x_lock(spi);
@ -379,8 +382,10 @@ int pga11x_select(PGA11X_HANDLE handle,
uint16_t u2cmd; uint16_t u2cmd;
DEBUGASSERT(handle && settings); 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,
spiinfo("U1 channel: %d gain: %d\n", settings->u1.channel, settings->u1.gain); settings->u1.gain);
spiinfo("U1 channel: %d gain: %d\n", settings->u1.channel,
settings->u1.gain);
/* Format the commands */ /* Format the commands */
@ -508,10 +513,14 @@ int pga11x_read(PGA11X_HANDLE handle, FAR struct pga11x_settings_s *settings)
/* Decode the returned value */ /* Decode the returned value */
spiinfo("Returning %04x %04x\n", u2value, u1value); spiinfo("Returning %04x %04x\n", u2value, u1value);
settings->u1.channel = (uint8_t)((u1value & PGA11X_CHAN_MASK) >> PGA11X_CHAN_SHIFT); settings->u1.channel =
settings->u1.gain = (uint8_t)((u1value & PGA11X_GAIN_MASK) >> PGA11X_GAIN_SHIFT); (uint8_t)((u1value & PGA11X_CHAN_MASK) >> PGA11X_CHAN_SHIFT);
settings->u2.channel = (uint8_t)((u2value & PGA11X_CHAN_MASK) >> PGA11X_CHAN_SHIFT); settings->u1.gain =
settings->u2.gain = (uint8_t)((u2value & PGA11X_GAIN_MASK) >> PGA11X_GAIN_SHIFT); (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; return OK;
#else #else
FAR struct spi_dev_s *spi = (FAR struct spi_dev_s *)handle; FAR struct spi_dev_s *spi = (FAR struct spi_dev_s *)handle;
@ -543,8 +552,10 @@ int pga11x_read(PGA11X_HANDLE handle, FAR struct pga11x_settings_s *settings)
/* Decode the returned value */ /* Decode the returned value */
spiinfo("Returning: %04x\n", value); spiinfo("Returning: %04x\n", value);
settings->channel = (uint8_t)((value & PGA11X_CHAN_MASK) >> PGA11X_CHAN_SHIFT); settings->channel =
settings->gain = (uint8_t)((value & PGA11X_GAIN_MASK) >> PGA11X_GAIN_SHIFT); (uint8_t)((value & PGA11X_CHAN_MASK) >> PGA11X_CHAN_SHIFT);
settings->gain =
(uint8_t)((value & PGA11X_GAIN_MASK) >> PGA11X_GAIN_SHIFT);
return OK; return OK;
#endif #endif
} }

View File

@ -93,7 +93,7 @@
#define ADS1242_REG_MUX_BIT_NSEL1 (1 << 1) #define ADS1242_REG_MUX_BIT_NSEL1 (1 << 1)
#define ADS1242_REG_MUX_BIT_NSEL0 (1 << 0) #define ADS1242_REG_MUX_BIT_NSEL0 (1 << 0)
/* ACR */ /* 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_UnB (1 << 6)
#define ADS1242_REG_ACR_BIT_SPEED (1 << 5) #define ADS1242_REG_ACR_BIT_SPEED (1 << 5)
#define ADS1242_REG_ACR_BIT_BUFEN (1 << 4) #define ADS1242_REG_ACR_BIT_BUFEN (1 << 4)