AndroidのBLEラジコンプロポアプリ「BLEPropo」と接続し、RCサーボとDCモータを制御するプログラムです。 BLE Nanoで動作を確認しています。 BLEPropo → https://github.com/lipoyang/BLEPropo

Dependencies:   BLE_API mbed

BLEを使ったAndroid用ラジコンプロポアプリ「BLEPropo」に対応するBLE Nano用ファームウェアです。
BLEPropoは、GitHubにて公開中。
https://github.com/lipoyang/BLEPropo
/media/uploads/lipoyang/blepropo_ui.png
ラジコンは、mbed HRM1017とRCサーボやDCモータを組み合わせて作ります。
/media/uploads/lipoyang/ministeer3.jpg
回路図
/media/uploads/lipoyang/ministeer3.pdf

Committer:
lipoyang
Date:
Sat Mar 14 12:02:48 2015 +0000
Revision:
5:7f89fca19a9e
-convert nRF51822 library to a folder

Who changed what in which revision?

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