MCPcopy Create free account
hub / github.com/RobTillaart/Arduino / _getMetaData

Method _getMetaData

libraries/FRAM_I2C/FRAM.cpp:305–333  ·  view source on GitHub ↗

metadata is packed as [....MMMM][MMMMDDDD][PPPPPPPP] M = manufacturerID D = density => memory size = 2^D KB P = product ID (together with D)

Source from the content-addressed store, hash-verified

303// D = density => memory size = 2^D KB
304// P = product ID (together with D)
305uint16_t FRAM::_getMetaData(uint8_t field)
306{
307 if (field > 2) return 0;
308
309 _wire->beginTransmission(FRAM_SLAVE_ID_);
310 _wire->write(_address << 1);
311 _wire->endTransmission(false);
312 int x = _wire->requestFrom(FRAM_SLAVE_ID_, (uint8_t)3);
313 if (x != 3) return -1;
314
315 uint32_t value = 0;
316 value = _wire->read();
317 value = value << 8;
318 value |= _wire->read();
319 value = value << 8;
320 value |= _wire->read();
321
322 // MANUFACTURER
323 if (field == 0) return (value >> 12) & 0xFF;
324 // PRODUCT ID
325 if (field == 1) return value & 0x0FFF;
326 // DENSITY
327 // 3 => MB85RC64
328 // 5 => MB85RC256
329 // 6 => MB85RC512
330 // 7 => MB85RC1M
331 if (field == 2) return (value >> 8) & 0x0F;
332 return 0;
333}
334
335
336void FRAM::_writeBlock(uint16_t memaddr, uint8_t * obj, uint8_t size)

Callers

nothing calls this directly

Calls 2

writeMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected