Writes a signed long as four bytes starting from a specific location in a page Takes three arguments - 1. _addr --> Any address - from 0 to capacity 2. data --> One signed long 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()/era
| 906 | // WARNING: You can only write to previously erased memory locations (see datasheet). |
| 907 | // Use the eraseSector()/eraseBlock32K/eraseBlock64K commands to first clear memory (write 0xFFs) |
| 908 | bool SPIFlash::writeLong(uint32_t _addr, int32_t data, bool errorCheck) { |
| 909 | //return _write(_addr, data, sizeof(data), errorCheck, _LONG_); |
| 910 | #ifdef RUNDIAGNOSTIC |
| 911 | _spifuncruntime = micros(); |
| 912 | #endif |
| 913 | if(!_prep(PAGEPROG, _addr, sizeof(data))) { |
| 914 | return false; |
| 915 | } |
| 916 | |
| 917 | _beginSPI(PAGEPROG); |
| 918 | for (uint8_t i = 0; i < sizeof(data); i++) { |
| 919 | _nextByte(WRITE, data >> (8*i)); |
| 920 | } |
| 921 | CHIP_DESELECT |
| 922 | |
| 923 | if (!errorCheck) { |
| 924 | _endSPI(); |
| 925 | #ifdef RUNDIAGNOSTIC |
| 926 | _spifuncruntime = micros() - _spifuncruntime; |
| 927 | #endif |
| 928 | return true; |
| 929 | } |
| 930 | else { |
| 931 | if (!_notBusy()) { |
| 932 | return false; |
| 933 | } |
| 934 | union { |
| 935 | uint8_t byte[4]; |
| 936 | int32_t Long; |