foxBMS
1.1.1
The foxBMS Battery Management System API Documentation
|
Driver for the MAX17841B ASCI and MAX1785x monitoring chip. More...
#include "mxm_battery_management.h"
Go to the source code of this file.
Macros | |
#define | HELLOALL_TX_LENGTH (3u) |
#define | HELLOALL_RX_LENGTH HELLOALL_TX_LENGTH |
Functions | |
static void | MXM_5XClearCommandBuffer (MXM_5X_INSTANCE_s *pInstance) |
Clear the command-buffer. More... | |
static STD_RETURN_TYPE_e | MXM_5XIsUserAccessibleRegister (uint8_t regAddress) |
Check if a register address is user accessible. More... | |
static STD_RETURN_TYPE_e | MXM_52IsUserAccessibleRegister (uint8_t regAddress) |
Check if a register address is user accessible in MAX17852. More... | |
static STD_RETURN_TYPE_e | MXM_53IsUserAccessibleRegister (uint8_t regAddress) |
Check if a register address is user accessible in MAX17853. More... | |
static void | MXM_5XConstructCommandBufferHelloall (MXM_5X_INSTANCE_s *pInstance) |
clears the command buffer and writes HELLOALL into the buffer More... | |
static STD_RETURN_TYPE_e | MXM_5XConstructCommandBufferWriteall (MXM_5X_INSTANCE_s *pInstance, uint8_t regAddress, uint8_t dataLSB, uint8_t dataMSB) |
clears the command buffer and writes WRITEALL into the buffer More... | |
static STD_RETURN_TYPE_e | MXM_5XConstructCommandBufferWriteDevice (MXM_5X_INSTANCE_s *pInstance, uint8_t deviceAddress, uint8_t regAddress, uint8_t dataLSB, uint8_t dataMSB) |
clears the command buffer and writes a WRITEDEVICE message More... | |
static STD_RETURN_TYPE_e | MXM_5XConstructCommandBufferReadall (MXM_5X_INSTANCE_s *pInstance, uint8_t regAddress) |
clears the command buffer and writes READALL into the buffer More... | |
STD_RETURN_TYPE_e | MXM_5XGetRXBuffer (const MXM_5X_INSTANCE_s *const kpkInstance, uint8_t *rxBuffer, uint16_t rxBufferLength) |
Copy RX buffer into variable. More... | |
MXM_DC_BYTE_e | MXM_5XGetLastDCByte (const MXM_5X_INSTANCE_s *const kpkInstance) |
Returns the last received DC byte. More... | |
uint8_t | MXM_5XGetNumberOfSatellites (const MXM_5X_INSTANCE_s *const kpkInstance) |
Get number of satellites. More... | |
STD_RETURN_TYPE_e | MXM_5XGetNumberOfSatellitesGood (const MXM_5X_INSTANCE_s *const kpkInstance) |
Get the value of MXM_5X_INSTANCE::numberOfSatellitesIsGood. More... | |
STD_RETURN_TYPE_e | MXM_5XSetStateRequest (MXM_5X_INSTANCE_s *pInstance5x, MXM_STATEMACHINE_5X_e state, MXM_5X_COMMAND_PAYLOAD_s commandPayload, MXM_5X_STATE_REQUEST_STATUS_e *processed) |
Set state request for the Battery Management Statemachine. More... | |
void | MXM_5XStateMachine (MXM_41B_INSTANCE_s *pInstance41b, MXM_5X_INSTANCE_s *pInstance5x) |
Execute state-machine for Battery Management Protocol. More... | |
STD_RETURN_TYPE_e must_check_return | MXM_5XUserAccessibleAddressSpaceCheckerSelfCheck (void) |
runs a selfcheck for the address space check More... | |
Driver for the MAX17841B ASCI and MAX1785x monitoring chip.
SPDX-License-Identifier: BSD-3-Clause
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
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 HOLDER 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.
We kindly request you to use one or more of the following phrases to refer to foxBMS in your hardware, software, documentation or advertising materials:
def
Definition in file mxm_battery_management.c.
#define HELLOALL_RX_LENGTH HELLOALL_TX_LENGTH |
length of the helloall command
Definition at line 63 of file mxm_battery_management.c.
#define HELLOALL_TX_LENGTH (3u) |
length of the helloall command
Definition at line 62 of file mxm_battery_management.c.
|
static |
Check if a register address is user accessible in MAX17852.
Checks if a register address is inside the user accessible memory range. This range is specified in the datasheet of the monitoring IC.
[in] | regAddress | register address to be checked |
Definition at line 209 of file mxm_battery_management.c.
|
static |
Check if a register address is user accessible in MAX17853.
Checks if a register address is inside the user accessible memory range. This range is specified in the datasheet of the monitoring IC as the following:
[in] | regAddress | register address to be checked |
Definition at line 225 of file mxm_battery_management.c.
|
static |
Clear the command-buffer.
Clears MXM_5X_INSTANCE_s::commandBuffer by writing 0x00 to every entry.
[in,out] | pInstance | pointer to the state-struct |
Definition at line 182 of file mxm_battery_management.c.
|
static |
clears the command buffer and writes HELLOALL into the buffer
Fills the command buffer with a HELLOALL message after having it cleaned.
[in,out] | pInstance | pointer to the state-struct |
Definition at line 242 of file mxm_battery_management.c.
|
static |
clears the command buffer and writes READALL into the buffer
Fills the command buffer with a READALL command. This command retrieves the LSB and MSB of exactly one register of every device in the daisy-chain.
[in,out] | pInstance | pointer to the state-struct |
[in] | regAddress | address of the register that should be read |
Definition at line 309 of file mxm_battery_management.c.
|
static |
clears the command buffer and writes WRITEALL into the buffer
Fills the command buffer with a WRITEALL command. This command writes the same lsb and msb to every satellite in the daisy-chain in the same register.
[in,out] | pInstance | pointer to the state-struct |
[in] | regAddress | address of the register that should be written |
[in] | dataLSB | LSB of the register that should be written |
[in] | dataMSB | MSB of the register that should be written |
Definition at line 250 of file mxm_battery_management.c.
|
static |
clears the command buffer and writes a WRITEDEVICE message
Fills the command buffer with a WRITEDEVICE message. This message is addressed to one specific device in the daisy-chain. Therefore the address of the device has to be supplied together with the register and the data that should be written.
[in,out] | pInstance | pointer to the state-struct |
[in] | deviceAddress | address for the satellite that should be written to |
[in] | regAddress | address of the register that should be written |
[in] | dataLSB | LSB of the register that should be written |
[in] | dataMSB | MSB of the register that should be written |
Definition at line 276 of file mxm_battery_management.c.
MXM_DC_BYTE_e MXM_5XGetLastDCByte | ( | const MXM_5X_INSTANCE_s *const | kpkInstance | ) |
Returns the last received DC byte.
[in] | kpkInstance | pointer to the instance struct |
Definition at line 360 of file mxm_battery_management.c.
uint8_t MXM_5XGetNumberOfSatellites | ( | const MXM_5X_INSTANCE_s *const | kpkInstance | ) |
Get number of satellites.
Getter-function for the number of satellites (variable MXM_5X_INSTANCE::numberOfSatellites).
[in] | kpkInstance | pointer to the state struct |
Definition at line 364 of file mxm_battery_management.c.
STD_RETURN_TYPE_e MXM_5XGetNumberOfSatellitesGood | ( | const MXM_5X_INSTANCE_s *const | kpkInstance | ) |
Get the value of MXM_5X_INSTANCE::numberOfSatellitesIsGood.
[in] | kpkInstance | pointer to the instance struct |
Definition at line 368 of file mxm_battery_management.c.
STD_RETURN_TYPE_e MXM_5XGetRXBuffer | ( | const MXM_5X_INSTANCE_s *const | kpkInstance, |
uint8_t * | rxBuffer, | ||
uint16_t | rxBufferLength | ||
) |
Copy RX buffer into variable.
This function copies the RX buffer which is locally available in the MXM_5XStateMachine() into a supplied array pointer. It will make sure that both the length of the local as also the supplied length of the RX buffer are not violated. In case of the supplied RX buffer being longer than the locally available one, the remaining entries of the buffer will be filled with 0.
[in,out] | kpkInstance | pointer to the state-struct |
[in] | rxBuffer | array-pointer to a RX buffer that shall be filled |
[in] | rxBufferLength | length of the supplied array |
Definition at line 339 of file mxm_battery_management.c.
|
static |
Check if a register address is user accessible.
Checks if a register address is inside the user accessible memory range. This range is specified in the datasheet of the monitoring IC as following:
[in] | regAddress | register address to be checked |
Definition at line 189 of file mxm_battery_management.c.
STD_RETURN_TYPE_e MXM_5XSetStateRequest | ( | MXM_5X_INSTANCE_s * | pInstance5x, |
MXM_STATEMACHINE_5X_e | state, | ||
MXM_5X_COMMAND_PAYLOAD_s | commandPayload, | ||
MXM_5X_STATE_REQUEST_STATUS_e * | processed | ||
) |
Set state request for the Battery Management Statemachine.
This function sets the state requests for the MXM_5XStateMachine().
[in,out] | pInstance5x | pointer to the 5x state |
[in] | state | State that is requested |
[in] | commandPayload | additional payload that is handled by the state |
[in,out] | processed | pointer to the status of the request |
Definition at line 372 of file mxm_battery_management.c.
void MXM_5XStateMachine | ( | MXM_41B_INSTANCE_s * | pInstance41b, |
MXM_5X_INSTANCE_s * | pInstance5x | ||
) |
Execute state-machine for Battery Management Protocol.
This function executes the state-machine that exposes an interface for the Maxim Battery Management Protocol for monitoring ICs of the MAX1785x family.
Definition at line 404 of file mxm_battery_management.c.
STD_RETURN_TYPE_e must_check_return MXM_5XUserAccessibleAddressSpaceCheckerSelfCheck | ( | void | ) |
runs a selfcheck for the address space check
Runs a selfcheck for the function which is checking if a register address is inside the user accessible address space of the monitoring IC.
Definition at line 971 of file mxm_battery_management.c.