acassis commented on a change in pull request #1618:
URL: https://github.com/apache/incubator-nuttx/pull/1618#discussion_r474335764
##########
File path: boards/arm/samd5e5/metro-m4/src/metro-m4.h
##########
@@ -71,6 +71,46 @@
#define PORT_RED_LED (PORT_OUTPUT | PORT_PULL_NONE | PORT_OUTPUT_SET | \
PORTA | PORT_PIN16)
+#define PORT_D8 (PORT_OUTPUT | PORT_PULL_NONE | PORT_OUTPUT_SET |
PORTA | PORT_PIN21)
Review comment:
Please, try to align this line
##########
File path: boards/arm/samd5e5/metro-m4/src/sam_gpio.c
##########
@@ -0,0 +1,341 @@
+/****************************************************************************
+ * boards/arm/samd5e5/metro-m4/src/sam_gpio.c
+ *
+ * Copyright 2020 Falker Automacao Agricola LTDA.
+ * Author: Leomar Mateus Radke <[email protected]>
Review comment:
Ditto
##########
File path: boards/arm/samd5e5/metro-m4/src/sam_bq27426.c
##########
@@ -0,0 +1,78 @@
+/****************************************************************************
+ * boards/arm/samd5e5/metro-m4/src/sam_bq27426.c
+ *
+ * Copyright 2020 Falker Automacao Agricola LTDA.
Review comment:
We cannot use our Copyright with Apache Foundation (too bad... I also
liked the BSD way)
##########
File path: boards/arm/samd5e5/metro-m4/src/sam_bringup.c
##########
@@ -137,12 +142,47 @@ int sam_bringup(void)
}
#endif
+#ifdef CONFIG_FS_SMARTFS
+ /* Initialize Smart File System (SMARTFS) */
+
+ ret = sam_smartfs_initialize();
+ if (ret < 0)
+ {
+ syslog(LOG_ERR, "ERROR: Failed to mount smartfs %d\n", ret);
+ return ret;
+ }
+
+ /* Mount the file system at /mnt/nvm */
+
+ ret = mount("/dev/smart0", "/mnt/nvm", "smartfs", 0, NULL);
+ if (ret < 0)
+ {
+ syslog(LOG_ERR, "ERROR: Failed to mount the SmartFS volume: %d\n",
+ ret);
+ return ret;
+ }
+#endif
+
#ifdef CONFIG_FS_AUTOMOUNTER
/* Initialize the auto-mounter */
sam_automount_initialize();
#endif
+#ifdef CONFIG_BQ27426
+ /* Configure and initialize the BQ2426 distance sensor */
+
+ ret = sam_bq27426_initialize("/dev/batt1");
Review comment:
"Starting From Zero Got Nothing to Lose" ;-)
##########
File path: boards/arm/samd5e5/metro-m4/src/sam_smartfs.c
##########
@@ -0,0 +1,238 @@
+/****************************************************************************
+ * boards/arm/samd5e5/metro-m4/src/sam_smartfs.c
+ *
+ * Copyright 2020 Falker Automacao Agricola LTDA.
Review comment:
Ditto
##########
File path: include/nuttx/power/bq27426.h
##########
@@ -0,0 +1,227 @@
+/****************************************************************************
+ * include/nuttx/power/bq27426.h
+ * Lower half driver for bq27426 battery fuel gauge.
+ *
+ * Copyright (C) 2017 Neil Hancock. All rights reserved.
+ *
+ * Copyright (C) 2017 Haltian Ltd. All rights reserved.
+ * Author: Juha Niskanen <[email protected]>
+ *
+ * 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 __DRIVERS_POWER_BQ27426_H
+#define __DRIVERS_POWER_BQ27426_H
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* Auxiliary Definitions */
+
+#define BQ27426_I2C_TIMEOUT 2000
+
+#define BQ27426_I2C_ADDRESS 0x55 /* Default I2C address of the BQ27426 */
+
+/* General Constants */
+
+#define BQ27426_UNSEAL_KEY 0x8000 /* Secret code to unseal the BQ27426 */
+#define BQ27426_DEVICE_ID 0x0426 /* Default device ID */
+
+/* Standard Commands */
+
+/* The fuel gauge uses a series of 2-byte standard commands to enable system
+ * reading and writing of battery information. Each command has an associated
+ * sequential command-code pair.
+ */
+
+#define BQ27426_COMMAND_CONTROL 0x00 /* Control() */
+#define BQ27426_COMMAND_TEMP 0x02 /* Temperature() */
+#define BQ27426_COMMAND_VOLTAGE 0x04 /* Voltage() */
+#define BQ27426_COMMAND_FLAGS 0x06 /* Flags() */
+#define BQ27426_COMMAND_NOM_CAPACITY 0x08 /* NominalAvailableCapacity() */
+#define BQ27426_COMMAND_AVAIL_CAPACITY 0x0A /* FullAvailableCapacity() */
+#define BQ27426_COMMAND_REM_CAPACITY 0x0C /* RemainingCapacity() */
+#define BQ27426_COMMAND_FULL_CAPACITY 0x0E /* FullChargeCapacity() */
+#define BQ27426_COMMAND_AVG_CURRENT 0x10 /* AverageCurrent() */
+#define BQ27426_COMMAND_AVG_POWER 0x18 /* AveragePower() */
+#define BQ27426_COMMAND_SOC 0x1C /* StateOfCharge() */
+#define BQ27426_COMMAND_INT_TEMP 0x1E /* InternalTemperature() */
+#define BQ27426_COMMAND_SOH 0x20 /* StateOfHealth() */
+#define BQ27426_COMMAND_REM_CAP_UNFL 0x28 /* RemainingCapacityUnfiltered()
*/
+#define BQ27426_COMMAND_REM_CAP_FIL 0x2A /* RemainingCapacityFiltered() */
+#define BQ27426_COMMAND_FULL_CAP_UNFL 0x2C /* FullChargeCapacityUnfiltered()
*/
+#define BQ27426_COMMAND_FULL_CAP_FIL 0x2E /* FullChargeCapacityFiltered() */
+#define BQ27426_COMMAND_SOC_UNFL 0x30 /* StateOfChargeUnfiltered() */
+
+/* Control Sub-commands */
+
+/* Issuing a Control() command requires a subsequent 2-byte subcommand. These
+ * additional bytes specify the particular control function desired. The
+ * Control() command allows the system to control specific features of the
+ * fuel gauge during normal operation and additional features when the
+ * device is in different access modes.
+ */
+
+#define BQ27426_CONTROL_STATUS 0x0000
+#define BQ27426_CONTROL_DEVICE_TYPE 0x0001
+#define BQ27426_CONTROL_FW_VERSION 0x0002
+#define BQ27426_CONTROL_DM_CODE 0x0004
+#define BQ27426_CONTROL_PREV_MACWRITE 0x0007
+#define BQ27426_CONTROL_CHEM_ID 0x0008
+#define BQ27426_CONTROL_BAT_INSERT 0x000C
+#define BQ27426_CONTROL_BAT_REMOVE 0x000D
+#define BQ27426_CONTROL_SET_CFGUPDATE 0x0013
+#define BQ27426_CONTROL_SMOOTH_SYNC 0x0019
+#define BQ27426_CONTROL_SHUTDOWN_ENABLE 0x001B
+#define BQ27426_CONTROL_SHUTDOWN 0x001C
+#define BQ27426_CONTROL_SEALED 0x0020
+#define BQ27426_CONTROL_PULSE_SOC_INT 0x0023
+#define BQ27426_CONTROL_CHEM_A 0x0030
+#define BQ27426_CONTROL_CHEM_B 0x0031
+#define BQ27426_CONTROL_CHEM_C 0x0032
+#define BQ27426_CONTROL_RESET 0x0041
+#define BQ27426_CONTROL_SOFT_RESET 0x0042
+
+/* Control Status Word - Bit Definitions */
+
+/* Bit positions for the 16-bit data of CONTROL_STATUS.
+ * CONTROL_STATUS instructs the fuel gauge to return status
+ * information to Control() addresses 0x00 and 0x01.
+ * The read-only status word contains status bits that are
+ * set or cleared either automatically as conditions warrant or
+ * through using specified subcommands.
+ */
+
+#define BQ27426_STATUS_SHUTDOWNEN (1 << 15)
+#define BQ27426_STATUS_WDRESET (1 << 14)
+#define BQ27426_STATUS_SS (1 << 13)
+#define BQ27426_STATUS_CALMODE (1 << 12)
+#define BQ27426_STATUS_CCA (1 << 11)
+#define BQ27426_STATUS_BCA (1 << 10)
+#define BQ27426_STATUS_QMAX_UP (1 << 9)
+#define BQ27426_STATUS_RES_UP (1 << 8)
+#define BQ27426_STATUS_INITCOMP (1 << 7)
+#define BQ27426_STATUS_SLEEP (1 << 4)
+#define BQ27426_STATUS_LDMD (1 << 3)
+#define BQ27426_STATUS_RUP_DIS (1 << 2)
+#define BQ27426_STATUS_VOK (1 << 1)
+#define BQ27426_STATUS_CHEMCHANGE (1 << 0)
+
+/* Flag Command - Bit Definitions */
+
+/* Bit positions for the 16-bit data of Flags()
+ * This read-word function returns the contents of the fuel gauging status
+ * register, depicting the current operating status.
+ */
+
+#define BQ27426_FLAG_OT (1 << 15)
+#define BQ27426_FLAG_UT (1 << 14)
+#define BQ27426_FLAG_FC (1 << 9)
+#define BQ27426_FLAG_CHG (1 << 8)
+#define BQ27426_FLAG_OCVTAKEN (1 << 7)
+#define BQ27426_FLAG_DODCORRECT (1 << 6)
+#define BQ27426_FLAG_ITPOR (1 << 5)
+#define BQ27426_FLAG_CFGUPMODE (1 << 4)
+#define BQ27426_FLAG_BAT_DET (1 << 3)
+#define BQ27426_FLAG_SOC1 (1 << 2)
+#define BQ27426_FLAG_SOCF (1 << 1)
+#define BQ27426_FLAG_DSG (1 << 0)
+
+/* Extended Data Commands */
+
+/* Extended data commands offer additional functionality beyond
+ * the standard set of commands.
+ * They are used in the same manner; however, unlike standard
+ * scommands, extended commands are not limited to 2-byte words.
+ */
+
+#define BQ27426_EXTENDED_OPCONFIG 0x3A /* OpConfig()*/
+#define BQ27426_EXTENDED_CAPACITY 0x3C /* DesignCapacity()*/
+#define BQ27426_EXTENDED_DATACLASS 0x3E /* DataClass()*/
+#define BQ27426_EXTENDED_DATABLOCK 0x3F /* DataBlock()*/
+#define BQ27426_EXTENDED_BLOCKDATA 0x40 /* BlockData()*/
+#define BQ27426_EXTENDED_CHECKSUM 0x60 /* BlockDataCheckSum()*/
+#define BQ27426_EXTENDED_CONTROL 0x61 /* BlockDataControl()*/
+
+/* Configuration Class, Subclass ID's */
+
+/* To access a subclass of the extended data, set the DataClass()
+ * function with one of these values.
+ */
+
+/* Configuration Classes */
+
+#define BQ27426_ID_SAFETY 2 /* Safety */
Review comment:
Please, try to align those value to start all in the same column, this
block and all others
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]