foxBMS - Unit Tests  1.3.0
The foxBMS Unit Tests 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_s
 

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)
 

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...
 
uint8_t CAN_ConvertBooleanToInteger (bool input)
 Transform a bool to a bit (set if true) 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
2022-05-30 (date of last update)
Version
v1.3.0
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 69 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 70 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 71 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 72 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 73 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 74 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 75 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 76 of file can_helper.h.

Function Documentation

◆ CAN_ConvertBooleanToInteger()

uint8_t CAN_ConvertBooleanToInteger ( bool  input)

Transform a bool to a bit (set if true)

Parameters
[in]inputinput boolean (true will become 1u)
Returns
unsigned integer indicating the state of the input

Definition at line 336 of file can_helper.c.

◆ 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 161 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 289 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 249 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 142 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 206 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 167 of file can_helper.c.

Here is the call graph for this function: