foxBMS - Unit Tests  1.2.0
The foxBMS Unit Tests API Documentation
mxm_bitextract.h File Reference

Bit extraction function for MXM_17841b. More...

#include "general.h"
Include dependency graph for mxm_bitextract.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define MXM_41B_REG_FALSE   ((MXM_41B_REG_BIT_VALUE)0x00u)
 
#define MXM_41B_REG_TRUE   ((MXM_41B_REG_BIT_VALUE)0x01u)
 
#define MXM_41B_REG_BAUD_RATE_500KBPS   ((MXM_41B_REG_BIT_VALUE)0x00u)
 
#define MXM_41B_REG_BAUD_RATE_500KBPS_ALT   ((MXM_41B_REG_BIT_VALUE)0x01u)
 
#define MXM_41B_REG_BAUD_RATE_1MBPS   ((MXM_41B_REG_BIT_VALUE)0x02u)
 
#define MXM_41B_REG_BAUD_RATE_2MBPS   ((MXM_41B_REG_BIT_VALUE)0x03u)
 
#define MXM_41B_REG_KEEP_ALIVE_0US   ((MXM_41B_REG_BIT_VALUE)0x00u)
 
#define MXM_41B_REG_KEEP_ALIVE_10US   ((MXM_41B_REG_BIT_VALUE)0x01u)
 
#define MXM_41B_REG_KEEP_ALIVE_20US   ((MXM_41B_REG_BIT_VALUE)0x02u)
 
#define MXM_41B_REG_KEEP_ALIVE_40US   ((MXM_41B_REG_BIT_VALUE)0x03u)
 
#define MXM_41B_REG_KEEP_ALIVE_80US   ((MXM_41B_REG_BIT_VALUE)0x04u)
 
#define MXM_41B_REG_KEEP_ALIVE_160US   ((MXM_41B_REG_BIT_VALUE)0x05u)
 
#define MXM_41B_REG_KEEP_ALIVE_320US   ((MXM_41B_REG_BIT_VALUE)0x06u)
 
#define MXM_41B_REG_KEEP_ALIVE_640US   ((MXM_41B_REG_BIT_VALUE)0x07u)
 
#define MXM_41B_REG_KEEP_ALIVE_1280US   ((MXM_41B_REG_BIT_VALUE)0x08u)
 
#define MXM_41B_REG_KEEP_ALIVE_2560US   ((MXM_41B_REG_BIT_VALUE)0x09u)
 
#define MXM_41B_REG_KEEP_ALIVE_5120US   ((MXM_41B_REG_BIT_VALUE)0x0Au)
 
#define MXM_41B_REG_KEEP_ALIVE_10240US   ((MXM_41B_REG_BIT_VALUE)0x0Bu)
 
#define MXM_41B_REG_KEEP_ALIVE_INF_DLY   ((MXM_41B_REG_BIT_VALUE)0x0Fu)
 
#define MXM_REG_MASK(start, end)   (((1u << ((end) - (start) + 1u)) - 1u) << (start))
 define for creating a bitmask More...
 
#define MXM_41B_TX_PREAMBLES   ((MXM_41B_REG_BITS)5u)
 
#define MXM_41B_KEEP_ALIVE   ((MXM_41B_REG_BITS)0u)
 
#define MXM_41B_RX_ERROR   ((MXM_41B_REG_BITS)7u)
 
#define MXM_41B_RX_BUSY_STATUS   ((MXM_41B_REG_BITS)5u)
 
#define MXM_41B_RX_OVERFLOW_INT_ENABLE   ((MXM_41B_REG_BITS)3u)
 
#define MXM_41B_RX_STOP_STATUS   ((MXM_41B_REG_BITS)1u)
 
#define MXM_41B_RX_EMPTY_STATUS   ((MXM_41B_REG_BITS)0u)
 

Typedefs

typedef uint8_t MXM_41B_REG_BIT_VALUE
 Bit-values for registers. More...
 
typedef uint8_t MXM_41B_REG_BITS
 

Functions

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...
 
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...
 

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.h.

Macro Definition Documentation

◆ MXM_41B_KEEP_ALIVE

#define MXM_41B_KEEP_ALIVE   ((MXM_41B_REG_BITS)0u)

bit for the feature Keep Alive

Definition at line 119 of file mxm_bitextract.h.

◆ MXM_41B_REG_BAUD_RATE_1MBPS

#define MXM_41B_REG_BAUD_RATE_1MBPS   ((MXM_41B_REG_BIT_VALUE)0x02u)

bit sequence for baud rate 1MBps

Definition at line 79 of file mxm_bitextract.h.

◆ MXM_41B_REG_BAUD_RATE_2MBPS

#define MXM_41B_REG_BAUD_RATE_2MBPS   ((MXM_41B_REG_BIT_VALUE)0x03u)

bit sequence for baud rate 2MBps

Definition at line 81 of file mxm_bitextract.h.

◆ MXM_41B_REG_BAUD_RATE_500KBPS

#define MXM_41B_REG_BAUD_RATE_500KBPS   ((MXM_41B_REG_BIT_VALUE)0x00u)

bit sequence for baud rate 500KBps

Definition at line 75 of file mxm_bitextract.h.

◆ MXM_41B_REG_BAUD_RATE_500KBPS_ALT

#define MXM_41B_REG_BAUD_RATE_500KBPS_ALT   ((MXM_41B_REG_BIT_VALUE)0x01u)

alternative bit sequence for baud rate 500KBps

Definition at line 77 of file mxm_bitextract.h.

◆ MXM_41B_REG_FALSE

#define MXM_41B_REG_FALSE   ((MXM_41B_REG_BIT_VALUE)0x00u)

one bit, 0u

Definition at line 71 of file mxm_bitextract.h.

◆ MXM_41B_REG_KEEP_ALIVE_0US

#define MXM_41B_REG_KEEP_ALIVE_0US   ((MXM_41B_REG_BIT_VALUE)0x00u)

bit sequence for a keep alive period of 0µs

Definition at line 83 of file mxm_bitextract.h.

◆ MXM_41B_REG_KEEP_ALIVE_10240US

#define MXM_41B_REG_KEEP_ALIVE_10240US   ((MXM_41B_REG_BIT_VALUE)0x0Bu)

bit sequence for a keep alive period of 10240µs

Definition at line 105 of file mxm_bitextract.h.

◆ MXM_41B_REG_KEEP_ALIVE_10US

#define MXM_41B_REG_KEEP_ALIVE_10US   ((MXM_41B_REG_BIT_VALUE)0x01u)

bit sequence for a keep alive period of 10µs

Definition at line 85 of file mxm_bitextract.h.

◆ MXM_41B_REG_KEEP_ALIVE_1280US

#define MXM_41B_REG_KEEP_ALIVE_1280US   ((MXM_41B_REG_BIT_VALUE)0x08u)

bit sequence for a keep alive period of 1280µs

Definition at line 99 of file mxm_bitextract.h.

◆ MXM_41B_REG_KEEP_ALIVE_160US

#define MXM_41B_REG_KEEP_ALIVE_160US   ((MXM_41B_REG_BIT_VALUE)0x05u)

bit sequence for a keep alive period of 160µs

Definition at line 93 of file mxm_bitextract.h.

◆ MXM_41B_REG_KEEP_ALIVE_20US

#define MXM_41B_REG_KEEP_ALIVE_20US   ((MXM_41B_REG_BIT_VALUE)0x02u)

bit sequence for a keep alive period of 20µs

Definition at line 87 of file mxm_bitextract.h.

◆ MXM_41B_REG_KEEP_ALIVE_2560US

#define MXM_41B_REG_KEEP_ALIVE_2560US   ((MXM_41B_REG_BIT_VALUE)0x09u)

bit sequence for a keep alive period of 2560µs

Definition at line 101 of file mxm_bitextract.h.

◆ MXM_41B_REG_KEEP_ALIVE_320US

#define MXM_41B_REG_KEEP_ALIVE_320US   ((MXM_41B_REG_BIT_VALUE)0x06u)

bit sequence for a keep alive period of 320µs

Definition at line 95 of file mxm_bitextract.h.

◆ MXM_41B_REG_KEEP_ALIVE_40US

#define MXM_41B_REG_KEEP_ALIVE_40US   ((MXM_41B_REG_BIT_VALUE)0x03u)

bit sequence for a keep alive period of 40µs

Definition at line 89 of file mxm_bitextract.h.

◆ MXM_41B_REG_KEEP_ALIVE_5120US

#define MXM_41B_REG_KEEP_ALIVE_5120US   ((MXM_41B_REG_BIT_VALUE)0x0Au)

bit sequence for a keep alive period of 5120µs

Definition at line 103 of file mxm_bitextract.h.

◆ MXM_41B_REG_KEEP_ALIVE_640US

#define MXM_41B_REG_KEEP_ALIVE_640US   ((MXM_41B_REG_BIT_VALUE)0x07u)

bit sequence for a keep alive period of 640µs

Definition at line 97 of file mxm_bitextract.h.

◆ MXM_41B_REG_KEEP_ALIVE_80US

#define MXM_41B_REG_KEEP_ALIVE_80US   ((MXM_41B_REG_BIT_VALUE)0x04u)

bit sequence for a keep alive period of 80µs

Definition at line 91 of file mxm_bitextract.h.

◆ MXM_41B_REG_KEEP_ALIVE_INF_DLY

#define MXM_41B_REG_KEEP_ALIVE_INF_DLY   ((MXM_41B_REG_BIT_VALUE)0x0Fu)

bit sequence for a infinite keep alive period (disabled)

Definition at line 107 of file mxm_bitextract.h.

◆ MXM_41B_REG_TRUE

#define MXM_41B_REG_TRUE   ((MXM_41B_REG_BIT_VALUE)0x01u)

one bit, 1u

Definition at line 73 of file mxm_bitextract.h.

◆ MXM_41B_RX_BUSY_STATUS

#define MXM_41B_RX_BUSY_STATUS   ((MXM_41B_REG_BITS)5u)

bit for the RX Busy Status

Definition at line 123 of file mxm_bitextract.h.

◆ MXM_41B_RX_EMPTY_STATUS

#define MXM_41B_RX_EMPTY_STATUS   ((MXM_41B_REG_BITS)0u)

bit for the RX Empty Status

Definition at line 129 of file mxm_bitextract.h.

◆ MXM_41B_RX_ERROR

#define MXM_41B_RX_ERROR   ((MXM_41B_REG_BITS)7u)

bit for the RX Error

Definition at line 121 of file mxm_bitextract.h.

◆ MXM_41B_RX_OVERFLOW_INT_ENABLE

#define MXM_41B_RX_OVERFLOW_INT_ENABLE   ((MXM_41B_REG_BITS)3u)

bit for the feature RX Overflow Interrupt

Definition at line 125 of file mxm_bitextract.h.

◆ MXM_41B_RX_STOP_STATUS

#define MXM_41B_RX_STOP_STATUS   ((MXM_41B_REG_BITS)1u)

bit for the RX Stop Status

Definition at line 127 of file mxm_bitextract.h.

◆ MXM_41B_TX_PREAMBLES

#define MXM_41B_TX_PREAMBLES   ((MXM_41B_REG_BITS)5u)

bit for the feature TX Preambles

Definition at line 117 of file mxm_bitextract.h.

◆ MXM_REG_MASK

#define MXM_REG_MASK (   start,
  end 
)    (((1u << ((end) - (start) + 1u)) - 1u) << (start))

define for creating a bitmask

Definition at line 112 of file mxm_bitextract.h.

Typedef Documentation

◆ MXM_41B_REG_BIT_VALUE

typedef uint8_t MXM_41B_REG_BIT_VALUE

Bit-values for registers.

Definition at line 69 of file mxm_bitextract.h.

◆ MXM_41B_REG_BITS

typedef uint8_t MXM_41B_REG_BITS

types for bits in the register of MAX17841B

Definition at line 115 of file mxm_bitextract.h.

Function Documentation

◆ 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: