Skip to content

Commit

Permalink
~
Browse files Browse the repository at this point in the history
  • Loading branch information
joshbrew committed Nov 29, 2024
1 parent 3897b98 commit 9e99dfa
Show file tree
Hide file tree
Showing 99 changed files with 1,282 additions and 1,278 deletions.
17 changes: 16 additions & 1 deletion Firmware/nrf5340/cpuapp/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,16 @@
build*/
.pio
.vscode/.browse.c_cpp.db*
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/ipch
# editors
.vscode
*.swp
*~

# python
.venv

# build
/build*
build*/
62 changes: 2 additions & 60 deletions Firmware/nrf5340/cpuapp/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,62 +1,4 @@
{
"nrf-connect.topdir": "${nrf-connect.sdk:2.5.1}",
"nrf-connect.toolchain.path": "${nrf-connect.toolchain:2.5.1}",
"nrf-connect.debugging.bindings": {
"${workspaceFolder}/build": "Launch build"
},
"files.associations": {
"*.tcc": "cpp",
"string": "cpp",
"fstream": "cpp",
"array": "cpp",
"atomic": "cpp",
"bit": "cpp",
"cctype": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"compare": "cpp",
"concepts": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"deque": "cpp",
"unordered_map": "cpp",
"vector": "cpp",
"exception": "cpp",
"algorithm": "cpp",
"functional": "cpp",
"iterator": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"netfwd": "cpp",
"numeric": "cpp",
"optional": "cpp",
"random": "cpp",
"ratio": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"initializer_list": "cpp",
"iosfwd": "cpp",
"istream": "cpp",
"limits": "cpp",
"new": "cpp",
"numbers": "cpp",
"ostream": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"cinttypes": "cpp",
"typeinfo": "cpp",
"zcbor_common.h": "c",
"smp.h": "c"
},
"C_Cpp.dimInactiveRegions": true
"nrf-connect.topdir": "${nrf-connect.sdk:1.9.1}",
"nrf-connect.toolchain.path": "${nrf-connect.toolchain:1.9.1}"
}
20 changes: 7 additions & 13 deletions Firmware/nrf5340/cpuapp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
cmake_minimum_required(VERSION 3.20.0)
# SPDX-License-Identifier: Apache-2.0

# set(DTC_OVERLAY_FILE "nrf5340dk_nrf5340.overlay")
set(DTS_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dts")

# Get the parent directory of ZEPHYR_BASE
# get_filename_component(PARENT_DIR ${ZEPHYR_BASE} DIRECTORY)
# set(MODULE_DIR "${PARENT_DIR}/modules")
cmake_minimum_required(VERSION 3.17.0)

set(DTC_OVERLAY_FILE "nrf5340dk_nrf5340.overlay")

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})

project(hello_world)

FILE(GLOB app_sources src/*.c*)
target_sources(app PRIVATE ${app_sources})

target_include_directories(app PRIVATE
include
include/Transports)

set_property(TARGET app PROPERTY CXX_STANDARD 17)
include
include/Transports)

project(BT40_port_to_3.5)
set_property(TARGET app PROPERTY CXX_STANDARD 17)
4 changes: 0 additions & 4 deletions Firmware/nrf5340/cpuapp/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ mainmenu "Application"
bool "Include the ADS131M08 sensors in compilation"
default n

config USE_ADS131M08_1
bool "Include the ADS131M08_1 sensors in compilation"
default n

config USE_BME280
bool "Include the BME280 sensor in compilation"
default n
Expand Down
2 changes: 1 addition & 1 deletion Firmware/nrf5340/cpuapp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ For pinouts refer to datasheet: https://www.mouser.com/datasheet/2/915/Fanstel_0
Note, the BT-series design is using the BT840 footprint, so correlate the pins via the datasheet.

Instructions:
- [Install](https://nrfconnect.github.io/vscode-nrf-connect/) nRFConnect for VSCode. We used SDK version 2.8.0 in the toolchain manager.
- [Install](https://nrfconnect.github.io/vscode-nrf-connect/) nRFConnect for VSCode. We used SDK version 1.9.1 in the toolchain manager. Note v2023.11.301 of the main plugin would not work for us and others. Use v2023.11.24
- Open this repo in VSCode and launch the nRFConnect menu within VSCode
- In VSCode, in the nRFConnect extension under the APPLICATIONS tab, select the "Add Build Configuration" button to the right of the main folder name (cpuapp). Select the correct board, nrf5340dk_nrf5340_cpuapp, and click Build Configuration. Make sure prj.conf is selected as the configuration below it.
- Connect the nRF52-dk via usb with the flash pins wired to the custom PCB. Note: wire VTG to VDD on the DK, then VDDnRF to the custom PCB's VDD pin, then the rest of the SW/Reset/Gnd pins.
Expand Down
10 changes: 5 additions & 5 deletions Firmware/nrf5340/cpuapp/include/ADS131M08_zephyr.hpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#pragma once

#include <zephyr/types.h>
#include <zephyr/device.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/drivers/spi.h>
#include <zephyr/sys/util.h>
#include <zephyr/sys/atomic.h>
#include <device.h>
#include <drivers/gpio.h>
#include <drivers/spi.h>
#include <sys/util.h>
#include <atomic>

#define ADS131_ID 0x00
#define ADS131_STATUS 0x01
Expand Down
18 changes: 5 additions & 13 deletions Firmware/nrf5340/cpuapp/include/Transports/i2c_transport.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#pragma once
#include <zephyr/sys/atomic.h>
#include <zephyr/drivers/i2c.h>
#include <atomic>
#include <drivers/i2c.h>

// #define MAX30102_NODE DT_NODELABEL(max30102)
/**
* @brief template transport class used to read/write device registers via i2c bus
*
Expand All @@ -18,23 +17,16 @@ class I2CTransport
*/
I2CTransport()
{
// dev = device_get_binding(DeviceName::c_str());
// dev = DEVICE_DT_GET(MAX30102_NODE);
// if(strcmp(DeviceName::c_str(), "i2c1max"))
// {
// dev = DEVICE_DT_GET(DT_NODELABEL(i2c1max));
// }
dev = device_get_binding(DeviceName::c_str());
deviceStatus.store(0, std::memory_order_relaxed);
}

/**
* @brief Initialization function used to intialize when underlayer infrastructure is ready
*/
void Initialize(const device* dev_arg)
void Initialize()
{
dev = dev_arg;
int status = i2c_configure(dev, I2C_SPEED_SET(I2C_SPEED_FAST) | I2C_MODE_CONTROLLER);
// int status = i2c_configure(dev, I2C_SPEED_SET(I2C_SPEED_FAST) | I2C_MODE_MASTER);
int status = i2c_configure(dev, I2C_SPEED_SET(I2C_SPEED_FAST) | I2C_MODE_MASTER);
deviceStatus.store(status, std::memory_order_relaxed);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include <atomic>

#include <zephyr/drivers/spi.h>
#include <drivers/spi.h>

#define ADS131_DRV DT_NODELABEL(ads131drv) ///< ADS131M08 device

Expand Down
27 changes: 14 additions & 13 deletions Firmware/nrf5340/cpuapp/include/audio_module.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,33 @@

#include <string.h>
#include <nrf.h>
#include <zephyr/kernel.h>
#include <kernel.h>

#include <zephyr/types.h>
#include <zephyr/device.h>
#include <zephyr/drivers/gpio.h>
#include <device.h>
#include <drivers/gpio.h>

#include <zephyr/sys/util.h>
#include <zephyr/sys/atomic.h>
#include <sys/util.h>
#include <atomic>
#include "ble_types.hpp"
#include "ble_commands.hpp"
#include "device_string.hpp"

/*************************/
#include <string.h>
#include <nrf.h>
#include <zephyr/device.h>
#include <zephyr/drivers/i2s.h>
#include <zephyr/drivers/gpio.h>
#include <kernel.h>
#include <device.h>
#include <drivers/i2s.h>
#include <drivers/gpio.h>

#include <zephyr/logging/log.h>
#include <zephyr/sys/printk.h>
#include <logging/log.h>
#include <sys/printk.h>

/* Prepare for 32 sample values */
#define NUM_SAMPLES 32
#define I2S_BLOCK_SIZE 128
#define NUM_BLOCKS 5
#define NUM_SAMPLES 32
#define BLOCK_SIZE 128
#define NUM_BLOCKS 5
// #define J_LIMIT sizeof(rawAudioData) / (NUM_BLOCKS * NUM_SAMPLES * 2)
// #define J_LIMIT (93056 / (NUM_BLOCKS * NUM_SAMPLES * 2))

Expand Down
4 changes: 2 additions & 2 deletions Firmware/nrf5340/cpuapp/include/ble_gatt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

#include <functional>

#include <zephyr/bluetooth/gatt.h>
#include <zephyr/sys/atomic.h>
#include <bluetooth/gatt.h>
#include <sys/atomic.h>

#include "ble_types.hpp"
#include "commandid.hpp"
Expand Down
2 changes: 1 addition & 1 deletion Firmware/nrf5340/cpuapp/include/ble_types.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include <functional>
#include <zephyr/bluetooth/bluetooth.h>
#include <bluetooth/bluetooth.h>

namespace Bluetooth
{
Expand Down
12 changes: 6 additions & 6 deletions Firmware/nrf5340/cpuapp/include/bme280.hpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#pragma once

#include <zephyr/kernel.h>
#include <zephyr/device.h>
#include <zephyr/devicetree.h>
#include <zephyr/drivers/sensor.h>
#include <zephyr/sys/atomic.h>
#include <zephyr.h>
#include <device.h>
#include <devicetree.h>
#include <drivers/sensor.h>
#include <atomic>
#include <stdlib.h>
#include <zephyr/logging/log.h>
#include <logging/log.h>

#include "ble_service.hpp"
#include "usb_comm_handler.hpp"
Expand Down
19 changes: 10 additions & 9 deletions Firmware/nrf5340/cpuapp/include/dmic_module.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,27 @@

#include <string.h>
#include <nrf.h>
#include <zephyr/kernel.h>
#include <kernel.h>

#include <zephyr/types.h>
#include <zephyr/device.h>
#include <zephyr/drivers/gpio.h>
#include <device.h>
#include <drivers/gpio.h>

#include <zephyr/sys/util.h>
#include <zephyr/sys/atomic.h>
#include <sys/util.h>
#include <atomic>
#include "ble_types.hpp"
#include "ble_commands.hpp"
#include "device_string.hpp"

/*************************/
#include <zephyr/device.h>
#include <zephyr/audio/dmic.h>
#include <zephyr.h>
#include <device.h>
#include <audio/dmic.h>
#include "arm_math.h"
#include "dsp/transform_functions.h"

#include <zephyr/logging/log.h>
#include <zephyr/sys/printk.h>
#include <logging/log.h>
#include <sys/printk.h>

#define MAX_SAMPLE_RATE 16000
#define SAMPLE_BIT_WIDTH 16
Expand Down
14 changes: 6 additions & 8 deletions Firmware/nrf5340/cpuapp/include/max30102.hpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#pragma once

#include <zephyr/types.h>
#include <zephyr/device.h>
#include <zephyr/drivers/gpio.h>
#include <device.h>
#include <drivers/gpio.h>
//#include <drivers/i2c.h>
#include <zephyr/sys/util.h>
#include <zephyr/sys/atomic.h>
#include <sys/util.h>
#include <atomic>
#include "i2c_transport.hpp"
#include "device_string.hpp"
#include "ble_types.hpp"
Expand Down Expand Up @@ -131,10 +131,7 @@ class UsbCommHandler;
*/
class Max30102 {

// using I2C_1DeviceName = DeviceString<'I', '2', 'C', '_', '1'>;
// using I2C_1DeviceName = DeviceString<'i', '2', 'c', '1', 'm', 'a', 'x'>;
using I2C_1DeviceName = DeviceString<'m', 'a', 'x', '3', '0', '1', '0', '2'>;

using I2C_1DeviceName = DeviceString<'I', '2', 'C', '_', '1'>;

constexpr static uint8_t max30102_i2c_address = 0x57; //I2C Address
constexpr static uint8_t max30102_id = 0x15; // Part ID
Expand Down Expand Up @@ -232,4 +229,5 @@ class Max30102 {
std::atomic<bool> max30102_is_on_i2c_bus_; ///< Device status
I2CTransport<I2C_1DeviceName, max30102_i2c_address> transport; ///< I2C transport for device
UsbCommHandler &serialHandler; ///< USB communication controller

};
8 changes: 4 additions & 4 deletions Firmware/nrf5340/cpuapp/include/mpu6050.hpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#pragma once

#include <zephyr/types.h>
#include <zephyr/device.h>
#include <zephyr/drivers/gpio.h>
#include <device.h>
#include <drivers/gpio.h>
//#include <drivers/i2c.h>
#include <zephyr/sys/util.h>
#include <zephyr/sys/atomic.h>
#include <sys/util.h>
#include <atomic>
#include "i2c_transport.hpp"
#include "device_string.hpp"
#include "ble_types.hpp"
Expand Down
Loading

0 comments on commit 9e99dfa

Please sign in to comment.