Skip to content

Commit

Permalink
add read64/write64 (#39)
Browse files Browse the repository at this point in the history
* add read64 / write64
* update documentation
  • Loading branch information
pvogt09 authored Sep 3, 2023
1 parent b536e63 commit 44dea9c
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
30 changes: 30 additions & 0 deletions FRAM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions FRAM.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,15 @@ 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);

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);
Expand Down Expand Up @@ -138,13 +140,15 @@ 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);

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);
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down

0 comments on commit 44dea9c

Please sign in to comment.