2018-01-24 13:59:15 +01:00
|
|
|
//
|
|
|
|
// FILE: FRAM.h
|
|
|
|
// AUTHOR: Rob Tillaart
|
2019-07-31 19:46:25 +02:00
|
|
|
// VERSION: 0.1.1
|
2018-01-24 13:59:15 +01:00
|
|
|
// PURPOSE: Class for FRAM memory
|
|
|
|
// URL:
|
|
|
|
//
|
|
|
|
// HISTORY:
|
|
|
|
// see FRAM.cpp file
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef FRAM_H
|
|
|
|
#define FRAM_H
|
|
|
|
|
|
|
|
#include "Arduino.h"
|
|
|
|
#include "Wire.h"
|
|
|
|
|
2019-07-31 19:46:25 +02:00
|
|
|
#define FRAM_LIB_VERSION (F("0.1.1"))
|
2018-01-24 13:59:15 +01:00
|
|
|
|
|
|
|
#define FRAM_OK 0
|
|
|
|
#define FRAM_ERROR_ADDR -10
|
|
|
|
|
|
|
|
class FRAM
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
FRAM();
|
|
|
|
|
|
|
|
int begin(const int address); // defaults to 0x50
|
|
|
|
|
|
|
|
void write8(uint16_t memaddr, uint8_t value);
|
|
|
|
void write16(uint16_t memaddr, uint16_t value);
|
|
|
|
void write32(uint16_t memaddr, uint32_t value);
|
2018-01-24 14:48:10 +01:00
|
|
|
void write(uint16_t memaddr, uint8_t * obj, uint16_t size);
|
2018-01-24 13:59:15 +01:00
|
|
|
|
|
|
|
uint8_t read8(uint16_t memaddr);
|
|
|
|
uint16_t read16(uint16_t memaddr);
|
|
|
|
uint32_t read32(uint16_t memaddr);
|
|
|
|
void read(uint16_t memaddr, uint8_t * obj, uint16_t size);
|
|
|
|
|
|
|
|
uint16_t getManufacturerID();
|
|
|
|
uint16_t getProductID();
|
|
|
|
uint16_t getSize() { return _size; };
|
|
|
|
|
|
|
|
private:
|
|
|
|
int8_t _address;
|
|
|
|
uint16_t _size; // unknown
|
|
|
|
|
|
|
|
void writeBlock(uint16_t memaddr, uint8_t * obj, uint16_t size);
|
|
|
|
void readBlock(uint16_t memaddr, uint8_t * obj, uint16_t size);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// END OF FILE
|