move things around
Some checks failed
Build / build (ubuntu-22.04) (push) Failing after 2m20s
Documentation / build (push) Failing after -1m2s

This commit is contained in:
2025-05-31 00:01:48 -06:00
parent 321fadf77e
commit 3134dc52e4
69 changed files with 0 additions and 201 deletions

View File

@ -0,0 +1,12 @@
#-------------------------------------------------------------------------------
# Zephyr Example Application
#
# Copyright (c) 2021 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0
cmake_minimum_required(VERSION 3.13.1)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(app LANGUAGES C)
target_sources(app PRIVATE src/main.c)

15
firmware/app/Kconfig Normal file
View File

@ -0,0 +1,15 @@
# Copyright (c) 2021 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0
#
# This file is the application Kconfig entry point. All application Kconfig
# options can be defined here or included via other application Kconfig files.
# You can browse these options using the west targets menuconfig (terminal) or
# guiconfig (GUI).
menu "Zephyr"
source "Kconfig.zephyr"
endmenu
module = APP
module-str = APP
source "subsys/logging/Kconfig.template.log_config"

5
firmware/app/VERSION Normal file
View File

@ -0,0 +1,5 @@
VERSION_MAJOR = 1
VERSION_MINOR = 0
PATCHLEVEL = 0
VERSION_TWEAK = 0
EXTRAVERSION =

View File

@ -0,0 +1,27 @@
/*
* Copyright (c) 2021 Nordic Semiconductor ASA
* SPDX-License-Identifier: Apache-2.0
*/
/* This devicetree overlay file will be automatically picked by the Zephyr
* build system when building the sample for the nucleo_f302r8 board. It shows
* how the example-application can be built on sample boards already provided
* by Zephyr.
*/
/ {
example_sensor: example-sensor {
compatible = "zephyr,example-sensor";
input-gpios = <&gpio0 13 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
};
blink_led: blink-led {
compatible = "blink-gpio-led";
led-gpios = <&gpio0 17 GPIO_ACTIVE_HIGH>;
blink-period-ms = <500>;
};
};
&gpio0 {
status = "okay";
};

View File

@ -0,0 +1,27 @@
/*
* Copyright (c) 2021 Nordic Semiconductor ASA
* SPDX-License-Identifier: Apache-2.0
*/
/* This devicetree overlay file will be automatically picked by the Zephyr
* build system when building the sample for the nucleo_f302r8 board. It shows
* how the example-application can be built on sample boards already provided
* by Zephyr.
*/
/ {
example_sensor: example-sensor {
compatible = "zephyr,example-sensor";
input-gpios = <&gpioc 13 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
};
blink_led: blink-led {
compatible = "blink-gpio-led";
led-gpios = <&gpiob 13 GPIO_ACTIVE_HIGH>;
blink-period-ms = <1000>;
};
};
&gpioc {
status = "okay";
};

View File

@ -0,0 +1,16 @@
/ {
example_sensor: example-sensor {
compatible = "zephyr,example-sensor";
input-gpios = <&gpioc 13 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
};
blink_led: blink-led {
compatible = "blink-gpio-led";
led-gpios = <&gpioe 1 GPIO_ACTIVE_HIGH>;
blink-period-ms = <1000>;
};
};
&gpioc {
status = "okay";
};

View File

@ -0,0 +1,16 @@
/ {
example_sensor: example-sensor {
compatible = "zephyr,example-sensor";
input-gpios = <&gpioc 13 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
};
blink_led: blink-led {
compatible = "blink-gpio-led";
led-gpios = <&gpiob 0 GPIO_ACTIVE_HIGH>;
blink-period-ms = <1000>;
};
};
&gpioc {
status = "okay";
};

12
firmware/app/debug.conf Normal file
View File

@ -0,0 +1,12 @@
# Copyright (c) 2021 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0
#
# This is a Kconfig fragment which can be used to enable debug-related options
# in the application. See the README for more details.
# compiler
CONFIG_DEBUG_OPTIMIZATIONS=y
# logging
CONFIG_LOG=y
CONFIG_APP_LOG_LEVEL_DBG=y

28
firmware/app/prj.conf Normal file
View File

@ -0,0 +1,28 @@
# Copyright (c) 2021 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0
#
# This file contains selected Kconfig options for the application.
CONFIG_SENSOR=y
CONFIG_BLINK=y
CONFIG_STDOUT_CONSOLE=y
CONFIG_HEAP_MEM_POOL_SIZE=16384
CONFIG_DISPLAY=y
CONFIG_LOG=y
CONFIG_CFB_LOG_LEVEL_DBG=y
CONFIG_CHARACTER_FRAMEBUFFER=y
CONFIG_CBPRINTF_FP_SUPPORT=y
CONFIG_BT=y
CONFIG_BT_SMP=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_GATT_CLIENT=y
CONFIG_BT_DEVICE_NAME="Mellifera"
CONFIG_BOOTLOADER_MCUBOOT=y
CONFIG_MCUBOOT_GENERATE_UNSIGNED_IMAGE=y

16
firmware/app/sample.yaml Normal file
View File

@ -0,0 +1,16 @@
# This file is provided so that the application can be compiled using Twister,
# the Zephyr testing tool. In this file, multiple combinations can be specified,
# so that you can easily test all of them locally or in CI.
sample:
description: Example application
name: example-application
common:
build_only: true
integration_platforms:
- custom_plank
- nucleo_f302r8
tests:
app.default: {}
app.debug:
extra_overlay_confs:
- debug.conf

373
firmware/app/src/main.c Normal file
View File

@ -0,0 +1,373 @@
/*
* Copyright (c) 2021 Nordic Semiconductor ASA
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/kernel.h>
#include <zephyr/drivers/sensor.h>
#include <zephyr/logging/log.h>
#include <zephyr/display/cfb.h>
#include <app/drivers/blink.h>
#include <app_version.h>
#include <zephyr/bluetooth/bluetooth.h>
#include <zephyr/bluetooth/hci.h>
LOG_MODULE_REGISTER(main, CONFIG_APP_LOG_LEVEL);
#define BLINK_PERIOD_MS_STEP 100U
#define BLINK_PERIOD_MS_MAX 1000U
#define DEVICE_NAME CONFIG_BT_DEVICE_NAME
#define DEVICE_NAME_LEN (sizeof(DEVICE_NAME) - 1)
/*
* Set Advertisement data. Based on the Eddystone specification:
* https://github.com/google/eddystone/blob/master/protocol-specification.md
* https://github.com/google/eddystone/tree/master/eddystone-url
*/
static const struct bt_data ad[] = {
BT_DATA_BYTES(BT_DATA_FLAGS, BT_LE_AD_NO_BREDR),
BT_DATA_BYTES(BT_DATA_UUID16_ALL, 0xaa, 0xfe),
BT_DATA_BYTES(BT_DATA_SVC_DATA16,
0xaa, 0xfe, /* Eddystone UUID */
0x10, /* Eddystone-URL frame type */
0x00, /* Calibrated Tx power at 0m */
0x00, /* URL Scheme Prefix http://www. */
'z', 'e', 'p', 'h', 'y', 'r',
'p', 'r', 'o', 'j', 'e', 'c', 't',
0x08) /* .org */
};
/* Set Scan Response data */
static const struct bt_data sd[] = {
BT_DATA(BT_DATA_NAME_COMPLETE, DEVICE_NAME, DEVICE_NAME_LEN),
};
static void bt_ready(int err)
{
char addr_s[BT_ADDR_LE_STR_LEN];
bt_addr_le_t addr = {0};
size_t count = 1;
if (err)
{
LOG_ERR("Bluetooth init failed (err %d)", err);
return;
}
LOG_INF("Bluetooth initialized");
// Start advertising
err = bt_le_adv_start(BT_LE_ADV_NCONN_IDENTITY, ad, ARRAY_SIZE(ad),
sd, ARRAY_SIZE(sd));
if (err)
{
LOG_ERR("Advertising failed to start (err %d)", err);
return;
}
/* For connectable advertising you would use
* bt_le_oob_get_local(). For non-connectable non-identity
* advertising an non-resolvable private address is used;
* there is no API to retrieve that.
*/
bt_id_get(&addr, &count);
bt_addr_le_to_str(&addr, addr_s, sizeof(addr_s));
LOG_INF("Beacon started, advertising as %s", addr_s);
}
int main(void)
{
const struct device *display, *ina, *baro, *accel, *gyro, *mag, *lis, *hdc;
int err;
uint16_t x_res;
uint16_t y_res;
uint16_t rows;
uint8_t ppt;
uint8_t font_width;
uint8_t font_height;
struct sensor_value voltage, current, pressure, temperature, accel_x, accel_y, accel_z, accel_z_ref, gyro_x, gyro_y, gyro_z, mag_x, mag_y, mag_z, humidity;
char str_v[15] = {0};
char str_i[15] = {0};
char str_p[16] = {0};
char str_t[16] = {0};
char str_ax[16] = {0};
char str_ay[16] = {0};
char str_az[16] = {0};
char str_az_ref[16] = {0};
char str_gx[16] = {0};
char str_gy[16] = {0};
char str_gz[16] = {0};
char str_mx[16] = {0};
char str_my[16] = {0};
char str_mz[16] = {0};
char str_h[16] = {0};
LOG_INF("Starting Mellifera version %s...", APP_VERSION_STRING);
// LOG_INF("Board: %s", BOARD);
// Initialize the Bluetooth Subsystem
err = bt_enable(bt_ready);
if (err)
{
LOG_ERR("Bluetooth init failed (err %d)", err);
}
display = DEVICE_DT_GET(DT_CHOSEN(zephyr_display));
if (!device_is_ready(display))
{
LOG_ERR("Device %s not ready", display->name);
return 0;
}
if (display_set_pixel_format(display, PIXEL_FORMAT_MONO10) != 0)
{
if (display_set_pixel_format(display, PIXEL_FORMAT_MONO01) != 0)
{
LOG_ERR("Failed to set required pixel format");
return 0;
}
}
LOG_INF("Initialized %s", display->name);
if (cfb_framebuffer_init(display))
{
LOG_ERR("Framebuffer initialization failed!");
return 0;
}
cfb_framebuffer_clear(display, true);
display_blanking_off(display);
x_res = cfb_get_display_parameter(display, CFB_DISPLAY_WIDTH);
y_res = cfb_get_display_parameter(display, CFB_DISPLAY_HEIGH);
rows = cfb_get_display_parameter(display, CFB_DISPLAY_ROWS);
ppt = cfb_get_display_parameter(display, CFB_DISPLAY_PPT);
for (int idx = 0; idx < 42; idx++)
{
if (cfb_get_font_size(display, idx, &font_width, &font_height))
{
break;
}
cfb_framebuffer_set_font(display, idx);
LOG_INF("font width %d, font height %d",
font_width, font_height);
}
cfb_framebuffer_set_font(display, 0);
LOG_INF("x_res %d, y_res %d, ppt %d, rows %d, cols %d",
x_res,
y_res,
ppt,
rows,
cfb_get_display_parameter(display, CFB_DISPLAY_COLS));
cfb_set_kerning(display, 3);
ina = DEVICE_DT_GET(DT_NODELABEL(ina231));
if (!device_is_ready(ina))
{
LOG_ERR("Device %s not ready", ina->name);
return 0;
}
baro = DEVICE_DT_GET(DT_NODELABEL(bmp388));
if (!device_is_ready(baro))
{
LOG_ERR("Device %s not ready", baro->name);
return 0;
}
accel = DEVICE_DT_GET(DT_NODELABEL(bmx055_accel));
if (!device_is_ready(accel))
{
LOG_ERR("Device %s not ready", accel->name);
return 0;
}
LOG_INF("Initialized %s", accel->name);
gyro = DEVICE_DT_GET(DT_NODELABEL(bmx055_gyro));
if (!device_is_ready(gyro))
{
LOG_ERR("Device %s not ready", gyro->name);
return 0;
}
LOG_INF("Initialized %s", gyro->name);
mag = DEVICE_DT_GET(DT_NODELABEL(bmx055_mag));
if (!device_is_ready(mag))
{
LOG_ERR("Device %s not ready", mag->name);
return 0;
}
LOG_INF("Initialized %s", mag->name);
lis = DEVICE_DT_GET(DT_NODELABEL(lis2dh));
if (!device_is_ready(lis))
{
LOG_ERR("Device %s not ready", lis->name);
return 0;
}
LOG_INF("Initialized %s", lis->name);
hdc = DEVICE_DT_GET(DT_NODELABEL(hdc1080));
if (!device_is_ready(hdc))
{
LOG_ERR("Device %s not ready", hdc->name);
return 0;
}
while (1)
{
if (sensor_sample_fetch(ina) < 0)
{
LOG_ERR("Could not fetch sample");
}
if (sensor_channel_get(ina, SENSOR_CHAN_VOLTAGE, &voltage) < 0)
{
LOG_ERR("Could not get voltage");
}
if (sensor_channel_get(ina, SENSOR_CHAN_CURRENT, &current) < 0)
{
LOG_ERR("Could not get current");
}
if (sensor_sample_fetch(baro) < 0)
{
LOG_ERR("Could not fetch sample");
}
if (sensor_channel_get(baro, SENSOR_CHAN_PRESS, &pressure) < 0)
{
LOG_ERR("Could not get pressure");
}
if (sensor_channel_get(baro, SENSOR_CHAN_AMBIENT_TEMP, &temperature) < 0)
{
LOG_ERR("Could not get temperature");
}
if (sensor_sample_fetch(accel) < 0)
{
LOG_ERR("Could not fetch sample from accel");
}
if (sensor_channel_get(accel, SENSOR_CHAN_ACCEL_X, &accel_x) < 0)
{
LOG_ERR("Could not get acceleration");
}
if (sensor_channel_get(accel, SENSOR_CHAN_ACCEL_Y, &accel_y) < 0)
{
LOG_ERR("Could not get acceleration");
}
if (sensor_channel_get(accel, SENSOR_CHAN_ACCEL_Z, &accel_z) < 0)
{
LOG_ERR("Could not get acceleration");
}
if (sensor_sample_fetch(gyro) < 0)
{
LOG_ERR("Could not fetch sample from gyro");
}
if (sensor_channel_get(gyro, SENSOR_CHAN_GYRO_X, &gyro_x) < 0)
{
LOG_ERR("Could not get gyro");
}
if (sensor_channel_get(gyro, SENSOR_CHAN_GYRO_Y, &gyro_y) < 0)
{
LOG_ERR("Could not get gyro");
}
if (sensor_channel_get(gyro, SENSOR_CHAN_GYRO_Z, &gyro_z) < 0)
{
LOG_ERR("Could not get gyro");
}
if (sensor_sample_fetch(mag) < 0)
{
LOG_ERR("Could not fetch sample from mag");
}
if (sensor_channel_get(mag, SENSOR_CHAN_MAGN_X, &mag_x) < 0)
{
LOG_ERR("Could not get mag");
}
if (sensor_channel_get(mag, SENSOR_CHAN_MAGN_Y, &mag_y) < 0)
{
LOG_ERR("Could not get mag");
}
if (sensor_channel_get(mag, SENSOR_CHAN_MAGN_Z, &mag_z) < 0)
{
LOG_ERR("Could not get mag");
}
if (sensor_sample_fetch(lis) < 0)
{
LOG_ERR("Could not fetch sample");
}
if (sensor_channel_get(lis, SENSOR_CHAN_ACCEL_Z, &accel_z_ref) < 0)
{
LOG_ERR("Could not get acceleration");
}
if (sensor_sample_fetch(hdc) < 0)
{
LOG_ERR("Could not fetch sample");
}
if (sensor_channel_get(hdc, SENSOR_CHAN_AMBIENT_TEMP, &temperature) < 0)
{
LOG_ERR("Could not get sample");
}
if (sensor_channel_get(hdc, SENSOR_CHAN_HUMIDITY, &humidity) < 0)
{
LOG_ERR("Could not get sample");
}
sprintf(str_v, "V :%7.5f", voltage.val1 + voltage.val2 * 1e-6);
sprintf(str_i, "I :%7.5f", current.val1 + current.val2 * 1e-6);
sprintf(str_p, "P :%7.4f", pressure.val1 + pressure.val2 * 1e-6);
sprintf(str_t, "T :%7.4f", temperature.val1 + temperature.val2 * 1e-6);
sprintf(str_ax, "AX:%+7.3f", accel_x.val1 + accel_x.val2 * 1e-6);
sprintf(str_ay, "AY:%+7.3f", accel_y.val1 + accel_y.val2 * 1e-6);
sprintf(str_az, "AZ:%+7.3f", accel_z.val1 + accel_z.val2 * 1e-6);
sprintf(str_gx, "GX:%+7.3f", gyro_x.val1 + gyro_x.val2 * 1e-6);
sprintf(str_gy, "GY:%+7.3f", gyro_y.val1 + gyro_y.val2 * 1e-6);
sprintf(str_gz, "GZ:%+7.3f", gyro_z.val1 + gyro_z.val2 * 1e-6);
sprintf(str_mx, "MX:%+7.3f", mag_x.val1 + mag_x.val2 * 1e-6);
sprintf(str_my, "MY:%+7.3f", mag_y.val1 + mag_y.val2 * 1e-6);
sprintf(str_mz, "MZ:%+7.3f", mag_z.val1 + mag_z.val2 * 1e-6);
sprintf(str_az_ref, "Zr:%+7.3f", accel_z_ref.val1 + accel_z_ref.val2 * 1e-6);
sprintf(str_h, "H :%7.3f", humidity.val1 + humidity.val2 * 1e-6);
// LOG_INF("%s\t%s\t%s\t%s", str_v, str_i, str_p, str_t);
cfb_framebuffer_clear(display, false);
if (cfb_print(display, str_mx, 0, 0))
{
LOG_ERR("Failed to print a string");
}
if (cfb_print(display, str_gy, 0, 16))
{
LOG_ERR("Failed to print a string");
}
if (cfb_print(display, str_gz, 0, 16 * 2))
{
LOG_ERR("Failed to print a string");
}
if (cfb_print(display, str_ax, 0, 16 * 3))
{
LOG_ERR("Failed to print a string");
}
cfb_framebuffer_finalize(display);
#if defined(CONFIG_ARCH_POSIX)
k_sleep(K_MSEC(20));
#endif
}
return 0;
}