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