foxBMS - Unit Tests
1.5.0
The foxBMS Unit Tests API Documentation
|
Database module header. More...
#include "database_cfg.h"
#include "database_helper.h"
#include "fstd_types.h"
#include "os.h"
#include <stdint.h>
Go to the source code of this file.
Data Structures | |
struct | DATA_QUEUE_MESSAGE_s |
Macros | |
#define | DATA_MAX_ENTRIES_PER_ACCESS (4u) |
#define | DATA_ENTRY_0 (0u) |
#define | DATA_ENTRY_1 (1u) |
#define | DATA_ENTRY_2 (2u) |
#define | DATA_ENTRY_3 (3u) |
#define | GET_MACRO(_1, _2, _3, _4, NAME, ...) (NAME) |
#define | DATA_READ_DATA(...) |
#define | DATA_WRITE_DATA(...) |
#define | DATA_DUMMY_VALUE_UINT8_T_ALTERNATING_BIT_PATTERN ((uint8_t)0xAAu) |
Enumerations | |
enum | DATA_BLOCK_ACCESS_TYPE_e { DATA_WRITE_ACCESS , DATA_READ_ACCESS } |
data block access types (read or write) More... | |
Functions | |
void | DATA_DummyFunction (void) |
Dummy void function of the database module. More... | |
STD_RETURN_TYPE_e | DATA_Initialize (void) |
Initialization of database manager. More... | |
void | DATA_Task (void) |
trigger of database manager More... | |
STD_RETURN_TYPE_e | DATA_Write1DataBlock (void *pDataFromSender0) |
Stores one data block in database. More... | |
STD_RETURN_TYPE_e | DATA_Write2DataBlocks (void *pDataFromSender0, void *pDataFromSender1) |
Stores two data blocks in database. More... | |
STD_RETURN_TYPE_e | DATA_Write3DataBlocks (void *pDataFromSender0, void *pDataFromSender1, void *pDataFromSender2) |
Stores three data blocks in database. More... | |
STD_RETURN_TYPE_e | DATA_Write4DataBlocks (void *pDataFromSender0, void *pDataFromSender1, void *pDataFromSender2, void *pDataFromSender3) |
Stores four data blocks in database. More... | |
STD_RETURN_TYPE_e | DATA_Read1DataBlock (void *pDataToReceiver0) |
Reads one data block in database by value. More... | |
STD_RETURN_TYPE_e | DATA_Read2DataBlocks (void *pDataToReceiver0, void *pDataToReceiver1) |
Reads two data blocks in database by value. More... | |
STD_RETURN_TYPE_e | DATA_Read3DataBlocks (void *pDataToReceiver0, void *pDataToReceiver1, void *pDataToReceiver2) |
Reads three data blocks in database by value. More... | |
STD_RETURN_TYPE_e | DATA_Read4DataBlocks (void *pDataToReceiver0, void *pDataToReceiver1, void *pDataToReceiver2, void *pDataToReceiver3) |
Reads four data blocks in database by value. More... | |
void | DATA_ExecuteDataBist (void) |
Executes a built-in self-test for the database module. More... | |
Database module header.
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:
Provides interfaces to database module
Definition in file database.h.
#define DATA_DUMMY_VALUE_UINT8_T_ALTERNATING_BIT_PATTERN ((uint8_t)0xAAu) |
dummy value for the built-in self-test (alternating bit pattern)
Definition at line 115 of file database.h.
#define DATA_ENTRY_0 (0u) |
Definition at line 77 of file database.h.
#define DATA_ENTRY_1 (1u) |
Definition at line 78 of file database.h.
#define DATA_ENTRY_2 (2u) |
Definition at line 79 of file database.h.
#define DATA_ENTRY_3 (3u) |
Definition at line 80 of file database.h.
#define DATA_MAX_ENTRIES_PER_ACCESS (4u) |
Maximum number of database entries that can be read or written during one access call to the database
Definition at line 75 of file database.h.
#define DATA_READ_DATA | ( | ... | ) |
variadic macro for read access to the database
Definition at line 86 of file database.h.
#define DATA_WRITE_DATA | ( | ... | ) |
variadic macro for write access to the database
Definition at line 96 of file database.h.
#define GET_MACRO | ( | _1, | |
_2, | |||
_3, | |||
_4, | |||
NAME, | |||
... | |||
) | (NAME) |
helper macro for the variadic macros for read and write functions
Definition at line 84 of file database.h.
data block access types (read or write)
Enumerator | |
---|---|
DATA_WRITE_ACCESS | write access to data block |
DATA_READ_ACCESS | read access to data block |
Definition at line 109 of file database.h.
void DATA_DummyFunction | ( | void | ) |
Dummy void function of the database module.
This function is needed in the database module in order to implement the DATA_READ_DATA() and DATA_WRITE_DATA() in a ISO C99 standard compatible way. The invocation of a macro that accepts a variable number of arguments (and this is the case for DATA_READ_DATA() and DATA_WRITE_DATA()) needs more arguments in the invocation than there are parameters in the macro definition. For the most simple case, that DATA_READ_DATA() and DATA_WRITE_DATA() are only called with one argument, a violation of the standard would appear if the DATA_DummyFunction() would be omitted: GET_MACRO(databaseVariable, DATA_Read4DataBlocks, DATA_Read3DataBlocks, DATA_Read2DataBlocks, DATA_Read2DataBlocks, DATA_Read1DataBlock)(databaseVariable) So the macro invocation has six parameters, but it needs seven and an ISO C99 violation would appear. Adding the DATA_DummyFunction() fixes this violation. For details see 6.10.3 (paragraph 4) of the ISO C99 standard.
Definition at line 297 of file database.c.
void DATA_ExecuteDataBist | ( | void | ) |
Executes a built-in self-test for the database module.
This test writes and reads a database entry in order to check that the database module is working as expected. If the test fails, it will fail an assertion.
Definition at line 363 of file database.c.
STD_RETURN_TYPE_e DATA_Initialize | ( | void | ) |
Initialization of database manager.
Definition at line 229 of file database.c.
STD_RETURN_TYPE_e DATA_Read1DataBlock | ( | void * | pDataToReceiver0 | ) |
Reads one data block in database by value.
This function reads data from database and copy this content in passed struct
[out] | pDataToReceiver0 | (type: void *) |
Definition at line 300 of file database.c.
STD_RETURN_TYPE_e DATA_Read2DataBlocks | ( | void * | pDataToReceiver0, |
void * | pDataToReceiver1 | ||
) |
Reads two data blocks in database by value.
This function reads data from database and copy this content in passed struct
[out] | pDataToReceiver0 | (type: void *) |
[out] | pDataToReceiver1 | (type: void *) |
Definition at line 305 of file database.c.
STD_RETURN_TYPE_e DATA_Read3DataBlocks | ( | void * | pDataToReceiver0, |
void * | pDataToReceiver1, | ||
void * | pDataToReceiver2 | ||
) |
Reads three data blocks in database by value.
This function reads data from database and copy this content in passed struct
[out] | pDataToReceiver0 | (type: void *) |
[out] | pDataToReceiver1 | (type: void *) |
[out] | pDataToReceiver2 | (type: void *) |
Definition at line 311 of file database.c.
STD_RETURN_TYPE_e DATA_Read4DataBlocks | ( | void * | pDataToReceiver0, |
void * | pDataToReceiver1, | ||
void * | pDataToReceiver2, | ||
void * | pDataToReceiver3 | ||
) |
Reads four data blocks in database by value.
This function reads data from database and copy this content in passed struct
[out] | pDataToReceiver0 | (type: void *) |
[out] | pDataToReceiver1 | (type: void *) |
[out] | pDataToReceiver2 | (type: void *) |
[out] | pDataToReceiver3 | (type: void *) |
Definition at line 318 of file database.c.
void DATA_Task | ( | void | ) |
trigger of database manager
TODO
Definition at line 279 of file database.c.
STD_RETURN_TYPE_e DATA_Write1DataBlock | ( | void * | pDataFromSender0 | ) |
Stores one data block in database.
This function stores passed data in database and updates timestamp and previous timestamp in passed struct
[in,out] | pDataFromSender0 | (type: void *) |
Definition at line 331 of file database.c.
STD_RETURN_TYPE_e DATA_Write2DataBlocks | ( | void * | pDataFromSender0, |
void * | pDataFromSender1 | ||
) |
Stores two data blocks in database.
This function stores passed data in database and updates timestamp and previous timestamp in passed struct
[in,out] | pDataFromSender0 | (type: void *) |
[in,out] | pDataFromSender1 | (type: void *) |
Definition at line 336 of file database.c.
STD_RETURN_TYPE_e DATA_Write3DataBlocks | ( | void * | pDataFromSender0, |
void * | pDataFromSender1, | ||
void * | pDataFromSender2 | ||
) |
Stores three data blocks in database.
This function stores passed data in database and updates timestamp and previous timestamp in passed struct
[in,out] | pDataFromSender0 | (type: void *) |
[in,out] | pDataFromSender1 | (type: void *) |
[in,out] | pDataFromSender2 | (type: void *) |
Definition at line 342 of file database.c.
STD_RETURN_TYPE_e DATA_Write4DataBlocks | ( | void * | pDataFromSender0, |
void * | pDataFromSender1, | ||
void * | pDataFromSender2, | ||
void * | pDataFromSender3 | ||
) |
Stores four data blocks in database.
This function stores passed data in database and updates timestamp and previous timestamp in passed struct
[in,out] | pDataFromSender0 | (type: void *) |
[in,out] | pDataFromSender1 | (type: void *) |
[in,out] | pDataFromSender2 | (type: void *) |
[in,out] | pDataFromSender3 | (type: void *) |
Definition at line 350 of file database.c.