foxBMS
1.1.1
The foxBMS Battery Management System API Documentation
|
Driver for the MC33775A monitoring chip. More...
#include "n775.h"
#include "HL_system.h"
#include "MC33775A.h"
#include "database.h"
#include "diag.h"
#include "mic_dma.h"
#include "os.h"
Go to the source code of this file.
Macros | |
#define | N775_MAX_SUPPORTED_CELLS (12u) |
#define | N775_SAVELASTSTATES() |
Functions | |
static void | N775_SetFirstMeasurementCycleFinished (N775_STATE_s *n775_state) |
sets the measurement initialization status. More... | |
static void | N775_CopyStructToTxBuffer (N775_MESSAGE_s *message, uint16_t *buffer) |
sends a write command to the daisy-chain. More... | |
static void | N775_WakeUp (uint16_t daisyChainAddress, uint16_t deviceAddress, uint16_t registerAddress) |
sends a wake-up command to the daisy-chain. More... | |
static void | N775_Write (uint16_t daisyChainAddress, uint16_t deviceAddress, uint16_t registerAddress, uint16_t data) |
sends a write command to the daisy-chain. More... | |
static void | N775_Read (uint16_t daisyChainAddress, uint16_t deviceAddress, uint16_t registerAddress, uint16_t totalNumberOfRequestedRegister) |
sends a read command to the daisy-chain. More... | |
static void | N775_Initialize_Database (void) |
in the database, initializes the fields related to the N775 driver. More... | |
static void | N775_StateTransition (N775_STATEMACH_e state, uint8_t subState, uint16_t timer_ms) |
function for setting N775_Trigger state transitions More... | |
uint16_t | n775_CrcAddItem (uint16_t remainder, uint16_t item) |
Called to calculate the CRC of a message. NXP function. More... | |
static N775_RETURN_TYPE_e | N775_CheckStateRequest (N775_STATE_REQUEST_e statereq) |
checks the state requests that are made. More... | |
uint16_t | n775_CalcCrc (const N775_MESSAGE_s *msg) |
Calculate the CRC of a message. NXP function. More... | |
uint8_t | N775_CheckReEntrance (void) |
re-entrance check of N775 state machine trigger function More... | |
uint8_t | TEST_N775_CheckReEntrance (void) |
N775_STATE_REQUEST_e | N775_GetStateRequest (void) |
gets the current state request. More... | |
N775_STATEMACH_e | N775_GetState (void) |
gets the current state. More... | |
N775_STATE_REQUEST_e | N775_TransferStateRequest () |
transfers the current state request to the state machine. More... | |
N775_RETURN_TYPE_e | N775_SetStateRequest (N775_STATE_REQUEST_e statereq) |
sets the current state request of the state variable n775_state. More... | |
void | N775_Trigger (void) |
trigger function for the N775 driver state machine. More... | |
bool | N775_IsFirstMeasurementCycleFinished (void) |
gets the measurement initialization status. More... | |
void | TEST_N775_SetFirstMeasurementCycleFinished (N775_STATE_s *n775_state) |
Variables | |
uint16_t | n775_RXbuffer [N775_MAX_N_BYTES_FOR_DATA_RECEPTION] = {0} |
uint16_t | n775_TXbuffer [N775_TX_MESSAGE_LENGTH] = {0} |
N775_MESSAGE_s | n775_sentData = {0} |
N775_MESSAGE_s | n775_receivedData = {0} |
uint8_t | n775_enumerateAddress = 1u |
N775_STATE_s | n775_state |
static DATA_BLOCK_CELL_VOLTAGE_s | n775_cellVoltage = {.header.uniqueId = DATA_BLOCK_ID_CELL_VOLTAGE_BASE} |
static DATA_BLOCK_CELL_TEMPERATURE_s | n775_cellTemperature = {.header.uniqueId = DATA_BLOCK_ID_CELL_TEMPERATURE_BASE} |
static DATA_BLOCK_MIN_MAX_s | n775_minMax = {.header.uniqueId = DATA_BLOCK_ID_MIN_MAX} |
static DATA_BLOCK_BALANCING_CONTROL_s | n775_balancingControl = {.header.uniqueId = DATA_BLOCK_ID_BALANCING_CONTROL} |
Driver for the MC33775A 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:
Definition in file n775.c.
#define N775_MAX_SUPPORTED_CELLS (12u) |
#define N775_SAVELASTSTATES | ( | ) |
Saves the last state and the last substate
uint16_t n775_CalcCrc | ( | const N775_MESSAGE_s * | msg | ) |
uint8_t N775_CheckReEntrance | ( | void | ) |
re-entrance check of N775 state machine trigger function
This function is not re-entrant and should only be called time- or event-triggered. It increments the triggerentry counter from the state variable n775_state. It should never be called by two different processes, so if it is the case, triggerentry should never be higher than 0 when this function is called.
Definition at line 274 of file n775.c.
|
static |
checks the state requests that are made.
This function checks the validity of the state requests. The results of the checked is returned immediately.
statereq | state request to be checked |
|
static |
uint16_t n775_CrcAddItem | ( | uint16_t | remainder, |
uint16_t | item | ||
) |
N775_STATEMACH_e N775_GetState | ( | void | ) |
N775_STATE_REQUEST_e N775_GetStateRequest | ( | void | ) |
|
static |
bool N775_IsFirstMeasurementCycleFinished | ( | void | ) |
|
static |
sends a read command to the daisy-chain.
daisyChainAddress | parameter CADD in the message format |
deviceAddress | parameter DADD in the message format lies between 1 and 62 |
registerAddress | address of first consecutive register to be read from |
totalNumberOfRequestedRegister | total number of registers values sent by daisy-chain lies between 1 and 256 |
Set Head part or WRITE message
Set Data head part or WRITE message
Set Data part or WRITE message
Set CRC part or WRITE message
Definition at line 705 of file n775.c.
|
static |
N775_RETURN_TYPE_e N775_SetStateRequest | ( | N775_STATE_REQUEST_e | statereq | ) |
sets the current state request of the state variable n775_state.
This function is used to make a state request to the state machine,e.g, start voltage measurement, read result of voltage measurement, re-initialization It calls N775_CheckStateRequest() to check if the request is valid. The state request is rejected if is not valid. The result of the check is returned immediately, so that the requester can act in case it made a non-valid state request.
statereq | state request to set |
Definition at line 339 of file n775.c.
|
static |
N775_STATE_REQUEST_e N775_TransferStateRequest | ( | ) |
transfers the current state request to the state machine.
This function takes the current state request from n775_state and transfers it to the state machine. It resets the value from n775_state to N775_STATE_NO_REQUEST
Definition at line 328 of file n775.c.
void N775_Trigger | ( | void | ) |
|
static |
sends a wake-up command to the daisy-chain.
daisyChainAddress | parameter CADD in the message format |
deviceAddress | parameter DADD in the message format lies between 1 and 62, 63 means all devices |
registerAddress | address of register to be written to |
Set Head part or WRITE message
Set Data head part or WRITE message
Set Data part or WRITE message
Set CRC part or WRITE message
Definition at line 584 of file n775.c.
|
static |
sends a write command to the daisy-chain.
daisyChainAddress | parameter CADD in the message format |
deviceAddress | parameter DADD in the message format lies between 1 and 62, 63 means all devices |
registerAddress | address of register to be written to |
data | data to be written in the device register |
Set Head part or WRITE message
Set Data head part or WRITE message
Set Data part or WRITE message
Set CRC part or WRITE message
Definition at line 643 of file n775.c.
uint8_t TEST_N775_CheckReEntrance | ( | void | ) |
void TEST_N775_SetFirstMeasurementCycleFinished | ( | N775_STATE_s * | n775_state | ) |
|
static |
|
static |
|
static |
|
static |
N775_MESSAGE_s n775_receivedData = {0} |
uint16_t n775_RXbuffer[N775_MAX_N_BYTES_FOR_DATA_RECEPTION] = {0} |
N775_MESSAGE_s n775_sentData = {0} |
N775_STATE_s n775_state |
Variable containing the state machine state for the MC33775A driver.
uint16_t n775_TXbuffer[N775_TX_MESSAGE_LENGTH] = {0} |