mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-10-03 18:09:02 -04:00
0.3.2 FRAM_I2C
This commit is contained in:
parent
43caa84948
commit
7eb4224bf1
@ -2,6 +2,10 @@ compile:
|
||||
# Choosing to run compilation tests on 2 different Arduino platforms
|
||||
platforms:
|
||||
- uno
|
||||
- leonardo
|
||||
- due
|
||||
- zero
|
||||
# - due
|
||||
# - zero
|
||||
# - leonardo
|
||||
- m4
|
||||
- esp32
|
||||
# - esp8266
|
||||
# - mega2560
|
@ -4,10 +4,14 @@ name: Arduino CI
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
arduino_ci:
|
||||
runTest:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: Arduino-CI/action@master
|
||||
# Arduino-CI/action@v0.1.1
|
||||
- uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: 2.6
|
||||
- run: |
|
||||
gem install arduino_ci
|
||||
arduino_ci.rb
|
||||
|
@ -1,20 +1,22 @@
|
||||
//
|
||||
// FILE: FRAM.cpp
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.3.1
|
||||
// VERSION: 0.3.2
|
||||
// DATE: 2018-01-24
|
||||
// PURPOSE: Arduino library for I2C FRAM
|
||||
// URL: https://github.com/RobTillaart/FRAM_I2C
|
||||
//
|
||||
// HISTORY:
|
||||
// 0.1.0 2018-01-24 initial version
|
||||
// 0.1.1 2019-07-31 added suppport for Fujitsu 64Kbit MB85RC64T (kudos ysoyipek)
|
||||
// 0.1.1 2019-07-31 added support for Fujitsu 64Kbit MB85RC64T (kudos ysoyipek)
|
||||
// 0.2.0 2020-04-30 refactor, add writeProtectPin code
|
||||
// 0.2.1 2020-06-10 fix library.json
|
||||
// 0.2.2 2020-12-23 arduino-CI + unit test + getWriteProtect()
|
||||
// 0.2.2 2020-12-23 Arduino-CI + unit test + getWriteProtect()
|
||||
// 0.2.3 2021-01-ii fix getMetaData (kudos to PraxisSoft
|
||||
// 0.3.0 2021-01-13 fix #2 ESP32 + WireN support
|
||||
// 0.3.1 2021-02-05 fix #7 typo in .cpp
|
||||
// 0.3.2 2021-12-18 update Arduino-CI, add badges,
|
||||
// update library.json, license, minor edits
|
||||
|
||||
|
||||
#include "FRAM.h"
|
||||
@ -22,6 +24,7 @@
|
||||
|
||||
const uint8_t FRAM_SLAVE_ID_= 0x7C;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//
|
||||
// PUBLIC
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// FILE: FRAM.h
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.3.1
|
||||
// VERSION: 0.3.2
|
||||
// DATE: 2018-01-24
|
||||
// PURPOSE: Arduino library for I2C FRAM
|
||||
// URL: https://github.com/RobTillaart/FRAM_I2C
|
||||
@ -13,7 +13,7 @@
|
||||
#include "Wire.h"
|
||||
|
||||
|
||||
#define FRAM_LIB_VERSION (F("0.3.1"))
|
||||
#define FRAM_LIB_VERSION (F("0.3.2"))
|
||||
|
||||
|
||||
#define FRAM_OK 0
|
||||
@ -63,4 +63,6 @@ private:
|
||||
TwoWire* _wire;
|
||||
};
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2018-2021 Rob Tillaart
|
||||
Copyright (c) 2018-2022 Rob Tillaart
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -1,5 +1,7 @@
|
||||
|
||||
[![Arduino CI](https://github.com/RobTillaart/FRAM_I2C/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
|
||||
[![Arduino-lint](https://github.com/RobTillaart/FRAM_I2C/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/FRAM_I2C/actions/workflows/arduino-lint.yml)
|
||||
[![JSON check](https://github.com/RobTillaart/FRAM_I2C/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/FRAM_I2C/actions/workflows/jsoncheck.yml)
|
||||
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/FRAM_I2C/blob/master/LICENSE)
|
||||
[![GitHub release](https://img.shields.io/github/release/RobTillaart/FRAM_I2C.svg?maxAge=3600)](https://github.com/RobTillaart/FRAM_I2C/releases)
|
||||
|
||||
@ -13,12 +15,14 @@ Arduino library for I2C FRAM
|
||||
|
||||
FRAM is a library to read and write (over I2C) to an FRAM module.
|
||||
FRAM is much faster than EEPROM and almost as fast as Arduino UNO RAM.
|
||||
Another imaportant feature is that FRAM keeps its content after a reboot (non-volatile)
|
||||
Another important feature is that FRAM keeps its content after a reboot (non-volatile)
|
||||
|
||||
FRAM stands for Ferroelectric RAM - https://en.wikipedia.org/wiki/Ferroelectric_RAM
|
||||
|
||||
Types of FRAM the library should work with
|
||||
|
||||
| SIZE | TYPE |
|
||||
|:---:|:---:|
|
||||
|:-----:|:----------:|
|
||||
| 8KB | MB85RC64T |
|
||||
| 32KB | MB85RC256V |
|
||||
| 64KB | MB85RC512T |
|
||||
@ -32,35 +36,45 @@ Address = 0x50 (default) .. 0x57
|
||||
### Constructor
|
||||
|
||||
- **FRAM(TwoWire \*wire = &Wire)** Constructor with optional Wire interface.
|
||||
- **int begin(address = 0x50, writeProtectPin = -1)** address and writeProtectPin is optional
|
||||
- **int begin(sda, scl, address = 0x50, writeProtectPin = -1)** idem fro ESP32 a.o.
|
||||
- **bool isConnected()** checks if the address is visable on the I2C bus
|
||||
- **int begin(uint8_t address = 0x50, int8_t writeProtectPin = -1)** address and writeProtectPin is optional.
|
||||
- **int begin(uint8_t sda, uint8_t scl, uint8_t address = 0x50, int8_t writeProtectPin = -1)** idem fro ESP32 a.o.
|
||||
- **bool isConnected()** checks if the address is visible on the I2C bus.
|
||||
|
||||
|
||||
### Write & read
|
||||
|
||||
Support for basic types and 2 calls for generic object
|
||||
|
||||
- **void write8(memaddr, value)** uint8_t
|
||||
- **void write16(memaddr, value)** uint16_t
|
||||
- **void write32(memaddr, value)** uint32_t
|
||||
- **void write( memaddr, \* obj, size)** other types / sizes
|
||||
- **uint8_t read8(memaddr)**
|
||||
- **uint16_t read16(memaddr)**
|
||||
- **uint32_t read32(memaddr)**
|
||||
- **void read(memaddr, uint8_t \* obj, size)**
|
||||
- **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 write(uint16_t memaddr, uint8_t \* obj, uint16_t size)** other types / sizes
|
||||
- **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 uint8_t \* obj, uint16_t size)**
|
||||
|
||||
|
||||
### Miscelaneous
|
||||
### Miscellaneous
|
||||
|
||||
- **bool setWriteProtect(b)** make the FRAM writeprotect by pulling line HIGH / LOW.
|
||||
- **bool setWriteProtect(bool b)** make the FRAM write-protected by pulling line HIGH / LOW.
|
||||
Returns true if a writeProtectPin was defined.
|
||||
Otherwise the FRAM cannot be write protected.
|
||||
- **uint16_t getManufacturerID()** idem
|
||||
- **uint16_t getProductID()** idem
|
||||
- **bool getWriteProtect()** get current status.
|
||||
- **uint16_t getManufacturerID()** idem.
|
||||
- **uint16_t getProductID()** idem.
|
||||
- **uint16_t getSize()** returns size in KB.
|
||||
|
||||
|
||||
## Operational
|
||||
|
||||
See examples
|
||||
|
||||
## Future
|
||||
|
||||
- test
|
||||
- extend examples
|
||||
- example in which FRAM is used as buffer for some stream?
|
||||
- example FRAM ring buffer
|
||||
-
|
||||
|
||||
|
@ -1,15 +1,13 @@
|
||||
//
|
||||
// FILE: testFRAM.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.0
|
||||
// PURPOSE: test for FRAM library for Arduino
|
||||
// URL: https://github.com/RobTillaart/FRAM_I2C
|
||||
//
|
||||
// Released to the public domain
|
||||
//
|
||||
|
||||
|
||||
#include "FRAM.h"
|
||||
|
||||
|
||||
FRAM fram;
|
||||
|
||||
uint32_t start;
|
||||
@ -43,6 +41,7 @@ void setup()
|
||||
Serial.println("done...");
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
}
|
||||
@ -64,6 +63,7 @@ void testID()
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
|
||||
void testFRAMmemory()
|
||||
{
|
||||
Serial.println();
|
||||
@ -93,6 +93,7 @@ void testFRAMmemory()
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
|
||||
void testReadWriteSmall()
|
||||
{
|
||||
Serial.println();
|
||||
@ -136,6 +137,7 @@ void testReadWriteSmall()
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
|
||||
void testReadWriteLarge()
|
||||
{
|
||||
Serial.println();
|
||||
@ -171,6 +173,7 @@ void testReadWriteLarge()
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
|
||||
void testWriteText()
|
||||
{
|
||||
char str[10][20] =
|
||||
@ -196,9 +199,9 @@ void testWriteText()
|
||||
Serial.print(stop - start);
|
||||
Serial.println(" ms");
|
||||
Serial.println();
|
||||
|
||||
}
|
||||
|
||||
|
||||
void testReadText1()
|
||||
{
|
||||
char str[10][20];
|
||||
@ -221,6 +224,7 @@ void testReadText1()
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
|
||||
void testReadText2()
|
||||
{
|
||||
char str[20];
|
||||
@ -237,4 +241,5 @@ void testReadText2()
|
||||
}
|
||||
|
||||
|
||||
// END OF FILE
|
||||
// -- END OF FILE --
|
||||
|
||||
|
@ -1,13 +1,14 @@
|
||||
//
|
||||
// FILE: testFRAMPerformance.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.0
|
||||
// PURPOSE: test for FRAM library for Arduino
|
||||
// URL: https://github.com/RobTillaart/FRAM_I2C
|
||||
//
|
||||
|
||||
|
||||
#include "FRAM.h"
|
||||
|
||||
|
||||
FRAM fram;
|
||||
|
||||
uint32_t start;
|
||||
@ -15,6 +16,7 @@ uint32_t stop;
|
||||
|
||||
int ar[600];
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
@ -46,10 +48,12 @@ void setup()
|
||||
Serial.println("done...");
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void testReadWriteLarge()
|
||||
{
|
||||
Serial.println();
|
||||
@ -86,4 +90,6 @@ void testReadWriteLarge()
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
// END OF FILE
|
||||
|
||||
// -- END OF FILE --
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Syntax Coloring Map for FRAM
|
||||
# Syntax Colouring Map for FRAM
|
||||
|
||||
# Datatypes (KEYWORD1)
|
||||
# Data types (KEYWORD1)
|
||||
FRAM KEYWORD1
|
||||
|
||||
# Methods and Functions (KEYWORD2)
|
||||
@ -17,13 +17,18 @@ read16 KEYWORD2
|
||||
read32 KEYWORD2
|
||||
read KEYWORD2
|
||||
|
||||
setWriteProtect KEYWORD2
|
||||
getWriteProtect KEYWORD2
|
||||
|
||||
getManufacturerID KEYWORD2
|
||||
getProductID KEYWORD2
|
||||
getSize KEYWORD2
|
||||
|
||||
|
||||
# Constants (LITERAL1)
|
||||
FRAM_LIB_VERSION LITERAL1
|
||||
FRAM_OK LITERAL1
|
||||
FRAM_ERROR_ADDR LITERAL1
|
||||
FRAM_ERROR_I2C LITERAL1
|
||||
FRAM_ERROR_CONNECT LITERAL1
|
||||
|
||||
|
@ -15,8 +15,9 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/RobTillaart/FRAM_I2C.git"
|
||||
},
|
||||
"version": "0.3.1",
|
||||
"version": "0.3.2",
|
||||
"license": "MIT",
|
||||
"frameworks": "arduino",
|
||||
"platforms": "*"
|
||||
"platforms": "*",
|
||||
"headers": "FRAM.h"
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
name=FRAM_I2C
|
||||
version=0.3.1
|
||||
version=0.3.2
|
||||
author=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
sentence=Arduino library for I2C FRAM.
|
||||
|
@ -24,35 +24,32 @@
|
||||
#include <ArduinoUnitTests.h>
|
||||
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "FRAM.h"
|
||||
|
||||
|
||||
|
||||
unittest_setup()
|
||||
{
|
||||
fprintf(stderr, "FRAM_LIB_VERSION: %s\n", (char*) FRAM_LIB_VERSION);
|
||||
}
|
||||
|
||||
|
||||
unittest_teardown()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
unittest(test_new_operator)
|
||||
{
|
||||
assertEqualINF(exp(800));
|
||||
assertEqualINF(0.0/0.0);
|
||||
assertEqualINF(42);
|
||||
|
||||
assertEqualNAN(INFINITY - INFINITY);
|
||||
assertEqualNAN(0.0/0.0);
|
||||
assertEqualNAN(42);
|
||||
unittest(test_constants)
|
||||
{
|
||||
assertEqual( 0, FRAM_OK );
|
||||
assertEqual(-10, FRAM_ERROR_ADDR );
|
||||
assertEqual(-11, FRAM_ERROR_I2C );
|
||||
assertEqual(-12, FRAM_ERROR_CONNECT);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
unittest(test_constructor)
|
||||
{
|
||||
fprintf(stderr, "VERSION: %s\n", FRAM_LIB_VERSION);
|
||||
FRAM fram49;
|
||||
FRAM fram50;
|
||||
FRAM fram52;
|
||||
@ -60,30 +57,31 @@ unittest(test_constructor)
|
||||
|
||||
Wire.begin();
|
||||
|
||||
fprintf(stderr, "\ndifferent constructors\n");
|
||||
fprintf(stderr, "\n Different constructors\n");
|
||||
assertEqual(FRAM_ERROR_ADDR, fram49.begin(0x49));
|
||||
assertEqual(FRAM_OK, fram50.begin());
|
||||
assertEqual(FRAM_OK, fram52.begin(0x52));
|
||||
assertEqual(FRAM_OK, fram57.begin(0x57, 4));
|
||||
|
||||
fprintf(stderr, "\nno writeProtect pin defined\n");
|
||||
fprintf(stderr, "\n no writeProtect pin defined\n");
|
||||
assertFalse(fram50.setWriteProtect(true));
|
||||
assertFalse(fram50.getWriteProtect());
|
||||
assertFalse(fram50.setWriteProtect(false));
|
||||
assertFalse(fram50.getWriteProtect());
|
||||
|
||||
fprintf(stderr, "\nwriteProtect pin defined\n");
|
||||
fprintf(stderr, "\n writeProtect pin defined\n");
|
||||
assertTrue(fram57.setWriteProtect(true));
|
||||
assertTrue(fram57.getWriteProtect());
|
||||
assertTrue(fram57.setWriteProtect(false));
|
||||
assertFalse(fram57.getWriteProtect());
|
||||
|
||||
fprintf(stderr, "\nall fail as nothing connected\n");
|
||||
fprintf(stderr, "\n all fail as nothing connected\n");
|
||||
assertEqual(65535, fram50.getManufacturerID());
|
||||
assertEqual(65535, fram50.getProductID());
|
||||
assertEqual(0, fram50.getSize());
|
||||
}
|
||||
|
||||
|
||||
unittest_main()
|
||||
|
||||
// --------
|
||||
|
Loading…
x
Reference in New Issue
Block a user