diff options
Diffstat (limited to 'src/drivers')
-rw-r--r-- | src/drivers/Bma421.cpp | 14 | ||||
-rw-r--r-- | src/drivers/Bma421.h | 6 | ||||
-rw-r--r-- | src/drivers/Cst816s.cpp | 11 | ||||
-rw-r--r-- | src/drivers/Cst816s.h | 11 | ||||
-rw-r--r-- | src/drivers/PinMap.h | 24 | ||||
-rw-r--r-- | src/drivers/SpiMaster.cpp | 2 | ||||
-rw-r--r-- | src/drivers/TwiMaster.cpp | 20 |
7 files changed, 40 insertions, 48 deletions
diff --git a/src/drivers/Bma421.cpp b/src/drivers/Bma421.cpp index 2f60f42f..539cc8d1 100644 --- a/src/drivers/Bma421.cpp +++ b/src/drivers/Bma421.cpp @@ -42,10 +42,16 @@ void Bma421::Init() { if (ret != BMA4_OK) return; - switch(bma.chip_id) { - case BMA423_CHIP_ID: deviceType = DeviceTypes::BMA421; break; - case BMA425_CHIP_ID: deviceType = DeviceTypes::BMA425; break; - default: deviceType = DeviceTypes::Unknown; break; + switch (bma.chip_id) { + case BMA423_CHIP_ID: + deviceType = DeviceTypes::BMA421; + break; + case BMA425_CHIP_ID: + deviceType = DeviceTypes::BMA425; + break; + default: + deviceType = DeviceTypes::Unknown; + break; } ret = bma423_write_config_file(&bma); diff --git a/src/drivers/Bma421.h b/src/drivers/Bma421.h index ace644bd..ac5c707f 100644 --- a/src/drivers/Bma421.h +++ b/src/drivers/Bma421.h @@ -6,11 +6,7 @@ namespace Pinetime { class TwiMaster; class Bma421 { public: - enum class DeviceTypes : uint8_t { - Unknown, - BMA421, - BMA425 - }; + enum class DeviceTypes : uint8_t { Unknown, BMA421, BMA425 }; struct Values { uint32_t steps; int16_t x; diff --git a/src/drivers/Cst816s.cpp b/src/drivers/Cst816s.cpp index e9573df1..cf10c895 100644 --- a/src/drivers/Cst816s.cpp +++ b/src/drivers/Cst816s.cpp @@ -80,14 +80,9 @@ Cst816S::TouchInfos Cst816S::GetTouchInfo() { Gestures gesture = static_cast<Gestures>(touchData[gestureIndex]); // Validity check - if(x >= maxX || y >= maxY || - (gesture != Gestures::None && - gesture != Gestures::SlideDown && - gesture != Gestures::SlideUp && - gesture != Gestures::SlideLeft && - gesture != Gestures::SlideRight && - gesture != Gestures::SingleTap && - gesture != Gestures::DoubleTap && + if (x >= maxX || y >= maxY || + (gesture != Gestures::None && gesture != Gestures::SlideDown && gesture != Gestures::SlideUp && gesture != Gestures::SlideLeft && + gesture != Gestures::SlideRight && gesture != Gestures::SingleTap && gesture != Gestures::DoubleTap && gesture != Gestures::LongPress)) { info.isValid = false; return info; diff --git a/src/drivers/Cst816s.h b/src/drivers/Cst816s.h index 4a548d45..9d426c9d 100644 --- a/src/drivers/Cst816s.h +++ b/src/drivers/Cst816s.h @@ -44,21 +44,22 @@ namespace Pinetime { uint8_t GetFwVersion() const { return fwVersion; } + private: bool CheckDeviceIds(); // Unused/Unavailable commented out static constexpr uint8_t gestureIndex = 1; static constexpr uint8_t touchPointNumIndex = 2; - //static constexpr uint8_t touchEventIndex = 3; + // static constexpr uint8_t touchEventIndex = 3; static constexpr uint8_t touchXHighIndex = 3; static constexpr uint8_t touchXLowIndex = 4; - //static constexpr uint8_t touchIdIndex = 5; + // static constexpr uint8_t touchIdIndex = 5; static constexpr uint8_t touchYHighIndex = 5; static constexpr uint8_t touchYLowIndex = 6; - //static constexpr uint8_t touchStep = 6; - //static constexpr uint8_t touchXYIndex = 7; - //static constexpr uint8_t touchMiscIndex = 8; + // static constexpr uint8_t touchStep = 6; + // static constexpr uint8_t touchXYIndex = 7; + // static constexpr uint8_t touchMiscIndex = 8; static constexpr uint8_t maxX = 240; static constexpr uint8_t maxY = 240; diff --git a/src/drivers/PinMap.h b/src/drivers/PinMap.h index 579bf38a..167a8771 100644 --- a/src/drivers/PinMap.h +++ b/src/drivers/PinMap.h @@ -3,18 +3,18 @@ namespace Pinetime { namespace PinMap { - - #ifdef WATCH_P8 - // COLMI P8 - static constexpr uint8_t Charging = 19; - static constexpr uint8_t Cst816sReset = 13; - static constexpr uint8_t Button = 17; - #else - // Pinetime - static constexpr uint8_t Charging = 12; - static constexpr uint8_t Cst816sReset = 10; - static constexpr uint8_t Button = 13; - #endif + +#ifdef WATCH_P8 + // COLMI P8 + static constexpr uint8_t Charging = 19; + static constexpr uint8_t Cst816sReset = 13; + static constexpr uint8_t Button = 17; +#else + // Pinetime + static constexpr uint8_t Charging = 12; + static constexpr uint8_t Cst816sReset = 10; + static constexpr uint8_t Button = 13; +#endif static constexpr uint8_t Cst816sIrq = 28; static constexpr uint8_t PowerPresent = 19; diff --git a/src/drivers/SpiMaster.cpp b/src/drivers/SpiMaster.cpp index 747dbc84..38f72fee 100644 --- a/src/drivers/SpiMaster.cpp +++ b/src/drivers/SpiMaster.cpp @@ -10,7 +10,7 @@ SpiMaster::SpiMaster(const SpiMaster::SpiModule spi, const SpiMaster::Parameters } bool SpiMaster::Init() { - if(mutex == nullptr) { + if (mutex == nullptr) { mutex = xSemaphoreCreateBinary(); ASSERT(mutex != nullptr); } diff --git a/src/drivers/TwiMaster.cpp b/src/drivers/TwiMaster.cpp index 9b456d5f..25d23c28 100644 --- a/src/drivers/TwiMaster.cpp +++ b/src/drivers/TwiMaster.cpp @@ -13,19 +13,13 @@ TwiMaster::TwiMaster(NRF_TWIM_Type* module, uint32_t frequency, uint8_t pinSda, } void TwiMaster::ConfigurePins() const { - NRF_GPIO->PIN_CNF[pinScl] = - (GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos) | - (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) | - (GPIO_PIN_CNF_PULL_Disabled << GPIO_PIN_CNF_PULL_Pos) | - (GPIO_PIN_CNF_DRIVE_S0D1 << GPIO_PIN_CNF_DRIVE_Pos) | - (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos); - - NRF_GPIO->PIN_CNF[pinSda] = - (GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos) | - (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) | - (GPIO_PIN_CNF_PULL_Disabled << GPIO_PIN_CNF_PULL_Pos) | - (GPIO_PIN_CNF_DRIVE_S0D1 << GPIO_PIN_CNF_DRIVE_Pos) | - (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos); + NRF_GPIO->PIN_CNF[pinScl] = (GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos) | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) | + (GPIO_PIN_CNF_PULL_Disabled << GPIO_PIN_CNF_PULL_Pos) | (GPIO_PIN_CNF_DRIVE_S0D1 << GPIO_PIN_CNF_DRIVE_Pos) | + (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos); + + NRF_GPIO->PIN_CNF[pinSda] = (GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos) | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) | + (GPIO_PIN_CNF_PULL_Disabled << GPIO_PIN_CNF_PULL_Pos) | (GPIO_PIN_CNF_DRIVE_S0D1 << GPIO_PIN_CNF_DRIVE_Pos) | + (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos); } void TwiMaster::Init() { |