Cherrypick "add more locking for shared SPI devices (#5595) " (#5728)

* add more locking for shared SPI devices (#5595)

* add more locking for shared SPI devices
* call initSPI before the lock is used
* remove old one
* don't double lock
* Add missing unlock
* More missing unlocks
* Add locks to SafeFile, remove from `readcb`, introduce some LockGuards
* fix lock in setupSDCard()
* pull radiolib trunk with SPI-CS fixes
* change ContentHandler to Constructor type locks, where applicable

---------

Co-authored-by: mverch67 <manuel.verch@gmx.de>
Co-authored-by: GUVWAF <thijs@havinga.eu>
Co-authored-by: Manuel <71137295+mverch67@users.noreply.github.com>

* mesh-tab: lower I2C touch frequency

---------

Co-authored-by: Thomas Göttgens <tgoettgens@gmail.com>
Co-authored-by: mverch67 <manuel.verch@gmx.de>
Co-authored-by: GUVWAF <thijs@havinga.eu>
Co-authored-by: Manuel <71137295+mverch67@users.noreply.github.com>
This commit is contained in:
Tom Fifield
2025-01-03 10:05:26 +08:00
committed by GitHub
parent 9d710041c4
commit e1aaafb77a
16 changed files with 125 additions and 22 deletions

View File

@@ -1,6 +1,7 @@
#include "configuration.h"
#include "FSCommon.h"
#include "SPILock.h"
#include "mesh-pb-constants.h"
#include <Arduino.h>
#include <pb_decode.h>
@@ -55,9 +56,12 @@ bool readcb(pb_istream_t *stream, uint8_t *buf, size_t count)
/// Write to an arduino file
bool writecb(pb_ostream_t *stream, const uint8_t *buf, size_t count)
{
spiLock->lock();
auto file = (Print *)stream->state;
// LOG_DEBUG("writing %d bytes to protobuf file", count);
return file->write(buf, count) == count;
bool status = file->write(buf, count) == count;
spiLock->unlock();
return status;
}
#endif
@@ -68,4 +72,4 @@ bool is_in_helper(uint32_t n, const uint32_t *array, pb_size_t count)
return true;
return false;
}
}