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 /*
jksoft 0:8c643bfe55b7 2 * Copyright (c) 2011 Nordic Semiconductor. All Rights Reserved.
jksoft 0:8c643bfe55b7 3 *
jksoft 0:8c643bfe55b7 4 * The information contained herein is confidential property of Nordic Semiconductor. The use,
jksoft 0:8c643bfe55b7 5 * copying, transfer or disclosure of such information is prohibited except by express written
jksoft 0:8c643bfe55b7 6 * agreement with Nordic Semiconductor.
jksoft 0:8c643bfe55b7 7 *
jksoft 0:8c643bfe55b7 8 */
jksoft 0:8c643bfe55b7 9 /**
jksoft 0:8c643bfe55b7 10 @defgroup nrf_sdm_api SoftDevice Manager API
jksoft 0:8c643bfe55b7 11 @{
jksoft 0:8c643bfe55b7 12
jksoft 0:8c643bfe55b7 13 @brief APIs for SoftDevice management.
jksoft 0:8c643bfe55b7 14
jksoft 0:8c643bfe55b7 15 */
jksoft 0:8c643bfe55b7 16
jksoft 0:8c643bfe55b7 17 /* Header guard */
jksoft 0:8c643bfe55b7 18 #ifndef NRF_SDM_H__
jksoft 0:8c643bfe55b7 19 #define NRF_SDM_H__
jksoft 0:8c643bfe55b7 20
jksoft 0:8c643bfe55b7 21 #include "nordic_global.h"
jksoft 0:8c643bfe55b7 22 #include "nrf_svc.h"
jksoft 0:8c643bfe55b7 23 #include "nrf51.h"
jksoft 0:8c643bfe55b7 24 #include "nrf_soc.h"
jksoft 0:8c643bfe55b7 25 #include "nrf_error_sdm.h"
jksoft 0:8c643bfe55b7 26
jksoft 0:8c643bfe55b7 27 /** @addtogroup NRF_SDM_DEFINES Defines
jksoft 0:8c643bfe55b7 28 * @{ */
jksoft 0:8c643bfe55b7 29
jksoft 0:8c643bfe55b7 30 /**@brief SoftDevice Manager SVC Base number. */
jksoft 0:8c643bfe55b7 31 #define SDM_SVC_BASE 0x10
jksoft 0:8c643bfe55b7 32
jksoft 0:8c643bfe55b7 33 /** @} */
jksoft 0:8c643bfe55b7 34
jksoft 0:8c643bfe55b7 35 /** @addtogroup NRF_SDM_ENUMS Enumerations
jksoft 0:8c643bfe55b7 36 * @{ */
jksoft 0:8c643bfe55b7 37
jksoft 0:8c643bfe55b7 38 /**@brief nRF SoftDevice Manager API SVC numbers. */
jksoft 0:8c643bfe55b7 39 enum NRF_SD_SVCS
jksoft 0:8c643bfe55b7 40 {
jksoft 0:8c643bfe55b7 41 SD_SOFTDEVICE_ENABLE = SDM_SVC_BASE, /**< ::sd_softdevice_enable */
jksoft 0:8c643bfe55b7 42 SD_SOFTDEVICE_DISABLE, /**< ::sd_softdevice_disable */
jksoft 0:8c643bfe55b7 43 SD_SOFTDEVICE_IS_ENABLED, /**< ::sd_softdevice_is_enabled */
jksoft 0:8c643bfe55b7 44 SD_SOFTDEVICE_FORWARD_TO_APPLICATION,/**< ::sd_softdevice_forward_to_application */
jksoft 0:8c643bfe55b7 45 SVC_SDM_LAST /**< Placeholder for last SDM SVC */
jksoft 0:8c643bfe55b7 46 };
jksoft 0:8c643bfe55b7 47
jksoft 0:8c643bfe55b7 48 /**@brief Possible lfclk oscillator sources. */
jksoft 0:8c643bfe55b7 49 enum NRF_CLOCK_LFCLKSRCS
jksoft 0:8c643bfe55b7 50 {
jksoft 0:8c643bfe55b7 51 NRF_CLOCK_LFCLKSRC_SYNTH_250_PPM, /**< LFCLK Synthesized from HFCLK. */
jksoft 0:8c643bfe55b7 52 NRF_CLOCK_LFCLKSRC_XTAL_500_PPM, /**< LFCLK crystal oscillator 500 PPM accuracy. */
jksoft 0:8c643bfe55b7 53 NRF_CLOCK_LFCLKSRC_XTAL_250_PPM, /**< LFCLK crystal oscillator 250 PPM accuracy. */
jksoft 0:8c643bfe55b7 54 NRF_CLOCK_LFCLKSRC_XTAL_150_PPM, /**< LFCLK crystal oscillator 150 PPM accuracy. */
jksoft 0:8c643bfe55b7 55 NRF_CLOCK_LFCLKSRC_XTAL_100_PPM, /**< LFCLK crystal oscillator 100 PPM accuracy. */
jksoft 0:8c643bfe55b7 56 NRF_CLOCK_LFCLKSRC_XTAL_75_PPM, /**< LFCLK crystal oscillator 75 PPM accuracy. */
jksoft 0:8c643bfe55b7 57 NRF_CLOCK_LFCLKSRC_XTAL_50_PPM, /**< LFCLK crystal oscillator 50 PPM accuracy. */
jksoft 0:8c643bfe55b7 58 NRF_CLOCK_LFCLKSRC_XTAL_30_PPM, /**< LFCLK crystal oscillator 30 PPM accuracy. */
jksoft 0:8c643bfe55b7 59 NRF_CLOCK_LFCLKSRC_XTAL_20_PPM, /**< LFCLK crystal oscillator 20 PPM accuracy. */
jksoft 0:8c643bfe55b7 60 NRF_CLOCK_LFCLKSRC_RC_250_PPM_250MS_CALIBRATION, /**< LFCLK RC oscillator, 250ms calibration interval.*/
jksoft 0:8c643bfe55b7 61 NRF_CLOCK_LFCLKSRC_RC_250_PPM_500MS_CALIBRATION, /**< LFCLK RC oscillator, 500ms calibration interval.*/
jksoft 0:8c643bfe55b7 62 NRF_CLOCK_LFCLKSRC_RC_250_PPM_1000MS_CALIBRATION, /**< LFCLK RC oscillator, 1000ms calibration interval.*/
jksoft 0:8c643bfe55b7 63 NRF_CLOCK_LFCLKSRC_RC_250_PPM_2000MS_CALIBRATION, /**< LFCLK RC oscillator, 2000ms calibration interval.*/
jksoft 0:8c643bfe55b7 64 NRF_CLOCK_LFCLKSRC_RC_250_PPM_4000MS_CALIBRATION, /**< LFCLK RC oscillator, 4000ms calibration interval.*/
jksoft 0:8c643bfe55b7 65 NRF_CLOCK_LFCLKSRC_RC_250_PPM_8000MS_CALIBRATION, /**< LFCLK RC oscillator, 8000ms calibration interval.*/
jksoft 0:8c643bfe55b7 66 };
jksoft 0:8c643bfe55b7 67
jksoft 0:8c643bfe55b7 68 /** @} */
jksoft 0:8c643bfe55b7 69
jksoft 0:8c643bfe55b7 70 /** @addtogroup NRF_SDM_TYPES Types
jksoft 0:8c643bfe55b7 71 * @{ */
jksoft 0:8c643bfe55b7 72
jksoft 0:8c643bfe55b7 73 /**@brief Type representing lfclk oscillator source. */
jksoft 0:8c643bfe55b7 74 typedef uint32_t nrf_clock_lfclksrc_t;
jksoft 0:8c643bfe55b7 75
jksoft 0:8c643bfe55b7 76
jksoft 0:8c643bfe55b7 77 /**@brief SoftDevice Assertion Handler type.
jksoft 0:8c643bfe55b7 78 *
jksoft 0:8c643bfe55b7 79 * When an unexpected error occurs within the SoftDevice it will call the SoftDevice assertion handler callback.
jksoft 0:8c643bfe55b7 80 * The protocol stack will be in an undefined state when this happens and the only way to recover will be to
jksoft 0:8c643bfe55b7 81 * perform a reset, using e.g. CMSIS NVIC_SystemReset().
jksoft 0:8c643bfe55b7 82 *
jksoft 0:8c643bfe55b7 83 * @note This callback is executed in HardFault context, thus SVC functions cannot be called from the SoftDevice assert callback.
jksoft 0:8c643bfe55b7 84 *
jksoft 0:8c643bfe55b7 85 * @param[in] pc The program counter of the failed assert.
jksoft 0:8c643bfe55b7 86 * @param[in] line_number Line number where the assert failed.
jksoft 0:8c643bfe55b7 87 * @param[in] file_name File name where the assert failed.
jksoft 0:8c643bfe55b7 88 */
jksoft 0:8c643bfe55b7 89 typedef void (*softdevice_assertion_handler_t)(uint32_t pc, uint16_t line_number, const uint8_t * p_file_name);
jksoft 0:8c643bfe55b7 90
jksoft 0:8c643bfe55b7 91 /** @} */
jksoft 0:8c643bfe55b7 92
jksoft 0:8c643bfe55b7 93 /** @addtogroup NRF_SDM_FUNCTIONS Functions
jksoft 0:8c643bfe55b7 94 * @{ */
jksoft 0:8c643bfe55b7 95
jksoft 0:8c643bfe55b7 96 /**@brief Enables the SoftDevice and by extension the protocol stack.
jksoft 0:8c643bfe55b7 97 *
jksoft 0:8c643bfe55b7 98 * Idempotent function to enable the SoftDevice.
jksoft 0:8c643bfe55b7 99 *
jksoft 0:8c643bfe55b7 100 * @note Some care must be taken if a low frequency clock source is already running when calling this function:
jksoft 0:8c643bfe55b7 101 * If the LF clock has a different source then the one currently running, it will be stopped. Then, the new
jksoft 0:8c643bfe55b7 102 * clock source will be started.
jksoft 0:8c643bfe55b7 103 *
jksoft 0:8c643bfe55b7 104 * @note This function has no effect when returning with an error.
jksoft 0:8c643bfe55b7 105 *
jksoft 0:8c643bfe55b7 106 * @post If return code is ::NRF_SUCCESS
jksoft 0:8c643bfe55b7 107 * - SoC library and protocol stack APIs are made available
jksoft 0:8c643bfe55b7 108 * - A portion of RAM will be unavailable (see relevant SDS documentation)
jksoft 0:8c643bfe55b7 109 * - Some peripherals will be unavailable or available only through the SoC API (see relevant SDS documentation)
jksoft 0:8c643bfe55b7 110 * - Interrupts will not arrive from protected peripherals or interrupts
jksoft 0:8c643bfe55b7 111 * - nrf_nvic_ functions must be used instead of CMSIS NVIC_ functions for reliable usage of the softdevice.
jksoft 0:8c643bfe55b7 112 * - Interrupt latency may be affected by the SoftDevice (see relevant SDS documentation)
jksoft 0:8c643bfe55b7 113 * - Chosen low frequency clock source will be running
jksoft 0:8c643bfe55b7 114 *
jksoft 0:8c643bfe55b7 115 * @param clock_source Low frequency clock source and accuracy. (Note: In the case of XTAL source, the PPM accuracy of the chosen clock source must be greater than or equal to the actual characteristics of your XTAL clock).
jksoft 0:8c643bfe55b7 116 * @param assertion_handler Callback for SoftDevice assertions.
jksoft 0:8c643bfe55b7 117 *
jksoft 0:8c643bfe55b7 118 * @retval ::NRF_SUCCESS
jksoft 0:8c643bfe55b7 119 * @retval ::NRF_ERROR_SDM_INCORRECT_INTERRUPT_CONFIGURATION SoftDeviceinterrupt is already enabled, or an enabled interrupt has an illegal priority level
jksoft 0:8c643bfe55b7 120 * @retval ::NRF_ERROR_SDM_LFCLK_SOURCE_UNKNOWN Unknown low frequency clock source selected
jksoft 0:8c643bfe55b7 121 */
jksoft 0:8c643bfe55b7 122 SVCALL(SD_SOFTDEVICE_ENABLE, uint32_t, sd_softdevice_enable(nrf_clock_lfclksrc_t clock_source, softdevice_assertion_handler_t assertion_handler));
jksoft 0:8c643bfe55b7 123
jksoft 0:8c643bfe55b7 124 /**@brief Disables the SoftDevice and by extension the protocol stack.
jksoft 0:8c643bfe55b7 125 *
jksoft 0:8c643bfe55b7 126 * Idempotent function to disable the SoftDevice.
jksoft 0:8c643bfe55b7 127 *
jksoft 0:8c643bfe55b7 128 * @post SoC library and protocol stack APIs are made unavailable.
jksoft 0:8c643bfe55b7 129 * @post All interrupts that was protected by the SoftDevice will be disabled and initialized to priority 0 (highest).
jksoft 0:8c643bfe55b7 130 * @post All peripherals used by the SoftDevice will be reset to default values.
jksoft 0:8c643bfe55b7 131 * @post All of RAM become available.
jksoft 0:8c643bfe55b7 132 * @post All interrupts are forwarded to the application.
jksoft 0:8c643bfe55b7 133 * @post LFCLK source chosen in ::sd_softdevice_enable will be left running.
jksoft 0:8c643bfe55b7 134 *
jksoft 0:8c643bfe55b7 135 * @retval ::NRF_SUCCESS
jksoft 0:8c643bfe55b7 136 */
jksoft 0:8c643bfe55b7 137 SVCALL(SD_SOFTDEVICE_DISABLE, uint32_t, sd_softdevice_disable(void));
jksoft 0:8c643bfe55b7 138
jksoft 0:8c643bfe55b7 139 /**@brief Check if the SoftDevice is enabled.
jksoft 0:8c643bfe55b7 140 *
jksoft 0:8c643bfe55b7 141 * @param[out] p_softdevice_enabled If the SoftDevice is enabled: 1 else 0.
jksoft 0:8c643bfe55b7 142 *
jksoft 0:8c643bfe55b7 143 * @retval ::NRF_SUCCESS
jksoft 0:8c643bfe55b7 144 */
jksoft 0:8c643bfe55b7 145 SVCALL(SD_SOFTDEVICE_IS_ENABLED, uint32_t, sd_softdevice_is_enabled(uint8_t * p_softdevice_enabled));
jksoft 0:8c643bfe55b7 146
jksoft 0:8c643bfe55b7 147 /**@brief Start forwarding interrupts to application.
jksoft 0:8c643bfe55b7 148 *
jksoft 0:8c643bfe55b7 149 * This function is only intended to be called when a bootloader is enabled is used.
jksoft 0:8c643bfe55b7 150 * The bootloader should call this right before it starts the application.
jksoft 0:8c643bfe55b7 151 * It is recommended that all interrupt sources are off when this is called,
jksoft 0:8c643bfe55b7 152 * or you could end up having interrupts in the application being executed before main() of the application.
jksoft 0:8c643bfe55b7 153 *
jksoft 0:8c643bfe55b7 154 * @retval ::NRF_SUCCESS
jksoft 0:8c643bfe55b7 155 */
jksoft 0:8c643bfe55b7 156 SVCALL(SD_SOFTDEVICE_FORWARD_TO_APPLICATION, uint32_t, sd_softdevice_forward_to_application(void));
jksoft 0:8c643bfe55b7 157
jksoft 0:8c643bfe55b7 158 /** @} */
jksoft 0:8c643bfe55b7 159
jksoft 0:8c643bfe55b7 160 #endif // NRF_SDM_H__
jksoft 0:8c643bfe55b7 161
jksoft 0:8c643bfe55b7 162 /**
jksoft 0:8c643bfe55b7 163 @}
jksoft 0:8c643bfe55b7 164 */