iOSのBLEコントローラアプリ「RCBController」とmbed HRM1017を接続し、RCサーボモータを操作するテストプログラムです。

Dependencies:   BLE_API_Native_IRC Servo mbed

Fork of BLE_RCBController by Junichi Katsu

  • 古いBLEライブラリを使っているのでプラットフォームは”Nordic nRF51822”を選択してください。
  • ライブラリ類はUpdateしないでください。コンパイルエラーになります。

うまく接続できない時は、iPhone/iPadのBluetoothをOFF->ONしてキャッシュをクリアしてみてください。

/media/uploads/robo8080/img_1560.jpg

Committer:
jksoft
Date:
Thu Jul 10 14:21:52 2014 +0000
Revision:
0:8c643bfe55b7
??

Who changed what in which revision?

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