foxBMS-UnitTests
1.0.0
The foxBMS Unit Tests API Documentation
|
This is a collection of helper functions for the MAX1785x ICs. More...
#include "mxm_cfg.h"
#include "mxm_basic_defines.h"
#include "mxm_battery_management.h"
#include "mxm_register_map.h"
Go to the source code of this file.
Data Structures | |
struct | MXM_SELFCHECK |
struct | MXM_REGISTRY_ENTRY |
struct | MXM_MONITORING_INSTANCE |
Macros | |
#define | MXM_RX_BUFFER_LENGTH 100 |
Length of RX buffer. More... | |
Typedefs | |
typedef enum MXM_STATEMACHINE_STATES | MXM_STATEMACHINE_STATES_e |
States of the global Maxim state-machine. More... | |
typedef enum MXM_STATEMACHINE_OPERATION_STATES_e | MXM_STATEMACHINE_OPERATION_STATES_e |
typedef enum MXM_MONITORING_STATE | MXM_MONINTORING_STATE_e |
typedef struct MXM_SELFCHECK | MXM_SELFCHECK_s |
typedef struct MXM_REGISTRY_ENTRY | MXM_REGISTRY_ENTRY_s |
typedef struct MXM_MONITORING_INSTANCE | MXM_MONITORING_INSTANCE_s |
Functions | |
void | MXM_Convert (uint8_t lsb, uint8_t msb, uint16_t *pTarget, MXM_CONVERSION_TYPE_e convType, uint32_t fullScaleReference_mV) |
Convert a measurement value to a voltage value. More... | |
STD_RETURN_TYPE_e must_check_return | MXM_ConvertTest (void) |
Test the MXM_Convert()-function. More... | |
void | MXM_ExtractValueFromRegister (uint8_t lsb, uint8_t msb, MXM_REG_BM bitmask, uint16_t *pValue) |
Extract a value from a single register. More... | |
STD_RETURN_TYPE_e must_check_return | MXM_ExtractValueFromRegisterTest (void) |
Test MXM_ExtractValueFromRegister(). More... | |
uint8_t | MXM_FirstSetBit (uint16_t bitmask) |
Find Position of first set bit in bitmask. More... | |
STD_RETURN_TYPE_e must_check_return | MXM_FirstSetBitTest (void) |
Test MXM_FirstSetBit(). More... | |
void | MXM_Unipolar14BitInto16Bit (uint16_t inputValue, uint8_t *lsb, uint8_t *msb) |
convert a unipolar 14bit-value and shifts it into the 16bit-format More... | |
uint16_t | MXM_VoltageIntoUnipolar14Bit (uint16_t voltage_mV, uint16_t fullscaleReference_mV) |
convert a voltage value into a unipolar 14bit value More... | |
void | MXM_ConvertModuleToString (const uint16_t moduleNumber, uint8_t *pStringNumber, uint16_t *pModuleNumberInString) |
Get the string and module number from a global module number. More... | |
This is a collection of helper functions for the MAX1785x ICs.
BSD 3-Clause License 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:
″This product uses parts of foxBMS®″
″This product includes parts of foxBMS®″
″This product is derived from foxBMS®″
This collection of helper functions for the MAX1785x ICs helps to calculate the lsb and msb for register values and similar tasks.
Definition in file mxm_1785x_tools.h.
#define MXM_RX_BUFFER_LENGTH 100 |
Length of RX buffer.
This define describes the length of the array MXM_MONITORING_INSTANCE_s::rxBuffer. It is large enough to fit the largest message that can be written into a single buffer which consists of 6 command bytes and MXM_MAXIMUM_NR_OF_MODULES times 2 receive bytes for the maximum number of connected monitoring ICs.
Definition at line 185 of file mxm_1785x_tools.h.
typedef enum MXM_MONITORING_STATE MXM_MONINTORING_STATE_e |
intermediate state-definition for MXM_MonGetVoltages()
typedef struct MXM_MONITORING_INSTANCE MXM_MONITORING_INSTANCE_s |
Status of the Maxim-main-state-machine.
typedef struct MXM_REGISTRY_ENTRY MXM_REGISTRY_ENTRY_s |
struct describing an entry into the monitoring registry
typedef struct MXM_SELFCHECK MXM_SELFCHECK_s |
struct describing the different return values of selfchecks that the driver can execute
states of the MXM_StateMachineOperation() statemachine
typedef enum MXM_STATEMACHINE_STATES MXM_STATEMACHINE_STATES_e |
States of the global Maxim state-machine.
State transitions are currently autonomous and will have to be integrated into the Battery System state-machine.
enum MXM_MONITORING_STATE |
intermediate state-definition for MXM_MonGetVoltages()
Definition at line 142 of file mxm_1785x_tools.h.
states of the MXM_StateMachineOperation() statemachine
Definition at line 85 of file mxm_1785x_tools.h.
States of the global Maxim state-machine.
State transitions are currently autonomous and will have to be integrated into the Battery System state-machine.
Definition at line 74 of file mxm_1785x_tools.h.
void MXM_Convert | ( | uint8_t | lsb, |
uint8_t | msb, | ||
uint16_t * | pTarget, | ||
MXM_CONVERSION_TYPE_e | convType, | ||
uint32_t | fullScaleReference_mV | ||
) |
Convert a measurement value to a voltage value.
This function converts measurement values from the monitoring IC into a voltage value. It assumes that measurement values are spread over the LSB and MSB according to the datasheet. This means that the two lowest bits are 0 and the 14-bit measurement is spread over the 14 highest bits.
The conversion type describes the kind of measurement that has been executed.
[in] | lsb | LSB of the value |
[in] | msb | MSB of the value |
[out] | pTarget | pointer in which the converted value shall be written |
[in] | convType | type of conversion (bipolar or unipolar) |
[in] | fullScaleReference_mV | reference voltage of full scale (for voltage measurements 5000) |
Definition at line 98 of file mxm_1785x_tools.c.
void MXM_ConvertModuleToString | ( | const uint16_t | moduleNumber, |
uint8_t * | pStringNumber, | ||
uint16_t * | pModuleNumberInString | ||
) |
Get the string and module number from a global module number.
Maxim driver knows only one string internally and maps on demand this one string onto several strings (for instances where several modules are in the same daisy-chain but belong to different strings).
This function assumes that a string contains BS_NR_OF_MODULES modules in BS_NR_OF_STRINGS strings and that they are connected in a daisy-chain.
[in] | moduleNumber | number of the module in the daisy-chain (starts with 0) |
[out] | pStringNumber | pointer where the string number will be written |
[out] | pModuleNumberInString | module number in the string |
Definition at line 224 of file mxm_1785x_tools.c.
STD_RETURN_TYPE_e must_check_return MXM_ConvertTest | ( | void | ) |
Test the MXM_Convert()-function.
This test-function is intended as a self-check. It tests whether the MXM_Convert()-function computes the values as expected.
Definition at line 127 of file mxm_1785x_tools.c.
void MXM_ExtractValueFromRegister | ( | uint8_t | lsb, |
uint8_t | msb, | ||
MXM_REG_BM | bitmask, | ||
uint16_t * | pValue | ||
) |
Extract a value from a single register.
This function extracts a single value from a single register. The register has to be supplied as MSB and LSB. The bitmask has to be of type MXM_REG_BM. The extracted value will be written into value.
The function can only extract values from single registers (MSB and LSB)and does not handle values that span multiple registers.
[in] | lsb | least significant byte of the register |
[in] | msb | most significant byte of the register |
[in] | bitmask | bitmask for the value |
[out] | pValue | pointer to a variable in which the value should be written |
Definition at line 157 of file mxm_1785x_tools.c.
STD_RETURN_TYPE_e must_check_return MXM_ExtractValueFromRegisterTest | ( | void | ) |
Test MXM_ExtractValueFromRegister().
Self-check that tests whether MXM_ExtractValueFromRegister() works as expected.
Definition at line 176 of file mxm_1785x_tools.c.
uint8_t MXM_FirstSetBit | ( | uint16_t | bitmask | ) |
Find Position of first set bit in bitmask.
Searches a bitmask starting from the lowest bit and returns the position of the first set bit.
[in] | bitmask | bitmask that should be searched |
Definition at line 73 of file mxm_1785x_tools.c.
STD_RETURN_TYPE_e must_check_return MXM_FirstSetBitTest | ( | void | ) |
Test MXM_FirstSetBit().
Tests the function MXM_FirstSetBit() if it works as expected.
Definition at line 85 of file mxm_1785x_tools.c.
void MXM_Unipolar14BitInto16Bit | ( | uint16_t | inputValue, |
uint8_t * | lsb, | ||
uint8_t * | msb | ||
) |
convert a unipolar 14bit-value and shifts it into the 16bit-format
Takes a value in the unipolar 14bit format and transforms it into a 16bit register entry for the monitoring IC (separated into LSB and MSB).
[in] | inputValue | unipolar 14bit-value |
[out] | lsb | LSB in 16bit-format |
[out] | msb | MSB in 16bit-format |
Definition at line 205 of file mxm_1785x_tools.c.
uint16_t MXM_VoltageIntoUnipolar14Bit | ( | uint16_t | voltage_mV, |
uint16_t | fullscaleReference_mV | ||
) |
convert a voltage value into a unipolar 14bit value
Takes a voltage value in mV together with a reference for fullscale values into a unipolar 14bit value.
[in] | voltage_mV | voltage in mV |
[in] | fullscaleReference_mV | value of the fullscale in mV; typically 5000 |
Definition at line 216 of file mxm_1785x_tools.c.