Skip to content

Commit efe9a41

Browse files
committed
CMake: Add acceleration sensor configuration
The DRIVER_ACC configuration variable can be used to select the acceleration sensor driver to be used.
1 parent 5a5d9c2 commit efe9a41

File tree

4 files changed

+9
-2
lines changed

4 files changed

+9
-2
lines changed

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ set_property(CACHE TARGET_DEVICE PROPERTY STRINGS PINETIME P8)
5757
set(LF_CLK "XTAL" CACHE STRING "Low frequency clock source")
5858
set_property(CACHE LF_CLK PROPERTY STRINGS RC XTAL SYNT)
5959

60+
set(DRIVER_ACC "BMA421" CACHE STRING "Acceleration sensor driver")
61+
set_property(CACHE DRIVER_ACC PROPERTY STRINGS BMA421 SC7A20)
62+
6063
set(PROJECT_GIT_COMMIT_HASH "")
6164

6265
execute_process(COMMAND git rev-parse --short HEAD
@@ -100,6 +103,7 @@ message("DEVICE CONFIGURATION")
100103
message("--------------------")
101104
message(" * Target Pin Mapping : " ${TARGET_DEVICE})
102105
message(" * LF clock source : " ${LF_CLK})
106+
message(" * Acceleration sensor : " ${DRIVER_ACC})
103107
message("")
104108

105109
set(VERSION_EDIT_WARNING "// Do not edit this file, it is automatically generated by CMAKE!")

doc/buildAndProgram.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ CMake configures the project according to variables you specify the command line
3737
**BUILD_DFU (\*\*)**|Build DFU files while building (needs [adafruit-nrfutil](https://github.com/adafruit/Adafruit_nRF52_nrfutil)).|`-DBUILD_DFU=1`
3838
**TARGET_DEVICE**|Target device, used for pin map. Allowed: `PINETIME, P8`|`-DTARGET_DEVICE=PINETIME` (Default)
3939
**LF_CLK**|Configures the LF clock source. Allowed: `RC, XTAL, SYNT`|`-DLF_CLK=XTAL` (Default)
40+
**DRIVER_ACC**|Acceleration sensor driver selection. Allowed: `BMA421, SC7A20`|`-DDRIVER_ACC=BMA421` (Default)
4041
4142
####(**) Note about **CMAKE_BUILD_TYPE**:
4243
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/InfiniTimeOrg/InfiniTime/releases) new versions of InfiniTime.

src/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -816,6 +816,8 @@ elseif(LF_CLK STREQUAL "SYNT")
816816
else()
817817
message(FATAL_ERROR "Invalid LF_CLK")
818818
endif()
819+
add_definitions(-DDRIVER_ACC_${DRIVER_ACC})
820+
819821
# NOTE : Add the following defines to enable debug mode of the NRF SDK:
820822
#add_definitions(-DDEBUG)
821823
#add_definitions(-DDEBUG_NRF_USER)

src/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ Pinetime::Drivers::Cst816S touchPanel {twiMaster, touchPanelTwiAddress};
9090
Pinetime::Components::LittleVgl lvgl {lcd, touchPanel};
9191

9292
#if (defined DRIVER_ACC_SC7A20)
93-
#include <drivers/SC7A20.h>
94-
static constexpr uint8_t motionSensorTwiAddress = 0x18;
93+
#include <drivers/SC7A20.h>
94+
static constexpr uint8_t motionSensorTwiAddress = 0x18;
9595
Pinetime::Drivers::SC7A20 motionSensor {twiMaster, motionSensorTwiAddress};
9696
#else
9797
// Assume DRIVER_ACC_BMA421,

0 commit comments

Comments
 (0)