Rename battery.[ch] to battery_gauge.[ch]

This commit is contained in:
Alan Carvalho de Assis 2015-09-19 11:00:14 -06:00 committed by Gregory Nutt
parent 71d5cff0dd
commit 9f465fc502
5 changed files with 66 additions and 59 deletions

@ -1 +1 @@
Subproject commit dd690705a75a433318d8accaa1adfed84db47e30
Subproject commit 65514bae3f3be07684ea237ddf69ea4c79b2cd56

View File

@ -2,8 +2,8 @@
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
config BATTERY
bool "Battery support"
config BATTERY_GAUGE
bool "Battery Fuel Gauge support"
default n
config MAX1704X
@ -11,7 +11,7 @@ config MAX1704X
default n
select I2C
select I2C_MAX1704X
depends on BATTERY
depends on BATTERY_GAUGE
---help---
The MAX17040/MAX17041 are ultra-compact, low-cost, host-side fuel-gauge
systems for lithium-ion (Li+) batteries in handheld and portable equipment.

View File

@ -53,9 +53,9 @@ endif
# Add battery drivers
ifeq ($(CONFIG_BATTERY),y)
ifeq ($(CONFIG_BATTERY_GAUGE),y)
CSRCS += battery.c
CSRCS += battery_gauge.c
# Add I2C-based battery drivers

View File

@ -1,6 +1,6 @@
/****************************************************************************
* drivers/power/battery.c
* Upper-half, character driver for batteries.
* drivers/power/battery_gauge_gauge.c
* Upper-half, character driver for battery fuel gauge.
*
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
@ -46,7 +46,7 @@
#include <debug.h>
#include <nuttx/fs/fs.h>
#include <nuttx/power/battery.h>
#include <nuttx/power/battery_gauge.h>
/* This driver requires:
*
@ -69,11 +69,13 @@
/* Character driver methods */
static int bat_open(FAR struct file *filep);
static int bat_close(FAR struct file *filep);
static ssize_t bat_read(FAR struct file *, FAR char *, size_t nbytes);
static ssize_t bat_write(FAR struct file *filep, FAR const char *buffer, size_t buflen);
static int bat_ioctl(FAR struct file *filep,int cmd,unsigned long arg);
static int bat_gauge_open(FAR struct file *filep);
static int bat_gauge_close(FAR struct file *filep);
static ssize_t bat_gauge_read(FAR struct file *, FAR char *, size_t nbytes);
static ssize_t bat_gauge_write(FAR struct file *filep, FAR const char *buffer,
size_t buflen);
static int bat_gauge_ioctl(FAR struct file *filep, int cmd,
unsigned long arg);
/****************************************************************************
* Private Data
@ -81,12 +83,12 @@ static int bat_ioctl(FAR struct file *filep,int cmd,unsigned long arg);
static const struct file_operations g_batteryops =
{
bat_open,
bat_close,
bat_read,
bat_write,
bat_gauge_open,
bat_gauge_close,
bat_gauge_read,
bat_gauge_write,
0,
bat_ioctl
bat_gauge_ioctl
#ifndef CONFIG_DISABLE_POLL
, 0
#endif
@ -96,36 +98,37 @@ static const struct file_operations g_batteryops =
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: bat_open
* Name: bat_gauge_open
*
* Description:
* This function is called whenever the battery device is opened.
*
****************************************************************************/
static int bat_open(FAR struct file *filep)
static int bat_gauge_open(FAR struct file *filep)
{
return OK;
}
/****************************************************************************
* Name: bat_close
* Name: bat_gauge_close
*
* Description:
* This routine is called when the battery device is closed.
*
****************************************************************************/
static int bat_close(FAR struct file *filep)
static int bat_gauge_close(FAR struct file *filep)
{
return OK;
}
/****************************************************************************
* Name: bat_read
* Name: bat_gauge_read
****************************************************************************/
static ssize_t bat_read(FAR struct file *filep, FAR char *buffer, size_t buflen)
static ssize_t bat_gauge_read(FAR struct file *filep, FAR char *buffer,
size_t buflen)
{
/* Return nothing read */
@ -133,10 +136,10 @@ static ssize_t bat_read(FAR struct file *filep, FAR char *buffer, size_t buflen)
}
/****************************************************************************
* Name: bat_write
* Name: bat_gauge_write
****************************************************************************/
static ssize_t bat_write(FAR struct file *filep, FAR const char *buffer,
static ssize_t bat_gauge_write(FAR struct file *filep, FAR const char *buffer,
size_t buflen)
{
/* Return nothing written */
@ -145,13 +148,13 @@ static ssize_t bat_write(FAR struct file *filep, FAR const char *buffer,
}
/****************************************************************************
* Name: bat_ioctl
* Name: bat_gauge_ioctl
****************************************************************************/
static int bat_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
static int bat_gauge_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
{
FAR struct inode *inode = filep->f_inode;
FAR struct battery_dev_s *dev = inode->i_private;
FAR struct battery_gauge_dev_s *dev = inode->i_private;
int ret;
/* Inforce mutually exclusive access to the battery driver */
@ -222,7 +225,7 @@ static int bat_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
****************************************************************************/
/****************************************************************************
* Name: battery_register
* Name: battery_gauge_register
*
* Description:
* Register a lower half battery driver with the common, upper-half
@ -238,7 +241,8 @@ static int bat_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
*
****************************************************************************/
int battery_register(FAR const char *devpath, FAR struct battery_dev_s *dev)
int battery_gauge_register(FAR const char *devpath,
FAR struct battery_gauge_dev_s *dev)
{
int ret;

View File

@ -1,6 +1,6 @@
/****************************************************************************
* include/nuttx/power/battery.h
* NuttX Battery Interfaces
* include/nuttx/power/battery_gauge.h
* NuttX Battery Fuel Gauge Interfaces
*
* Copyright (C) 2012, 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
@ -34,8 +34,8 @@
*
****************************************************************************/
#ifndef __INCLUDE_NUTTX_POWER_BATTERY_H
#define __INCLUDE_NUTTX_POWER_BATTERY_H
#ifndef __INCLUDE_NUTTX_POWER_BATTERY_GAUGE_H
#define __INCLUDE_NUTTX_POWER_BATTERY_GAUGE_H
/****************************************************************************
* Included Files
@ -48,13 +48,13 @@
#include <semaphore.h>
#include <fixedmath.h>
#ifdef CONFIG_BATTERY
#ifdef CONFIG_BATTERY_GAUGE
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
/* CONFIG_BATTERY - Upper half battery driver support
/* CONFIG_BATTERY_GAUGE - Upper half battery fuel gauge driver support
*
* Specific, lower-half drivers will have other configuration requirements
* such as:
@ -64,15 +64,16 @@
*/
/* IOCTL Commands ***********************************************************/
/* The upper-half battery driver provides a character driver "wrapper"
* around the lower-half battery driver that does all of the real work.
/* The upper-half battery fuel gauge driver provides a character driver
* "wrapper" * around the lower-half battery driver that does all of the
* real work.
* Since there is no real data transfer to/or from a battery, all of the
* driver interaction is through IOCTIL commands. The IOCTL commands
* supported by the upper-half driver simply provide calls into the the
* lower half as summarized below:
*
* BATIOC_STATE - Return the current state of the battery (see
* enum battery_status_e).
* enum battery_gauge_status_e).
* Input value: A pointer to type int.
* BATIOC_ONLINE - Return 1 if the battery is online; 0 if offline.
* Input value: A pointer to type bool.
@ -95,7 +96,7 @@
****************************************************************************/
/* Battery status */
enum battery_status_e
enum battery_gauge_status_e
{
BATTERY_UNKNOWN = 0, /* Battery state is not known */
BATTERY_IDLE, /* Not full, not charging, not discharging */
@ -106,33 +107,33 @@ enum battery_status_e
/* This structure defines the lower half battery interface */
struct battery_dev_s;
struct battery_operations_s
struct battery_gauge_dev_s;
struct battery_gauge_operations_s
{
/* Return the current battery state (see enum battery_status_e) */
/* Return the current battery state (see enum battery_gauge_status_e) */
int (*state)(struct battery_dev_s *dev, int *status);
int (*state)(struct battery_gauge_dev_s *dev, int *status);
/* Return true if the batter is online */
int (*online)(struct battery_dev_s *dev, bool *status);
int (*online)(struct battery_gauge_dev_s *dev, bool *status);
/* Current battery voltage */
int (*voltage)(struct battery_dev_s *dev, b16_t *value);
int (*voltage)(struct battery_gauge_dev_s *dev, b16_t *value);
/* Battery capacity */
int (*capacity)(struct battery_dev_s *dev, b16_t *value);
int (*capacity)(struct battery_gauge_dev_s *dev, b16_t *value);
};
/* This structure defines the battery driver state structure */
struct battery_dev_s
struct battery_gauge_dev_s
{
/* Fields required by the upper-half driver */
FAR const struct battery_operations_s *ops; /* Battery operations */
FAR const struct battery_gauge_operations_s *ops; /* Battery operations */
sem_t batsem; /* Enforce mutually exclusive access */
/* Data fields specific to the lower-half driver may follow */
@ -156,7 +157,7 @@ extern "C"
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Name: battery_register
* Name: battery_gauge_register
*
* Description:
* Register a lower half battery driver with the common, upper-half
@ -172,18 +173,19 @@ extern "C"
*
****************************************************************************/
int battery_register(FAR const char *devpath, FAR struct battery_dev_s *dev);
int battery_gauge_register(FAR const char *devpath,
FAR struct battery_gauge_dev_s *dev);
/****************************************************************************
* Name: max1704x_initialize
*
* Description:
* Initialize the MAX1704x battery driver and return an instance of the
* lower_half interface that may be used with battery_register();
* lower_half interface that may be used with battery_gauge_register();
*
* This driver requires:
*
* CONFIG_BATTERY - Upper half battery driver support
* CONFIG_BATTERY_GAUGE - Upper half battery fuel gauge driver support
* CONFIG_I2C - I2C support
* CONFIG_I2C_MAX1704X - And the driver must be explictly selected.
* CONFIG_I2C_MAX17040 or CONFIG_I2C_MAX17041 - The driver must know which
@ -203,8 +205,9 @@ int battery_register(FAR const char *devpath, FAR struct battery_dev_s *dev);
#if defined(CONFIG_I2C) && defined(CONFIG_I2C_MAX1704X)
struct i2c_dev_s; /* Forward reference */
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);
#endif
#undef EXTERN
@ -213,5 +216,5 @@ FAR struct battery_dev_s *max1704x_initialize(FAR struct i2c_dev_s *i2c
#endif
#endif /* __ASSEMBLY__ */
#endif /* CONFIG_BATTERY */
#endif /* __INCLUDE_NUTTX_POWER_BATTERY_H */
#endif /* CONFIG_BATTERY_GAUGE */
#endif /* __INCLUDE_NUTTX_POWER_BATTERY_GAUGE_H */