Review and bring closer to nuttx coding style
This commit is contained in:
parent
81e8524588
commit
fada63014d
@ -74,6 +74,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* ad_private Types
|
* ad_private Types
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
struct up_dev_s
|
struct up_dev_s
|
||||||
{
|
{
|
||||||
int devno;
|
int devno;
|
||||||
@ -109,6 +110,7 @@ static const struct dac_ops_s g_dacops =
|
|||||||
};
|
};
|
||||||
|
|
||||||
static struct up_dev_s g_dacpriv;
|
static struct up_dev_s g_dacpriv;
|
||||||
|
|
||||||
static struct dac_dev_s g_dacdev =
|
static struct dac_dev_s g_dacdev =
|
||||||
{
|
{
|
||||||
.ad_ops = &g_dacops,
|
.ad_ops = &g_dacops,
|
||||||
@ -122,9 +124,9 @@ static struct dac_dev_s g_dacdev =
|
|||||||
/* Reset the DAC device. Called early to initialize the hardware. This
|
/* Reset the DAC device. Called early to initialize the hardware. This
|
||||||
* is called, before ao_setup() and on error conditions.
|
* is called, before ao_setup() and on error conditions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void dac_reset(FAR struct dac_dev_s *dev)
|
static void dac_reset(FAR struct dac_dev_s *dev)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Configure the DAC. This method is called the first time that the DAC
|
/* Configure the DAC. This method is called the first time that the DAC
|
||||||
@ -132,10 +134,12 @@ static void dac_reset(FAR struct dac_dev_s *dev)
|
|||||||
* This setup includes configuring and attaching DAC interrupts. Interrupts
|
* This setup includes configuring and attaching DAC interrupts. Interrupts
|
||||||
* are all disabled upon return.
|
* are all disabled upon return.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int dac_setup(FAR struct dac_dev_s *dev)
|
static int dac_setup(FAR struct dac_dev_s *dev)
|
||||||
{
|
{
|
||||||
FAR struct up_dev_s *priv = (FAR struct up_dev_s *)dev->ad_priv;
|
FAR struct up_dev_s *priv = (FAR struct up_dev_s *)dev->ad_priv;
|
||||||
FAR struct spi_dev_s *spi = priv->spi;
|
FAR struct spi_dev_s *spi = priv->spi;
|
||||||
|
|
||||||
SPI_SELECT(spi, priv->devno, true);
|
SPI_SELECT(spi, priv->devno, true);
|
||||||
SPI_SEND(spi,AD5410_REG_CMD);
|
SPI_SEND(spi,AD5410_REG_CMD);
|
||||||
SPI_SEND(spi,(AD5410_CMD_OUTEN|AD5410_CMD_420MA)>>8);
|
SPI_SEND(spi,(AD5410_CMD_OUTEN|AD5410_CMD_420MA)>>8);
|
||||||
@ -147,11 +151,13 @@ static int dac_setup(FAR struct dac_dev_s *dev)
|
|||||||
/* Disable the DAC. This method is called when the DAC device is closed.
|
/* Disable the DAC. This method is called when the DAC device is closed.
|
||||||
* This method reverses the operation the setup method.
|
* This method reverses the operation the setup method.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void dac_shutdown(FAR struct dac_dev_s *dev)
|
static void dac_shutdown(FAR struct dac_dev_s *dev)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Call to enable or disable TX interrupts */
|
/* Call to enable or disable TX interrupts */
|
||||||
|
|
||||||
static void dac_txint(FAR struct dac_dev_s *dev, bool enable)
|
static void dac_txint(FAR struct dac_dev_s *dev, bool enable)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -160,6 +166,7 @@ static int dac_send(FAR struct dac_dev_s *dev, FAR struct dac_msg_s *msg)
|
|||||||
{
|
{
|
||||||
FAR struct up_dev_s *priv = (FAR struct up_dev_s *)dev->ad_priv;
|
FAR struct up_dev_s *priv = (FAR struct up_dev_s *)dev->ad_priv;
|
||||||
FAR struct spi_dev_s *spi = priv->spi;
|
FAR struct spi_dev_s *spi = priv->spi;
|
||||||
|
|
||||||
SPI_SELECT(spi, priv->devno, true);
|
SPI_SELECT(spi, priv->devno, true);
|
||||||
SPI_SEND(spi,AD5410_REG_WR);
|
SPI_SEND(spi,AD5410_REG_WR);
|
||||||
SPI_SEND(spi,(uint8_t)(msg->am_data>>24));
|
SPI_SEND(spi,(uint8_t)(msg->am_data>>24));
|
||||||
@ -170,6 +177,7 @@ static int dac_send(FAR struct dac_dev_s *dev, FAR struct dac_msg_s *msg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* All ioctl calls will be routed through this method */
|
/* All ioctl calls will be routed through this method */
|
||||||
|
|
||||||
static int dac_ioctl(FAR struct dac_dev_s *dev, int cmd, unsigned long arg)
|
static int dac_ioctl(FAR struct dac_dev_s *dev, int cmd, unsigned long arg)
|
||||||
{
|
{
|
||||||
dbg("Fix me:Not Implemented\n");
|
dbg("Fix me:Not Implemented\n");
|
||||||
@ -187,19 +195,20 @@ static int dac_ioctl(FAR struct dac_dev_s *dev, int cmd, unsigned long arg)
|
|||||||
* Initialize the selected DAC port
|
* Initialize the selected DAC port
|
||||||
*
|
*
|
||||||
* Input Parameter:
|
* Input Parameter:
|
||||||
* Port number (for hardware that has mutiple DAC interfaces)
|
* Port number (for hardware that has multiple DAC interfaces)
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* Valid ad5410 device structure reference on succcess; a NULL on failure
|
* Valid ad5410 device structure reference on success; a NULL on failure
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
FAR struct dac_dev_s *up_ad5410initialize(FAR struct spi_dev_s *spi, unsigned int devno)
|
FAR struct dac_dev_s *up_ad5410initialize(FAR struct spi_dev_s *spi,
|
||||||
|
unsigned int devno)
|
||||||
{
|
{
|
||||||
FAR struct up_dev_s *priv = (FAR struct up_dev_s *)g_dacdev.ad_priv;
|
FAR struct up_dev_s *priv = (FAR struct up_dev_s *)g_dacdev.ad_priv;
|
||||||
|
|
||||||
priv->spi=spi;
|
priv->spi=spi;
|
||||||
priv->devno=devno;
|
priv->devno=devno;
|
||||||
return &g_dacdev;
|
return &g_dacdev;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -67,20 +67,20 @@
|
|||||||
#define ADS125X_PGA32 0x05
|
#define ADS125X_PGA32 0x05
|
||||||
#define ADS125X_PGA64 0x06
|
#define ADS125X_PGA64 0x06
|
||||||
|
|
||||||
#define ADS125X_RDATA 0x01 //Read Data
|
#define ADS125X_RDATA 0x01 /* Read Data */
|
||||||
#define ADS125X_RDATAC 0x03 //Read Data Continuously
|
#define ADS125X_RDATAC 0x03 /* Read Data Continuously */
|
||||||
#define ADS125X_SDATAC 0x0F //Stop Read Data Continuously
|
#define ADS125X_SDATAC 0x0F /* Stop Read Data Continuously */
|
||||||
#define ADS125X_RREG 0x10 //Read from REG
|
#define ADS125X_RREG 0x10 /* Read from REG */
|
||||||
#define ADS125X_WREG 0x50 //Write to REG
|
#define ADS125X_WREG 0x50 /* Write to REG */
|
||||||
#define ADS125X_SELFCAL 0xF0 //Offset and Gain Self-Calibration
|
#define ADS125X_SELFCAL 0xF0 /* Offset and Gain Self-Calibration */
|
||||||
#define ADS125X_SELFOCAL 0xF1 //Offset Self-Calibration
|
#define ADS125X_SELFOCAL 0xF1 /* Offset Self-Calibration */
|
||||||
#define ADS125X_SELFGCAL 0xF2 //Gain Self-Calibration
|
#define ADS125X_SELFGCAL 0xF2 /* Gain Self-Calibration */
|
||||||
#define ADS125X_SYSOCAL 0xF3 //System Offset Calibration
|
#define ADS125X_SYSOCAL 0xF3 /* System Offset Calibration */
|
||||||
#define ADS125X_SYSGCAL 0xF4 //System Gain Calibration
|
#define ADS125X_SYSGCAL 0xF4 /* System Gain Calibration */
|
||||||
#define ADS125X_SYNC 0xFC //Synchronize the A/D Conversion
|
#define ADS125X_SYNC 0xFC /* Synchronize the A/D Conversion */
|
||||||
#define ADS125X_STANDBY 0xFD //Begin Standby Mode
|
#define ADS125X_STANDBY 0xFD /* Begin Standby Mode */
|
||||||
#define ADS125X_RESET 0xFE //Reset to Power-Up Values
|
#define ADS125X_RESET 0xFE /* Reset to Power-Up Values */
|
||||||
#define ADS125X_WAKEUP 0xFF //Completes SYNC and Exits Standby Mode
|
#define ADS125X_WAKEUP 0xFF /* Completes SYNC and Exits Standby Mode */
|
||||||
|
|
||||||
#ifndef CONFIG_ADS1255_FREQUENCY
|
#ifndef CONFIG_ADS1255_FREQUENCY
|
||||||
# define CONFIG_ADS1255_FREQUENCY 1000000
|
# define CONFIG_ADS1255_FREQUENCY 1000000
|
||||||
@ -330,14 +330,15 @@ static int adc_interrupt(int irq, void *context)
|
|||||||
* Initialize the selected adc port
|
* Initialize the selected adc port
|
||||||
*
|
*
|
||||||
* Input Parameter:
|
* Input Parameter:
|
||||||
* Port number (for hardware that has mutiple adc interfaces)
|
* Port number (for hardware that has multiple adc interfaces)
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* Valid can device structure reference on succcess; a NULL on failure
|
* Valid can device structure reference on success; a NULL on failure
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
FAR struct adc_dev_s *up_ads1255initialize(FAR struct spi_dev_s *spi, unsigned int devno)
|
FAR struct adc_dev_s *up_ads1255initialize(FAR struct spi_dev_s *spi,
|
||||||
|
unsigned int devno)
|
||||||
{
|
{
|
||||||
FAR struct up_dev_s *priv = (FAR struct up_dev_s *)g_adcdev.ad_priv;
|
FAR struct up_dev_s *priv = (FAR struct up_dev_s *)g_adcdev.ad_priv;
|
||||||
|
|
||||||
@ -348,4 +349,3 @@ FAR struct adc_dev_s *up_ads1255initialize(FAR struct spi_dev_s *spi, unsigned i
|
|||||||
return &g_adcdev;
|
return &g_adcdev;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user