From 44dea9cd4a91681a30278bbdadf3b06a9e1dbb7d Mon Sep 17 00:00:00 2001 From: pvogt09 <50047961+pvogt09@users.noreply.github.com> Date: Sun, 3 Sep 2023 17:34:58 +0200 Subject: [PATCH] add read64/write64 (#39) * add read64 / write64 * update documentation --- FRAM.cpp | 30 ++++++++++++++++++++++++++++++ FRAM.h | 4 ++++ README.md | 2 ++ 3 files changed, 36 insertions(+) diff --git a/FRAM.cpp b/FRAM.cpp index d585890..1d102fb 100644 --- a/FRAM.cpp +++ b/FRAM.cpp @@ -110,6 +110,13 @@ void FRAM::write32(uint16_t memaddr, uint32_t value) } +void FRAM::write64(uint16_t memaddr, uint64_t value) +{ + uint64_t val = value; + _writeBlock(memaddr, (uint8_t *)&val, sizeof(uint64_t)); +} + + void FRAM::writeFloat(uint16_t memaddr, float value) { float val = value; @@ -167,6 +174,14 @@ uint32_t FRAM::read32(uint16_t memaddr) } +uint64_t FRAM::read64(uint16_t memaddr) +{ + uint64_t val; + _readBlock(memaddr, (uint8_t *)&val, sizeof(uint64_t)); + return val; +} + + float FRAM::readFloat(uint16_t memaddr) { float val; @@ -433,6 +448,13 @@ void FRAM32::write32(uint32_t memaddr, uint32_t value) } +void FRAM32::write64(uint32_t memaddr, uint64_t value) +{ + uint64_t val = value; + _writeBlock(memaddr, (uint8_t *)&val, sizeof(uint64_t)); +} + + void FRAM32::writeFloat(uint32_t memaddr, float value) { float val = value; @@ -490,6 +512,14 @@ uint32_t FRAM32::read32(uint32_t memaddr) } +uint64_t FRAM32::read64(uint32_t memaddr) +{ + uint64_t val; + _readBlock(memaddr, (uint8_t *)&val, sizeof(uint64_t)); + return val; +} + + float FRAM32::readFloat(uint32_t memaddr) { float val; diff --git a/FRAM.h b/FRAM.h index e03709b..ee017da 100644 --- a/FRAM.h +++ b/FRAM.h @@ -48,6 +48,7 @@ class FRAM void write8(uint16_t memaddr, uint8_t value); void write16(uint16_t memaddr, uint16_t value); void write32(uint16_t memaddr, uint32_t value); + void write64(uint16_t memaddr, uint64_t value); void writeFloat(uint16_t memaddr, float value); void writeDouble(uint16_t memaddr, double value); void write(uint16_t memaddr, uint8_t * obj, uint16_t size); @@ -55,6 +56,7 @@ class FRAM uint8_t read8(uint16_t memaddr); uint16_t read16(uint16_t memaddr); uint32_t read32(uint16_t memaddr); + uint64_t read64(uint16_t memaddr); float readFloat(uint16_t memaddr); double readDouble(uint16_t memaddr); void read(uint16_t memaddr, uint8_t * obj, uint16_t size); @@ -138,6 +140,7 @@ class FRAM32 : public FRAM void write8(uint32_t memaddr, uint8_t value); void write16(uint32_t memaddr, uint16_t value); void write32(uint32_t memaddr, uint32_t value); + void write64(uint32_t memaddr, uint64_t value); void writeFloat(uint32_t memaddr, float value); void writeDouble(uint32_t memaddr, double value); void write(uint32_t memaddr, uint8_t * obj, uint16_t size); @@ -145,6 +148,7 @@ class FRAM32 : public FRAM uint8_t read8(uint32_t memaddr); uint16_t read16(uint32_t memaddr); uint32_t read32(uint32_t memaddr); + uint64_t read64(uint32_t memaddr); float readFloat(uint32_t memaddr); double readDouble(uint32_t memaddr); void read(uint32_t memaddr, uint8_t * obj, uint16_t size); diff --git a/README.md b/README.md index f07fc8b..4e531e0 100644 --- a/README.md +++ b/README.md @@ -96,6 +96,7 @@ In the **FRAM32** class these functions have an **uin32_t memaddr**. - **void write8(uint16_t memaddr, uint8_t value)** uint8_t - **void write16(uint16_t memaddr, uint16_t value)** uint16_t - **void write32(uint16_t memaddr, uint32_t value)** uint32_t +- **void write64(uint16_t memaddr, uint64_t value)** uint64_t - **void writeFloat(uint16_t memaddr, float value)** float - **void writeDouble(uint16_t memaddr, double value)** double - For boards that have an 8 byte double. @@ -104,6 +105,7 @@ In the **FRAM32** class these functions have an **uin32_t memaddr**. - **uint8_t read8(uint16_t memaddr)** - **uint16_t read16(uint16_t memaddr)** - **uint32_t read32(uint16_t memaddr)** +- **uint64_t read64(uint16_t memaddr)** - **float readFloat(uint16_t memaddr)** - **double readDouble(uint16_t memaddr)** - For board that have 8 byte double.