Nordic stack and drivers for the mbed BLE API

Dependents:   idd_hw5_bleFanProto

Fork of nRF51822 by Nordic Semiconductor

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers nrf_soc.h Source File

nrf_soc.h

00001 /* Copyright (c) 2011 Nordic Semiconductor. All Rights Reserved.
00002  *
00003  * The information contained herein is confidential property of Nordic Semiconductor. The use,
00004  * copying, transfer or disclosure of such information is prohibited except by express written
00005  * agreement with Nordic Semiconductor.
00006  *
00007  */
00008  
00009 /**
00010  * @defgroup nrf_soc_api SoC Library API
00011  * @{
00012  * 
00013  * @brief APIs for the SoC library.
00014  * 
00015 */
00016 
00017 #ifndef NRF_SOC_H__
00018 #define NRF_SOC_H__
00019 
00020 #include <stdint.h>
00021 #include <stdbool.h>
00022 #include "nrf_svc.h"
00023 #include "nrf51.h"
00024 #include "nrf51_bitfields.h"
00025 #include "nrf_error_soc.h"
00026 
00027 /** @addtogroup NRF_SOC_DEFINES Defines
00028  * @{ */
00029 
00030 /**@brief The number of the lowest SVC number reserved for the SoC library. */
00031 #define SOC_SVC_BASE               (0x20)
00032 #define SOC_SVC_BASE_NOT_AVAILABLE (0x23)
00033 
00034 /**@brief Guranteed time for application to process radio inactive notification. */
00035 #define NRF_RADIO_NOTIFICATION_INACTIVE_GUARANTEED_TIME_US  (62)
00036 
00037 /**@brief The minimum allowed timeslot extension time. */
00038 #define NRF_RADIO_MINIMUM_TIMESLOT_LENGTH_EXTENSION_TIME_US (200)
00039 
00040 #define SOC_ECB_KEY_LENGTH            (16)                       /**< ECB key length. */
00041 #define SOC_ECB_CLEARTEXT_LENGTH      (16)                       /**< ECB cleartext length. */
00042 #define SOC_ECB_CIPHERTEXT_LENGTH     (SOC_ECB_CLEARTEXT_LENGTH) /**< ECB ciphertext length. */
00043 
00044 #define SD_EVT_IRQn                   (SWI2_IRQn)        /**< SoftDevice Event IRQ number. Used for both protocol events and SoC events. */
00045 #define SD_EVT_IRQHandler             (SWI2_IRQHandler)  /**< SoftDevice Event IRQ handler. Used for both protocol events and SoC events. */
00046 #define RADIO_NOTIFICATION_IRQn       (SWI1_IRQn)        /**< The radio notification IRQ number. */
00047 #define RADIO_NOTIFICATION_IRQHandler (SWI1_IRQHandler)  /**< The radio notification IRQ handler. */
00048 
00049 #define NRF_RADIO_LENGTH_MIN_US       (100)               /**< The shortest allowed radio timeslot, in microseconds. */
00050 #define NRF_RADIO_LENGTH_MAX_US       (100000)            /**< The longest allowed radio timeslot, in microseconds. */
00051 
00052 #define NRF_RADIO_DISTANCE_MAX_US         (128000000UL - 1UL) /**< The longest timeslot distance, in microseconds, allowed for the distance parameter (see @ref nrf_radio_request_normal_t) in the request. */
00053 
00054 #define NRF_RADIO_EARLIEST_TIMEOUT_MAX_US (128000000UL - 1UL) /**< The longest timeout, in microseconds, allowed when requesting the earliest possible timeslot. */
00055 
00056 #define NRF_RADIO_START_JITTER_US     (2)                 /**< The maximum jitter in NRF_RADIO_CALLBACK_SIGNAL_TYPE_START relative to the requested start time. */
00057 
00058 /** @} */
00059 
00060 /** @addtogroup NRF_SOC_TYPES Types
00061  * @{ */
00062 
00063 /**@brief The SVC numbers used by the SVC functions in the SoC library. */
00064 enum NRF_SOC_SVCS
00065 {
00066   SD_FLASH_PAGE_ERASE = SOC_SVC_BASE,
00067   SD_FLASH_WRITE,
00068   SD_FLASH_PROTECT,
00069   SD_MUTEX_NEW = SOC_SVC_BASE_NOT_AVAILABLE,
00070   SD_MUTEX_ACQUIRE,
00071   SD_MUTEX_RELEASE,
00072   SD_NVIC_ENABLEIRQ,
00073   SD_NVIC_DISABLEIRQ,
00074   SD_NVIC_GETPENDINGIRQ,
00075   SD_NVIC_SETPENDINGIRQ,
00076   SD_NVIC_CLEARPENDINGIRQ,
00077   SD_NVIC_SETPRIORITY,
00078   SD_NVIC_GETPRIORITY,
00079   SD_NVIC_SYSTEMRESET,
00080   SD_NVIC_CRITICAL_REGION_ENTER,
00081   SD_NVIC_CRITICAL_REGION_EXIT,
00082   SD_RAND_APPLICATION_POOL_CAPACITY,
00083   SD_RAND_APPLICATION_BYTES_AVAILABLE,
00084   SD_RAND_APPLICATION_GET_VECTOR,
00085   SD_POWER_MODE_SET,
00086   SD_POWER_SYSTEM_OFF,
00087   SD_POWER_RESET_REASON_GET,
00088   SD_POWER_RESET_REASON_CLR,
00089   SD_POWER_POF_ENABLE,
00090   SD_POWER_POF_THRESHOLD_SET,
00091   SD_POWER_RAMON_SET,
00092   SD_POWER_RAMON_CLR,
00093   SD_POWER_RAMON_GET,
00094   SD_POWER_GPREGRET_SET,
00095   SD_POWER_GPREGRET_CLR,
00096   SD_POWER_GPREGRET_GET,
00097   SD_POWER_DCDC_MODE_SET,
00098   SD_APP_EVT_WAIT,
00099   SD_CLOCK_HFCLK_REQUEST,
00100   SD_CLOCK_HFCLK_RELEASE,
00101   SD_CLOCK_HFCLK_IS_RUNNING,
00102   SD_PPI_CHANNEL_ENABLE_GET,
00103   SD_PPI_CHANNEL_ENABLE_SET,
00104   SD_PPI_CHANNEL_ENABLE_CLR,
00105   SD_PPI_CHANNEL_ASSIGN,
00106   SD_PPI_GROUP_TASK_ENABLE,
00107   SD_PPI_GROUP_TASK_DISABLE,
00108   SD_PPI_GROUP_ASSIGN,
00109   SD_PPI_GROUP_GET,
00110   SD_RADIO_NOTIFICATION_CFG_SET,
00111   SD_ECB_BLOCK_ENCRYPT,
00112   SD_RADIO_SESSION_OPEN,
00113   SD_RADIO_SESSION_CLOSE,
00114   SD_RADIO_REQUEST,
00115   SD_EVT_GET,
00116   SD_TEMP_GET,
00117   SVC_SOC_LAST
00118 };
00119 
00120 /**@brief Possible values of a ::nrf_mutex_t. */
00121 enum NRF_MUTEX_VALUES
00122 {
00123   NRF_MUTEX_FREE,
00124   NRF_MUTEX_TAKEN
00125 };
00126 
00127 /**@brief Possible values of ::nrf_app_irq_priority_t. */
00128 enum NRF_APP_PRIORITIES
00129 {
00130   NRF_APP_PRIORITY_HIGH = 1,
00131   NRF_APP_PRIORITY_LOW = 3
00132 };
00133 
00134 /**@brief Possible values of ::nrf_power_mode_t. */
00135 enum NRF_POWER_MODES
00136 {
00137   NRF_POWER_MODE_CONSTLAT,  /**< Constant latency mode. See power management in the reference manual. */
00138   NRF_POWER_MODE_LOWPWR     /**< Low power mode. See power management in the reference manual. */
00139 };
00140 
00141 
00142 /**@brief Possible values of ::nrf_power_failure_threshold_t */
00143 enum NRF_POWER_THRESHOLDS
00144 {
00145   NRF_POWER_THRESHOLD_V21,  /**< 2.1 Volts power failure threshold. */
00146   NRF_POWER_THRESHOLD_V23,  /**< 2.3 Volts power failure threshold. */
00147   NRF_POWER_THRESHOLD_V25,  /**< 2.5 Volts power failure threshold. */ 
00148   NRF_POWER_THRESHOLD_V27   /**< 2.7 Volts power failure threshold. */
00149 };
00150 
00151 
00152 /**@brief Possible values of ::nrf_power_dcdc_mode_t. */
00153 enum NRF_POWER_DCDC_MODES
00154 {
00155   NRF_POWER_DCDC_MODE_OFF,          /**< The DCDC is always off. */
00156   NRF_POWER_DCDC_MODE_ON,           /**< The DCDC is always on. */
00157   NRF_POWER_DCDC_MODE_AUTOMATIC     /**< The DCDC is automatically managed. */
00158 };
00159 
00160 /**@brief Possible values of ::nrf_radio_notification_distance_t. */
00161 enum NRF_RADIO_NOTIFICATION_DISTANCES
00162 {
00163   NRF_RADIO_NOTIFICATION_DISTANCE_NONE = 0, /**< The event does not have a notification. */
00164   NRF_RADIO_NOTIFICATION_DISTANCE_800US,    /**< The distance from the active notification to start of radio activity. */
00165   NRF_RADIO_NOTIFICATION_DISTANCE_1740US,   /**< The distance from the active notification to start of radio activity. */
00166   NRF_RADIO_NOTIFICATION_DISTANCE_2680US,   /**< The distance from the active notification to start of radio activity. */
00167   NRF_RADIO_NOTIFICATION_DISTANCE_3620US,   /**< The distance from the active notification to start of radio activity. */
00168   NRF_RADIO_NOTIFICATION_DISTANCE_4560US,   /**< The distance from the active notification to start of radio activity. */
00169   NRF_RADIO_NOTIFICATION_DISTANCE_5500US    /**< The distance from the active notification to start of radio activity. */
00170 };
00171 
00172 
00173 /**@brief Possible values of ::nrf_radio_notification_type_t. */
00174 enum NRF_RADIO_NOTIFICATION_TYPES
00175 {
00176   NRF_RADIO_NOTIFICATION_TYPE_NONE = 0,        /**< The event does not have a radio notification signal. */
00177   NRF_RADIO_NOTIFICATION_TYPE_INT_ON_ACTIVE,   /**< Using interrupt for notification when the radio will be enabled. */
00178   NRF_RADIO_NOTIFICATION_TYPE_INT_ON_INACTIVE, /**< Using interrupt for notification when the radio has been disabled. */
00179   NRF_RADIO_NOTIFICATION_TYPE_INT_ON_BOTH,     /**< Using interrupt for notification both when the radio will be enabled and disabled. */
00180 };
00181 
00182 /**@brief SoC Events. */
00183 enum NRF_SOC_EVTS
00184 {
00185   NRF_EVT_HFCLKSTARTED,                         /**< Event indicating that the HFCLK has started. */
00186   NRF_EVT_POWER_FAILURE_WARNING,                /**< Event indicating that a power failure warning has occurred. */
00187   NRF_EVT_FLASH_OPERATION_SUCCESS,              /**< Event indicating that the ongoing flash operation has completed successfully. */
00188   NRF_EVT_FLASH_OPERATION_ERROR,                /**< Event indicating that the ongoing flash operation has timed out with an error. */
00189   NRF_EVT_RADIO_BLOCKED,                        /**< Event indicating that a radio timeslot was blocked. */
00190   NRF_EVT_RADIO_CANCELED,                       /**< Event indicating that a radio timeslot was canceled by SoftDevice. */
00191   NRF_EVT_RADIO_SIGNAL_CALLBACK_INVALID_RETURN, /**< Event indicating that a radio signal callback handler return was invalid. */
00192   NRF_EVT_RADIO_SESSION_IDLE,                   /**< Event indicating that a radio session is idle. */
00193   NRF_EVT_RADIO_SESSION_CLOSED,                 /**< Event indicating that a radio session is closed. */
00194   NRF_EVT_NUMBER_OF_EVTS
00195 };
00196 
00197 /** @} */
00198 
00199 /** @addtogroup NRF_SOC_TYPES Types
00200  * @{ */
00201 
00202 /**@brief Represents a mutex for use with the nrf_mutex functions.
00203  * @note Accessing the value directly is not safe, use the mutex functions!
00204  */
00205 typedef volatile uint8_t nrf_mutex_t;
00206 
00207 /**@brief The interrupt priorities available to the application while the softdevice is active. */
00208 typedef uint8_t nrf_app_irq_priority_t;
00209 
00210 /**@brief Represents a power mode, used in power mode functions */
00211 typedef uint8_t nrf_power_mode_t;
00212 
00213 /**@brief Represents a power failure threshold value. */
00214 typedef uint8_t nrf_power_failure_threshold_t;
00215 
00216 /**@brief Represents a DCDC mode value. */
00217 typedef uint32_t nrf_power_dcdc_mode_t;
00218 
00219 /**@brief Radio notification distances. */
00220 typedef uint8_t nrf_radio_notification_distance_t;
00221 
00222 /**@brief Radio notification types. */
00223 typedef uint8_t nrf_radio_notification_type_t;
00224 
00225 /** @brief The Radio signal callback types. */
00226 enum NRF_RADIO_CALLBACK_SIGNAL_TYPE
00227 {
00228   NRF_RADIO_CALLBACK_SIGNAL_TYPE_START,            /**< This signal indicates the start of the radio timeslot. */
00229   NRF_RADIO_CALLBACK_SIGNAL_TYPE_TIMER0,            /**< This signal indicates the NRF_TIMER0 interrupt. */
00230   NRF_RADIO_CALLBACK_SIGNAL_TYPE_RADIO,             /**< This signal indicates the NRF_RADIO interrupt. */
00231   NRF_RADIO_CALLBACK_SIGNAL_TYPE_EXTEND_FAILED,     /**< This signal indicates extend action failed. */
00232   NRF_RADIO_CALLBACK_SIGNAL_TYPE_EXTEND_SUCCEEDED   /**< This signal indicates extend action succeeded. */
00233 };
00234 
00235 /** @brief The actions requested by the signal callback.
00236  *
00237  *  This code gives the SOC instructions about what action to take when the signal callback has
00238  *  returned.
00239  */
00240 enum NRF_RADIO_SIGNAL_CALLBACK_ACTION
00241 {
00242   NRF_RADIO_SIGNAL_CALLBACK_ACTION_NONE,            /**< Return without action. */
00243   NRF_RADIO_SIGNAL_CALLBACK_ACTION_EXTEND,          /**< Request an extension of the current timeslot (maximum execution time for this action is when the extension succeeded). */
00244   NRF_RADIO_SIGNAL_CALLBACK_ACTION_END,             /**< End the current radio timeslot. */
00245   NRF_RADIO_SIGNAL_CALLBACK_ACTION_REQUEST_AND_END  /**< Request a new radio timeslot and end the current timeslot. */
00246 };
00247 
00248 /**@brief Radio timeslot high frequency clock source configuration. */
00249 enum NRF_RADIO_HFCLK_CFG
00250 {
00251   NRF_RADIO_HFCLK_CFG_DEFAULT,                      /**< Use the currently selected oscillator as HF clock source during the timeslot (i.e. the source is not specified). */
00252   NRF_RADIO_HFCLK_CFG_FORCE_XTAL,                   /**< Force external crystal to be used as HF clock source during whole the timeslot. */
00253 };
00254 
00255 /** @brief Radio timeslot priorities. */
00256 enum NRF_RADIO_PRIORITY
00257 {
00258   NRF_RADIO_PRIORITY_HIGH,                          /**< High (equal priority as the normal connection priority of the SoftDevice stack(s)). */
00259   NRF_RADIO_PRIORITY_NORMAL,                        /**< Normal (equal priority as the priority of secondary activites of the SoftDevice stack(s)). */
00260 };
00261 
00262 /** @brief Radio timeslot request type. */
00263 enum NRF_RADIO_REQUEST_TYPE
00264 {
00265   NRF_RADIO_REQ_TYPE_EARLIEST,                      /**< Request timeslot as early as possible. This should always be used for the first request in a session. */
00266   NRF_RADIO_REQ_TYPE_NORMAL                         /**< Normal timeslot request. */
00267 };
00268 
00269 /** @brief Parameters for a request for a timeslot as early as possible. */
00270 typedef struct
00271 {
00272   uint8_t       hfclk;                              /**< High frequency clock source, see @ref NRF_RADIO_HFCLK_CFG. */
00273   uint8_t       priority;                           /**< The radio timeslot priority, see @ref NRF_RADIO_PRIORITY. */
00274   uint32_t      length_us;                          /**< The radio timeslot length (in the range 100 to 100,000] microseconds). */
00275   uint32_t      timeout_us;                         /**< Longest acceptable delay until the start of the requested timeslot (up to @ref NRF_RADIO_EARLIEST_TIMEOUT_MAX_US microseconds). */
00276 } nrf_radio_request_earliest_t;
00277 
00278 /** @brief Parameters for a normal radio request. */
00279 typedef struct
00280 {
00281   uint8_t       hfclk;                              /**< High frequency clock source, see @ref NRF_RADIO_HFCLK_CFG. */
00282   uint8_t       priority;                           /**< The radio timeslot priority, see @ref NRF_RADIO_PRIORITY. */
00283   uint32_t      distance_us;                        /**< Distance from the start of the previous radio timeslot (up to @ref NRF_RADIO_DISTANCE_MAX_US microseconds). */
00284   uint32_t      length_us;                          /**< The radio timeslot length (in the range [100..100,000] microseconds). */
00285 } nrf_radio_request_normal_t;
00286 
00287 /** @brief Radio request parameters. */
00288 typedef struct
00289 {
00290   uint8_t                         request_type;     /**< Type of request, see @ref NRF_RADIO_REQUEST_TYPE. */
00291   union
00292   {
00293     nrf_radio_request_earliest_t  earliest;         /**< Parameters for a request for a timeslot as early as possible. */
00294     nrf_radio_request_normal_t    normal;           /**< Parameters for a normal radio request. */
00295   } params;
00296 } nrf_radio_request_t;
00297 
00298 /**@brief Return parameters of the radio timeslot signal callback. */
00299 typedef struct
00300 {
00301   uint8_t               callback_action;            /**< The action requested by the application when returning from the signal callback, see @ref NRF_RADIO_SIGNAL_CALLBACK_ACTION. */
00302   union
00303   {
00304     struct
00305     {
00306       nrf_radio_request_t * p_next;                 /**< The request parameters for the next radio timeslot. */
00307     } request;                                      /**< Additional parameters for return_code @ref NRF_RADIO_SIGNAL_CALLBACK_ACTION_REQUEST_AND_END. */
00308     struct
00309     {
00310       uint32_t              length_us;              /**< Requested extension of the timeslot duration (microseconds) (for minimum time see @ref NRF_RADIO_MINIMUM_TIMESLOT_LENGTH_EXTENSION_TIME_US). */
00311     } extend;                                       /**< Additional parameters for return_code @ref NRF_RADIO_SIGNAL_CALLBACK_ACTION_EXTEND. */
00312   } params;
00313 } nrf_radio_signal_callback_return_param_t;
00314 
00315 /**@brief The radio signal callback type.
00316  *
00317  * @note In case of invalid return parameters, the radio timeslot will automatically end
00318  *       immediately after returning from the signal callback and the
00319  *       @ref NRF_EVT_RADIO_SIGNAL_CALLBACK_INVALID_RETURN event will be sent.
00320  * @note The returned struct pointer must remain valid after the signal callback
00321  *       function returns. For instance, this means that it must not point to a stack variable.
00322  *
00323  * @param[in] signal_type Type of signal, see @ref NRF_RADIO_CALLBACK_SIGNAL_TYPE.
00324  *
00325  * @return Pointer to structure containing action requested by the application.
00326  */
00327 typedef nrf_radio_signal_callback_return_param_t * (*nrf_radio_signal_callback_t) (uint8_t signal_type);
00328 
00329 /**@brief AES ECB data structure */
00330 typedef struct
00331 {
00332   uint8_t key[SOC_ECB_KEY_LENGTH];                  /**< Encryption key. */
00333   uint8_t cleartext[SOC_ECB_CLEARTEXT_LENGTH];      /**< Clear Text data. */
00334   uint8_t ciphertext[SOC_ECB_CIPHERTEXT_LENGTH];    /**< Cipher Text data. */
00335 } nrf_ecb_hal_data_t;
00336 
00337 /** @} */
00338 
00339 /** @addtogroup NRF_SOC_FUNCTIONS Functions
00340  * @{ */
00341 
00342 /**@brief Initialize a mutex.
00343  *
00344  * @param[in] p_mutex Pointer to the mutex to initialize.
00345  *
00346  * @retval ::NRF_SUCCESS
00347  */
00348 SVCALL(SD_MUTEX_NEW, uint32_t, sd_mutex_new(nrf_mutex_t * p_mutex));
00349 
00350 /**@brief Attempt to acquire a mutex.
00351  *
00352  * @param[in] p_mutex Pointer to the mutex to acquire.
00353  *
00354  * @retval ::NRF_SUCCESS The mutex was successfully acquired.
00355  * @retval ::NRF_ERROR_SOC_MUTEX_ALREADY_TAKEN The mutex could not be acquired.
00356  */
00357 SVCALL(SD_MUTEX_ACQUIRE, uint32_t, sd_mutex_acquire(nrf_mutex_t * p_mutex));
00358 
00359 /**@brief Release a mutex.
00360  *
00361  * @param[in] p_mutex Pointer to the mutex to release.
00362  *
00363  * @retval ::NRF_SUCCESS
00364  */
00365 SVCALL(SD_MUTEX_RELEASE, uint32_t, sd_mutex_release(nrf_mutex_t * p_mutex));
00366 
00367 /**@brief Enable External Interrupt.
00368  * @note Corresponds to NVIC_EnableIRQ in CMSIS.
00369  *
00370  * @pre{IRQn is valid and not reserved by the stack}
00371  *
00372  * @param[in] IRQn See the NVIC_EnableIRQ documentation in CMSIS.
00373  *
00374  * @retval ::NRF_SUCCESS The interrupt was enabled.
00375  * @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE The interrupt is not available for the application.
00376  * @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_PRIORITY_NOT_ALLOWED The interrupt has a priority not available for the application.
00377  */
00378 SVCALL(SD_NVIC_ENABLEIRQ, uint32_t, sd_nvic_EnableIRQ(IRQn_Type IRQn));
00379 
00380 /**@brief  Disable External Interrupt.
00381  * @note Corresponds to NVIC_DisableIRQ in CMSIS.
00382  *
00383  * @pre{IRQn is valid and not reserved by the stack}
00384  *
00385  * @param[in] IRQn See the NVIC_DisableIRQ documentation in CMSIS
00386  *
00387  * @retval ::NRF_SUCCESS The interrupt was disabled.
00388  * @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE The interrupt is not available for the application.
00389  */
00390 SVCALL(SD_NVIC_DISABLEIRQ, uint32_t, sd_nvic_DisableIRQ(IRQn_Type IRQn));
00391 
00392 /**@brief  Get Pending Interrupt.
00393  * @note Corresponds to NVIC_GetPendingIRQ in CMSIS.
00394  *
00395  * @pre{IRQn is valid and not reserved by the stack}
00396  *
00397  * @param[in]   IRQn          See the NVIC_GetPendingIRQ documentation in CMSIS.
00398  * @param[out]  p_pending_irq Return value from NVIC_GetPendingIRQ.
00399  *
00400  * @retval ::NRF_SUCCESS The interrupt is available for the application.
00401  * @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE IRQn is not available for the application.
00402  */
00403 SVCALL(SD_NVIC_GETPENDINGIRQ, uint32_t, sd_nvic_GetPendingIRQ(IRQn_Type IRQn, uint32_t * p_pending_irq));
00404 
00405 /**@brief  Set Pending Interrupt.
00406  * @note Corresponds to NVIC_SetPendingIRQ in CMSIS.
00407  *
00408  * @pre{IRQn is valid and not reserved by the stack}
00409  *
00410  * @param[in] IRQn See the NVIC_SetPendingIRQ documentation in CMSIS.
00411  *
00412  * @retval ::NRF_SUCCESS The interrupt is set pending.
00413  * @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE IRQn is not available for the application.
00414  */
00415 SVCALL(SD_NVIC_SETPENDINGIRQ, uint32_t, sd_nvic_SetPendingIRQ(IRQn_Type IRQn));
00416 
00417 /**@brief  Clear Pending Interrupt.
00418  * @note Corresponds to NVIC_ClearPendingIRQ in CMSIS.
00419  *
00420  * @pre{IRQn is valid and not reserved by the stack}
00421  *
00422  * @param[in] IRQn See the NVIC_ClearPendingIRQ documentation in CMSIS.
00423  *
00424  * @retval ::NRF_SUCCESS The interrupt pending flag is cleared.
00425  * @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE IRQn is not available for the application.
00426  */
00427 SVCALL(SD_NVIC_CLEARPENDINGIRQ, uint32_t, sd_nvic_ClearPendingIRQ(IRQn_Type IRQn));
00428 
00429 /**@brief Set Interrupt Priority.
00430  * @note Corresponds to NVIC_SetPriority in CMSIS.
00431  *
00432  * @pre{IRQn is valid and not reserved by the stack}
00433  * @pre{priority is valid and not reserved by the stack}
00434  *
00435  * @param[in] IRQn      See the NVIC_SetPriority documentation in CMSIS.
00436  * @param[in] priority  A valid IRQ priority for use by the application.
00437  *
00438  * @retval ::NRF_SUCCESS The interrupt and priority level is available for the application.
00439  * @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE IRQn is not available for the application.
00440  * @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_PRIORITY_NOT_ALLOWED The interrupt priority is not available for the application.
00441  */
00442 SVCALL(SD_NVIC_SETPRIORITY, uint32_t, sd_nvic_SetPriority(IRQn_Type IRQn, nrf_app_irq_priority_t priority));
00443 
00444 /**@brief Get Interrupt Priority.
00445  * @note Corresponds to NVIC_GetPriority in CMSIS.
00446  *
00447  * @pre{IRQn is valid and not reserved by the stack}
00448  *
00449  * @param[in]  IRQn         See the NVIC_GetPriority documentation in CMSIS.
00450  * @param[out] p_priority   Return value from NVIC_GetPriority.
00451  *
00452  * @retval ::NRF_SUCCESS The interrupt priority is returned in p_priority.
00453  * @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE - IRQn is not available for the application.
00454  */
00455 SVCALL(SD_NVIC_GETPRIORITY, uint32_t, sd_nvic_GetPriority(IRQn_Type IRQn, nrf_app_irq_priority_t * p_priority));
00456 
00457 /**@brief System Reset.
00458  * @note Corresponds to NVIC_SystemReset in CMSIS.
00459  *
00460  * @retval ::NRF_ERROR_SOC_NVIC_SHOULD_NOT_RETURN
00461  */
00462 SVCALL(SD_NVIC_SYSTEMRESET, uint32_t, sd_nvic_SystemReset(void));
00463 
00464 /**@brief Enters critical region.
00465  *
00466  * @post Application interrupts will be disabled.
00467  * @sa sd_nvic_critical_region_exit
00468  *
00469  * @param[out]  p_is_nested_critical_region  1: If in a nested critical region.
00470  *                                           0: Otherwise.
00471  *
00472  * @retval ::NRF_SUCCESS
00473  */
00474 SVCALL(SD_NVIC_CRITICAL_REGION_ENTER, uint32_t, sd_nvic_critical_region_enter(uint8_t * p_is_nested_critical_region));
00475 
00476 /**@brief Exit critical region.
00477  *
00478  * @pre Application has entered a critical region using ::sd_nvic_critical_region_enter.
00479  * @post If not in a nested critical region, the application interrupts will restored to the state before ::sd_nvic_critical_region_enter was called. 
00480  *
00481  * @param[in] is_nested_critical_region If this is set to 1, the critical region won't be exited. @sa sd_nvic_critical_region_enter.
00482  *
00483  * @retval ::NRF_SUCCESS
00484  */
00485 SVCALL(SD_NVIC_CRITICAL_REGION_EXIT, uint32_t, sd_nvic_critical_region_exit(uint8_t is_nested_critical_region));
00486 
00487 /**@brief Query the capacity of the application random pool.
00488  *
00489  * @param[out] p_pool_capacity The capacity of the pool.
00490  *
00491  * @retval ::NRF_SUCCESS
00492  */
00493 SVCALL(SD_RAND_APPLICATION_POOL_CAPACITY, uint32_t, sd_rand_application_pool_capacity_get(uint8_t * p_pool_capacity));
00494 
00495 /**@brief Get number of random bytes available to the application.
00496  *
00497  * @param[out] p_bytes_available The number of bytes currently available in the pool.
00498  *
00499  * @retval ::NRF_SUCCESS
00500  */
00501 SVCALL(SD_RAND_APPLICATION_BYTES_AVAILABLE, uint32_t, sd_rand_application_bytes_available_get(uint8_t * p_bytes_available));
00502 
00503 /**@brief Get random bytes from the application pool.
00504  *
00505  * @param[out]  p_buff  Pointer to unit8_t buffer for storing the bytes.
00506  * @param[in]   length  Number of bytes to take from pool and place in p_buff.
00507  *
00508  * @retval ::NRF_SUCCESS The requested bytes were written to p_buff.
00509  * @retval ::NRF_ERROR_SOC_RAND_NOT_ENOUGH_VALUES No bytes were written to the buffer, because there were not enough bytes available.
00510 */
00511 SVCALL(SD_RAND_APPLICATION_GET_VECTOR, uint32_t, sd_rand_application_vector_get(uint8_t * p_buff, uint8_t length));
00512 
00513 /**@brief Gets the reset reason register. 
00514  *
00515  * @param[out]  p_reset_reason  Contents of the NRF_POWER->RESETREAS register.
00516  *
00517  * @retval ::NRF_SUCCESS
00518  */
00519 SVCALL(SD_POWER_RESET_REASON_GET, uint32_t, sd_power_reset_reason_get(uint32_t * p_reset_reason));
00520 
00521 /**@brief Clears the bits of the reset reason register. 
00522  *
00523  * @param[in] reset_reason_clr_msk Contains the bits to clear from the reset reason register.
00524  *
00525  * @retval ::NRF_SUCCESS
00526  */
00527 SVCALL(SD_POWER_RESET_REASON_CLR, uint32_t, sd_power_reset_reason_clr(uint32_t reset_reason_clr_msk));
00528 
00529 /**@brief Sets the power mode when in CPU sleep.
00530  *
00531  * @param[in] power_mode The power mode to use when in CPU sleep. @sa sd_app_evt_wait
00532  *
00533  * @retval ::NRF_SUCCESS The power mode was set.
00534  * @retval ::NRF_ERROR_SOC_POWER_MODE_UNKNOWN The power mode was unknown.
00535  */
00536 SVCALL(SD_POWER_MODE_SET, uint32_t, sd_power_mode_set(nrf_power_mode_t power_mode));
00537 
00538 /**@brief Puts the chip in System OFF mode. 
00539  *
00540  * @retval ::NRF_ERROR_SOC_POWER_OFF_SHOULD_NOT_RETURN
00541  */
00542 SVCALL(SD_POWER_SYSTEM_OFF, uint32_t, sd_power_system_off(void));
00543 
00544 /**@brief Enables or disables the power-fail comparator.
00545  *
00546  * Enabling this will give a softdevice event (NRF_EVT_POWER_FAILURE_WARNING) when the power failure warning occurs.
00547  * The event can be retrieved with sd_evt_get();
00548  *
00549  * @param[in] pof_enable    True if the power-fail comparator should be enabled, false if it should be disabled.
00550  *
00551  * @retval ::NRF_SUCCESS
00552  */
00553 SVCALL(SD_POWER_POF_ENABLE, uint32_t, sd_power_pof_enable(uint8_t pof_enable));
00554 
00555 /**@brief Sets the power-fail threshold value.
00556  *
00557  * @param[in] threshold The power-fail threshold value to use.
00558  *
00559  * @retval ::NRF_SUCCESS The power failure threshold was set.
00560  * @retval ::NRF_ERROR_SOC_POWER_POF_THRESHOLD_UNKNOWN The power failure threshold is unknown.
00561  */
00562 SVCALL(SD_POWER_POF_THRESHOLD_SET, uint32_t, sd_power_pof_threshold_set(nrf_power_failure_threshold_t threshold));
00563 
00564 /**@brief Sets bits in the NRF_POWER->RAMON register.
00565  *
00566  * @param[in] ramon Contains the bits needed to be set in the NRF_POWER->RAMON register.
00567  *
00568  * @retval ::NRF_SUCCESS
00569  */
00570 SVCALL(SD_POWER_RAMON_SET, uint32_t, sd_power_ramon_set(uint32_t ramon));
00571 
00572 /** @brief Clears bits in the NRF_POWER->RAMON register.
00573  *
00574  * @param ramon Contains the bits needed to be cleared in the NRF_POWER->RAMON register.
00575  *
00576  * @retval ::NRF_SUCCESS
00577  */
00578 SVCALL(SD_POWER_RAMON_CLR, uint32_t, sd_power_ramon_clr(uint32_t ramon));
00579 
00580 /**@brief Get contents of NRF_POWER->RAMON register, indicates power status of ram blocks.
00581  *
00582  * @param[out] p_ramon Content of NRF_POWER->RAMON register.
00583  *
00584  * @retval ::NRF_SUCCESS
00585  */
00586 SVCALL(SD_POWER_RAMON_GET, uint32_t, sd_power_ramon_get(uint32_t * p_ramon));
00587 
00588 /**@brief Set bits in the NRF_POWER->GPREGRET register.
00589  *
00590  * @param[in] gpregret_msk Bits to be set in the GPREGRET register.
00591  *
00592  * @retval ::NRF_SUCCESS
00593  */
00594 SVCALL(SD_POWER_GPREGRET_SET, uint32_t, sd_power_gpregret_set(uint32_t gpregret_msk));
00595 
00596 /**@brief Clear bits in the NRF_POWER->GPREGRET register.
00597  *
00598  * @param[in] gpregret_msk Bits to be clear in the GPREGRET register.
00599  *
00600  * @retval ::NRF_SUCCESS
00601  */
00602 SVCALL(SD_POWER_GPREGRET_CLR, uint32_t, sd_power_gpregret_clr(uint32_t gpregret_msk));
00603 
00604 /**@brief Get contents of the NRF_POWER->GPREGRET register.
00605  *
00606  * @param[out] p_gpregret Contents of the GPREGRET register.
00607  *
00608  * @retval ::NRF_SUCCESS
00609  */
00610 SVCALL(SD_POWER_GPREGRET_GET, uint32_t, sd_power_gpregret_get(uint32_t *p_gpregret));
00611 
00612 /**@brief Sets the DCDC mode.
00613  *
00614  * Depending on the internal state of the SoftDevice, the mode change may not happen immediately.
00615  * The DCDC mode switch will be blocked when occurring in close proximity to radio transmissions. When
00616  * the radio transmission is done, the last mode will be used.
00617  *
00618  * @param[in] dcdc_mode The mode of the DCDC.
00619  *
00620  * @retval ::NRF_SUCCESS
00621  * @retval ::NRF_ERROR_INVALID_PARAM The DCDC mode is invalid.
00622  */
00623 SVCALL(SD_POWER_DCDC_MODE_SET, uint32_t, sd_power_dcdc_mode_set(nrf_power_dcdc_mode_t dcdc_mode));
00624 
00625 /**@brief Request the high frequency crystal oscillator.
00626  *
00627  * Will start the high frequency crystal oscillator, the startup time of the crystal varies
00628  * and the ::sd_clock_hfclk_is_running function can be polled to check if it has started.
00629  *
00630  * @see sd_clock_hfclk_is_running
00631  * @see sd_clock_hfclk_release
00632  *
00633  * @retval ::NRF_SUCCESS
00634  */
00635 SVCALL(SD_CLOCK_HFCLK_REQUEST, uint32_t, sd_clock_hfclk_request(void));
00636 
00637 /**@brief Releases the high frequency crystal oscillator.
00638  *
00639  * Will stop the high frequency crystal oscillator, this happens immediately.
00640  *
00641  * @see sd_clock_hfclk_is_running
00642  * @see sd_clock_hfclk_request
00643  *
00644  * @retval ::NRF_SUCCESS
00645  */
00646 SVCALL(SD_CLOCK_HFCLK_RELEASE, uint32_t, sd_clock_hfclk_release(void));
00647 
00648 /**@brief Checks if the high frequency crystal oscillator is running.
00649  *
00650  * @see sd_clock_hfclk_request
00651  * @see sd_clock_hfclk_release
00652  *
00653  * @param[out] p_is_running 1 if the external crystal oscillator is running, 0 if not.
00654  *
00655  * @retval ::NRF_SUCCESS
00656  */
00657 SVCALL(SD_CLOCK_HFCLK_IS_RUNNING, uint32_t, sd_clock_hfclk_is_running(uint32_t * p_is_running));
00658 
00659 /**@brief Waits for an application event.
00660  * 
00661  * An application event is either an application interrupt or a pended interrupt when the
00662  * interrupt is disabled. When the interrupt is enabled it will be taken immediately since
00663  * this function will wait in thread mode, then the execution will return in the application's
00664  * main thread. When an interrupt is disabled and gets pended it will return to the application's 
00665  * thread main. The application must ensure that the pended flag is cleared using 
00666  * ::sd_nvic_ClearPendingIRQ in order to sleep using this function. This is only necessary for
00667  * disabled interrupts, as the interrupt handler will clear the pending flag automatically for
00668  * enabled interrupts.
00669  *
00670  * In order to wake up from disabled interrupts, the SEVONPEND flag has to be set in the Cortex-M0
00671  * System Control Register (SCR). @sa CMSIS_SCB
00672  *
00673  * @note If an application interrupt has happened since the last time sd_app_evt_wait was
00674  *       called this function will return immediately and not go to sleep. This is to avoid race
00675  *       conditions that can occur when a flag is updated in the interrupt handler and processed
00676  *       in the main loop.
00677  *
00678  * @post An application interrupt has happened or a interrupt pending flag is set.
00679  *
00680  * @retval ::NRF_SUCCESS
00681  */
00682 SVCALL(SD_APP_EVT_WAIT, uint32_t, sd_app_evt_wait(void));
00683 
00684 /**@brief Get PPI channel enable register contents.
00685  *
00686  * @param[out] p_channel_enable The contents of the PPI CHEN register.
00687  *
00688  * @retval ::NRF_SUCCESS
00689  */
00690 SVCALL(SD_PPI_CHANNEL_ENABLE_GET, uint32_t, sd_ppi_channel_enable_get(uint32_t * p_channel_enable));
00691 
00692 /**@brief Set PPI channel enable register.
00693  *
00694  * @param[in] channel_enable_set_msk Mask containing the bits to set in the PPI CHEN register.
00695  *
00696  * @retval ::NRF_SUCCESS
00697  */
00698 SVCALL(SD_PPI_CHANNEL_ENABLE_SET, uint32_t, sd_ppi_channel_enable_set(uint32_t channel_enable_set_msk));
00699 
00700 /**@brief Clear PPI channel enable register.
00701  *
00702  * @param[in] channel_enable_clr_msk Mask containing the bits to clear in the PPI CHEN register.
00703  *
00704  * @retval ::NRF_SUCCESS
00705  */
00706 SVCALL(SD_PPI_CHANNEL_ENABLE_CLR, uint32_t, sd_ppi_channel_enable_clr(uint32_t channel_enable_clr_msk));
00707 
00708 /**@brief Assign endpoints to a PPI channel.
00709  *
00710  * @param[in] channel_num Number of the PPI channel to assign.
00711  * @param[in] evt_endpoint Event endpoint of the PPI channel.
00712  * @param[in] task_endpoint Task endpoint of the PPI channel.
00713  *
00714  * @retval ::NRF_ERROR_SOC_PPI_INVALID_CHANNEL The channel number is invalid.
00715  * @retval ::NRF_SUCCESS
00716  */
00717 SVCALL(SD_PPI_CHANNEL_ASSIGN, uint32_t, sd_ppi_channel_assign(uint8_t channel_num, const volatile void * evt_endpoint, const volatile void * task_endpoint));
00718 
00719 /**@brief Task to enable a channel group.
00720  *
00721  * @param[in] group_num Number of the channel group.
00722  *
00723  * @retval ::NRF_ERROR_SOC_PPI_INVALID_GROUP The group number is invalid
00724  * @retval ::NRF_SUCCESS
00725  */
00726 SVCALL(SD_PPI_GROUP_TASK_ENABLE, uint32_t, sd_ppi_group_task_enable(uint8_t group_num));
00727 
00728 /**@brief Task to disable a channel group.
00729  *
00730  * @param[in] group_num Number of the PPI group.
00731  *
00732  * @retval ::NRF_ERROR_SOC_PPI_INVALID_GROUP The group number is invalid.
00733  * @retval ::NRF_SUCCESS
00734  */
00735 SVCALL(SD_PPI_GROUP_TASK_DISABLE, uint32_t, sd_ppi_group_task_disable(uint8_t group_num));
00736 
00737 /**@brief Assign PPI channels to a channel group.
00738  *
00739  * @param[in] group_num Number of the channel group.
00740  * @param[in] channel_msk Mask of the channels to assign to the group.
00741  *
00742  * @retval ::NRF_ERROR_SOC_PPI_INVALID_GROUP The group number is invalid.
00743  * @retval ::NRF_SUCCESS
00744  */
00745 SVCALL(SD_PPI_GROUP_ASSIGN, uint32_t, sd_ppi_group_assign(uint8_t group_num, uint32_t channel_msk));
00746 
00747 /**@brief Gets the PPI channels of a channel group.
00748  *
00749  * @param[in]   group_num Number of the channel group.
00750  * @param[out]  p_channel_msk Mask of the channels assigned to the group.
00751  *
00752  * @retval ::NRF_ERROR_SOC_PPI_INVALID_GROUP The group number is invalid.
00753  * @retval ::NRF_SUCCESS
00754  */
00755 SVCALL(SD_PPI_GROUP_GET, uint32_t, sd_ppi_group_get(uint8_t group_num, uint32_t * p_channel_msk));
00756 
00757 /**@brief Configures the Radio Notification signal.
00758  *
00759  * @note
00760  *      - The notification signal latency depends on the interrupt priority settings of SWI used
00761  *        for notification signal.
00762  *      - In the period between the ACTIVE signal and the start of the Radio Event, the SoftDevice
00763  *        will interrupt the application to do Radio Event preparation.
00764  *      - Using the Radio Notification feature may limit the bandwidth, as the SoftDevice may have
00765  *        to shorten the connection events to have time for the Radio Notification signals.
00766  *
00767  * @param[in]  type      Type of notification signal.
00768  *                       @ref NRF_RADIO_NOTIFICATION_TYPE_NONE shall be used to turn off radio
00769  *                       notification. Using @ref NRF_RADIO_NOTIFICATION_DISTANCE_NONE is
00770  *                       recommended (but not required) to be used with
00771  *                       @ref NRF_RADIO_NOTIFICATION_TYPE_NONE.
00772  *
00773  * @param[in]  distance  Distance between the notification signal and start of radio activity.
00774  *                       This parameter is ignored when @ref NRF_RADIO_NOTIFICATION_TYPE_NONE or 
00775  *                       @ref NRF_RADIO_NOTIFICATION_TYPE_INT_ON_INACTIVE is used.
00776  *
00777  * @retval ::NRF_ERROR_INVALID_PARAM The group number is invalid.
00778  * @retval ::NRF_SUCCESS
00779  */
00780 SVCALL(SD_RADIO_NOTIFICATION_CFG_SET, uint32_t, sd_radio_notification_cfg_set(nrf_radio_notification_type_t type, nrf_radio_notification_distance_t distance));
00781 
00782 /**@brief Encrypts a block according to the specified parameters.
00783  *
00784  * 128-bit AES encryption.
00785  *
00786  * @param[in, out] p_ecb_data Pointer to the ECB parameters' struct (two input
00787  *                            parameters and one output parameter).
00788  *
00789  * @retval ::NRF_SUCCESS
00790  */
00791 SVCALL(SD_ECB_BLOCK_ENCRYPT, uint32_t, sd_ecb_block_encrypt(nrf_ecb_hal_data_t * p_ecb_data));
00792 
00793 /**@brief Gets any pending events generated by the SoC API.
00794  *
00795  * The application should keep calling this function to get events, until ::NRF_ERROR_NOT_FOUND is returned.
00796  *
00797  * @param[out] p_evt_id Set to one of the values in @ref NRF_SOC_EVTS, if any events are pending.
00798  *
00799  * @retval ::NRF_SUCCESS An event was pending. The event id is written in the p_evt_id parameter.
00800  * @retval ::NRF_ERROR_NOT_FOUND No pending events. 
00801  */
00802 SVCALL(SD_EVT_GET, uint32_t, sd_evt_get(uint32_t * p_evt_id));
00803 
00804 /**@brief Get the temperature measured on the chip
00805  * 
00806  * This function will block until the temperature measurement is done.
00807  * It takes around 50us from call to return.
00808  *
00809  * @note Pan #28 in PAN-028 v 1.6 "Negative measured values are not represented correctly" is corrected by this function.
00810  *
00811  * @param[out] p_temp Result of temperature measurement. Die temperature in 0.25 degrees celsius.
00812  *
00813  * @retval ::NRF_SUCCESS A temperature measurement was done, and the temperature was written to temp
00814  */
00815 SVCALL(SD_TEMP_GET, uint32_t, sd_temp_get(int32_t * p_temp));
00816 
00817 /**@brief Flash Write
00818  *
00819  * Commands to write a buffer to flash
00820  *
00821  * This call initiates the flash access command, and its completion will be communicated to the
00822  * application with exactly one of the following events:
00823  *      - NRF_EVT_FLASH_OPERATION_SUCCESS - The command was successfully completed.
00824  *      - NRF_EVT_FLASH_OPERATION_ERROR   - The command could not be started.
00825  *
00826  * @note
00827  *      - This call takes control over the radio and the CPU during flash erase and write to make sure that
00828  *        they will not interfere with the flash access. This means that all interrupts will be blocked
00829  *        for a predictable time (depending on the NVMC specification in nRF51 Series Reference Manual
00830  *        and the command parameters).
00831  *
00832  *
00833  * @param[in]  p_dst Pointer to start of flash location to be written.
00834  * @param[in]  p_src Pointer to buffer with data to be written
00835  * @param[in]  size  Number of 32-bit words to write. Maximum size is 256 32bit words.
00836  *
00837  * @retval ::NRF_ERROR_INVALID_ADDR   Tried to write to a non existing flash address, or p_dst or p_src was unaligned.
00838  * @retval ::NRF_ERROR_BUSY           The previous command has not yet completed.
00839  * @retval ::NRF_ERROR_INVALID_LENGTH Size was 0, or more than 256 words.
00840  * @retval ::NRF_ERROR_FORBIDDEN      Tried to write to or read from protected location.
00841  * @retval ::NRF_SUCCESS              The command was accepted.
00842  */
00843 SVCALL(SD_FLASH_WRITE, uint32_t, sd_flash_write(uint32_t * const p_dst, uint32_t const * const p_src, uint32_t size));
00844 
00845 
00846 /**@brief Flash Erase page
00847  *
00848  * Commands to erase a flash page
00849  *
00850  * This call initiates the flash access command, and its completion will be communicated to the
00851  * application with exactly one of the following events:
00852  *      - NRF_EVT_FLASH_OPERATION_SUCCESS - The command was successfully completed.
00853  *      - NRF_EVT_FLASH_OPERATION_ERROR   - The command could not be started.
00854  *
00855  * @note
00856  *      - This call takes control over the radio and the CPU during flash erase and write to make sure that
00857  *        they will not interfere with the flash access. This means that all interrupts will be blocked
00858  *        for a predictable time (depending on the NVMC specification in nRF51 Series Reference Manual
00859  *        and the command parameters).
00860  *
00861  *
00862  * @param[in]  page_number Pagenumber of the page to erase
00863  * @retval ::NRF_ERROR_INTERNAL      If a new session could not be opened due to an internal error.
00864  * @retval ::NRF_ERROR_INVALID_ADDR  Tried to erase to a non existing flash page.
00865  * @retval ::NRF_ERROR_BUSY          The previous command has not yet completed.
00866  * @retval ::NRF_ERROR_FORBIDDEN     Tried to erase a protected page.
00867  * @retval ::NRF_SUCCESS             The command was accepted.
00868  */
00869 SVCALL(SD_FLASH_PAGE_ERASE, uint32_t, sd_flash_page_erase(uint32_t page_number));
00870 
00871 
00872 /**@brief Flash Protection set
00873  *
00874  * Commands to set the flash protection registers PROTENSETx
00875  *
00876  * @note To read the values in PROTENSETx you can read them directly. They are only write-protected.
00877  *
00878  * @param[in]  protenset0 Value to be written to PROTENSET0
00879  * @param[in]  protenset1 Value to be written to PROTENSET1
00880  *
00881  * @retval ::NRF_ERROR_FORBIDDEN Tried to protect the SoftDevice
00882  * @retval ::NRF_SUCCESS Values successfully written to PROTENSETx
00883  */
00884 SVCALL(SD_FLASH_PROTECT, uint32_t, sd_flash_protect(uint32_t protenset0, uint32_t protenset1));
00885 
00886 /**@brief Opens a session for radio requests.
00887  *
00888  * @note Only one session can be open at a time.
00889  * @note p_radio_signal_callback(NRF_RADIO_CALLBACK_SIGNAL_TYPE_START) will be called when the radio timeslot
00890  *       starts. From this point the NRF_RADIO and NRF_TIMER0 peripherals can be freely accessed
00891  *       by the application.
00892  * @note p_radio_signal_callback(NRF_RADIO_CALLBACK_SIGNAL_TYPE_TIMER0) is called whenever the NRF_TIMER0
00893  *       interrupt occurs.
00894  * @note p_radio_signal_callback(NRF_RADIO_CALLBACK_SIGNAL_TYPE_RADIO) is called whenever the NRF_RADIO
00895  *       interrupt occurs.
00896  * @note p_radio_signal_callback() will be called at ARM interrupt priority level 0. This
00897  *       implies that none of the sd_* API calls can be used from p_radio_signal_callback().
00898  *
00899  * @param[in] p_radio_signal_callback The signal callback.
00900  *
00901  * @retval ::NRF_ERROR_INVALID_ADDR p_radio_signal_callback is an invalid function pointer.
00902  * @retval ::NRF_ERROR_BUSY If session cannot be opened.
00903  * @retval ::NRF_ERROR_INTERNAL If a new session could not be opened due to an internal error.
00904  * @retval ::NRF_SUCCESS Otherwise.
00905  */
00906  SVCALL(SD_RADIO_SESSION_OPEN, uint32_t, sd_radio_session_open(nrf_radio_signal_callback_t p_radio_signal_callback));
00907 
00908 /**@brief Closes a session for radio requests.
00909  *
00910  * @note Any current radio timeslot will be finished before the session is closed.
00911  * @note If a radio timeslot is scheduled when the session is closed, it will be canceled.
00912  * @note The application cannot consider the session closed until the NRF_EVT_RADIO_SESSION_CLOSED
00913  *       event is received.
00914  *
00915  * @retval ::NRF_ERROR_FORBIDDEN If session not opened.
00916  * @retval ::NRF_ERROR_BUSY If session is currently being closed.
00917  * @retval ::NRF_SUCCESS Otherwise.
00918  */
00919  SVCALL(SD_RADIO_SESSION_CLOSE, uint32_t, sd_radio_session_close(void));
00920 
00921  /**@brief Requests a radio timeslot.
00922  *
00923  * @note The timing of the radio timeslot is specified by p_request->distance_us. For the first
00924  *       request in a session, p_request->distance_us is required to be 0 by convention, and
00925  *       the timeslot is scheduled at the first possible opportunity. All following radio timeslots are
00926  *       requested with a distance of p_request->distance_us measured from the start of the
00927  *       previous radio timeslot.
00928  * @note A too small p_request->distance_us will lead to a NRF_EVT_RADIO_BLOCKED event.
00929  * @note Timeslots scheduled too close will lead to a NRF_EVT_RADIO_BLOCKED event.
00930  * @note See the SoftDevice Specification for more on radio timeslot scheduling, distances and lengths.
00931  * @note If an opportunity for the first radio timeslot is not found before 100ms after the call to this
00932  *       function, it is not scheduled, and instead a NRF_EVT_RADIO_BLOCKED event is sent.
00933  *       The application may then try to schedule the first radio timeslot again.
00934  * @note Successful requests will result in nrf_radio_signal_callback_t(NRF_RADIO_CALLBACK_SIGNAL_TYPE_START).
00935  *       Unsuccessful requests will result in a NRF_EVT_RADIO_BLOCKED event, see @ref NRF_SOC_EVTS.
00936  * @note The jitter in the start time of the radio timeslots is +/- NRF_RADIO_START_JITTER_US us.
00937  * @note The nrf_radio_signal_callback_t(NRF_RADIO_CALLBACK_SIGNAL_TYPE_START) call has a latency relative to the
00938  *       specified radio timeslot start, but this does not affect the actual start time of the timeslot.
00939  * @note NRF_TIMER0 is reset at the start of the radio timeslot, and is clocked at 1MHz from the high frequency
00940  *       (16 MHz) clock source. If p_request->hfclk_force_xtal is true, the high frequency clock is 
00941  *       guaranteed to be clocked from the external crystal.
00942  * @note The SoftDevice will neither access the NRF_RADIO peripheral nor the NRF_TIMER0 peripheral
00943  *       during the radio timeslot.
00944  *
00945  * @param[in] p_request Pointer to the request parameters.
00946  *
00947  * @retval ::NRF_ERROR_FORBIDDEN If session not opened or the session is not IDLE.
00948  * @retval ::NRF_ERROR_INVALID_ADDR If the p_request pointer is invalid.
00949  * @retval ::NRF_ERROR_INVALID_PARAM If the parameters of p_request are not valid.
00950  * @retval ::NRF_SUCCESS Otherwise.
00951  */
00952  SVCALL(SD_RADIO_REQUEST, uint32_t, sd_radio_request(nrf_radio_request_t * p_request ));
00953 
00954 /** @} */
00955 
00956 #endif // NRF_SOC_H__
00957 
00958 /**@} */