Fix IOCTL definition to avoid duplication and mess
This commit is contained in:
parent
3cd7558a5e
commit
895ad29b0d
@ -47,6 +47,7 @@
|
||||
|
||||
#include <nuttx/fs/fs.h>
|
||||
#include <nuttx/power/battery_charger.h>
|
||||
#include <nuttx/power/battery_ioctl.h>
|
||||
|
||||
/* This driver requires:
|
||||
*
|
||||
|
@ -47,6 +47,7 @@
|
||||
|
||||
#include <nuttx/fs/fs.h>
|
||||
#include <nuttx/power/battery_gauge.h>
|
||||
#include <nuttx/power/battery_ioctl.h>
|
||||
|
||||
/* This driver requires:
|
||||
*
|
||||
|
@ -1,6 +1,6 @@
|
||||
/****************************************************************************
|
||||
* drivers/power/max1704x.c
|
||||
* Lower half driver for MAX1704x battery charger
|
||||
* Lower half driver for MAX1704x battery fuel gauge
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
@ -55,11 +55,11 @@
|
||||
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/i2c.h>
|
||||
#include <nuttx/power/battery.h>
|
||||
#include <nuttx/power/battery_gauge.h>
|
||||
|
||||
/* This driver requires:
|
||||
*
|
||||
* CONFIG_BATTERY - Upper half battery driver support
|
||||
* CONFIG_BATTERY - Upper half battery gauge driver support
|
||||
* CONFIG_I2C - I2C support
|
||||
* CONFIG_I2C_MAX1704X - And the driver must be explictly selected.
|
||||
*/
|
||||
@ -177,8 +177,8 @@ struct max1704x_dev_s
|
||||
{
|
||||
/* The common part of the battery driver visible to the upper-half driver */
|
||||
|
||||
FAR const struct battery_operations_s *ops; /* Battery operations */
|
||||
sem_t batsem; /* Enforce mutually exclusive access */
|
||||
FAR const struct battery_gauge_operations_s *ops; /* Battery operations */
|
||||
sem_t batsem; /* Enforce mutually exclusive access */
|
||||
|
||||
/* Data fields specific to the lower half MAX1704x driver follow */
|
||||
|
||||
@ -208,16 +208,16 @@ static inline int max1704x_reset(FAR struct max1704x_dev_s *priv);
|
||||
|
||||
/* Battery driver lower half methods */
|
||||
|
||||
static int max1704x_state(struct battery_dev_s *dev, int *status);
|
||||
static int max1704x_online(struct battery_dev_s *dev, bool *status);
|
||||
static int max1704x_voltage(struct battery_dev_s *dev, b16_t *value);
|
||||
static int max1704x_capacity(struct battery_dev_s *dev, b16_t *value);
|
||||
static int max1704x_state(struct battery_gauge_dev_s *dev, int *status);
|
||||
static int max1704x_online(struct battery_gauge_dev_s *dev, bool *status);
|
||||
static int max1704x_voltage(struct battery_gauge_dev_s *dev, b16_t *value);
|
||||
static int max1704x_capacity(struct battery_gauge_dev_s *dev, b16_t *value);
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
static const struct battery_operations_s g_max1704xops =
|
||||
static const struct battery_gauge_operations_s g_max1704xops =
|
||||
{
|
||||
max1704x_state,
|
||||
max1704x_online,
|
||||
@ -410,7 +410,7 @@ static inline int max1704x_reset(FAR struct max1704x_dev_s *priv)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int max1704x_state(struct battery_dev_s *dev, int *status)
|
||||
static int max1704x_state(struct battery_gauge_dev_s *dev, int *status)
|
||||
{
|
||||
FAR struct max1704x_dev_s *priv = (FAR struct max1704x_dev_s *)dev;
|
||||
b16_t soc = 0;
|
||||
@ -454,7 +454,7 @@ static int max1704x_state(struct battery_dev_s *dev, int *status)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int max1704x_online(struct battery_dev_s *dev, bool *status)
|
||||
static int max1704x_online(struct battery_gauge_dev_s *dev, bool *status)
|
||||
{
|
||||
/* There is no concept of online/offline in this driver */
|
||||
|
||||
@ -470,7 +470,7 @@ static int max1704x_online(struct battery_dev_s *dev, bool *status)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int max1704x_voltage(struct battery_dev_s *dev, b16_t *value)
|
||||
static int max1704x_voltage(struct battery_gauge_dev_s *dev, b16_t *value)
|
||||
{
|
||||
FAR struct max1704x_dev_s *priv = (FAR struct max1704x_dev_s *)dev;
|
||||
return max1704x_getvcell(priv, value);
|
||||
@ -484,7 +484,7 @@ static int max1704x_voltage(struct battery_dev_s *dev, b16_t *value)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int max1704x_capacity(struct battery_dev_s *dev, b16_t *value)
|
||||
static int max1704x_capacity(struct battery_gauge_dev_s *dev, b16_t *value)
|
||||
{
|
||||
FAR struct max1704x_dev_s *priv = (FAR struct max1704x_dev_s *)dev;
|
||||
return max1704x_getsoc(priv, value);
|
||||
@ -520,8 +520,9 @@ static int max1704x_capacity(struct battery_dev_s *dev, b16_t *value)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
FAR struct battery_dev_s *max1704x_initialize(FAR struct i2c_dev_s *i2c,
|
||||
uint8_t addr, uint32_t frequency)
|
||||
FAR struct battery_gauge_dev_s *max1704x_initialize(FAR struct i2c_dev_s *i2c,
|
||||
uint8_t addr,
|
||||
uint32_t frequency)
|
||||
{
|
||||
FAR struct max1704x_dev_s *priv;
|
||||
#if 0
|
||||
@ -557,7 +558,7 @@ FAR struct battery_dev_s *max1704x_initialize(FAR struct i2c_dev_s *i2c,
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return (FAR struct battery_dev_s *)priv;
|
||||
return (FAR struct battery_gauge_dev_s *)priv;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BATTERY && CONFIG_I2C && CONFIG_I2C_MAX1704X */
|
||||
|
@ -83,12 +83,6 @@
|
||||
* Input value: An int defining the voltage value.
|
||||
*/
|
||||
|
||||
#define BATIOC_STATE _BATIOC(0x0001)
|
||||
#define BATIOC_HEALTH _BATIOC(0x0002)
|
||||
#define BATIOC_ONLINE _BATIOC(0x0003)
|
||||
#define BATIOC_VOLTAGE _BATIOC(0x0004)
|
||||
#define BATIOC_CURRENT _BATIOC(0x0005)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
@ -86,11 +86,6 @@
|
||||
* Input value: A pointer to type b16_t.
|
||||
*/
|
||||
|
||||
#define BATIOC_STATE _BATIOC(0x0001)
|
||||
#define BATIOC_ONLINE _BATIOC(0x0002)
|
||||
#define BATIOC_VOLTAGE _BATIOC(0x0003)
|
||||
#define BATIOC_CAPACITY _BATIOC(0x0004)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
58
include/nuttx/power/battery_ioctl.h
Normal file
58
include/nuttx/power/battery_ioctl.h
Normal file
@ -0,0 +1,58 @@
|
||||
/****************************************************************************
|
||||
* include/nuttx/power/battery_ioctl.h
|
||||
* NuttX Battery IOCTLs definition
|
||||
*
|
||||
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_NUTTX_POWER_BATTERY_IOCTL_H
|
||||
#define __INCLUDE_NUTTX_POWER_BATTERY_IOCTL_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <nuttx/fs/ioctl.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define BATIOC_STATE _BATIOC(0x0001)
|
||||
#define BATIOC_HEALTH _BATIOC(0x0002)
|
||||
#define BATIOC_ONLINE _BATIOC(0x0003)
|
||||
#define BATIOC_VOLTAGE _BATIOC(0x0004)
|
||||
#define BATIOC_CURRENT _BATIOC(0x0005)
|
||||
#define BATIOC_CAPACITY _BATIOC(0x0006)
|
||||
|
||||
#endif /* __INCLUDE_NUTTX_POWER_BATTERY_IOCTL_H */
|
Loading…
Reference in New Issue
Block a user