diff --git a/Components/NVS_Lib/Inc/NVS_Cell.hpp b/Components/NVS_Lib/Inc/NVS_Cell.hpp new file mode 100644 index 0000000..bd666e1 --- /dev/null +++ b/Components/NVS_Lib/Inc/NVS_Cell.hpp @@ -0,0 +1,92 @@ +#ifndef __NVS_CELL_HPP__ +#define __NVS_CELL_HPP__ + +#include + + + + +#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__ */ diff --git a/Components/NVS_Lib/Inc/NVS_Page.hpp b/Components/NVS_Lib/Inc/NVS_Page.hpp new file mode 100644 index 0000000..7015c04 --- /dev/null +++ b/Components/NVS_Lib/Inc/NVS_Page.hpp @@ -0,0 +1,5 @@ +#ifndef __NVS_PAGE_HPP__ +#define __NVS_PAGE_HPP__ + + +#endif /* __NVS_PAGE_HPP__ */ diff --git a/Components/NVS_Lib/Inc/NVS_Value.hpp b/Components/NVS_Lib/Inc/NVS_Value.hpp new file mode 100644 index 0000000..25c5a5b --- /dev/null +++ b/Components/NVS_Lib/Inc/NVS_Value.hpp @@ -0,0 +1,51 @@ +#ifndef __NVS_VALUE_HPP__ +#define __NVS_VALUE_HPP__ + +#include + +#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__ */ diff --git a/Core/Src/main.cpp b/Core/Src/main.cpp index 6473451..0c80b1f 100644 --- a/Core/Src/main.cpp +++ b/Core/Src/main.cpp @@ -1,7 +1,8 @@ #include "main.hpp" +#include "NVS_Cell.hpp" - +// NVS_Cell::Data_t Test; // Основная программа int main(void)