Skip to content

Commit

Permalink
add
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeyLadanov committed May 8, 2024
1 parent 0760a2f commit c260259
Show file tree
Hide file tree
Showing 4 changed files with 150 additions and 1 deletion.
92 changes: 92 additions & 0 deletions Components/NVS_Lib/Inc/NVS_Cell.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#ifndef __NVS_CELL_HPP__
#define __NVS_CELL_HPP__

#include <cstdint>




#pragma pack(push, 1)
class NVS_Cell
{
public:
// Типы значений
typedef enum {
TYPE_FLOAT = 1,
TYPE_INT8,
TYPE_INT16,
TYPE_INT32,
TYPE_INT64,
TYPE_UINT8,
TYPE_UINT16,
TYPE_UINT32,
TYPE_UINT64,
TYPE_BOOL,
TYPE_ARRAY,
TYPE_DOUBLE
}NVS_DataType;

#pragma pack(push, 1)
struct DataBlock_t
{
uint32_t StartTag;
char Key[14];
uint8_t BlockCount;
uint8_t Type;
union __Value
{
float F32;
double Double;
uint64_t UI64;
uint32_t UI32;
uint16_t UI16;
uint8_t UI8;
int64_t I64;
int32_t I32;
int16_t I16;
int8_t I8;
bool BoolVal;
uint32_t BinarySize;
}Value;
uint32_t State;

DataBlock_t *GetNext(void)
{
return (DataBlock_t *) ((uint8_t *) this + BlockCount * sizeof(DataBlock_t));
}


uint8_t *GetBinaryData(void)
{
return ((uint8_t *) this + sizeof(DataBlock_t));
}

};

struct BinaryChunk_t
{
uint8_t Data[32];
};

#pragma pack(pop)

DataBlock_t Body;
uint8_t *BinaryBufferPtr = nullptr;

void Init(void)
{

}


DataBlock_t *Read(uint8_t *buf)
{
return (DataBlock_t *) buf;
}

};

#pragma pack(pop)


#endif /* __NVS_CELL_HPP__ */
5 changes: 5 additions & 0 deletions Components/NVS_Lib/Inc/NVS_Page.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#ifndef __NVS_PAGE_HPP__
#define __NVS_PAGE_HPP__


#endif /* __NVS_PAGE_HPP__ */
51 changes: 51 additions & 0 deletions Components/NVS_Lib/Inc/NVS_Value.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#ifndef __NVS_VALUE_HPP__
#define __NVS_VALUE_HPP__

#include <cstdint>

#pragma pack(push, 1)
class NVS_Value
{
// Типы значений
typedef enum {
TYPE_FLOAT = 1,
TYPE_INT8,
TYPE_INT16,
TYPE_INT32,
TYPE_INT64,
TYPE_UINT8,
TYPE_UINT16,
TYPE_UINT32,
TYPE_UINT64,
TYPE_BOOL,
TYPE_ARRAY,
TYPE_DOUBLE
}NVS_DataType;

uint32_t StartTag;
char Key[14];
uint8_t BlockCount;
uint8_t Type;
union __Value
{
float F32;
double Double;
uint64_t UI64;
uint32_t UI32;
uint16_t UI16;
uint8_t UI8;
int64_t I64;
int32_t I32;
int16_t I16;
int8_t I8;
bool BoolVal;
uint32_t BinarySize;
}Value;
uint32_t State;
};

#pragma pack(pop)



#endif /* __NVS_VALUE_HPP__ */
3 changes: 2 additions & 1 deletion Core/Src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@

#include "main.hpp"
#include "NVS_Cell.hpp"


// NVS_Cell::Data_t Test;

// Основная программа
int main(void)
Expand Down

0 comments on commit c260259

Please sign in to comment.