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