GY-63_MS5611/libraries/FRAM_I2C/FRAM.h

69 lines
1.7 KiB
C
Raw Normal View History

2021-01-29 06:31:58 -05:00
#pragma once
//
// FILE: FRAM.h
// AUTHOR: Rob Tillaart
2021-12-18 09:02:32 -05:00
// VERSION: 0.3.2
2021-01-29 06:31:58 -05:00
// DATE: 2018-01-24
// PURPOSE: Arduino library for I2C FRAM
// URL: https://github.com/RobTillaart/FRAM_I2C
//
#include "Arduino.h"
#include "Wire.h"
2021-12-18 09:02:32 -05:00
#define FRAM_LIB_VERSION (F("0.3.2"))
2021-01-29 06:31:58 -05:00
#define FRAM_OK 0
#define FRAM_ERROR_ADDR -10
#define FRAM_ERROR_I2C -11
#define FRAM_ERROR_CONNECT -12
class FRAM
{
public:
FRAM(TwoWire *wire = &Wire);
#if defined (ESP8266) || defined(ESP32)
// address and writeProtectPin is optional
2021-02-06 09:52:51 -05:00
int begin(uint8_t sda, uint8_t scl, const uint8_t address = 0x50, int8_t writeProtectPin = -1);
2021-01-29 06:31:58 -05:00
#endif
// address and writeProtectPin is optional
int begin(const uint8_t address = 0x50, int8_t writeProtectPin = -1);
bool isConnected();
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 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);
void read(uint16_t memaddr, uint8_t * obj, uint16_t size);
bool setWriteProtect(bool b);
bool getWriteProtect();
uint16_t getManufacturerID();
uint16_t getProductID();
uint16_t getSize();
private:
uint8_t _address;
int8_t _writeProtectPin = -1; // default no pin ==> no write protect.
uint16_t getMetaData(uint8_t id);
void writeBlock(uint16_t memaddr, uint8_t * obj, uint8_t size);
void readBlock(uint16_t memaddr, uint8_t * obj, uint8_t size);
TwoWire* _wire;
};
2021-12-18 09:02:32 -05:00
2021-01-29 06:31:58 -05:00
// -- END OF FILE --
2021-12-18 09:02:32 -05:00