Skip to content

Commit

Permalink
Merge pull request #24 from theBASTI0N/lis2dh12_driver
Browse files Browse the repository at this point in the history
feat: Custom LIS2DH12 Driver
  • Loading branch information
theBASTI0N authored Oct 14, 2021
2 parents 799f227 + 469b64a commit acf2e0c
Show file tree
Hide file tree
Showing 16 changed files with 11,357 additions and 1,530 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/build-and-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,11 @@ jobs:
python3 -m pip install -r zephyr/scripts/requirements.txt && \
python3 -m pip install -r nrf/scripts/requirements.txt && \
python3 -m pip install -r bootloader/mcuboot/scripts/requirements.txt && \
echo "source /workdir/ncs/zephyr/zephyr-env.sh" >> ~/.bashrc &&
cd nrf && cd applications
echo "source ${GITHUB_WORKSPACE}/ncs/zephyr/zephyr-env.sh" >> ~/.bashrc
- name: Clone Repo
run: |
cd ${GITHUB_WORKSPACE}/ncs/nrf/applications
rm -d -r ruuvitag_fw_zephyr || echo 'ruuvitag_fw_zephyr Folder exists'
git clone --recursive https://github.com/${GITHUB_REPOSITORY} ruuvitag_fw_zephyr
cd ruuvitag_fw_zephyr
Expand Down
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

cmake_minimum_required(VERSION 3.20.0)

# Add external Drivers
list(APPEND ZEPHYR_EXTRA_MODULES ${CMAKE_CURRENT_SOURCE_DIR}/drivers/lis2dh12)

# Add the board
set(BOARD_ROOT ${CMAKE_CURRENT_LIST_DIR})

Expand Down
4 changes: 0 additions & 4 deletions Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ config RUUVITAG_NFC_SENSOR_DATA_FREQUENCY
int "Controls how often the NFC Sensor data will be refreshed."
default 1

config RUUVITAG_RAWV2
int "Controls the data packet to be used."
default 1

endmenu #Ruuvitag

menu "Zephyr Kernel"
Expand Down
4 changes: 2 additions & 2 deletions boards/arm/ruuvi_ruuvitag/ruuvi_ruuvitag_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ CONFIG_GPIO=y
# enable uart driver
CONFIG_SERIAL=y

# enable console
# enable console
CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y

# additional board options
CONFIG_GPIO_AS_PINRESET=y
CONFIG_GPIO_AS_PINRESET=n
7 changes: 7 additions & 0 deletions drivers/lis2dh12/zephyr/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
if(CONFIG_LIS2DH12)
zephyr_include_directories(.)
zephyr_library()

zephyr_library_sources(lis2dh12.c)
zephyr_library_sources(lis2dh12_spi.c)
endif()
131 changes: 131 additions & 0 deletions drivers/lis2dh12/zephyr/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
# LIS2DH12 Three Axis Accelerometer configuration options

menuconfig LIS2DH12
bool "LIS2DH12 Three Axis Accelerometer"
depends on SPI
select HAS_STMEMSC
select USE_STDC_LIS2DH12
help
Enable SPI-based driver for LIS2DH12 triaxial accelerometer sensors.

if LIS2DH12

config LIS2DH12_INIT_PRIORITY
int "Sensor Init Priority"
range 0 100
default 90

config LIS2DH12_LOG_LEVEL
int "Log Level"
range 0 6
default 3

choice
prompt "Acceleration measurement range"
default LIS2DH12_ACCEL_RANGE_2G
help
Initial measurement full scale range for acceleration values.

config LIS2DH12_ACCEL_RANGE_2G
bool "+/-2g"

config LIS2DH12_ACCEL_RANGE_4G
bool "+/-4g"

config LIS2DH12_ACCEL_RANGE_8G
bool "+/-8g"

config LIS2DH12_ACCEL_RANGE_16G
bool "+/-16g"

endchoice

choice
prompt "Operation mode"
default LIS2DH12_OPER_MODE_NORMAL
help
Choose between high resolution, normal or low power operation
mode for chip at init.

config LIS2DH12_OPER_MODE_HIGH_RES
bool "high resolution (12 bit)"

config LIS2DH12_OPER_MODE_NORMAL
bool "normal (10 bit)"

config LIS2DH12_OPER_MODE_LOW_POWER
bool "low power (8 bit)"

endchoice

choice
prompt "Output data rate frequency"
default LIS2DH12_ODR_1
help
Initial data rate frequency of acceleration data at initialization.
Supported values:
1Hz, 10Hz, 25Hz, 50Hz, 100Hz, 200Hz, 400Hz in all power modes
1620Hz, 5376Hz in low power mode only
1344Hz in normal power mode

config LIS2DH12_ODR_1
bool "1Hz"

config LIS2DH12_ODR_10
bool "10Hz"

config LIS2DH12_ODR_25
bool "25Hz"

config LIS2DH12_ODR_50
bool "50Hz"

config LIS2DH12_ODR_100
bool "100Hz"

config LIS2DH12_ODR_200
bool "200Hz"

config LIS2DH12_ODR_400
bool "400Hz"

endchoice

config LIS2DH12_FIFO_ENABLED
bool "Enable FiFo"
default False

if LIS2DH12_FIFO_ENABLED

choice
prompt "FiFo Mode"
default LIS2DH12_BYPASS_MODE
help
Choose FiFo mode.

config LIS2DH12_BYPASS_MODE
bool "FiFO Bypassed"

config LIS2DH12_FIFO_MODE
bool "Normal FiFo mode."

config LIS2DH12_DYNAMIC_STREAM_MODE
bool "Dynamic Stream Mode."

config LIS2DH12_STREAM_TO_FIFO_MODE
bool "Stream to FiFo Mode."

endchoice

config LIS2DH_FIFO_WM
int "FiFO Watermark Size"
range 0 31
default 31

endif

config LIS2DH12_TEMP_EN
bool "Temperature Enabled"
default False

endif # LIS2DH12
Loading

0 comments on commit acf2e0c

Please sign in to comment.