Merge pull request #549 from hubmartin/pinmap

Put all duplicated GPIO pin definitions to a single file
This commit is contained in:
JF002 2021-09-13 20:05:43 +02:00 committed by GitHub
commit b0bdd2be1c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 118 additions and 92 deletions

View file

@ -51,6 +51,14 @@ if(BUILD_DFU)
set(BUILD_DFU true) set(BUILD_DFU true)
endif() endif()
option(WATCH_COLMI_P8 "Build for the Colmi P8" OFF)
set(TARGET_DEVICE "PineTime")
if(WATCH_COLMI_P8)
set(TARGET_DEVICE "Colmi P8")
add_definitions(-DWATCH_P8)
endif()
set(PROJECT_GIT_COMMIT_HASH "") set(PROJECT_GIT_COMMIT_HASH "")
execute_process(COMMAND git rev-parse --short HEAD execute_process(COMMAND git rev-parse --short HEAD
@ -68,6 +76,7 @@ message(" * Version : " ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${P
message(" * Toolchain : " ${ARM_NONE_EABI_TOOLCHAIN_PATH}) message(" * Toolchain : " ${ARM_NONE_EABI_TOOLCHAIN_PATH})
message(" * GitRef(S) : " ${PROJECT_GIT_COMMIT_HASH}) message(" * GitRef(S) : " ${PROJECT_GIT_COMMIT_HASH})
message(" * NRF52 SDK : " ${NRF5_SDK_PATH}) message(" * NRF52 SDK : " ${NRF5_SDK_PATH})
message(" * Target device : " ${TARGET_DEVICE})
set(PROGRAMMER "???") set(PROGRAMMER "???")
if(USE_JLINK) if(USE_JLINK)
message(" * Programmer/debugger : JLINK") message(" * Programmer/debugger : JLINK")

View file

@ -28,6 +28,7 @@ CMake configures the project according to variables you specify the command line
**GDB_CLIENT_BIN_PATH**|Path to arm-none-eabi-gdb executable. Used only if `USE_GDB_CLIENT` is 1.|`-DGDB_CLIENT_BIN_PATH=/home/jf/nrf52/gcc-arm-none-eabi-9-2019-q4-major/bin/arm-none-eabi-gdb` **GDB_CLIENT_BIN_PATH**|Path to arm-none-eabi-gdb executable. Used only if `USE_GDB_CLIENT` is 1.|`-DGDB_CLIENT_BIN_PATH=/home/jf/nrf52/gcc-arm-none-eabi-9-2019-q4-major/bin/arm-none-eabi-gdb`
**GDB_CLIENT_TARGET_REMOTE**|Target remote connection string. Used only if `USE_GDB_CLIENT` is 1.|`-DGDB_CLIENT_TARGET_REMOTE=/dev/ttyACM0` **GDB_CLIENT_TARGET_REMOTE**|Target remote connection string. Used only if `USE_GDB_CLIENT` is 1.|`-DGDB_CLIENT_TARGET_REMOTE=/dev/ttyACM0`
**BUILD_DFU (\*\*)**|Build DFU files while building (needs [adafruit-nrfutil](https://github.com/adafruit/Adafruit_nRF52_nrfutil)).|`-DBUILD_DFU=1` **BUILD_DFU (\*\*)**|Build DFU files while building (needs [adafruit-nrfutil](https://github.com/adafruit/Adafruit_nRF52_nrfutil)).|`-DBUILD_DFU=1`
**WATCH_COLMI_P8**|Use pin configuration for Colmi P8 watch|`-DWATCH_COLMI_P8=1`
####(**) Note about **CMAKE_BUILD_TYPE**: ####(**) Note about **CMAKE_BUILD_TYPE**:
By default, this variable is set to *Release*. It compiles the code with size and speed optimizations. We use this value for all the binaries we publish when we [release](https://github.com/JF002/InfiniTime/releases) new versions of InfiniTime. By default, this variable is set to *Release*. It compiles the code with size and speed optimizations. We use this value for all the binaries we publish when we [release](https://github.com/JF002/InfiniTime/releases) new versions of InfiniTime.

View file

@ -621,6 +621,7 @@ set(INCLUDE_FILES
drivers/DebugPins.h drivers/DebugPins.h
drivers/InternalFlash.h drivers/InternalFlash.h
drivers/Hrs3300.h drivers/Hrs3300.h
drivers/PinMap.h
drivers/Bma421.h drivers/Bma421.h
drivers/Bma421_C/bma4.c drivers/Bma421_C/bma4.c
drivers/Bma421_C/bma423.c drivers/Bma421_C/bma423.c

View file

@ -1,4 +1,5 @@
#include "BatteryController.h" #include "BatteryController.h"
#include "drivers/PinMap.h"
#include <hal/nrf_gpio.h> #include <hal/nrf_gpio.h>
#include <nrfx_saadc.h> #include <nrfx_saadc.h>
#include <algorithm> #include <algorithm>
@ -9,12 +10,12 @@ Battery* Battery::instance = nullptr;
Battery::Battery() { Battery::Battery() {
instance = this; instance = this;
nrf_gpio_cfg_input(chargingPin, static_cast<nrf_gpio_pin_pull_t> GPIO_PIN_CNF_PULL_Disabled); nrf_gpio_cfg_input(PinMap::Charging, static_cast<nrf_gpio_pin_pull_t> GPIO_PIN_CNF_PULL_Disabled);
} }
void Battery::Update() { void Battery::Update() {
isCharging = !nrf_gpio_pin_read(chargingPin); isCharging = !nrf_gpio_pin_read(PinMap::Charging);
isPowerPresent = !nrf_gpio_pin_read(powerPresentPin); isPowerPresent = !nrf_gpio_pin_read(PinMap::PowerPresent);
if (isReading) { if (isReading) {
return; return;

View file

@ -33,8 +33,6 @@ namespace Pinetime {
static Battery* instance; static Battery* instance;
nrf_saadc_value_t saadc_value; nrf_saadc_value_t saadc_value;
static constexpr uint32_t chargingPin = 12;
static constexpr uint32_t powerPresentPin = 19;
static constexpr nrf_saadc_input_t batteryVoltageAdcInput = NRF_SAADC_INPUT_AIN7; static constexpr nrf_saadc_input_t batteryVoltageAdcInput = NRF_SAADC_INPUT_AIN7;
uint16_t voltage = 0; uint16_t voltage = 0;
uint8_t percentRemaining = 0; uint8_t percentRemaining = 0;

View file

@ -1,13 +1,13 @@
#include "BrightnessController.h" #include "BrightnessController.h"
#include <hal/nrf_gpio.h> #include <hal/nrf_gpio.h>
#include "displayapp/screens/Symbols.h" #include "displayapp/screens/Symbols.h"
#include "drivers/PinMap.h"
using namespace Pinetime::Controllers; using namespace Pinetime::Controllers;
void BrightnessController::Init() { void BrightnessController::Init() {
nrf_gpio_cfg_output(pinLcdBacklight1); nrf_gpio_cfg_output(PinMap::LcdBacklightLow);
nrf_gpio_cfg_output(pinLcdBacklight2); nrf_gpio_cfg_output(PinMap::LcdBacklightMedium);
nrf_gpio_cfg_output(pinLcdBacklight3); nrf_gpio_cfg_output(PinMap::LcdBacklightHigh);
Set(level); Set(level);
} }
@ -16,24 +16,24 @@ void BrightnessController::Set(BrightnessController::Levels level) {
switch (level) { switch (level) {
default: default:
case Levels::High: case Levels::High:
nrf_gpio_pin_clear(pinLcdBacklight1); nrf_gpio_pin_clear(PinMap::LcdBacklightLow);
nrf_gpio_pin_clear(pinLcdBacklight2); nrf_gpio_pin_clear(PinMap::LcdBacklightMedium);
nrf_gpio_pin_clear(pinLcdBacklight3); nrf_gpio_pin_clear(PinMap::LcdBacklightHigh);
break; break;
case Levels::Medium: case Levels::Medium:
nrf_gpio_pin_clear(pinLcdBacklight1); nrf_gpio_pin_clear(PinMap::LcdBacklightLow);
nrf_gpio_pin_clear(pinLcdBacklight2); nrf_gpio_pin_clear(PinMap::LcdBacklightMedium);
nrf_gpio_pin_set(pinLcdBacklight3); nrf_gpio_pin_set(PinMap::LcdBacklightHigh);
break; break;
case Levels::Low: case Levels::Low:
nrf_gpio_pin_clear(pinLcdBacklight1); nrf_gpio_pin_clear(PinMap::LcdBacklightLow);
nrf_gpio_pin_set(pinLcdBacklight2); nrf_gpio_pin_set(PinMap::LcdBacklightMedium);
nrf_gpio_pin_set(pinLcdBacklight3); nrf_gpio_pin_set(PinMap::LcdBacklightHigh);
break; break;
case Levels::Off: case Levels::Off:
nrf_gpio_pin_set(pinLcdBacklight1); nrf_gpio_pin_set(PinMap::LcdBacklightLow);
nrf_gpio_pin_set(pinLcdBacklight2); nrf_gpio_pin_set(PinMap::LcdBacklightMedium);
nrf_gpio_pin_set(pinLcdBacklight3); nrf_gpio_pin_set(PinMap::LcdBacklightHigh);
break; break;
} }
} }

View file

@ -22,9 +22,6 @@ namespace Pinetime {
const char* ToString(); const char* ToString();
private: private:
static constexpr uint8_t pinLcdBacklight1 = 14;
static constexpr uint8_t pinLcdBacklight2 = 22;
static constexpr uint8_t pinLcdBacklight3 = 23;
Levels level = Levels::High; Levels level = Levels::High;
Levels backupLevel = Levels::High; Levels backupLevel = Levels::High;
}; };

View file

@ -2,6 +2,7 @@
#include <hal/nrf_gpio.h> #include <hal/nrf_gpio.h>
#include "systemtask/SystemTask.h" #include "systemtask/SystemTask.h"
#include "app_timer.h" #include "app_timer.h"
#include "drivers/PinMap.h"
APP_TIMER_DEF(shortVibTimer); APP_TIMER_DEF(shortVibTimer);
APP_TIMER_DEF(longVibTimer); APP_TIMER_DEF(longVibTimer);
@ -12,8 +13,8 @@ MotorController::MotorController(Controllers::Settings& settingsController) : se
} }
void MotorController::Init() { void MotorController::Init() {
nrf_gpio_cfg_output(pinMotor); nrf_gpio_cfg_output(PinMap::Motor);
nrf_gpio_pin_set(pinMotor); nrf_gpio_pin_set(PinMap::Motor);
app_timer_init(); app_timer_init();
app_timer_create(&shortVibTimer, APP_TIMER_MODE_SINGLE_SHOT, StopMotor); app_timer_create(&shortVibTimer, APP_TIMER_MODE_SINGLE_SHOT, StopMotor);
@ -30,7 +31,7 @@ void MotorController::RunForDuration(uint8_t motorDuration) {
return; return;
} }
nrf_gpio_pin_clear(pinMotor); nrf_gpio_pin_clear(PinMap::Motor);
app_timer_start(shortVibTimer, APP_TIMER_TICKS(motorDuration), nullptr); app_timer_start(shortVibTimer, APP_TIMER_TICKS(motorDuration), nullptr);
} }
@ -44,9 +45,9 @@ void MotorController::StartRinging() {
void MotorController::StopRinging() { void MotorController::StopRinging() {
app_timer_stop(longVibTimer); app_timer_stop(longVibTimer);
nrf_gpio_pin_set(pinMotor); nrf_gpio_pin_set(PinMap::Motor);
} }
void MotorController::StopMotor(void* p_context) { void MotorController::StopMotor(void* p_context) {
nrf_gpio_pin_set(pinMotor); nrf_gpio_pin_set(PinMap::Motor);
} }

View file

@ -6,7 +6,6 @@
namespace Pinetime { namespace Pinetime {
namespace Controllers { namespace Controllers {
static constexpr uint8_t pinMotor = 16;
class MotorController { class MotorController {
public: public:

View file

@ -3,6 +3,7 @@
#include <legacy/nrf_drv_gpiote.h> #include <legacy/nrf_drv_gpiote.h>
#include <nrfx_log.h> #include <nrfx_log.h>
#include <task.h> #include <task.h>
#include "drivers/PinMap.h"
using namespace Pinetime::Drivers; using namespace Pinetime::Drivers;
@ -18,12 +19,12 @@ Cst816S::Cst816S(TwiMaster& twiMaster, uint8_t twiAddress) : twiMaster {twiMaste
} }
void Cst816S::Init() { void Cst816S::Init() {
nrf_gpio_cfg_output(pinReset); nrf_gpio_cfg_output(PinMap::Cst816sReset);
nrf_gpio_pin_set(pinReset); nrf_gpio_pin_set(PinMap::Cst816sReset);
vTaskDelay(50); vTaskDelay(50);
nrf_gpio_pin_clear(pinReset); nrf_gpio_pin_clear(PinMap::Cst816sReset);
vTaskDelay(5); vTaskDelay(5);
nrf_gpio_pin_set(pinReset); nrf_gpio_pin_set(PinMap::Cst816sReset);
vTaskDelay(50); vTaskDelay(50);
// Wake the touchpanel up // Wake the touchpanel up
@ -80,9 +81,9 @@ Cst816S::TouchInfos Cst816S::GetTouchInfo() {
} }
void Cst816S::Sleep() { void Cst816S::Sleep() {
nrf_gpio_pin_clear(pinReset); nrf_gpio_pin_clear(PinMap::Cst816sReset);
vTaskDelay(5); vTaskDelay(5);
nrf_gpio_pin_set(pinReset); nrf_gpio_pin_set(PinMap::Cst816sReset);
vTaskDelay(50); vTaskDelay(50);
static constexpr uint8_t sleepValue = 0x03; static constexpr uint8_t sleepValue = 0x03;
twiMaster.Write(twiAddress, 0xA5, &sleepValue, 1); twiMaster.Write(twiAddress, 0xA5, &sleepValue, 1);

View file

@ -36,9 +36,6 @@ namespace Pinetime {
void Wakeup(); void Wakeup();
private: private:
static constexpr uint8_t pinIrq = 28;
static constexpr uint8_t pinReset = 10;
// Unused/Unavailable commented out // Unused/Unavailable commented out
static constexpr uint8_t gestureIndex = 1; static constexpr uint8_t gestureIndex = 1;
static constexpr uint8_t touchPointNumIndex = 2; static constexpr uint8_t touchPointNumIndex = 2;

38
src/drivers/PinMap.h Normal file
View file

@ -0,0 +1,38 @@
#pragma once
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
static constexpr uint8_t Cst816sIrq = 28;
static constexpr uint8_t PowerPresent = 19;
static constexpr uint8_t Motor = 16;
static constexpr uint8_t LcdBacklightLow = 14;
static constexpr uint8_t LcdBacklightMedium = 22;
static constexpr uint8_t LcdBacklightHigh = 23;
static constexpr uint8_t SpiSck = 2;
static constexpr uint8_t SpiMosi = 3;
static constexpr uint8_t SpiMiso = 4;
static constexpr uint8_t SpiFlashCsn = 5;
static constexpr uint8_t SpiLcdCsn = 25;
static constexpr uint8_t LcdDataCommand = 18;
static constexpr uint8_t TwiScl = 7;
static constexpr uint8_t TwiSda = 6;
}
}

View file

@ -43,7 +43,9 @@
#include "drivers/St7789.h" #include "drivers/St7789.h"
#include "drivers/TwiMaster.h" #include "drivers/TwiMaster.h"
#include "drivers/Cst816s.h" #include "drivers/Cst816s.h"
#include "drivers/PinMap.h"
#include "systemtask/SystemTask.h" #include "systemtask/SystemTask.h"
#include "drivers/PinMap.h"
#include "touchhandler/TouchHandler.h" #include "touchhandler/TouchHandler.h"
#if NRF_LOG_ENABLED #if NRF_LOG_ENABLED
@ -54,14 +56,6 @@ Pinetime::Logging::NrfLogger logger;
Pinetime::Logging::DummyLogger logger; Pinetime::Logging::DummyLogger logger;
#endif #endif
static constexpr uint8_t pinSpiSck = 2;
static constexpr uint8_t pinSpiMosi = 3;
static constexpr uint8_t pinSpiMiso = 4;
static constexpr uint8_t pinSpiFlashCsn = 5;
static constexpr uint8_t pinLcdCsn = 25;
static constexpr uint8_t pinLcdDataCommand = 18;
static constexpr uint8_t pinTwiScl = 7;
static constexpr uint8_t pinTwiSda = 6;
static constexpr uint8_t touchPanelTwiAddress = 0x15; static constexpr uint8_t touchPanelTwiAddress = 0x15;
static constexpr uint8_t motionSensorTwiAddress = 0x18; static constexpr uint8_t motionSensorTwiAddress = 0x18;
static constexpr uint8_t heartRateSensorTwiAddress = 0x44; static constexpr uint8_t heartRateSensorTwiAddress = 0x44;
@ -70,21 +64,21 @@ Pinetime::Drivers::SpiMaster spi {Pinetime::Drivers::SpiMaster::SpiModule::SPI0,
{Pinetime::Drivers::SpiMaster::BitOrder::Msb_Lsb, {Pinetime::Drivers::SpiMaster::BitOrder::Msb_Lsb,
Pinetime::Drivers::SpiMaster::Modes::Mode3, Pinetime::Drivers::SpiMaster::Modes::Mode3,
Pinetime::Drivers::SpiMaster::Frequencies::Freq8Mhz, Pinetime::Drivers::SpiMaster::Frequencies::Freq8Mhz,
pinSpiSck, Pinetime::PinMap::SpiSck,
pinSpiMosi, Pinetime::PinMap::SpiMosi,
pinSpiMiso}}; Pinetime::PinMap::SpiMiso}};
Pinetime::Drivers::Spi lcdSpi {spi, pinLcdCsn}; Pinetime::Drivers::Spi lcdSpi {spi, Pinetime::PinMap::SpiLcdCsn};
Pinetime::Drivers::St7789 lcd {lcdSpi, pinLcdDataCommand}; Pinetime::Drivers::St7789 lcd {lcdSpi, Pinetime::PinMap::LcdDataCommand};
Pinetime::Drivers::Spi flashSpi {spi, pinSpiFlashCsn}; Pinetime::Drivers::Spi flashSpi {spi, Pinetime::PinMap::SpiFlashCsn};
Pinetime::Drivers::SpiNorFlash spiNorFlash {flashSpi}; Pinetime::Drivers::SpiNorFlash spiNorFlash {flashSpi};
// The TWI device should work @ up to 400Khz but there is a HW bug which prevent it from // The TWI device should work @ up to 400Khz but there is a HW bug which prevent it from
// respecting correct timings. According to erratas heet, this magic value makes it run // respecting correct timings. According to erratas heet, this magic value makes it run
// at ~390Khz with correct timings. // at ~390Khz with correct timings.
static constexpr uint32_t MaxTwiFrequencyWithoutHardwareBug {0x06200000}; static constexpr uint32_t MaxTwiFrequencyWithoutHardwareBug {0x06200000};
Pinetime::Drivers::TwiMaster twiMaster {NRF_TWIM1, MaxTwiFrequencyWithoutHardwareBug, pinTwiSda, pinTwiScl}; Pinetime::Drivers::TwiMaster twiMaster {NRF_TWIM1, MaxTwiFrequencyWithoutHardwareBug, Pinetime::PinMap::TwiSda, Pinetime::PinMap::TwiScl};
Pinetime::Drivers::Cst816S touchPanel {twiMaster, touchPanelTwiAddress}; Pinetime::Drivers::Cst816S touchPanel {twiMaster, touchPanelTwiAddress};
#ifdef PINETIME_IS_RECOVERY #ifdef PINETIME_IS_RECOVERY
#include "displayapp/DummyLittleVgl.h" #include "displayapp/DummyLittleVgl.h"
@ -102,8 +96,8 @@ TimerHandle_t debounceTimer;
TimerHandle_t debounceChargeTimer; TimerHandle_t debounceChargeTimer;
Pinetime::Controllers::Battery batteryController; Pinetime::Controllers::Battery batteryController;
Pinetime::Controllers::Ble bleController; Pinetime::Controllers::Ble bleController;
static constexpr uint8_t pinTouchIrq = 28; static constexpr uint8_t pinTouchIrq = Pinetime::PinMap::Cst816sIrq;
static constexpr uint8_t pinPowerPresentIrq = 19; static constexpr uint8_t pinPowerPresentIrq = Pinetime::PinMap::PowerPresent;
Pinetime::Controllers::HeartRateController heartRateController; Pinetime::Controllers::HeartRateController heartRateController;
Pinetime::Applications::HeartRateTask heartRateApp(heartRateSensor, heartRateController); Pinetime::Applications::HeartRateTask heartRateApp(heartRateSensor, heartRateController);
@ -160,14 +154,14 @@ Pinetime::System::SystemTask systemTask(spi,
touchHandler); touchHandler);
void nrfx_gpiote_evt_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action) { void nrfx_gpiote_evt_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action) {
if (pin == pinTouchIrq) { if (pin == Pinetime::PinMap::Cst816sIrq) {
systemTask.OnTouchEvent(); systemTask.OnTouchEvent();
return; return;
} }
BaseType_t xHigherPriorityTaskWoken = pdFALSE; BaseType_t xHigherPriorityTaskWoken = pdFALSE;
if (pin == pinPowerPresentIrq and action == NRF_GPIOTE_POLARITY_TOGGLE) { if (pin == Pinetime::PinMap::PowerPresent and action == NRF_GPIOTE_POLARITY_TOGGLE) {
xTimerStartFromISR(debounceChargeTimer, &xHigherPriorityTaskWoken); xTimerStartFromISR(debounceChargeTimer, &xHigherPriorityTaskWoken);
portYIELD_FROM_ISR(xHigherPriorityTaskWoken); portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
return; return;
@ -300,18 +294,18 @@ int main(void) {
nrf_drv_clock_init(); nrf_drv_clock_init();
// Unblock i2c? // Unblock i2c?
nrf_gpio_cfg(pinTwiScl, nrf_gpio_cfg(Pinetime::PinMap::TwiScl,
NRF_GPIO_PIN_DIR_OUTPUT, NRF_GPIO_PIN_DIR_OUTPUT,
NRF_GPIO_PIN_INPUT_DISCONNECT, NRF_GPIO_PIN_INPUT_DISCONNECT,
NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_NOPULL,
NRF_GPIO_PIN_S0D1, NRF_GPIO_PIN_S0D1,
NRF_GPIO_PIN_NOSENSE); NRF_GPIO_PIN_NOSENSE);
nrf_gpio_pin_set(pinTwiScl); nrf_gpio_pin_set(Pinetime::PinMap::TwiScl);
for (uint8_t i = 0; i < 16; i++) { for (uint8_t i = 0; i < 16; i++) {
nrf_gpio_pin_toggle(pinTwiScl); nrf_gpio_pin_toggle(Pinetime::PinMap::TwiScl);
nrf_delay_us(5); nrf_delay_us(5);
} }
nrf_gpio_cfg_default(pinTwiScl); nrf_gpio_cfg_default(Pinetime::PinMap::TwiScl);
debounceTimer = xTimerCreate("debounceTimer", 200, pdFALSE, (void*) 0, DebounceTimerCallback); debounceTimer = xTimerCreate("debounceTimer", 200, pdFALSE, (void*) 0, DebounceTimerCallback);
debounceChargeTimer = xTimerCreate("debounceTimerCharge", 200, pdFALSE, (void*) 0, DebounceTimerChargeCallback); debounceChargeTimer = xTimerCreate("debounceTimerCharge", 200, pdFALSE, (void*) 0, DebounceTimerChargeCallback);

View file

@ -15,6 +15,7 @@
#include <components/brightness/BrightnessController.h> #include <components/brightness/BrightnessController.h>
#include <algorithm> #include <algorithm>
#include "recoveryImage.h" #include "recoveryImage.h"
#include "drivers/PinMap.h"
#include "displayapp/icons/infinitime/infinitime-nb.c" #include "displayapp/icons/infinitime/infinitime-nb.c"
#include "components/rle/RleDecoder.h" #include "components/rle/RleDecoder.h"
@ -27,12 +28,6 @@ Pinetime::Logging::NrfLogger logger;
Pinetime::Logging::DummyLogger logger; Pinetime::Logging::DummyLogger logger;
#endif #endif
static constexpr uint8_t pinSpiSck = 2;
static constexpr uint8_t pinSpiMosi = 3;
static constexpr uint8_t pinSpiMiso = 4;
static constexpr uint8_t pinSpiFlashCsn = 5;
static constexpr uint8_t pinLcdCsn = 25;
static constexpr uint8_t pinLcdDataCommand = 18;
static constexpr uint8_t displayWidth = 240; static constexpr uint8_t displayWidth = 240;
static constexpr uint8_t displayHeight = 240; static constexpr uint8_t displayHeight = 240;
@ -45,14 +40,14 @@ Pinetime::Drivers::SpiMaster spi {Pinetime::Drivers::SpiMaster::SpiModule::SPI0,
{Pinetime::Drivers::SpiMaster::BitOrder::Msb_Lsb, {Pinetime::Drivers::SpiMaster::BitOrder::Msb_Lsb,
Pinetime::Drivers::SpiMaster::Modes::Mode3, Pinetime::Drivers::SpiMaster::Modes::Mode3,
Pinetime::Drivers::SpiMaster::Frequencies::Freq8Mhz, Pinetime::Drivers::SpiMaster::Frequencies::Freq8Mhz,
pinSpiSck, Pinetime::PinMap::SpiSck,
pinSpiMosi, Pinetime::PinMap::SpiMosi,
pinSpiMiso}}; Pinetime::PinMap::SpiMiso}};
Pinetime::Drivers::Spi flashSpi {spi, pinSpiFlashCsn}; Pinetime::Drivers::Spi flashSpi {spi, Pinetime::PinMap::SpiFlashCsn};
Pinetime::Drivers::SpiNorFlash spiNorFlash {flashSpi}; Pinetime::Drivers::SpiNorFlash spiNorFlash {flashSpi};
Pinetime::Drivers::Spi lcdSpi {spi, pinLcdCsn}; Pinetime::Drivers::Spi lcdSpi {spi, Pinetime::PinMap::SpiLcdCsn};
Pinetime::Drivers::St7789 lcd {lcdSpi, pinLcdDataCommand}; Pinetime::Drivers::St7789 lcd {lcdSpi, Pinetime::PinMap::LcdDataCommand};
Pinetime::Components::Gfx gfx {lcd}; Pinetime::Components::Gfx gfx {lcd};
Pinetime::Controllers::BrightnessController brightnessController; Pinetime::Controllers::BrightnessController brightnessController;

View file

@ -21,8 +21,10 @@
#include "drivers/SpiNorFlash.h" #include "drivers/SpiNorFlash.h"
#include "drivers/TwiMaster.h" #include "drivers/TwiMaster.h"
#include "drivers/Hrs3300.h" #include "drivers/Hrs3300.h"
#include "drivers/PinMap.h"
#include "main.h" #include "main.h"
#include <memory> #include <memory>
using namespace Pinetime::System; using namespace Pinetime::System;
@ -154,7 +156,7 @@ void SystemTask::Work() {
heartRateSensor.Disable(); heartRateSensor.Disable();
heartRateApp.Start(); heartRateApp.Start();
nrf_gpio_cfg_sense_input(pinButton, (nrf_gpio_pin_pull_t) GPIO_PIN_CNF_PULL_Pulldown, (nrf_gpio_pin_sense_t) GPIO_PIN_CNF_SENSE_High); nrf_gpio_cfg_sense_input(PinMap::Button, (nrf_gpio_pin_pull_t) GPIO_PIN_CNF_PULL_Pulldown, (nrf_gpio_pin_sense_t) GPIO_PIN_CNF_SENSE_High);
nrf_gpio_cfg_output(15); nrf_gpio_cfg_output(15);
nrf_gpio_pin_set(15); nrf_gpio_pin_set(15);
@ -165,9 +167,9 @@ void SystemTask::Work() {
pinConfig.sense = (nrf_gpiote_polarity_t) NRF_GPIOTE_POLARITY_HITOLO; pinConfig.sense = (nrf_gpiote_polarity_t) NRF_GPIOTE_POLARITY_HITOLO;
pinConfig.pull = (nrf_gpio_pin_pull_t) GPIO_PIN_CNF_PULL_Pulldown; pinConfig.pull = (nrf_gpio_pin_pull_t) GPIO_PIN_CNF_PULL_Pulldown;
nrfx_gpiote_in_init(pinButton, &pinConfig, nrfx_gpiote_evt_handler); nrfx_gpiote_in_init(PinMap::Button, &pinConfig, nrfx_gpiote_evt_handler);
nrf_gpio_cfg_sense_input(pinTouchIrq, (nrf_gpio_pin_pull_t) GPIO_PIN_CNF_PULL_Pullup, (nrf_gpio_pin_sense_t) GPIO_PIN_CNF_SENSE_Low); nrf_gpio_cfg_sense_input(PinMap::Cst816sIrq, (nrf_gpio_pin_pull_t) GPIO_PIN_CNF_PULL_Pullup, (nrf_gpio_pin_sense_t) GPIO_PIN_CNF_SENSE_Low);
pinConfig.skip_gpio_setup = true; pinConfig.skip_gpio_setup = true;
pinConfig.hi_accuracy = false; pinConfig.hi_accuracy = false;
@ -175,19 +177,19 @@ void SystemTask::Work() {
pinConfig.sense = (nrf_gpiote_polarity_t) NRF_GPIOTE_POLARITY_HITOLO; pinConfig.sense = (nrf_gpiote_polarity_t) NRF_GPIOTE_POLARITY_HITOLO;
pinConfig.pull = (nrf_gpio_pin_pull_t) GPIO_PIN_CNF_PULL_Pullup; pinConfig.pull = (nrf_gpio_pin_pull_t) GPIO_PIN_CNF_PULL_Pullup;
nrfx_gpiote_in_init(pinTouchIrq, &pinConfig, nrfx_gpiote_evt_handler); nrfx_gpiote_in_init(PinMap::Cst816sIrq, &pinConfig, nrfx_gpiote_evt_handler);
pinConfig.sense = NRF_GPIOTE_POLARITY_TOGGLE; pinConfig.sense = NRF_GPIOTE_POLARITY_TOGGLE;
pinConfig.pull = NRF_GPIO_PIN_NOPULL; pinConfig.pull = NRF_GPIO_PIN_NOPULL;
pinConfig.is_watcher = false; pinConfig.is_watcher = false;
pinConfig.hi_accuracy = false; pinConfig.hi_accuracy = false;
pinConfig.skip_gpio_setup = true; pinConfig.skip_gpio_setup = true;
nrfx_gpiote_in_init(pinPowerPresentIrq, &pinConfig, nrfx_gpiote_evt_handler); nrfx_gpiote_in_init(PinMap::PowerPresent, &pinConfig, nrfx_gpiote_evt_handler);
if (nrf_gpio_pin_read(pinPowerPresentIrq)) { if (nrf_gpio_pin_read(PinMap::PowerPresent)) {
nrf_gpio_cfg_sense_input(pinPowerPresentIrq, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_SENSE_LOW); nrf_gpio_cfg_sense_input(PinMap::PowerPresent, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_SENSE_LOW);
} else { } else {
nrf_gpio_cfg_sense_input(pinPowerPresentIrq, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_SENSE_HIGH); nrf_gpio_cfg_sense_input(PinMap::PowerPresent, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_SENSE_HIGH);
} }
idleTimer = xTimerCreate("idleTimer", pdMS_TO_TICKS(2000), pdFALSE, this, IdleTimerCallback); idleTimer = xTimerCreate("idleTimer", pdMS_TO_TICKS(2000), pdFALSE, this, IdleTimerCallback);
@ -360,7 +362,7 @@ void SystemTask::Work() {
monitor.Process(); monitor.Process();
uint32_t systick_counter = nrf_rtc_counter_get(portNRF_RTC_REG); uint32_t systick_counter = nrf_rtc_counter_get(portNRF_RTC_REG);
dateTimeController.UpdateTime(systick_counter); dateTimeController.UpdateTime(systick_counter);
if (!nrf_gpio_pin_read(pinButton)) if (!nrf_gpio_pin_read(PinMap::Button))
watchdog.Kick(); watchdog.Kick();
} }
// Clear diagnostic suppression // Clear diagnostic suppression

View file

@ -8,6 +8,7 @@
#include <heartratetask/HeartRateTask.h> #include <heartratetask/HeartRateTask.h>
#include <components/settings/Settings.h> #include <components/settings/Settings.h>
#include <drivers/Bma421.h> #include <drivers/Bma421.h>
#include <drivers/PinMap.h>
#include <components/motion/MotionController.h> #include <components/motion/MotionController.h>
#include "SystemMonitor.h" #include "SystemMonitor.h"
@ -120,15 +121,6 @@ namespace Pinetime {
Pinetime::Controllers::TouchHandler& touchHandler; Pinetime::Controllers::TouchHandler& touchHandler;
Pinetime::Controllers::NimbleController nimbleController; Pinetime::Controllers::NimbleController nimbleController;
static constexpr uint8_t pinSpiSck = 2;
static constexpr uint8_t pinSpiMosi = 3;
static constexpr uint8_t pinSpiMiso = 4;
static constexpr uint8_t pinSpiCsn = 25;
static constexpr uint8_t pinLcdDataCommand = 18;
static constexpr uint8_t pinButton = 13;
static constexpr uint8_t pinTouchIrq = 28;
static constexpr uint8_t pinPowerPresentIrq = 19;
static void Process(void* instance); static void Process(void* instance);
void Work(); void Work();
void ReloadIdleTimer(); void ReloadIdleTimer();