summaryrefslogtreecommitdiff
path: root/src/drivers
diff options
context:
space:
mode:
authorRiku Isokoski <riksu9000@gmail.com>2021-07-15 22:49:20 (GMT)
committerRiku Isokoski <riksu9000@gmail.com>2021-07-15 22:49:20 (GMT)
commit93ccbf38e81b30165e49e897c01cac2eb54cc331 (patch)
treed8e1098b5dfebeb170388ccfa70b611a0900542b /src/drivers
parent2a3e1263906d1145d6b539ff019362f0077d8097 (diff)
Fix touch wakeup and code cleanup
Diffstat (limited to 'src/drivers')
-rw-r--r--src/drivers/TwiMaster.cpp12
-rw-r--r--src/drivers/TwiMaster.h3
2 files changed, 10 insertions, 5 deletions
diff --git a/src/drivers/TwiMaster.cpp b/src/drivers/TwiMaster.cpp
index fc9edf8..456c3e6 100644
--- a/src/drivers/TwiMaster.cpp
+++ b/src/drivers/TwiMaster.cpp
@@ -12,9 +12,10 @@ TwiMaster::TwiMaster(const Modules module, const Parameters& params) : module {m
}
void TwiMaster::Init() {
+ sleeping = false;
if(mutex == nullptr)
mutex = xSemaphoreCreateBinary();
-
+
NRF_GPIO->PIN_CNF[params.pinScl] =
((uint32_t) GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos) | ((uint32_t) GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) |
((uint32_t) GPIO_PIN_CNF_PULL_Pullup << GPIO_PIN_CNF_PULL_Pos) | ((uint32_t) GPIO_PIN_CNF_DRIVE_S0D1 << GPIO_PIN_CNF_DRIVE_Pos) |
@@ -176,11 +177,14 @@ void TwiMaster::Sleep() {
nrf_gpio_cfg_default(6);
nrf_gpio_cfg_default(7);
NRF_LOG_INFO("[TWIMASTER] Sleep");
+ sleeping = true;
}
void TwiMaster::Wakeup() {
- Init();
- NRF_LOG_INFO("[TWIMASTER] Wakeup");
+ if (sleeping) {
+ Init();
+ NRF_LOG_INFO("[TWIMASTER] Wakeup");
+ }
}
/* Sometimes, the TWIM device just freeze and never set the event EVENTS_LASTTX.
@@ -206,4 +210,4 @@ void TwiMaster::FixHwFreezed() {
// Re-enable I²C
twiBaseAddress->ENABLE = twi_state;
-} \ No newline at end of file
+}
diff --git a/src/drivers/TwiMaster.h b/src/drivers/TwiMaster.h
index 6175b99..5748ec6 100644
--- a/src/drivers/TwiMaster.h
+++ b/src/drivers/TwiMaster.h
@@ -39,6 +39,7 @@ namespace Pinetime {
uint8_t internalBuffer[maxDataSize + registerSize];
uint32_t txStartedCycleCount = 0;
static constexpr uint32_t HwFreezedDelay {161000};
+ bool sleeping;
};
}
-} \ No newline at end of file
+}