diff options
| author | Riku Isokoski <riksu9000@gmail.com> | 2021-08-18 12:23:30 (GMT) |
|---|---|---|
| committer | Riku Isokoski <riksu9000@gmail.com> | 2021-08-18 12:23:30 (GMT) |
| commit | 780a811f0559a9abd000f36d3fe49cbbb233b632 (patch) | |
| tree | 9dca2951bc08a8d8a9f1f81d02f505682e652f69 /src/drivers/Cst816s.cpp | |
| parent | 9c175e2f0cd90b56818953b748c8cad3eec2eb89 (diff) | |
Automatic error detection
Diffstat (limited to 'src/drivers/Cst816s.cpp')
| -rw-r--r-- | src/drivers/Cst816s.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/drivers/Cst816s.cpp b/src/drivers/Cst816s.cpp index 2a6809b..3db712e 100644 --- a/src/drivers/Cst816s.cpp +++ b/src/drivers/Cst816s.cpp @@ -17,7 +17,7 @@ using namespace Pinetime::Drivers; Cst816S::Cst816S(TwiMaster& twiMaster, uint8_t twiAddress) : twiMaster {twiMaster}, twiAddress {twiAddress} { } -void Cst816S::Init() { +bool Cst816S::Init() { nrf_gpio_cfg_output(pinReset); nrf_gpio_pin_set(pinReset); vTaskDelay(50); @@ -44,13 +44,18 @@ void Cst816S::Init() { // There's mixed information about which register contains which information if (twiMaster.Read(twiAddress, 0xA7, &chipId, 1) == TwiMaster::ErrorCodes::TransactionFailed) { chipId = 0xFF; + return false; } if (twiMaster.Read(twiAddress, 0xA8, &vendorId, 1) == TwiMaster::ErrorCodes::TransactionFailed) { vendorId = 0xFF; + return false; } if (twiMaster.Read(twiAddress, 0xA9, &fwVersion, 1) == TwiMaster::ErrorCodes::TransactionFailed) { fwVersion = 0xFF; + return false; } + + return chipId == 0xb4 && vendorId == 0 && fwVersion == 1; } Cst816S::TouchInfos Cst816S::GetTouchInfo() { |
