From ebc2b4d9eccf2e3ffacf5ce09dbda2b61ce293a1 Mon Sep 17 00:00:00 2001 From: Zoltan Havas Date: Fri, 15 Dec 2023 16:36:42 +0100 Subject: [PATCH] modules: hal_silabs: Add Proprietary TRX example Add Proprietary TRX example to show SiliconLabs radio board capabilities. Signed-off-by: Zoltan Havas --- examples/License.txt | 26 ++ examples/proprietary_trx/CMakeLists.txt | 22 ++ examples/proprietary_trx/README.rst | 114 ++++++ .../boards/efr32bg22_brd4184a.overlay | 8 + .../boards/efr32bg22_brd4184b.overlay | 8 + .../boards/efr32mg22_brd4182a.overlay | 8 + .../boards/efr32xg24_dk2601b.overlay | 8 + examples/proprietary_trx/prj.conf | 15 + .../prj_efr32xg24_dk2601b.conf | 14 + examples/proprietary_trx/src/app_cli.c | 84 ++++ examples/proprietary_trx/src/app_gpio.c | 186 +++++++++ examples/proprietary_trx/src/app_gpio.h | 71 ++++ examples/proprietary_trx/src/app_rail.c | 310 +++++++++++++++ examples/proprietary_trx/src/app_rail.h | 88 +++++ .../src/autogen/sl_rail_util_callbacks.c | 117 ++++++ .../src/autogen/sl_rail_util_init.c | 233 +++++++++++ .../src/autogen/sl_rail_util_init.h | 222 +++++++++++ .../radio_settings.radioconf | 18 + .../rail/efr32bg22_brd4184a/rail_config.c | 333 ++++++++++++++++ .../rail/efr32bg22_brd4184a/rail_config.h | 52 +++ .../radio_settings.radioconf | 18 + .../rail/efr32bg22_brd4184b/rail_config.c | 333 ++++++++++++++++ .../rail/efr32bg22_brd4184b/rail_config.h | 52 +++ .../radio_settings.radioconf | 18 + .../rail/efr32bg27_brd2602a/rail_config.c | 291 ++++++++++++++ .../rail/efr32bg27_brd2602a/rail_config.h | 50 +++ .../radio_settings.radioconf | 18 + .../rail/efr32xg24_dk2601b/rail_config.c | 366 ++++++++++++++++++ .../rail/efr32xg24_dk2601b/rail_config.h | 52 +++ examples/proprietary_trx/src/main.c | 203 ++++++++++ examples/proprietary_trx/src/main.h | 76 ++++ 31 files changed, 3414 insertions(+) create mode 100644 examples/License.txt create mode 100644 examples/proprietary_trx/CMakeLists.txt create mode 100644 examples/proprietary_trx/README.rst create mode 100644 examples/proprietary_trx/boards/efr32bg22_brd4184a.overlay create mode 100644 examples/proprietary_trx/boards/efr32bg22_brd4184b.overlay create mode 100644 examples/proprietary_trx/boards/efr32mg22_brd4182a.overlay create mode 100644 examples/proprietary_trx/boards/efr32xg24_dk2601b.overlay create mode 100644 examples/proprietary_trx/prj.conf create mode 100644 examples/proprietary_trx/prj_efr32xg24_dk2601b.conf create mode 100644 examples/proprietary_trx/src/app_cli.c create mode 100644 examples/proprietary_trx/src/app_gpio.c create mode 100644 examples/proprietary_trx/src/app_gpio.h create mode 100644 examples/proprietary_trx/src/app_rail.c create mode 100644 examples/proprietary_trx/src/app_rail.h create mode 100644 examples/proprietary_trx/src/autogen/sl_rail_util_callbacks.c create mode 100644 examples/proprietary_trx/src/autogen/sl_rail_util_init.c create mode 100644 examples/proprietary_trx/src/autogen/sl_rail_util_init.h create mode 100644 examples/proprietary_trx/src/config/rail/efr32bg22_brd4184a/radio_settings.radioconf create mode 100644 examples/proprietary_trx/src/config/rail/efr32bg22_brd4184a/rail_config.c create mode 100644 examples/proprietary_trx/src/config/rail/efr32bg22_brd4184a/rail_config.h create mode 100644 examples/proprietary_trx/src/config/rail/efr32bg22_brd4184b/radio_settings.radioconf create mode 100644 examples/proprietary_trx/src/config/rail/efr32bg22_brd4184b/rail_config.c create mode 100644 examples/proprietary_trx/src/config/rail/efr32bg22_brd4184b/rail_config.h create mode 100644 examples/proprietary_trx/src/config/rail/efr32bg27_brd2602a/radio_settings.radioconf create mode 100644 examples/proprietary_trx/src/config/rail/efr32bg27_brd2602a/rail_config.c create mode 100644 examples/proprietary_trx/src/config/rail/efr32bg27_brd2602a/rail_config.h create mode 100644 examples/proprietary_trx/src/config/rail/efr32xg24_dk2601b/radio_settings.radioconf create mode 100644 examples/proprietary_trx/src/config/rail/efr32xg24_dk2601b/rail_config.c create mode 100644 examples/proprietary_trx/src/config/rail/efr32xg24_dk2601b/rail_config.h create mode 100644 examples/proprietary_trx/src/main.c create mode 100644 examples/proprietary_trx/src/main.h diff --git a/examples/License.txt b/examples/License.txt new file mode 100644 index 00000000..b01dd586 --- /dev/null +++ b/examples/License.txt @@ -0,0 +1,26 @@ +# Example Licensing terms + +Source code in this example folder is covered by one of several different +licenses. The default license is the Zlib which applies unless otherwise noted. + +Some files may use different licensing terms. If so, they will be clearly +marked in the beginning of the file. + +## Zlib license +The licensor of this software is Silicon Laboratories Inc. + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. diff --git a/examples/proprietary_trx/CMakeLists.txt b/examples/proprietary_trx/CMakeLists.txt new file mode 100644 index 00000000..e41c3c5d --- /dev/null +++ b/examples/proprietary_trx/CMakeLists.txt @@ -0,0 +1,22 @@ +# Copyright (c) 2023 Silicon Laboratories Inc. +# SPDX-License-Identifier: Zlib + +cmake_minimum_required(VERSION 3.20.0) +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) +project(propriatery_trx) + +target_include_directories(app PRIVATE + src/ + src/autogen/ + src/config/ + src/config/rail + src/config/rail/${CONFIG_BOARD} +) + +target_sources(app PRIVATE src/main.c) +target_sources(app PRIVATE src/app_gpio.c) +target_sources(app PRIVATE src/app_cli.c) +target_sources(app PRIVATE src/app_rail.c) +target_sources(app PRIVATE src/autogen/sl_rail_util_callbacks.c) +target_sources(app PRIVATE src/autogen/sl_rail_util_init.c) +target_sources(app PRIVATE src/config/rail/${CONFIG_BOARD}/rail_config.c) diff --git a/examples/proprietary_trx/README.rst b/examples/proprietary_trx/README.rst new file mode 100644 index 00000000..fb2f310d --- /dev/null +++ b/examples/proprietary_trx/README.rst @@ -0,0 +1,114 @@ +Proprietary TRX +############### + +Overview +******** + +The Proprietary TRX example demonstrates the simplest exchange of transmit and +receive operation between two nodes implemented in RAIL. + +This application can be used for setting up a simple link test, where the nodes +are listening except for the short periods where packet transmission takes +place. Also, this application can be used as a learning material. + +Requirements +************ + +This application requires part or board that support RAIL, has radio antenna +connection and has at least one LED and one button. + +Building and Running +******************** + +This sample can be built for multiple boards, in this example we will build it +for the efr32bg22_brd4184a board: + +.. code-block:: bash + + west build -p always -b efr32bg22_brd4184a + + +This example implements both the receiver (RX) and the transmitter (TX) nodes. +The implementation is therefore symmetric, as both nodes are capable of sending +and receiving messages. In this document the use of `RX node` and `TX node` are +implicit and these terms refer the devices temporary, while the denoted +operations are performed. + +Compile the project and download the application to two radio boards. + +On startup the Zephyr boot will be displayed, with additional information +about the RAIL library version. + +The devices start in the receiving state. + +Issue the `send` command on the TX node to request packet transmission: + +.. code-block:: bash + + send + > Send packet request + +Additional logs can be viewed by the logger, which can be turned off. + +On the receiver side the following response will be printed out on packet +reception: + +.. code-block:: bash + + > Packet has been received: 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, + 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF, + +Additional logs can be viewed by the logger, which can be turned off. + +If the reception is enabled the device will automatically switch back to RX mode +either after a successful or faulty reception or a transmission. + + +The reception can be disabled by the `receive` command. + +.. code-block:: bash + + receive 0 + > Continues packet receiving is OFF + +Receive mode can be enabled again by the same command: + +.. code-block:: bash + + receive 1 + > Continues packet receiving is ON + + +Peripherals +*********** + +Same working can be achieved by pushing button or buttons and waiting for the +led or LEDs to toggle. + +Radio settings +************** + +For changing any settings for the used radio or radio phy please re-generate +the rail_config.c and rail_config.h files use +Simplicity Studio's `EFR32 Radio Configurator`_. + +.. _EFR32 Radio Configurator: https://www.silabs.com/documents/public/application-notes/an1253-efr32-radio-configurator-guide-for-ssv5.pdf + +Advance settings +**************** + +For advance user settings please use Simplicity Studio's slc generator, where +more settings can be generated for rail components. If new settings are ready, +they should be copied from Simplicity Studio config folder to `hal/silabs/gecko` +folder and overwrite their original file. For example after editing with slc +the RAIL Utility component user should copy `sl_rail_util_init_inst0_config.h`` +to `gecko/platform/radio/rail_lib/plugin/rail_util_init/config/proprietary/`` + +Extra Resources +*************** + +- `RAIL Tutorial Series`_: + it is advised to read through the `Studio v5 series` first to familiarize the + basics of packet transmission and reception + +.. _RAIL Tutorial Series: https://community.silabs.com/s/article/rail-tutorial-series?language=en_US diff --git a/examples/proprietary_trx/boards/efr32bg22_brd4184a.overlay b/examples/proprietary_trx/boards/efr32bg22_brd4184a.overlay new file mode 100644 index 00000000..f559013a --- /dev/null +++ b/examples/proprietary_trx/boards/efr32bg22_brd4184a.overlay @@ -0,0 +1,8 @@ +/* + * Copyright (c) 2023 Silicon Laboratories Inc. + * SPDX-License-Identifier: Zlib + */ + +&cpu0 { + cpu-power-states = <&pstate_em1>; +}; diff --git a/examples/proprietary_trx/boards/efr32bg22_brd4184b.overlay b/examples/proprietary_trx/boards/efr32bg22_brd4184b.overlay new file mode 100644 index 00000000..f559013a --- /dev/null +++ b/examples/proprietary_trx/boards/efr32bg22_brd4184b.overlay @@ -0,0 +1,8 @@ +/* + * Copyright (c) 2023 Silicon Laboratories Inc. + * SPDX-License-Identifier: Zlib + */ + +&cpu0 { + cpu-power-states = <&pstate_em1>; +}; diff --git a/examples/proprietary_trx/boards/efr32mg22_brd4182a.overlay b/examples/proprietary_trx/boards/efr32mg22_brd4182a.overlay new file mode 100644 index 00000000..f559013a --- /dev/null +++ b/examples/proprietary_trx/boards/efr32mg22_brd4182a.overlay @@ -0,0 +1,8 @@ +/* + * Copyright (c) 2023 Silicon Laboratories Inc. + * SPDX-License-Identifier: Zlib + */ + +&cpu0 { + cpu-power-states = <&pstate_em1>; +}; diff --git a/examples/proprietary_trx/boards/efr32xg24_dk2601b.overlay b/examples/proprietary_trx/boards/efr32xg24_dk2601b.overlay new file mode 100644 index 00000000..c3a2bc50 --- /dev/null +++ b/examples/proprietary_trx/boards/efr32xg24_dk2601b.overlay @@ -0,0 +1,8 @@ +/* + * Copyright (c) 2023 Silicon Laboratories Inc. + * SPDX-License-Identifier: Zlib + */ + +&cpu0 { + cpu-power-states = <&pstate_em0>; +}; diff --git a/examples/proprietary_trx/prj.conf b/examples/proprietary_trx/prj.conf new file mode 100644 index 00000000..feb2f58c --- /dev/null +++ b/examples/proprietary_trx/prj.conf @@ -0,0 +1,15 @@ +# Copyright (c) 2024 Silicon Laboratories Inc. +# SPDX-License-Identifier: Zlib +CONFIG_GPIO=y +CONFIG_SOC_GECKO_CUSTOM_RADIO_PHY=y +CONFIG_FPU=y +CONFIG_PM=y +CONFIG_PRINTK=y +CONFIG_LOG=y +CONFIG_SHELL=y +CONFIG_EVENTS=y +CONFIG_ASSERT=y +CONFIG_BOOT_BANNER=y +CONFIG_POSIX_CLOCK=y +CONFIG_INIT_STACKS=y +CONFIG_SMF=y diff --git a/examples/proprietary_trx/prj_efr32xg24_dk2601b.conf b/examples/proprietary_trx/prj_efr32xg24_dk2601b.conf new file mode 100644 index 00000000..d917ab8b --- /dev/null +++ b/examples/proprietary_trx/prj_efr32xg24_dk2601b.conf @@ -0,0 +1,14 @@ +# Copyright (c) 2023 Silicon Laboratories Inc. +# SPDX-License-Identifier: Zlib +CONFIG_GPIO=y +CONFIG_SOC_GECKO_CUSTOM_RADIO_PHY=y +CONFIG_FPU=y +CONFIG_PRINTK=y +CONFIG_LOG=y +CONFIG_SHELL=y +CONFIG_EVENTS=y +CONFIG_ASSERT=y +CONFIG_BOOT_BANNER=y +CONFIG_POSIX_CLOCK=y +CONFIG_INIT_STACKS=y +CONFIG_SMF=y diff --git a/examples/proprietary_trx/src/app_cli.c b/examples/proprietary_trx/src/app_cli.c new file mode 100644 index 00000000..a7308805 --- /dev/null +++ b/examples/proprietary_trx/src/app_cli.c @@ -0,0 +1,84 @@ +/***************************************************************************//** + * @file app_cli.c + * @brief CLI commands for the proprietary_trx example. + ******************************************************************************* + * # License + * Copyright 2024 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +// ----------------------------------------------------------------------------- +// Includes + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "em_chip.h" +#include "main.h" + +// ----------------------------------------------------------------------------- +// Public Function Definitions + +/****************************************************************************** + * CLI - send: Sets a flag indicating that a packet has to be sent + *****************************************************************************/ +void cli_send_packet(const struct shell *sh, size_t argc, char **argv) +{ + shell_fprintf(sh, SHELL_NORMAL, "Send packet request\n"); + k_event_post(&s_sl_machine.smf_event, EVENT_REQUEST_SEND); +} + +/****************************************************************************** + * CLI - info message: Unique ID of the board + *****************************************************************************/ +void cli_info(const struct shell *sh, size_t argc, char **argv) +{ + shell_fprintf(sh, SHELL_NORMAL, "Info:\n"); + shell_fprintf(sh, SHELL_NORMAL, " MCU Id: 0x%llx\n", SYSTEM_GetUnique()); +} + +/****************************************************************************** + * CLI - receive: Turn on/off continues packet receiving + *****************************************************************************/ +void cli_receive_packet(const struct shell *sh, size_t argc, char **argv) +{ + unsigned long continues_receive = strtoul(argv[1], NULL, 0); + s_sl_machine.allow_rx = continues_receive; + shell_fprintf(sh, SHELL_NORMAL, "Continues packet receiving is %s\n", + (continues_receive == 0) ? "OFF" : "ON"); + k_event_post(&s_sl_machine.smf_event, EVENT_CLI_RECEIVE_SETTING); +} + +SHELL_CMD_ARG_REGISTER(info, NULL, "Display unique ID of the MCU", cli_info, 1, 0); + +SHELL_CMD_ARG_REGISTER(send, NULL, "Send a packet", cli_send_packet, 1, 0); + +SHELL_CMD_ARG_REGISTER(receive, NULL, "Turn ON/OFF continues packet receiving", cli_receive_packet, + 2, 0); diff --git a/examples/proprietary_trx/src/app_gpio.c b/examples/proprietary_trx/src/app_gpio.c new file mode 100644 index 00000000..882f7924 --- /dev/null +++ b/examples/proprietary_trx/src/app_gpio.c @@ -0,0 +1,186 @@ +/***************************************************************************//** + * @file app_gpio.c + * @brief GPIO handling for the proprietary_trx example. + ******************************************************************************* + * # License + * Copyright 2024 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +// ----------------------------------------------------------------------------- +// Includes + +#include +#include +#include +#include +#include +#include +#include +#include +#include "errno.h" +#include "app_gpio.h" + +// ----------------------------------------------------------------------------- +// Macros and Typedefs + +LOG_MODULE_DECLARE(trx_app_log); + +// ----------------------------------------------------------------------------- +// Static Function Declarations + +// Callback function to handle button press for sending a packet +static void button_pressed(const struct device *dev, struct gpio_callback *cb, uint32_t pins); + +// Initialize given button to use button_press callback +static int init_button(const struct gpio_dt_spec *button); + +static int init_led(const struct gpio_dt_spec *led); + +// ----------------------------------------------------------------------------- +// Global Variables + +// ----------------------------------------------------------------------------- +// Static Variables + +// ----------------------------------------------------------------------------- +// Public Function Definitions + +int app_init_gpios(struct s_prop_var *s_state) +{ + BUILD_ASSERT(DT_NODE_HAS_STATUS(DT_ALIAS(sw0), okay), + "Unsupported board: sw0 devicetree alias is not defined"); + BUILD_ASSERT(DT_NODE_HAS_STATUS(DT_ALIAS(led0), okay), + "Unsupported board: led0 devicetree alias is not defined"); + + int ret = 0; + ret = init_button(&s_state->button0); + if (ret) { + return ret; + } + if (DT_NODE_HAS_STATUS(DT_ALIAS(sw1), okay)) { + ret = init_button(&s_state->button1); + if (ret) { + return ret; + } + } + + ret = init_led(&s_state->led0); + if (ret) { + return ret; + } + + if (DT_NODE_HAS_STATUS(DT_ALIAS(led1), okay)) { + ret = init_led(&s_state->led1); + if (ret) { + return ret; + } + } + + return ret; +} + +void app_update_receive_led(struct s_prop_var *s_state) +{ + int ret = 0; + ret = gpio_pin_toggle_dt(&(s_state->led0)); + if (ret) { + LOG_WRN("Led toggle for led0 returned with %d", ret); + } +} + +void app_update_send_led(struct s_prop_var *s_state) +{ + int ret = 0; + if (DT_NODE_HAS_STATUS(DT_ALIAS(led1), okay)) { + ret = gpio_pin_toggle_dt(&s_state->led1); + if (ret) { + LOG_WRN("Led toggle for led1 returned with %d", ret); + } + } else { + ret = gpio_pin_toggle_dt(&s_state->led0); + if (ret) { + LOG_WRN("Led toggle for led0 returned with %d", ret); + } + } +} +// ----------------------------------------------------------------------------- +// Static Function Definitions + +static void button_pressed(const struct device *dev, struct gpio_callback *cb, uint32_t pins) +{ + struct s_prop_var *context = CONTAINER_OF(cb, struct s_prop_var, button_cb_data); + k_event_post(&context->smf_event, EVENT_REQUEST_SEND); +} + +static int init_button(const struct gpio_dt_spec *button) +{ + int ret = 0; + if (!gpio_is_ready_dt(button)) { + LOG_ERR("Error: button device %s is not ready", button->port->name); + return -EINVAL; + } + + ret = gpio_pin_configure_dt(button, GPIO_INPUT); + if (ret) { + LOG_ERR("Error %d: failed to configure %s pin %d", ret, button->port->name, + button->pin); + return ret; + } + + ret = gpio_pin_interrupt_configure_dt(button, GPIO_INT_EDGE_TO_ACTIVE); + if (ret) { + LOG_ERR("Error %d: failed to configure interrupt on %s pin %d", ret, + button->port->name, button->pin); + return ret; + } + + gpio_init_callback(&s_sl_machine.button_cb_data, button_pressed, BIT(button->pin)); + gpio_add_callback(button->port, &s_sl_machine.button_cb_data); + + return 0; +} + +static int init_led(const struct gpio_dt_spec *led) +{ + int ret = 0; + if (led->port && !gpio_is_ready_dt(led)) { + LOG_ERR("LED device %s is not ready; ignoring it", led->port->name); + return -EINVAL; + } + + ret = gpio_pin_configure_dt(led, GPIO_OUTPUT); + if (ret) { + LOG_ERR("Error %d: failed to configure LED device %s pin %d", ret, led->port->name, + led->pin); + return ret; + } + + ret = gpio_pin_set_dt(led, 0); + if (ret) { + LOG_WRN("Led clear for %s returned with %d", led->port->name, ret); + } + + return 0; +} diff --git a/examples/proprietary_trx/src/app_gpio.h b/examples/proprietary_trx/src/app_gpio.h new file mode 100644 index 00000000..5614144b --- /dev/null +++ b/examples/proprietary_trx/src/app_gpio.h @@ -0,0 +1,71 @@ +/***************************************************************************//** + * @file app_gpio.h + * @brief GPIO handling for the proprietary_trx example. + ******************************************************************************* + * # License + * Copyright 2024 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef APP_GPIO_H +#define APP_GPIO_H + +#include "main.h" + +// ----------------------------------------------------------------------------- +// Public Function Declarations + +/** + * @brief Initialize GPIOs for the application. + * + * Initializes the GPIOs used by the application. + * One or two buttons, one is mandatory because of sending. + * One or two leds, for showing the send, receive packets. + * + * @param s_state pointer to the state machine for the led variables + * + * @return uint8_t The initialization status. 0 indicates success, and non-zero + * values indicate an error. + */ +int app_init_gpios(struct s_prop_var *s_state); + +/** + * @brief Update the receive LED status. + * + * @param s_state pointer to the state machine for the led variables + * + * Updates the status of the receive LED based on the application requirements. + */ +void app_update_receive_led(struct s_prop_var *s_state); + +/** + * @brief Update the send LED status. + * + * @param s_state pointer to the state machine for the led variables + * + * Updates the status of the send LED based on the application requirements. + */ +void app_update_send_led(struct s_prop_var *s_state); + +#endif /*APP_GPIO_H*/ diff --git a/examples/proprietary_trx/src/app_rail.c b/examples/proprietary_trx/src/app_rail.c new file mode 100644 index 00000000..867e4653 --- /dev/null +++ b/examples/proprietary_trx/src/app_rail.c @@ -0,0 +1,310 @@ +/***************************************************************************//** + * @file app_rail.c + * @brief RAIL handling for the proprietary_trx example. + ******************************************************************************* + * # License + * Copyright 2024 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +// ----------------------------------------------------------------------------- +// Includes + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "rail.h" +#include "rail_types.h" +#include "pa_conversions_efr32.h" +#include "sl_rail_util_init.h" +#include "app_rail.h" +#include "main.h" + +// ----------------------------------------------------------------------------- +// Macros and Typedefs + +LOG_MODULE_DECLARE(trx_app_log); + +// Generated radio protocol phy have multiply channels to cover the RF band from +// start to end with selected channel spacing, RAIL need to know which is the +// active channel to send/receive, range is from radio_config.c +// from channelNumberStart to channelNumberEnd +#define CHANNEL 0U + +// ----------------------------------------------------------------------------- +// Static Function Declarations + +static void set_up_tx_fifo(RAIL_Handle_t rail_handle); + +static void prepare_package(RAIL_Handle_t rail_handle, uint8_t *out_data, uint16_t length); + +static uint16_t unpack_packet(uint8_t *rx_destination, + const RAIL_RxPacketInfo_t *packet_information, + uint8_t **start_of_payload); + +// Install RAIL interrupt service routines (ISRs) +static void rail_isr_installer(void); + +// ----------------------------------------------------------------------------- +// Global Variables + +// ----------------------------------------------------------------------------- +// Static Variables + +// ----------------------------------------------------------------------------- +// Public Function Definitions + +void handle_send(bool *packet_sent) +{ + // Default payload packet content + static uint8_t out_packet[16] = { + 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, + 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF, + }; + RAIL_Handle_t rail_handle = sl_rail_util_get_handle(SL_RAIL_UTIL_HANDLE_INST0); + if (*packet_sent) { + prepare_package(rail_handle, out_packet, sizeof(out_packet)); + LOG_INF("Packet prepared"); + RAIL_StartTx(rail_handle, CHANNEL, RAIL_TX_OPTIONS_DEFAULT, NULL); + LOG_INF("Packet is being sent"); + *packet_sent = false; + } else { + LOG_WRN("Sending is in progress"); + } +} + +void handle_sent(bool *packet_sent) +{ + *packet_sent = true; + LOG_INF("Packet successfully sent"); +} + +void handle_error(uint64_t *error_code) +{ + LOG_ERR("Radio Error occurred\nEvents: %llX", *error_code); + *error_code = 0; +} + +void set_continuous_rx(bool enable_continuous_rx) +{ + RAIL_Status_t status; + RAIL_RadioState_t selected_state = RAIL_RF_STATE_IDLE; + RAIL_StateTransitions_t tx_transitions; + RAIL_StateTransitions_t rx_transitions; + RAIL_Handle_t rail_handle = sl_rail_util_get_handle(SL_RAIL_UTIL_HANDLE_INST0); + + if (enable_continuous_rx) { + selected_state = RAIL_RF_STATE_RX; + } + + tx_transitions.success = selected_state; + tx_transitions.error = selected_state; + rx_transitions.success = selected_state; + rx_transitions.error = selected_state; + + status = RAIL_SetTxTransitions(rail_handle, &tx_transitions); + if (status) { + LOG_ERR("RAIL_SetTxTransitions failed, return value: %d", status); + } else { + LOG_INF("RAIL_SetTxTransitions success"); + } + + status = RAIL_SetRxTransitions(rail_handle, &rx_transitions); + + if (status) { + LOG_ERR("RAIL_SetRxTransitions failed, return value: %d", status); + } else { + LOG_INF("RAIL_SetTxTransitions success"); + } + + if (enable_continuous_rx) { + RAIL_StartRx(rail_handle, CHANNEL, NULL); + } else { + RAIL_Idle(rail_handle, RAIL_IDLE, true); + } +} + +void handle_receive(void) +{ + RAIL_RxPacketHandle_t rx_packet_handle; + RAIL_RxPacketInfo_t packet_info; + RAIL_Status_t rail_status = RAIL_STATUS_NO_ERROR; + uint8_t *start_of_packet = NULL; + uint16_t packet_size = 0; + static __ALIGNED(RAIL_FIFO_ALIGNMENT) uint8_t rx_fifo[128]; + RAIL_Handle_t rail_handle = sl_rail_util_get_handle(SL_RAIL_UTIL_HANDLE_INST0); + rx_packet_handle = RAIL_GetRxPacketInfo(rail_handle, RAIL_RX_PACKET_HANDLE_OLDEST_COMPLETE, + &packet_info); + while (rx_packet_handle != RAIL_RX_PACKET_HANDLE_INVALID) { + packet_size = unpack_packet(rx_fifo, &packet_info, &start_of_packet); + rail_status = RAIL_ReleaseRxPacket(rail_handle, rx_packet_handle); + if (rail_status) { + LOG_WRN("RAIL_ReleaseRxPacket() result:%d", rail_status); + } + LOG_INF("Length of packet: %d", packet_size); + LOG_HEXDUMP_INF(start_of_packet, packet_size, "Received Packet: "); + rx_packet_handle = RAIL_GetRxPacketInfo( + rail_handle, RAIL_RX_PACKET_HANDLE_OLDEST_COMPLETE, &packet_info); + } +} + +void app_rail_init(void) +{ + RAIL_Status_t status = RAIL_STATUS_NO_ERROR; + RAIL_Handle_t rail_handle; + rail_isr_installer(); + sl_rail_util_pa_init(); + sl_rail_util_init(); + + rail_handle = sl_rail_util_get_handle(SL_RAIL_UTIL_HANDLE_INST0); + set_up_tx_fifo(rail_handle); + + status = RAIL_StartRx(rail_handle, CHANNEL, NULL); + if (status) { + LOG_WRN("After initialization RAIL_StartRx() result:%d ", status); + } + + if (IS_ENABLED(CONFIG_PM)) { + status = RAIL_InitPowerManager(); + if (status) { + LOG_ERR("RAIL: failed to initialize power management, status=%d", status); + } + } +} + +/****************************************************************************** + * RAIL callback, called if a RAIL event occurs. + *****************************************************************************/ +/** + * @brief RAIL callback for handling RAIL events. + * + * RAIL event's callback, and it handles RX, TX, and calibration events. + * + * @param rail_handle RAIL handle for communication. + * @param events RAIL events that occurred. + */ +void sl_rail_util_on_event(RAIL_Handle_t rail_handle, RAIL_Events_t events) +{ + // Contains the status of RAIL Calibration + static RAIL_Status_t calibration_status = 0; + s_sl_machine.error_code = events; + // Handle Rx events + if (events & RAIL_EVENTS_RX_COMPLETION) { + if (events & RAIL_EVENT_RX_PACKET_RECEIVED) { + // Keep the packet in the radio buffer, download it later at the state + // machine + RAIL_HoldRxPacket(rail_handle); + k_event_post(&s_sl_machine.smf_event, EVENT_RADIO_RECEIVED); + } else { + k_event_post(&s_sl_machine.smf_event, EVENT_RADIO_ERROR); + } + } + // Handle Tx events + if (events & RAIL_EVENTS_TX_COMPLETION) { + if (events & RAIL_EVENT_TX_PACKET_SENT) { + k_event_post(&s_sl_machine.smf_event, EVENT_RADIO_SENT); + } else { + k_event_post(&s_sl_machine.smf_event, EVENT_RADIO_ERROR); + } + } + + // Perform all calibrations when needed + if (events & RAIL_EVENT_CAL_NEEDED) { + calibration_status = RAIL_Calibrate(rail_handle, NULL, RAIL_CAL_ALL_PENDING); + if (calibration_status) { + k_event_post(&s_sl_machine.smf_event, EVENT_RADIO_ERROR); + } + } +} + +// ----------------------------------------------------------------------------- +// Static Function Definitions + +static void set_up_tx_fifo(RAIL_Handle_t rail_handle) +{ + uint16_t allocated_tx_fifo_size = 0; + static __ALIGNED(RAIL_FIFO_ALIGNMENT) uint8_t tx_fifo[128]; + allocated_tx_fifo_size = RAIL_SetTxFifo(rail_handle, tx_fifo, 0, sizeof(tx_fifo)); + if (allocated_tx_fifo_size != sizeof(tx_fifo)) { + LOG_WRN("RAIL_SetTxFifo allocation failed %d instead of %d", allocated_tx_fifo_size, + sizeof(tx_fifo)); + } +} + +/** + * Prepares the packet for sending and load it in the RAIL TX FIFO + * + * @param rail_handle Which rail handlers should be used for the TX FIFO writing + * @param out_data The payload buffer + * @param length The length of the payload + */ +static void prepare_package(RAIL_Handle_t rail_handle, uint8_t *out_data, uint16_t length) +{ + // Check if write fifo has written all bytes + uint16_t bytes_writen_in_fifo = 0; + bytes_writen_in_fifo = RAIL_WriteTxFifo(rail_handle, out_data, length, true); + if (bytes_writen_in_fifo != length) { + LOG_WRN("RAIL_SetTxFifo allocation failed %d instead of %d", bytes_writen_in_fifo, + length); + } +} + +/** + * Helps to unpack the received packet, point to the payload and returns the length. + * + * @param rx_destination Where should the full packet be unpacked + * @param packet_information Where should all the information of the packet stored + * @param start_of_payload Pointer where the payload starts + * @return The length of the received payload + */ +static uint16_t unpack_packet(uint8_t *rx_destination, + const RAIL_RxPacketInfo_t *packet_information, + uint8_t **start_of_payload) +{ + RAIL_CopyRxPacket(rx_destination, packet_information); + *start_of_payload = rx_destination; + return packet_information->packetBytes; +} + +static void rail_isr_installer(void) +{ +#ifdef CONFIG_SOC_SERIES_EFR32MG24 + IRQ_CONNECT(SYNTH_IRQn, 0, SYNTH_IRQHandler, NULL, 0); +#else + IRQ_CONNECT(RDMAILBOX_IRQn, 0, RDMAILBOX_IRQHandler, NULL, 0); +#endif + IRQ_CONNECT(RAC_SEQ_IRQn, 0, RAC_SEQ_IRQHandler, NULL, 0); + IRQ_CONNECT(RAC_RSM_IRQn, 0, RAC_RSM_IRQHandler, NULL, 0); + IRQ_CONNECT(PROTIMER_IRQn, 0, PROTIMER_IRQHandler, NULL, 0); + IRQ_CONNECT(MODEM_IRQn, 0, MODEM_IRQHandler, NULL, 0); + IRQ_CONNECT(FRC_IRQn, 0, FRC_IRQHandler, NULL, 0); + IRQ_CONNECT(BUFC_IRQn, 0, BUFC_IRQHandler, NULL, 0); + IRQ_CONNECT(AGC_IRQn, 0, AGC_IRQHandler, NULL, 0); +} diff --git a/examples/proprietary_trx/src/app_rail.h b/examples/proprietary_trx/src/app_rail.h new file mode 100644 index 00000000..8d6d0391 --- /dev/null +++ b/examples/proprietary_trx/src/app_rail.h @@ -0,0 +1,88 @@ +/***************************************************************************//** + * @file app_rail.h + * @brief RAIL configuration and handling functions. + ******************************************************************************* + * # License + * Copyright 2024 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef APP_RAIL_H +#define APP_RAIL_H + +// ----------------------------------------------------------------------------- +// Public Function Declarations + +/** + * @brief Handle the process of sending a packet. + * + * Handles the process of sending a packet, preparing the package, + * and initiating the transmission. + * + * @param packet_sent pointer to sending flag + */ +void handle_send(bool *packet_sent); + +/** + * @brief Handle the event of a successfully sent packet. + * + * Handles the event when a packet has been successfully sent. + * + * @param packet_sent pointer to sending flag + */ +void handle_sent(bool *packet_sent); + +/** + * @brief Handle a radio error event. + * + * Handles events where a radio error has occurred. + * + * @param error_code pointer to the error events happened with RAIL + */ +void handle_error(uint64_t *error_code); + +/** + * @brief Set continuous receive mode. + * + * Sets the radio to continuous receive mode or disables it based on the provided parameter. + * + * @param enable_continuous_rx Boolean indicating whether to enable continuous receive mode. + */ +void set_continuous_rx(bool enable_continuous_rx); + +/** + * @brief Handle the process of receiving packets. + * + * Handles the process of receiving packets, including unpacking and logging. + */ +void handle_receive(void); + +/** + * @brief Initialize the RAIL communication. + * + * Initializes RAIL communication, installs ISRs, and sets up the TX FIFO. + */ +void app_rail_init(void); + +#endif /*APP_RAIL_H*/ diff --git a/examples/proprietary_trx/src/autogen/sl_rail_util_callbacks.c b/examples/proprietary_trx/src/autogen/sl_rail_util_callbacks.c new file mode 100644 index 00000000..55fc76c4 --- /dev/null +++ b/examples/proprietary_trx/src/autogen/sl_rail_util_callbacks.c @@ -0,0 +1,117 @@ + /***************************************************************************//** + * @file sl_rail_util_callbacks.c + * @brief RAIL Callbacks + * WARNING: Auto-Generated Radio Callbacks - DO NOT EDIT + * Any application code placed within this file will be discarged + * upon project regeneration. + ******************************************************************************* + * # License + * Copyright 2020 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#include "rail.h" +#ifdef SL_CATALOG_APP_ASSERT_PRESENT +#include "app_assert.h" +#define APP_ASSERT(expr, ...) app_assert(expr,__VA_ARGS__) +#else + #define APP_ASSERT(expr, string ,rail_handle, error_code) \ + do { \ + if (!(expr)) { \ + while (1) ; \ + } \ + } while (0) +#endif +#include "sl_rail_util_callbacks_config.h" +#include "pa_conversions_efr32.h" + +// Provide weak function called by callback RAILCb_AssertFailed. +__WEAK +void sl_rail_util_on_assert_failed(RAIL_Handle_t rail_handle, + RAIL_AssertErrorCodes_t error_code) +{ + (void) rail_handle; + (void) error_code; + APP_ASSERT(false, + "rail_handle: 0x%X, error_code: %d", + rail_handle, + error_code); +} + +#if SL_RAIL_UTIL_CALLBACKS_ASSERT_FAILED_OVERRIDE +// Note: RAILCb_AssertFailed is called directly by the RAIL library when +// needed, so maintain this exact function signature. +void RAILCb_AssertFailed(RAIL_Handle_t rail_handle, + RAIL_AssertErrorCodes_t error_code) +{ + sl_rail_util_on_assert_failed(rail_handle, error_code); +} +#endif + +// Provide weak function called by callback sli_rail_util_on_rf_ready. +__WEAK +void sl_rail_util_on_rf_ready(RAIL_Handle_t rail_handle) +{ + (void) rail_handle; +} + +// Internal-only callback set up through call to RAIL_Init(). +void sli_rail_util_on_rf_ready(RAIL_Handle_t rail_handle) +{ + sl_rail_util_on_rf_ready(rail_handle); +} + +// Provide weak function called by callback +// sli_rail_util_on_channel_config_change. +__WEAK +void sl_rail_util_on_channel_config_change(RAIL_Handle_t rail_handle, + const RAIL_ChannelConfigEntry_t *entry) +{ + (void) rail_handle; + (void) entry; +} + +// Internal-only callback set up through call to RAIL_ConfigChannels(). +void sli_rail_util_on_channel_config_change(RAIL_Handle_t rail_handle, + const RAIL_ChannelConfigEntry_t *entry) +{ + sl_rail_util_pa_on_channel_config_change(rail_handle, entry); + sl_rail_util_on_channel_config_change(rail_handle, entry); +} + +// Provide weak function called by callback sli_rail_util_on_event. +__WEAK +void sl_rail_util_on_event(RAIL_Handle_t rail_handle, + RAIL_Events_t events) +{ + (void) rail_handle; + (void) events; +} + +// Internal-only callback set up through call to RAIL_Init(). +void sli_rail_util_on_event(RAIL_Handle_t rail_handle, + RAIL_Events_t events) +{ + sl_rail_util_on_event(rail_handle, events); +} diff --git a/examples/proprietary_trx/src/autogen/sl_rail_util_init.c b/examples/proprietary_trx/src/autogen/sl_rail_util_init.c new file mode 100644 index 00000000..361d7087 --- /dev/null +++ b/examples/proprietary_trx/src/autogen/sl_rail_util_init.c @@ -0,0 +1,233 @@ +/***************************************************************************//** + * @file + * @brief + ******************************************************************************* + * # License + * Copyright 2020 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ +#include "rail.h" +#include "rail_ble.h" // for RAIL_BLE_State_t +#include "sli_rail_util_callbacks.h" // for internal-only callback signatures +#include "sl_rail_util_init.h" +#include "sl_rail_util_protocol.h" + +#if defined(SL_CATALOG_TIMING_TEST_PRESENT) && !SL_RAIL_LIB_MULTIPROTOCOL_SUPPORT +// Needed for measuring RAIL_Init() time as a part of +// detailed timing characterization. +#include "em_timer.h" +#include "em_cmu.h" +#endif + +#ifdef SL_CATALOG_APP_ASSERT_PRESENT +#include "app_assert.h" +#define APP_ASSERT(expr, ...) app_assert(expr,__VA_ARGS__) +#else +#define APP_ASSERT(expr, ...) \ + do { \ + if (!(expr)) { \ + while (1) ; \ + } \ + } while (0) +#endif + +#if 0U \ + || SL_RAIL_UTIL_INIT_RADIO_CONFIG_SUPPORT_INST0_ENABLE \ + || 0U + #include "rail_config.h" +#endif + +// Instance: inst0 +static RAIL_Handle_t sl_rail_handle_inst0 = RAIL_EFR32_HANDLE; + +#if defined(SL_CATALOG_TIMING_TEST_PRESENT) && !SL_RAIL_LIB_MULTIPROTOCOL_SUPPORT +uint32_t sli_timing_start_tick = 0U; +uint32_t sli_timing_end_tick = 0U; +static TIMER_TypeDef *timer = TIMER0; +static void setupTimingTestTimer(void) +{ + // Clock TIMER0 using the HF clock + CMU_ClockSelectSet(cmuClock_TIMER0, cmuSelect_HFXO); + CMU_ClockEnable(cmuClock_TIMER0, true); + // Use default configuration, prescaled by 8. + TIMER_Init_TypeDef timerCfg = TIMER_INIT_DEFAULT; + timerCfg.prescale = timerPrescale8; + // Enable TIMER0 to upcount + TIMER_Init(timer, &timerCfg); +} +#endif + +static void sl_rail_util_init_inst0(void) +{ +#if SL_RAIL_UTIL_INIT_INST0_ENABLE + RAIL_Status_t status; + RAIL_Config_t sl_rail_config = { + .eventsCallback = &sli_rail_util_on_event, + // Other fields are ignored nowadays + }; + (void) status; // Suppress compiler warning if status ends up unused +#ifdef SL_CATALOG_TIMING_TEST_PRESENT + setupTimingTestTimer(); + sli_timing_start_tick = timer->CNT; +#endif // SL_CATALOG_TIMING_TEST_PRESENT + sl_rail_handle_inst0 = RAIL_Init(&sl_rail_config, +#if SL_RAIL_UTIL_INIT_INIT_COMPLETE_CALLBACK_INST0_ENABLE + &sli_rail_util_on_rf_ready +#else + NULL +#endif // SL_RAIL_UTIL_INIT_INIT_COMPLETE_CALLBACK_INST0_ENABLE + ); +#ifdef SL_CATALOG_TIMING_TEST_PRESENT + sli_timing_end_tick = timer->CNT; +#endif // SL_CATALOG_TIMING_TEST_PRESENT + APP_ASSERT((NULL != sl_rail_handle_inst0), + "RAIL_Init failed, return value: NULL"); + +#if SL_RAIL_UTIL_INIT_DATA_FORMATS_INST0_ENABLE + RAIL_DataConfig_t data_config = { + .txSource = SL_RAIL_UTIL_INIT_DATA_FORMAT_INST0_TX_SOURCE, + .rxSource = SL_RAIL_UTIL_INIT_DATA_FORMAT_INST0_RX_SOURCE, + .txMethod = SL_RAIL_UTIL_INIT_DATA_FORMAT_INST0_TX_MODE, + .rxMethod = SL_RAIL_UTIL_INIT_DATA_FORMAT_INST0_RX_MODE, + }; + status = RAIL_ConfigData(sl_rail_handle_inst0, &data_config); + APP_ASSERT((RAIL_STATUS_NO_ERROR == status), + "RAIL_ConfigData failed, return value: %d", + status); +#endif // SL_RAIL_UTIL_INIT_DATA_FORMATS_INST0_ENABLE + +#if SL_RAIL_UTIL_INIT_PROTOCOLS_INST0_ENABLE + const RAIL_ChannelConfig_t *channel_config = NULL; + if (SL_RAIL_UTIL_INIT_PROTOCOL_INST0_DEFAULT + == SL_RAIL_UTIL_PROTOCOL_PROPRIETARY) { +#if SL_RAIL_UTIL_INIT_RADIO_CONFIG_SUPPORT_INST0_ENABLE + channel_config = channelConfigs[SL_RAIL_UTIL_INIT_PROTOCOL_PROPRIETARY_INST0_INDEX]; +#else // !SL_RAIL_UTIL_INIT_RADIO_CONFIG_SUPPORT_INST0_ENABLE + APP_ASSERT(false, + "SL_RAIL_UTIL_INIT_RADIO_CONFIG_SUPPORT_INST0_ENABLE must be true when (SL_RAIL_UTIL_INIT_PROTOCOL_INST0_DEFAULT == SL_RAIL_UTIL_PROTOCOL_PROPRIETARY)"); +#endif // SL_RAIL_UTIL_INIT_RADIO_CONFIG_SUPPORT_INST0_ENABLE + } + (void) RAIL_ConfigChannels(sl_rail_handle_inst0, + channel_config, + &sli_rail_util_on_channel_config_change); + status = sl_rail_util_protocol_config(sl_rail_handle_inst0, + SL_RAIL_UTIL_INIT_PROTOCOL_INST0_DEFAULT); + APP_ASSERT((RAIL_STATUS_NO_ERROR == status), + "sl_rail_util_protocol_config failed, return value: %d", + status); +#endif // SL_RAIL_UTIL_INIT_PROTOCOLS_INST0_ENABLE + +#if SL_RAIL_UTIL_INIT_CALIBRATIONS_INST0_ENABLE + status = RAIL_ConfigCal(sl_rail_handle_inst0, + 0U + | (SL_RAIL_UTIL_INIT_CALIBRATION_TEMPERATURE_NOTIFY_INST0_ENABLE + ? RAIL_CAL_TEMP : 0U) + | (SL_RAIL_UTIL_INIT_CALIBRATION_ONETIME_NOTIFY_INST0_ENABLE + ? RAIL_CAL_ONETIME : 0U)); + APP_ASSERT((RAIL_STATUS_NO_ERROR == status), + "RAIL_ConfigCal failed, return value: %d", + status); +#endif // SL_RAIL_UTIL_INIT_CALIBRATIONS_INST0_ENABLE + +#if SL_RAIL_UTIL_INIT_EVENTS_INST0_ENABLE + status = RAIL_ConfigEvents(sl_rail_handle_inst0, + RAIL_EVENTS_ALL, + SL_RAIL_UTIL_INIT_EVENT_INST0_MASK); + APP_ASSERT((RAIL_STATUS_NO_ERROR == status), + "RAIL_ConfigEvents failed, return value: %d", + status); +#endif // SL_RAIL_UTIL_INIT_EVENTS_INST0_ENABLE + +#if SL_RAIL_UTIL_INIT_TRANSITIONS_INST0_ENABLE + RAIL_StateTransitions_t tx_transitions = { + .success = SL_RAIL_UTIL_INIT_TRANSITION_INST0_TX_SUCCESS, + .error = SL_RAIL_UTIL_INIT_TRANSITION_INST0_TX_ERROR + }; + RAIL_StateTransitions_t rx_transitions = { + .success = SL_RAIL_UTIL_INIT_TRANSITION_INST0_RX_SUCCESS, + .error = SL_RAIL_UTIL_INIT_TRANSITION_INST0_RX_ERROR + }; + status = RAIL_SetTxTransitions(sl_rail_handle_inst0, + &tx_transitions); + APP_ASSERT((RAIL_STATUS_NO_ERROR == status), + "RAIL_SetTxTransitions failed, return value: %d", + status); + status = RAIL_SetRxTransitions(sl_rail_handle_inst0, + &rx_transitions); + APP_ASSERT((RAIL_STATUS_NO_ERROR == status), + "RAIL_SetRxTransitions failed, return value: %d", + status); +#endif // SL_RAIL_UTIL_INIT_TRANSITIONS_INST0_ENABLE +#else // !SL_RAIL_UTIL_INIT_INST0_ENABLE + // Eliminate compiler warnings. + (void) sl_rail_handle_inst0; +#endif // SL_RAIL_UTIL_INIT_INST0_ENABLE +} + +RAIL_Handle_t sl_rail_util_get_handle(sl_rail_util_handle_type_t handle) +{ + RAIL_Handle_t *sl_rail_handle_array[] = { + &sl_rail_handle_inst0, + }; + return *sl_rail_handle_array[handle]; +} + +#define INIT_INSTANCES (0 + 1) + +#if (INIT_INSTANCES > 1) && !SL_RAIL_LIB_MULTIPROTOCOL_SUPPORT + #error "sl_rail_util_init.c: If you are going to use more than one rail_util_init instance, you must use the Multiprotocol RAIL library." +#elif (INIT_INSTANCES > 4) + static uint64_t extraStateBuffers[INIT_INSTANCES - 4][RAIL_STATE_BUFFER_BYTES / sizeof(uint64_t)]; + static RAIL_StateBufferEntry_t extraProtos[INIT_INSTANCES - 4]; +#else + // RAIL provides enough built-in state buffers for all the instances +#endif + +void sl_rail_util_init(void) +{ +#if (INIT_INSTANCES > 2) + RAIL_Status_t status; + status = RAIL_AddStateBuffer3(RAIL_EFR32_HANDLE); + APP_ASSERT((RAIL_STATUS_NO_ERROR == status), + "RAIL_AddStateBuffer3 failed, return value: %d", + status); +#if (INIT_INSTANCES > 3) + status = RAIL_AddStateBuffer4(RAIL_EFR32_HANDLE); + APP_ASSERT((RAIL_STATUS_NO_ERROR == status), + "RAIL_AddStateBuffer4 failed, return value: %d", + status); +#endif +#if (INIT_INSTANCES > 4) + for (int i = 0; i < (INIT_INSTANCES - 4); i++) { + extraProtos[i].bufferBytes = sizeof(extraStateBuffers[0]); + extraProtos[i].buffer = extraStateBuffers[i]; + status = RAIL_AddStateBuffer(RAIL_EFR32_HANDLE, &extraProtos[i]); + APP_ASSERT((RAIL_STATUS_NO_ERROR == status), + "RAIL_AddStateBuffer(%d) failed, return value: %d", + (INIT_INSTANCES + i), status); + } +#endif +#endif + sl_rail_util_init_inst0(); +} diff --git a/examples/proprietary_trx/src/autogen/sl_rail_util_init.h b/examples/proprietary_trx/src/autogen/sl_rail_util_init.h new file mode 100644 index 00000000..5f5a971d --- /dev/null +++ b/examples/proprietary_trx/src/autogen/sl_rail_util_init.h @@ -0,0 +1,222 @@ +/***************************************************************************//** + * @file + * @brief + ******************************************************************************* + * # License + * Copyright 2020 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef SL_RAIL_UTIL_INIT_H +#define SL_RAIL_UTIL_INIT_H + +#include "rail.h" +#include "sl_rail_util_init_inst0_config.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum sl_rail_util_handle_type{ + SL_RAIL_UTIL_HANDLE_INST0, +} sl_rail_util_handle_type_t; + +/** + * Initialize the RAIL Init Utility. + * + * @note: This function should be called during application initialization. + */ +void sl_rail_util_init(void); + +/** + * Get the RAIL handle created during initialization. + * @param[in] handle The enum name of the desired RAIL handle. + * + * @return A valid RAIL handle. If the RAIL handle hasn't been set up, the + * invalid value of \ref RAIL_EFR32_HANDLE will be returned. + */ +RAIL_Handle_t sl_rail_util_get_handle(sl_rail_util_handle_type_t handle); + +/** + * A callback available to the application, called on RAIL asserts. + * + * @param[in] rail_handle The RAIL handle associated with the assert. + * @param[in] error_code The assertion error code. + */ +void sl_rail_util_on_assert_failed(RAIL_Handle_t rail_handle, + RAIL_AssertErrorCodes_t error_code); + +/** + * A callback available to the application, called on RAIL init completion. + * + * @param[in] rail_handle The RAIL handle associated with the RAIL init + * completion notification. + */ +void sl_rail_util_on_rf_ready(RAIL_Handle_t rail_handle); + +/** + * A callback available to the application, called on a channel configuration + * change. + * + * @param[in] rail_handle The RAIL handle associated with the channel config + * change notification. + * @param[in] entry The channel configuration being changed to. + */ +void sl_rail_util_on_channel_config_change(RAIL_Handle_t rail_handle, + const RAIL_ChannelConfigEntry_t *entry); + +/** + * A callback available to the application, called on registered RAIL events. + * + * @param[in] rail_handle The RAIL handle associated with the RAIL event + * notification. + * @param[in] events The RAIL events having occurred. + */ +void sl_rail_util_on_event(RAIL_Handle_t rail_handle, + RAIL_Events_t events); + +/** + * An event mask, available to the application, specifying the radio events + * setup within the init code. + * + * @note: Because the value of this define is evaluated based on values in the + * \ref RAIL_Events_t enum, this define will only have a valid value during + * run-time. + */ +#define SL_RAIL_UTIL_INIT_EVENT_INST0_MASK (RAIL_EVENTS_NONE \ + | (SL_RAIL_UTIL_INIT_EVENT_RSSI_AVERAGE_DONE_INST0_ENABLE \ + ? RAIL_EVENT_RSSI_AVERAGE_DONE : RAIL_EVENTS_NONE) \ + | (SL_RAIL_UTIL_INIT_EVENT_RX_ACK_TIMEOUT_INST0_ENABLE \ + ? RAIL_EVENT_RX_ACK_TIMEOUT : RAIL_EVENTS_NONE) \ + | (SL_RAIL_UTIL_INIT_EVENT_RX_FIFO_ALMOST_FULL_INST0_ENABLE \ + ? RAIL_EVENT_RX_FIFO_ALMOST_FULL : RAIL_EVENTS_NONE) \ + | (SL_RAIL_UTIL_INIT_EVENT_RX_PACKET_RECEIVED_INST0_ENABLE \ + ? RAIL_EVENT_RX_PACKET_RECEIVED : RAIL_EVENTS_NONE) \ + | (SL_RAIL_UTIL_INIT_EVENT_RX_PREAMBLE_LOST_INST0_ENABLE \ + ? RAIL_EVENT_RX_PREAMBLE_LOST : RAIL_EVENTS_NONE) \ + | (SL_RAIL_UTIL_INIT_EVENT_RX_PREAMBLE_DETECT_INST0_ENABLE \ + ? RAIL_EVENT_RX_PREAMBLE_DETECT : RAIL_EVENTS_NONE) \ + | (SL_RAIL_UTIL_INIT_EVENT_RX_SYNC1_DETECT_INST0_ENABLE \ + ? RAIL_EVENT_RX_SYNC1_DETECT : RAIL_EVENTS_NONE) \ + | (SL_RAIL_UTIL_INIT_EVENT_RX_SYNC2_DETECT_INST0_ENABLE \ + ? RAIL_EVENT_RX_SYNC2_DETECT : RAIL_EVENTS_NONE) \ + | (SL_RAIL_UTIL_INIT_EVENT_RX_FRAME_ERROR_INST0_ENABLE \ + ? RAIL_EVENT_RX_FRAME_ERROR : RAIL_EVENTS_NONE) \ + | (SL_RAIL_UTIL_INIT_EVENT_RX_FIFO_FULL_INST0_ENABLE \ + ? RAIL_EVENT_RX_FIFO_FULL : RAIL_EVENTS_NONE) \ + | (SL_RAIL_UTIL_INIT_EVENT_RX_FIFO_OVERFLOW_INST0_ENABLE \ + ? RAIL_EVENT_RX_FIFO_OVERFLOW : RAIL_EVENTS_NONE) \ + | (SL_RAIL_UTIL_INIT_EVENT_RX_ADDRESS_FILTERED_INST0_ENABLE \ + ? RAIL_EVENT_RX_ADDRESS_FILTERED : RAIL_EVENTS_NONE) \ + | (SL_RAIL_UTIL_INIT_EVENT_RX_TIMEOUT_INST0_ENABLE \ + ? RAIL_EVENT_RX_TIMEOUT : RAIL_EVENTS_NONE) \ + | (SL_RAIL_UTIL_INIT_EVENT_RX_TX_SCHEDULED_RX_TX_STARTED_INST0_ENABLE \ + ? RAIL_EVENT_SCHEDULED_RX_STARTED : RAIL_EVENTS_NONE) \ + | (SL_RAIL_UTIL_INIT_EVENT_RX_SCHEDULED_RX_END_INST0_ENABLE \ + ? RAIL_EVENT_RX_SCHEDULED_RX_END : RAIL_EVENTS_NONE) \ + | (SL_RAIL_UTIL_INIT_EVENT_RX_SCHEDULED_RX_MISSED_INST0_ENABLE \ + ? RAIL_EVENT_RX_SCHEDULED_RX_MISSED : RAIL_EVENTS_NONE) \ + | (SL_RAIL_UTIL_INIT_EVENT_RX_PACKET_ABORTED_INST0_ENABLE \ + ? RAIL_EVENT_RX_PACKET_ABORTED : RAIL_EVENTS_NONE) \ + | (SL_RAIL_UTIL_INIT_EVENT_RX_FILTER_PASSED_INST0_ENABLE \ + ? RAIL_EVENT_RX_FILTER_PASSED : RAIL_EVENTS_NONE) \ + | (SL_RAIL_UTIL_INIT_EVENT_RX_TIMING_LOST_INST0_ENABLE \ + ? RAIL_EVENT_RX_TIMING_LOST : RAIL_EVENTS_NONE) \ + | (SL_RAIL_UTIL_INIT_EVENT_RX_TIMING_DETECT_INST0_ENABLE \ + ? RAIL_EVENT_RX_TIMING_DETECT : RAIL_EVENTS_NONE) \ + | (SL_RAIL_UTIL_INIT_EVENT_RX_CHANNEL_HOPPING_COMPLETE_INST0_ENABLE \ + ? RAIL_EVENT_RX_CHANNEL_HOPPING_COMPLETE : RAIL_EVENTS_NONE) \ + | (SL_RAIL_UTIL_INIT_EVENT_RX_DUTY_CYCLE_RX_END_INST0_ENABLE \ + ? RAIL_EVENT_RX_DUTY_CYCLE_RX_END : RAIL_EVENTS_NONE) \ + | (SL_RAIL_UTIL_INIT_EVENT_IEEE802154_DATA_REQUEST_COMMAND_INST0_ENABLE \ + ? RAIL_EVENT_IEEE802154_DATA_REQUEST_COMMAND : RAIL_EVENTS_NONE) \ + | (SL_RAIL_UTIL_INIT_EVENT_ZWAVE_BEAM_INST0_ENABLE \ + ? RAIL_EVENT_ZWAVE_BEAM : RAIL_EVENTS_NONE) \ + | (SL_RAIL_UTIL_INIT_EVENT_ZWAVE_LR_ACK_REQUEST_COMMAND_INST0_ENABLE \ + ? RAIL_EVENT_ZWAVE_LR_ACK_REQUEST_COMMAND : RAIL_EVENTS_NONE) \ + | (SL_RAIL_UTIL_INIT_EVENT_TX_FIFO_ALMOST_EMPTY_INST0_ENABLE \ + ? RAIL_EVENT_TX_FIFO_ALMOST_EMPTY : RAIL_EVENTS_NONE) \ + | (SL_RAIL_UTIL_INIT_EVENT_TX_PACKET_SENT_INST0_ENABLE \ + ? RAIL_EVENT_TX_PACKET_SENT : RAIL_EVENTS_NONE) \ + | (SL_RAIL_UTIL_INIT_EVENT_TXACK_PACKET_SENT_INST0_ENABLE \ + ? RAIL_EVENT_TXACK_PACKET_SENT : RAIL_EVENTS_NONE) \ + | (SL_RAIL_UTIL_INIT_EVENT_TX_ABORTED_INST0_ENABLE \ + ? RAIL_EVENT_TX_ABORTED : RAIL_EVENTS_NONE) \ + | (SL_RAIL_UTIL_INIT_EVENT_TXACK_ABORTED_INST0_ENABLE \ + ? RAIL_EVENT_TXACK_ABORTED : RAIL_EVENTS_NONE) \ + | (SL_RAIL_UTIL_INIT_EVENT_TX_BLOCKED_INST0_ENABLE \ + ? RAIL_EVENT_TX_BLOCKED : RAIL_EVENTS_NONE) \ + | (SL_RAIL_UTIL_INIT_EVENT_TXACK_BLOCKED_INST0_ENABLE \ + ? RAIL_EVENT_TXACK_BLOCKED : RAIL_EVENTS_NONE) \ + | (SL_RAIL_UTIL_INIT_EVENT_TX_UNDERFLOW_INST0_ENABLE \ + ? RAIL_EVENT_TX_UNDERFLOW : RAIL_EVENTS_NONE) \ + | (SL_RAIL_UTIL_INIT_EVENT_TXACK_UNDERFLOW_INST0_ENABLE \ + ? RAIL_EVENT_TXACK_UNDERFLOW : RAIL_EVENTS_NONE) \ + | (SL_RAIL_UTIL_INIT_EVENT_TX_CHANNEL_CLEAR_INST0_ENABLE \ + ? RAIL_EVENT_TX_CHANNEL_CLEAR : RAIL_EVENTS_NONE) \ + | (SL_RAIL_UTIL_INIT_EVENT_TX_CHANNEL_BUSY_INST0_ENABLE \ + ? RAIL_EVENT_TX_CHANNEL_BUSY : RAIL_EVENTS_NONE) \ + | (SL_RAIL_UTIL_INIT_EVENT_TX_CCA_RETRY_INST0_ENABLE \ + ? RAIL_EVENT_TX_CCA_RETRY : RAIL_EVENTS_NONE) \ + | (SL_RAIL_UTIL_INIT_EVENT_TX_START_CCA_INST0_ENABLE \ + ? RAIL_EVENT_TX_START_CCA : RAIL_EVENTS_NONE) \ + | (SL_RAIL_UTIL_INIT_EVENT_TX_STARTED_INST0_ENABLE \ + ? RAIL_EVENT_TX_STARTED : RAIL_EVENTS_NONE) \ + | (SL_RAIL_UTIL_INIT_EVENT_TX_SCHEDULED_TX_MISSED_INST0_ENABLE \ + ? RAIL_EVENT_TX_SCHEDULED_TX_MISSED : RAIL_EVENTS_NONE) \ + | (SL_RAIL_UTIL_INIT_EVENT_CONFIG_UNSCHEDULED_INST0_ENABLE \ + ? RAIL_EVENT_CONFIG_UNSCHEDULED : RAIL_EVENTS_NONE) \ + | (SL_RAIL_UTIL_INIT_EVENT_CONFIG_SCHEDULED_INST0_ENABLE \ + ? RAIL_EVENT_CONFIG_SCHEDULED : RAIL_EVENTS_NONE) \ + | (SL_RAIL_UTIL_INIT_EVENT_SCHEDULER_STATUS_INST0_ENABLE \ + ? RAIL_EVENT_SCHEDULER_STATUS : RAIL_EVENTS_NONE) \ + | (SL_RAIL_UTIL_INIT_EVENT_CAL_NEEDED_INST0_ENABLE \ + ? RAIL_EVENT_CAL_NEEDED : RAIL_EVENTS_NONE) \ + | (SL_RAIL_UTIL_INIT_EVENT_DETECT_RSSI_THRESHOLD_INST0_ENABLE \ + ? RAIL_EVENT_DETECT_RSSI_THRESHOLD : RAIL_EVENTS_NONE) \ + | (SL_RAIL_UTIL_INIT_EVENT_THERMISTOR_DONE_INST0_ENABLE \ + ? RAIL_EVENT_THERMISTOR_DONE : RAIL_EVENTS_NONE) \ + | (SL_RAIL_UTIL_INIT_EVENT_TX_BLOCKED_TOO_HOT_INST0_ENABLE \ + ? RAIL_EVENT_TX_BLOCKED_TOO_HOT : RAIL_EVENTS_NONE) \ + | (SL_RAIL_UTIL_INIT_EVENT_TEMPERATURE_TOO_HOT_INST0_ENABLE \ + ? RAIL_EVENT_TEMPERATURE_TOO_HOT : RAIL_EVENTS_NONE) \ + | (SL_RAIL_UTIL_INIT_EVENT_TEMPERATURE_COOL_DOWN_INST0_ENABLE \ + ? RAIL_EVENT_TEMPERATURE_COOL_DOWN : RAIL_EVENTS_NONE)) + +/** + * An inverted event mask, available to the application, specifying the radio + * events setup within the init code. + * + * @note: Because the value of this define is evaluated based on values in the + * \ref RAIL_Events_t enum, this define will only have a valid value during + * run-time. + */ +#define SL_RAIL_UTIL_INIT_EVENT_INST0_INVERSE_MASK \ + (~SL_RAIL_UTIL_INIT_EVENT_INST0_MASK) + +#ifdef __cplusplus +} +#endif + +#endif // SL_RAIL_UTIL_INIT_H diff --git a/examples/proprietary_trx/src/config/rail/efr32bg22_brd4184a/radio_settings.radioconf b/examples/proprietary_trx/src/config/rail/efr32bg22_brd4184a/radio_settings.radioconf new file mode 100644 index 00000000..af90a4c2 --- /dev/null +++ b/examples/proprietary_trx/src/config/rail/efr32bg22_brd4184a/radio_settings.radioconf @@ -0,0 +1,18 @@ + + + + + + + 0 + 20 + SAME_AS_FIRST_CHANNEL + RAIL_TX_POWER_MAX + {"selectedPhy":"PHY_Datasheet_2450M_2GFSK_1Mbps_500K"} + + + {"selectedPhy":"PHY_Datasheet_2450M_2GFSK_1Mbps_500K"} + + + + \ No newline at end of file diff --git a/examples/proprietary_trx/src/config/rail/efr32bg22_brd4184a/rail_config.c b/examples/proprietary_trx/src/config/rail/efr32bg22_brd4184a/rail_config.c new file mode 100644 index 00000000..a1ca3028 --- /dev/null +++ b/examples/proprietary_trx/src/config/rail/efr32bg22_brd4184a/rail_config.c @@ -0,0 +1,333 @@ +/***************************************************************************//** + * @brief RAIL Configuration + * @details + * WARNING: Auto-Generated Radio Config - DO NOT EDIT + * Radio Configurator Version: 2022.5.2 + * RAIL Adapter Version: 2.4.19 + * RAIL Compatibility: 2.x + ******************************************************************************* + * # License + * Copyright 2019 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#include "em_device.h" +#include "rail_config.h" + +uint32_t RAILCb_CalcSymbolRate(RAIL_Handle_t railHandle) +{ + (void)railHandle; + return 0U; +} + +uint32_t RAILCb_CalcBitRate(RAIL_Handle_t railHandle) +{ + (void)railHandle; + return 0U; +} + +void RAILCb_ConfigFrameTypeLength(RAIL_Handle_t railHandle, const RAIL_FrameType_t *frameType) +{ + (void)railHandle; + (void)frameType; +} + +static const uint8_t irCalConfig[] = {25, 63, 1, 6, 4, 16, 1, 0, 0, 1, 1, 6, 0, + 16, 39, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0}; + +static const int32_t timingConfig[] = {0, 0, 0}; + +static const uint8_t hfxoRetimingConfigEntries[] = { + 2, 0, 0, 0, 0x00, 0xf0, 0x49, 0x02, 6, 20, 0, 0, 0x00, 0xe0, 0x93, 0x04, 5, 56, + 0, 0, 0xa0, 0x08, 0, 0, 0, 0, 0x58, 0x09, 1, 4, 7, 6, 0x10, 0x0a, 1, 4, + 7, 7, 0xc8, 0x0a, 0, 4, 8, 7, 0x80, 0x0b, 0, 4, 8, 8, 0x38, 0x0c, 0, 4, + 9, 8, 0x61, 0x08, 0, 0, 0, 0, 0x68, 0x08, 0, 0, 0, 0, 0xc7, 0x09, 1, 4, + 4, 3, 0x2c, 0x0b, 1, 4, 4, 4, 0x92, 0x0c, 1, 4, 5, 4}; + +static RAIL_ChannelConfigEntryAttr_t channelConfigEntryAttr = { +#if RAIL_SUPPORTS_OFDM_PA + {{0xFFFFFFFFUL}, {0xFFFFFFFFUL, 0xFFFFFFFFUL}} +#else // RAIL_SUPPORTS_OFDM_PA + {0xFFFFFFFFUL}, +#endif // RAIL_SUPPORTS_OFDM_PA +}; + +static const uint32_t phyInfo[] = { + 13UL, + 0x00924924UL, // 146.28571428571428 + (uint32_t)NULL, + (uint32_t)irCalConfig, + (uint32_t)timingConfig, + 0x00000000UL, + 8000000UL, + 28000000UL, + 1000000UL, + 0x00F50101UL, + 0x02503EC5UL, + (uint32_t)NULL, + (uint32_t)hfxoRetimingConfigEntries, + (uint32_t)NULL, + 0UL, + 0UL, + 999997UL, + (uint32_t)NULL, + (uint32_t)NULL, +}; + +const uint32_t Protocol_Configuration_modemConfigBase[] = { + 0x0002400CUL, + 0x00000000UL, + /* 4010 */ 0x00004000UL, + 0x00024020UL, + 0x0000000FUL, + /* 4024 */ 0x00000000UL, + 0x00074030UL, + 0x00000000UL, + /* 4034 */ 0x00000000UL, + /* 4038 */ 0x00000000UL, + /* 403C */ 0x00000000UL, + /* 4040 */ 0x00000000UL, + /* 4044 */ 0x00004000UL, + /* 4048 */ 0x00040700UL, + 0x00014050UL, + 0x00000000UL, + 0x0002405CUL, + 0x00000000UL, + /* 4060 */ 0x00000000UL, + 0x000140A8UL, + 0x00000000UL, + 0x000440BCUL, + 0x00000000UL, + /* 40C0 */ 0x00000000UL, + /* 40C4 */ 0x00000000UL, + /* 40C8 */ 0x00000000UL, + 0x00044104UL, + 0x00004CFFUL, + /* 4108 */ 0x00000000UL, + /* 410C */ 0x00004DFFUL, + /* 4110 */ 0x00000000UL, + 0x1001C020UL, + 0x0007F800UL, + 0x3001C020UL, + 0x000802F5UL, + 0x0008C024UL, + 0x00001300UL, + /* C028 */ 0x83B380ECUL, + /* C02C */ 0x51407543UL, + /* C030 */ 0x48000FA0UL, + /* C034 */ 0x00004030UL, + /* C038 */ 0x00000000UL, + /* C03C */ 0x00000000UL, + /* C040 */ 0x0000022EUL, + 0x0004C050UL, + 0x04301151UL, + /* C054 */ 0xE6092D0EUL, + /* C058 */ 0x08070654UL, + /* C05C */ 0x0002B6D1UL, + 0x000AC064UL, + 0x1C003004UL, + /* C068 */ 0x09183040UL, + /* C06C */ 0x2079640DUL, + /* C070 */ 0x01FBFCEBUL, + /* C074 */ 0x03E8F67FUL, + /* C078 */ 0x15724BBDUL, + /* C07C */ 0x0518A311UL, + /* C080 */ 0x76543210UL, + /* C084 */ 0x00000A98UL, + /* C088 */ 0x00000000UL, + 0x01010008UL, + 0x00000744UL, + 0x01010018UL, + 0x00000000UL, + 0x01010020UL, + 0x0000A001UL, + 0x0108401CUL, + 0x00000010UL, + /* 4020 */ 0x04000000UL, + /* 4024 */ 0x0002C00FUL, + /* 4028 */ 0x00005000UL, + /* 402C */ 0x000C1000UL, + /* 4030 */ 0x03000000UL, + /* 4034 */ 0x00000000UL, + /* 4038 */ 0x00000000UL, + 0x01064058UL, + 0x00FF04C8UL, + /* 405C */ 0x00000C41UL, + /* 4060 */ 0x00000001UL, + /* 4064 */ 0x00140012UL, + /* 4068 */ 0x0000B16FUL, + /* 406C */ 0x00000000UL, + 0x01114080UL, + 0x13C00714UL, + /* 4084 */ 0x00000000UL, + /* 4088 */ 0x003B03F1UL, + /* 408C */ 0x00000000UL, + /* 4090 */ 0x00000000UL, + /* 4094 */ 0x22140A04UL, + /* 4098 */ 0x4F4A4132UL, + /* 409C */ 0x00000000UL, + /* 40A0 */ 0x00000000UL, + /* 40A4 */ 0x00000000UL, + /* 40A8 */ 0x00000000UL, + /* 40AC */ 0x00000000UL, + /* 40B0 */ 0x00000000UL, + /* 40B4 */ 0x00000000UL, + /* 40B8 */ 0x00000000UL, + /* 40BC */ 0x00000000UL, + /* 40C0 */ 0x00000000UL, + 0x010240E0UL, + 0x00000033UL, + /* 40E4 */ 0x00000000UL, + 0x010140ECUL, + 0x8C84B89BUL, + 0x010540F4UL, + 0x07830464UL, + /* 40F8 */ 0x3AC81388UL, + /* 40FC */ 0x000A209CUL, + /* 4100 */ 0x00206100UL, + /* 4104 */ 0x123556B7UL, + 0x0103410CUL, + 0x0011F778UL, + /* 4110 */ 0x29043020UL, + /* 4114 */ 0x4040BB88UL, + 0x01024124UL, + 0x00000000UL, + /* 4128 */ 0x00000000UL, + 0x010A4130UL, + 0x0C660664UL, + /* 4134 */ 0x0000010CUL, + /* 4138 */ 0x00FA53E8UL, + /* 413C */ 0x00000000UL, + /* 4140 */ 0x00000000UL, + /* 4144 */ 0x00000000UL, + /* 4148 */ 0x00000000UL, + /* 414C */ 0x00000000UL, + /* 4150 */ 0x00000000UL, + /* 4154 */ 0x00000101UL, + 0x01034168UL, + 0x07830464UL, + /* 416C */ 0x00821388UL, + /* 4170 */ 0x00000000UL, + 0x01044230UL, + 0x00000000UL, + /* 4234 */ 0x0E000000UL, + /* 4238 */ 0x00000000UL, + /* 423C */ 0x00000000UL, + 0x01024244UL, + 0x00000000UL, + /* 4248 */ 0x001F81F4UL, + 0x010C4254UL, + 0x00000000UL, + /* 4258 */ 0x003C0000UL, + /* 425C */ 0x00000000UL, + /* 4260 */ 0x00000000UL, + /* 4264 */ 0x55555555UL, + /* 4268 */ 0x00000017UL, + /* 426C */ 0x00000000UL, + /* 4270 */ 0x00000000UL, + /* 4274 */ 0x0006AAAAUL, + /* 4278 */ 0x00000000UL, + /* 427C */ 0x00000000UL, + /* 4280 */ 0x00000000UL, + 0x01018010UL, + 0x00000003UL, + 0x01028038UL, + 0x00103EC5UL, + /* 803C */ 0x00000001UL, + 0x0103809CUL, + 0x00000000UL, + /* 80A0 */ 0x00037870UL, + /* 80A4 */ 0x000000D0UL, + 0x110180A8UL, + 0x000001F0UL, + 0x310180A8UL, + 0x01CB4205UL, + 0x110180ACUL, + 0x000001F0UL, + 0x310180ACUL, + 0x00FD3E05UL, + 0x010280B0UL, + 0x02000300UL, + /* 80B4 */ 0x01000037UL, + 0x02020098UL, + 0x04000C00UL, + /* 009C */ 0x0000004CUL, + 0x020100A4UL, + 0x00000400UL, + 0x020200D0UL, + 0xAA400005UL, + /* 00D4 */ 0x00000188UL, + 0x020100E4UL, + 0x11512C6CUL, + 0x020200F4UL, + 0x00000000UL, + /* 00F8 */ 0x1108213DUL, + 0x120100FCUL, + 0x0000003FUL, + 0x320100FCUL, + 0x00045400UL, + 0x02010130UL, + 0x02510060UL, + 0x02010154UL, + 0x00003FC4UL, + 0x02010168UL, + 0x00000400UL, + 0x03014FFCUL, + (uint32_t)&phyInfo, + 0xFFFFFFFFUL, +}; + +const RAIL_ChannelConfigEntry_t Protocol_Configuration_channels[] = { + { + .phyConfigDeltaAdd = NULL, + .baseFrequency = 2450000000, + .channelSpacing = 1000000, + .physicalChannelOffset = 0, + .channelNumberStart = 0, + .channelNumberEnd = 20, + .maxPower = RAIL_TX_POWER_MAX, + .attr = &channelConfigEntryAttr, +#ifdef RADIO_CONFIG_ENABLE_CONC_PHY + .entryType = 0, +#endif +#ifdef RADIO_CONFIG_ENABLE_STACK_INFO + .stackInfo = NULL, +#endif + }, +}; + +const RAIL_ChannelConfig_t Protocol_Configuration_channelConfig = { + .phyConfigBase = Protocol_Configuration_modemConfigBase, + .phyConfigDeltaSubtract = NULL, + .configs = Protocol_Configuration_channels, + .length = 1U, + .signature = 0UL, +}; + +const RAIL_ChannelConfig_t *channelConfigs[] = {&Protocol_Configuration_channelConfig, NULL}; + +#ifdef RADIO_CONFIG_ENABLE_STACK_INFO +#endif // RADIO_CONFIG_ENABLE_STACK_INFO + +uint32_t protocolAccelerationBuffer[303]; diff --git a/examples/proprietary_trx/src/config/rail/efr32bg22_brd4184a/rail_config.h b/examples/proprietary_trx/src/config/rail/efr32bg22_brd4184a/rail_config.h new file mode 100644 index 00000000..f8123e0a --- /dev/null +++ b/examples/proprietary_trx/src/config/rail/efr32bg22_brd4184a/rail_config.h @@ -0,0 +1,52 @@ +/***************************************************************************//** + * @brief RAIL Configuration + * @details + * WARNING: Auto-Generated Radio Config - DO NOT EDIT + * Radio Configurator Version: 2022.5.2 + * RAIL Adapter Version: 2.4.19 + * RAIL Compatibility: 2.x + ******************************************************************************* + * # License + * Copyright 2019 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef __RAIL_CONFIG_H__ +#define __RAIL_CONFIG_H__ + +#include +#include "rail_types.h" + +#define PROTOCOL_ACCELERATION_BUFFER protocolAccelerationBuffer +extern uint32_t protocolAccelerationBuffer[]; +#define RADIO_CONFIG_XTAL_FREQUENCY 38400000UL + +#define RAIL0_CHANNEL_GROUP_1_PHY_DATASHEET_2450M_2GFSK_1MBPS_500K +#define RAIL0_CHANNEL_GROUP_1_PROFILE_BASE +extern const RAIL_ChannelConfig_t *channelConfigs[]; + +#ifdef RADIO_CONFIG_ENABLE_STACK_INFO +#endif // RADIO_CONFIG_ENABLE_STACK_INFO + +#endif // __RAIL_CONFIG_H__ diff --git a/examples/proprietary_trx/src/config/rail/efr32bg22_brd4184b/radio_settings.radioconf b/examples/proprietary_trx/src/config/rail/efr32bg22_brd4184b/radio_settings.radioconf new file mode 100644 index 00000000..af90a4c2 --- /dev/null +++ b/examples/proprietary_trx/src/config/rail/efr32bg22_brd4184b/radio_settings.radioconf @@ -0,0 +1,18 @@ + + + + + + + 0 + 20 + SAME_AS_FIRST_CHANNEL + RAIL_TX_POWER_MAX + {"selectedPhy":"PHY_Datasheet_2450M_2GFSK_1Mbps_500K"} + + + {"selectedPhy":"PHY_Datasheet_2450M_2GFSK_1Mbps_500K"} + + + + \ No newline at end of file diff --git a/examples/proprietary_trx/src/config/rail/efr32bg22_brd4184b/rail_config.c b/examples/proprietary_trx/src/config/rail/efr32bg22_brd4184b/rail_config.c new file mode 100644 index 00000000..a1ca3028 --- /dev/null +++ b/examples/proprietary_trx/src/config/rail/efr32bg22_brd4184b/rail_config.c @@ -0,0 +1,333 @@ +/***************************************************************************//** + * @brief RAIL Configuration + * @details + * WARNING: Auto-Generated Radio Config - DO NOT EDIT + * Radio Configurator Version: 2022.5.2 + * RAIL Adapter Version: 2.4.19 + * RAIL Compatibility: 2.x + ******************************************************************************* + * # License + * Copyright 2019 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#include "em_device.h" +#include "rail_config.h" + +uint32_t RAILCb_CalcSymbolRate(RAIL_Handle_t railHandle) +{ + (void)railHandle; + return 0U; +} + +uint32_t RAILCb_CalcBitRate(RAIL_Handle_t railHandle) +{ + (void)railHandle; + return 0U; +} + +void RAILCb_ConfigFrameTypeLength(RAIL_Handle_t railHandle, const RAIL_FrameType_t *frameType) +{ + (void)railHandle; + (void)frameType; +} + +static const uint8_t irCalConfig[] = {25, 63, 1, 6, 4, 16, 1, 0, 0, 1, 1, 6, 0, + 16, 39, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0}; + +static const int32_t timingConfig[] = {0, 0, 0}; + +static const uint8_t hfxoRetimingConfigEntries[] = { + 2, 0, 0, 0, 0x00, 0xf0, 0x49, 0x02, 6, 20, 0, 0, 0x00, 0xe0, 0x93, 0x04, 5, 56, + 0, 0, 0xa0, 0x08, 0, 0, 0, 0, 0x58, 0x09, 1, 4, 7, 6, 0x10, 0x0a, 1, 4, + 7, 7, 0xc8, 0x0a, 0, 4, 8, 7, 0x80, 0x0b, 0, 4, 8, 8, 0x38, 0x0c, 0, 4, + 9, 8, 0x61, 0x08, 0, 0, 0, 0, 0x68, 0x08, 0, 0, 0, 0, 0xc7, 0x09, 1, 4, + 4, 3, 0x2c, 0x0b, 1, 4, 4, 4, 0x92, 0x0c, 1, 4, 5, 4}; + +static RAIL_ChannelConfigEntryAttr_t channelConfigEntryAttr = { +#if RAIL_SUPPORTS_OFDM_PA + {{0xFFFFFFFFUL}, {0xFFFFFFFFUL, 0xFFFFFFFFUL}} +#else // RAIL_SUPPORTS_OFDM_PA + {0xFFFFFFFFUL}, +#endif // RAIL_SUPPORTS_OFDM_PA +}; + +static const uint32_t phyInfo[] = { + 13UL, + 0x00924924UL, // 146.28571428571428 + (uint32_t)NULL, + (uint32_t)irCalConfig, + (uint32_t)timingConfig, + 0x00000000UL, + 8000000UL, + 28000000UL, + 1000000UL, + 0x00F50101UL, + 0x02503EC5UL, + (uint32_t)NULL, + (uint32_t)hfxoRetimingConfigEntries, + (uint32_t)NULL, + 0UL, + 0UL, + 999997UL, + (uint32_t)NULL, + (uint32_t)NULL, +}; + +const uint32_t Protocol_Configuration_modemConfigBase[] = { + 0x0002400CUL, + 0x00000000UL, + /* 4010 */ 0x00004000UL, + 0x00024020UL, + 0x0000000FUL, + /* 4024 */ 0x00000000UL, + 0x00074030UL, + 0x00000000UL, + /* 4034 */ 0x00000000UL, + /* 4038 */ 0x00000000UL, + /* 403C */ 0x00000000UL, + /* 4040 */ 0x00000000UL, + /* 4044 */ 0x00004000UL, + /* 4048 */ 0x00040700UL, + 0x00014050UL, + 0x00000000UL, + 0x0002405CUL, + 0x00000000UL, + /* 4060 */ 0x00000000UL, + 0x000140A8UL, + 0x00000000UL, + 0x000440BCUL, + 0x00000000UL, + /* 40C0 */ 0x00000000UL, + /* 40C4 */ 0x00000000UL, + /* 40C8 */ 0x00000000UL, + 0x00044104UL, + 0x00004CFFUL, + /* 4108 */ 0x00000000UL, + /* 410C */ 0x00004DFFUL, + /* 4110 */ 0x00000000UL, + 0x1001C020UL, + 0x0007F800UL, + 0x3001C020UL, + 0x000802F5UL, + 0x0008C024UL, + 0x00001300UL, + /* C028 */ 0x83B380ECUL, + /* C02C */ 0x51407543UL, + /* C030 */ 0x48000FA0UL, + /* C034 */ 0x00004030UL, + /* C038 */ 0x00000000UL, + /* C03C */ 0x00000000UL, + /* C040 */ 0x0000022EUL, + 0x0004C050UL, + 0x04301151UL, + /* C054 */ 0xE6092D0EUL, + /* C058 */ 0x08070654UL, + /* C05C */ 0x0002B6D1UL, + 0x000AC064UL, + 0x1C003004UL, + /* C068 */ 0x09183040UL, + /* C06C */ 0x2079640DUL, + /* C070 */ 0x01FBFCEBUL, + /* C074 */ 0x03E8F67FUL, + /* C078 */ 0x15724BBDUL, + /* C07C */ 0x0518A311UL, + /* C080 */ 0x76543210UL, + /* C084 */ 0x00000A98UL, + /* C088 */ 0x00000000UL, + 0x01010008UL, + 0x00000744UL, + 0x01010018UL, + 0x00000000UL, + 0x01010020UL, + 0x0000A001UL, + 0x0108401CUL, + 0x00000010UL, + /* 4020 */ 0x04000000UL, + /* 4024 */ 0x0002C00FUL, + /* 4028 */ 0x00005000UL, + /* 402C */ 0x000C1000UL, + /* 4030 */ 0x03000000UL, + /* 4034 */ 0x00000000UL, + /* 4038 */ 0x00000000UL, + 0x01064058UL, + 0x00FF04C8UL, + /* 405C */ 0x00000C41UL, + /* 4060 */ 0x00000001UL, + /* 4064 */ 0x00140012UL, + /* 4068 */ 0x0000B16FUL, + /* 406C */ 0x00000000UL, + 0x01114080UL, + 0x13C00714UL, + /* 4084 */ 0x00000000UL, + /* 4088 */ 0x003B03F1UL, + /* 408C */ 0x00000000UL, + /* 4090 */ 0x00000000UL, + /* 4094 */ 0x22140A04UL, + /* 4098 */ 0x4F4A4132UL, + /* 409C */ 0x00000000UL, + /* 40A0 */ 0x00000000UL, + /* 40A4 */ 0x00000000UL, + /* 40A8 */ 0x00000000UL, + /* 40AC */ 0x00000000UL, + /* 40B0 */ 0x00000000UL, + /* 40B4 */ 0x00000000UL, + /* 40B8 */ 0x00000000UL, + /* 40BC */ 0x00000000UL, + /* 40C0 */ 0x00000000UL, + 0x010240E0UL, + 0x00000033UL, + /* 40E4 */ 0x00000000UL, + 0x010140ECUL, + 0x8C84B89BUL, + 0x010540F4UL, + 0x07830464UL, + /* 40F8 */ 0x3AC81388UL, + /* 40FC */ 0x000A209CUL, + /* 4100 */ 0x00206100UL, + /* 4104 */ 0x123556B7UL, + 0x0103410CUL, + 0x0011F778UL, + /* 4110 */ 0x29043020UL, + /* 4114 */ 0x4040BB88UL, + 0x01024124UL, + 0x00000000UL, + /* 4128 */ 0x00000000UL, + 0x010A4130UL, + 0x0C660664UL, + /* 4134 */ 0x0000010CUL, + /* 4138 */ 0x00FA53E8UL, + /* 413C */ 0x00000000UL, + /* 4140 */ 0x00000000UL, + /* 4144 */ 0x00000000UL, + /* 4148 */ 0x00000000UL, + /* 414C */ 0x00000000UL, + /* 4150 */ 0x00000000UL, + /* 4154 */ 0x00000101UL, + 0x01034168UL, + 0x07830464UL, + /* 416C */ 0x00821388UL, + /* 4170 */ 0x00000000UL, + 0x01044230UL, + 0x00000000UL, + /* 4234 */ 0x0E000000UL, + /* 4238 */ 0x00000000UL, + /* 423C */ 0x00000000UL, + 0x01024244UL, + 0x00000000UL, + /* 4248 */ 0x001F81F4UL, + 0x010C4254UL, + 0x00000000UL, + /* 4258 */ 0x003C0000UL, + /* 425C */ 0x00000000UL, + /* 4260 */ 0x00000000UL, + /* 4264 */ 0x55555555UL, + /* 4268 */ 0x00000017UL, + /* 426C */ 0x00000000UL, + /* 4270 */ 0x00000000UL, + /* 4274 */ 0x0006AAAAUL, + /* 4278 */ 0x00000000UL, + /* 427C */ 0x00000000UL, + /* 4280 */ 0x00000000UL, + 0x01018010UL, + 0x00000003UL, + 0x01028038UL, + 0x00103EC5UL, + /* 803C */ 0x00000001UL, + 0x0103809CUL, + 0x00000000UL, + /* 80A0 */ 0x00037870UL, + /* 80A4 */ 0x000000D0UL, + 0x110180A8UL, + 0x000001F0UL, + 0x310180A8UL, + 0x01CB4205UL, + 0x110180ACUL, + 0x000001F0UL, + 0x310180ACUL, + 0x00FD3E05UL, + 0x010280B0UL, + 0x02000300UL, + /* 80B4 */ 0x01000037UL, + 0x02020098UL, + 0x04000C00UL, + /* 009C */ 0x0000004CUL, + 0x020100A4UL, + 0x00000400UL, + 0x020200D0UL, + 0xAA400005UL, + /* 00D4 */ 0x00000188UL, + 0x020100E4UL, + 0x11512C6CUL, + 0x020200F4UL, + 0x00000000UL, + /* 00F8 */ 0x1108213DUL, + 0x120100FCUL, + 0x0000003FUL, + 0x320100FCUL, + 0x00045400UL, + 0x02010130UL, + 0x02510060UL, + 0x02010154UL, + 0x00003FC4UL, + 0x02010168UL, + 0x00000400UL, + 0x03014FFCUL, + (uint32_t)&phyInfo, + 0xFFFFFFFFUL, +}; + +const RAIL_ChannelConfigEntry_t Protocol_Configuration_channels[] = { + { + .phyConfigDeltaAdd = NULL, + .baseFrequency = 2450000000, + .channelSpacing = 1000000, + .physicalChannelOffset = 0, + .channelNumberStart = 0, + .channelNumberEnd = 20, + .maxPower = RAIL_TX_POWER_MAX, + .attr = &channelConfigEntryAttr, +#ifdef RADIO_CONFIG_ENABLE_CONC_PHY + .entryType = 0, +#endif +#ifdef RADIO_CONFIG_ENABLE_STACK_INFO + .stackInfo = NULL, +#endif + }, +}; + +const RAIL_ChannelConfig_t Protocol_Configuration_channelConfig = { + .phyConfigBase = Protocol_Configuration_modemConfigBase, + .phyConfigDeltaSubtract = NULL, + .configs = Protocol_Configuration_channels, + .length = 1U, + .signature = 0UL, +}; + +const RAIL_ChannelConfig_t *channelConfigs[] = {&Protocol_Configuration_channelConfig, NULL}; + +#ifdef RADIO_CONFIG_ENABLE_STACK_INFO +#endif // RADIO_CONFIG_ENABLE_STACK_INFO + +uint32_t protocolAccelerationBuffer[303]; diff --git a/examples/proprietary_trx/src/config/rail/efr32bg22_brd4184b/rail_config.h b/examples/proprietary_trx/src/config/rail/efr32bg22_brd4184b/rail_config.h new file mode 100644 index 00000000..f8123e0a --- /dev/null +++ b/examples/proprietary_trx/src/config/rail/efr32bg22_brd4184b/rail_config.h @@ -0,0 +1,52 @@ +/***************************************************************************//** + * @brief RAIL Configuration + * @details + * WARNING: Auto-Generated Radio Config - DO NOT EDIT + * Radio Configurator Version: 2022.5.2 + * RAIL Adapter Version: 2.4.19 + * RAIL Compatibility: 2.x + ******************************************************************************* + * # License + * Copyright 2019 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef __RAIL_CONFIG_H__ +#define __RAIL_CONFIG_H__ + +#include +#include "rail_types.h" + +#define PROTOCOL_ACCELERATION_BUFFER protocolAccelerationBuffer +extern uint32_t protocolAccelerationBuffer[]; +#define RADIO_CONFIG_XTAL_FREQUENCY 38400000UL + +#define RAIL0_CHANNEL_GROUP_1_PHY_DATASHEET_2450M_2GFSK_1MBPS_500K +#define RAIL0_CHANNEL_GROUP_1_PROFILE_BASE +extern const RAIL_ChannelConfig_t *channelConfigs[]; + +#ifdef RADIO_CONFIG_ENABLE_STACK_INFO +#endif // RADIO_CONFIG_ENABLE_STACK_INFO + +#endif // __RAIL_CONFIG_H__ diff --git a/examples/proprietary_trx/src/config/rail/efr32bg27_brd2602a/radio_settings.radioconf b/examples/proprietary_trx/src/config/rail/efr32bg27_brd2602a/radio_settings.radioconf new file mode 100644 index 00000000..796e5d37 --- /dev/null +++ b/examples/proprietary_trx/src/config/rail/efr32bg27_brd2602a/radio_settings.radioconf @@ -0,0 +1,18 @@ + + + + + + + 0 + 20 + SAME_AS_FIRST_CHANNEL + RAIL_TX_POWER_MAX + {"selectedPhy":"PHY_Datasheet_2450M_2GFSK_1Mbps_500K"} + + + {"selectedPhy":"PHY_Datasheet_2450M_2GFSK_1Mbps_500K"} + + + + \ No newline at end of file diff --git a/examples/proprietary_trx/src/config/rail/efr32bg27_brd2602a/rail_config.c b/examples/proprietary_trx/src/config/rail/efr32bg27_brd2602a/rail_config.c new file mode 100644 index 00000000..ab176c9f --- /dev/null +++ b/examples/proprietary_trx/src/config/rail/efr32bg27_brd2602a/rail_config.c @@ -0,0 +1,291 @@ +/***************************************************************************//** + * @brief RAIL Configuration + * @details + * WARNING: Auto-Generated Radio Config - DO NOT EDIT + * Radio Configurator Version: 2302.5.1 + * RAIL Adapter Version: 2.4.31 + * RAIL Compatibility: 2.x + ******************************************************************************* + * # License + * Copyright 2019 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ +#include "em_device.h" +#include "rail_config.h" + +uint32_t RAILCb_CalcSymbolRate(RAIL_Handle_t railHandle) +{ + (void) railHandle; + return 0U; +} + +uint32_t RAILCb_CalcBitRate(RAIL_Handle_t railHandle) +{ + (void) railHandle; + return 0U; +} + +void RAILCb_ConfigFrameTypeLength(RAIL_Handle_t railHandle, + const RAIL_FrameType_t *frameType) +{ + (void) railHandle; + (void) frameType; +} + +static const uint8_t irCalConfig[] = { + 25, 63, 1, 6, 4, 16, 1, 0, 0, 1, 1, 6, 0, 16, 39, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0 +}; + +static const int32_t timingConfig[] = { + 0, 0, 0 +}; + +static const uint8_t hfxoRetimingConfigEntries[] = { + 2, 0, 0, 0, 0x00, 0xf0, 0x49, 0x02, 6, 20, 0, 0, 0x00, 0xe0, 0x93, 0x04, 5, 56, 0, 0, 0xa0, 0x08, 0, 0, 0, 0, 0x58, 0x09, 1, 4, 7, 6, 0x10, 0x0a, 1, 4, 7, 7, 0xc8, 0x0a, 0, 4, 8, 7, 0x80, 0x0b, 0, 4, 8, 8, 0x38, 0x0c, 0, 4, 9, 8, 0x61, 0x08, 0, 0, 0, 0, 0x68, 0x08, 0, 0, 0, 0, 0xc7, 0x09, 1, 4, 4, 3, 0x2c, 0x0b, 1, 4, 4, 4, 0x92, 0x0c, 1, 4, 5, 4 +}; + +static RAIL_ChannelConfigEntryAttr_t channelConfigEntryAttr = { +#if RAIL_SUPPORTS_OFDM_PA + { + { 0xFFFFFFFFUL }, + { 0xFFFFFFFFUL, 0xFFFFFFFFUL } + } +#else // RAIL_SUPPORTS_OFDM_PA + { 0xFFFFFFFFUL }, +#endif // RAIL_SUPPORTS_OFDM_PA +}; + +static const uint32_t phyInfo[] = { + 16UL, + 0x00924924UL, // 146.28571428571428 + (uint32_t) NULL, + (uint32_t) irCalConfig, + (uint32_t) timingConfig, + 0x00000000UL, + 8000000UL, + 28000000UL, + 1000000UL, + 0x00F40101UL, + 0x02503EC5UL, + (uint32_t) NULL, + (uint32_t) hfxoRetimingConfigEntries, + (uint32_t) NULL, + 0UL, + 0UL, + 999997UL, + (uint32_t) NULL, + (uint32_t) NULL, + (uint32_t) NULL, +}; + +const uint32_t Protocol_Configuration_modemConfigBase[] = { + 0x0002400CUL, 0x00000000UL, + /* 4010 */ 0x00004000UL, + 0x00024020UL, 0x0000000FUL, + /* 4024 */ 0x00000000UL, + 0x00074030UL, 0x00000000UL, + /* 4034 */ 0x00000000UL, + /* 4038 */ 0x00000000UL, + /* 403C */ 0x00000000UL, + /* 4040 */ 0x00000000UL, + /* 4044 */ 0x00004000UL, + /* 4048 */ 0x03040700UL, + 0x00014050UL, 0x00000000UL, + 0x0002405CUL, 0x00000000UL, + /* 4060 */ 0x00000000UL, + 0x000140A8UL, 0x00000000UL, + 0x000440BCUL, 0x00000000UL, + /* 40C0 */ 0x00000000UL, + /* 40C4 */ 0x00000000UL, + /* 40C8 */ 0x00000000UL, + 0x00044104UL, 0x00004CFFUL, + /* 4108 */ 0x00000000UL, + /* 410C */ 0x00004DFFUL, + /* 4110 */ 0x00000000UL, + 0x1001C020UL, 0x0007F800UL, + 0x3001C020UL, 0x000802F5UL, + 0x0008C024UL, 0x00001300UL, + /* C028 */ 0x83B380ECUL, + /* C02C */ 0x51407543UL, + /* C030 */ 0x48000FA0UL, + /* C034 */ 0x00004030UL, + /* C038 */ 0x00000000UL, + /* C03C */ 0x00000000UL, + /* C040 */ 0x0000022EUL, + 0x0004C050UL, 0x04301151UL, + /* C054 */ 0xE6092D0EUL, + /* C058 */ 0x08070654UL, + /* C05C */ 0x0002B6D1UL, + 0x000AC064UL, 0x1C003004UL, + /* C068 */ 0x09183040UL, + /* C06C */ 0x2079640DUL, + /* C070 */ 0x01FBFCEBUL, + /* C074 */ 0x03E8F67FUL, + /* C078 */ 0x15724BBDUL, + /* C07C */ 0x0518A311UL, + /* C080 */ 0x76543210UL, + /* C084 */ 0x00000A98UL, + /* C088 */ 0x00000000UL, + 0x01010008UL, 0x00000744UL, + 0x01010018UL, 0x00000000UL, + 0x01010020UL, 0x0000A001UL, + 0x0108401CUL, 0x00000010UL, + /* 4020 */ 0x04000000UL, + /* 4024 */ 0x0002C00FUL, + /* 4028 */ 0x00005000UL, + /* 402C */ 0x000C1000UL, + /* 4030 */ 0x03000000UL, + /* 4034 */ 0x00000000UL, + /* 4038 */ 0x00000000UL, + 0x01064058UL, 0x00FF04C8UL, + /* 405C */ 0x00000C41UL, + /* 4060 */ 0x00000001UL, + /* 4064 */ 0x00140012UL, + /* 4068 */ 0x0000B16FUL, + /* 406C */ 0x00000000UL, + 0x01114080UL, 0x13C00714UL, + /* 4084 */ 0x00000000UL, + /* 4088 */ 0x003B03F1UL, + /* 408C */ 0x00000000UL, + /* 4090 */ 0x00000000UL, + /* 4094 */ 0x22140A04UL, + /* 4098 */ 0x4F4A4132UL, + /* 409C */ 0x00000000UL, + /* 40A0 */ 0x00000000UL, + /* 40A4 */ 0x00000000UL, + /* 40A8 */ 0x00000000UL, + /* 40AC */ 0x00000000UL, + /* 40B0 */ 0x00000000UL, + /* 40B4 */ 0x00000000UL, + /* 40B8 */ 0x00000000UL, + /* 40BC */ 0x00000000UL, + /* 40C0 */ 0x00000000UL, + 0x010240E0UL, 0x00000033UL, + /* 40E4 */ 0x00000000UL, + 0x010140ECUL, 0x8C84B89BUL, + 0x010540F4UL, 0x07830464UL, + /* 40F8 */ 0x3AC81388UL, + /* 40FC */ 0x000A209CUL, + /* 4100 */ 0x00206100UL, + /* 4104 */ 0x123556B7UL, + 0x0103410CUL, 0x0011F778UL, + /* 4110 */ 0x29043020UL, + /* 4114 */ 0x4040BB88UL, + 0x01024124UL, 0x00000000UL, + /* 4128 */ 0x00000000UL, + 0x010A4130UL, 0x0C660664UL, + /* 4134 */ 0x0000010CUL, + /* 4138 */ 0x00FA53E8UL, + /* 413C */ 0x00000000UL, + /* 4140 */ 0x00000000UL, + /* 4144 */ 0x00000000UL, + /* 4148 */ 0x00000000UL, + /* 414C */ 0x00000000UL, + /* 4150 */ 0x00000000UL, + /* 4154 */ 0x00000101UL, + 0x01034168UL, 0x07830464UL, + /* 416C */ 0x00821388UL, + /* 4170 */ 0x00000000UL, + 0x01044230UL, 0x00000000UL, + /* 4234 */ 0x0E000000UL, + /* 4238 */ 0x00000000UL, + /* 423C */ 0x00000000UL, + 0x01024244UL, 0x00000000UL, + /* 4248 */ 0x001F81F4UL, + 0x010C4254UL, 0x00000000UL, + /* 4258 */ 0x003C0000UL, + /* 425C */ 0x00000000UL, + /* 4260 */ 0x00000000UL, + /* 4264 */ 0x55555555UL, + /* 4268 */ 0x00000017UL, + /* 426C */ 0x00000000UL, + /* 4270 */ 0x00000000UL, + /* 4274 */ 0x0006AAAAUL, + /* 4278 */ 0x00000000UL, + /* 427C */ 0x00000000UL, + /* 4280 */ 0x00000002UL, + 0x01018010UL, 0x00000003UL, + 0x01028038UL, 0x00103EC5UL, + /* 803C */ 0x00000001UL, + 0x0103809CUL, 0x00000000UL, + /* 80A0 */ 0x00037870UL, + /* 80A4 */ 0x000000D0UL, + 0x110180A8UL, 0x000001F0UL, + 0x310180A8UL, 0x01CB4205UL, + 0x110180ACUL, 0x000001F0UL, + 0x310180ACUL, 0x00FD3E05UL, + 0x010280B0UL, 0x02000300UL, + /* 80B4 */ 0x01000037UL, + 0x02020098UL, 0x04000C00UL, + /* 009C */ 0x0000004CUL, + 0x020100A4UL, 0x00000400UL, + 0x020200D0UL, 0xAA400005UL, + /* 00D4 */ 0x00000188UL, + 0x020100E4UL, 0x11512C6CUL, + 0x020200F4UL, 0x00000000UL, + /* 00F8 */ 0x1108233DUL, + 0x120100FCUL, 0x0000003FUL, + 0x320100FCUL, 0x00045400UL, + 0x02010130UL, 0x02510060UL, + 0x02010154UL, 0x00003FC4UL, + 0x02010168UL, 0x00000400UL, + 0x03014FFCUL, (uint32_t) &phyInfo, + 0xFFFFFFFFUL, +}; + +const RAIL_ChannelConfigEntry_t Protocol_Configuration_channels[] = { + { + .phyConfigDeltaAdd = NULL, + .baseFrequency = 2450000000, + .channelSpacing = 1000000, + .physicalChannelOffset = 0, + .channelNumberStart = 0, + .channelNumberEnd = 20, + .maxPower = RAIL_TX_POWER_MAX, + .attr = &channelConfigEntryAttr, +#ifdef RADIO_CONFIG_ENABLE_CONC_PHY + .entryType = 0, +#endif +#ifdef RADIO_CONFIG_ENABLE_STACK_INFO + .stackInfo = NULL, +#endif + .alternatePhy = NULL, + }, +}; + +const RAIL_ChannelConfig_t Protocol_Configuration_channelConfig = { + .phyConfigBase = Protocol_Configuration_modemConfigBase, + .phyConfigDeltaSubtract = NULL, + .configs = Protocol_Configuration_channels, + .length = 1U, + .signature = 0UL, + .xtalFrequencyHz = 38400000UL, +}; + +const RAIL_ChannelConfig_t *channelConfigs[] = { + &Protocol_Configuration_channelConfig, + NULL +}; + +uint32_t protocolAccelerationBuffer[303]; diff --git a/examples/proprietary_trx/src/config/rail/efr32bg27_brd2602a/rail_config.h b/examples/proprietary_trx/src/config/rail/efr32bg27_brd2602a/rail_config.h new file mode 100644 index 00000000..3b733872 --- /dev/null +++ b/examples/proprietary_trx/src/config/rail/efr32bg27_brd2602a/rail_config.h @@ -0,0 +1,50 @@ +/***************************************************************************//** + * @brief RAIL Configuration + * @details + * WARNING: Auto-Generated Radio Config Header - DO NOT EDIT + * Radio Configurator Version: 2302.5.1 + * RAIL Adapter Version: 2.4.31 + * RAIL Compatibility: 2.x + ******************************************************************************* + * # License + * Copyright 2019 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef __RAIL_CONFIG_H__ +#define __RAIL_CONFIG_H__ + +#include +#include "rail_types.h" + +#define PROTOCOL_ACCELERATION_BUFFER protocolAccelerationBuffer +extern uint32_t protocolAccelerationBuffer[]; + +#define RADIO_CONFIG_XTAL_FREQUENCY 38400000UL + +#define RAIL0_CHANNEL_GROUP_1_PHY_DATASHEET_2450M_2GFSK_1MBPS_500K +#define RAIL0_CHANNEL_GROUP_1_PROFILE_BASE +extern const RAIL_ChannelConfig_t *channelConfigs[]; + +#endif // __RAIL_CONFIG_H__ diff --git a/examples/proprietary_trx/src/config/rail/efr32xg24_dk2601b/radio_settings.radioconf b/examples/proprietary_trx/src/config/rail/efr32xg24_dk2601b/radio_settings.radioconf new file mode 100644 index 00000000..dfb42b02 --- /dev/null +++ b/examples/proprietary_trx/src/config/rail/efr32xg24_dk2601b/radio_settings.radioconf @@ -0,0 +1,18 @@ + + + + + + + 0 + 20 + SAME_AS_FIRST_CHANNEL + RAIL_TX_POWER_MAX + {"selectedPhy":"PHY_Studio_2450M_2GFSK_1Mbps_500K"} + + + {"selectedPhy":"PHY_Studio_2450M_2GFSK_1Mbps_500K"} + + + + \ No newline at end of file diff --git a/examples/proprietary_trx/src/config/rail/efr32xg24_dk2601b/rail_config.c b/examples/proprietary_trx/src/config/rail/efr32xg24_dk2601b/rail_config.c new file mode 100644 index 00000000..6ea24946 --- /dev/null +++ b/examples/proprietary_trx/src/config/rail/efr32xg24_dk2601b/rail_config.c @@ -0,0 +1,366 @@ +/***************************************************************************//** + * @brief RAIL Configuration + * @details + * WARNING: Auto-Generated Radio Config - DO NOT EDIT + * Radio Configurator Version: 2022.5.2 + * RAIL Adapter Version: 2.4.19 + * RAIL Compatibility: 2.x + ******************************************************************************* + * # License + * Copyright 2019 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ +#include "em_device.h" +#include "rail_config.h" + +uint32_t RAILCb_CalcSymbolRate(RAIL_Handle_t railHandle) +{ + (void) railHandle; + return 0U; +} + +uint32_t RAILCb_CalcBitRate(RAIL_Handle_t railHandle) +{ + (void) railHandle; + return 0U; +} + +void RAILCb_ConfigFrameTypeLength(RAIL_Handle_t railHandle, + const RAIL_FrameType_t *frameType) +{ + (void) railHandle; + (void) frameType; +} + +static const uint8_t irCalConfig[] = { + 25, 63, 1, 6, 4, 16, 1, 0, 0, 1, 1, 6, 0, 16, 39, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0 +}; + +static const int32_t timingConfig[] = { + 8000, 8000, 0 +}; + +static const uint8_t hfxoRetimingConfigEntries[] = { + 2, 0, 0, 0, 0xc0, 0x17, 0x53, 0x02, 6, 20, 0, 0, 0x80, 0x2f, 0xa6, 0x04, 5, 56, 0, 0, 0xa0, 0x08, 0, 0, 0, 0, 0x58, 0x09, 1, 4, 7, 6, 0x10, 0x0a, 1, 4, 7, 7, 0xc8, 0x0a, 0, 4, 8, 7, 0x80, 0x0b, 0, 4, 8, 8, 0x38, 0x0c, 0, 4, 9, 8, 0x61, 0x08, 0, 0, 0, 0, 0x8a, 0x08, 0, 0, 0, 0, 0xc7, 0x09, 1, 4, 4, 3, 0x2c, 0x0b, 1, 4, 4, 4, 0x92, 0x0c, 1, 4, 5, 4 +}; + +static RAIL_ChannelConfigEntryAttr_t channelConfigEntryAttr = { +#if RAIL_SUPPORTS_OFDM_PA + { +#ifdef RADIO_CONFIG_ENABLE_IRCAL_MULTIPLE_RF_PATHS + { 0xFFFFFFFFUL, 0xFFFFFFFFUL, }, +#else + { 0xFFFFFFFFUL }, +#endif // RADIO_CONFIG_ENABLE_IRCAL_MULTIPLE_RF_PATHS + { 0xFFFFFFFFUL, 0xFFFFFFFFUL } + } +#else // RAIL_SUPPORTS_OFDM_PA +#ifdef RADIO_CONFIG_ENABLE_IRCAL_MULTIPLE_RF_PATHS + { 0xFFFFFFFFUL, 0xFFFFFFFFUL, }, +#else + { 0xFFFFFFFFUL }, +#endif // RADIO_CONFIG_ENABLE_IRCAL_MULTIPLE_RF_PATHS +#endif // RAIL_SUPPORTS_OFDM_PA +}; + +static const uint32_t phyInfo[] = { + 13UL, + 0x00444444UL, // 68.26666666666667 + (uint32_t) NULL, + (uint32_t) irCalConfig, + (uint32_t) timingConfig, + 0x00000000UL, + 0UL, + 36000000UL, + 1000000UL, + 0x00F80101UL, + 0x021039C3UL, + (uint32_t) NULL, + (uint32_t) hfxoRetimingConfigEntries, + (uint32_t) NULL, + 0UL, + 0UL, + 1000002UL, + (uint32_t) NULL, + (uint32_t) NULL, +}; + +const uint32_t Protocol_Configuration_modemConfigBase[] = { + 0x0002400CUL, 0x00000000UL, + /* 4010 */ 0x00004000UL, + 0x00024020UL, 0x0000000FUL, + /* 4024 */ 0x00000000UL, + 0x00074030UL, 0x00000000UL, + /* 4034 */ 0x00000000UL, + /* 4038 */ 0x00000000UL, + /* 403C */ 0x00000000UL, + /* 4040 */ 0x00000000UL, + /* 4044 */ 0x00004000UL, + /* 4048 */ 0x03000700UL, + 0x00014050UL, 0x00000000UL, + 0x0002405CUL, 0x00000000UL, + /* 4060 */ 0x00000000UL, + 0x000140A8UL, 0x00000007UL, + 0x000440BCUL, 0x00000000UL, + /* 40C0 */ 0x00000000UL, + /* 40C4 */ 0x00000000UL, + /* 40C8 */ 0x00000000UL, + 0x00044108UL, 0x00004CFFUL, + /* 410C */ 0x00000000UL, + /* 4110 */ 0x00004DFFUL, + /* 4114 */ 0x00000000UL, + 0x1001C020UL, 0x0007F800UL, + 0x3001C020UL, 0x012801FEUL, + 0x0009C024UL, 0x00001300UL, + /* C028 */ 0x03B380ECUL, + /* C02C */ 0x51407543UL, + /* C030 */ 0xF8000FA0UL, + /* C034 */ 0x00004000UL, + /* C038 */ 0x0007AAA8UL, + /* C03C */ 0x00000000UL, + /* C040 */ 0x00000000UL, + /* C044 */ 0x00000000UL, + 0x0010C054UL, 0x00302151UL, + /* C058 */ 0xE6110012UL, + /* C05C */ 0x00000036UL, + /* C060 */ 0x100F0E0AUL, + /* C064 */ 0x00000011UL, + /* C068 */ 0x0002C688UL, + /* C06C */ 0x00000520UL, + /* C070 */ 0x000010BAUL, + /* C074 */ 0x00200400UL, + /* C078 */ 0x00801804UL, + /* C07C */ 0x01203C0BUL, + /* C080 */ 0x02107C18UL, + /* C084 */ 0x06E0FC2FUL, + /* C088 */ 0x0000007FUL, + /* C08C */ 0x00000000UL, + /* C090 */ 0x00000000UL, + 0x0005C0A8UL, 0x15724BBDUL, + /* C0AC */ 0x0518A311UL, + /* C0B0 */ 0x76543210UL, + /* C0B4 */ 0x00000A98UL, + /* C0B8 */ 0x00000000UL, + 0x0004C0CCUL, 0x00000001UL, + /* C0D0 */ 0x00000000UL, + /* C0D4 */ 0x000A0001UL, + /* C0D8 */ 0x00280001UL, + 0x01010008UL, 0x00000744UL, + 0x01010018UL, 0x00000000UL, + 0x01010020UL, 0x0000A001UL, + 0x01254040UL, 0x70400000UL, + /* 4044 */ 0x00000000UL, + /* 4048 */ 0x00000010UL, + /* 404C */ 0x04000000UL, + /* 4050 */ 0x0082C00FUL, + /* 4054 */ 0x20000000UL, + /* 4058 */ 0x00000000UL, + /* 405C */ 0x03000000UL, + /* 4060 */ 0x20000000UL, + /* 4064 */ 0x00000000UL, + /* 4068 */ 0x00F804B9UL, + /* 406C */ 0x00000C40UL, + /* 4070 */ 0x00000008UL, + /* 4074 */ 0x00140012UL, + /* 4078 */ 0x0000B16FUL, + /* 407C */ 0x00000000UL, + /* 4080 */ 0x00000E7CUL, + /* 4084 */ 0x00000000UL, + /* 4088 */ 0x002A03F1UL, + /* 408C */ 0x62040000UL, + /* 4090 */ 0x00000000UL, + /* 4094 */ 0x22140A04UL, + /* 4098 */ 0x4F4A4132UL, + /* 409C */ 0x00000000UL, + /* 40A0 */ 0x00000000UL, + /* 40A4 */ 0x00000000UL, + /* 40A8 */ 0x00000000UL, + /* 40AC */ 0x00000000UL, + /* 40B0 */ 0x00000000UL, + /* 40B4 */ 0x00000000UL, + /* 40B8 */ 0x00000000UL, + /* 40BC */ 0x00000000UL, + /* 40C0 */ 0x00000000UL, + /* 40C4 */ 0x00000000UL, + /* 40C8 */ 0x00000000UL, + /* 40CC */ 0x00000000UL, + /* 40D0 */ 0x00000000UL, + 0x010140E0UL, 0x00000200UL, + 0x01024110UL, 0x00051E33UL, + /* 4114 */ 0x00000000UL, + 0x010E411CUL, 0x8C416000UL, + /* 4120 */ 0x00000000UL, + /* 4124 */ 0x078304FFUL, + /* 4128 */ 0x3AC81388UL, + /* 412C */ 0x0C6606FFUL, + /* 4130 */ 0x078304FFUL, + /* 4134 */ 0x03FF1388UL, + /* 4138 */ 0xF00A20BCUL, + /* 413C */ 0x005160EBUL, + /* 4140 */ 0x40A46503UL, + /* 4144 */ 0x55F68D00UL, + /* 4148 */ 0x42A832A4UL, + /* 414C */ 0x00403B89UL, + /* 4150 */ 0x800003C0UL, + 0x01024158UL, 0x00000000UL, + /* 415C */ 0x0000FDFFUL, + 0x010D4164UL, 0x0000010CUL, + /* 4168 */ 0x00FA53E8UL, + /* 416C */ 0x40000000UL, + /* 4170 */ 0x00000000UL, + /* 4174 */ 0x00000000UL, + /* 4178 */ 0x00000000UL, + /* 417C */ 0x00000000UL, + /* 4180 */ 0x00000000UL, + /* 4184 */ 0x00000101UL, + /* 4188 */ 0x00000000UL, + /* 418C */ 0x00000000UL, + /* 4190 */ 0x00000000UL, + /* 4194 */ 0x00000000UL, + 0x010241A4UL, 0x00000000UL, + /* 41A8 */ 0x00000000UL, + 0x010241B0UL, 0x00000000UL, + /* 41B4 */ 0xC03795E0UL, + 0x010341BCUL, 0x00000000UL, + /* 41C0 */ 0x003C0000UL, + /* 41C4 */ 0x00069069UL, + 0x010341D0UL, 0x55555555UL, + /* 41D4 */ 0x806E01E6UL, + /* 41D8 */ 0x00AA0006UL, + 0x011641E0UL, 0x00000000UL, + /* 41E4 */ 0x30DF0C02UL, + /* 41E8 */ 0x00319E2EUL, + /* 41EC */ 0x00161801UL, + /* 41F0 */ 0x0002939DUL, + /* 41F4 */ 0x0DF03A13UL, + /* 41F8 */ 0x04687FA9UL, + /* 41FC */ 0x2CE524B3UL, + /* 4200 */ 0x30DF0C02UL, + /* 4204 */ 0x00319E2EUL, + /* 4208 */ 0x00161801UL, + /* 420C */ 0x0002939DUL, + /* 4210 */ 0x0DF03A13UL, + /* 4214 */ 0x04687FA9UL, + /* 4218 */ 0x2CE524B3UL, + /* 421C */ 0x80000000UL, + /* 4220 */ 0x00000000UL, + /* 4224 */ 0x00000040UL, + /* 4228 */ 0x00000000UL, + /* 422C */ 0x40001860UL, + /* 4230 */ 0x00000000UL, + /* 4234 */ 0x00000000UL, + 0x0101423CUL, 0x00000000UL, + 0x01034244UL, 0x00000014UL, + /* 4248 */ 0x00000000UL, + /* 424C */ 0x04050008UL, + 0x01014268UL, 0x00000000UL, + 0x01024280UL, 0x00000000UL, + /* 4284 */ 0x00000081UL, + 0x01054298UL, 0x0200003FUL, + /* 429C */ 0x0000FFFFUL, + /* 42A0 */ 0x0000FFFFUL, + /* 42A4 */ 0x000003FFUL, + /* 42A8 */ 0x0000FFFFUL, + 0x010142B4UL, 0x00000000UL, + 0x010A4330UL, 0x01200040UL, + /* 4334 */ 0x000000A0UL, + /* 4338 */ 0x01005008UL, + /* 433C */ 0x1F1F1F1FUL, + /* 4340 */ 0x1B1F1F1FUL, + /* 4344 */ 0x11131518UL, + /* 4348 */ 0x0C0D0E10UL, + /* 434C */ 0x2F87C145UL, + /* 4350 */ 0x00000000UL, + /* 4354 */ 0x00000000UL, + 0x01018010UL, 0x00000003UL, + 0x01028038UL, 0x001039C3UL, + /* 803C */ 0x00000001UL, + 0x0103809CUL, 0x00000000UL, + /* 80A0 */ 0x00037870UL, + /* 80A4 */ 0x0000C0D5UL, + 0x110180A8UL, 0x000001F0UL, + 0x310180A8UL, 0x01CB4205UL, + 0x110180ACUL, 0x000001F0UL, + 0x310180ACUL, 0x008D2205UL, + 0x010280B0UL, 0x02000300UL, + /* 80B4 */ 0x01000037UL, + 0x0201009CUL, 0x04000C00UL, + 0x020300D8UL, 0xAA400005UL, + /* 00DC */ 0x00000188UL, + /* 00E0 */ 0x000000C0UL, + 0x120100ECUL, 0x00000FE0UL, + 0x320100ECUL, 0x1151200CUL, + 0x020100F0UL, 0x0000012BUL, + 0x12010110UL, 0x000FFF00UL, + 0x32010110UL, 0x31000002UL, + 0x12010150UL, 0x0001C000UL, + 0x32010150UL, 0x00A200C1UL, + 0x02010174UL, 0x019BF169UL, + 0x12010178UL, 0x001C0000UL, + 0x32010178UL, 0x1FE00410UL, + 0x12010180UL, 0x00000779UL, + 0x32010180UL, 0x00000002UL, + 0x02020184UL, 0x00000000UL, + /* 0188 */ 0x00000050UL, + 0x03014FFCUL, (uint32_t) &phyInfo, + 0xFFFFFFFFUL, +}; + +const RAIL_ChannelConfigEntry_t Protocol_Configuration_channels[] = { + { + .phyConfigDeltaAdd = NULL, + .baseFrequency = 2450000000, + .channelSpacing = 1000000, + .physicalChannelOffset = 0, + .channelNumberStart = 0, + .channelNumberEnd = 20, + .maxPower = RAIL_TX_POWER_MAX, + .attr = &channelConfigEntryAttr, +#ifdef RADIO_CONFIG_ENABLE_CONC_PHY + .entryType = 0, +#endif +#ifdef RADIO_CONFIG_ENABLE_STACK_INFO + .stackInfo = NULL, +#endif + }, +}; + +const RAIL_ChannelConfig_t Protocol_Configuration_channelConfig = { + .phyConfigBase = Protocol_Configuration_modemConfigBase, + .phyConfigDeltaSubtract = NULL, + .configs = Protocol_Configuration_channels, + .length = 1U, + .signature = 0UL, +}; + +const RAIL_ChannelConfig_t *channelConfigs[] = { + &Protocol_Configuration_channelConfig, + NULL +}; + + +#ifdef RADIO_CONFIG_ENABLE_STACK_INFO +#endif // RADIO_CONFIG_ENABLE_STACK_INFO + +uint32_t protocolAccelerationBuffer[435]; diff --git a/examples/proprietary_trx/src/config/rail/efr32xg24_dk2601b/rail_config.h b/examples/proprietary_trx/src/config/rail/efr32xg24_dk2601b/rail_config.h new file mode 100644 index 00000000..df211223 --- /dev/null +++ b/examples/proprietary_trx/src/config/rail/efr32xg24_dk2601b/rail_config.h @@ -0,0 +1,52 @@ +/***************************************************************************//** + * @brief RAIL Configuration + * @details + * WARNING: Auto-Generated Radio Config Header - DO NOT EDIT + * Radio Configurator Version: 2022.5.2 + * RAIL Adapter Version: 2.4.19 + * RAIL Compatibility: 2.x + ******************************************************************************* + * # License + * Copyright 2019 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef __RAIL_CONFIG_H__ +#define __RAIL_CONFIG_H__ + +#include +#include "rail_types.h" + +#define PROTOCOL_ACCELERATION_BUFFER protocolAccelerationBuffer +extern uint32_t protocolAccelerationBuffer[]; +#define RADIO_CONFIG_XTAL_FREQUENCY 39000000UL + +#define RAIL0_CHANNEL_GROUP_1_PHY_STUDIO_2450M_2GFSK_1MBPS_500K +#define RAIL0_CHANNEL_GROUP_1_PROFILE_BASE +extern const RAIL_ChannelConfig_t *channelConfigs[]; + +#ifdef RADIO_CONFIG_ENABLE_STACK_INFO +#endif // RADIO_CONFIG_ENABLE_STACK_INFO + +#endif // __RAIL_CONFIG_H__ diff --git a/examples/proprietary_trx/src/main.c b/examples/proprietary_trx/src/main.c new file mode 100644 index 00000000..09fe34c7 --- /dev/null +++ b/examples/proprietary_trx/src/main.c @@ -0,0 +1,203 @@ +/***************************************************************************//** + * @file main.c + * @brief Main file for the proprietary_trx example. + ******************************************************************************* + * # License + * Copyright 2024 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +// ----------------------------------------------------------------------------- +// Includes + +#include +#include +#include +#include +#include +#include +#include +#include +#include "rail.h" +#include "rail_types.h" +#include "pa_conversions_efr32.h" +#include "sl_rail_util_init.h" +#include "app_gpio.h" +#include "app_rail.h" +#include "main.h" + +// ----------------------------------------------------------------------------- +// Macros and Typedefs +LOG_MODULE_REGISTER(trx_app_log, LOG_LEVEL_INF); + +/* List of application states */ +enum radio_state { + INIT, + IDLE, + SEND, + SENT, + RECEIVE, + ERROR +}; + +// ----------------------------------------------------------------------------- +// Static Function Declarations + +static void init_run(void *o); +static void idle_run(void *o); +static void send_run(void *o); +static void sent_run(void *o); +static void received_run(void *o); +static void error_run(void *o); + +// ----------------------------------------------------------------------------- +// Global Variables + +// +struct s_prop_var s_sl_machine = {.led1 = GPIO_DT_SPEC_GET_OR(DT_ALIAS(led1), gpios, {0}), + .led0 = GPIO_DT_SPEC_GET_OR(DT_ALIAS(led0), gpios, {0}), + .button1 = GPIO_DT_SPEC_GET_OR(DT_ALIAS(sw1), gpios, {0}), + .button0 = GPIO_DT_SPEC_GET_OR(DT_ALIAS(sw0), gpios, {0})}; + +// ----------------------------------------------------------------------------- +// Static Variables + +static const struct smf_state radio_states[] = { + [INIT] = SMF_CREATE_STATE(NULL, init_run, NULL), + [IDLE] = SMF_CREATE_STATE(NULL, idle_run, NULL), + [SEND] = SMF_CREATE_STATE(NULL, send_run, NULL), + [SENT] = SMF_CREATE_STATE(NULL, sent_run, NULL), + [RECEIVE] = SMF_CREATE_STATE(NULL, received_run, NULL), + [ERROR] = SMF_CREATE_STATE(NULL, error_run, NULL), + +}; + +// ----------------------------------------------------------------------------- +// Public Function Definitions + +int main(void) +{ + uint8_t ret = 0; + uint32_t incoming_events = 0; + /* Initialize the event */ + k_event_init(&s_sl_machine.smf_event); + smf_set_initial(&s_sl_machine.ctx, &radio_states[INIT]); + + while (1) { + ret = smf_run_state(&s_sl_machine.ctx); + if (ret) { + return -1; + } + + /* Block until an event is detected */ + incoming_events = + k_event_wait(&s_sl_machine.smf_event, + (EVENT_REQUEST_SEND | EVENT_RADIO_SENT | EVENT_RADIO_RECEIVED | + EVENT_CLI_RECEIVE_SETTING | EVENT_RADIO_ERROR), + false, K_FOREVER); + + if (incoming_events & EVENT_REQUEST_SEND) { + smf_set_state(&s_sl_machine.ctx, &radio_states[SEND]); + } + if (incoming_events & EVENT_RADIO_SENT) { + smf_set_state(&s_sl_machine.ctx, &radio_states[SENT]); + } + if (incoming_events & EVENT_RADIO_RECEIVED) { + smf_set_state(&s_sl_machine.ctx, &radio_states[RECEIVE]); + } + if (incoming_events & EVENT_RADIO_ERROR) { + smf_set_state(&s_sl_machine.ctx, &radio_states[ERROR]); + } + } + return 0; +} + +// ----------------------------------------------------------------------------- +// Static Function Definitions + +static void init_run(void *o) +{ + RAIL_Version_t rail_version; + struct s_prop_var *s = o; + LOG_INF("INIT STATE"); + if (app_init_gpios(s)) { + LOG_ERR("LED and Button init failed!"); + } + app_rail_init(); + RAIL_GetVersion(&rail_version, 1); + printk("RAIL LIB version: %d.%d.%d\n", rail_version.major, rail_version.minor, + rail_version.rev); + printk(" HASH: %u\n", rail_version.hash); + printk("Press the button\n"); + s->packet_sent = true; + smf_set_state(&s->ctx, &radio_states[IDLE]); +} + +static void idle_run(void *o) +{ + struct s_prop_var *s = o; + LOG_INF("IDLE STATE"); + if (k_event_test(&(s->smf_event), EVENT_CLI_RECEIVE_SETTING)) { + set_continuous_rx(s->allow_rx); + k_event_clear(&(s->smf_event), EVENT_CLI_RECEIVE_SETTING); + } +} + +static void send_run(void *o) +{ + struct s_prop_var *s = o; + LOG_INF("SEND STATE"); + handle_send(&(s->packet_sent)); + smf_set_state(&s->ctx, &radio_states[IDLE]); + k_event_clear(&(s->smf_event), EVENT_REQUEST_SEND); +} + +static void sent_run(void *o) +{ + struct s_prop_var *s = o; + LOG_INF("SENT STATE"); + handle_sent(&(s->packet_sent)); + app_update_send_led(s); + smf_set_state(&s->ctx, &radio_states[IDLE]); + k_event_clear(&(s->smf_event), EVENT_RADIO_SENT); +} + +static void received_run(void *o) +{ + struct s_prop_var *s = o; + LOG_INF("RECEIVE STATE"); + handle_receive(); + app_update_receive_led(s); + smf_set_state(&s->ctx, &radio_states[IDLE]); + k_event_clear(&(s->smf_event), EVENT_RADIO_RECEIVED); +} + +static void error_run(void *o) +{ + struct s_prop_var *s = o; + LOG_INF("ERROR STATE"); + handle_error(&(s->error_code)); + smf_set_state(&s->ctx, &radio_states[IDLE]); + k_event_clear(&(s->smf_event), EVENT_RADIO_ERROR); +} diff --git a/examples/proprietary_trx/src/main.h b/examples/proprietary_trx/src/main.h new file mode 100644 index 00000000..3c39b91c --- /dev/null +++ b/examples/proprietary_trx/src/main.h @@ -0,0 +1,76 @@ +/***************************************************************************//** + * @file main.h + * @brief Main header file for the proprietary TRX example. + ******************************************************************************* + * # License + * Copyright 2024 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +#ifndef MAIN_H +#define MAIN_H + +// ----------------------------------------------------------------------------- +// Includes + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// ----------------------------------------------------------------------------- +// Macros and Typedefs + +// List of events +#define EVENT_REQUEST_SEND BIT(0) +#define EVENT_CLI_RECEIVE_SETTING BIT(1) +#define EVENT_RADIO_RECEIVED BIT(2) +#define EVENT_RADIO_SENT BIT(3) +#define EVENT_RADIO_ERROR BIT(4) + +// A structure to contain all state machine, event, radio and gpio variables +struct s_prop_var { + struct smf_ctx ctx; + struct gpio_callback button_cb_data; + struct k_event smf_event; + bool allow_rx; + bool packet_sent; + uint64_t error_code; + struct gpio_dt_spec led0; + struct gpio_dt_spec led1; + struct gpio_dt_spec button0; + struct gpio_dt_spec button1; +}; + +// ----------------------------------------------------------------------------- +// Global Variables + +extern struct s_prop_var s_sl_machine; + +#endif