MCPcopy Create free account
hub / github.com/Marzogh/SPIMemory / writeByte

Method writeByte

src/SPIFlash.cpp:461–484  ·  view source on GitHub ↗

Writes a byte of data to a specific location in a page. Takes three arguments - 1. _addr --> Any address - from 0 to capacity 2. data --> One byte to be written to a particular location on a page 3. errorCheck --> Turned on by default. Checks for writing errors WARNING: You can only write to previously erased memory locations (see datasheet). Use the eraseSector()/eraseBlock32K/eraseBlock64K comma

Source from the content-addressed store, hash-verified

459// WARNING: You can only write to previously erased memory locations (see datasheet).
460// Use the eraseSector()/eraseBlock32K/eraseBlock64K commands to first clear memory (write 0xFFs)
461bool SPIFlash::writeByte(uint32_t _addr, uint8_t data, bool errorCheck) {
462 //return _write(_addr, data, sizeof(data), errorCheck, _BYTE_);
463 #ifdef RUNDIAGNOSTIC
464 _spifuncruntime = micros();
465 #endif
466 if(!_prep(PAGEPROG, _addr, sizeof(data))) {
467 return false;
468 }
469
470 _beginSPI(PAGEPROG);
471 _nextByte(WRITE, data);
472 CHIP_DESELECT
473
474 if (!errorCheck) {
475 _endSPI();
476 #ifdef RUNDIAGNOSTIC
477 _spifuncruntime = micros() - _spifuncruntime;
478 #endif
479 return true;
480 }
481 else {
482 if (!_notBusy()) {
483 return false;
484 }
485 _currentAddress = _addr;
486 CHIP_SELECT
487 _nextByte(WRITE, READDATA);

Callers

nothing calls this directly

Calls 1

ifFunction · 0.70

Tested by

no test coverage detected