SG RFID nRF51822 fork

Fork of nRF51822 by Nordic Semiconductor

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