Skip to content

Commit 9751693

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 ccea19b commit 9751693

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-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, MOY-TFK5, MOY-TIN5,MOY-TON5, MOY-UNK`|`-DTARGET_DEVICE=PINETIME` (Default)
42+
**TARGET_DEVICE**|Target device, used for the pin map and the low frequency clock source, and the acceleration driver selection. Allowed: `PINETIME, MOY-TFK5, MOY-TIN5,MOY-TON5, MOY-UNK`|`-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: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -795,22 +795,27 @@ add_definitions(-DTARGET_DEVICE_${TARGET_DEVICE})
795795
if(TARGET_DEVICE STREQUAL "PINETIME")
796796
add_definitions(-DDRIVER_PINMAP_PINETIME)
797797
add_definitions(-DCLOCK_CONFIG_LF_SRC=1) # XTAL
798+
add_definitions(-DDRIVER_ACC_BMA421)
798799
elseif(TARGET_DEVICE STREQUAL "MOY-TFK5") # P8a
799800
add_definitions(-DDRIVER_PINMAP_P8)
800801
add_definitions(-DCLOCK_CONFIG_LF_SRC=1) # XTAL
802+
add_definitions(-DDRIVER_ACC_BMA421)
801803
elseif(TARGET_DEVICE STREQUAL "MOY-TIN5") # P8a variant 2
802804
add_definitions(-DDRIVER_PINMAP_P8)
803805
add_definitions(-DCLOCK_CONFIG_LF_SRC=1) # XTAL
806+
add_definitions(-DDRIVER_ACC_SC7A20)
804807
elseif(TARGET_DEVICE STREQUAL "MOY-TON5") # P8b
805808
add_definitions(-DDRIVER_PINMAP_P8)
806809
add_definitions(-DCLOCK_CONFIG_LF_SRC=0) # RC
807810
add_definitions(-DMYNEWT_VAL_BLE_LL_SCA=500)
808811
add_definitions(-DCLOCK_CONFIG_LF_CAL_ENABLED=1)
812+
add_definitions(-DDRIVER_ACC_SC7A20)
809813
elseif(TARGET_DEVICE STREQUAL "MOY-UNK") # P8b mirrored
810814
add_definitions(-DDRIVER_PINMAP_P8)
811815
add_definitions(-DCLOCK_CONFIG_LF_SRC=0) # RC
812816
add_definitions(-DMYNEWT_VAL_BLE_LL_SCA=500)
813817
add_definitions(-DCLOCK_CONFIG_LF_CAL_ENABLED=1)
818+
add_definitions(-DDRIVER_ACC_SC7A20)
814819
else()
815820
message(FATAL_ERROR "Invalid TARGET_DEVICE")
816821
endif()

src/main.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,11 @@ Pinetime::Drivers::Cst816S touchPanel {twiMaster, touchPanelTwiAddress};
8989
Pinetime::Components::LittleVgl lvgl {lcd, touchPanel};
9090

9191
#if (defined DRIVER_ACC_SC7A20)
92-
#include <drivers/SC7A20.h>
93-
static constexpr uint8_t motionSensorTwiAddress = 0x18;
92+
#include <drivers/SC7A20.h>
93+
static constexpr uint8_t motionSensorTwiAddress = 0x18;
9494
Pinetime::Drivers::SC7A20 motionSensor {twiMaster, motionSensorTwiAddress};
9595
#else
96-
// Assume DRIVER_ACC_BMA421,
97-
// this is needed for the LVGL simulator,
98-
// which does not set any target hardware configuration variables
96+
// Assume PineTime (DRIVER_ACC_BMA421)
9997
#include <drivers/Bma421.h>
10098
static constexpr uint8_t motionSensorTwiAddress = 0x18;
10199
Pinetime::Drivers::Bma421 motionSensor {twiMaster, motionSensorTwiAddress};

0 commit comments

Comments
 (0)