Rename to pre-transaction hook

This commit is contained in:
mark9064 2024-04-18 18:54:07 +01:00 committed by JF
parent 24e6a2f8ab
commit 7a9211587a
6 changed files with 10 additions and 10 deletions

View file

@ -9,8 +9,8 @@ Spi::Spi(SpiMaster& spiMaster, uint8_t pinCsn) : spiMaster {spiMaster}, pinCsn {
nrf_gpio_pin_set(pinCsn);
}
bool Spi::Write(const uint8_t* data, size_t size, const std::function<void()>& transactionHook) {
return spiMaster.Write(pinCsn, data, size, transactionHook);
bool Spi::Write(const uint8_t* data, size_t size, const std::function<void()>& preTransactionHook) {
return spiMaster.Write(pinCsn, data, size, preTransactionHook);
}
bool Spi::Read(uint8_t* cmd, size_t cmdSize, uint8_t* data, size_t dataSize) {

View file

@ -15,7 +15,7 @@ namespace Pinetime {
Spi& operator=(Spi&&) = delete;
bool Init();
bool Write(const uint8_t* data, size_t size, const std::function<void()>& transactionHook);
bool Write(const uint8_t* data, size_t size, const std::function<void()>& preTransactionHook);
bool Read(uint8_t* cmd, size_t cmdSize, uint8_t* data, size_t dataSize);
bool WriteCmdAndBuffer(const uint8_t* cmd, size_t cmdSize, const uint8_t* data, size_t dataSize);
void Sleep();

View file

@ -167,7 +167,7 @@ void SpiMaster::PrepareRx(const uint32_t bufferAddress, const size_t size) {
spiBaseAddress->EVENTS_END = 0;
}
bool SpiMaster::Write(uint8_t pinCsn, const uint8_t* data, size_t size, const std::function<void()>& transactionHook) {
bool SpiMaster::Write(uint8_t pinCsn, const uint8_t* data, size_t size, const std::function<void()>& preTransactionHook) {
if (data == nullptr)
return false;
auto ok = xSemaphoreTake(mutex, portMAX_DELAY);
@ -181,8 +181,8 @@ bool SpiMaster::Write(uint8_t pinCsn, const uint8_t* data, size_t size, const st
DisableWorkaroundForFtpan58(spiBaseAddress, 0, 0);
}
if (transactionHook != nullptr) {
transactionHook();
if (preTransactionHook != nullptr) {
preTransactionHook();
}
nrf_gpio_pin_clear(this->pinCsn);

View file

@ -32,7 +32,7 @@ namespace Pinetime {
SpiMaster& operator=(SpiMaster&&) = delete;
bool Init();
bool Write(uint8_t pinCsn, const uint8_t* data, size_t size, const std::function<void()>& transactionHook);
bool Write(uint8_t pinCsn, const uint8_t* data, size_t size, const std::function<void()>& preTransactionHook);
bool Read(uint8_t pinCsn, uint8_t* cmd, size_t cmdSize, uint8_t* data, size_t dataSize);
bool WriteCmdAndBuffer(uint8_t pinCsn, const uint8_t* cmd, size_t cmdSize, const uint8_t* data, size_t dataSize);

View file

@ -49,8 +49,8 @@ void St7789::WriteCommand(const uint8_t* data, size_t size) {
});
}
void St7789::WriteSpi(const uint8_t* data, size_t size, const std::function<void()>& transactionHook) {
spi.Write(data, size, transactionHook);
void St7789::WriteSpi(const uint8_t* data, size_t size, const std::function<void()>& preTransactionHook) {
spi.Write(data, size, preTransactionHook);
}
void St7789::SoftwareReset() {

View file

@ -47,7 +47,7 @@ namespace Pinetime {
void SetVdv();
void WriteCommand(uint8_t cmd);
void WriteCommand(const uint8_t* data, size_t size);
void WriteSpi(const uint8_t* data, size_t size, const std::function<void()>& transactionHook);
void WriteSpi(const uint8_t* data, size_t size, const std::function<void()>& preTransactionHook);
enum class Commands : uint8_t {
SoftwareReset = 0x01,