To get started with Seeed Tiny BLE, include detecting motion, button and battery level.

Dependencies:   BLE_API eMPL_MPU6050 mbed nRF51822

Committer:
yihui
Date:
Wed Apr 22 07:47:17 2015 +0000
Revision:
1:fc2f9d636751
update libraries; ; delete nRF51822/nordic-sdk/components/gpiote/app_gpiote.c to solve GPIOTE_IRQHandler multiply defined issue. temperarily change nRF51822 library to folder

Who changed what in which revision?

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