Fawwaz Nadzmy / mbed-dev

Fork of mbed-dev by mbed official

Committer:
<>
Date:
Fri Oct 28 11:17:30 2016 +0100
Revision:
149:156823d33999
Parent:
targets/hal/TARGET_NORDIC/TARGET_NRF5/sdk/ble/ble_dtm/ble_dtm.h@144:ef7eb2e8f9f7
This updates the lib to the mbed lib v128

NOTE: This release includes a restructuring of the file and directory locations and thus some
include paths in your code may need updating accordingly.

Who changed what in which revision?

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