Skip to content

Commit

Permalink
added description of nre begin
Browse files Browse the repository at this point in the history
  • Loading branch information
smkkHw committed Jan 3, 2018
1 parent 762f1c9 commit fd6610d
Showing 1 changed file with 53 additions and 39 deletions.
92 changes: 53 additions & 39 deletions ReadMe.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

# Arduino External EEPROM Library v3.3.4 #

Original library by http://github.com/JChristensen/extEEPROM
Expand Down Expand Up @@ -51,10 +52,10 @@ To use the **extEEPROM Library**, the standard [Arduino Wire library](http://ard
```
## Enumerations ##

###eeprom_size_t
#####Description
### eeprom_size_t
##### Description
EEPROM device size in k-bits. Many manufacturers' EEPROM part numbers are designated in k-bits.
#####Values
##### Values
- kbits_2
- kbits_4
- kbits_8
Expand All @@ -67,61 +68,73 @@ EEPROM device size in k-bits. Many manufacturers' EEPROM part numbers are design
- kbits_1024
- kbits_2048

###twiClockFreq_t
#####Description
### twiClockFreq_t
##### Description
I2C bus speed.
#####Values
##### Values
- extEEPROM::twiClock100kHz
- extEEPROM::twiClock400kHz

## Constructor ##

###extEEPROM(eeprom_size_t devCap, byte nDev, unsigned int pgSize, byte busAddr)
#####Description
### extEEPROM(eeprom_size_t devCap, byte nDev, unsigned int pgSize, byte busAddr)
##### Description
Instantiates an external EEPROM object.
#####Syntax
##### Syntax
`extEEPROM myEEPROM(eeprom_size_t devCap, byte nDev, unsigned int pgSize, byte busAddr));`
#####Parameters
##### Parameters
**devCap** *(eeprom_size_t)*: The size of one EEPROM device in k-bits. Choose a value from the eeprom_size_t enumeration above.
**nDev** *(byte)*: The number of EEPROM devices on the bus. Note that if there are multiple EEPROM devices on the bus, they must be identical and each must have its address pins strapped properly.
**pgSize** *(unsigned int)*: The EEPROM page size in bytes. Consult the datasheet if you are unsure of the page size.
**busAddr** *(byte)*: The base I2C bus address for the EEPROM(s). 0x50 is a common value and this parameter can be omitted, in which case 0x50 will be used as the default.
#####Example
##### Example
```c++
extEEPROM myEEPROM(kbits_256, 2, 64); //two 24LC256 EEPROMS on the bus
extEEPROM oddEEPROM(kbits_8, 1, 16, 0x42); //an EEPROM with a non-standard I2C address
```
## Methods ##
###begin(twiClockFreq_t freq)
#####Description
### begin(twiClockFreq_t freq, TwoWire *_comm)
##### Description
Initializes the library. Call this method once in the setup code. begin() does a dummy I/O so that the user may interrogate the return status to ensure the EEPROM is operational.
#####Syntax
##### Syntax
`myEEPROM.begin(twiClockFreq_t freq);`
#####Parameters
##### Parameters
**freq** *(twiClockFreq_t)*: The desired I2C bus speed, `extEEPROM::twiClock100kHz` or `extEEPROM::twiClock400kHz`. Can be omitted in which case it will default to `twiClock100kHz`. **NOTE:** When using 400kHz, if there are other devices on the bus they must all support a 400kHz bus speed. **Secondly**, the other devices should be initialized first, as other libraries may not support adjusting the bus speed. To ensure the desired speed is set, call the extEEPROM.begin() function *after* initializing all other I2C devices.
#####Returns
**_comm** *(TwoWire * )*: The Used I2C TwoWire channel . Can be omitted in which case it will default to the first Arduino I2C channel `Wire`. If another of the possible I2C channel is used its pointer shall be passed as parameter. **NOTE:** If another I2C channel is unse, and not the default one, the first parameters **freq** MUST be defined.
##### Returns
I2C I/O status, zero if successful *(byte)*. See the [Arduino Wire.endTransmission() function](http://arduino.cc/en/Reference/WireEndTransmission) for a description of other return codes.
#####Example
##### Examples
```c++
extEEPROM myEEPROM(kbits_256, 2, 64);
byte i2cStat = myEEPROM.begin(extEEPROM::twiClock400kHz);
if ( i2cStat != 0 ) {
//there was a problem
}
```
###write(unsigned long addr, byte *values, unsigned int nBytes)
#####Description
##### Use of other I2C channel
```c++
extEEPROM myEEPROM(kbits_256, 2, 64);
byte i2cStat = myEEPROM.begin(extEEPROM::twiClock400kHz, &Wire1);
if ( i2cStat != 0 ) {
//there was a problem
}
```
### write(unsigned long addr, byte *values, unsigned int nBytes)
##### Description
Write one or more bytes to external EEPROM.
#####Syntax
##### Syntax
`myEEPROM.write(unsigned long addr, byte* values, byte nBytes);`
#####Parameters
##### Parameters
**addr** *(unsigned long)*: The beginning EEPROM location to write.
**values** _(byte*)_: Pointer to an array containing the data to write.
**nBytes** *(unsigned int)*: The number of bytes to write.
#####Returns
##### Returns
I2C I/O status, zero if successful *(byte)*. See the [Arduino Wire.endTransmission() function](http://arduino.cc/en/Reference/WireEndTransmission) for a description of other return codes. Returns a status of EEPROM_ADDR_ERR if the I/O would extend past the top of the EEPROM address space.
#####Example
##### Example
```c++
byte myData[10];
//write 10 bytes starting at location 42
Expand All @@ -136,31 +149,31 @@ if ( i2cStat != 0 ) {
}
}
```
###write(unsigned long addr, byte value)
#####Description
### write(unsigned long addr, byte value)
##### Description
Writes a single byte to external EEPROM.
#####Syntax
`myEEPROM.write(unsigned long addr, byte value);`
#####Parameters
**addr** *(unsigned long)*: The EEPROM location to write.
**values** _(byte)_: The value to write.
#####Returns
##### Returns
Same as multiple-byte write() above.
#####Example
##### Example
```c++
//write the value 16 to EEPROM location 314.
byte i2cStat = myEEPROM.write(314, 16);
```
###read(unsigned long addr, byte *values, unsigned int nBytes)
#####Description
### read(unsigned long addr, byte *values, unsigned int nBytes)
##### Description
Reads one or more bytes from external EEPROM into an array supplied by the caller.
#####Syntax
##### Syntax
`myEEPROM.read(unsigned long addr, byte *values, byte nBytes);`
#####Parameters
##### Parameters
**addr** *(unsigned long)*: The beginning EEPROM location to read from.
**values** _(byte*)_: Pointer to an array to receive the data.
**nBytes** *(unsigned int)*: The number of bytes to read.
#####Returns
##### Returns
I2C I/O status, zero if successful *(byte)*. See the [Arduino Wire.endTransmission() function](http://arduino.cc/en/Reference/WireEndTransmission) for a description of other return codes. Returns a status of EEPROM_ADDR_ERR if the I/O would extend past the top of the EEPROM address space.
#####Example
```c++
Expand All @@ -177,17 +190,17 @@ if ( i2cStat != 0 ) {
}
}
```
###read(unsigned long addr)
#####Description
### read(unsigned long addr)
##### Description
Reads a single byte from external EEPROM.
#####Syntax
##### Syntax
`myEEPROM.read(unsigned long addr);`
#####Parameters
##### Parameters
**addr** *(unsigned long)*: The EEPROM location to read from.
#####Returns
##### Returns
The data read from EEPROM or an error code *(int)*. To distinguish error values from valid data, error values are returned as negative numbers. See the [Arduino Wire.endTransmission() function](http://arduino.cc/en/Reference/WireEndTransmission) for a description of return codes. Returns a status of EEPROM_ADDR_ERR if the I/O would extend past the top of the EEPROM address space.

#####Example
##### Example
```c++
int myData;
//read a byte from location 42
Expand All @@ -202,8 +215,9 @@ if ( readValue < 0 ) {
}
}
else {
//data read ok
//data read ok
}
```

![CC BY-SA](http://mirrors.creativecommons.org/presskit/buttons/80x15/png/by-sa.png)

0 comments on commit fd6610d

Please sign in to comment.