foxBMS
1.0.1
The foxBMS Battery Management System API Documentation
|
Database module implementation. More...
Go to the source code of this file.
Data Structures | |
struct | DATA_BASE_HEADER |
struct | DATA_QUEUE_MESSAGE |
Macros | |
#define | DATA_QUEUE_TIMEOUT_MS ((TickType_t)10u) |
#define | DATA_QUEUE_LENGTH (1u) |
Length of data Queue. More... | |
#define | DATA_QUEUE_ITEM_SIZE (sizeof(DATA_QUEUE_MESSAGE_s)) |
Size of data Queue item. More... | |
#define | DATA_MAX_ENTRIES_PER_ACCESS (4u) |
Typedefs | |
typedef struct DATA_BASE_HEADER | DATA_BASE_HEADER_s |
typedef struct DATA_QUEUE_MESSAGE | DATA_QUEUE_MESSAGE_s |
Functions | |
STD_RETURN_TYPE_e | DATA_Init (void) |
Initialization of database manager. More... | |
void | DATA_Task (void) |
trigger of database manager More... | |
void | DATA_DummyFunction (void) |
Dummy void function of the database module. More... | |
STD_RETURN_TYPE_e | DATA_Read_1_DataBlock (void *pDataToReceiver0) |
Reads a datablock in database by value. More... | |
STD_RETURN_TYPE_e | DATA_Read_2_DataBlocks (void *pDataToReceiver0, void *pDataToReceiver1) |
Reads a datablock in database by value. More... | |
STD_RETURN_TYPE_e | DATA_Read_3_DataBlocks (void *pDataToReceiver0, void *pDataToReceiver1, void *pDataToReceiver2) |
Reads a datablock in database by value. More... | |
STD_RETURN_TYPE_e | DATA_Read_4_DataBlocks (void *pDataToReceiver0, void *pDataToReceiver1, void *pDataToReceiver2, void *pDataToReceiver3) |
Reads a datablock in database by value. More... | |
STD_RETURN_TYPE_e | DATA_Write_1_DataBlock (void *pDataFromSender0) |
Stores a datablock in database. More... | |
STD_RETURN_TYPE_e | DATA_Write_2_DataBlocks (void *pDataFromSender0, void *pDataFromSender1) |
Stores a datablock in database. More... | |
STD_RETURN_TYPE_e | DATA_Write_3_DataBlocks (void *pDataFromSender0, void *pDataFromSender1, void *pDataFromSender2) |
Stores a datablock in database. More... | |
STD_RETURN_TYPE_e | DATA_Write_4_DataBlocks (void *pDataFromSender0, void *pDataFromSender1, void *pDataFromSender2, void *pDataFromSender3) |
Stores a datablock in database. More... | |
bool | DATA_DatabaseEntryUpdatedAtLeastOnce (void *pDatabaseEntry) |
Checks if passed database entry has been updated at least once. More... | |
bool | DATA_DatabaseEntryUpdatedRecently (void *pDatabaseEntry, uint32_t timeInterval) |
Checks if passed database entry has been updated within the last time interval. More... | |
bool | DATA_DatabaseEntryUpdatedWithinInterval (void *pDatabaseEntry, uint32_t timeInterval) |
Checks if passed database entry has been periodically updated within the time interval. More... | |
Variables | |
static QueueHandle_t | data_queue |
static StaticQueue_t | dataQueueStructure |
structure for static data queue More... | |
static uint8_t | dataQueueStorageArea [DATA_QUEUE_LENGTH *DATA_QUEUE_ITEM_SIZE] |
size of Queue storage More... | |
static const DATA_BASE_HEADER_s | data_baseHeader |
device configuration of database More... | |
static uint16_t | uniqueIdToDatabaseEntry [DATA_BLOCK_ID_MAX] |
uniqueId to respective database entry selector More... | |
Database module implementation.
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:
Implementation of database module
Definition in file database.c.
#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 80 of file database.c.
#define DATA_QUEUE_ITEM_SIZE (sizeof(DATA_QUEUE_MESSAGE_s)) |
Size of data Queue item.
Definition at line 74 of file database.c.
#define DATA_QUEUE_LENGTH (1u) |
Length of data Queue.
Definition at line 69 of file database.c.
#define DATA_QUEUE_TIMEOUT_MS ((TickType_t)10u) |
Maximum queue timeout time in milliseconds
Definition at line 64 of file database.c.
typedef struct DATA_BASE_HEADER DATA_BASE_HEADER_s |
configuration struct of database device
typedef struct DATA_QUEUE_MESSAGE DATA_QUEUE_MESSAGE_s |
struct for database queue, contains pointer to data, database entry and access type
bool DATA_DatabaseEntryUpdatedAtLeastOnce | ( | void * | pDatabaseEntry | ) |
Checks if passed database entry has been updated at least once.
[in] | pDatabaseEntry | (type: void *) |
Definition at line 328 of file database.c.
bool DATA_DatabaseEntryUpdatedRecently | ( | void * | pDatabaseEntry, |
uint32_t | timeInterval | ||
) |
Checks if passed database entry has been updated within the last time interval.
[in] | pDatabaseEntry | (type: void *) |
[in] | timeInterval | in systicks (type: uint32_t) |
Definition at line 340 of file database.c.
bool DATA_DatabaseEntryUpdatedWithinInterval | ( | void * | pDatabaseEntry, |
uint32_t | timeInterval | ||
) |
Checks if passed database entry has been periodically updated within the time interval.
Checks if the last update timestamp is not older than time interval and if the difference between previous timestamp and timestamp is smaller than time interval
[in] | pDatabaseEntry | (type: void *) |
[in] | timeInterval | in systicks (type: uint32_t) |
Definition at line 356 of file database.c.
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(databaseVaribale, DATA_Read_4_DataBlocks, DATA_Read_3_DataBlocks, DATA_Read_2_DataBlocks, DATA_Read_2_DataBlocks, DATA_Read_1_DataBlock)(databaseVaribale) 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 237 of file database.c.
STD_RETURN_TYPE_e DATA_Init | ( | void | ) |
Initialization of database manager.
Definition at line 138 of file database.c.
STD_RETURN_TYPE_e DATA_Read_1_DataBlock | ( | void * | pDataToReceiver0 | ) |
Reads a datablock in database by value.
This function reads data from database and copy this content in passed struct
[out] | pDataToReceiver0 | (type: void *) |
Definition at line 240 of file database.c.
STD_RETURN_TYPE_e DATA_Read_2_DataBlocks | ( | void * | pDataToReceiver0, |
void * | pDataToReceiver1 | ||
) |
Reads a datablock 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 245 of file database.c.
STD_RETURN_TYPE_e DATA_Read_3_DataBlocks | ( | void * | pDataToReceiver0, |
void * | pDataToReceiver1, | ||
void * | pDataToReceiver2 | ||
) |
Reads a datablock 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 250 of file database.c.
STD_RETURN_TYPE_e DATA_Read_4_DataBlocks | ( | void * | pDataToReceiver0, |
void * | pDataToReceiver1, | ||
void * | pDataToReceiver2, | ||
void * | pDataToReceiver3 | ||
) |
Reads a datablock 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 255 of file database.c.
void DATA_Task | ( | void | ) |
trigger of database manager
TODO
Definition at line 189 of file database.c.
STD_RETURN_TYPE_e DATA_Write_1_DataBlock | ( | void * | pDataFromSender0 | ) |
Stores a datablock 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 284 of file database.c.
STD_RETURN_TYPE_e DATA_Write_2_DataBlocks | ( | void * | pDataFromSender0, |
void * | pDataFromSender1 | ||
) |
Stores a datablock 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 289 of file database.c.
STD_RETURN_TYPE_e DATA_Write_3_DataBlocks | ( | void * | pDataFromSender0, |
void * | pDataFromSender1, | ||
void * | pDataFromSender2 | ||
) |
Stores a datablock 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 294 of file database.c.
STD_RETURN_TYPE_e DATA_Write_4_DataBlocks | ( | void * | pDataFromSender0, |
void * | pDataFromSender1, | ||
void * | pDataFromSender2, | ||
void * | pDataFromSender3 | ||
) |
Stores a datablock 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 299 of file database.c.
|
static |
device configuration of database
all attributes of device configuration are listed here (pointer to channel list, number of channels)
Definition at line 119 of file database.c.
|
static |
handle of the data queue
Definition at line 100 of file database.c.
|
static |
size of Queue storage
The array to use as the queue's storage area. This must be at least DATA_QUEUE_LENGTH * DATA_QUEUE_ITEM_SIZE
Definition at line 112 of file database.c.
|
static |
structure for static data queue
Definition at line 105 of file database.c.
|
static |
uniqueId to respective database entry selector
This array is the link between the uniqueId of a database entry and the actual position of the database entry in data_database[]
Definition at line 129 of file database.c.