Skip to content

Commit

Permalink
bcf: add sensortest
Browse files Browse the repository at this point in the history
commit 0817d36
Author: Jason Kridner <[email protected]>
Date:   Sun Mar 12 09:35:42 2023 -0400

    sensortest: increase send rate

commit d84dcba
Author: Jason Kridner <[email protected]>
Date:   Fri Dec 16 00:38:16 2022 -0500

    sensortest: make subghz the default

    An overlay to enable 2.4GHz will be needed until this issue is fixed:

    zephyrproject-rtos#29750

commit aeb1d88
Author: Vaishnav Achath <[email protected]>
Date:   Mon Oct 24 20:57:36 2022 +0530

    samples: add beagleconnect freedom C7 sensortest sample

    Signed-off-by: Vaishnav Achath <[email protected]>

sensortest: add CONFIG_GPIO

bcf: sensortest: update button api

samples: bcf: sensortest: button_handler function type
  • Loading branch information
jadonk committed Oct 22, 2023
1 parent d79e4f7 commit 7962b67
Show file tree
Hide file tree
Showing 5 changed files with 559 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.13.1)
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
project(beagleconnect_freedom)

FILE(GLOB app_sources src/*.c)
target_sources(app PRIVATE ${app_sources})
157 changes: 157 additions & 0 deletions samples/boards/beagleconnect_freedom/sensortest/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
.. _ti-cc1352r_sensortag:

CC1352R SensorTag Demo
######################

Overview
********

This sample demonstrates some of the capabilities of the CC1352R SensorTag by
exercising GPIO output, GPIO input, as well as I2C and SPI I/O with the on-board
sensors.

* Cycle through Red, Green, and Blue LEDs every 500 ms
* Respond to Button press events with a console message
* Print out sensor readings on the Zephyr Shell

Requirements
************

Building, Flashing and Running
******************************

.. zephyr-app-commands::
:zephyr-app: samples/boards/ti/cc1352r_sensortag
:board: cc1352r_sensortag
:goals: build flash
:compact:

Sample Output
=============

Initialization
--------------

After reset, the red, green, and blue LEDs should immediately begin to change
every 500 ms and the following message should appear on the console.

.. code-block:: console
*** Booting Zephyr OS build v2.4.0-rc1-283-gf239276916a5 ***
[00:00:00.018,218] <inf> ti_cc1352r_sensortag: opening device Red LED
[00:00:00.018,218] <inf> ti_cc1352r_sensortag: opening device Green LED
[00:00:00.018,249] <inf> ti_cc1352r_sensortag: opening device Blue LED
[00:00:00.018,249] <inf> ti_cc1352r_sensortag: opening device Push button 1
[00:00:00.018,280] <inf> ti_cc1352r_sensortag: opening device Push button 2
[00:00:00.018,310] <inf> ti_cc1352r_sensortag: opening device OPT3001
[00:00:00.018,310] <inf> ti_cc1352r_sensortag: opening device ADXL362
uart:~$
Ambient Light Sensor
--------------------

Here, we will demonstrate using the ambient light sensor via the Zephyr Shell.

First, take a reading of the ambient light.

.. code-block:: console
uart:~$ sensor get OPT3001
channel idx=17 light = 106.640000
Then, cover the ambient light sensor (located where the ☀️symbol is) and
take a second reading.

.. code-block:: console
uart:~$ sensor get OPT3001
channel idx=17 light = 0.850000
Accelerometer
-------------

Here we will take a number of (uncalibrated) readings of the acceleration due
to gravity using the Zephyr Shell.

First, rest the CC1352R SensorTag so that the Sub-1GHz antenna is pointing up
and the red printed circuit board is facing you. Then, take a reading.

.. code-block:: console
uart:~$ sensor get ADXL362
channel idx=0 accel_x = -0.480525
channel idx=1 accel_y = -10.738281
channel idx=2 accel_z = 1.490610
channel idx=12 die_temp = -26.000000
This reading indicates that the acceleration due to gravity in the y direction
is approximately -10 m/s^2.

Then, rotate the CC1352R SensorTag 90° clockwise, so that the Sub-1GHz antenna
is pointing right, and take a second reading.

.. code-block:: console
uart:~$ sensor get ADXL362
channel idx=0 accel_x = 9.286897
channel idx=1 accel_y = 0.117679
channel idx=2 accel_z = 1.441577
channel idx=12 die_temp = -25.935000
This reading indicates that the acceleration due to gravity in the x direction
is 9 m/s^2.

Lastly, rest the CC1352R SensorTag flat so that the Sub-1GHz antenna is
pointing away from you, and take a third reading.

.. code-block:: console
uart:~$ sensor get ADXL362
channel idx=0 accel_x = -0.823758
channel idx=1 accel_y = 0.235359
channel idx=2 accel_z = 11.169774
channel idx=12 die_temp = -25.675000
This reading indicates that the acceleration due to gravity in the z direction
is 11 m/s^2.

Button Events
-------------

Here we will demonstrate button events being logged to the console.

Note, that there is a small delay between when the event occurs and when the
event is logged. Also note, that only button press events trigger events in
this demonstration, and not button release events.

.. code-block:: console
uart:~$
[00:00:02.377,227] <inf> ti_cc1352r_sensortag: Push button 1 event
[00:00:04.062,561] <inf> ti_cc1352r_sensortag: Push button 2 event
In this sample application, if we push the buttons within 100 ms of each
other, then we also trigger each of the sensor values to be displayed.

.. code-block:: console
uart:~$
[00:00:01.713,226] <inf> ti_cc1352r_sensortag: Push button 2 event
[00:00:01.713,928] <inf> ti_cc1352r_sensortag: Push button 1 event
[00:00:01.714,508] <inf> ti_cc1352r_sensortag: OPT3001: 1.700000
[00:00:01.714,599] <inf> ti_cc1352r_sensortag: ADXL362: x: -2.118236
[00:00:01.714,599] <inf> ti_cc1352r_sensortag: ADXL362: y: 0.166713
[00:00:01.714,630] <inf> ti_cc1352r_sensortag: ADXL362: z: 11.012867
Additional Sensors
------------------

At this time, Zephyr does not include a driver for the HDC2080 humidity
and temperature sensor from Texas Instruments. However, we are able to
read arbitrary registers via the I2C shell. The HDC2080 is located at
I2C address 0x41 and the identity register is at device address 0xfc.

.. code-block:: console
uart:~$ i2c read I2C_0 41 fc
00000000: 49 54 d0 07 00 00 00 00 00 00 00 00 00 00 00 ff |IT...... ........|
66 changes: 66 additions & 0 deletions samples/boards/beagleconnect_freedom/sensortest/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
CONFIG_I2C_LOG_LEVEL_DBG=y
CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y
CONFIG_CONSOLE_SUBSYS=y
CONFIG_CONSOLE_GETCHAR=y
CONFIG_ENTROPY_GENERATOR=y
CONFIG_LED=y
CONFIG_LOG=y
CONFIG_SHELL=y
CONFIG_GPIO=y
CONFIG_GPIO_SHELL=y
CONFIG_SENSOR=y
CONFIG_IEEE802154=y
CONFIG_NETWORKING=y
CONFIG_NET_ICMPV6_LOG_LEVEL_DBG=y
CONFIG_NET_HOSTNAME_ENABLE=y
CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=3
CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT=4
CONFIG_NET_IF_MAX_IPV6_COUNT=2
CONFIG_NET_SHELL=y
CONFIG_NET_TCP=y
CONFIG_NET_MAX_CONN=8
CONFIG_NET_MAX_CONTEXTS=10
CONFIG_NET_CONTEXT_NET_PKT_POOL=y
CONFIG_NET_PKT_RX_COUNT=8
CONFIG_NET_BUF_RX_COUNT=64
CONFIG_NET_PKT_TX_COUNT=20
CONFIG_NET_BUF_TX_COUNT=50
CONFIG_NET_STATISTICS=y
CONFIG_NET_LOG=y
CONFIG_MDNS_RESPONDER=y
CONFIG_DNS_SD=y
CONFIG_NET_CONFIG_AUTO_INIT=y
CONFIG_NET_CONFIG_SETTINGS=y
CONFIG_NET_CONFIG_MY_IPV6_ADDR="2001:db8::1"
CONFIG_NET_CONFIG_PEER_IPV6_ADDR="2001:db8::2"
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_POSIX_NAMES=y
CONFIG_NET_SOCKETS_POLL_MAX=8
CONFIG_NET_CONNECTION_MANAGER=y
CONFIG_NET_CONFIG_NEED_IPV6=y
CONFIG_NET_CONFIG_NEED_IPV4=n
CONFIG_NET_L2_IEEE802154=y
CONFIG_NET_L2_IEEE802154_SHELL=y
CONFIG_NET_L2_IEEE802154_LOG_LEVEL_INF=y

CONFIG_IEEE802154_CC13XX_CC26XX=n
CONFIG_IEEE802154_CC13XX_CC26XX_SUB_GHZ=y
CONFIG_NET_CONFIG_IEEE802154_CHANNEL=1
CONFIG_NET_CONFIG_IEEE802154_PAN_ID=0xabcd
CONFIG_NET_CONFIG_IEEE802154_RADIO_TX_POWER=20
CONFIG_IEEE802154_CC13XX_CC26XX_SUB_GHZ_NUM_RX_BUF=6

# Hacks
CONFIG_NEWLIB_LIBC=y
CONFIG_POSIX_MAX_FDS=16
CONFIG_POSIX_CLOCK=y
CONFIG_PTHREAD_IPC=y
CONFIG_MAX_PTHREAD_COUNT=16
#CONFIG_PTHREAD_DYNAMIC_STACK=y

# Telnet
CONFIG_NET_SHELL=y
CONFIG_KERNEL_SHELL=y
CONFIG_SHELL_BACKEND_TELNET=y
CONFIG_SHELL_TELNET_SUPPORT_COMMAND=y
2 changes: 2 additions & 0 deletions samples/boards/beagleconnect_freedom/sensortest/sample.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sample:
name: BeagleConnect Freedom Sensor Test
Loading

0 comments on commit 7962b67

Please sign in to comment.