test

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