### Setting RAIL TX Power and Starting RX Source: https://context7_llms Demonstrates how to set the transmit power in dBm for a specific RAIL handle and then initiate a receive operation on a designated channel. This includes examples of setting different power levels and using different channel configurations. ```c // Use a RAIL handle and channel to access the desired channel configuration entry. RAIL_SetTxPowerDbm(railHandle1, 100); // set 10.0 dBm TX power RAIL_StartRx(railHandle1, 0, &schedInfo); // RX using generated1_channels[2] RAIL_SetTxPowerDbm(railHandle1, 0); // set 0 dBm TX power RAIL_StartRx(railHandle1, 0, &schedInfo); // RX using generated1_channels[1] RAIL_StartRx(railHandle2, 0, &schedInfo); // RX using generated2_channels[0] ``` -------------------------------- ### Configure MFM Ping-Pong Buffers and Initialize Transmission Source: https://context7_llms Initializes MFM functionality by setting up ping-pong buffers with predefined data patterns, configuring state timing, enabling MFM data source, and starting transmission. The example demonstrates buffer population, RAIL configuration, and error handling with assertions for proper initialization. ```c #define MFM_RAW_BUF_WORDS 128 extern RAIL_Handle_t railHandle; uint8_t txCount = 0; uint32_t mfmPingPongBuffers[2][MFM_RAW_BUF_WORDS]; typedef struct mfmConfigApp { RAIL_MFM_PingPongBufferConfig_t buffer; RAIL_StateTiming_t timings; RAIL_DataConfig_t dataConfig; } mfmConfigApp_t; static mfmConfigApp_t mfmConfig = { .buffer = { .pBuffer0 = (&mfmPingPongBuffers[0]), .pBuffer1 = (&mfmPingPongBuffers[1]), .bufferSizeWords = MFM_RAW_BUF_WORDS, }, .timings = { .idleToTx = 100, .idleToRx = 0, .rxToTx = 0, .txToRx = 0, .rxSearchTimeout = 0, .txToRxSearchTimeout = 0 }, .dataConfig = { .txSource = TX_MFM_DATA, .rxSource = RX_PACKET_DATA, .txMethod = PACKET_MODE, .rxMethod = PACKET_MODE, }, }; void mfmInit(void) { uint32_t idx; uint32_t *pDst0 = mfmConfig.buffer.pBuffer0; uint32_t *pDst1 = mfmConfig.buffer.pBuffer1; for (idx = 0; idx < (mfmConfig.buffer.bufferSizeWords / 4); idx++) { pDst0[4 * idx + 0] = 0x755A3100; pDst1[4 * idx + 0] = 0x755A3100; pDst0[4 * idx + 1] = 0x315A757F; pDst1[4 * idx + 1] = 0x315A757F; pDst0[4 * idx + 2] = 0x8BA6CF00; pDst1[4 * idx + 2] = 0x8BA6CF00; pDst0[4 * idx + 3] = 0xCFA68B81; pDst1[4 * idx + 3] = 0xCFA68B81; } RAIL_Status_t status; status = RAIL_SetMfmPingPongFifo(railHandle, &mfmConfig.buffer); assert(status == RAIL_STATUS_NO_ERROR); status = RAIL_SetStateTiming(railHandle, &mfmConfig.timings); assert(status == RAIL_STATUS_NO_ERROR); mfmConfig.dataConfig.txSource = TX_MFM_DATA; status = RAIL_ConfigData(railHandle, &mfmConfig.dataConfig); assert(status == RAIL_STATUS_NO_ERROR); status = RAIL_StartTx(railHandle, 0, 0, NULL); assert(status == RAIL_STATUS_NO_ERROR); } ``` -------------------------------- ### Full Example: Test Auto-ACK Feature Source: https://context7_llms This example provides the necessary commands for both TX and RX nodes to test the Auto-ACK functionality. It includes setting up addresses, configuring for ACK requests, transmitting, and verifying the received ACK frame. ```shell // TX node rx 0 config2p4GHz802154 enable802154 rx 100 192 1000 setPanId802154 0x1234 setShortAddr802154 0x5678 settxpayload 0 0x0E 0x21 0x88 0x00 0x55 0x55 0xAA 0xAA 0x34 0x12 0x78 0x56 0x55 configTxOptions 1 rx 1 // RX node rx 0 config2p4GHz802154 enable802154 rx 100 192 1000 setPanId802154 0x5555 setShortAddr802154 0xAAAA rx 1 ``` -------------------------------- ### Full Example: Send and Receive Packet with Long Address Source: https://context7_llms This complete example illustrates the sequence of commands for both the transmitting (TX) and receiving (RX) nodes to establish communication using long 802.15.4 addresses. It includes configuration, setting addresses, and transmitting/receiving packets. ```shell // RX Node rx 0 config2p4GHz802154 enable802154 rx 100 192 1000 rx 1 setPanId802154 0x5555 setLongAddr802154 0x01 0x23 0x45 0x67 0x89 0xAB 0xCD 0xEF // TX Node rx 0 config2p4GHz802154 enable802154 rx 100 192 1000 rx 1 settxpayload 0 0x14 0x00 0x8C 0x00 0x55 0x55 0x01 0x23 0x45 0x67 settxpayload 10 0x89 0xAB 0xCD 0xEF 0x34 0x12 0x78 0x56 0x55 settxlength 19 ``` -------------------------------- ### Initialize RAIL Library Example (C) Source: https://context7_llms This C code snippet demonstrates the initialization of the RAIL (Radio Abstraction Interface Layer) library. It includes setting up communication parameters, event handlers, and state transitions necessary for radio operations. This example requires the 'rail.h' and 'rail_config.h' headers, with 'rail_config.h' being generated by the radio calculator. ```c #include "rail.h" #include "rail_config.h" // Generated by radio calculator #define TX_FIFO_SIZE (128) // Any power of 2 from [64, 4096] on the EFR32 static RAIL_Handle_t gRailHandle = NULL; static RAIL_TxPower_t txPower = 200; // Default to 20 dBm static uint8_t txFifo[TX_FIFO_SIZE]; static const RAIL_TxPowerConfig_t railTxPowerConfig = { // May be const // ... desired PA settings }; static void radioConfigChangedHandler(RAIL_Handle_t railHandle, const RAIL_ChannelConfigEntry_t *entry) { bool isSubgig = (entry->baseFrequency < 1000000000UL); // ... handle radio configuration change, e.g., select the desired PA possibly // using isSubgig to handle multiple configurations RAIL_ConfigTxPower(railHandle, &railTxPowerConfig); // The TX power must be reapplied after changing the PA above. RAIL_SetTxPowerDbm(railHandle, txPower); } static void radioEventHandler(RAIL_Handle_t railHandle, RAIL_Events_t events) { // ... handle RAIL events, e.g., receive and transmit completion } #if MULTIPROTOCOL static RAILSched_Config_t schedCfg; // Must never be const static RAIL_Config_t railCfg = { // Must never be const .eventsCallback = &radioEventHandler, .protocol = NULL, // For BLE, pointer to a RAIL_BLE_State_t .scheduler = &schedCfg, // For MultiProtocol, additional scheduler memory }; #else static RAIL_Config_t railCfg = { // Must never be const .eventsCallback = &radioEventHandler, .protocol = NULL, .scheduler = NULL, }; #endif // Initializes the radio out of startup so that it's ready to receive. void radioInitialize(void) { // Initializes the RAIL library and any internal state it requires. gRailHandle = RAIL_Init(&railCfg, NULL); // Configures calibration settings. RAIL_ConfigCal(gRailHandle, RAIL_CAL_ALL); // Configures radio according to the generated radio settings. RAIL_ConfigChannels(gRailHandle, channelConfigs[0], &radioConfigChangedHandler); // Configures the most useful callbacks and catches a few errors. RAIL_ConfigEvents(gRailHandle, RAIL_EVENTS_ALL, RAIL_EVENT_TX_PACKET_SENT | RAIL_EVENT_RX_PACKET_RECEIVED | RAIL_EVENT_RX_FRAME_ERROR // invalid CRC | RAIL_EVENT_RX_ADDRESS_FILTERED); // Sets automatic transitions to always receive once started. RAIL_StateTransitions_t railStateTransitions = { .success = RAIL_RF_STATE_RX, .error = RAIL_RF_STATE_RX, }; RAIL_SetRxTransitions(gRailHandle, &railStateTransitions); RAIL_SetTxTransitions(gRailHandle, &railStateTransitions); // Sets up the transmit buffer. RAIL_SetTxFifo(gRailHandle, txFifo, 0, TX_FIFO_SIZE); } ``` -------------------------------- ### Initialize and Use Sleep Timer API Source: https://docs.silabs.com/gecko-platform/latest/platform-service/sleeptimer Demonstrates the initialization of the sleep timer driver and starting a one-shot timer. The application must include 'sl_sleeptimer.h'. The timer uses a user-supplied callback function executed upon expiration. This example assumes proper initialization has already occurred. ```c #include "sl_sleeptimer.h" void my_timer_callback(sl_sleeptimer_timer_handle_t *handle, void *data) { //Code executed when the timer expire. } int start_timer(void) { sl_status_t status; sl_sleeptimer_timer_handle_t my_timer; uint32_t timer_timeout = 300; // We assume the sleeptimer is initialized properly status = sl_sleeptimer_start_timer(&my_timer, timer_timeout, my_timer_callback, (void *)NULL, 0, 0); if(status != SL_STATUS_OK) { return -1; } return 1; } ``` -------------------------------- ### WMBus Setup Frame Source: https://context7_llms Assembles a Wireless M-Bus frame into a provided buffer with specified parameters. ```APIDOC ## sl_rail_sdk_wmbus_setup_frame ### Description Populates a buffer to create a Wireless M-Bus frame, configuring its access number, accessibility, device type, sensor data, periodicity, and encryption status. ### Method N/A (This is a function call, not an HTTP endpoint) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example ```c #include "sl_rail_sdk_wmbus.h" // Include necessary headers uint8_t frameBuffer[256]; // Buffer for the WMBus frame uint8_t accessNumber = 1; sl_rail_sdk_wmbus_accessibility_t accessibility = SL_RAIL_SDK_WMBUS_ACCESSIBILITY_LIMITED_ACCESS; sl_rail_sdk_wmbus_device_type_t deviceType = SL_RAIL_SDK_WMBUS_TYPE_METER; // Example // Define sensor data (structure depends on sl_rail_sdk_wmbus_sensor_data_t definition) sl_rail_sdk_wmbus_sensor_data_t sensors[] = { ... }; bool isPeriodic = true; bool shouldEncrypt = false; uint16_t frameLength = sl_rail_sdk_wmbus_setup_frame( frameBuffer, accessNumber, accessibility, deviceType, sensors, // Pass pointer to array or single element as needed isPeriodic, shouldEncrypt ); // frameBuffer now contains the WMBus frame, and frameLength is its size. ``` ### Response #### Success Response (uint16_t) - **frameLength** (uint16_t) - The length of the assembled Wireless M-Bus frame in bytes. #### Response Example ```c // If the frame was successfully assembled to 42 bytes: // returned value would be 42 ``` ``` -------------------------------- ### Dynamic Multiprotocol (DMP) Setup Configuration Source: https://context7_llms This configuration extends the Multi-Region setup for Dynamic Multiprotocol environments. It involves using separate rail handles for different protocols and initializing them with their respective channel configurations. The RAIL scheduler then automatically manages the loading of the required configuration. ```c // Initialization for 868MHz protocol RAIL_ConfigChannels(railHandle868, channelConfigs[0], NULL); // Initialization for 915MHz protocol RAIL_ConfigChannels(railHandle915, channelConfigs[1], NULL); ``` -------------------------------- ### Dynamic Multiprotocol (DMP) Setup with Multi-PHY in RAIL Source: https://context7_llms Shows how the Multi-Region PHY setup can be used in a Dynamic Multiprotocol (DMP) environment. It requires separate RAIL handles for each protocol/region. `RAIL_ConfigChannels()` is called during initialization for each handle, and the RAIL scheduler automatically manages the loading of the correct configuration. ```C RAIL_ConfigChannels(railHandle868, channelConfigs[0], NULL); RAIL_ConfigChannels(railHandle915, channelConfigs[1], NULL); ``` -------------------------------- ### Common (FSK) PA CSV File Format Example (Text) Source: https://context7_llms An example illustrating the expected format for a CSV file used by the `pa_dbm_mapping_table_generator.py` script for Common (FSK) power settings. It includes a header row and subsequent data rows, with ramp level and dBm values separated by commas. Comments are supported using the '#' symbol. ```text RAMPLEV,#dBm x,#-317 x,#-316 x,#-315 x,#-314 ``` -------------------------------- ### Example: IEEE 802.15.4 PHY CSMA-CA Default Parameters Source: https://context7_llms This example shows the default parameters for the IEEE 802.15.4 PHY using CSMA-CA. It configures up to 4 CCA attempts with varying random backoff ranges and a specific RSSI threshold. The `minBo`, `maxBo`, and `tries` parameters influence the backoff and retry logic. ```shell setLbtParams 3 5 4 -75 320 128 0 ``` -------------------------------- ### Print Sample Application Name - C Source: https://context7_llms Prints the sample application name along with the operating system information on which it is running. Takes a const char pointer to the application name as input and produces formatted console output. ```c void print_sample_app_name(const char *app_name) ``` -------------------------------- ### Get Meter Limited RX Start Delay (C) Source: https://context7_llms Returns the delay in microseconds after transmission before reception should start for limited accessibility modes (C and F). Requires sl_rail_sdk_wmbus_set_mode() to be called beforehand. Takes a boolean parameter to indicate slow mode. ```c uint32_t sl_rail_sdk_wmbus_get_meter_limited_acc_rx_start (bool slowMode) ``` -------------------------------- ### Initialize Simple LED Configuration - C Source: https://docs.silabs.com/gecko-platform/latest/platform-driver/simple-led Demonstrates the automatic code generation for Simple LED instances in sl_simple_led_instances.c. The sl_simple_led_context_t struct is configured with port, pin, and polarity settings from instance-specific headers, and the sl_led_t struct maps all LED operation functions. Multiple instances can coexist in the same file. ```c // sl_simple_led_instances.c #include "sl_simple_led.h" #include "sl_gpio.h" #include "sl_simple_led_inst0_config.h" sl_simple_led_context_t simple_inst0_context = { .port = SL_SIMPLE_LED_INST0_PORT, .pin = SL_SIMPLE_LED_INST0_PIN, .polarity = SL_SIMPLE_LED_INST0_POLARITY, }; const sl_led_t sl_led_inst0 = { .context = &simple_inst0_context, .init = sl_simple_led_init, .turn_on = sl_simple_led_turn_on, .turn_off = sl_simple_led_turn_off, .toggle = sl_simple_led_toggle, .get_state = sl_simple_led_get_state, }; void sl_simple_led_init_instances(void) { sl_led_init(&sl_led_inst0); } ``` -------------------------------- ### Get RSSI Command and Example Source: https://context7_llms This section describes the `getRssi` command used to retrieve the Received Signal Strength Indicator (RSSI) in dBm when the receiver is active. It includes an example of the command execution and its output format, noting a potential systematic offset in the returned value that requires calibration. ```sh getRssi Get RSSI in dBm if the receiver is turned on. ``` ```sh > getRssi getRssi {{(getRssi)}{rssi:-94}} > > ``` -------------------------------- ### Get RX Time Preamble Start Alt - RAIL C API Source: https://context7_llms Adjusts a RAIL RX timestamp to refer to the start of the preamble. This function takes a RAIL instance handle and a pointer to packet details, updating the packetTime field with the calculated preamble start time. The application must set the totalPacketBytes field before calling this function to account for all bytes received after the preamble and sync word(s), including CRC bytes. ```c RAIL_Status_t RAIL_GetRxTimePreambleStartAlt( RAIL_Handle_t railHandle, RAIL_RxPacketDetails_t * pPacketDetails ) ``` -------------------------------- ### Initialize RAIL Library and Configure Radio Settings Source: https://docs.silabs.com/rail/latest/rail-api This C code snippet demonstrates the initialization of the RAIL library, radio calibration, channel configuration, event handling setup, and state transitions for receiving and transmitting. It requires generated channel configurations and sets up event callbacks for packet transmission, reception, and errors. ```c #include "rail.h" #include "rail_config.h" // Generated by radio calculator #define TX_FIFO_SIZE (128) // Any power of 2 from [64, 4096] on the EFR32 static RAIL_Handle_t gRailHandle = NULL; static RAIL_TxPower_t txPower = 200; // Default to 20 dBm static uint8_t txFifo[TX_FIFO_SIZE]; static const RAIL_TxPowerConfig_t railTxPowerConfig = { // ... desired PA settings }; static void radioConfigChangedHandler(RAIL_Handle_t railHandle, const RAIL_ChannelConfigEntry_t *entry) { bool isSubgig = (entry->baseFrequency < 1000000000UL); // ... handle radio configuration change, e.g., select the desired PA possibly // using isSubgig to handle multiple configurations RAIL_ConfigTxPower(railHandle, &railTxPowerConfig); // The TX power must be reapplied after changing the PA above. RAIL_SetTxPowerDbm(railHandle, txPower); } static void radioEventHandler(RAIL_Handle_t railHandle, RAIL_Events_t events) { // ... handle RAIL events, e.g., receive and transmit completion } #if MULTIPROTOCOL static RAILSched_Config_t schedCfg; // Must never be const static RAIL_Config_t railCfg = { // Must never be const .eventsCallback = &radioEventHandler, .protocol = NULL, // For BLE, pointer to a RAIL_BLE_State_t .scheduler = &schedCfg, // For MultiProtocol, additional scheduler memory }; #else static RAIL_Config_t railCfg = { // Must never be const .eventsCallback = &radioEventHandler, .protocol = NULL, .scheduler = NULL, }; #endif // Initializes the radio out of startup so that it's ready to receive. void radioInitialize(void) { // Initializes the RAIL library and any internal state it requires. gRailHandle = RAIL_Init(&railCfg, NULL); // Configures calibration settings. RAIL_ConfigCal(gRailHandle, RAIL_CAL_ALL); // Configures radio according to the generated radio settings. RAIL_ConfigChannels(gRailHandle, channelConfigs[0], &radioConfigChangedHandler); // Configures the most useful callbacks and catches a few errors. RAIL_ConfigEvents(gRailHandle, RAIL_EVENTS_ALL, RAIL_EVENT_TX_PACKET_SENT | RAIL_EVENT_RX_PACKET_RECEIVED | RAIL_EVENT_RX_FRAME_ERROR // invalid CRC | RAIL_EVENT_RX_ADDRESS_FILTERED); // Sets automatic transitions to always receive once started. RAIL_StateTransitions_t railStateTransitions = { .success = RAIL_RF_STATE_RX, .error = RAIL_RF_STATE_RX, }; RAIL_SetRxTransitions(gRailHandle, &railStateTransitions); RAIL_SetTxTransitions(gRailHandle, &railStateTransitions); // Sets up the transmit buffer. RAIL_SetTxFifo(gRailHandle, txFifo, 0, TX_FIFO_SIZE); } ``` -------------------------------- ### Control Simple LED - Initialize, Turn On/Off, Toggle, Get State - C Source: https://docs.silabs.com/gecko-platform/latest/platform-driver/simple-led Demonstrates basic usage of the Simple LED Driver API for controlling LEDs. Shows initialization (required before other operations), turning on/off, toggling state, and retrieving current LED state. All operations use void pointer handles to the LED instance. ```c // initialize simple LED sl_simple_led_init(&simple_led_inst0); // turn on simple LED, turn off simple LED, and toggle the simple LED sl_simple_led_turn_on(&simple_led_inst0); sl_simple_led_turn_off(&simple_led_inst0); sl_simple_led_toggle(&simple_led_inst0); // get the state of the simple LED sl_led_state_t state = sl_simple_led_get_state(&simple_led_instance0); ``` -------------------------------- ### Get RAIL Handle Instance Source: https://context7_llms This code snippet demonstrates how to obtain a RAIL handle, which is essential for directing API calls to the correct protocol in a multiprotocol setup. The handle is obtained using sl_rail_util_get_handle, where INST0 should be replaced with the uppercase name of the init component instance. ```c RAIL_Handle_t railHandle = sl_rail_util_get_handle(SL_RAIL_UTIL_HANDLE_INST0); ``` -------------------------------- ### Initialize Channel Hopping Configuration with Buffer Source: https://context7_llms Example initialization pattern for setting up a RAIL RX channel hopping configuration. Demonstrates allocation of a buffer for internal RAIL use, specification of buffer length in 32-bit words, setting the number of channels, and pointing to the channel entries array. ```C uint32_t channelHoppingBuffer[256]; RAIL_RxChannelHoppingConfigEntry_t channelEntries[4]; RAIL_RxChannelHoppingConfig_t config = { .buffer = channelHoppingBuffer, .bufferLength = sizeof(channelHoppingBuffer) / sizeof(uint32_t), .numberOfChannels = 4, .entries = channelEntries }; ``` -------------------------------- ### Configure Sleep without Timer Synchronization (With Power Manager) Source: https://context7_llms This C example demonstrates configuring RAIL for sleep without timer synchronization, specifically when using the power manager. It includes necessary initializations for the power manager and RAIL's power manager integration, along with configuring sleep settings via RAIL_ConfigSleepAlt. The example assumes board-specific LFCLK setup and enters a main loop where sleep can be initiated. Dependencies: RAIL library, sl_power_manager.h, assert.h. ```c #include "rail.h" #include "sl_power_manager.h" extern RAIL_Handle_t railHandle; void main(void) { RAIL_Status_t status; bool shouldSleep = false; // This function depends on your board/chip but it must enable the LFCLK // you intend to use for RTCC sync before we configure sleep as that function // will attempt to auto detect the clock. BoardSetupLFCLK(); // Configure sleep for no timer synchronization RAIL_TimerSyncConfig_t timerSyncConfig = { .sleep = RAIL_SLEEP_CONFIG_TIMERSYNC_DISABLED, }; status = RAIL_ConfigSleepAlt(railHandle, &timerSyncConfig); assert(status == RAIL_STATUS_NO_ERROR); // Initialize application-level power manager service sl_power_manager_init(); // Initialize RAIL library's use of the power manager RAIL_InitPowerManager(); // Application main loop while(1) { // ... do normal app stuff and set shouldSleep to true when we want to // sleep if (shouldSleep) { ``` -------------------------------- ### Configure Clock Source and Enable RTCC Peripheral Source: https://docs.silabs.com/gecko-platform/latest/platform-service/sleeptimer Demonstrates how to select a clock source and enable the RTCC (Real-time Counter and Calendar) peripheral before initializing the sleep timer module. This example shows the typical setup for projects without Micrium OS, where the clock must be manually configured. ```c CMU_ClockSelectSet(cmuClock_LFE, cmuSelect_LFRCO); CMU_ClockEnable(cmuClock_RTCC, true); ``` -------------------------------- ### Start Transmission using RAIL_StartTx (C) Source: https://docs.silabs.com/rail/latest/rail-training-tx This code snippet shows how to initiate a radio transmission using the `RAIL_StartTx` function. It takes the RAIL handle, channel, transmission options, and a parameter for DMP mode. This function instructs the RAIL library to send the data currently in the FIFO. ```c RAIL_StartTx(rail_handle, 0, RAIL_TX_OPTIONS_DEFAULT, NULL); ``` -------------------------------- ### Start RAIL in Receive Mode Source: https://docs.silabs.com/rail/latest/rail-training-event Initiates the radio to start receiving packets on a specified channel. Includes error handling for the start receive operation. ```c status = RAIL_StartRx(rail_handle, 0, NULL); if(status != RAIL_STATUS_NO_ERROR) { // Turn led1 ON on StartRx Error sl_led_toggle(&sl_led_led1); } ``` -------------------------------- ### Start RSSI Averaging - RAIL Source: https://context7_llms Initiates a non-blocking hardware-based RSSI averaging mechanism over a specified time period. Only one RSSI averaging instance can run at a time, and the radio must be idle to start. In multiprotocol mode, this is a scheduled event that will start when the railHandle becomes active. ```C RAIL_Status_t RAIL_StartAverageRssi(RAIL_Handle_t railHandle, uint16_t channel, RAIL_Time_t averagingTimeUs, const RAIL_SchedulerInfo_t *schedulerInfo) ``` -------------------------------- ### RAIL API for Channel-based Multi-PHY Source: https://context7_llms Demonstrates how to initiate reception on different 'virtual channels' configured with varying bitrates using the RAIL API. This allows switching between protocols or configurations by simply selecting a channel. Assumes a RAIL handle and pre-configured channels. ```c RAIL_StartRx(rail_handle, 0, NULL); // Searches for 100kb/s packets on channel 0 RAIL_StartRx(rail_handle, 1, NULL); // Searches for 500kb/s packets on channel 1 ``` -------------------------------- ### Get and Set Wi-SUN OFDM Scrambler - C Source: https://docs.silabs.com/rail/2.19.0/rail-sdk-services/rail-sdk-packet-assistant Enables getting and setting the Wi-SUN OFDM scrambler configuration. The 'get' function returns the current scrambler value, and the 'set' function applies a new 2-bit wide scrambler value. ```c uint8_t get_wisun_ofdm_scrambler (void ) uint8_t set_wisun_ofdm_scrambler (uint8_t new_scrambler) ``` -------------------------------- ### RAIL TX Repeat Start to Start Support Macro Source: https://context7_llms Indicates whether the selected chip supports the RAIL_TX_REPEAT_OPTION_START_TO_START transmit option. This macro is a boolean flag. ```c #define RAIL_SUPPORTS_TX_REPEAT_START_TO_START 0 ``` -------------------------------- ### Configure and Enable RX Channel Hopping in C Source: https://context7_llms Demonstrates how to set up RX channel hopping by defining buffer sizes, creating channel hopping entries and configuration structures, and enabling the feature. The buffer size calculation includes overhead per channel plus PHY configuration delta sizes. This example configures hopping across 4 channels and enables the hopping functionality on a RAIL handle. ```c #define CHANNEL_HOPPING_NUMBER_OF_CHANNELS 4 #define CHANNEL_HOPPING_BUFFER_SIZE do { 3 + (RAIL_CHANNEL_HOPPING_BUFFER_SIZE_PER_CHANNEL * CHANNEL_HOPPING_NUMBER_OF_CHANNELS) + 2 * (SIZEOF_UINT32_DELTA_SUBTRACT + SIZEOF_UINT32_DELTA_ADD_0 + SIZEOF_UINT32_DELTA_ADD_1 + SIZEOF_UINT32_DELTA_ADD_2 + SIZEOF_UINT32_DELTA_ADD_3) } while (0) RAIL_RxChannelHoppingConfigEntry_t channelHoppingEntries[CHANNEL_HOPPING_NUMBER_OF_CHANNELS]; uint32_t channelHoppingBuffer[CHANNEL_HOPPING_BUFFER_SIZE]; RAIL_RxChannelHoppingConfig_t channelHoppingConfig = { .buffer = channelHoppingBuffer, .bufferLength = CHANNEL_HOPPING_BUFFER_SIZE, .numberOfChannels = CHANNEL_HOPPING_NUMBER_OF_CHANNELS, .entries = channelHoppingEntries }; channelHoppingEntries[0].channel = 1; channelHoppingEntries[1].channel = 2; channelHoppingEntries[2].channel = 3; RAIL_ConfigRxChannelHopping(railHandle, &channelHoppingConfig); RAIL_EnableRxChannelHopping(railHandle, true, true); ``` -------------------------------- ### RAIL Configure Channels Function Source: https://context7_llms Sets up the channels supported by the device, taking a RAIL handle, a pointer to the channel configuration, and an optional callback function for configuration changes. It returns the first available channel in the configuration and prepares it for use. ```c uint16_t RAIL_ConfigChannels(RAIL_Handle_t railHandle, const RAIL_ChannelConfig_t *config, RAIL_RadioConfigChangedCallback_t cb); ``` -------------------------------- ### Start RAIL Multi-Timer Function Source: https://context7_llms Starts a multi-timer instance with a specified expiration time, mode, callback, and arguments. It takes a pointer to the multi-timer structure and returns a RAIL_Status_t. ```c RAIL_Status_t RAIL_SetMultiTimer(RAIL_MultiTimer_t *tmr, RAIL_Time_t expirationTime, RAIL_TimeMode_t expirationMode, RAIL_MultiTimerCallback_t callback, void *cbArg); ``` -------------------------------- ### RAIL Multi-PHY Calibration at Startup (C) Source: https://context7_llms This C code snippet demonstrates how to explicitly request calibration for all protocols and channel groups at startup. It iterates through predefined channel groups, prepares each channel using RAIL_PrepareChannel, and then calibrates the IR using RAIL_CalibrateIr. This method is useful when the RAIL_EVENT_CAL_NEEDED event is not sufficient. ```c #define NUMBER_OF_GROUPS 5 const int16_t calibration_channels[NUMBER_OF_GROUPS] = {0, 10, 25, 50, 65}; for(uint8_t i=0; itimeSent field is updated to reflect the preamble start time. This function is used in transmit-complete event handling and can also retrieve the RAIL_EVENT_TX_STARTED timestamp. ```c RAIL_Status_t RAIL_GetTxTimePreambleStartAlt(RAIL_Handle_t railHandle, RAIL_TxPacketDetails_t *pPacketDetails) ``` -------------------------------- ### Beta 1: RF Sensing, Timers, and Data Rate Info Source: https://context7_llms Introduces new features for RF energy sensing, advanced timer management, and a command to retrieve data rate information for the current PHY configuration. ```shell rfSense sleep setTimer timerCancel printTimerStats printDataRates ``` -------------------------------- ### Start a Multitimer Instance (C) Source: https://context7_llms Starts a multitimer instance with a specified expiration time, mode, and callback function. The timer can be restarted if already running. An expiration time of 0 triggers an immediate callback. ```c RAIL_Status_t RAIL_SetMultiTimer ( RAIL_MultiTimer_t * tmr, RAIL_Time_t expirationTime, RAIL_TimeMode_t expirationMode, RAIL_MultiTimerCallback_t callback, void * cbArg ) ``` -------------------------------- ### Start Timer in Milliseconds - C Source: https://docs.silabs.com/gecko-platform/latest/platform-service/sleeptimer Starts a 32-bit timer with timeout specified in milliseconds instead of ticks. Automatically converts milliseconds to timer ticks for convenience. ```c sl_status_t sl_sleeptimer_start_timer_ms( sl_sleeptimer_timer_handle_t *handle, uint32_t timeout_ms, sl_sleeptimer_timer_callback_t callback, void *callback_data, uint8_t priority, uint16_t option_flags ); ``` -------------------------------- ### Initialize Simple LED Driver (C) Source: https://docs.silabs.com/gecko-platform/latest/platform-driver/simple-led Initializes the simple LED driver. It requires a pointer to simple-led specific data, typically a sl_simple_led_context_t. Returns SL_STATUS_OK on successful initialization. ```c sl_status_t sl_simple_led_init(void *led_handle) ``` -------------------------------- ### RAIL_StartRx - Start Receiver on Specific Channel Source: https://context7_llms Start the receiver on a specific channel. This is a non-blocking function that initiates packet reception and triggers the eventsCallback when packets are received. Any ongoing operations will be aborted if called with a different channel. ```APIDOC ## RAIL_StartRx ### Description Start the receiver on a specific channel. This is a non-blocking function that initiates radio packet reception. ### Method Function Call ### Signature ```c RAIL_Status_t RAIL_StartRx( RAIL_Handle_t railHandle, uint16_t channel, const RAIL_SchedulerInfo_t *schedulerInfo ) ``` ### Parameters #### Input Parameters - **railHandle** (RAIL_Handle_t) - Required - A RAIL instance handle - **channel** (uint16_t) - Required - The channel to listen on - **schedulerInfo** (const RAIL_SchedulerInfo_t *) - Optional - A pointer to information allowing the radio scheduler to place this receive appropriately. Only used in multiprotocol version of RAIL; may be set to NULL in other versions ### Returns - **RAIL_Status_t** - Status code indicating success or failure of the function call ### Behavior - Non-blocking function - When a packet is received, RAIL_Config_t::eventsCallback fires with RAIL_EVENT_RX_PACKET_RECEIVED set - If called while not idle with a different channel, any ongoing receive or transmit operation will be aborted ### Notes - Any ongoing receive or transmit operations are cancelled when switching channels - The schedulerInfo parameter is only applicable in multiprotocol RAIL configurations ``` -------------------------------- ### Simple LED Instance Header Declaration - C Source: https://docs.silabs.com/gecko-platform/latest/platform-driver/simple-led Shows the header file (sl_simple_led_instances.h) that declares external LED instances and initialization function. This file allows multiple instances to be declared and provides extern declarations for use across translation units. ```c // sl_simple_led_instances.h #ifndef SL_SIMPLE_LED_INSTANCES_H #define SL_SIMPLE_LED_INSTANCES_H #include "sl_simple_led.h" extern const sl_led_t sl_led_inst0; void sl_simple_led_init_instances(void); #endif // SL_SIMPLE_LED_INIT_H ``` -------------------------------- ### Setup Wireless M-Bus Frame Source: https://context7_llms Configures and prepares a Wireless M-Bus frame. This function takes various parameters including access number, accessibility settings, device type, sensor data, and flags for periodic transmission and encryption, then populates the provided buffer. ```c uint16_t sl_rail_sdk_wmbus_setup_frame(uint8_t *buffer, uint8_t access_number, sl_rail_sdk_wmbus_accessibility_t accessibility, sl_rail_sdk_wmbus_device_type_t new_device_type, sl_rail_sdk_wmbus_sensor_data_t *sensors_data, bool periodic, bool encrypt); ``` -------------------------------- ### Start Periodic Timer in Milliseconds - C Source: https://docs.silabs.com/gecko-platform/latest/platform-service/sleeptimer Starts a 32-bit periodic timer that automatically repeats at the specified millisecond interval. The callback is executed at each timeout period with support for priority-based scheduling. ```c sl_status_t sl_sleeptimer_start_periodic_timer_ms( sl_sleeptimer_timer_handle_t *handle, uint32_t timeout_ms, sl_sleeptimer_timer_callback_t callback, void *callback_data, uint8_t priority, uint16_t option_flags ); ``` -------------------------------- ### RAIL Get Scheduler Status Alternate Function Source: https://context7_llms Provides an alternative method to get the RAIL scheduler status, also returning the status of the underlying RAIL API call. It requires pointers to store the scheduler and RAIL statuses. ```c RAIL_Status_t RAIL_GetSchedulerStatusAlt(RAIL_Handle_t railHandle, RAIL_SchedulerStatus_t *pSchedulerStatus, RAIL_Status_t *pRailStatus) ``` -------------------------------- ### RAIL API: Initialization and Utility Functions (C) Source: https://docs.silabs.com/rail/latest/rail/2.19.2/efr32-migration-guide-for-proprietary-apps This snippet highlights the initialization and utility functions provided by the RAIL library. It mentions key utilities such as RAIL Library Initialization, Packet Trace Information (PTI), Power Amplifier (PA), and RF Path utilities. ```c // RAIL Library Initialization RAIL_Status_t railInitStatus = RAIL_Init(); // Packet Trace Information (PTI) Utility RAIL_Status_t ptiEnableStatus = RAIL_EnablePti(true); // Power Amplifier (PA) Utility RAIL_Status_t paConfigStatus = RAIL_SetPaPower(10); // RF Path Utility RAIL_Status_t rfPathStatus = RAIL_SetRfPath(RAIL_RF_PATH_2); ``` -------------------------------- ### Initialize and Configure PA with RAIL Library (C) Source: https://docs.silabs.com/rail/2.19.0/rail-api/pa This C code snippet demonstrates how to initialize and configure the Power Amplifier (PA) using the Silicon Labs RAIL library. It includes initializing power curves, setting PA mode, voltage, and ramp time, converting dBm to raw power levels, and setting the transmitter power. This example assumes a valid RAIL handle has already been initialized. ```c #include "pa_conversions_efr32.h" // A macro RAIL_TX_POWER_CURVES_CONFIG is used as the curve // structures used by the provided conversion functions. RAIL_TxPowerCurvesConfigAlt_t tx_power_curves_config = RAIL_TX_POWER_CURVES_CONFIG; // Saves those curves // to be referenced when the conversion functions are called. RAIL_InitTxPowerCurves(rail_handle, &tx_power_curves_config); // Declares the structure used to configure the PA. RAIL_TxPowerConfig_t txPowerConfig = { .mode = RAIL_TX_POWER_MODE_2P4_HP, .voltage = 3300, .rampTime = 10, }; // Initializes the PA. Here, it is assumed that 'railHandle' is a valid RAIL_Handle_t // that has already been initialized. RAIL_ConfigTxPower(railHandle, &txPowerConfig); // Picks a dBm power to use: 100 deci-dBm = 10 dBm. See docs on RAIL_TxPower_t. RAIL_TxPower_t power = 100; // Gets the config written by RAIL_ConfigTxPower() to confirm what was actually set. RAIL_GetTxPowerConfig(railHandle, &txPowerConfig); // RAIL_ConvertDbmToRaw() is the default weak version, // or the customer version, if overwritten. RAIL_TxPowerLevel_t powerLevel = RAIL_ConvertDbmToRaw(railHandle, txPowerConfig.mode, power); // Writes the result of the conversion to the PA power registers in terms // of raw power levels. RAIL_SetTxPower(railHandle, powerLevel); ``` -------------------------------- ### Set Transmit FIFO Address with Offset (C) Source: https://context7_llms Configures the transmit FIFO by setting its base address, a starting offset from the base, initial data length, and total size. This allows for a circular buffer that doesn't necessarily start at the base address. ```c uint16_t RAIL_SetTxFifoAlt(RAIL_Handle_t railHandle, uint8_t *addr, uint16_t startOffset, uint16_t initLength, uint16_t size); ``` -------------------------------- ### Initialize PA Configuration and Power Curves in C Source: https://context7_llms Initializes the PA by loading power conversion curves and configuring the TX power settings. This example demonstrates loading the default EFR32 power curves and setting up a RAIL_TxPowerConfig_t structure with 2.4 GHz high-power mode and 3.3V supply voltage. The RAIL_InitTxPowerCurves function must be called before setting TX power to enable proper dBm to raw power level conversion. ```c #include "pa_conversions_efr32.h" // A macro RAIL_TX_POWER_CURVES_CONFIG is used as the curve // structures used by the provided conversion functions. RAIL_TxPowerCurvesConfigAlt_t tx_power_curves_config = RAIL_TX_POWER_CURVES_CONFIG; // Saves those curves // to be referenced when the conversion functions are called. RAIL_InitTxPowerCurves(rail_handle, &tx_power_curves_config); // Declares the structure used to configure the PA. RAIL_TxPowerConfig_t txPowerConfig = { .mode = RAIL_TX_POWER_MODE_2P4_HP, .voltage = 3300 ``` -------------------------------- ### RAIL Transmit Start and Scheduled TX Events Source: https://context7_llms Details RAIL events associated with the initiation of transmit operations, including normal packet transmission, scheduled transmissions, and missed scheduled transmissions. These events provide timing information for transmit start. ```c #define RAIL_EVENT_TX_STARTED (1ULL << RAIL_EVENT_TX_STARTED_SHIFT) // Description: Occurs when the radio starts transmitting a normal packet on the air. #define RAIL_TX_STARTED_BYTES 0U // Description: A value to pass as [RAIL_GetTxTimePreambleStart()](transmit#rail-get-tx-time-preamble-start) totalPacketBytes parameter to retrieve the [RAIL_EVENT_TX_STARTED](events#rail-event-tx-started) timestamp. #define RAIL_EVENT_SCHEDULED_TX_STARTED (1ULL << RAIL_EVENT_SCHEDULED_TX_STARTED_SHIFT) // Description: Occurs when a scheduled TX begins turning on the transmitter. #define RAIL_EVENT_TX_SCHEDULED_TX_MISSED (1ULL << RAIL_EVENT_TX_SCHEDULED_TX_MISSED_SHIFT) // Description: Occurs when the start of a scheduled transmit is missed. ``` -------------------------------- ### Restart Periodic Timer (C) Source: https://docs.silabs.com/gecko-platform/latest/platform-service/sleeptimer Restarts a 32-bit periodic timer. Similar to starting a timer, it converts milliseconds to timer ticks with a maximum limit. It also has the same interrupt priority restriction as the start function. ```c sl_status_t sl_sleeptimer_restart_periodic_timer_ms ( sl_sleeptimer_timer_handle_t *handle, uint32_t timeout_ms, sl_sleeptimer_timer_callback_t callback, void *callback_data, uint8_t priority, uint16_t option_flags ); ``` -------------------------------- ### Include Simple LED Instances Header in C Source: https://context7_llms This C code snippet shows how to include the header file that declares instances for simple LEDs. This is necessary to access and control the LEDs (e.g., led0, led1) within the application, typically for status indication. ```c #include "sl_simple_led_instances.h" ``` -------------------------------- ### Start Periodic Timer (C) Source: https://docs.silabs.com/gecko-platform/latest/platform-service/sleeptimer Starts a 32-bit periodic timer. This function converts milliseconds to timer ticks, with a maximum timeout value limited by sl_sleeptimer_get_max_ms32_conversion(). Cannot be called from interrupts with priority higher than BASEPRI. ```c sl_status_t sl_sleeptimer_start_periodic_timer_ms ( sl_sleeptimer_timer_handle_t *handle, uint32_t timeout_ms, sl_sleeptimer_timer_callback_t callback, void *callback_data, uint8_t priority, uint16_t option_flags ); ``` -------------------------------- ### Configure Script Execution on Boot with RAILtest Flash Source: https://context7_llms This example illustrates how to enter a command script into flash memory and configure it to run automatically on device boot. After entering and saving the script, a 'reset' command triggers a device reboot, causing the script to execute. This is useful for setting up initial device states or running essential boot-time operations. ```shell enterScript 1 tx 1 wait 500000 tx 2 endScript reset ``` -------------------------------- ### Get and Set Wi-SUN OFDM Rate - C Source: https://docs.silabs.com/rail/2.19.0/rail-sdk-services/rail-sdk-packet-assistant Allows retrieval and setting of the Wi-SUN OFDM transmission rate. The 'get' function returns the current rate, and the 'set' function updates it with a new value. ```c uint8_t get_wisun_ofdm_rate (void ) uint8_t set_wisun_ofdm_rate (uint8_t new_rate) ``` -------------------------------- ### Power Manager Initialization and Energy Mode Control - C Source: https://docs.silabs.com/gecko-platform/latest/platform-service/power-manager Initializes the Power Manager, sets energy mode requirements, subscribes to transition events, and implements the main sleep loop. Demonstrates adding/removing EM requirements and calling sl_power_manager_sleep() for low-power operation. The event callback prints transition information. ```c sl_power_manager_em_transition_event_handle_t event_handle; sl_power_manager_em_transition_event_info_t event_info = { .event_mask = EM_EVENT_MASK_ALL, .on_event = my_events_callback, } void main(void) { // Initialize power manager; not needed if sl_system_init() is used. sl_power_manager_init(); // Limit sleep level to EM1. sl_power_manager_add_em_requirement(SL_POWER_MANAGER_EM1); // Subscribe to all event types; get notified for every power transition. sl_power_manager_subscribe_em_transition_event(&event_handle, &event_info); while (1) { // Actions [...] if (completed) { // Remove energy mode requirement, can go to EM2 or EM3 now, depending on the configuration. sl_power_manager_remove_em_requirement(SL_POWER_MANAGER_EM1); } // Sleep to lowest possible energy mode; This call is not needed when using the kernel. sl_power_manager_sleep(); // Will resume after an interrupt or exception. } } void my_events_callback(sl_power_manager_em_t from, sl_power_manager_em_t to) { printf("Event:%s-%s\r\n", string_lookup_table[from], string_lookup_table[to]); } ``` -------------------------------- ### Get and Set Wi-SUN FSK Whitening - C Source: https://docs.silabs.com/rail/2.19.0/rail-sdk-services/rail-sdk-packet-assistant Allows for the retrieval and modification of the Wi-SUN FSK whitening setting. The 'get' function returns the current whitening value, while the 'set' function applies a new value. ```c uint8_t get_wisun_fsk_whitening (void ) uint8_t set_wisun_fsk_whitening (uint8_t new_whitening) ```