foxBMS  1.1.1
The foxBMS Battery Management System API Documentation
can_helper.h File Reference

Headers for the helper functions for the CAN module. More...

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

Go to the source code of this file.

Data Structures

struct  CAN_SIGNAL_TYPE
 

Macros

#define CAN_BYTE_0_POSITION   (0u)
 
#define CAN_BYTE_1_POSITION   (1u)
 
#define CAN_BYTE_2_POSITION   (2u)
 
#define CAN_BYTE_3_POSITION   (3u)
 
#define CAN_BYTE_4_POSITION   (4u)
 
#define CAN_BYTE_5_POSITION   (5u)
 
#define CAN_BYTE_6_POSITION   (6u)
 
#define CAN_BYTE_7_POSITION   (7u)
 

Typedefs

typedef struct CAN_SIGNAL_TYPE CAN_SIGNAL_TYPE_s
 

Functions

void CAN_TxPrepareSignalData (float *pSignal, CAN_SIGNAL_TYPE_s signalProperties)
 Prepare signal data. This function takes the signal data and applies factor, applies offset and compares with signal minimum and maximum values. More...
 
void CAN_RxConvertRawSignalData (float *pSignalConverted, float signalRaw, CAN_SIGNAL_TYPE_s signalProperties)
 Convert raw signal data. This function takes the raw signal data and applies offset and factor to convert the raw value. More...
 
void CAN_TxSetMessageDataWithSignalData (uint64_t *pMessage, uint64_t bitStart, uint8_t bitLength, uint64_t canSignal, CAN_ENDIANNESS_e endianness)
 Puts CAN signal data in a 64-bit variable. This function is used to compose a 64-bit CAN message. It takes signal data, signal bit start, signal bit length and puts the data in the 64-bit variable. More...
 
void CAN_TxSetCanDataWithMessageData (uint64_t message, uint8_t *pCanData, CAN_ENDIANNESS_e endianness)
 Copy CAN data from a 64-bit variable to 8 bytes. This function is used to copy a 64-bit CAN message to 8 bytes. More...
 
void CAN_RxGetSignalDataFromMessageData (uint64_t message, uint64_t bitStart, uint8_t bitLength, uint64_t *pCanSignal, CAN_ENDIANNESS_e endianness)
 Gets CAN signal data from a 64-bit variable. This function is used to get signal data from a 64-bit CAN message. It takes signal bit start, signal bit length and extract signal data from the the 64-bit variable. More...
 
void CAN_RxGetMessageDataFromCanData (uint64_t *pMessage, const uint8_t *const kpkCanData, CAN_ENDIANNESS_e endianness)
 Copy CAN data from 8 bytes to a 64-bit variable. More...
 

Detailed Description

Headers for the helper functions for the CAN module.

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
2021-04-22 (date of creation)
Updated
2021-06-24 (date of last update)
Prefix
CAN

Definition in file can_helper.h.

Macro Definition Documentation

◆ CAN_BYTE_0_POSITION

#define CAN_BYTE_0_POSITION   (0u)

position for CAN byte 0 to 7

Definition at line 68 of file can_helper.h.

◆ CAN_BYTE_1_POSITION

#define CAN_BYTE_1_POSITION   (1u)

position for CAN byte 0 to 7

Definition at line 69 of file can_helper.h.

◆ CAN_BYTE_2_POSITION

#define CAN_BYTE_2_POSITION   (2u)

position for CAN byte 0 to 7

Definition at line 70 of file can_helper.h.

◆ CAN_BYTE_3_POSITION

#define CAN_BYTE_3_POSITION   (3u)

position for CAN byte 0 to 7

Definition at line 71 of file can_helper.h.

◆ CAN_BYTE_4_POSITION

#define CAN_BYTE_4_POSITION   (4u)

position for CAN byte 0 to 7

Definition at line 72 of file can_helper.h.

◆ CAN_BYTE_5_POSITION

#define CAN_BYTE_5_POSITION   (5u)

position for CAN byte 0 to 7

Definition at line 73 of file can_helper.h.

◆ CAN_BYTE_6_POSITION

#define CAN_BYTE_6_POSITION   (6u)

position for CAN byte 0 to 7

Definition at line 74 of file can_helper.h.

◆ CAN_BYTE_7_POSITION

#define CAN_BYTE_7_POSITION   (7u)

position for CAN byte 0 to 7

Definition at line 75 of file can_helper.h.

Typedef Documentation

◆ CAN_SIGNAL_TYPE_s

type definition for fields of a CAN signal

Function Documentation

◆ CAN_RxConvertRawSignalData()

void CAN_RxConvertRawSignalData ( float *  pSignalConverted,
float  signalRaw,
CAN_SIGNAL_TYPE_s  signalProperties 
)

Convert raw signal data. This function takes the raw signal data and applies offset and factor to convert the raw value.

Parameters
[out]pSignalConvertedcoverted signal data
[in]signalRawraw signal data
[in]signalPropertiessignal properties (factor, offset, min, max)

Definition at line 160 of file can_helper.c.

◆ CAN_RxGetMessageDataFromCanData()

void CAN_RxGetMessageDataFromCanData ( uint64_t *  pMessage,
const uint8_t *const  kpkCanData,
CAN_ENDIANNESS_e  endianness 
)

Copy CAN data from 8 bytes to a 64-bit variable.

This function is used to copy data from a 64-bit variable to 8 bytes.

Parameters
[in]pMessage64-bit where the data is copied
[out]kpkCanData8 bytes containing the data
[in]endiannessbig or little endianness of data

Definition at line 288 of file can_helper.c.

◆ CAN_RxGetSignalDataFromMessageData()

void CAN_RxGetSignalDataFromMessageData ( uint64_t  message,
uint64_t  bitStart,
uint8_t  bitLength,
uint64_t *  pCanSignal,
CAN_ENDIANNESS_e  endianness 
)

Gets CAN signal data from a 64-bit variable. This function is used to get signal data from a 64-bit CAN message. It takes signal bit start, signal bit length and extract signal data from the the 64-bit variable.

Parameters
[in]message64-bit variable containing the CAN data
[in]bitStartstarting bit were the signal data must be put
[in]bitLengthlength of the signal data to be put in CAN message
[out]pCanSignalsignal data to be retrieved from message
[in]endiannessbig or little endianness of data

Definition at line 248 of file can_helper.c.

Here is the call graph for this function:

◆ CAN_TxPrepareSignalData()

void CAN_TxPrepareSignalData ( float *  pSignal,
CAN_SIGNAL_TYPE_s  signalProperties 
)

Prepare signal data. This function takes the signal data and applies factor, applies offset and compares with signal minimum and maximum values.

Parameters
[in,out]pSignalsignal data
[in]signalPropertiessignal properties (factor, offset, min, max)

Definition at line 141 of file can_helper.c.

◆ CAN_TxSetCanDataWithMessageData()

void CAN_TxSetCanDataWithMessageData ( uint64_t  message,
uint8_t *  pCanData,
CAN_ENDIANNESS_e  endianness 
)

Copy CAN data from a 64-bit variable to 8 bytes. This function is used to copy a 64-bit CAN message to 8 bytes.

Parameters
[in]message64-bit variable containing the CAN data
[out]pCanData8 bytes where the data is copied
[in]endiannessbig or little endianness of data

Definition at line 205 of file can_helper.c.

◆ CAN_TxSetMessageDataWithSignalData()

void CAN_TxSetMessageDataWithSignalData ( uint64_t *  pMessage,
uint64_t  bitStart,
uint8_t  bitLength,
uint64_t  canSignal,
CAN_ENDIANNESS_e  endianness 
)

Puts CAN signal data in a 64-bit variable. This function is used to compose a 64-bit CAN message. It takes signal data, signal bit start, signal bit length and puts the data in the 64-bit variable.

Parameters
[out]pMessage64-bit variable containing the CAN data
[in]bitStartstarting bit were the signal data must be put
[in]bitLengthlength of the signal data to be put in CAN message
[in]canSignalsignal data to be put in message
[in]endiannessbig or little endianness of data

Definition at line 166 of file can_helper.c.

Here is the call graph for this function: