commit bbedb8d0fdca25f13ea9f92d082e92fd05dd9a82 Author: xlemmingx Date: Thu May 22 12:46:26 2025 +0200 initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..89cc49c --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +.pio +.vscode/.browse.c_cpp.db* +.vscode/c_cpp_properties.json +.vscode/launch.json +.vscode/ipch diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..080e70d --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,10 @@ +{ + // See http://go.microsoft.com/fwlink/?LinkId=827846 + // for the documentation about the extensions.json format + "recommendations": [ + "platformio.platformio-ide" + ], + "unwantedRecommendations": [ + "ms-vscode.cpptools-extension-pack" + ] +} diff --git a/boards/g2h_lorawan_heat_control.json b/boards/g2h_lorawan_heat_control.json new file mode 100644 index 0000000..7e23a61 --- /dev/null +++ b/boards/g2h_lorawan_heat_control.json @@ -0,0 +1,43 @@ +{ + "build": { + "core": "stm32", + "cpu": "cortex-m4", + "extra_flags": "-DSTM32WL -DSTM32WLxx -DSTM32WLE5xx", + "f_cpu": "48000000L", + "framework_extra_flags": { + "arduino": "-DUSE_CM4_STARTUP_FILE" + }, + "mcu": "stm32wl55jc", + "product_line": "STM32WL55xx", + "variant": "STM32WLxx/WL54JCI_WL55JCI_WLE4J(8-B-C)I_WLE5J(8-B-C)I" + }, + "debug": { + "default_tools": [ + "stlink" + ], + "jlink_device": "STM32WL55JC", + "onboard_tools": [ + "stlink" + ], + "openocd_target": "stm32wlx", + "svd_path": "STM32WL5x_CM4.svd" + }, + "frameworks": [ + "arduino", + "zephyr" + ], + "name": "G2H LoraWAN Heat Control", + "upload": { + "maximum_ram_size": 65536, + "maximum_size": 262144, + "protocol": "stlink", + "protocols": [ + "jlink", + "cmsis-dap", + "stlink", + "mbed" + ] + }, + "url": "https://www.st.com/en/evaluation-tools/nucleo-wl55jc.html", + "vendor": "ST" +} diff --git a/include/README b/include/README new file mode 100644 index 0000000..49819c0 --- /dev/null +++ b/include/README @@ -0,0 +1,37 @@ + +This directory is intended for project header files. + +A header file is a file containing C declarations and macro definitions +to be shared between several project source files. You request the use of a +header file in your project source file (C, C++, etc) located in `src` folder +by including it, with the C preprocessing directive `#include'. + +```src/main.c + +#include "header.h" + +int main (void) +{ + ... +} +``` + +Including a header file produces the same results as copying the header file +into each source file that needs it. Such copying would be time-consuming +and error-prone. With a header file, the related declarations appear +in only one place. If they need to be changed, they can be changed in one +place, and programs that include the header file will automatically use the +new version when next recompiled. The header file eliminates the labor of +finding and changing all the copies as well as the risk that a failure to +find one copy will result in inconsistencies within a program. + +In C, the convention is to give header files names that end with `.h'. + +Read more about using header files in official GCC documentation: + +* Include Syntax +* Include Operation +* Once-Only Headers +* Computed Includes + +https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html diff --git a/lib/README b/lib/README new file mode 100644 index 0000000..9379397 --- /dev/null +++ b/lib/README @@ -0,0 +1,46 @@ + +This directory is intended for project specific (private) libraries. +PlatformIO will compile them to static libraries and link into the executable file. + +The source code of each library should be placed in a separate directory +("lib/your_library_name/[Code]"). + +For example, see the structure of the following example libraries `Foo` and `Bar`: + +|--lib +| | +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| | |- library.json (optional. for custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html +| | +| |--Foo +| | |- Foo.c +| | |- Foo.h +| | +| |- README --> THIS FILE +| +|- platformio.ini +|--src + |- main.c + +Example contents of `src/main.c` using Foo and Bar: +``` +#include +#include + +int main (void) +{ + ... +} + +``` + +The PlatformIO Library Dependency Finder will find automatically dependent +libraries by scanning project source files. + +More information about PlatformIO Library Dependency Finder +- https://docs.platformio.org/page/librarymanager/ldf.html diff --git a/platformio.ini b/platformio.ini new file mode 100644 index 0000000..4637da5 --- /dev/null +++ b/platformio.ini @@ -0,0 +1,14 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[env:g2h_lorawan_heat_control] +platform = ststm32 +board = g2h_lorawan_heat_control +framework = zephyr diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..696d160 --- /dev/null +++ b/src/main.c @@ -0,0 +1,203 @@ +/* + * Class A LoRaWAN sample application + * + * Copyright (c) 2020 Manivannan Sadhasivam + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include +#include +#include +#include +#include + +#include + +/* Customize based on network configuration */ +#define LORAWAN_DEV_EUI { 0x2D, 0xBF, 0xF6, 0xC2, 0xA1, 0x20,\ + 0x01, 0x4A } +#define LORAWAN_JOIN_EUI { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ + 0x00, 0x00 } +/* #define LORAWAN_APP_KEY { 0x71, 0x5A, 0x39, 0xB2, 0x86, 0xC3,\ + 0x37, 0xA3, 0xC4, 0xF0, 0x78, 0xF9,\ + 0x0F, 0x33, 0x07, 0x7D } */ +#define LORAWAN_APP_KEY { 0x71, 0x5A, 0x39, 0xB2, 0x86, 0xC3,\ + 0x37, 0xA3, 0xC4, 0xF0, 0x78, 0xF9,\ + 0x0F, 0x33, 0x07, 0x7D } + +#define DELAY K_MSEC(10000) + +#define LOG_LEVEL CONFIG_LOG_DEFAULT_LEVEL +#include +LOG_MODULE_REGISTER(lorawan_class_a); + +char data[] = {'h', 'e', 'l', 'l', 'o', 'w', 'o', 'r', 'l', 'd'}; + +static void dl_callback(uint8_t port, uint8_t flags, int16_t rssi, int8_t snr, uint8_t len, + const uint8_t *hex_data) +{ + LOG_INF("Port %d, Pending %d, RSSI %ddB, SNR %ddBm, Time %d", port, + flags & LORAWAN_DATA_PENDING, rssi, snr, !!(flags & LORAWAN_TIME_UPDATED)); + if (hex_data) { + LOG_HEXDUMP_INF(hex_data, len, "Payload: "); + } +} + +static void lorwan_datarate_changed(enum lorawan_datarate dr) +{ + uint8_t unused, max_size; + + lorawan_get_payload_sizes(&unused, &max_size); + LOG_INF("New Datarate: DR_%d, Max Payload %d", dr, max_size); +} + + +/* MAIN */ +int main(void) +{ + + // MLX90614 Example Fetch + const struct device *i2c_dev = DEVICE_DT_GET(DT_NODELABEL(i2c1)); + uint8_t reg_addr; + uint8_t read_data[3]; + + if (!i2c_dev) { + printk("I2C device not found\n"); + return; + } + + reg_addr = 0x06; + if (i2c_write_read(i2c_dev, 0x5A, ®_addr, sizeof(reg_addr), &read_data, sizeof(read_data)) < 0) + { + printk("Failed to write to I2C device\n"); + } + int16_t temperature = (read_data[1] << 8) | read_data[0]; // Temperaturwert aus den empfangenen Daten + float temp_celsius = temperature * 0.02 - 273.15; // Umrechnung in Celsius + + printf("Temperatur Sensor: %.2f °C\n", temp_celsius); + + + + reg_addr = 0x07; + if (i2c_write_read(i2c_dev, 0x5A, ®_addr, sizeof(reg_addr), &read_data, sizeof(read_data)) < 0) + { + printk("Failed to write to I2C device\n"); + } + + // Temperaturdaten verarbeiten + temperature = (read_data[1] << 8) | read_data[0]; // Temperaturwert aus den empfangenen Daten + temp_celsius = temperature * 0.02 - 273.15; // Umrechnung in Celsius + + printf("Temperatur IR: %.2f °C\n", temp_celsius); + + return 0; + + + + /* + // SHT4X Example Fetch + if(!DT_HAS_COMPAT_STATUS_OKAY(sensirion_sht4x)) { + printf("No sensirion,sht4x compatible node found in the device tree"); + } + + const struct device *const sht = DEVICE_DT_GET_ANY(sensirion_sht4x); + struct sensor_value temp, hum; + + if (!device_is_ready(sht)) { + printf("SHT4X-Device %s is not ready.\n", sht->name); + return 0; + } + + while (true) { + + if (sensor_sample_fetch(sht)) { + printf("Failed to fetch sample from SHT4X device\n"); + return 0; + } + + sensor_channel_get(sht, SENSOR_CHAN_AMBIENT_TEMP, &temp); + sensor_channel_get(sht, SENSOR_CHAN_HUMIDITY, &hum); + + printf("SHT4X: %.2f Temp. [C] ; %0.2f RH [%%]\n", + sensor_value_to_double(&temp), + sensor_value_to_double(&hum)); + + k_sleep(K_MSEC(5000)); + } + */ + + const struct device *lora_dev; + struct lorawan_join_config join_cfg; + uint8_t dev_eui[] = LORAWAN_DEV_EUI; + uint8_t join_eui[] = LORAWAN_JOIN_EUI; + uint8_t app_key[] = LORAWAN_APP_KEY; + int ret; + + struct lorawan_downlink_cb downlink_cb = { + .port = LW_RECV_PORT_ANY, + .cb = dl_callback + }; + + lora_dev = DEVICE_DT_GET(DT_ALIAS(lora0)); + if (!device_is_ready(lora_dev)) { + LOG_ERR("%s: device not ready.", lora_dev->name); + return 0; + } + + ret = lorawan_start(); + if (ret < 0) { + LOG_ERR("lorawan_start failed: %d", ret); + return 0; + } else { + LOG_INF("LoraWan started successfully"); + } + + lorawan_register_downlink_callback(&downlink_cb); + lorawan_register_dr_changed_callback(lorwan_datarate_changed); + + join_cfg.mode = LORAWAN_ACT_OTAA; + join_cfg.dev_eui = dev_eui; + join_cfg.otaa.join_eui = join_eui; + join_cfg.otaa.app_key = app_key; + join_cfg.otaa.nwk_key = app_key; + join_cfg.otaa.dev_nonce = 14u; + + // TODO: Repeat until success + LOG_INF("Joining network over OTAA"); + ret = lorawan_join(&join_cfg); + if (ret < 0) { + LOG_ERR("lorawan_join_network failed: %d", ret); + return 0; + } + + LOG_INF("Sending data..."); + while (1) { + ret = lorawan_send(2, data, sizeof(data), + LORAWAN_MSG_CONFIRMED); + + /* + * Note: The stack may return -EAGAIN if the provided data + * length exceeds the maximum possible one for the region and + * datarate. But since we are just sending the same data here, + * we'll just continue. + */ + if (ret == -EAGAIN) { + LOG_ERR("lorawan_send failed: %d. Continuing...", ret); + k_sleep(DELAY); + continue; + } + + if (ret < 0) { + LOG_ERR("lorawan_send failed: %d", ret); + k_sleep(DELAY); + continue; + } else { + LOG_INF("Data sent!"); + } + + k_sleep(DELAY); + } +} \ No newline at end of file diff --git a/test/README b/test/README new file mode 100644 index 0000000..9b1e87b --- /dev/null +++ b/test/README @@ -0,0 +1,11 @@ + +This directory is intended for PlatformIO Test Runner and project tests. + +Unit Testing is a software testing method by which individual units of +source code, sets of one or more MCU program modules together with associated +control data, usage procedures, and operating procedures, are tested to +determine whether they are fit for use. Unit testing finds problems early +in the development cycle. + +More information about PlatformIO Unit Testing: +- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt new file mode 100644 index 0000000..3de8eed --- /dev/null +++ b/zephyr/CMakeLists.txt @@ -0,0 +1,9 @@ +# Path to out-of-tree boards definitions +set (BOARD_ROOT "${CMAKE_CURRENT_SOURCE_DIR}") + +cmake_minimum_required(VERSION 3.13.1) +include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE) +project(embedded_raumsenor_lorawan) + +FILE(GLOB app_sources ../src/*.c*) +target_sources(app PRIVATE ${app_sources}) diff --git a/zephyr/boards/st/g2h_lorawan_heat_control/Kconfig.g2h_lorawan_heat_control b/zephyr/boards/st/g2h_lorawan_heat_control/Kconfig.g2h_lorawan_heat_control new file mode 100644 index 0000000..b330d59 --- /dev/null +++ b/zephyr/boards/st/g2h_lorawan_heat_control/Kconfig.g2h_lorawan_heat_control @@ -0,0 +1,5 @@ +# Copyright (c) 2020 STMicroelectronics +# SPDX-License-Identifier: Apache-2.0 + +config BOARD_G2H_LORAWAN_HEAT_CONTROL + select SOC_STM32WL55XX diff --git a/zephyr/boards/st/g2h_lorawan_heat_control/arduino_r3_connector.dtsi b/zephyr/boards/st/g2h_lorawan_heat_control/arduino_r3_connector.dtsi new file mode 100644 index 0000000..93c9694 --- /dev/null +++ b/zephyr/boards/st/g2h_lorawan_heat_control/arduino_r3_connector.dtsi @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2020 STMicroelectronics + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/ { + arduino_header: connector { + compatible = "arduino-header-r3"; + #gpio-cells = <2>; + gpio-map-mask = <0xffffffff 0xffffffc0>; + gpio-map-pass-thru = <0 0x3f>; + gpio-map = <0 0 &gpiob 1 0>, /* A0 */ + <1 0 &gpiob 2 0>, /* A1 */ + <2 0 &gpioa 10 0>, /* A2 */ + <3 0 &gpiob 4 0>, /* A3 */ + <4 0 &gpiob 14 0>, /* A4 */ + <5 0 &gpiob 13 0>, /* A5 */ + <6 0 &gpiob 7 0>, /* D0 */ + <7 0 &gpiob 6 0>, /* D1 */ + <8 0 &gpiob 12 0>, /* D2 */ + <9 0 &gpiob 3 0>, /* D3 */ + <10 0 &gpiob 5 0>, /* D4 */ + <11 0 &gpiob 8 0>, /* D5 */ + <12 0 &gpiob 10 0>, /* D6 */ + <13 0 &gpioc 1 0>, /* D7 */ + <14 0 &gpioc 2 0>, /* D8 */ + <15 0 &gpioa 9 0>, /* D9 */ + <16 0 &gpioa 4 0>, /* D10 */ + <17 0 &gpioa 7 0>, /* D11 */ + <18 0 &gpioa 6 0>, /* D12 */ + <19 0 &gpioa 5 0>, /* D13 */ + <20 0 &gpiob 11 0>, /* D14 */ + <21 0 &gpiob 12 0>; /* D15 */ + }; +}; + +arduino_serial: &usart1 {}; +arduino_i2c: &i2c2 {}; +arduino_spi: &spi1 {}; diff --git a/zephyr/boards/st/g2h_lorawan_heat_control/board.cmake b/zephyr/boards/st/g2h_lorawan_heat_control/board.cmake new file mode 100644 index 0000000..716846e --- /dev/null +++ b/zephyr/boards/st/g2h_lorawan_heat_control/board.cmake @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: Apache-2.0 + +# keep first +board_runner_args(stm32cubeprogrammer "--port=swd" "--reset-mode=hw") + +# keep first +include(${ZEPHYR_BASE}/boards/common/stm32cubeprogrammer.board.cmake) +include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake) diff --git a/zephyr/boards/st/g2h_lorawan_heat_control/board.yml b/zephyr/boards/st/g2h_lorawan_heat_control/board.yml new file mode 100644 index 0000000..d2d5e3a --- /dev/null +++ b/zephyr/boards/st/g2h_lorawan_heat_control/board.yml @@ -0,0 +1,6 @@ +board: + name: g2h_lorawan_heat_control + full_name: G2H LoraWAN Heat Control + vendor: st + socs: + - name: stm32wl55xx diff --git a/zephyr/boards/st/g2h_lorawan_heat_control/g2h_lorawan_heat_control.dts b/zephyr/boards/st/g2h_lorawan_heat_control/g2h_lorawan_heat_control.dts new file mode 100644 index 0000000..ae3d54e --- /dev/null +++ b/zephyr/boards/st/g2h_lorawan_heat_control/g2h_lorawan_heat_control.dts @@ -0,0 +1,211 @@ +/* + * Copyright (c) 2020-2024 STMicroelectronics + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; +#include +#include +#include "arduino_r3_connector.dtsi" +#include "st_morpho_connector.dtsi" +#include + +/ { + model = "G2H LoraWAN Heat control based on STM32WL55JC-NUCLEO"; + compatible = "st,stm32wl55-nucleo,g2h_lorawan_heat_control"; + + chosen { + zephyr,console = &lpuart1; + zephyr,shell-uart = &lpuart1; + zephyr,sram = &sram0; + zephyr,flash = &flash0; + zephyr,code-partition = &slot0_partition; + }; + + aliases { + lora0 = &lora; + watchdog0 = &iwdg; + die-temp0 = &die_temp; + }; +}; + +&clk_lsi { + status = "okay"; +}; + +stm32_lp_tick_source: &lptim1 { + clocks = <&rcc STM32_CLOCK_BUS_APB1 0x80000000>, + <&rcc STM32_SRC_LSI LPTIM1_SEL(1)>; + status = "okay"; +}; + +&clk_hsi { + status = "okay"; +}; + +&clk_lse { + status = "okay"; +}; + +&pll { + div-m = <1>; + mul-n = <6>; + div-r = <2>; + div-q = <2>; + clocks = <&clk_hsi>; + status = "okay"; +}; + +&rcc { + clocks = <&pll>; + clock-frequency = ; + cpu1-prescaler = <1>; + cpu2-prescaler = <1>; + ahb3-prescaler = <1>; + apb1-prescaler = <1>; + apb2-prescaler = <1>; +}; + +&lpuart1 { + pinctrl-0 = <&lpuart1_tx_pa2 &lpuart1_rx_pa3>; + pinctrl-names = "default"; + current-speed = <115200>; + status = "okay"; +}; + +&i2c1 { + status = "okay"; + pinctrl-0 = <&i2c1_scl_pa9 &i2c1_sda_pa10>; + pinctrl-names = "default"; + status = "okay"; + clock-frequency = ; + + sht4x: sht4x@44 { + status = "okay"; + compatible = "sensirion,sht4x"; + label = "SHT4X Integrated Temp Sensor"; + reg = <0x44>; + repeatability = <2>; + }; + + mlx90614: mlx90614@5A { + status = "okay"; + compatible = "melexis,mlx90614"; + label = "MLX90614 Infrared Temp Sensor"; + reg = <0x5A>; + }; + +}; + +&spi1 { + pinctrl-0 = <&spi1_nss_pa4 &spi1_sck_pa5 + &spi1_miso_pa6 &spi1_mosi_pa7>; + pinctrl-names = "default"; + status = "okay"; +}; + + +&dac1 { + pinctrl-0 = <&dac_out1_pa10>; + pinctrl-names = "default"; + status = "okay"; +}; + +&timers2 { + status = "okay"; + pwm2: pwm { + status = "okay"; + pinctrl-0 = <&tim2_ch4_pb11>; + pinctrl-names = "default"; + }; +}; + + +&adc1 { + pinctrl-0 = <&adc_in5_pb1 &adc_in0_pb13>; + pinctrl-names = "default"; + st,adc-clock-source = "SYNC"; + st,adc-prescaler = <4>; + status = "okay"; +}; + +&die_temp { + status = "okay"; +}; + +&aes { + status = "okay"; +}; + +&rng { + status = "okay"; +}; + +&iwdg { + status = "okay"; +}; + +&subghzspi { + status = "okay"; + lora: radio@0 { + status = "okay"; + tx-enable-gpios = <&gpioc 4 GPIO_ACTIVE_LOW>; /* FE_CTRL1 */ + rx-enable-gpios = <&gpioc 5 GPIO_ACTIVE_LOW>; /* FE_CTRL2 */ + dio3-tcxo-voltage = ; + tcxo-power-startup-delay-ms = <5>; + /* High-power output is selected as a consequence of using + * tx/rx-enable-gpio to control FE_CTRL1 and FE_CTRL2. Low-power + * output would require both FE_CTRL1 and FE_CTRL2 to be high, + * which is not currently supported by the driver. + */ + power-amplifier-output = "rfo-hp"; + rfo-lp-max-power = <15>; + rfo-hp-max-power = <22>; + }; +}; + +&flash0 { + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + boot_partition: partition@0 { + label = "mcuboot"; + reg = <0x00000000 DT_SIZE_K(32)>; + read-only; + }; + slot0_partition: partition@8000 { + label = "image-0"; + reg = <0x00008000 DT_SIZE_K(104)>; + }; + slot1_partition: partition@22000 { + label = "image-1"; + reg = <0x00022000 DT_SIZE_K(104)>; + }; + + /* + * Set 16kB of storage (8x2kB pages) at the end of the 256kB of + * flash. + */ + storage_partition: partition@3c000 { + label = "storage"; + reg = <0x0003c000 DT_SIZE_K(16)>; + }; + }; +}; + +&rtc { + clocks = <&rcc STM32_CLOCK_BUS_APB1 0x00000400>, + <&rcc STM32_SRC_LSE RTC_SEL(1)>; + status = "okay"; +}; + +&vref { + status = "okay"; +}; + +&vbat { + status = "okay"; +}; diff --git a/zephyr/boards/st/g2h_lorawan_heat_control/g2h_lorawan_heat_control.yaml b/zephyr/boards/st/g2h_lorawan_heat_control/g2h_lorawan_heat_control.yaml new file mode 100644 index 0000000..350f6ac --- /dev/null +++ b/zephyr/boards/st/g2h_lorawan_heat_control/g2h_lorawan_heat_control.yaml @@ -0,0 +1,26 @@ +identifier: g2h_lorawan_heat_control +name: G2H LoraWAN Heat Control +type: mcu +arch: arm +toolchain: + - zephyr + - gnuarmemb +ram: 64 +flash: 256 +supported: + - gpio + - i2c + - spi + - arduino_gpio + - arduino_i2c + - arduino_spi + - adc + - dac + - pwm + - counter + - dma + - watchdog + - nvs + - lora + - rtc +vendor: st diff --git a/zephyr/boards/st/g2h_lorawan_heat_control/g2h_lorawan_heat_control_defconfig b/zephyr/boards/st/g2h_lorawan_heat_control/g2h_lorawan_heat_control_defconfig new file mode 100644 index 0000000..8b09bb0 --- /dev/null +++ b/zephyr/boards/st/g2h_lorawan_heat_control/g2h_lorawan_heat_control_defconfig @@ -0,0 +1,15 @@ +# enable uart driver +CONFIG_SERIAL=y + +# enable GPIO +CONFIG_GPIO=y + +# console +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y + +# Enable MPU +CONFIG_ARM_MPU=y + +# Enable HW stack protection +CONFIG_HW_STACK_PROTECTION=y diff --git a/zephyr/boards/st/g2h_lorawan_heat_control/st_morpho_connector.dtsi b/zephyr/boards/st/g2h_lorawan_heat_control/st_morpho_connector.dtsi new file mode 100644 index 0000000..c2e2a06 --- /dev/null +++ b/zephyr/boards/st/g2h_lorawan_heat_control/st_morpho_connector.dtsi @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2023 Marcin Niestroj + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include + +/ { + st_morpho_header: st-morpho-header { + compatible = "st-morpho-header"; + #gpio-cells = <2>; + gpio-map-mask = ; + gpio-map-pass-thru = <0x0 GPIO_DT_FLAGS_MASK>; + gpio-map = , + , /* shared with SWD connected to STLINK */ + , /* shared with SWD connected to STLINK */ + , + , + , + , + , + , + , + , + , + , + + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , /* SB7=ON, SB2=OFF, SB6=OFF */ + , + , /* SB9=ON, SB4=OFF, SB10=OFF */ + ; + }; +}; diff --git a/zephyr/boards/st/g2h_lorawan_heat_control/support/openocd.cfg b/zephyr/boards/st/g2h_lorawan_heat_control/support/openocd.cfg new file mode 100644 index 0000000..9d7fe81 --- /dev/null +++ b/zephyr/boards/st/g2h_lorawan_heat_control/support/openocd.cfg @@ -0,0 +1,11 @@ +source [find interface/stlink.cfg] + +transport select hla_swd + +source [find target/stm32wlx.cfg] + +# Debug compatible reset configuration (default) +reset_config srst_only srst_nogate + +# Sleep mode compatible reset configuration (stock firmware compatible) +# reset_config srst_only srst_nogate connect_assert_srst diff --git a/zephyr/prj.conf b/zephyr/prj.conf new file mode 100644 index 0000000..77c880e --- /dev/null +++ b/zephyr/prj.conf @@ -0,0 +1,12 @@ +CONFIG_LOG=y +CONFIG_SENSOR=y +CONFIG_I2C=y +CONFIG_SHT4X=y +CONFIG_LORA=y +CONFIG_LORAWAN=y +CONFIG_LORAMAC_REGION_EU868=y +CONFIG_MAIN_STACK_SIZE=2048 +CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048 +CONFIG_LOG_DEFAULT_LEVEL=3 +CONFIG_NEWLIB_LIBC=y +CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y \ No newline at end of file