mbed HRM11017を使ってkonashi.jsでナイトライダー

Dependencies:   BLE_API_Native_IRC mbed

Fork of BLE_RCBController by Junichi Katsu

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers nrf_sdm.h Source File

nrf_sdm.h

00001 /*
00002  * Copyright (c) 2011 Nordic Semiconductor. All Rights Reserved.
00003  *
00004  * The information contained herein is confidential property of Nordic Semiconductor. The use,
00005  * copying, transfer or disclosure of such information is prohibited except by express written
00006  * agreement with Nordic Semiconductor.
00007  *
00008  */
00009 /**
00010   @defgroup nrf_sdm_api SoftDevice Manager API
00011   @{
00012      
00013   @brief APIs for SoftDevice management.
00014  
00015 */
00016 
00017 /* Header guard */
00018 #ifndef NRF_SDM_H__
00019 #define NRF_SDM_H__
00020 
00021 #include "nordic_global.h"
00022 #include "nrf_svc.h"
00023 #include "nrf51.h"
00024 #include "nrf_soc.h"
00025 #include "nrf_error_sdm.h"
00026 
00027 /** @addtogroup NRF_SDM_DEFINES Defines
00028  * @{ */
00029 
00030 /**@brief SoftDevice Manager SVC Base number. */
00031 #define SDM_SVC_BASE 0x10   
00032 
00033 /** @} */
00034 
00035 /** @addtogroup NRF_SDM_ENUMS Enumerations
00036  * @{ */
00037 
00038 /**@brief nRF SoftDevice Manager API SVC numbers. */
00039 enum NRF_SD_SVCS
00040 {
00041   SD_SOFTDEVICE_ENABLE = SDM_SVC_BASE, /**< ::sd_softdevice_enable */
00042   SD_SOFTDEVICE_DISABLE,               /**< ::sd_softdevice_disable */
00043   SD_SOFTDEVICE_IS_ENABLED,            /**< ::sd_softdevice_is_enabled */
00044   SD_SOFTDEVICE_FORWARD_TO_APPLICATION,/**< ::sd_softdevice_forward_to_application */
00045   SVC_SDM_LAST                         /**< Placeholder for last SDM SVC */
00046 };
00047 
00048 /**@brief Possible lfclk oscillator sources. */
00049 enum NRF_CLOCK_LFCLKSRCS
00050 {
00051   NRF_CLOCK_LFCLKSRC_SYNTH_250_PPM,                       /**< LFCLK Synthesized from HFCLK.                    */
00052   NRF_CLOCK_LFCLKSRC_XTAL_500_PPM,                        /**< LFCLK crystal oscillator 500 PPM accuracy.       */
00053   NRF_CLOCK_LFCLKSRC_XTAL_250_PPM,                        /**< LFCLK crystal oscillator 250 PPM accuracy.       */
00054   NRF_CLOCK_LFCLKSRC_XTAL_150_PPM,                        /**< LFCLK crystal oscillator 150 PPM accuracy.       */
00055   NRF_CLOCK_LFCLKSRC_XTAL_100_PPM,                        /**< LFCLK crystal oscillator 100 PPM accuracy.       */
00056   NRF_CLOCK_LFCLKSRC_XTAL_75_PPM,                         /**< LFCLK crystal oscillator 75 PPM accuracy.        */
00057   NRF_CLOCK_LFCLKSRC_XTAL_50_PPM,                         /**< LFCLK crystal oscillator 50 PPM accuracy.        */
00058   NRF_CLOCK_LFCLKSRC_XTAL_30_PPM,                         /**< LFCLK crystal oscillator 30 PPM accuracy.        */
00059   NRF_CLOCK_LFCLKSRC_XTAL_20_PPM,                         /**< LFCLK crystal oscillator 20 PPM accuracy.        */
00060   NRF_CLOCK_LFCLKSRC_RC_250_PPM_250MS_CALIBRATION,        /**< LFCLK RC oscillator, 250ms  calibration interval.*/
00061   NRF_CLOCK_LFCLKSRC_RC_250_PPM_500MS_CALIBRATION,        /**< LFCLK RC oscillator, 500ms  calibration interval.*/
00062   NRF_CLOCK_LFCLKSRC_RC_250_PPM_1000MS_CALIBRATION,       /**< LFCLK RC oscillator, 1000ms calibration interval.*/
00063   NRF_CLOCK_LFCLKSRC_RC_250_PPM_2000MS_CALIBRATION,       /**< LFCLK RC oscillator, 2000ms calibration interval.*/
00064   NRF_CLOCK_LFCLKSRC_RC_250_PPM_4000MS_CALIBRATION,       /**< LFCLK RC oscillator, 4000ms calibration interval.*/
00065   NRF_CLOCK_LFCLKSRC_RC_250_PPM_8000MS_CALIBRATION,       /**< LFCLK RC oscillator, 8000ms calibration interval.*/
00066 };
00067 
00068 /** @} */
00069 
00070 /** @addtogroup NRF_SDM_TYPES Types
00071  * @{ */
00072 
00073 /**@brief Type representing lfclk oscillator source. */
00074 typedef uint32_t nrf_clock_lfclksrc_t;
00075 
00076 
00077 /**@brief SoftDevice Assertion Handler type.
00078  *
00079  * When an unexpected error occurs within the SoftDevice it will call the SoftDevice assertion handler callback.
00080  * The protocol stack will be in an undefined state when this happens and the only way to recover will be to
00081  * perform a reset, using e.g. CMSIS NVIC_SystemReset().
00082  *
00083  * @note This callback is executed in HardFault context, thus SVC functions cannot be called from the SoftDevice assert callback.
00084  *       
00085  * @param[in] pc The program counter of the failed assert.
00086  * @param[in] line_number Line number where the assert failed.
00087  * @param[in] file_name File name where the assert failed.
00088  */
00089 typedef void (*softdevice_assertion_handler_t)(uint32_t pc, uint16_t line_number, const uint8_t * p_file_name);
00090 
00091 /** @} */
00092 
00093 /** @addtogroup NRF_SDM_FUNCTIONS Functions
00094  * @{ */
00095 
00096 /**@brief Enables the SoftDevice and by extension the protocol stack.
00097  *
00098  * Idempotent function to enable the SoftDevice.
00099  *
00100  * @note Some care must be taken if a low frequency clock source is already running when calling this function:
00101  *       If the LF clock has a different source then the one currently running, it will be stopped. Then, the new
00102  *       clock source will be started.
00103  *
00104  * @note This function has no effect when returning with an error.
00105  *
00106  * @post If return code is ::NRF_SUCCESS 
00107  *       - SoC library and protocol stack APIs are made available
00108  *       - A portion of RAM will be unavailable (see relevant SDS documentation)
00109  *       - Some peripherals will be unavailable or available only through the SoC API (see relevant SDS documentation)
00110  *       - Interrupts will not arrive from protected peripherals or interrupts
00111  *       - nrf_nvic_ functions must be used instead of CMSIS NVIC_ functions for reliable usage of the softdevice.
00112  *       - Interrupt latency may be affected by the SoftDevice  (see relevant SDS documentation)
00113  *       - Chosen low frequency clock source will be running
00114  *
00115  * @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).
00116  * @param assertion_handler Callback for SoftDevice assertions.
00117  *
00118  * @retval ::NRF_SUCCESS
00119  * @retval ::NRF_ERROR_SDM_INCORRECT_INTERRUPT_CONFIGURATION SoftDeviceinterrupt is already enabled, or an enabled interrupt has an illegal priority level
00120  * @retval ::NRF_ERROR_SDM_LFCLK_SOURCE_UNKNOWN Unknown low frequency clock source selected
00121  */
00122 SVCALL(SD_SOFTDEVICE_ENABLE, uint32_t, sd_softdevice_enable(nrf_clock_lfclksrc_t clock_source, softdevice_assertion_handler_t assertion_handler));
00123 
00124 /**@brief Disables the SoftDevice and by extension the protocol stack.
00125  * 
00126  * Idempotent function to disable the SoftDevice.
00127  *
00128  * @post SoC library and protocol stack APIs are made unavailable.
00129  * @post All interrupts that was protected by the SoftDevice will be disabled and initialized to priority 0 (highest).
00130  * @post All peripherals used by the SoftDevice will be reset to default values.
00131  * @post All of RAM become available.
00132  * @post All interrupts are forwarded to the application.
00133  * @post LFCLK source chosen in ::sd_softdevice_enable will be left running.
00134  *
00135  * @retval ::NRF_SUCCESS
00136  */
00137 SVCALL(SD_SOFTDEVICE_DISABLE, uint32_t, sd_softdevice_disable(void));
00138 
00139 /**@brief Check if the SoftDevice is enabled.
00140  *
00141  * @param[out]  p_softdevice_enabled If the SoftDevice is enabled: 1 else 0.
00142  *
00143  * @retval ::NRF_SUCCESS
00144  */
00145 SVCALL(SD_SOFTDEVICE_IS_ENABLED, uint32_t, sd_softdevice_is_enabled(uint8_t * p_softdevice_enabled));
00146 
00147 /**@brief Start forwarding interrupts to application.
00148  * 
00149  * This function is only intended to be called when a bootloader is enabled is used.
00150  * The bootloader should call this right before it starts the application. 
00151  * It is recommended that all interrupt sources are off when this is called, 
00152  * or you could end up having interrupts in the application being executed before main() of the application.
00153  *
00154  * @retval ::NRF_SUCCESS
00155  */
00156 SVCALL(SD_SOFTDEVICE_FORWARD_TO_APPLICATION, uint32_t, sd_softdevice_forward_to_application(void)); 
00157 
00158 /** @} */
00159 
00160 #endif // NRF_SDM_H__
00161 
00162 /**
00163   @}
00164 */