iOSのBLEコントローラアプリ「RCBController」と接続し、コントローラの操作を取得するサンプルプログラムです。 mbed HRM1017で動作を確認しています。 2014.08.20時点でのBLEライブラリに対応しました。

Dependencies:   BLE_API mbed

Fork of BLE_RCBController by Junichi Katsu

Committer:
jksoft
Date:
Wed Aug 20 13:41:01 2014 +0000
Revision:
4:ebda47d22091
Parent:
nRF51822/nordic/nrf-sdk/ble/ble_dtm.h@1:48f6e08a3ac2
?????????

Who changed what in which revision?

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