Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement new hardware abstraction from InfiniTime using C++20 concepts. #73

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
22 changes: 11 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ project(InfiniSim VERSION ${PROJECT_VERSION} LANGUAGES C CXX)
# https://cmake.org/cmake/help/latest/prop_tgt/CXX_STANDARD.html
string(COMPARE EQUAL "${CMAKE_CXX_STANDARD}" "" no_cmake_cxx_standard_set)
if(no_cmake_cxx_standard_set)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
message(STATUS "Using default C++ standard ${CMAKE_CXX_STANDARD}")
Expand Down Expand Up @@ -142,12 +142,13 @@ target_sources(infinisim PUBLIC
sim/drivers/Cst816s.cpp
sim/drivers/Hrs3300.h
sim/drivers/Hrs3300.cpp
sim/drivers/SpiMaster.h
sim/drivers/SpiMaster.cpp
sim/drivers/infinisim/SpiMaster.h
sim/drivers/infinisim/Spi.h
sim/drivers/infinisim/Spi.cpp
sim/drivers/TwiMaster.h
sim/drivers/TwiMaster.cpp
sim/drivers/SpiNorFlash.h
sim/drivers/SpiNorFlash.cpp
sim/drivers/infinisim/SpiNorFlash.h
sim/drivers/infinisim/SpiNorFlash.cpp
sim/heartratetask/HeartRateTask.h
sim/heartratetask/HeartRateTask.cpp
)
Expand Down Expand Up @@ -214,7 +215,6 @@ target_sources(infinisim PUBLIC
${InfiniTime_DIR}/src/components/timer/TimerController.cpp
${InfiniTime_DIR}/src/drivers/PinMap.h
${InfiniTime_DIR}/src/drivers/Spi.h
${InfiniTime_DIR}/src/drivers/Spi.cpp
${InfiniTime_DIR}/src/drivers/St7789.h
${InfiniTime_DIR}/src/drivers/St7789.cpp
${InfiniTime_DIR}/src/touchhandler/TouchHandler.h
Expand Down Expand Up @@ -335,13 +335,13 @@ add_executable(littlefs-do
${InfiniTime_DIR}/src/components/fs/FS.h
${InfiniTime_DIR}/src/components/fs/FS.cpp
# dependencies for FS.h
sim/drivers/SpiNorFlash.h
sim/drivers/SpiNorFlash.cpp
sim/drivers/infinisim/SpiNorFlash.h
sim/drivers/infinisim/SpiNorFlash.cpp
# dependencies for SpiNorFlash.h
${InfiniTime_DIR}/src/drivers/Spi.h
${InfiniTime_DIR}/src/drivers/Spi.cpp
sim/drivers/SpiMaster.h
sim/drivers/SpiMaster.cpp
sim/drivers/infinisim/SpiMaster.h
sim/drivers/infinisim/Spi.h
sim/drivers/infinisim/Spi.cpp

${InfiniTime_DIR}/src/components/settings/Settings.h
${InfiniTime_DIR}/src/components/settings/Settings.cpp
Expand Down
2 changes: 1 addition & 1 deletion littlefs-do-main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#include "components/fs/FS.h"
#include "components/settings/Settings.h"
#include "drivers/SpiNorFlash.h"
#include "drivers/infinisim/SpiNorFlash.h"

#include "nlohmann/json.hpp"
#include "miniz.h"
Expand Down
37 changes: 19 additions & 18 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,24 @@
#include <drivers/Bma421.h>

#include "BootloaderVersion.h"
#include "buttonhandler/ButtonHandler.h"
#include "components/battery/BatteryController.h"
#include "components/ble/BleController.h"
#include "components/ble/NotificationManager.h"
#include "components/brightness/BrightnessController.h"
#include "components/motor/MotorController.h"
#include "components/datetime/DateTimeController.h"
#include "components/heartrate/HeartRateController.h"
#include "components/fs/FS.h"
#include "components/heartrate/HeartRateController.h"
#include "components/motor/MotorController.h"
#include "drivers/Cst816s.h"
#include "drivers/PinMap.h"
#include "drivers/Spi.h"
#include "drivers/SpiMaster.h"
#include "drivers/SpiNorFlash.h"
#include "drivers/St7789.h"
#include "drivers/TwiMaster.h"
#include "drivers/Cst816s.h"
#include "drivers/PinMap.h"
#include "sim/drivers/infinisim/SpiMaster.h"
#include "sim/drivers/infinisim/SpiNorFlash.h"
#include "systemtask/SystemTask.h"
#include "drivers/PinMap.h"
#include "touchhandler/TouchHandler.h"
#include "buttonhandler/ButtonHandler.h"

// get the simulator-headers
#include "displayapp/DisplayApp.h"
Expand All @@ -70,6 +69,8 @@
#endif
#include <gif.h>

#include "port/infinitime.h"

/*********************
* DEFINES
*********************/
Expand Down Expand Up @@ -290,19 +291,19 @@ static constexpr uint8_t touchPanelTwiAddress = 0x15;
static constexpr uint8_t motionSensorTwiAddress = 0x18;
static constexpr uint8_t heartRateSensorTwiAddress = 0x44;

Pinetime::Drivers::SpiMaster spi {Pinetime::Drivers::SpiMaster::SpiModule::SPI0,
{Pinetime::Drivers::SpiMaster::BitOrder::Msb_Lsb,
Pinetime::Drivers::SpiMaster::Modes::Mode3,
Pinetime::Drivers::SpiMaster::Frequencies::Freq8Mhz,
Pinetime::PinMap::SpiSck,
Pinetime::PinMap::SpiMosi,
Pinetime::PinMap::SpiMiso}};
Pinetime::Drivers::Infinisim::SpiMaster spiImpl {};
Pinetime::Drivers::SpiMaster spi {spiImpl};


Pinetime::Drivers::Spi lcdSpi {spi, Pinetime::PinMap::SpiLcdCsn};
Pinetime::Drivers::Infinisim::Spi lcdSpiImpl {spiImpl, Pinetime::PinMap::SpiLcdCsn};
Pinetime::Drivers::Spi lcdSpi {lcdSpiImpl};
Pinetime::Drivers::St7789 lcd {lcdSpi, Pinetime::PinMap::LcdDataCommand};

Pinetime::Drivers::Spi flashSpi {spi, Pinetime::PinMap::SpiFlashCsn};
Pinetime::Drivers::SpiNorFlash spiNorFlash {"spiNorFlash.raw"};
Pinetime::Drivers::Infinisim::Spi flashSpiImpl {spiImpl, Pinetime::PinMap::SpiFlashCsn};
Pinetime::Drivers::Spi flashSpi {flashSpiImpl};

Pinetime::Drivers::Infinisim::SpiNorFlash spiNorFlashImpl {"spiNorFlash.raw"};
Pinetime::Drivers::SpiNorFlash spiNorFlash {spiNorFlashImpl};

// 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
Expand Down
4 changes: 0 additions & 4 deletions sim/components/ble/NimbleController.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@
//#include "components/ble/FSService.h"

namespace Pinetime {
namespace Drivers {
class SpiNorFlash;
}

namespace System {
class SystemTask;
}
Expand Down
Loading