Commit d6728c5b authored by Thomas Schöpping's avatar Thomas Schöpping
Browse files

Initial open-source release.

parents
################################################################################
# AMiRo-LLD is a compilation of low-level hardware drivers for the Autonomous #
# Mini Robot (AMiRo) platform. #
# Copyright (C) 2016..2018 Thomas Schöpping et al. #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
# #
# This research/work was supported by the Cluster of Excellence Cognitive #
# Interaction Technology 'CITEC' (EXC 277) at Bielefeld University, which is #
# funded by the German Research Foundation (DFG). #
################################################################################
# absolute path to this directory
AMIROLLD_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
# include paths
AMIROLLD_INC = $(AMIROLLD_DIR) \
$(AMIROLLD_DIR)include/
AMIROLLD_SRCDIR = $(AMIROLLD_DIR)source/
# C sources
AMIROLLD_CSRC = $(AMIROLLD_SRCDIR)alld_a3906.c \
$(AMIROLLD_SRCDIR)alld_at24c01bn-sh-b.c \
$(AMIROLLD_SRCDIR)alld_bq24103a.c \
$(AMIROLLD_SRCDIR)alld_bq27500.c \
$(AMIROLLD_SRCDIR)alld_hmc5883l.c \
$(AMIROLLD_SRCDIR)alld_ina219.c \
$(AMIROLLD_SRCDIR)alld_l3g4200d.c \
$(AMIROLLD_SRCDIR)alld_led.c \
$(AMIROLLD_SRCDIR)alld_lis331dlh.c \
$(AMIROLLD_SRCDIR)alld_ltc4412.c \
$(AMIROLLD_SRCDIR)alld_mpr121.c \
$(AMIROLLD_SRCDIR)alld_pca9544a.c \
$(AMIROLLD_SRCDIR)alld_pklcs1212e4001.c \
$(AMIROLLD_SRCDIR)alld_tlc5947.c \
$(AMIROLLD_SRCDIR)alld_tps2051bdbv.c \
$(AMIROLLD_SRCDIR)alld_tps62113.c \
$(AMIROLLD_SRCDIR)alld_vcnl4020.c
AMiRo-LLD is a compilation of low-level hardware drivers for the base version of
the Autonomous Mini Robot (AMiRo) [1]. It provides directional interfaces for an
operating system to access the drivers and for the drivers to access the
communication infrastructure via the operating system.
Copyright (C) 2016..2018 Thomas Schöpping et al.
(a complete list of all authors is given below)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or (at
your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
This research/work was supported by the Cluster of Excellence
Cognitive Interaction Technology 'CITEC' (EXC 277) at Bielefeld
University, which is funded by the German Research Foundation (DFG).
Authors:
- Thomas Schöpping <tschoepp[at]cit-ec.uni-bielefeld.de>
- Marc Rothmann
References:
[1] S. Herbrechtsmeier, T. Korthals, T. Schopping and U. Rückert, "AMiRo: A
modular & customizable open-source mini robot platform," 2016 20th
International Conference on System Theory, Control and Computing (ICSTCC),
Sinaia, 2016, pp. 687-692.
################################################################################
# #
# RRRRRRRR EEEEEEEE AAA DDDDDDDD MM MM EEEEEEEE #
# RR RR EE AA AA DD DD MMM MMM EE #
# RR RR EE AA AA DD DD MMMM MMMM EE #
# RRRRRRRR EEEEEE AA AA DD DD MM MMM MM EEEEEE #
# RR RR EE AAAAAAAAA DD DD MM MM EE #
# RR RR EE AA AA DD DD MM MM EE #
# RR RR EEEEEEEE AA AA DDDDDDDD MM MM EEEEEEEE #
# #
################################################################################
AMiRo-LLD is a compilation of low-level hardware drivers, originally developed
for the Autonomous Mini Robot (AMiRo) [1]. It provides a modular design, so that
each driver can be (de)activated individually as required. Interface functions
allow for bidirectional comunication with an operating system. On the one hand
drivers access according hardware interfaces via defined interface functions
(which need to be implemented by the operating system) and any applications (or
the operating system itself) can take advantage of the drivers by their
individual interfaces. The abstraction layer of the hardware interfaces is
called "periphAL", which is defined by this project.
Although this compilation was originally designed to be used in combination with
the AMiRo operating system (AMiRo-OS; cf. https://opensource.cit-ec.de/projects/amiro-os/),
it is not limited to this use case. The included drivers may be used for any
purpose and contributions of further drivers, even if the according hardware is
not present on the AMiRo platform, are highly appreciated.
The files are structured as follows:
* include/
Each driver defines exactly one include header in this directory. By
convention these files are named by the form
alld_<product_name>.h
<product_name> is a placeholder for the exact name of the according hardware,
or the product familiy, if the driver is compatible with all parts.
* source/
Any source files are placed in this directory. Usually there is a single file
for each driver. If multiple files are necessary, these should be placed in an
accordingly named subfolder. Names of folders and files should comply to the
aforementioned convention.
* templates/
AMiRo-LLD requires an implementation of the defined interface and an
configuration header to be accessible in the include paths at compile time.
Template files for both can be found in this folder. It is recommended to
place according implementations of these templated not in the AMiRo-LLD
project, but the superproject which includes AMiRo-LLD.
* /
The project root directory contains this file, a license.html file as well as
a Makefile that allows to easily integrate the project. Furthermore, two
interface headers are provided: amiro-lld.h and periphALtypes.h. These are
entry points for any utilizing superproject, so it is not required (and not
recommanded) to include each driver individually.
================================================================================
/*
AMiRo-LLD is a compilation of low-level hardware drivers for the Autonomous Mini Robot (AMiRo) platform.
Copyright (C) 2016..2018 Thomas Schöpping et al.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _AMIROLLD_H_
#define _AMIROLLD_H_
/**
* @brief AMIRO-LLD identification macro.
*/
#define _AMIRO_LLD_
/**
* @name AMiRo-LLD version and relase information.
* @{
*/
/**
* @brief Realease type of this version.
* IPossible values are "pre-alpha", "alpha", "beta", "release candidate", "release".
*/
#define AMIRO_LLD_RELEASE_TYPE "release"
/**
* @brief The periphery abstraction layer interface major version.
* @note Changes of the major version imply incompatibilities.
*/
#define AMIRO_LLD_VERSION_MAJOR 1
/**
* @brief The periphery abstraction layer interface minor version.
* @note A higher minor version implies new functionalty, but all old interfaces are still available.
*/
#define AMIRO_LLD_VERSION_MINOR 0
/**
* @brief The periphery abstraction layer interface patch level.
*/
#define AMIRO_LLD_VERSION_PATCH 0
/**
* @brief The periphery abstraction layer interface required major version.
*/
#define PERIPHAL_REQUIRED_MAJOR 1
/**
* @brief The periphery abstraction layer interface required minor version.
*/
#define PERIPHAL_REQUIRED_MINOR 0
/** @} */
#include <alldconf.h>
#if !defined(_AMIRO_LLD_CFG_)
#error "invalid AMiRo-LLD configuration file"
#endif
#if (AMIRO_LLD_CFG_VERSION_MAJOR != AMIRO_LLD_VERSION_MAJOR) || (AMIRO_LLD_CFG_VERSION_MINOR < AMIRO_LLD_VERSION_MINOR)
#error "incompatible AMiRo-LLD configuration file"
#endif
#include <periphAL.h>
#if !defined(PERIPHAL_VERSION_MAJOR) || !defined(PERIPHAL_VERSION_MINOR)
#error "invalid periphAL implementation"
#endif
#if (PERIPHAL_VERSION_MAJOR != PERIPHAL_REQUIRED_MAJOR) || (PERIPHAL_VERSION_MINOR < PERIPHAL_REQUIRED_MINOR)
#error "incompatible periphAL implementation"
#endif
#endif /* _AMIROLLD_H_ */
This diff is collapsed.
/*
AMiRo-LLD is a compilation of low-level hardware drivers for the Autonomous Mini Robot (AMiRo) platform.
Copyright (C) 2016..2018 Thomas Schöpping et al.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _AMIROLLD_A3906_H_
#define _AMIROLLD_A3906_H_
#include <amiro-lld.h>
#if defined(AMIROLLD_CFG_USE_A3906) || defined(__DOXYGEN__)
/**
* @brief Active state of power pin.
*/
#define A3906_LLD_POWER_PIN_ACTIVE_STATE APAL_GPIO_ACTIVE_HIGH
/**
* @brief A3906 driver struct.
*/
typedef struct {
apalControlGpio_t power_pin; /**< @brief GPIO to enable/disable power of the A3906. */
} A3906Driver;
/**
* @brief Power state of the A3906.
*/
typedef enum {
A3906_LLD_POWER_OFF = 0x00, /**< 'power off' state */
A3906_LLD_POWER_ON = 0x01, /**< 'power on' state */
} a3906_lld_power_t;
#ifdef __cplusplus
extern "C" {
#endif
apalExitStatus_t a3906_lld_set_power(const A3906Driver* const a3906, const a3906_lld_power_t power_state);
apalExitStatus_t a3906_lld_get_power(const A3906Driver* const a3906, a3906_lld_power_t* const power_state);
apalExitStatus_t a3906_lld_set_pwm(apalPWMDriver_t* pwm, const apalPWMchannel_t channel, const apalPWMwidth_t width);
#ifdef __cplusplus
}
#endif
#endif /* defined(AMIROLLD_CFG_USE_A3906) */
#endif /* _AMIROLLD_A3906_H_ */
/*
AMiRo-LLD is a compilation of low-level hardware drivers for the Autonomous Mini Robot (AMiRo) platform.
Copyright (C) 2016..2018 Thomas Schöpping et al.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _AMIROLLD_AT24C01BN_H_
#define _AMIROLLD_AT24C01BN_H_
#include <amiro-lld.h>
#if defined(AMIROLLD_CFG_USE_AT24C01BN) || defined(__DOXYGEN__)
/**
* @brief Memory size of the EEPROM in bits.
*/
#define AT24C01BN_LLD_SIZE_BITS 1024
/**
* @brief Memory size of the EEPROM in bytes
*/
#define AT24C01BN_LLD_SIZE_BYTES 128
/**
* @brief Size of a page in bytes
*/
#define AT24C01BN_LLD_PAGE_SIZE_BYTES 8
/**
* @brief Time in microseconds a write operation takes to complete (I2C will not respond).
* @note The system should wait slightly longer.
*/
#define AT24C01BN_LLD_WRITECYCLETIME_US 5000
/**
* @brief Maximum I2C frequency.
*/
#define AT24C01BN_LLD_I2C_MAXFREQUENCY 400000
/**
* @brief Maximum I2C frequency at 5V.
*/
#define AT24C01BN_LLD_I2C_MAXFREQUENCY_5V 1000000
/**
* @brief The AT24C01BN driver struct
*/
typedef struct {
apalI2CDriver_t* i2cd; /**< @brief The I2C Driver */
uint8_t addr; /**< @brief The address of the AT24C01B for I2C communication, which is defined by the wiring of the A0, A1, A2 pins */
} AT24C01BNDriver;
/**
* @brief Bitmasks for the I2C address, including the wiring of the A0, A1, A2 pins.
*/
enum {
AT24C01BN_LLD_I2C_ADDR_FIXED = 0x50u,
AT24C01BN_LLD_I2C_ADDR_A0 = 0x01u,
AT24C01BN_LLD_I2C_ADDR_A1 = 0x02u,
AT24C01BN_LLD_I2C_ADDR_A2 = 0x04u,
};
#ifdef __cplusplus
extern "C" {
#endif
apalExitStatus_t at24c01bn_lld_poll_ack(const AT24C01BNDriver* const at24c01bn, const apalTime_t timeout);
apalExitStatus_t at24c01bn_lld_read_current_address(const AT24C01BNDriver* const at24c01bn, uint8_t* const data, const uint8_t num, const apalTime_t timeout);
apalExitStatus_t at24c01bn_lld_read(const AT24C01BNDriver* const at24c01bn, const uint8_t addr, uint8_t* const data, const uint8_t num, const apalTime_t timeout);
apalExitStatus_t at24c01bn_lld_write_byte(const AT24C01BNDriver* const at24c01bn, const uint8_t addr, const uint8_t data, const apalTime_t timeout);
apalExitStatus_t at24c01bn_lld_write_page(const AT24C01BNDriver* const at24c01bn, const uint8_t addr, const uint8_t* const data, const uint8_t num, const apalTime_t timeout);
#ifdef __cplusplus
}
#endif
#endif /* defined(AMIROLLD_CFG_USE_AT24C01BN) */
#endif /* _AMIROLLD_AT24C01BN_H_ */
/*
AMiRo-LLD is a compilation of low-level hardware drivers for the Autonomous Mini Robot (AMiRo) platform.
Copyright (C) 2016..2018 Thomas Schöpping et al.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _AMIROLLD_BQ24103A_H_
#define _AMIROLLD_BQ24103A_H_
#include <amiro-lld.h>
#if defined(AMIROLLD_CFG_USE_BQ24103A) || defined(__DOXYGEN__)
/**
* @brief Active state of enabled gpio.
*/
#define BQ24103A_LLD_ENABLED_GPIO_ACTIVE_STATE APAL_GPIO_ACTIVE_LOW
/**
* @brief Active state of charge status gpio.
*/
#define BQ24103A_LLD_CHARGE_STATUS_GPIO_ACTIVE_STATE APAL_GPIO_ACTIVE_HIGH
/**
* @brief The BQ24103A driver struct.
*/
typedef struct {
apalControlGpio_t gpio_enabled; /**< @brief GPIO to enable/disable the bq24103a */
apalControlGpio_t gpio_charge_status; /**< @brief GPIO showing the status of the bq24103a */
} BQ24103ADriver;
/**
* @brief Enable enum.
*/
typedef enum {
BQ24103A_LLD_ENABLED = 0x01, /**< @brief 'charging on' state */
BQ24103A_LLD_DISABLED = 0x00, /**< @brief 'charging off' state */
} bq24103a_lld_enable_t;
/**
* @brief Charge state enum.
*/
typedef enum {
BQ24103A_LLD_CHARGING = 0x01, /**< @brief status indicating that the battery is being charged */
BQ24103A_LLD_NOT_CHARGING = 0x00, /**< @brife status indicating that the battery is not being charged */
} bq24103a_lld_charge_state_t;
#ifdef __cplusplus
extern "C" {
#endif
apalExitStatus_t bq24103a_lld_get_enabled(const BQ24103ADriver* const bq24103a, bq24103a_lld_enable_t* const enable);
apalExitStatus_t bq24103a_lld_set_enabled(const BQ24103ADriver* const bq24103a, const bq24103a_lld_enable_t enable);
apalExitStatus_t bq24103a_lld_get_charge_status(const BQ24103ADriver* const bq24103a, bq24103a_lld_charge_state_t* const charge);
#ifdef __cplusplus
}
#endif
#endif /* defined(AMIROLLD_CFG_USE_BQ24103A) */
#endif /* _AMIROLLD_BQ24103A_H_ */
/*
AMiRo-LLD is a compilation of low-level hardware drivers for the Autonomous Mini Robot (AMiRo) platform.
Copyright (C) 2016..2018 Thomas Schöpping et al.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _AMIROLLD_BQ27500_H_
#define _AMIROLLD_BQ27500_H_
#include <amiro-lld.h>
#if defined(AMIROLLD_CFG_USE_BQ27500) || defined(__DOXYGEN__)
/**
* @brief fixed I2C address
*/
#define BQ27500_LLD_I2C_ADDR 0x55u
/**
* @brief maximum I2C frequency in Hz
*/
#define BQ27500_LLD_I2C_MAXFREQUENCY 100000
/**
* @brief default key0 to get into unsealed mode
*/
#define BQ27500_LLD_DEFAULT_UNSEAL_KEY0 0x3672u
/**
* @brief default key1 to get into unsealed mode
*/
#define BQ27500_LLD_DEFAULT_UNSEAL_KEY1 0x0414u
/**
* @brief Active state of battery low gpio.
*/
#define BQ27500_LLD_BATLOW_ACTIVE_STATE APAL_GPIO_ACTIVE_HIGH
/**
* @brief Active state of battery good gpio.
*/
#define BQ27500_LLD_BATGOOD_ACTIVE_STATE APAL_GPIO_ACTIVE_LOW
/**
* @brief Possible standard commands.
*/
typedef enum {
// unit | access
// | sealed | unsealed
// ---------+---------+----------
BQ27500_LLD_STD_CMD_Control = 0x00u, BQ27500_LLD_STD_CMD_CNTL = 0x00u, // N/A | R/W | R/W
BQ27500_LLD_STD_CMD_AtRate = 0x02u, BQ27500_LLD_STD_CMD_AR = 0x02u, // mA | R/W | R/W
BQ27500_LLD_STD_CMD_AtRateTimeToEmpty = 0x04u, BQ27500_LLD_STD_CMD_ARTTE = 0x04u, // minutes | R | R/W
BQ27500_LLD_STD_CMD_Temperatur = 0x06u, BQ27500_LLD_STD_CMD_TEMP = 0x06u, // 0.1 K | R | R/W
BQ27500_LLD_STD_CMD_Voltage = 0x08u, BQ27500_LLD_STD_CMD_VOLT = 0x08u, // mV | R | R/W
BQ27500_LLD_STD_CMD_Flags = 0x0Au, BQ27500_LLD_STD_CMD_FLAGS = 0x0Au, // N/A | R | R/W
BQ27500_LLD_STD_CMD_NominalAvailableCapacity = 0x0Cu, BQ27500_LLD_STD_CMD_NAC = 0x0Cu, // mAh | R | R/W
BQ27500_LLD_STD_CMD_FullAvailableCapacity = 0x0Eu, BQ27500_LLD_STD_CMD_FAC = 0x0Eu, // mAh | R | R/W
BQ27500_LLD_STD_CMD_RemainingCapacity = 0x10u, BQ27500_LLD_STD_CMD_RM = 0x10u, // mAh | R | R/W
BQ27500_LLD_STD_CMD_FullChargeCapacity = 0x12u, BQ27500_LLD_STD_CMD_FCC = 0x12u, // mAh | R | R/W
BQ27500_LLD_STD_CMD_AverageCurrent = 0x14u, BQ27500_LLD_STD_CMD_AI = 0x14u, // mA | R | R/W
BQ27500_LLD_STD_CMD_TimeToEmpty = 0x16u, BQ27500_LLD_STD_CMD_TTE = 0x16u, // minutes | R | R/W
BQ27500_LLD_STD_CMD_TimeToFull = 0x18u, BQ27500_LLD_STD_CMD_TTF = 0x18u, // minutes | R | R/W
BQ27500_LLD_STD_CMD_StandbyCurrent = 0x1Au, BQ27500_LLD_STD_CMD_SI = 0x1Au, // mA | R | R/W
BQ27500_LLD_STD_CMD_StandbyTimeToEmpty = 0x1Cu, BQ27500_LLD_STD_CMD_STTE = 0x1Cu, // minutes | R | R/W
BQ27500_LLD_STD_CMD_MaxLoadCurrent = 0x1Eu, BQ27500_LLD_STD_CMD_MLI = 0x1Eu, // mA | R | R/W
BQ27500_LLD_STD_CMD_MaxLoadTimeToEmpty = 0x20u, BQ27500_LLD_STD_CMD_MLTTE = 0x20u, // minutes | R | R/W
BQ27500_LLD_STD_CMD_AvailableEnergy = 0x22u, BQ27500_LLD_STD_CMD_AE = 0x22u, // mWh | R | R/W
BQ27500_LLD_STD_CMD_AveragePower = 0x24u, BQ27500_LLD_STD_CMD_AP = 0x24u, // mW | R | R/W
BQ27500_LLD_STD_CMD_TimeToEmptyAtConstantPower = 0x26u, BQ27500_LLD_STD_CMD_TTECP = 0x26u, // minutes | R | R/W
BQ27500_LLD_STD_CMD_CycleCount = 0x2Au, BQ27500_LLD_STD_CMD_CC = 0x2Au, // counts | R | R/W
BQ27500_LLD_STD_CMD_StateOfCharge = 0x2Cu, BQ27500_LLD_STD_CMD_SOC = 0x2Cu // % | R | R/W
} bq27500_lld_std_command_t;
/**
* @brief Subcommands of the control command.
*/
typedef enum {
// sealed access
// -------------
BQ27500_LLD_SUB_CMD_CONTROL_STATUS = 0x0000u, // yes
BQ27500_LLD_SUB_CMD_DEVICE_TYPE = 0x0001u, // yes
BQ27500_LLD_SUB_CMD_FW_VERSION = 0x0002u, // yes
BQ27500_LLD_SUB_CMD_HW_VERSION = 0x0003u, // yes
BQ27500_LLD_SUB_CMD_DF_CHECKSUM = 0x0004u, // no
BQ27500_LLD_SUB_CMD_RESET_DATA = 0x0005u, // yes
BQ27500_LLD_SUB_CMD_PREV_MACWRITE = 0x0007u, // yes
BQ27500_LLD_SUB_CMD_CHEM_ID = 0x0008u, // yes
BQ27500_LLD_SUB_CMD_BOARD_OFFSET = 0x0009u, // no
BQ27500_LLD_SUB_CMD_CC_INT_OFFSET = 0x000Au, // no
BQ27500_LLD_SUB_CMD_WRITE_OFFSET = 0x000Bu, // no
BQ27500_LLD_SUB_CMD_SET_HIBERNATE = 0x0011u, // yes
BQ27500_LLD_SUB_CMD_CLEAR_HIBERNATE = 0x0012u, // yes
BQ27500_LLD_SUB_CMD_SET_SLEEPp = 0x0013u, // yes
BQ27500_LLD_SUB_CMD_CLEAR_SLEEPp = 0x0014u, // yes
BQ27500_LLD_SUB_CMD_SEALED = 0x0020u, // no
BQ27500_LLD_SUB_CMD_IT_ENABLE = 0x0021u, // no
BQ27500_LLD_SUB_CMD_IF_CHECKSUM = 0x0022u, // no
BQ27500_LLD_SUB_CMD_CAL_MODE = 0x0040u, // no
BQ27500_LLD_SUB_CMD_RESET = 0x0041u, // no
} bq27500_lld_control_subcmd_t;
/**
* @brief Extended commands.
*/
typedef enum {
// length | unit | sealed | unsealed
// -------+------+--------+----------
BQ27500_LLD_EXT_CMD_DesignCapacity = 0x3Cu, EXT_CMD_DCAP = 0x3Cu, // 2 | mAh | R | R
BQ27500_LLD_EXT_CMD_DataFlashClass = 0x3Eu, EXT_CMD_DFCLS = 0x3Eu, // 1 | N/A | N/A | R/W
BQ27500_LLD_EXT_CMD_DataFlashBlock = 0x3Fu, EXT_CMD_DFBLK = 0x3Fu, // 1 | N/A | R/W | R/W
BQ27500_LLD_EXT_CMD_BlockData = 0x40u, EXT_CMD_DFD = 0x40u, // 32 | N/A | R | R/W
BQ27500_LLD_EXT_CMD_BlockDataCheckSum = 0x60u,EXT_CMD_DFDCKS = 0x60u, // 1 | N/A | R/W | R/W
BQ27500_LLD_EXT_CMD_BlockDataControl = 0x61u, EXT_CMD_DFDCNTL = 0x61u, // 1 | N/A | N/A | R/W
BQ27500_LLD_EXT_CMD_DeviceNameLength = 0x62u, EXT_CMD_DNAMELEN = 0x62u, // 1 | N/A | R | R
BQ27500_LLD_EXT_CMD_DeviceName = 0x63u, EXT_CMD_DNAME = 0x63u, // 7 | N/A | R | R
BQ27500_LLD_EXT_CMD_ApplicationStatus = 0x6Au, EXT_CMD_APPSTAT = 0x6Au // 1 | N/A | R | R
} bq27500_lld_ext_command_t;
/**
* @brief Read or write access to extended commands.
*/
typedef enum {
BQ27500_LLD_EXT_CMD_READ = 0,
BQ27500_LLD_EXT_CMD_WRITE = 1,
} bq27500_lld_ext_cmd_access_t;
/**
* @brief Union to inspect the version value.
*/
typedef union {
uint16_t value;
struct {
uint16_t minor_low : 4;
uint16_t minor_high : 4;
uint16_t major_low : 4;
uint16_t major_high : 4;
} content;
} bq27500_lld_version_t;
/**
* @brief Union to inspect the flags register.
*/
typedef union {
uint16_t value;
struct {
uint16_t dsg : 1;
uint16_t socf : 1;
uint16_t soc1 : 1;
uint16_t bat_det : 1;
uint16_t wait_id : 1;
uint16_t ocv_gd : 1;
uint16_t rsvd_6_7 : 2;
uint16_t chg : 1;
uint16_t fc : 1;
uint16_t xchg : 1;
uint16_t chg_inh : 1;
uint16_t rsvd_12_13 : 2;
uint16_t otd : 1;
uint16_t otc : 1;
} content;
} bq27500_lld_flags_t;
/**
* @brief Union to inspect the control st