Does the data structure to which the packet pointer points matter? NRF_RADIO->PACKETPTR

I am currently trying to develop a proprietary radio communication protocol using the NRF radio peripheral.

However, my application is not working out yet.

I am wondering if it has something to do with the packet pointer and packet structure that I am using.

I have tried different packet structures such as:


1. uint8_t packet;

2. uint8_t packet[x];

3. uint8_t packet[x][y];

And, after populating the packet with some random values, I define the packet pointer as

// for case 1
NRF_RADIO->PACKETPTR = (uint32_t)&packet

// for case 2
NRF_RADIO->PACKETPTR = (uint32_t)&packet[z]

// for case 3
NRF_RADIO->PACKETPTR = (uint32_t)&packet[w]

In my opinion, the radio should populate the received data right at the memory address provided by the pointer and the structure of the place holder should not really matter.
similarly, for the transmitter case, the radio should just refer to the memory address provided by the pointer and just send whatever is there.

However, I am not sure about anything and I just want to make sure, the structure of the packet to which the pointer is pointing does not really matter. I can imagine the size of the structure might matter in correct capturing the packets, but, overall, it should not impede the radio to populate the address.

Thanks.

Parents
  • Hello,

    It should not matter.

    If you want to see some very low level directly accessing radio hardware may I suggest:
    https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.1.0/nrf_dev_radio_rx_example.html 
    https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.1.0/nrf_dev_radio_tx_example.html 

    Edit: Also of course study the radio chapter in the product specification that show states and transition between states.

    Kenneth

  • Thanks Keneth for clarification. Unfortunately, I cannot find the following in my install folder (ncs) 

    <InstallFolder>\examples\peripheral\radio\receiver

    <InstallFolder>\examples\peripheral\radio\transmitter

    Could you please provide the Git hub link for these two projects?

    Thanks. 

  • Hello,

    My mistake, I thought for a moment you were using the old nRF5 SDK. I am uploading the relevant files to here. I do believe they can be used as reference on how to use the radio (but also notice that the external 32MHz must be started before the radio can be used).

    Kenneth

    /**
     * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA
     *
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without modification,
     * are permitted provided that the following conditions are met:
     *
     * 1. Redistributions of source code must retain the above copyright notice, this
     *    list of conditions and the following disclaimer.
     *
     * 2. Redistributions in binary form, except as embedded into a Nordic
     *    Semiconductor ASA integrated circuit in a product or a software update for
     *    such product, must reproduce the above copyright notice, this list of
     *    conditions and the following disclaimer in the documentation and/or other
     *    materials provided with the distribution.
     *
     * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
     *    contributors may be used to endorse or promote products derived from this
     *    software without specific prior written permission.
     *
     * 4. This software, with or without modification, must only be used with a
     *    Nordic Semiconductor ASA integrated circuit.
     *
     * 5. Any software provided in binary form under this license must not be reverse
     *    engineered, decompiled, modified and/or disassembled.
     *
     * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
     * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
     * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
     * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
     * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
     * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     *
     */
    /** @file
    *
    * @defgroup nrf_dev_button_radio_tx_example_main main.c
    * @{
    * @ingroup nrf_dev_button_radio_tx_example
    *
    * @brief Radio Transceiver Example Application main file.
    *
    * This file contains the source code for a sample application using the NRF_RADIO peripheral.
    *
    */
    
    #include <stdint.h>
    #include <stdbool.h>
    #include <stdio.h>
    #include "radio_config.h"
    #include "nrf_gpio.h"
    #include "app_timer.h"
    #include "boards.h"
    #include "bsp.h"
    #include "nordic_common.h"
    #include "nrf_error.h"
    
    #include "nrf_log.h"
    #include "nrf_log_ctrl.h"
    #include "nrf_log_default_backends.h"
    
    static uint32_t                   packet;                    /**< Packet to transmit. */
    
    /**@brief Function for sending packet.
     */
    void send_packet()
    {
        // send the packet:
        NRF_RADIO->EVENTS_READY = 0U;
        NRF_RADIO->TASKS_TXEN   = 1;
    
        while (NRF_RADIO->EVENTS_READY == 0U)
        {
            // wait
        }
        NRF_RADIO->EVENTS_END  = 0U;
        NRF_RADIO->TASKS_START = 1U;
    
        while (NRF_RADIO->EVENTS_END == 0U)
        {
            // wait
        }
    
        uint32_t err_code = bsp_indication_set(BSP_INDICATE_SENT_OK);
        NRF_LOG_INFO("The packet was sent");
        APP_ERROR_CHECK(err_code);
    
        NRF_RADIO->EVENTS_DISABLED = 0U;
        // Disable radio
        NRF_RADIO->TASKS_DISABLE = 1U;
    
        while (NRF_RADIO->EVENTS_DISABLED == 0U)
        {
            // wait
        }
    }
    
    
    /**@brief Function for handling bsp events.
     */
    void bsp_evt_handler(bsp_event_t evt)
    {
        uint32_t prep_packet = 0;
        switch (evt)
        {
            case BSP_EVENT_KEY_0:
                /* Fall through. */
            case BSP_EVENT_KEY_1:
                /* Fall through. */
            case BSP_EVENT_KEY_2:
                /* Fall through. */
            case BSP_EVENT_KEY_3:
                /* Fall through. */
            case BSP_EVENT_KEY_4:
                /* Fall through. */
            case BSP_EVENT_KEY_5:
                /* Fall through. */
            case BSP_EVENT_KEY_6:
                /* Fall through. */
            case BSP_EVENT_KEY_7:
                /* Get actual button state. */
                for (int i = 0; i < BUTTONS_NUMBER; i++)
                {
                    prep_packet |= (bsp_board_button_state_get(i) ? (1 << i) : 0);
                }
                break;
            default:
                /* No implementation needed. */
                break;
        }
        packet = prep_packet;
    }
    
    
    /**@brief Function for initialization oscillators.
     */
    void clock_initialization()
    {
        /* Start 16 MHz crystal oscillator */
        NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
        NRF_CLOCK->TASKS_HFCLKSTART    = 1;
    
        /* Wait for the external oscillator to start up */
        while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0)
        {
            // Do nothing.
        }
    
        /* Start low frequency crystal oscillator for app_timer(used by bsp)*/
        NRF_CLOCK->LFCLKSRC            = (CLOCK_LFCLKSRC_SRC_Xtal << CLOCK_LFCLKSRC_SRC_Pos);
        NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
        NRF_CLOCK->TASKS_LFCLKSTART    = 1;
    
        while (NRF_CLOCK->EVENTS_LFCLKSTARTED == 0)
        {
            // Do nothing.
        }
    }
    
    
    /**
     * @brief Function for application main entry.
     * @return 0. int return type required by ANSI/ISO standard.
     */
    int main(void)
    {
        uint32_t err_code = NRF_SUCCESS;
    
        clock_initialization();
    
        err_code = app_timer_init();
        APP_ERROR_CHECK(err_code);
    
        err_code = NRF_LOG_INIT(NULL);
        APP_ERROR_CHECK(err_code);
    
        NRF_LOG_DEFAULT_BACKENDS_INIT();
    
        err_code = bsp_init(BSP_INIT_LEDS | BSP_INIT_BUTTONS, bsp_evt_handler);
        APP_ERROR_CHECK(err_code);
    
        // Set radio configuration parameters
        radio_configure();
    
        // Set payload pointer
        NRF_RADIO->PACKETPTR = (uint32_t)&packet;
    
        err_code = bsp_indication_set(BSP_INDICATE_USER_STATE_OFF);
        NRF_LOG_INFO("Radio transmitter example started.");
        NRF_LOG_INFO("Press Any Button");
        APP_ERROR_CHECK(err_code);
    
        while (true)
        {
            if (packet != 0)
            {
                send_packet();
                NRF_LOG_INFO("The contents of the package was %u", (unsigned int)packet);
                packet = 0;
            }
            NRF_LOG_FLUSH();
            __WFE();
        }
    }
    
    
    /**
     *@}
     **/
    
    /**
     * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA
     *
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without modification,
     * are permitted provided that the following conditions are met:
     *
     * 1. Redistributions of source code must retain the above copyright notice, this
     *    list of conditions and the following disclaimer.
     *
     * 2. Redistributions in binary form, except as embedded into a Nordic
     *    Semiconductor ASA integrated circuit in a product or a software update for
     *    such product, must reproduce the above copyright notice, this list of
     *    conditions and the following disclaimer in the documentation and/or other
     *    materials provided with the distribution.
     *
     * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
     *    contributors may be used to endorse or promote products derived from this
     *    software without specific prior written permission.
     *
     * 4. This software, with or without modification, must only be used with a
     *    Nordic Semiconductor ASA integrated circuit.
     *
     * 5. Any software provided in binary form under this license must not be reverse
     *    engineered, decompiled, modified and/or disassembled.
     *
     * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
     * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
     * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
     * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
     * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
     * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     *
     */
    /** @file
    *
    * @defgroup nrf_dev_radio_rx_example_main main.c
    * @{
    * @ingroup nrf_dev_radio_rx_example
    * @brief Radio Receiver example Application main file.
    *
    * This file contains the source code for a sample application using the NRF_RADIO peripheral.
    *
    */
    #include <stdint.h>
    #include <stdbool.h>
    #include <stdio.h>
    #include "radio_config.h"
    #include "nrf_gpio.h"
    #include "boards.h"
    #include "bsp.h"
    #include "app_timer.h"
    #include "nordic_common.h"
    #include "nrf_error.h"
    #include "app_error.h"
    
    #include "nrf_log.h"
    #include "nrf_log_ctrl.h"
    #include "nrf_log_default_backends.h"
    
    static uint32_t                   packet;              /**< Packet to transmit. */
    
    /**@brief Function for initialization oscillators.
     */
    void clock_initialization()
    {
        /* Start 16 MHz crystal oscillator */
        NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
        NRF_CLOCK->TASKS_HFCLKSTART    = 1;
    
        /* Wait for the external oscillator to start up */
        while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0)
        {
            // Do nothing.
        }
    
        /* Start low frequency crystal oscillator for app_timer(used by bsp)*/
        NRF_CLOCK->LFCLKSRC            = (CLOCK_LFCLKSRC_SRC_Xtal << CLOCK_LFCLKSRC_SRC_Pos);
        NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
        NRF_CLOCK->TASKS_LFCLKSTART    = 1;
    
        while (NRF_CLOCK->EVENTS_LFCLKSTARTED == 0)
        {
            // Do nothing.
        }
    }
    
    
    /**@brief Function for reading packet.
     */
    uint32_t read_packet()
    {
        uint32_t result = 0;
    
        NRF_RADIO->EVENTS_READY = 0U;
        // Enable radio and wait for ready
        NRF_RADIO->TASKS_RXEN = 1U;
    
        while (NRF_RADIO->EVENTS_READY == 0U)
        {
            // wait
        }
        NRF_RADIO->EVENTS_END = 0U;
        // Start listening and wait for address received event
        NRF_RADIO->TASKS_START = 1U;
    
        // Wait for end of packet or buttons state changed
        while (NRF_RADIO->EVENTS_END == 0U)
        {
            // wait
        }
    
        if (NRF_RADIO->CRCSTATUS == 1U)
        {
            result = packet;
        }
        NRF_RADIO->EVENTS_DISABLED = 0U;
        // Disable radio
        NRF_RADIO->TASKS_DISABLE = 1U;
    
        while (NRF_RADIO->EVENTS_DISABLED == 0U)
        {
            // wait
        }
        return result;
    }
    
    
    /**
     * @brief Function for application main entry.
     * @return 0. int return type required by ANSI/ISO standard.
     */
    int main(void)
    {
        uint32_t err_code = NRF_SUCCESS;
    
        clock_initialization();
    
        err_code = app_timer_init();
        APP_ERROR_CHECK(err_code);
    
        err_code = NRF_LOG_INIT(NULL);
        APP_ERROR_CHECK(err_code);
        NRF_LOG_DEFAULT_BACKENDS_INIT();
    
        err_code = bsp_init(BSP_INIT_LEDS, NULL);
        APP_ERROR_CHECK(err_code);
    
        // Set radio configuration parameters
        radio_configure();
        NRF_RADIO->PACKETPTR = (uint32_t)&packet;
    
        err_code = bsp_indication_set(BSP_INDICATE_USER_STATE_OFF);
        NRF_LOG_INFO("Radio receiver example started.");
        NRF_LOG_INFO("Wait for first packet");
        APP_ERROR_CHECK(err_code);
        NRF_LOG_FLUSH();
    
        while (true)
        {
            uint32_t received = read_packet();
    
            err_code = bsp_indication_set(BSP_INDICATE_RCV_OK);
            NRF_LOG_INFO("Packet was received");
            APP_ERROR_CHECK(err_code);
    
            NRF_LOG_INFO("The contents of the package is %u", (unsigned int)received);
            NRF_LOG_FLUSH();
        }
    }
    
    /**
     *@}
     **/
    
    /**
     * Copyright (c) 2009 - 2021, Nordic Semiconductor ASA
     *
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without modification,
     * are permitted provided that the following conditions are met:
     *
     * 1. Redistributions of source code must retain the above copyright notice, this
     *    list of conditions and the following disclaimer.
     *
     * 2. Redistributions in binary form, except as embedded into a Nordic
     *    Semiconductor ASA integrated circuit in a product or a software update for
     *    such product, must reproduce the above copyright notice, this list of
     *    conditions and the following disclaimer in the documentation and/or other
     *    materials provided with the distribution.
     *
     * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
     *    contributors may be used to endorse or promote products derived from this
     *    software without specific prior written permission.
     *
     * 4. This software, with or without modification, must only be used with a
     *    Nordic Semiconductor ASA integrated circuit.
     *
     * 5. Any software provided in binary form under this license must not be reverse
     *    engineered, decompiled, modified and/or disassembled.
     *
     * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
     * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
     * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
     * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
     * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
     * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     *
     */
    /** @file
    * @addtogroup nrf_dev_radio_rx_example_main nrf_dev_radio_tx_example_main
    * @{
    */
    
    #include "radio_config.h"
    #include "nrf_delay.h"
    
    /* These are set to zero as ShockBurst packets don't have corresponding fields. */
    #define PACKET_S1_FIELD_SIZE      (0UL)  /**< Packet S1 field size in bits. */
    #define PACKET_S0_FIELD_SIZE      (0UL)  /**< Packet S0 field size in bits. */
    #define PACKET_LENGTH_FIELD_SIZE  (0UL)  /**< Packet length field size in bits. */
    
    /**
     * @brief Function for swapping/mirroring bits in a byte.
     *
     *@verbatim
     * output_bit_7 = input_bit_0
     * output_bit_6 = input_bit_1
     *           :
     * output_bit_0 = input_bit_7
     *@endverbatim
     *
     * @param[in] inp is the input byte to be swapped.
     *
     * @return
     * Returns the swapped/mirrored input byte.
     */
    static uint32_t swap_bits(uint32_t inp);
    
    /**
     * @brief Function for swapping bits in a 32 bit word for each byte individually.
     *
     * The bits are swapped as follows:
     * @verbatim
     * output[31:24] = input[24:31]
     * output[23:16] = input[16:23]
     * output[15:8]  = input[8:15]
     * output[7:0]   = input[0:7]
     * @endverbatim
     * @param[in] input is the input word to be swapped.
     *
     * @return
     * Returns the swapped input byte.
     */
    static uint32_t bytewise_bitswap(uint32_t inp);
    
    static uint32_t swap_bits(uint32_t inp)
    {
        uint32_t i;
        uint32_t retval = 0;
    
        inp = (inp & 0x000000FFUL);
    
        for (i = 0; i < 8; i++)
        {
            retval |= ((inp >> i) & 0x01) << (7 - i);
        }
    
        return retval;
    }
    
    
    static uint32_t bytewise_bitswap(uint32_t inp)
    {
          return (swap_bits(inp >> 24) << 24)
               | (swap_bits(inp >> 16) << 16)
               | (swap_bits(inp >> 8) << 8)
               | (swap_bits(inp));
    }
    
    
    /**
     * @brief Function for configuring the radio to operate in ShockBurst compatible mode.
     *
     * To configure the application running on nRF24L series devices:
     *
     * @verbatim
     * uint8_t tx_address[5] = { 0xC0, 0x01, 0x23, 0x45, 0x67 };
     * hal_nrf_set_rf_channel(7);
     * hal_nrf_set_address_width(HAL_NRF_AW_5BYTES);
     * hal_nrf_set_address(HAL_NRF_TX, tx_address);
     * hal_nrf_set_address(HAL_NRF_PIPE0, tx_address);
     * hal_nrf_open_pipe(0, false);
     * hal_nrf_set_datarate(HAL_NRF_1MBPS);
     * hal_nrf_set_crc_mode(HAL_NRF_CRC_16BIT);
     * hal_nrf_setup_dynamic_payload(0xFF);
     * hal_nrf_enable_dynamic_payload(false);
     * @endverbatim
     *
     * When transmitting packets with hal_nrf_write_tx_payload(const uint8_t *tx_pload, uint8_t length),
     * match the length with PACKET_STATIC_LENGTH.
     * hal_nrf_write_tx_payload(payload, PACKET_STATIC_LENGTH);
     *
    */
    void radio_configure()
    {
        // Radio config
        NRF_RADIO->TXPOWER   = (RADIO_TXPOWER_TXPOWER_0dBm << RADIO_TXPOWER_TXPOWER_Pos);
        NRF_RADIO->FREQUENCY = 7UL;  // Frequency bin 7, 2407MHz
        NRF_RADIO->MODE      = (RADIO_MODE_MODE_Nrf_1Mbit << RADIO_MODE_MODE_Pos);
    
        // Radio address config
        NRF_RADIO->PREFIX0 =
            ((uint32_t)swap_bits(0xC3) << 24) // Prefix byte of address 3 converted to nRF24L series format
          | ((uint32_t)swap_bits(0xC2) << 16) // Prefix byte of address 2 converted to nRF24L series format
          | ((uint32_t)swap_bits(0xC1) << 8)  // Prefix byte of address 1 converted to nRF24L series format
          | ((uint32_t)swap_bits(0xC0) << 0); // Prefix byte of address 0 converted to nRF24L series format
    
        NRF_RADIO->PREFIX1 =
            ((uint32_t)swap_bits(0xC7) << 24) // Prefix byte of address 7 converted to nRF24L series format
          | ((uint32_t)swap_bits(0xC6) << 16) // Prefix byte of address 6 converted to nRF24L series format
          | ((uint32_t)swap_bits(0xC4) << 0); // Prefix byte of address 4 converted to nRF24L series format
    
        NRF_RADIO->BASE0 = bytewise_bitswap(0x01234567UL);  // Base address for prefix 0 converted to nRF24L series format
        NRF_RADIO->BASE1 = bytewise_bitswap(0x89ABCDEFUL);  // Base address for prefix 1-7 converted to nRF24L series format
    
        NRF_RADIO->TXADDRESS   = 0x00UL;  // Set device address 0 to use when transmitting
        NRF_RADIO->RXADDRESSES = 0x01UL;  // Enable device address 0 to use to select which addresses to receive
    
        // Packet configuration
        NRF_RADIO->PCNF0 = (PACKET_S1_FIELD_SIZE     << RADIO_PCNF0_S1LEN_Pos) |
                           (PACKET_S0_FIELD_SIZE     << RADIO_PCNF0_S0LEN_Pos) |
                           (PACKET_LENGTH_FIELD_SIZE << RADIO_PCNF0_LFLEN_Pos); //lint !e845 "The right argument to operator '|' is certain to be 0"
    
        // Packet configuration
        NRF_RADIO->PCNF1 = (RADIO_PCNF1_WHITEEN_Disabled << RADIO_PCNF1_WHITEEN_Pos) |
                           (RADIO_PCNF1_ENDIAN_Big       << RADIO_PCNF1_ENDIAN_Pos)  |
                           (PACKET_BASE_ADDRESS_LENGTH   << RADIO_PCNF1_BALEN_Pos)   |
                           (PACKET_STATIC_LENGTH         << RADIO_PCNF1_STATLEN_Pos) |
                           (PACKET_PAYLOAD_MAXSIZE       << RADIO_PCNF1_MAXLEN_Pos); //lint !e845 "The right argument to operator '|' is certain to be 0"
    
        // CRC Config
        NRF_RADIO->CRCCNF = (RADIO_CRCCNF_LEN_Two << RADIO_CRCCNF_LEN_Pos); // Number of checksum bits
        if ((NRF_RADIO->CRCCNF & RADIO_CRCCNF_LEN_Msk) == (RADIO_CRCCNF_LEN_Two << RADIO_CRCCNF_LEN_Pos))
        {
            NRF_RADIO->CRCINIT = 0xFFFFUL;   // Initial value
            NRF_RADIO->CRCPOLY = 0x11021UL;  // CRC poly: x^16 + x^12^x^5 + 1
        }
        else if ((NRF_RADIO->CRCCNF & RADIO_CRCCNF_LEN_Msk) == (RADIO_CRCCNF_LEN_One << RADIO_CRCCNF_LEN_Pos))
        {
            NRF_RADIO->CRCINIT = 0xFFUL;   // Initial value
            NRF_RADIO->CRCPOLY = 0x107UL;  // CRC poly: x^8 + x^2^x^1 + 1
        }
    }
    
    /**
     * @}
     */
    
    radio_config.h

Reply
  • Hello,

    My mistake, I thought for a moment you were using the old nRF5 SDK. I am uploading the relevant files to here. I do believe they can be used as reference on how to use the radio (but also notice that the external 32MHz must be started before the radio can be used).

    Kenneth

    /**
     * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA
     *
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without modification,
     * are permitted provided that the following conditions are met:
     *
     * 1. Redistributions of source code must retain the above copyright notice, this
     *    list of conditions and the following disclaimer.
     *
     * 2. Redistributions in binary form, except as embedded into a Nordic
     *    Semiconductor ASA integrated circuit in a product or a software update for
     *    such product, must reproduce the above copyright notice, this list of
     *    conditions and the following disclaimer in the documentation and/or other
     *    materials provided with the distribution.
     *
     * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
     *    contributors may be used to endorse or promote products derived from this
     *    software without specific prior written permission.
     *
     * 4. This software, with or without modification, must only be used with a
     *    Nordic Semiconductor ASA integrated circuit.
     *
     * 5. Any software provided in binary form under this license must not be reverse
     *    engineered, decompiled, modified and/or disassembled.
     *
     * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
     * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
     * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
     * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
     * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
     * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     *
     */
    /** @file
    *
    * @defgroup nrf_dev_button_radio_tx_example_main main.c
    * @{
    * @ingroup nrf_dev_button_radio_tx_example
    *
    * @brief Radio Transceiver Example Application main file.
    *
    * This file contains the source code for a sample application using the NRF_RADIO peripheral.
    *
    */
    
    #include <stdint.h>
    #include <stdbool.h>
    #include <stdio.h>
    #include "radio_config.h"
    #include "nrf_gpio.h"
    #include "app_timer.h"
    #include "boards.h"
    #include "bsp.h"
    #include "nordic_common.h"
    #include "nrf_error.h"
    
    #include "nrf_log.h"
    #include "nrf_log_ctrl.h"
    #include "nrf_log_default_backends.h"
    
    static uint32_t                   packet;                    /**< Packet to transmit. */
    
    /**@brief Function for sending packet.
     */
    void send_packet()
    {
        // send the packet:
        NRF_RADIO->EVENTS_READY = 0U;
        NRF_RADIO->TASKS_TXEN   = 1;
    
        while (NRF_RADIO->EVENTS_READY == 0U)
        {
            // wait
        }
        NRF_RADIO->EVENTS_END  = 0U;
        NRF_RADIO->TASKS_START = 1U;
    
        while (NRF_RADIO->EVENTS_END == 0U)
        {
            // wait
        }
    
        uint32_t err_code = bsp_indication_set(BSP_INDICATE_SENT_OK);
        NRF_LOG_INFO("The packet was sent");
        APP_ERROR_CHECK(err_code);
    
        NRF_RADIO->EVENTS_DISABLED = 0U;
        // Disable radio
        NRF_RADIO->TASKS_DISABLE = 1U;
    
        while (NRF_RADIO->EVENTS_DISABLED == 0U)
        {
            // wait
        }
    }
    
    
    /**@brief Function for handling bsp events.
     */
    void bsp_evt_handler(bsp_event_t evt)
    {
        uint32_t prep_packet = 0;
        switch (evt)
        {
            case BSP_EVENT_KEY_0:
                /* Fall through. */
            case BSP_EVENT_KEY_1:
                /* Fall through. */
            case BSP_EVENT_KEY_2:
                /* Fall through. */
            case BSP_EVENT_KEY_3:
                /* Fall through. */
            case BSP_EVENT_KEY_4:
                /* Fall through. */
            case BSP_EVENT_KEY_5:
                /* Fall through. */
            case BSP_EVENT_KEY_6:
                /* Fall through. */
            case BSP_EVENT_KEY_7:
                /* Get actual button state. */
                for (int i = 0; i < BUTTONS_NUMBER; i++)
                {
                    prep_packet |= (bsp_board_button_state_get(i) ? (1 << i) : 0);
                }
                break;
            default:
                /* No implementation needed. */
                break;
        }
        packet = prep_packet;
    }
    
    
    /**@brief Function for initialization oscillators.
     */
    void clock_initialization()
    {
        /* Start 16 MHz crystal oscillator */
        NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
        NRF_CLOCK->TASKS_HFCLKSTART    = 1;
    
        /* Wait for the external oscillator to start up */
        while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0)
        {
            // Do nothing.
        }
    
        /* Start low frequency crystal oscillator for app_timer(used by bsp)*/
        NRF_CLOCK->LFCLKSRC            = (CLOCK_LFCLKSRC_SRC_Xtal << CLOCK_LFCLKSRC_SRC_Pos);
        NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
        NRF_CLOCK->TASKS_LFCLKSTART    = 1;
    
        while (NRF_CLOCK->EVENTS_LFCLKSTARTED == 0)
        {
            // Do nothing.
        }
    }
    
    
    /**
     * @brief Function for application main entry.
     * @return 0. int return type required by ANSI/ISO standard.
     */
    int main(void)
    {
        uint32_t err_code = NRF_SUCCESS;
    
        clock_initialization();
    
        err_code = app_timer_init();
        APP_ERROR_CHECK(err_code);
    
        err_code = NRF_LOG_INIT(NULL);
        APP_ERROR_CHECK(err_code);
    
        NRF_LOG_DEFAULT_BACKENDS_INIT();
    
        err_code = bsp_init(BSP_INIT_LEDS | BSP_INIT_BUTTONS, bsp_evt_handler);
        APP_ERROR_CHECK(err_code);
    
        // Set radio configuration parameters
        radio_configure();
    
        // Set payload pointer
        NRF_RADIO->PACKETPTR = (uint32_t)&packet;
    
        err_code = bsp_indication_set(BSP_INDICATE_USER_STATE_OFF);
        NRF_LOG_INFO("Radio transmitter example started.");
        NRF_LOG_INFO("Press Any Button");
        APP_ERROR_CHECK(err_code);
    
        while (true)
        {
            if (packet != 0)
            {
                send_packet();
                NRF_LOG_INFO("The contents of the package was %u", (unsigned int)packet);
                packet = 0;
            }
            NRF_LOG_FLUSH();
            __WFE();
        }
    }
    
    
    /**
     *@}
     **/
    
    /**
     * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA
     *
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without modification,
     * are permitted provided that the following conditions are met:
     *
     * 1. Redistributions of source code must retain the above copyright notice, this
     *    list of conditions and the following disclaimer.
     *
     * 2. Redistributions in binary form, except as embedded into a Nordic
     *    Semiconductor ASA integrated circuit in a product or a software update for
     *    such product, must reproduce the above copyright notice, this list of
     *    conditions and the following disclaimer in the documentation and/or other
     *    materials provided with the distribution.
     *
     * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
     *    contributors may be used to endorse or promote products derived from this
     *    software without specific prior written permission.
     *
     * 4. This software, with or without modification, must only be used with a
     *    Nordic Semiconductor ASA integrated circuit.
     *
     * 5. Any software provided in binary form under this license must not be reverse
     *    engineered, decompiled, modified and/or disassembled.
     *
     * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
     * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
     * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
     * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
     * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
     * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     *
     */
    /** @file
    *
    * @defgroup nrf_dev_radio_rx_example_main main.c
    * @{
    * @ingroup nrf_dev_radio_rx_example
    * @brief Radio Receiver example Application main file.
    *
    * This file contains the source code for a sample application using the NRF_RADIO peripheral.
    *
    */
    #include <stdint.h>
    #include <stdbool.h>
    #include <stdio.h>
    #include "radio_config.h"
    #include "nrf_gpio.h"
    #include "boards.h"
    #include "bsp.h"
    #include "app_timer.h"
    #include "nordic_common.h"
    #include "nrf_error.h"
    #include "app_error.h"
    
    #include "nrf_log.h"
    #include "nrf_log_ctrl.h"
    #include "nrf_log_default_backends.h"
    
    static uint32_t                   packet;              /**< Packet to transmit. */
    
    /**@brief Function for initialization oscillators.
     */
    void clock_initialization()
    {
        /* Start 16 MHz crystal oscillator */
        NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
        NRF_CLOCK->TASKS_HFCLKSTART    = 1;
    
        /* Wait for the external oscillator to start up */
        while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0)
        {
            // Do nothing.
        }
    
        /* Start low frequency crystal oscillator for app_timer(used by bsp)*/
        NRF_CLOCK->LFCLKSRC            = (CLOCK_LFCLKSRC_SRC_Xtal << CLOCK_LFCLKSRC_SRC_Pos);
        NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
        NRF_CLOCK->TASKS_LFCLKSTART    = 1;
    
        while (NRF_CLOCK->EVENTS_LFCLKSTARTED == 0)
        {
            // Do nothing.
        }
    }
    
    
    /**@brief Function for reading packet.
     */
    uint32_t read_packet()
    {
        uint32_t result = 0;
    
        NRF_RADIO->EVENTS_READY = 0U;
        // Enable radio and wait for ready
        NRF_RADIO->TASKS_RXEN = 1U;
    
        while (NRF_RADIO->EVENTS_READY == 0U)
        {
            // wait
        }
        NRF_RADIO->EVENTS_END = 0U;
        // Start listening and wait for address received event
        NRF_RADIO->TASKS_START = 1U;
    
        // Wait for end of packet or buttons state changed
        while (NRF_RADIO->EVENTS_END == 0U)
        {
            // wait
        }
    
        if (NRF_RADIO->CRCSTATUS == 1U)
        {
            result = packet;
        }
        NRF_RADIO->EVENTS_DISABLED = 0U;
        // Disable radio
        NRF_RADIO->TASKS_DISABLE = 1U;
    
        while (NRF_RADIO->EVENTS_DISABLED == 0U)
        {
            // wait
        }
        return result;
    }
    
    
    /**
     * @brief Function for application main entry.
     * @return 0. int return type required by ANSI/ISO standard.
     */
    int main(void)
    {
        uint32_t err_code = NRF_SUCCESS;
    
        clock_initialization();
    
        err_code = app_timer_init();
        APP_ERROR_CHECK(err_code);
    
        err_code = NRF_LOG_INIT(NULL);
        APP_ERROR_CHECK(err_code);
        NRF_LOG_DEFAULT_BACKENDS_INIT();
    
        err_code = bsp_init(BSP_INIT_LEDS, NULL);
        APP_ERROR_CHECK(err_code);
    
        // Set radio configuration parameters
        radio_configure();
        NRF_RADIO->PACKETPTR = (uint32_t)&packet;
    
        err_code = bsp_indication_set(BSP_INDICATE_USER_STATE_OFF);
        NRF_LOG_INFO("Radio receiver example started.");
        NRF_LOG_INFO("Wait for first packet");
        APP_ERROR_CHECK(err_code);
        NRF_LOG_FLUSH();
    
        while (true)
        {
            uint32_t received = read_packet();
    
            err_code = bsp_indication_set(BSP_INDICATE_RCV_OK);
            NRF_LOG_INFO("Packet was received");
            APP_ERROR_CHECK(err_code);
    
            NRF_LOG_INFO("The contents of the package is %u", (unsigned int)received);
            NRF_LOG_FLUSH();
        }
    }
    
    /**
     *@}
     **/
    
    /**
     * Copyright (c) 2009 - 2021, Nordic Semiconductor ASA
     *
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without modification,
     * are permitted provided that the following conditions are met:
     *
     * 1. Redistributions of source code must retain the above copyright notice, this
     *    list of conditions and the following disclaimer.
     *
     * 2. Redistributions in binary form, except as embedded into a Nordic
     *    Semiconductor ASA integrated circuit in a product or a software update for
     *    such product, must reproduce the above copyright notice, this list of
     *    conditions and the following disclaimer in the documentation and/or other
     *    materials provided with the distribution.
     *
     * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
     *    contributors may be used to endorse or promote products derived from this
     *    software without specific prior written permission.
     *
     * 4. This software, with or without modification, must only be used with a
     *    Nordic Semiconductor ASA integrated circuit.
     *
     * 5. Any software provided in binary form under this license must not be reverse
     *    engineered, decompiled, modified and/or disassembled.
     *
     * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
     * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
     * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
     * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
     * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
     * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     *
     */
    /** @file
    * @addtogroup nrf_dev_radio_rx_example_main nrf_dev_radio_tx_example_main
    * @{
    */
    
    #include "radio_config.h"
    #include "nrf_delay.h"
    
    /* These are set to zero as ShockBurst packets don't have corresponding fields. */
    #define PACKET_S1_FIELD_SIZE      (0UL)  /**< Packet S1 field size in bits. */
    #define PACKET_S0_FIELD_SIZE      (0UL)  /**< Packet S0 field size in bits. */
    #define PACKET_LENGTH_FIELD_SIZE  (0UL)  /**< Packet length field size in bits. */
    
    /**
     * @brief Function for swapping/mirroring bits in a byte.
     *
     *@verbatim
     * output_bit_7 = input_bit_0
     * output_bit_6 = input_bit_1
     *           :
     * output_bit_0 = input_bit_7
     *@endverbatim
     *
     * @param[in] inp is the input byte to be swapped.
     *
     * @return
     * Returns the swapped/mirrored input byte.
     */
    static uint32_t swap_bits(uint32_t inp);
    
    /**
     * @brief Function for swapping bits in a 32 bit word for each byte individually.
     *
     * The bits are swapped as follows:
     * @verbatim
     * output[31:24] = input[24:31]
     * output[23:16] = input[16:23]
     * output[15:8]  = input[8:15]
     * output[7:0]   = input[0:7]
     * @endverbatim
     * @param[in] input is the input word to be swapped.
     *
     * @return
     * Returns the swapped input byte.
     */
    static uint32_t bytewise_bitswap(uint32_t inp);
    
    static uint32_t swap_bits(uint32_t inp)
    {
        uint32_t i;
        uint32_t retval = 0;
    
        inp = (inp & 0x000000FFUL);
    
        for (i = 0; i < 8; i++)
        {
            retval |= ((inp >> i) & 0x01) << (7 - i);
        }
    
        return retval;
    }
    
    
    static uint32_t bytewise_bitswap(uint32_t inp)
    {
          return (swap_bits(inp >> 24) << 24)
               | (swap_bits(inp >> 16) << 16)
               | (swap_bits(inp >> 8) << 8)
               | (swap_bits(inp));
    }
    
    
    /**
     * @brief Function for configuring the radio to operate in ShockBurst compatible mode.
     *
     * To configure the application running on nRF24L series devices:
     *
     * @verbatim
     * uint8_t tx_address[5] = { 0xC0, 0x01, 0x23, 0x45, 0x67 };
     * hal_nrf_set_rf_channel(7);
     * hal_nrf_set_address_width(HAL_NRF_AW_5BYTES);
     * hal_nrf_set_address(HAL_NRF_TX, tx_address);
     * hal_nrf_set_address(HAL_NRF_PIPE0, tx_address);
     * hal_nrf_open_pipe(0, false);
     * hal_nrf_set_datarate(HAL_NRF_1MBPS);
     * hal_nrf_set_crc_mode(HAL_NRF_CRC_16BIT);
     * hal_nrf_setup_dynamic_payload(0xFF);
     * hal_nrf_enable_dynamic_payload(false);
     * @endverbatim
     *
     * When transmitting packets with hal_nrf_write_tx_payload(const uint8_t *tx_pload, uint8_t length),
     * match the length with PACKET_STATIC_LENGTH.
     * hal_nrf_write_tx_payload(payload, PACKET_STATIC_LENGTH);
     *
    */
    void radio_configure()
    {
        // Radio config
        NRF_RADIO->TXPOWER   = (RADIO_TXPOWER_TXPOWER_0dBm << RADIO_TXPOWER_TXPOWER_Pos);
        NRF_RADIO->FREQUENCY = 7UL;  // Frequency bin 7, 2407MHz
        NRF_RADIO->MODE      = (RADIO_MODE_MODE_Nrf_1Mbit << RADIO_MODE_MODE_Pos);
    
        // Radio address config
        NRF_RADIO->PREFIX0 =
            ((uint32_t)swap_bits(0xC3) << 24) // Prefix byte of address 3 converted to nRF24L series format
          | ((uint32_t)swap_bits(0xC2) << 16) // Prefix byte of address 2 converted to nRF24L series format
          | ((uint32_t)swap_bits(0xC1) << 8)  // Prefix byte of address 1 converted to nRF24L series format
          | ((uint32_t)swap_bits(0xC0) << 0); // Prefix byte of address 0 converted to nRF24L series format
    
        NRF_RADIO->PREFIX1 =
            ((uint32_t)swap_bits(0xC7) << 24) // Prefix byte of address 7 converted to nRF24L series format
          | ((uint32_t)swap_bits(0xC6) << 16) // Prefix byte of address 6 converted to nRF24L series format
          | ((uint32_t)swap_bits(0xC4) << 0); // Prefix byte of address 4 converted to nRF24L series format
    
        NRF_RADIO->BASE0 = bytewise_bitswap(0x01234567UL);  // Base address for prefix 0 converted to nRF24L series format
        NRF_RADIO->BASE1 = bytewise_bitswap(0x89ABCDEFUL);  // Base address for prefix 1-7 converted to nRF24L series format
    
        NRF_RADIO->TXADDRESS   = 0x00UL;  // Set device address 0 to use when transmitting
        NRF_RADIO->RXADDRESSES = 0x01UL;  // Enable device address 0 to use to select which addresses to receive
    
        // Packet configuration
        NRF_RADIO->PCNF0 = (PACKET_S1_FIELD_SIZE     << RADIO_PCNF0_S1LEN_Pos) |
                           (PACKET_S0_FIELD_SIZE     << RADIO_PCNF0_S0LEN_Pos) |
                           (PACKET_LENGTH_FIELD_SIZE << RADIO_PCNF0_LFLEN_Pos); //lint !e845 "The right argument to operator '|' is certain to be 0"
    
        // Packet configuration
        NRF_RADIO->PCNF1 = (RADIO_PCNF1_WHITEEN_Disabled << RADIO_PCNF1_WHITEEN_Pos) |
                           (RADIO_PCNF1_ENDIAN_Big       << RADIO_PCNF1_ENDIAN_Pos)  |
                           (PACKET_BASE_ADDRESS_LENGTH   << RADIO_PCNF1_BALEN_Pos)   |
                           (PACKET_STATIC_LENGTH         << RADIO_PCNF1_STATLEN_Pos) |
                           (PACKET_PAYLOAD_MAXSIZE       << RADIO_PCNF1_MAXLEN_Pos); //lint !e845 "The right argument to operator '|' is certain to be 0"
    
        // CRC Config
        NRF_RADIO->CRCCNF = (RADIO_CRCCNF_LEN_Two << RADIO_CRCCNF_LEN_Pos); // Number of checksum bits
        if ((NRF_RADIO->CRCCNF & RADIO_CRCCNF_LEN_Msk) == (RADIO_CRCCNF_LEN_Two << RADIO_CRCCNF_LEN_Pos))
        {
            NRF_RADIO->CRCINIT = 0xFFFFUL;   // Initial value
            NRF_RADIO->CRCPOLY = 0x11021UL;  // CRC poly: x^16 + x^12^x^5 + 1
        }
        else if ((NRF_RADIO->CRCCNF & RADIO_CRCCNF_LEN_Msk) == (RADIO_CRCCNF_LEN_One << RADIO_CRCCNF_LEN_Pos))
        {
            NRF_RADIO->CRCINIT = 0xFFUL;   // Initial value
            NRF_RADIO->CRCPOLY = 0x107UL;  // CRC poly: x^8 + x^2^x^1 + 1
        }
    }
    
    /**
     * @}
     */
    
    radio_config.h

Children
Related