daniel-p-carvalho commented on code in PR #20970:
URL: https://github.com/apache/nuttx/pull/20970#discussion_r4367827102


##########
drivers/power/battery/ltc4013.c:
##########
@@ -0,0 +1,548 @@
+/****************************************************************************
+ * drivers/power/battery/ltc4013.c
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/* Lower half driver for the Analog Devices LTC4013 battery charger
+ * controller.  The chip is controlled through pins that the board
+ * provides and the charge voltage is set by the feedback network of the
+ * board, see include/nuttx/power/ltc4013.h.
+ */
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+
+#include <stdbool.h>
+#include <stdint.h>
+#include <errno.h>
+
+#include <nuttx/debug.h>
+#include <nuttx/kmalloc.h>
+#include <nuttx/power/battery_charger.h>
+#include <nuttx/power/battery_ioctl.h>
+#include <nuttx/power/ltc4013.h>
+
+#if defined(CONFIG_BATTERY_CHARGER) && defined(CONFIG_LTC4013)

Review Comment:
   Done, removed the check from the .c file (the build already gates the file 
on CONFIG_LTC4013).



##########
include/nuttx/power/ltc4013.h:
##########
@@ -0,0 +1,213 @@
+/****************************************************************************
+ * include/nuttx/power/ltc4013.h
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+#ifndef __INCLUDE_NUTTX_POWER_LTC4013_H
+#define __INCLUDE_NUTTX_POWER_LTC4013_H
+
+/* Lower half driver for the Analog Devices LTC4013 multi-chemistry battery
+ * charger controller, on top of the battery charger upper half
+ * (include/nuttx/power/battery_charger.h).
+ *
+ * The LTC4013 has no digital interface.  The board wires its pins as
+ * follows and provides the access to them through the callbacks of
+ * struct ltc4013_config_s:
+ *
+ *   ENAB          Enable (also usable as an input UVLO).
+ *   MODE1, MODE2  Three-state pins that select the charge algorithm
+ *                 (Table 1 of the datasheet): low, high or floating.
+ *   STAT0, STAT1  Open drain status outputs (Table 2 of the datasheet).
+ *   FB            Feedback of the battery voltage.  The divider from the
+ *                 battery to FB sets the charge voltage.
+ *
+ * The application chooses the charge profile: it selects the algorithm
+ * with BATIOC_OPERATE (LTC4013_OPRTN_ALGO) and the voltage with
+ * BATIOC_VOLTAGE.  The voltage is the one of the VFLOAT column of Table 1,
+ * the voltage of the last stage of the algorithm (for the Li-Ion
+ * algorithms it is the charge voltage).  The absorption and the
+ * equalization voltages follow from the same divider, in the proportions
+ * of the datasheet.  The charge current is set by the sense resistor of the
+ * board and the input current by its input stage, so BATIOC_CURRENT and
+ * BATIOC_INPUT_CURRENT are not supported.
+ *
+ * How the voltage is programmed depends on the board.  If the board
+ * provides the voltage callback, it programs its own feedback network (a
+ * digital potentiometer, a DAC, ...) for a battery voltage and the
+ * regulation voltage of the FB pin that the driver passes, and the voltage
+ * is set by software.  Without it the divider is fixed by the hardware:
+ * BATIOC_VOLTAGE is not supported, and if the board gives the two
+ * resistors of the divider (r_top from the battery to FB and r_bottom from
+ * FB to ground) BATIOC_GET_VOLTAGE reports the voltage that it programs
+ * with the selected algorithm.
+ *
+ * The driver drives ENAB low when it registers.  When the voltage is set by
+ * software the charger cannot be enabled until a voltage has been set.
+ * Changing the algorithm is refused while the charger is enabled, since
+ * the regulation voltage of the FB pin changes with it; the driver then
+ * programs the same battery voltage again, with the new regulation voltage.
+ */
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdbool.h>
+#include <stdint.h>
+
+#if defined(CONFIG_BATTERY_CHARGER) && defined(CONFIG_LTC4013)

Review Comment:
   Done, the header now uses `#ifdef CONFIG_LTC4013`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to