The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
AnnaBridge
Date:
Thu Nov 08 11:45:42 2018 +0000
Revision:
171:3a7713b1edbc
Parent:
TARGET_NRF51_DONGLE/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_11/ble/ble_dtm/ble_dtm.h@169:a7c7b631e539
mbed library. Release version 164

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AnnaBridge 143:86740a56073b 1 /*
AnnaBridge 143:86740a56073b 2 * Copyright (c) 2012 Nordic Semiconductor ASA
AnnaBridge 143:86740a56073b 3 * All rights reserved.
AnnaBridge 143:86740a56073b 4 *
AnnaBridge 143:86740a56073b 5 * Redistribution and use in source and binary forms, with or without modification,
AnnaBridge 143:86740a56073b 6 * are permitted provided that the following conditions are met:
AnnaBridge 143:86740a56073b 7 *
AnnaBridge 143:86740a56073b 8 * 1. Redistributions of source code must retain the above copyright notice, this list
AnnaBridge 143:86740a56073b 9 * of conditions and the following disclaimer.
AnnaBridge 143:86740a56073b 10 *
AnnaBridge 143:86740a56073b 11 * 2. Redistributions in binary form, except as embedded into a Nordic Semiconductor ASA
AnnaBridge 143:86740a56073b 12 * integrated circuit in a product or a software update for such product, must reproduce
AnnaBridge 143:86740a56073b 13 * the above copyright notice, this list of conditions and the following disclaimer in
AnnaBridge 143:86740a56073b 14 * the documentation and/or other materials provided with the distribution.
AnnaBridge 143:86740a56073b 15 *
AnnaBridge 143:86740a56073b 16 * 3. Neither the name of Nordic Semiconductor ASA nor the names of its contributors may be
AnnaBridge 143:86740a56073b 17 * used to endorse or promote products derived from this software without specific prior
AnnaBridge 143:86740a56073b 18 * written permission.
AnnaBridge 143:86740a56073b 19 *
AnnaBridge 143:86740a56073b 20 * 4. This software, with or without modification, must only be used with a
AnnaBridge 143:86740a56073b 21 * Nordic Semiconductor ASA integrated circuit.
AnnaBridge 143:86740a56073b 22 *
AnnaBridge 143:86740a56073b 23 * 5. Any software provided in binary or object form under this license must not be reverse
AnnaBridge 143:86740a56073b 24 * engineered, decompiled, modified and/or disassembled.
AnnaBridge 143:86740a56073b 25 *
AnnaBridge 143:86740a56073b 26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
AnnaBridge 143:86740a56073b 27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
AnnaBridge 143:86740a56073b 28 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
AnnaBridge 143:86740a56073b 29 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
AnnaBridge 143:86740a56073b 30 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
AnnaBridge 143:86740a56073b 31 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
AnnaBridge 143:86740a56073b 32 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
AnnaBridge 143:86740a56073b 33 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
AnnaBridge 143:86740a56073b 34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
AnnaBridge 143:86740a56073b 35 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
AnnaBridge 143:86740a56073b 36 *
AnnaBridge 143:86740a56073b 37 */
AnnaBridge 143:86740a56073b 38
AnnaBridge 143:86740a56073b 39
AnnaBridge 143:86740a56073b 40 /** @file
AnnaBridge 143:86740a56073b 41 *
AnnaBridge 143:86740a56073b 42 * @defgroup ble_sdk_dtmlib_dtm DTM - Direct Test Mode
AnnaBridge 143:86740a56073b 43 * @{
AnnaBridge 143:86740a56073b 44 * @ingroup ble_sdk_lib
AnnaBridge 143:86740a56073b 45 * @brief Module for testing RF/PHY using DTM commands.
AnnaBridge 143:86740a56073b 46 */
AnnaBridge 143:86740a56073b 47
AnnaBridge 143:86740a56073b 48 #ifndef BLE_DTM_H__
AnnaBridge 143:86740a56073b 49 #define BLE_DTM_H__
AnnaBridge 143:86740a56073b 50
AnnaBridge 143:86740a56073b 51 #include <stdint.h>
AnnaBridge 143:86740a56073b 52 #include <stdbool.h>
AnnaBridge 143:86740a56073b 53
AnnaBridge 143:86740a56073b 54
AnnaBridge 143:86740a56073b 55 /**@brief Configuration parameters. */
AnnaBridge 143:86740a56073b 56 #define DEFAULT_TX_POWER RADIO_TXPOWER_TXPOWER_0dBm /**< Default Transmission power using in the DTM module. */
AnnaBridge 143:86740a56073b 57 #define DEFAULT_TIMER NRF_TIMER0 /**< Default timer used for timing. */
AnnaBridge 143:86740a56073b 58 #define DEFAULT_TIMER_IRQn TIMER0_IRQn /**< IRQ used for timer. NOTE: MUST correspond to DEFAULT_TIMER. */
AnnaBridge 143:86740a56073b 59
AnnaBridge 143:86740a56073b 60 /**@brief BLE DTM command codes. */
AnnaBridge 143:86740a56073b 61 typedef uint32_t dtm_cmd_t; /**< DTM command type. */
AnnaBridge 143:86740a56073b 62
AnnaBridge 143:86740a56073b 63 #define LE_RESET 0 /**< DTM command: Reset device. */
AnnaBridge 143:86740a56073b 64 #define LE_RECEIVER_TEST 1 /**< DTM command: Start receive test. */
AnnaBridge 143:86740a56073b 65 #define LE_TRANSMITTER_TEST 2 /**< DTM command: Start transmission test. */
AnnaBridge 143:86740a56073b 66 #define LE_TEST_END 3 /**< DTM command: End test and send packet report. */
AnnaBridge 143:86740a56073b 67
AnnaBridge 143:86740a56073b 68 // Configuration options used as parameter 2
AnnaBridge 143:86740a56073b 69 // when cmd == LE_TRANSMITTER_TEST and payload == DTM_PKT_VENDORSPECIFIC
AnnaBridge 143:86740a56073b 70 // Configuration value, if any, is supplied in parameter 3
AnnaBridge 143:86740a56073b 71
AnnaBridge 143:86740a56073b 72 #define CARRIER_TEST 0 /**< Length=0 indicates a constant, unmodulated carrier until LE_TEST_END or LE_RESET */
AnnaBridge 143:86740a56073b 73 #define CARRIER_TEST_STUDIO 1 /**< nRFgo Studio uses value 1 in length field, to indicate a constant, unmodulated carrier until LE_TEST_END or LE_RESET */
AnnaBridge 143:86740a56073b 74 #define SET_TX_POWER 2 /**< Set transmission power, value -40..+4 dBm in steps of 4 */
AnnaBridge 143:86740a56073b 75 #define SELECT_TIMER 3 /**< Select on of the 16 MHz timers 0, 1 or 2 */
AnnaBridge 143:86740a56073b 76
AnnaBridge 143:86740a56073b 77 #define LE_PACKET_REPORTING_EVENT 0x8000 /**< DTM Packet reporting event, returned by the device to the tester. */
AnnaBridge 143:86740a56073b 78 #define LE_TEST_STATUS_EVENT_SUCCESS 0x0000 /**< DTM Status event, indicating success. */
AnnaBridge 143:86740a56073b 79 #define LE_TEST_STATUS_EVENT_ERROR 0x0001 /**< DTM Status event, indicating an error. */
AnnaBridge 143:86740a56073b 80
AnnaBridge 143:86740a56073b 81 #define DTM_PKT_PRBS9 0x00 /**< Bit pattern PRBS9. */
AnnaBridge 143:86740a56073b 82 #define DTM_PKT_0X0F 0x01 /**< Bit pattern 11110000 (LSB is the leftmost bit). */
AnnaBridge 143:86740a56073b 83 #define DTM_PKT_0X55 0x02 /**< Bit pattern 10101010 (LSB is the leftmost bit). */
AnnaBridge 143:86740a56073b 84 #define DTM_PKT_VENDORSPECIFIC 0xFFFFFFFF /**< Vendor specific. Nordic: Continuous carrier test, or configuration. */
AnnaBridge 143:86740a56073b 85
AnnaBridge 143:86740a56073b 86 /**@brief Return codes from dtm_cmd(). */
AnnaBridge 143:86740a56073b 87 #define DTM_SUCCESS 0x00 /**< Indicate that the DTM function completed with success. */
AnnaBridge 143:86740a56073b 88 #define DTM_ERROR_ILLEGAL_CHANNEL 0x01 /**< Physical channel number must be in the range 0..39. */
AnnaBridge 143:86740a56073b 89 #define DTM_ERROR_INVALID_STATE 0x02 /**< Sequencing error: Command is not valid now. */
AnnaBridge 143:86740a56073b 90 #define DTM_ERROR_ILLEGAL_LENGTH 0x03 /**< Payload size must be in the range 0..37. */
AnnaBridge 143:86740a56073b 91 #define DTM_ERROR_ILLEGAL_CONFIGURATION 0x04 /**< Parameter out of range (legal range is function dependent). */
AnnaBridge 143:86740a56073b 92 #define DTM_ERROR_UNINITIALIZED 0x05 /**< DTM module has not been initialized by the application. */
AnnaBridge 143:86740a56073b 93
AnnaBridge 143:86740a56073b 94 // Note: DTM_PKT_VENDORSPECIFIC, is not a packet type
AnnaBridge 143:86740a56073b 95 #define PACKET_TYPE_MAX DTM_PKT_0X55 /**< Highest value allowed as DTM Packet type. */
AnnaBridge 143:86740a56073b 96
AnnaBridge 143:86740a56073b 97 /** @brief BLE DTM event type. */
AnnaBridge 143:86740a56073b 98 typedef uint32_t dtm_event_t; /**< Type for handling DTM event. */
AnnaBridge 143:86740a56073b 99
AnnaBridge 143:86740a56073b 100 /** @brief BLE DTM frequency type. */
AnnaBridge 143:86740a56073b 101 typedef uint32_t dtm_freq_t; /**< Physical channel, valid range: 0..39. */
AnnaBridge 143:86740a56073b 102
AnnaBridge 143:86740a56073b 103 /**@brief BLE DTM packet types. */
AnnaBridge 143:86740a56073b 104 typedef uint32_t dtm_pkt_type_t; /**< Type for holding the requested DTM payload type.*/
AnnaBridge 143:86740a56073b 105
AnnaBridge 143:86740a56073b 106
AnnaBridge 143:86740a56073b 107 /**@brief Function for initializing or re-initializing DTM module
AnnaBridge 143:86740a56073b 108 *
AnnaBridge 143:86740a56073b 109 * @return DTM_SUCCESS on successful initialization of the DTM module.
AnnaBridge 143:86740a56073b 110 */
AnnaBridge 143:86740a56073b 111 uint32_t dtm_init(void);
AnnaBridge 143:86740a56073b 112
AnnaBridge 143:86740a56073b 113
AnnaBridge 143:86740a56073b 114 /**@brief Function for giving control to dtmlib for handling timer and radio events.
AnnaBridge 143:86740a56073b 115 * Will return to caller at 625us intervals or whenever another event than radio occurs
AnnaBridge 143:86740a56073b 116 * (such as UART input). Function will put MCU to sleep between events.
AnnaBridge 143:86740a56073b 117 *
AnnaBridge 143:86740a56073b 118 * @return Time counter, incremented every 625 us.
AnnaBridge 143:86740a56073b 119 */
AnnaBridge 143:86740a56073b 120 uint32_t dtm_wait(void);
AnnaBridge 143:86740a56073b 121
AnnaBridge 143:86740a56073b 122
AnnaBridge 143:86740a56073b 123 /**@brief Function for calling when a complete command has been prepared by the Tester.
AnnaBridge 143:86740a56073b 124 *
AnnaBridge 143:86740a56073b 125 * @param[in] cmd One of the DTM_CMD values (bits 14:15 in the 16-bit UART format).
AnnaBridge 143:86740a56073b 126 * @param[in] freq Phys. channel no - actual frequency = (2402 + freq * 2) MHz (bits 8:13 in
AnnaBridge 143:86740a56073b 127 * the 16-bit UART format).
AnnaBridge 143:86740a56073b 128 * @param[in] length Payload length, 0..37 (bits 2:7 in the 16-bit UART format).
AnnaBridge 143:86740a56073b 129 * @param[in] payload One of the DTM_PKT values (bits 0:1 in the 16-bit UART format).
AnnaBridge 143:86740a56073b 130 *
AnnaBridge 143:86740a56073b 131 * @return DTM_SUCCESS or one of the DTM_ERROR_ values
AnnaBridge 143:86740a56073b 132 */
AnnaBridge 143:86740a56073b 133 uint32_t dtm_cmd(dtm_cmd_t cmd, dtm_freq_t freq, uint32_t length, dtm_pkt_type_t payload);
AnnaBridge 143:86740a56073b 134
AnnaBridge 143:86740a56073b 135
AnnaBridge 143:86740a56073b 136 /**@brief Function for reading the result of a DTM command
AnnaBridge 143:86740a56073b 137 *
AnnaBridge 143:86740a56073b 138 * @param[out] p_dtm_event Pointer to buffer for 16 bit event code according to DTM standard.
AnnaBridge 143:86740a56073b 139 *
AnnaBridge 143:86740a56073b 140 * @return true: new event, false: no event since last call, this event has been read earlier
AnnaBridge 143:86740a56073b 141 */
AnnaBridge 143:86740a56073b 142 bool dtm_event_get(dtm_event_t * p_dtm_event);
AnnaBridge 143:86740a56073b 143
AnnaBridge 143:86740a56073b 144
AnnaBridge 143:86740a56073b 145 /**@brief Function for configuring the timer to use.
AnnaBridge 143:86740a56073b 146 *
AnnaBridge 143:86740a56073b 147 * @note Must be called when no DTM test is running.
AnnaBridge 143:86740a56073b 148 *
AnnaBridge 143:86740a56073b 149 * @param[in] new_timer Index (0..2) of timer to be used by the DTM library
AnnaBridge 143:86740a56073b 150 *
AnnaBridge 143:86740a56073b 151 * @return true: success, new timer was selected, false: parameter error
AnnaBridge 143:86740a56073b 152 */
AnnaBridge 143:86740a56073b 153 bool dtm_set_timer(uint32_t new_timer);
AnnaBridge 143:86740a56073b 154
AnnaBridge 143:86740a56073b 155
AnnaBridge 143:86740a56073b 156 /**@brief Function for configuring the transmit power.
AnnaBridge 143:86740a56073b 157 *
AnnaBridge 143:86740a56073b 158 * @note Must be called when no DTM test is running.
AnnaBridge 143:86740a56073b 159 *
AnnaBridge 143:86740a56073b 160 * @param[in] new_tx_power New output level, +4..-40, in steps of 4.
AnnaBridge 143:86740a56073b 161 *
AnnaBridge 143:86740a56073b 162 * @return true: tx power setting changed, false: parameter error
AnnaBridge 143:86740a56073b 163 */
AnnaBridge 143:86740a56073b 164 bool dtm_set_txpower(uint32_t new_tx_power);
AnnaBridge 143:86740a56073b 165
AnnaBridge 143:86740a56073b 166 #endif // BLE_DTM_H__
AnnaBridge 143:86740a56073b 167
AnnaBridge 143:86740a56073b 168 /** @} */