changed low freq. clock source to IRC
Dependents: BLE_ANCS_SDAPI_IRC
Fork of nRF51822 by
nordic/nrf-sdk/ble/ble_dtm.h@37:8c9bf3bea9db, 2014-07-06 (annotated)
- Committer:
- ytsuboi
- Date:
- Sun Jul 06 13:08:48 2014 +0000
- Revision:
- 37:8c9bf3bea9db
- Parent:
- 0:eff01767de02
changed low freq. clock to IRC
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bogdanm | 0:eff01767de02 | 1 | /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. |
bogdanm | 0:eff01767de02 | 2 | * |
bogdanm | 0:eff01767de02 | 3 | * The information contained herein is property of Nordic Semiconductor ASA. |
bogdanm | 0:eff01767de02 | 4 | * Terms and conditions of usage are described in detail in NORDIC |
bogdanm | 0:eff01767de02 | 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. |
bogdanm | 0:eff01767de02 | 6 | * |
bogdanm | 0:eff01767de02 | 7 | * Licensees are granted free, non-transferable use of the information. NO |
bogdanm | 0:eff01767de02 | 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from |
bogdanm | 0:eff01767de02 | 9 | * the file. |
bogdanm | 0:eff01767de02 | 10 | * |
bogdanm | 0:eff01767de02 | 11 | */ |
bogdanm | 0:eff01767de02 | 12 | |
bogdanm | 0:eff01767de02 | 13 | /** @file |
bogdanm | 0:eff01767de02 | 14 | * |
bogdanm | 0:eff01767de02 | 15 | * @defgroup ble_sdk_dtmlib_dtm DTM - Direct Test Mode |
bogdanm | 0:eff01767de02 | 16 | * @{ |
bogdanm | 0:eff01767de02 | 17 | * @ingroup ble_sdk_lib |
bogdanm | 0:eff01767de02 | 18 | * @brief Module for testing RF/PHY using DTM commands. |
bogdanm | 0:eff01767de02 | 19 | */ |
bogdanm | 0:eff01767de02 | 20 | |
bogdanm | 0:eff01767de02 | 21 | #ifndef BLE_DTM_H__ |
bogdanm | 0:eff01767de02 | 22 | #define BLE_DTM_H__ |
bogdanm | 0:eff01767de02 | 23 | |
bogdanm | 0:eff01767de02 | 24 | #include <stdint.h> |
bogdanm | 0:eff01767de02 | 25 | #include <stdbool.h> |
bogdanm | 0:eff01767de02 | 26 | #include "nordic_global.h" |
bogdanm | 0:eff01767de02 | 27 | |
bogdanm | 0:eff01767de02 | 28 | |
bogdanm | 0:eff01767de02 | 29 | /**@brief Configuration parameters. */ |
bogdanm | 0:eff01767de02 | 30 | #define DEFAULT_TX_POWER RADIO_TXPOWER_TXPOWER_Pos4dBm /**< Default Transmission power using in the DTM module. */ |
bogdanm | 0:eff01767de02 | 31 | #define DEFAULT_TIMER NRF_TIMER0 /**< Default timer used for timing. */ |
bogdanm | 0:eff01767de02 | 32 | #define DEFAULT_TIMER_IRQn TIMER0_IRQn /**< IRQ used for timer. NOTE: MUST correspond to DEFAULT_TIMER. */ |
bogdanm | 0:eff01767de02 | 33 | |
bogdanm | 0:eff01767de02 | 34 | /**@brief BLE DTM command codes. */ |
bogdanm | 0:eff01767de02 | 35 | typedef uint32_t dtm_cmd_t; /**< DTM command type. */ |
bogdanm | 0:eff01767de02 | 36 | |
bogdanm | 0:eff01767de02 | 37 | #define LE_RESET 0 /**< DTM command: Reset device. */ |
bogdanm | 0:eff01767de02 | 38 | #define LE_RECEIVER_TEST 1 /**< DTM command: Start receive test. */ |
bogdanm | 0:eff01767de02 | 39 | #define LE_TRANSMITTER_TEST 2 /**< DTM command: Start transmission test. */ |
bogdanm | 0:eff01767de02 | 40 | #define LE_TEST_END 3 /**< DTM command: End test and send packet report. */ |
bogdanm | 0:eff01767de02 | 41 | |
bogdanm | 0:eff01767de02 | 42 | // Configuration options used as parameter 2 |
bogdanm | 0:eff01767de02 | 43 | // when cmd == LE_TRANSMITTER_TEST and payload == DTM_PKT_VENDORSPECIFIC |
bogdanm | 0:eff01767de02 | 44 | // Configuration value, if any, is supplied in parameter 3 |
bogdanm | 0:eff01767de02 | 45 | |
bogdanm | 0:eff01767de02 | 46 | #define CARRIER_TEST 0 /**< Length=0 indicates a constant, unmodulated carrier until LE_TEST_END or LE_RESET */ |
bogdanm | 0:eff01767de02 | 47 | #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 */ |
bogdanm | 0:eff01767de02 | 48 | #define SET_TX_POWER 2 /**< Set transmission power, value -40..+4 dBm in steps of 4 */ |
bogdanm | 0:eff01767de02 | 49 | #define SELECT_TIMER 3 /**< Select on of the 16 MHz timers 0, 1 or 2 */ |
bogdanm | 0:eff01767de02 | 50 | |
bogdanm | 0:eff01767de02 | 51 | #define LE_PACKET_REPORTING_EVENT 0x8000 /**< DTM Packet reporting event, returned by the device to the tester. */ |
bogdanm | 0:eff01767de02 | 52 | #define LE_TEST_STATUS_EVENT_SUCCESS 0x0000 /**< DTM Status event, indicating success. */ |
bogdanm | 0:eff01767de02 | 53 | #define LE_TEST_STATUS_EVENT_ERROR 0x0001 /**< DTM Status event, indicating an error. */ |
bogdanm | 0:eff01767de02 | 54 | |
bogdanm | 0:eff01767de02 | 55 | #define DTM_PKT_PRBS9 0x00 /**< Bit pattern PRBS9. */ |
bogdanm | 0:eff01767de02 | 56 | #define DTM_PKT_0X0F 0x01 /**< Bit pattern 11110000 (LSB is the leftmost bit). */ |
bogdanm | 0:eff01767de02 | 57 | #define DTM_PKT_0X55 0x02 /**< Bit pattern 10101010 (LSB is the leftmost bit). */ |
bogdanm | 0:eff01767de02 | 58 | #define DTM_PKT_VENDORSPECIFIC 0xFFFFFFFF /**< Vendor specific. Nordic: Continuous carrier test, or configuration. */ |
bogdanm | 0:eff01767de02 | 59 | |
bogdanm | 0:eff01767de02 | 60 | /**@brief Return codes from dtm_cmd(). */ |
bogdanm | 0:eff01767de02 | 61 | #define DTM_SUCCESS 0x00 /**< Indicate that the DTM function completed with success. */ |
bogdanm | 0:eff01767de02 | 62 | #define DTM_ERROR_ILLEGAL_CHANNEL 0x01 /**< Physical channel number must be in the range 0..39. */ |
bogdanm | 0:eff01767de02 | 63 | #define DTM_ERROR_INVALID_STATE 0x02 /**< Sequencing error: Command is not valid now. */ |
bogdanm | 0:eff01767de02 | 64 | #define DTM_ERROR_ILLEGAL_LENGTH 0x03 /**< Payload size must be in the range 0..37. */ |
bogdanm | 0:eff01767de02 | 65 | #define DTM_ERROR_ILLEGAL_CONFIGURATION 0x04 /**< Parameter out of range (legal range is function dependent). */ |
bogdanm | 0:eff01767de02 | 66 | #define DTM_ERROR_UNINITIALIZED 0x05 /**< DTM module has not been initialized by the application. */ |
bogdanm | 0:eff01767de02 | 67 | |
bogdanm | 0:eff01767de02 | 68 | // Note: DTM_PKT_VENDORSPECIFIC, is not a packet type |
bogdanm | 0:eff01767de02 | 69 | #define PACKET_TYPE_MAX DTM_PKT_0X55 /**< Highest value allowed as DTM Packet type. */ |
bogdanm | 0:eff01767de02 | 70 | |
bogdanm | 0:eff01767de02 | 71 | /** @brief BLE DTM event type. */ |
bogdanm | 0:eff01767de02 | 72 | typedef uint32_t dtm_event_t; /**< Type for handling DTM event. */ |
bogdanm | 0:eff01767de02 | 73 | |
bogdanm | 0:eff01767de02 | 74 | /** @brief BLE DTM frequency type. */ |
bogdanm | 0:eff01767de02 | 75 | typedef uint32_t dtm_freq_t; /**< Physical channel, valid range: 0..39. */ |
bogdanm | 0:eff01767de02 | 76 | |
bogdanm | 0:eff01767de02 | 77 | /**@brief BLE DTM packet types. */ |
bogdanm | 0:eff01767de02 | 78 | typedef uint32_t dtm_pkt_type_t; /**< Type for holding the requested DTM payload type.*/ |
bogdanm | 0:eff01767de02 | 79 | |
bogdanm | 0:eff01767de02 | 80 | |
bogdanm | 0:eff01767de02 | 81 | /**@brief Function for initializing or re-initializing DTM module |
bogdanm | 0:eff01767de02 | 82 | * |
bogdanm | 0:eff01767de02 | 83 | * @return DTM_SUCCESS on successful initialization of the DTM module. |
bogdanm | 0:eff01767de02 | 84 | */ |
bogdanm | 0:eff01767de02 | 85 | uint32_t dtm_init(void); |
bogdanm | 0:eff01767de02 | 86 | |
bogdanm | 0:eff01767de02 | 87 | |
bogdanm | 0:eff01767de02 | 88 | /**@brief Function for giving control to dtmlib for handling timer and radio events. |
bogdanm | 0:eff01767de02 | 89 | * Will return to caller at 625us intervals or whenever another event than radio occurs |
bogdanm | 0:eff01767de02 | 90 | * (such as UART input). Function will put MCU to sleep between events. |
bogdanm | 0:eff01767de02 | 91 | * |
bogdanm | 0:eff01767de02 | 92 | * @return Time counter, incremented every 625 us. |
bogdanm | 0:eff01767de02 | 93 | */ |
bogdanm | 0:eff01767de02 | 94 | uint32_t dtm_wait(void); |
bogdanm | 0:eff01767de02 | 95 | |
bogdanm | 0:eff01767de02 | 96 | |
bogdanm | 0:eff01767de02 | 97 | /**@brief Function for calling when a complete command has been prepared by the Tester. |
bogdanm | 0:eff01767de02 | 98 | * |
bogdanm | 0:eff01767de02 | 99 | * @param[in] cmd One of the DTM_CMD values (bits 14:15 in the 16-bit UART format). |
bogdanm | 0:eff01767de02 | 100 | * @param[in] freq Phys. channel no - actual frequency = (2402 + freq * 2) MHz (bits 8:13 in |
bogdanm | 0:eff01767de02 | 101 | * the 16-bit UART format). |
bogdanm | 0:eff01767de02 | 102 | * @param[in] length Payload length, 0..37 (bits 2:7 in the 16-bit UART format). |
bogdanm | 0:eff01767de02 | 103 | * @param[in] payload One of the DTM_PKT values (bits 0:1 in the 16-bit UART format). |
bogdanm | 0:eff01767de02 | 104 | * |
bogdanm | 0:eff01767de02 | 105 | * @return DTM_SUCCESS or one of the DTM_ERROR_ values |
bogdanm | 0:eff01767de02 | 106 | */ |
bogdanm | 0:eff01767de02 | 107 | uint32_t dtm_cmd(dtm_cmd_t cmd, dtm_freq_t freq, uint32_t length, dtm_pkt_type_t payload); |
bogdanm | 0:eff01767de02 | 108 | |
bogdanm | 0:eff01767de02 | 109 | |
bogdanm | 0:eff01767de02 | 110 | /**@brief Function for reading the result of a DTM command |
bogdanm | 0:eff01767de02 | 111 | * |
bogdanm | 0:eff01767de02 | 112 | * @param[out] p_dtm_event Pointer to buffer for 16 bit event code according to DTM standard. |
bogdanm | 0:eff01767de02 | 113 | * |
bogdanm | 0:eff01767de02 | 114 | * @return true: new event, false: no event since last call, this event has been read earlier |
bogdanm | 0:eff01767de02 | 115 | */ |
bogdanm | 0:eff01767de02 | 116 | bool dtm_event_get(dtm_event_t * p_dtm_event); |
bogdanm | 0:eff01767de02 | 117 | |
bogdanm | 0:eff01767de02 | 118 | |
bogdanm | 0:eff01767de02 | 119 | /**@brief Function for configuring the timer to use. |
bogdanm | 0:eff01767de02 | 120 | * |
bogdanm | 0:eff01767de02 | 121 | * @note Must be called when no DTM test is running. |
bogdanm | 0:eff01767de02 | 122 | * |
bogdanm | 0:eff01767de02 | 123 | * @param[in] new_timer Index (0..2) of timer to be used by the DTM library |
bogdanm | 0:eff01767de02 | 124 | * |
bogdanm | 0:eff01767de02 | 125 | * @return true: success, new timer was selected, false: parameter error |
bogdanm | 0:eff01767de02 | 126 | */ |
bogdanm | 0:eff01767de02 | 127 | bool dtm_set_timer(uint32_t new_timer); |
bogdanm | 0:eff01767de02 | 128 | |
bogdanm | 0:eff01767de02 | 129 | |
bogdanm | 0:eff01767de02 | 130 | /**@brief Function for configuring the transmit power. |
bogdanm | 0:eff01767de02 | 131 | * |
bogdanm | 0:eff01767de02 | 132 | * @note Must be called when no DTM test is running. |
bogdanm | 0:eff01767de02 | 133 | * |
bogdanm | 0:eff01767de02 | 134 | * @param[in] new_tx_power New output level, +4..-40, in steps of 4. |
bogdanm | 0:eff01767de02 | 135 | * |
bogdanm | 0:eff01767de02 | 136 | * @return true: tx power setting changed, false: parameter error |
bogdanm | 0:eff01767de02 | 137 | */ |
bogdanm | 0:eff01767de02 | 138 | bool dtm_set_txpower(uint32_t new_tx_power); |
bogdanm | 0:eff01767de02 | 139 | |
bogdanm | 0:eff01767de02 | 140 | #endif // BLE_DTM_H__ |
bogdanm | 0:eff01767de02 | 141 | |
bogdanm | 0:eff01767de02 | 142 | /** @} */ |