Skip to content

Commit

Permalink
CMake: Add acceleration sensor configuration
Browse files Browse the repository at this point in the history
The DRIVER_ACC configuration variable can be used to select the
acceleration sensor driver to be used.
  • Loading branch information
StarGate01 committed May 17, 2022
1 parent c1b9d3f commit 78b1d61
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion doc/buildAndProgram.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,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_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`
**TARGET_DEVICE**|Target device, used for the pin map and the low frequency clock source. Allowed: `PINETIME, P8A, P8B`|`-DTARGET_DEVICE=PINETIME` (Default)
**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)
####(**) 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/InfiniTimeOrg/InfiniTime/releases) new versions of InfiniTime.
Expand Down
3 changes: 3 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -810,12 +810,15 @@ add_definitions(-D__HEAP_SIZE=4096)
add_definitions(-DTARGET_DEVICE_${TARGET_DEVICE})
if(TARGET_DEVICE STREQUAL "PINETIME")
add_definitions(-DCLOCK_CONFIG_LF_SRC=1) # XTAL
add_definitions(-DDRIVER_ACC_BMA421)
elseif(TARGET_DEVICE STREQUAL "P8A")
add_definitions(-DCLOCK_CONFIG_LF_SRC=1) # XTAL
add_definitions(-DDRIVER_ACC_BMA421)
elseif(TARGET_DEVICE STREQUAL "P8B")
add_definitions(-DCLOCK_CONFIG_LF_SRC=0) # RC
add_definitions(-DMYNEWT_VAL_BLE_LL_SCA=500)
add_definitions(-DCLOCK_CONFIG_LF_CAL_ENABLED=1)
add_definitions(-DDRIVER_ACC_SC7A20)
else()
message(FATAL_ERROR "Invalid TARGET_DEVICE")
endif()
Expand Down
8 changes: 3 additions & 5 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,11 @@ Pinetime::Drivers::Cst816S touchPanel {twiMaster, touchPanelTwiAddress};
Pinetime::Components::LittleVgl lvgl {lcd, touchPanel};

#if (defined DRIVER_ACC_SC7A20)
#include <drivers/SC7A20.h>
static constexpr uint8_t motionSensorTwiAddress = 0x18;
#include <drivers/SC7A20.h>
static constexpr uint8_t motionSensorTwiAddress = 0x18;
Pinetime::Drivers::SC7A20 motionSensor {twiMaster, motionSensorTwiAddress};
#else
// Assume DRIVER_ACC_BMA421,
// this is needed for the LVGL simulator,
// which does not set any target hardware configuration variables
// Assume PineTime (DRIVER_ACC_BMA421)
#include <drivers/Bma421.h>
static constexpr uint8_t motionSensorTwiAddress = 0x18;
Pinetime::Drivers::Bma421 motionSensor {twiMaster, motionSensorTwiAddress};
Expand Down

0 comments on commit 78b1d61

Please sign in to comment.