Skip to content

Commit e474afd

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 8e121f8 commit e474afd

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

doc/buildAndProgram.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ CMake configures the project according to variables you specify the command line
3939
**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`
4040
**GDB_CLIENT_TARGET_REMOTE**|Target remote connection string. Used only if `USE_GDB_CLIENT` is 1.|`-DGDB_CLIENT_TARGET_REMOTE=/dev/ttyACM0`
4141
**BUILD_DFU (\*\*)**|Build DFU files while building (needs [adafruit-nrfutil](https://github.com/adafruit/Adafruit_nRF52_nrfutil)).|`-DBUILD_DFU=1`
42-
**TARGET_DEVICE**|Target device, used for the pin map and the low frequency clock source. Allowed: `PINETIME, P8A, P8B`|`-DTARGET_DEVICE=PINETIME` (Default)
42+
**TARGET_DEVICE**|Target device, used for the pin map, the low frequency clock source, and the acceleration driver selection. Allowed: `PINETIME, P8A, P8B`|`-DTARGET_DEVICE=PINETIME` (Default)
4343
4444
####(**) Note about **CMAKE_BUILD_TYPE**:
4545
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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,12 +802,15 @@ add_definitions(-D__HEAP_SIZE=4096)
802802
add_definitions(-DTARGET_DEVICE_${TARGET_DEVICE})
803803
if(TARGET_DEVICE STREQUAL "PINETIME")
804804
add_definitions(-DCLOCK_CONFIG_LF_SRC=1) # XTAL
805+
add_definitions(-DDRIVER_ACC_BMA421)
805806
elseif(TARGET_DEVICE STREQUAL "P8A")
806807
add_definitions(-DCLOCK_CONFIG_LF_SRC=1) # XTAL
808+
add_definitions(-DDRIVER_ACC_BMA421)
807809
elseif(TARGET_DEVICE STREQUAL "P8B")
808810
add_definitions(-DCLOCK_CONFIG_LF_SRC=0) # RC
809811
add_definitions(-DMYNEWT_VAL_BLE_LL_SCA=500)
810812
add_definitions(-DCLOCK_CONFIG_LF_CAL_ENABLED=1)
813+
add_definitions(-DDRIVER_ACC_SC7A20)
811814
else()
812815
message(FATAL_ERROR "Invalid TARGET_DEVICE")
813816
endif()

src/main.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,11 @@ 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
97-
// Assume DRIVER_ACC_BMA421,
98-
// this is needed for the LVGL simulator,
99-
// which does not set any target hardware configuration variables
97+
// Assume PineTime (DRIVER_ACC_BMA421)
10098
#include <drivers/Bma421.h>
10199
static constexpr uint8_t motionSensorTwiAddress = 0x18;
102100
Pinetime::Drivers::Bma421 motionSensor {twiMaster, motionSensorTwiAddress};

0 commit comments

Comments
 (0)