Skip to content

Commit

Permalink
Rename to pre-transaction hook
Browse files Browse the repository at this point in the history
  • Loading branch information
mark9064 authored and JF002 committed May 1, 2024
1 parent 24e6a2f commit 7a92115
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/drivers/Spi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/drivers/Spi.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions src/drivers/SpiMaster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion src/drivers/SpiMaster.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/drivers/St7789.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion src/drivers/St7789.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 7a92115

Please sign in to comment.