Rename to pre-transaction hook
This commit is contained in:
parent
24e6a2f8ab
commit
7a9211587a
|
@ -9,8 +9,8 @@ Spi::Spi(SpiMaster& spiMaster, uint8_t pinCsn) : spiMaster {spiMaster}, pinCsn {
|
||||||
nrf_gpio_pin_set(pinCsn);
|
nrf_gpio_pin_set(pinCsn);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Spi::Write(const uint8_t* data, size_t size, const std::function<void()>& transactionHook) {
|
bool Spi::Write(const uint8_t* data, size_t size, const std::function<void()>& preTransactionHook) {
|
||||||
return spiMaster.Write(pinCsn, data, size, transactionHook);
|
return spiMaster.Write(pinCsn, data, size, preTransactionHook);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Spi::Read(uint8_t* cmd, size_t cmdSize, uint8_t* data, size_t dataSize) {
|
bool Spi::Read(uint8_t* cmd, size_t cmdSize, uint8_t* data, size_t dataSize) {
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace Pinetime {
|
||||||
Spi& operator=(Spi&&) = delete;
|
Spi& operator=(Spi&&) = delete;
|
||||||
|
|
||||||
bool Init();
|
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 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);
|
bool WriteCmdAndBuffer(const uint8_t* cmd, size_t cmdSize, const uint8_t* data, size_t dataSize);
|
||||||
void Sleep();
|
void Sleep();
|
||||||
|
|
|
@ -167,7 +167,7 @@ void SpiMaster::PrepareRx(const uint32_t bufferAddress, const size_t size) {
|
||||||
spiBaseAddress->EVENTS_END = 0;
|
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)
|
if (data == nullptr)
|
||||||
return false;
|
return false;
|
||||||
auto ok = xSemaphoreTake(mutex, portMAX_DELAY);
|
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);
|
DisableWorkaroundForFtpan58(spiBaseAddress, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (transactionHook != nullptr) {
|
if (preTransactionHook != nullptr) {
|
||||||
transactionHook();
|
preTransactionHook();
|
||||||
}
|
}
|
||||||
nrf_gpio_pin_clear(this->pinCsn);
|
nrf_gpio_pin_clear(this->pinCsn);
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ namespace Pinetime {
|
||||||
SpiMaster& operator=(SpiMaster&&) = delete;
|
SpiMaster& operator=(SpiMaster&&) = delete;
|
||||||
|
|
||||||
bool Init();
|
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 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);
|
bool WriteCmdAndBuffer(uint8_t pinCsn, const uint8_t* cmd, size_t cmdSize, const uint8_t* data, size_t dataSize);
|
||||||
|
|
|
@ -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) {
|
void St7789::WriteSpi(const uint8_t* data, size_t size, const std::function<void()>& preTransactionHook) {
|
||||||
spi.Write(data, size, transactionHook);
|
spi.Write(data, size, preTransactionHook);
|
||||||
}
|
}
|
||||||
|
|
||||||
void St7789::SoftwareReset() {
|
void St7789::SoftwareReset() {
|
||||||
|
|
|
@ -47,7 +47,7 @@ namespace Pinetime {
|
||||||
void SetVdv();
|
void SetVdv();
|
||||||
void WriteCommand(uint8_t cmd);
|
void WriteCommand(uint8_t cmd);
|
||||||
void WriteCommand(const uint8_t* data, size_t size);
|
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 {
|
enum class Commands : uint8_t {
|
||||||
SoftwareReset = 0x01,
|
SoftwareReset = 0x01,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user