foxBMS  1.2.0
The foxBMS Battery Management System API Documentation
mxm_bitextract.c File Reference

Bit extraction function for mxm_17841b. More...

#include "mxm_bitextract.h"
Include dependency graph for mxm_bitextract.c:

Go to the source code of this file.

Functions

static MXM_41B_REG_BIT_VALUE bitValue (MXM_41B_REG_BIT_VALUE value, uint8_t numberOfBits, MXM_41B_REG_BITS position, MXM_41B_REG_BITS shift)
 Extract a bit value function. More...
 
MXM_41B_REG_BIT_VALUE mxm_41bReadValue (uint8_t reg, uint8_t numberOfBits, MXM_41B_REG_BITS position)
 read a value from a register supplied as variable More...
 
MXM_41B_REG_BIT_VALUE mxm_41bWriteValue (MXM_41B_REG_BIT_VALUE value, uint8_t numberOfBits, MXM_41B_REG_BITS shift, uint8_t reg)
 write a value to a register supplied as variable More...
 

Detailed Description

Bit extraction function for mxm_17841b.

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:

  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 of the copyright holder 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 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®″
Author
foxBMS Team
Date
2019-01-15 (date of creation)
Updated
2020-05-14 (date of last update)
Prefix
MXM

This module supplies a specific bit extraction functionality to read & write into status registers. The different statuses that are read from or write into are indicated in the enum. Battery monitoring driver for MAX1785x battery monitoring ICs.

Definition in file mxm_bitextract.c.

Function Documentation

◆ bitValue()

static MXM_41B_REG_BIT_VALUE bitValue ( MXM_41B_REG_BIT_VALUE  value,
uint8_t  numberOfBits,
MXM_41B_REG_BITS  position,
MXM_41B_REG_BITS  shift 
)
static

Extract a bit value function.

The function is used to extract some number of bits (numOfBits) from a position (pos) to write or read from the configuration and status registers.

Parameters
[in]valuevalue of the bits that shall be written or read
[in]numberOfBitsnumber of bits to be extracted from the value register
[in]positionposition of bits to be extracted from the value register, start from right to left
[in]shiftnumber of bit-shift to the left for read function the shift value is zero.
Returns
bit values for registers

Definition at line 90 of file mxm_bitextract.c.

◆ mxm_41bReadValue()

MXM_41B_REG_BIT_VALUE mxm_41bReadValue ( uint8_t  reg,
uint8_t  numberOfBits,
MXM_41B_REG_BITS  position 
)

read a value from a register supplied as variable

This function takes a register (reg), and extracts the data described by its length in bits (numberOfBits) and position (pos). This value is then returned.

Parameters
[in]regvalue of the register to be read
[in]numberOfBitslength og the bit sequence in bits
[in]positionstart position of the bit sequence
Returns
the isolated and shifted bit value

Definition at line 101 of file mxm_bitextract.c.

Here is the call graph for this function:

◆ mxm_41bWriteValue()

MXM_41B_REG_BIT_VALUE mxm_41bWriteValue ( MXM_41B_REG_BIT_VALUE  value,
uint8_t  numberOfBits,
MXM_41B_REG_BITS  shift,
uint8_t  reg 
)

write a value to a register supplied as variable

This function takes a register (reg), writes the data described by numberOFBits, shift and value to the register value and returns the updated register.

Parameters
[in]valueregister value that should be written to the register
[in]numberOfBitslength of the entry that should be written in bits
[in]shiftstart position in the register in bits
[in]regcomplete value of the register
Returns
updated value of the register

Definition at line 105 of file mxm_bitextract.c.

Here is the call graph for this function: