BLE FOTA APP

Dependencies:   BLE_API mbed

It doesn't work with the default FOTA bootloader. It use NVIC_SystemReset() to enter a bootloader.

Committer:
yihui
Date:
Fri Oct 10 03:36:28 2014 +0000
Revision:
1:a607cd9655d7
use NVIC_SystemReset() to run bootloader

Who changed what in which revision?

UserRevisionLine numberNew contents of line
yihui 1:a607cd9655d7 1 /* Copyright (c) 2011 Nordic Semiconductor. All Rights Reserved.
yihui 1:a607cd9655d7 2 *
yihui 1:a607cd9655d7 3 * The information contained herein is confidential property of Nordic Semiconductor. The use,
yihui 1:a607cd9655d7 4 * copying, transfer or disclosure of such information is prohibited except by express written
yihui 1:a607cd9655d7 5 * agreement with Nordic Semiconductor.
yihui 1:a607cd9655d7 6 *
yihui 1:a607cd9655d7 7 */
yihui 1:a607cd9655d7 8
yihui 1:a607cd9655d7 9 /**
yihui 1:a607cd9655d7 10 * @defgroup nrf_soc_api SoC Library API
yihui 1:a607cd9655d7 11 * @{
yihui 1:a607cd9655d7 12 *
yihui 1:a607cd9655d7 13 * @brief APIs for the SoC library.
yihui 1:a607cd9655d7 14 *
yihui 1:a607cd9655d7 15 */
yihui 1:a607cd9655d7 16
yihui 1:a607cd9655d7 17 #ifndef NRF_SOC_H__
yihui 1:a607cd9655d7 18 #define NRF_SOC_H__
yihui 1:a607cd9655d7 19
yihui 1:a607cd9655d7 20 #include <stdint.h>
yihui 1:a607cd9655d7 21 #include <stdbool.h>
yihui 1:a607cd9655d7 22 #include "nrf_svc.h"
yihui 1:a607cd9655d7 23 #include "nrf51.h"
yihui 1:a607cd9655d7 24 #include "nrf51_bitfields.h"
yihui 1:a607cd9655d7 25 #include "nrf_error_soc.h"
yihui 1:a607cd9655d7 26
yihui 1:a607cd9655d7 27 /** @addtogroup NRF_SOC_DEFINES Defines
yihui 1:a607cd9655d7 28 * @{ */
yihui 1:a607cd9655d7 29
yihui 1:a607cd9655d7 30 /**@brief The number of the lowest SVC number reserved for the SoC library. */
yihui 1:a607cd9655d7 31 #define SOC_SVC_BASE (0x20)
yihui 1:a607cd9655d7 32 #define SOC_SVC_BASE_NOT_AVAILABLE (0x23)
yihui 1:a607cd9655d7 33
yihui 1:a607cd9655d7 34 /**@brief Guranteed time for application to process radio inactive notification. */
yihui 1:a607cd9655d7 35 #define NRF_RADIO_NOTIFICATION_INACTIVE_GUARANTEED_TIME_US (62)
yihui 1:a607cd9655d7 36
yihui 1:a607cd9655d7 37 /**@brief The minimum allowed timeslot extension time. */
yihui 1:a607cd9655d7 38 #define NRF_RADIO_MINIMUM_TIMESLOT_LENGTH_EXTENSION_TIME_US (200)
yihui 1:a607cd9655d7 39
yihui 1:a607cd9655d7 40 #define SOC_ECB_KEY_LENGTH (16) /**< ECB key length. */
yihui 1:a607cd9655d7 41 #define SOC_ECB_CLEARTEXT_LENGTH (16) /**< ECB cleartext length. */
yihui 1:a607cd9655d7 42 #define SOC_ECB_CIPHERTEXT_LENGTH (SOC_ECB_CLEARTEXT_LENGTH) /**< ECB ciphertext length. */
yihui 1:a607cd9655d7 43
yihui 1:a607cd9655d7 44 #define SD_EVT_IRQn (SWI2_IRQn) /**< SoftDevice Event IRQ number. Used for both protocol events and SoC events. */
yihui 1:a607cd9655d7 45 #define SD_EVT_IRQHandler (SWI2_IRQHandler) /**< SoftDevice Event IRQ handler. Used for both protocol events and SoC events. */
yihui 1:a607cd9655d7 46 #define RADIO_NOTIFICATION_IRQn (SWI1_IRQn) /**< The radio notification IRQ number. */
yihui 1:a607cd9655d7 47 #define RADIO_NOTIFICATION_IRQHandler (SWI1_IRQHandler) /**< The radio notification IRQ handler. */
yihui 1:a607cd9655d7 48
yihui 1:a607cd9655d7 49 #define NRF_RADIO_LENGTH_MIN_US (100) /**< The shortest allowed radio timeslot, in microseconds. */
yihui 1:a607cd9655d7 50 #define NRF_RADIO_LENGTH_MAX_US (100000) /**< The longest allowed radio timeslot, in microseconds. */
yihui 1:a607cd9655d7 51
yihui 1:a607cd9655d7 52 #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. */
yihui 1:a607cd9655d7 53
yihui 1:a607cd9655d7 54 #define NRF_RADIO_EARLIEST_TIMEOUT_MAX_US (128000000UL - 1UL) /**< The longest timeout, in microseconds, allowed when requesting the earliest possible timeslot. */
yihui 1:a607cd9655d7 55
yihui 1:a607cd9655d7 56 #define NRF_RADIO_START_JITTER_US (2) /**< The maximum jitter in NRF_RADIO_CALLBACK_SIGNAL_TYPE_START relative to the requested start time. */
yihui 1:a607cd9655d7 57
yihui 1:a607cd9655d7 58 /** @} */
yihui 1:a607cd9655d7 59
yihui 1:a607cd9655d7 60 /** @addtogroup NRF_SOC_TYPES Types
yihui 1:a607cd9655d7 61 * @{ */
yihui 1:a607cd9655d7 62
yihui 1:a607cd9655d7 63 /**@brief The SVC numbers used by the SVC functions in the SoC library. */
yihui 1:a607cd9655d7 64 enum NRF_SOC_SVCS
yihui 1:a607cd9655d7 65 {
yihui 1:a607cd9655d7 66 SD_FLASH_PAGE_ERASE = SOC_SVC_BASE,
yihui 1:a607cd9655d7 67 SD_FLASH_WRITE,
yihui 1:a607cd9655d7 68 SD_FLASH_PROTECT,
yihui 1:a607cd9655d7 69 SD_MUTEX_NEW = SOC_SVC_BASE_NOT_AVAILABLE,
yihui 1:a607cd9655d7 70 SD_MUTEX_ACQUIRE,
yihui 1:a607cd9655d7 71 SD_MUTEX_RELEASE,
yihui 1:a607cd9655d7 72 SD_NVIC_ENABLEIRQ,
yihui 1:a607cd9655d7 73 SD_NVIC_DISABLEIRQ,
yihui 1:a607cd9655d7 74 SD_NVIC_GETPENDINGIRQ,
yihui 1:a607cd9655d7 75 SD_NVIC_SETPENDINGIRQ,
yihui 1:a607cd9655d7 76 SD_NVIC_CLEARPENDINGIRQ,
yihui 1:a607cd9655d7 77 SD_NVIC_SETPRIORITY,
yihui 1:a607cd9655d7 78 SD_NVIC_GETPRIORITY,
yihui 1:a607cd9655d7 79 SD_NVIC_SYSTEMRESET,
yihui 1:a607cd9655d7 80 SD_NVIC_CRITICAL_REGION_ENTER,
yihui 1:a607cd9655d7 81 SD_NVIC_CRITICAL_REGION_EXIT,
yihui 1:a607cd9655d7 82 SD_RAND_APPLICATION_POOL_CAPACITY,
yihui 1:a607cd9655d7 83 SD_RAND_APPLICATION_BYTES_AVAILABLE,
yihui 1:a607cd9655d7 84 SD_RAND_APPLICATION_GET_VECTOR,
yihui 1:a607cd9655d7 85 SD_POWER_MODE_SET,
yihui 1:a607cd9655d7 86 SD_POWER_SYSTEM_OFF,
yihui 1:a607cd9655d7 87 SD_POWER_RESET_REASON_GET,
yihui 1:a607cd9655d7 88 SD_POWER_RESET_REASON_CLR,
yihui 1:a607cd9655d7 89 SD_POWER_POF_ENABLE,
yihui 1:a607cd9655d7 90 SD_POWER_POF_THRESHOLD_SET,
yihui 1:a607cd9655d7 91 SD_POWER_RAMON_SET,
yihui 1:a607cd9655d7 92 SD_POWER_RAMON_CLR,
yihui 1:a607cd9655d7 93 SD_POWER_RAMON_GET,
yihui 1:a607cd9655d7 94 SD_POWER_GPREGRET_SET,
yihui 1:a607cd9655d7 95 SD_POWER_GPREGRET_CLR,
yihui 1:a607cd9655d7 96 SD_POWER_GPREGRET_GET,
yihui 1:a607cd9655d7 97 SD_POWER_DCDC_MODE_SET,
yihui 1:a607cd9655d7 98 SD_APP_EVT_WAIT,
yihui 1:a607cd9655d7 99 SD_CLOCK_HFCLK_REQUEST,
yihui 1:a607cd9655d7 100 SD_CLOCK_HFCLK_RELEASE,
yihui 1:a607cd9655d7 101 SD_CLOCK_HFCLK_IS_RUNNING,
yihui 1:a607cd9655d7 102 SD_PPI_CHANNEL_ENABLE_GET,
yihui 1:a607cd9655d7 103 SD_PPI_CHANNEL_ENABLE_SET,
yihui 1:a607cd9655d7 104 SD_PPI_CHANNEL_ENABLE_CLR,
yihui 1:a607cd9655d7 105 SD_PPI_CHANNEL_ASSIGN,
yihui 1:a607cd9655d7 106 SD_PPI_GROUP_TASK_ENABLE,
yihui 1:a607cd9655d7 107 SD_PPI_GROUP_TASK_DISABLE,
yihui 1:a607cd9655d7 108 SD_PPI_GROUP_ASSIGN,
yihui 1:a607cd9655d7 109 SD_PPI_GROUP_GET,
yihui 1:a607cd9655d7 110 SD_RADIO_NOTIFICATION_CFG_SET,
yihui 1:a607cd9655d7 111 SD_ECB_BLOCK_ENCRYPT,
yihui 1:a607cd9655d7 112 SD_RADIO_SESSION_OPEN,
yihui 1:a607cd9655d7 113 SD_RADIO_SESSION_CLOSE,
yihui 1:a607cd9655d7 114 SD_RADIO_REQUEST,
yihui 1:a607cd9655d7 115 SD_EVT_GET,
yihui 1:a607cd9655d7 116 SD_TEMP_GET,
yihui 1:a607cd9655d7 117 SVC_SOC_LAST
yihui 1:a607cd9655d7 118 };
yihui 1:a607cd9655d7 119
yihui 1:a607cd9655d7 120 /**@brief Possible values of a ::nrf_mutex_t. */
yihui 1:a607cd9655d7 121 enum NRF_MUTEX_VALUES
yihui 1:a607cd9655d7 122 {
yihui 1:a607cd9655d7 123 NRF_MUTEX_FREE,
yihui 1:a607cd9655d7 124 NRF_MUTEX_TAKEN
yihui 1:a607cd9655d7 125 };
yihui 1:a607cd9655d7 126
yihui 1:a607cd9655d7 127 /**@brief Possible values of ::nrf_app_irq_priority_t. */
yihui 1:a607cd9655d7 128 enum NRF_APP_PRIORITIES
yihui 1:a607cd9655d7 129 {
yihui 1:a607cd9655d7 130 NRF_APP_PRIORITY_HIGH = 1,
yihui 1:a607cd9655d7 131 NRF_APP_PRIORITY_LOW = 3
yihui 1:a607cd9655d7 132 };
yihui 1:a607cd9655d7 133
yihui 1:a607cd9655d7 134 /**@brief Possible values of ::nrf_power_mode_t. */
yihui 1:a607cd9655d7 135 enum NRF_POWER_MODES
yihui 1:a607cd9655d7 136 {
yihui 1:a607cd9655d7 137 NRF_POWER_MODE_CONSTLAT, /**< Constant latency mode. See power management in the reference manual. */
yihui 1:a607cd9655d7 138 NRF_POWER_MODE_LOWPWR /**< Low power mode. See power management in the reference manual. */
yihui 1:a607cd9655d7 139 };
yihui 1:a607cd9655d7 140
yihui 1:a607cd9655d7 141
yihui 1:a607cd9655d7 142 /**@brief Possible values of ::nrf_power_failure_threshold_t */
yihui 1:a607cd9655d7 143 enum NRF_POWER_THRESHOLDS
yihui 1:a607cd9655d7 144 {
yihui 1:a607cd9655d7 145 NRF_POWER_THRESHOLD_V21, /**< 2.1 Volts power failure threshold. */
yihui 1:a607cd9655d7 146 NRF_POWER_THRESHOLD_V23, /**< 2.3 Volts power failure threshold. */
yihui 1:a607cd9655d7 147 NRF_POWER_THRESHOLD_V25, /**< 2.5 Volts power failure threshold. */
yihui 1:a607cd9655d7 148 NRF_POWER_THRESHOLD_V27 /**< 2.7 Volts power failure threshold. */
yihui 1:a607cd9655d7 149 };
yihui 1:a607cd9655d7 150
yihui 1:a607cd9655d7 151
yihui 1:a607cd9655d7 152 /**@brief Possible values of ::nrf_power_dcdc_mode_t. */
yihui 1:a607cd9655d7 153 enum NRF_POWER_DCDC_MODES
yihui 1:a607cd9655d7 154 {
yihui 1:a607cd9655d7 155 NRF_POWER_DCDC_MODE_OFF, /**< The DCDC is always off. */
yihui 1:a607cd9655d7 156 NRF_POWER_DCDC_MODE_ON, /**< The DCDC is always on. */
yihui 1:a607cd9655d7 157 NRF_POWER_DCDC_MODE_AUTOMATIC /**< The DCDC is automatically managed. */
yihui 1:a607cd9655d7 158 };
yihui 1:a607cd9655d7 159
yihui 1:a607cd9655d7 160 /**@brief Possible values of ::nrf_radio_notification_distance_t. */
yihui 1:a607cd9655d7 161 enum NRF_RADIO_NOTIFICATION_DISTANCES
yihui 1:a607cd9655d7 162 {
yihui 1:a607cd9655d7 163 NRF_RADIO_NOTIFICATION_DISTANCE_NONE = 0, /**< The event does not have a notification. */
yihui 1:a607cd9655d7 164 NRF_RADIO_NOTIFICATION_DISTANCE_800US, /**< The distance from the active notification to start of radio activity. */
yihui 1:a607cd9655d7 165 NRF_RADIO_NOTIFICATION_DISTANCE_1740US, /**< The distance from the active notification to start of radio activity. */
yihui 1:a607cd9655d7 166 NRF_RADIO_NOTIFICATION_DISTANCE_2680US, /**< The distance from the active notification to start of radio activity. */
yihui 1:a607cd9655d7 167 NRF_RADIO_NOTIFICATION_DISTANCE_3620US, /**< The distance from the active notification to start of radio activity. */
yihui 1:a607cd9655d7 168 NRF_RADIO_NOTIFICATION_DISTANCE_4560US, /**< The distance from the active notification to start of radio activity. */
yihui 1:a607cd9655d7 169 NRF_RADIO_NOTIFICATION_DISTANCE_5500US /**< The distance from the active notification to start of radio activity. */
yihui 1:a607cd9655d7 170 };
yihui 1:a607cd9655d7 171
yihui 1:a607cd9655d7 172
yihui 1:a607cd9655d7 173 /**@brief Possible values of ::nrf_radio_notification_type_t. */
yihui 1:a607cd9655d7 174 enum NRF_RADIO_NOTIFICATION_TYPES
yihui 1:a607cd9655d7 175 {
yihui 1:a607cd9655d7 176 NRF_RADIO_NOTIFICATION_TYPE_NONE = 0, /**< The event does not have a radio notification signal. */
yihui 1:a607cd9655d7 177 NRF_RADIO_NOTIFICATION_TYPE_INT_ON_ACTIVE, /**< Using interrupt for notification when the radio will be enabled. */
yihui 1:a607cd9655d7 178 NRF_RADIO_NOTIFICATION_TYPE_INT_ON_INACTIVE, /**< Using interrupt for notification when the radio has been disabled. */
yihui 1:a607cd9655d7 179 NRF_RADIO_NOTIFICATION_TYPE_INT_ON_BOTH, /**< Using interrupt for notification both when the radio will be enabled and disabled. */
yihui 1:a607cd9655d7 180 };
yihui 1:a607cd9655d7 181
yihui 1:a607cd9655d7 182 /**@brief SoC Events. */
yihui 1:a607cd9655d7 183 enum NRF_SOC_EVTS
yihui 1:a607cd9655d7 184 {
yihui 1:a607cd9655d7 185 NRF_EVT_HFCLKSTARTED, /**< Event indicating that the HFCLK has started. */
yihui 1:a607cd9655d7 186 NRF_EVT_POWER_FAILURE_WARNING, /**< Event indicating that a power failure warning has occurred. */
yihui 1:a607cd9655d7 187 NRF_EVT_FLASH_OPERATION_SUCCESS, /**< Event indicating that the ongoing flash operation has completed successfully. */
yihui 1:a607cd9655d7 188 NRF_EVT_FLASH_OPERATION_ERROR, /**< Event indicating that the ongoing flash operation has timed out with an error. */
yihui 1:a607cd9655d7 189 NRF_EVT_RADIO_BLOCKED, /**< Event indicating that a radio timeslot was blocked. */
yihui 1:a607cd9655d7 190 NRF_EVT_RADIO_CANCELED, /**< Event indicating that a radio timeslot was canceled by SoftDevice. */
yihui 1:a607cd9655d7 191 NRF_EVT_RADIO_SIGNAL_CALLBACK_INVALID_RETURN, /**< Event indicating that a radio signal callback handler return was invalid. */
yihui 1:a607cd9655d7 192 NRF_EVT_RADIO_SESSION_IDLE, /**< Event indicating that a radio session is idle. */
yihui 1:a607cd9655d7 193 NRF_EVT_RADIO_SESSION_CLOSED, /**< Event indicating that a radio session is closed. */
yihui 1:a607cd9655d7 194 NRF_EVT_NUMBER_OF_EVTS
yihui 1:a607cd9655d7 195 };
yihui 1:a607cd9655d7 196
yihui 1:a607cd9655d7 197 /** @} */
yihui 1:a607cd9655d7 198
yihui 1:a607cd9655d7 199 /** @addtogroup NRF_SOC_TYPES Types
yihui 1:a607cd9655d7 200 * @{ */
yihui 1:a607cd9655d7 201
yihui 1:a607cd9655d7 202 /**@brief Represents a mutex for use with the nrf_mutex functions.
yihui 1:a607cd9655d7 203 * @note Accessing the value directly is not safe, use the mutex functions!
yihui 1:a607cd9655d7 204 */
yihui 1:a607cd9655d7 205 typedef volatile uint8_t nrf_mutex_t;
yihui 1:a607cd9655d7 206
yihui 1:a607cd9655d7 207 /**@brief The interrupt priorities available to the application while the softdevice is active. */
yihui 1:a607cd9655d7 208 typedef uint8_t nrf_app_irq_priority_t;
yihui 1:a607cd9655d7 209
yihui 1:a607cd9655d7 210 /**@brief Represents a power mode, used in power mode functions */
yihui 1:a607cd9655d7 211 typedef uint8_t nrf_power_mode_t;
yihui 1:a607cd9655d7 212
yihui 1:a607cd9655d7 213 /**@brief Represents a power failure threshold value. */
yihui 1:a607cd9655d7 214 typedef uint8_t nrf_power_failure_threshold_t;
yihui 1:a607cd9655d7 215
yihui 1:a607cd9655d7 216 /**@brief Represents a DCDC mode value. */
yihui 1:a607cd9655d7 217 typedef uint32_t nrf_power_dcdc_mode_t;
yihui 1:a607cd9655d7 218
yihui 1:a607cd9655d7 219 /**@brief Radio notification distances. */
yihui 1:a607cd9655d7 220 typedef uint8_t nrf_radio_notification_distance_t;
yihui 1:a607cd9655d7 221
yihui 1:a607cd9655d7 222 /**@brief Radio notification types. */
yihui 1:a607cd9655d7 223 typedef uint8_t nrf_radio_notification_type_t;
yihui 1:a607cd9655d7 224
yihui 1:a607cd9655d7 225 /** @brief The Radio signal callback types. */
yihui 1:a607cd9655d7 226 enum NRF_RADIO_CALLBACK_SIGNAL_TYPE
yihui 1:a607cd9655d7 227 {
yihui 1:a607cd9655d7 228 NRF_RADIO_CALLBACK_SIGNAL_TYPE_START, /**< This signal indicates the start of the radio timeslot. */
yihui 1:a607cd9655d7 229 NRF_RADIO_CALLBACK_SIGNAL_TYPE_TIMER0, /**< This signal indicates the NRF_TIMER0 interrupt. */
yihui 1:a607cd9655d7 230 NRF_RADIO_CALLBACK_SIGNAL_TYPE_RADIO, /**< This signal indicates the NRF_RADIO interrupt. */
yihui 1:a607cd9655d7 231 NRF_RADIO_CALLBACK_SIGNAL_TYPE_EXTEND_FAILED, /**< This signal indicates extend action failed. */
yihui 1:a607cd9655d7 232 NRF_RADIO_CALLBACK_SIGNAL_TYPE_EXTEND_SUCCEEDED /**< This signal indicates extend action succeeded. */
yihui 1:a607cd9655d7 233 };
yihui 1:a607cd9655d7 234
yihui 1:a607cd9655d7 235 /** @brief The actions requested by the signal callback.
yihui 1:a607cd9655d7 236 *
yihui 1:a607cd9655d7 237 * This code gives the SOC instructions about what action to take when the signal callback has
yihui 1:a607cd9655d7 238 * returned.
yihui 1:a607cd9655d7 239 */
yihui 1:a607cd9655d7 240 enum NRF_RADIO_SIGNAL_CALLBACK_ACTION
yihui 1:a607cd9655d7 241 {
yihui 1:a607cd9655d7 242 NRF_RADIO_SIGNAL_CALLBACK_ACTION_NONE, /**< Return without action. */
yihui 1:a607cd9655d7 243 NRF_RADIO_SIGNAL_CALLBACK_ACTION_EXTEND, /**< Request an extension of the current timeslot (maximum execution time for this action is when the extension succeeded). */
yihui 1:a607cd9655d7 244 NRF_RADIO_SIGNAL_CALLBACK_ACTION_END, /**< End the current radio timeslot. */
yihui 1:a607cd9655d7 245 NRF_RADIO_SIGNAL_CALLBACK_ACTION_REQUEST_AND_END /**< Request a new radio timeslot and end the current timeslot. */
yihui 1:a607cd9655d7 246 };
yihui 1:a607cd9655d7 247
yihui 1:a607cd9655d7 248 /**@brief Radio timeslot high frequency clock source configuration. */
yihui 1:a607cd9655d7 249 enum NRF_RADIO_HFCLK_CFG
yihui 1:a607cd9655d7 250 {
yihui 1:a607cd9655d7 251 NRF_RADIO_HFCLK_CFG_DEFAULT, /**< Use the currently selected oscillator as HF clock source during the timeslot (i.e. the source is not specified). */
yihui 1:a607cd9655d7 252 NRF_RADIO_HFCLK_CFG_FORCE_XTAL, /**< Force external crystal to be used as HF clock source during whole the timeslot. */
yihui 1:a607cd9655d7 253 };
yihui 1:a607cd9655d7 254
yihui 1:a607cd9655d7 255 /** @brief Radio timeslot priorities. */
yihui 1:a607cd9655d7 256 enum NRF_RADIO_PRIORITY
yihui 1:a607cd9655d7 257 {
yihui 1:a607cd9655d7 258 NRF_RADIO_PRIORITY_HIGH, /**< High (equal priority as the normal connection priority of the SoftDevice stack(s)). */
yihui 1:a607cd9655d7 259 NRF_RADIO_PRIORITY_NORMAL, /**< Normal (equal priority as the priority of secondary activites of the SoftDevice stack(s)). */
yihui 1:a607cd9655d7 260 };
yihui 1:a607cd9655d7 261
yihui 1:a607cd9655d7 262 /** @brief Radio timeslot request type. */
yihui 1:a607cd9655d7 263 enum NRF_RADIO_REQUEST_TYPE
yihui 1:a607cd9655d7 264 {
yihui 1:a607cd9655d7 265 NRF_RADIO_REQ_TYPE_EARLIEST, /**< Request timeslot as early as possible. This should always be used for the first request in a session. */
yihui 1:a607cd9655d7 266 NRF_RADIO_REQ_TYPE_NORMAL /**< Normal timeslot request. */
yihui 1:a607cd9655d7 267 };
yihui 1:a607cd9655d7 268
yihui 1:a607cd9655d7 269 /** @brief Parameters for a request for a timeslot as early as possible. */
yihui 1:a607cd9655d7 270 typedef struct
yihui 1:a607cd9655d7 271 {
yihui 1:a607cd9655d7 272 uint8_t hfclk; /**< High frequency clock source, see @ref NRF_RADIO_HFCLK_CFG. */
yihui 1:a607cd9655d7 273 uint8_t priority; /**< The radio timeslot priority, see @ref NRF_RADIO_PRIORITY. */
yihui 1:a607cd9655d7 274 uint32_t length_us; /**< The radio timeslot length (in the range 100 to 100,000] microseconds). */
yihui 1:a607cd9655d7 275 uint32_t timeout_us; /**< Longest acceptable delay until the start of the requested timeslot (up to @ref NRF_RADIO_EARLIEST_TIMEOUT_MAX_US microseconds). */
yihui 1:a607cd9655d7 276 } nrf_radio_request_earliest_t;
yihui 1:a607cd9655d7 277
yihui 1:a607cd9655d7 278 /** @brief Parameters for a normal radio request. */
yihui 1:a607cd9655d7 279 typedef struct
yihui 1:a607cd9655d7 280 {
yihui 1:a607cd9655d7 281 uint8_t hfclk; /**< High frequency clock source, see @ref NRF_RADIO_HFCLK_CFG. */
yihui 1:a607cd9655d7 282 uint8_t priority; /**< The radio timeslot priority, see @ref NRF_RADIO_PRIORITY. */
yihui 1:a607cd9655d7 283 uint32_t distance_us; /**< Distance from the start of the previous radio timeslot (up to @ref NRF_RADIO_DISTANCE_MAX_US microseconds). */
yihui 1:a607cd9655d7 284 uint32_t length_us; /**< The radio timeslot length (in the range [100..100,000] microseconds). */
yihui 1:a607cd9655d7 285 } nrf_radio_request_normal_t;
yihui 1:a607cd9655d7 286
yihui 1:a607cd9655d7 287 /** @brief Radio request parameters. */
yihui 1:a607cd9655d7 288 typedef struct
yihui 1:a607cd9655d7 289 {
yihui 1:a607cd9655d7 290 uint8_t request_type; /**< Type of request, see @ref NRF_RADIO_REQUEST_TYPE. */
yihui 1:a607cd9655d7 291 union
yihui 1:a607cd9655d7 292 {
yihui 1:a607cd9655d7 293 nrf_radio_request_earliest_t earliest; /**< Parameters for a request for a timeslot as early as possible. */
yihui 1:a607cd9655d7 294 nrf_radio_request_normal_t normal; /**< Parameters for a normal radio request. */
yihui 1:a607cd9655d7 295 } params;
yihui 1:a607cd9655d7 296 } nrf_radio_request_t;
yihui 1:a607cd9655d7 297
yihui 1:a607cd9655d7 298 /**@brief Return parameters of the radio timeslot signal callback. */
yihui 1:a607cd9655d7 299 typedef struct
yihui 1:a607cd9655d7 300 {
yihui 1:a607cd9655d7 301 uint8_t callback_action; /**< The action requested by the application when returning from the signal callback, see @ref NRF_RADIO_SIGNAL_CALLBACK_ACTION. */
yihui 1:a607cd9655d7 302 union
yihui 1:a607cd9655d7 303 {
yihui 1:a607cd9655d7 304 struct
yihui 1:a607cd9655d7 305 {
yihui 1:a607cd9655d7 306 nrf_radio_request_t * p_next; /**< The request parameters for the next radio timeslot. */
yihui 1:a607cd9655d7 307 } request; /**< Additional parameters for return_code @ref NRF_RADIO_SIGNAL_CALLBACK_ACTION_REQUEST_AND_END. */
yihui 1:a607cd9655d7 308 struct
yihui 1:a607cd9655d7 309 {
yihui 1:a607cd9655d7 310 uint32_t length_us; /**< Requested extension of the timeslot duration (microseconds) (for minimum time see @ref NRF_RADIO_MINIMUM_TIMESLOT_LENGTH_EXTENSION_TIME_US). */
yihui 1:a607cd9655d7 311 } extend; /**< Additional parameters for return_code @ref NRF_RADIO_SIGNAL_CALLBACK_ACTION_EXTEND. */
yihui 1:a607cd9655d7 312 } params;
yihui 1:a607cd9655d7 313 } nrf_radio_signal_callback_return_param_t;
yihui 1:a607cd9655d7 314
yihui 1:a607cd9655d7 315 /**@brief The radio signal callback type.
yihui 1:a607cd9655d7 316 *
yihui 1:a607cd9655d7 317 * @note In case of invalid return parameters, the radio timeslot will automatically end
yihui 1:a607cd9655d7 318 * immediately after returning from the signal callback and the
yihui 1:a607cd9655d7 319 * @ref NRF_EVT_RADIO_SIGNAL_CALLBACK_INVALID_RETURN event will be sent.
yihui 1:a607cd9655d7 320 * @note The returned struct pointer must remain valid after the signal callback
yihui 1:a607cd9655d7 321 * function returns. For instance, this means that it must not point to a stack variable.
yihui 1:a607cd9655d7 322 *
yihui 1:a607cd9655d7 323 * @param[in] signal_type Type of signal, see @ref NRF_RADIO_CALLBACK_SIGNAL_TYPE.
yihui 1:a607cd9655d7 324 *
yihui 1:a607cd9655d7 325 * @return Pointer to structure containing action requested by the application.
yihui 1:a607cd9655d7 326 */
yihui 1:a607cd9655d7 327 typedef nrf_radio_signal_callback_return_param_t * (*nrf_radio_signal_callback_t) (uint8_t signal_type);
yihui 1:a607cd9655d7 328
yihui 1:a607cd9655d7 329 /**@brief AES ECB data structure */
yihui 1:a607cd9655d7 330 typedef struct
yihui 1:a607cd9655d7 331 {
yihui 1:a607cd9655d7 332 uint8_t key[SOC_ECB_KEY_LENGTH]; /**< Encryption key. */
yihui 1:a607cd9655d7 333 uint8_t cleartext[SOC_ECB_CLEARTEXT_LENGTH]; /**< Clear Text data. */
yihui 1:a607cd9655d7 334 uint8_t ciphertext[SOC_ECB_CIPHERTEXT_LENGTH]; /**< Cipher Text data. */
yihui 1:a607cd9655d7 335 } nrf_ecb_hal_data_t;
yihui 1:a607cd9655d7 336
yihui 1:a607cd9655d7 337 /** @} */
yihui 1:a607cd9655d7 338
yihui 1:a607cd9655d7 339 /** @addtogroup NRF_SOC_FUNCTIONS Functions
yihui 1:a607cd9655d7 340 * @{ */
yihui 1:a607cd9655d7 341
yihui 1:a607cd9655d7 342 /**@brief Initialize a mutex.
yihui 1:a607cd9655d7 343 *
yihui 1:a607cd9655d7 344 * @param[in] p_mutex Pointer to the mutex to initialize.
yihui 1:a607cd9655d7 345 *
yihui 1:a607cd9655d7 346 * @retval ::NRF_SUCCESS
yihui 1:a607cd9655d7 347 */
yihui 1:a607cd9655d7 348 SVCALL(SD_MUTEX_NEW, uint32_t, sd_mutex_new(nrf_mutex_t * p_mutex));
yihui 1:a607cd9655d7 349
yihui 1:a607cd9655d7 350 /**@brief Attempt to acquire a mutex.
yihui 1:a607cd9655d7 351 *
yihui 1:a607cd9655d7 352 * @param[in] p_mutex Pointer to the mutex to acquire.
yihui 1:a607cd9655d7 353 *
yihui 1:a607cd9655d7 354 * @retval ::NRF_SUCCESS The mutex was successfully acquired.
yihui 1:a607cd9655d7 355 * @retval ::NRF_ERROR_SOC_MUTEX_ALREADY_TAKEN The mutex could not be acquired.
yihui 1:a607cd9655d7 356 */
yihui 1:a607cd9655d7 357 SVCALL(SD_MUTEX_ACQUIRE, uint32_t, sd_mutex_acquire(nrf_mutex_t * p_mutex));
yihui 1:a607cd9655d7 358
yihui 1:a607cd9655d7 359 /**@brief Release a mutex.
yihui 1:a607cd9655d7 360 *
yihui 1:a607cd9655d7 361 * @param[in] p_mutex Pointer to the mutex to release.
yihui 1:a607cd9655d7 362 *
yihui 1:a607cd9655d7 363 * @retval ::NRF_SUCCESS
yihui 1:a607cd9655d7 364 */
yihui 1:a607cd9655d7 365 SVCALL(SD_MUTEX_RELEASE, uint32_t, sd_mutex_release(nrf_mutex_t * p_mutex));
yihui 1:a607cd9655d7 366
yihui 1:a607cd9655d7 367 /**@brief Enable External Interrupt.
yihui 1:a607cd9655d7 368 * @note Corresponds to NVIC_EnableIRQ in CMSIS.
yihui 1:a607cd9655d7 369 *
yihui 1:a607cd9655d7 370 * @pre{IRQn is valid and not reserved by the stack}
yihui 1:a607cd9655d7 371 *
yihui 1:a607cd9655d7 372 * @param[in] IRQn See the NVIC_EnableIRQ documentation in CMSIS.
yihui 1:a607cd9655d7 373 *
yihui 1:a607cd9655d7 374 * @retval ::NRF_SUCCESS The interrupt was enabled.
yihui 1:a607cd9655d7 375 * @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE The interrupt is not available for the application.
yihui 1:a607cd9655d7 376 * @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_PRIORITY_NOT_ALLOWED The interrupt has a priority not available for the application.
yihui 1:a607cd9655d7 377 */
yihui 1:a607cd9655d7 378 SVCALL(SD_NVIC_ENABLEIRQ, uint32_t, sd_nvic_EnableIRQ(IRQn_Type IRQn));
yihui 1:a607cd9655d7 379
yihui 1:a607cd9655d7 380 /**@brief Disable External Interrupt.
yihui 1:a607cd9655d7 381 * @note Corresponds to NVIC_DisableIRQ in CMSIS.
yihui 1:a607cd9655d7 382 *
yihui 1:a607cd9655d7 383 * @pre{IRQn is valid and not reserved by the stack}
yihui 1:a607cd9655d7 384 *
yihui 1:a607cd9655d7 385 * @param[in] IRQn See the NVIC_DisableIRQ documentation in CMSIS
yihui 1:a607cd9655d7 386 *
yihui 1:a607cd9655d7 387 * @retval ::NRF_SUCCESS The interrupt was disabled.
yihui 1:a607cd9655d7 388 * @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE The interrupt is not available for the application.
yihui 1:a607cd9655d7 389 */
yihui 1:a607cd9655d7 390 SVCALL(SD_NVIC_DISABLEIRQ, uint32_t, sd_nvic_DisableIRQ(IRQn_Type IRQn));
yihui 1:a607cd9655d7 391
yihui 1:a607cd9655d7 392 /**@brief Get Pending Interrupt.
yihui 1:a607cd9655d7 393 * @note Corresponds to NVIC_GetPendingIRQ in CMSIS.
yihui 1:a607cd9655d7 394 *
yihui 1:a607cd9655d7 395 * @pre{IRQn is valid and not reserved by the stack}
yihui 1:a607cd9655d7 396 *
yihui 1:a607cd9655d7 397 * @param[in] IRQn See the NVIC_GetPendingIRQ documentation in CMSIS.
yihui 1:a607cd9655d7 398 * @param[out] p_pending_irq Return value from NVIC_GetPendingIRQ.
yihui 1:a607cd9655d7 399 *
yihui 1:a607cd9655d7 400 * @retval ::NRF_SUCCESS The interrupt is available for the application.
yihui 1:a607cd9655d7 401 * @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE IRQn is not available for the application.
yihui 1:a607cd9655d7 402 */
yihui 1:a607cd9655d7 403 SVCALL(SD_NVIC_GETPENDINGIRQ, uint32_t, sd_nvic_GetPendingIRQ(IRQn_Type IRQn, uint32_t * p_pending_irq));
yihui 1:a607cd9655d7 404
yihui 1:a607cd9655d7 405 /**@brief Set Pending Interrupt.
yihui 1:a607cd9655d7 406 * @note Corresponds to NVIC_SetPendingIRQ in CMSIS.
yihui 1:a607cd9655d7 407 *
yihui 1:a607cd9655d7 408 * @pre{IRQn is valid and not reserved by the stack}
yihui 1:a607cd9655d7 409 *
yihui 1:a607cd9655d7 410 * @param[in] IRQn See the NVIC_SetPendingIRQ documentation in CMSIS.
yihui 1:a607cd9655d7 411 *
yihui 1:a607cd9655d7 412 * @retval ::NRF_SUCCESS The interrupt is set pending.
yihui 1:a607cd9655d7 413 * @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE IRQn is not available for the application.
yihui 1:a607cd9655d7 414 */
yihui 1:a607cd9655d7 415 SVCALL(SD_NVIC_SETPENDINGIRQ, uint32_t, sd_nvic_SetPendingIRQ(IRQn_Type IRQn));
yihui 1:a607cd9655d7 416
yihui 1:a607cd9655d7 417 /**@brief Clear Pending Interrupt.
yihui 1:a607cd9655d7 418 * @note Corresponds to NVIC_ClearPendingIRQ in CMSIS.
yihui 1:a607cd9655d7 419 *
yihui 1:a607cd9655d7 420 * @pre{IRQn is valid and not reserved by the stack}
yihui 1:a607cd9655d7 421 *
yihui 1:a607cd9655d7 422 * @param[in] IRQn See the NVIC_ClearPendingIRQ documentation in CMSIS.
yihui 1:a607cd9655d7 423 *
yihui 1:a607cd9655d7 424 * @retval ::NRF_SUCCESS The interrupt pending flag is cleared.
yihui 1:a607cd9655d7 425 * @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE IRQn is not available for the application.
yihui 1:a607cd9655d7 426 */
yihui 1:a607cd9655d7 427 SVCALL(SD_NVIC_CLEARPENDINGIRQ, uint32_t, sd_nvic_ClearPendingIRQ(IRQn_Type IRQn));
yihui 1:a607cd9655d7 428
yihui 1:a607cd9655d7 429 /**@brief Set Interrupt Priority.
yihui 1:a607cd9655d7 430 * @note Corresponds to NVIC_SetPriority in CMSIS.
yihui 1:a607cd9655d7 431 *
yihui 1:a607cd9655d7 432 * @pre{IRQn is valid and not reserved by the stack}
yihui 1:a607cd9655d7 433 * @pre{priority is valid and not reserved by the stack}
yihui 1:a607cd9655d7 434 *
yihui 1:a607cd9655d7 435 * @param[in] IRQn See the NVIC_SetPriority documentation in CMSIS.
yihui 1:a607cd9655d7 436 * @param[in] priority A valid IRQ priority for use by the application.
yihui 1:a607cd9655d7 437 *
yihui 1:a607cd9655d7 438 * @retval ::NRF_SUCCESS The interrupt and priority level is available for the application.
yihui 1:a607cd9655d7 439 * @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE IRQn is not available for the application.
yihui 1:a607cd9655d7 440 * @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_PRIORITY_NOT_ALLOWED The interrupt priority is not available for the application.
yihui 1:a607cd9655d7 441 */
yihui 1:a607cd9655d7 442 SVCALL(SD_NVIC_SETPRIORITY, uint32_t, sd_nvic_SetPriority(IRQn_Type IRQn, nrf_app_irq_priority_t priority));
yihui 1:a607cd9655d7 443
yihui 1:a607cd9655d7 444 /**@brief Get Interrupt Priority.
yihui 1:a607cd9655d7 445 * @note Corresponds to NVIC_GetPriority in CMSIS.
yihui 1:a607cd9655d7 446 *
yihui 1:a607cd9655d7 447 * @pre{IRQn is valid and not reserved by the stack}
yihui 1:a607cd9655d7 448 *
yihui 1:a607cd9655d7 449 * @param[in] IRQn See the NVIC_GetPriority documentation in CMSIS.
yihui 1:a607cd9655d7 450 * @param[out] p_priority Return value from NVIC_GetPriority.
yihui 1:a607cd9655d7 451 *
yihui 1:a607cd9655d7 452 * @retval ::NRF_SUCCESS The interrupt priority is returned in p_priority.
yihui 1:a607cd9655d7 453 * @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE - IRQn is not available for the application.
yihui 1:a607cd9655d7 454 */
yihui 1:a607cd9655d7 455 SVCALL(SD_NVIC_GETPRIORITY, uint32_t, sd_nvic_GetPriority(IRQn_Type IRQn, nrf_app_irq_priority_t * p_priority));
yihui 1:a607cd9655d7 456
yihui 1:a607cd9655d7 457 /**@brief System Reset.
yihui 1:a607cd9655d7 458 * @note Corresponds to NVIC_SystemReset in CMSIS.
yihui 1:a607cd9655d7 459 *
yihui 1:a607cd9655d7 460 * @retval ::NRF_ERROR_SOC_NVIC_SHOULD_NOT_RETURN
yihui 1:a607cd9655d7 461 */
yihui 1:a607cd9655d7 462 SVCALL(SD_NVIC_SYSTEMRESET, uint32_t, sd_nvic_SystemReset(void));
yihui 1:a607cd9655d7 463
yihui 1:a607cd9655d7 464 /**@brief Enters critical region.
yihui 1:a607cd9655d7 465 *
yihui 1:a607cd9655d7 466 * @post Application interrupts will be disabled.
yihui 1:a607cd9655d7 467 * @sa sd_nvic_critical_region_exit
yihui 1:a607cd9655d7 468 *
yihui 1:a607cd9655d7 469 * @param[out] p_is_nested_critical_region 1: If in a nested critical region.
yihui 1:a607cd9655d7 470 * 0: Otherwise.
yihui 1:a607cd9655d7 471 *
yihui 1:a607cd9655d7 472 * @retval ::NRF_SUCCESS
yihui 1:a607cd9655d7 473 */
yihui 1:a607cd9655d7 474 SVCALL(SD_NVIC_CRITICAL_REGION_ENTER, uint32_t, sd_nvic_critical_region_enter(uint8_t * p_is_nested_critical_region));
yihui 1:a607cd9655d7 475
yihui 1:a607cd9655d7 476 /**@brief Exit critical region.
yihui 1:a607cd9655d7 477 *
yihui 1:a607cd9655d7 478 * @pre Application has entered a critical region using ::sd_nvic_critical_region_enter.
yihui 1:a607cd9655d7 479 * @post If not in a nested critical region, the application interrupts will restored to the state before ::sd_nvic_critical_region_enter was called.
yihui 1:a607cd9655d7 480 *
yihui 1:a607cd9655d7 481 * @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.
yihui 1:a607cd9655d7 482 *
yihui 1:a607cd9655d7 483 * @retval ::NRF_SUCCESS
yihui 1:a607cd9655d7 484 */
yihui 1:a607cd9655d7 485 SVCALL(SD_NVIC_CRITICAL_REGION_EXIT, uint32_t, sd_nvic_critical_region_exit(uint8_t is_nested_critical_region));
yihui 1:a607cd9655d7 486
yihui 1:a607cd9655d7 487 /**@brief Query the capacity of the application random pool.
yihui 1:a607cd9655d7 488 *
yihui 1:a607cd9655d7 489 * @param[out] p_pool_capacity The capacity of the pool.
yihui 1:a607cd9655d7 490 *
yihui 1:a607cd9655d7 491 * @retval ::NRF_SUCCESS
yihui 1:a607cd9655d7 492 */
yihui 1:a607cd9655d7 493 SVCALL(SD_RAND_APPLICATION_POOL_CAPACITY, uint32_t, sd_rand_application_pool_capacity_get(uint8_t * p_pool_capacity));
yihui 1:a607cd9655d7 494
yihui 1:a607cd9655d7 495 /**@brief Get number of random bytes available to the application.
yihui 1:a607cd9655d7 496 *
yihui 1:a607cd9655d7 497 * @param[out] p_bytes_available The number of bytes currently available in the pool.
yihui 1:a607cd9655d7 498 *
yihui 1:a607cd9655d7 499 * @retval ::NRF_SUCCESS
yihui 1:a607cd9655d7 500 */
yihui 1:a607cd9655d7 501 SVCALL(SD_RAND_APPLICATION_BYTES_AVAILABLE, uint32_t, sd_rand_application_bytes_available_get(uint8_t * p_bytes_available));
yihui 1:a607cd9655d7 502
yihui 1:a607cd9655d7 503 /**@brief Get random bytes from the application pool.
yihui 1:a607cd9655d7 504 *
yihui 1:a607cd9655d7 505 * @param[out] p_buff Pointer to unit8_t buffer for storing the bytes.
yihui 1:a607cd9655d7 506 * @param[in] length Number of bytes to take from pool and place in p_buff.
yihui 1:a607cd9655d7 507 *
yihui 1:a607cd9655d7 508 * @retval ::NRF_SUCCESS The requested bytes were written to p_buff.
yihui 1:a607cd9655d7 509 * @retval ::NRF_ERROR_SOC_RAND_NOT_ENOUGH_VALUES No bytes were written to the buffer, because there were not enough bytes available.
yihui 1:a607cd9655d7 510 */
yihui 1:a607cd9655d7 511 SVCALL(SD_RAND_APPLICATION_GET_VECTOR, uint32_t, sd_rand_application_vector_get(uint8_t * p_buff, uint8_t length));
yihui 1:a607cd9655d7 512
yihui 1:a607cd9655d7 513 /**@brief Gets the reset reason register.
yihui 1:a607cd9655d7 514 *
yihui 1:a607cd9655d7 515 * @param[out] p_reset_reason Contents of the NRF_POWER->RESETREAS register.
yihui 1:a607cd9655d7 516 *
yihui 1:a607cd9655d7 517 * @retval ::NRF_SUCCESS
yihui 1:a607cd9655d7 518 */
yihui 1:a607cd9655d7 519 SVCALL(SD_POWER_RESET_REASON_GET, uint32_t, sd_power_reset_reason_get(uint32_t * p_reset_reason));
yihui 1:a607cd9655d7 520
yihui 1:a607cd9655d7 521 /**@brief Clears the bits of the reset reason register.
yihui 1:a607cd9655d7 522 *
yihui 1:a607cd9655d7 523 * @param[in] reset_reason_clr_msk Contains the bits to clear from the reset reason register.
yihui 1:a607cd9655d7 524 *
yihui 1:a607cd9655d7 525 * @retval ::NRF_SUCCESS
yihui 1:a607cd9655d7 526 */
yihui 1:a607cd9655d7 527 SVCALL(SD_POWER_RESET_REASON_CLR, uint32_t, sd_power_reset_reason_clr(uint32_t reset_reason_clr_msk));
yihui 1:a607cd9655d7 528
yihui 1:a607cd9655d7 529 /**@brief Sets the power mode when in CPU sleep.
yihui 1:a607cd9655d7 530 *
yihui 1:a607cd9655d7 531 * @param[in] power_mode The power mode to use when in CPU sleep. @sa sd_app_evt_wait
yihui 1:a607cd9655d7 532 *
yihui 1:a607cd9655d7 533 * @retval ::NRF_SUCCESS The power mode was set.
yihui 1:a607cd9655d7 534 * @retval ::NRF_ERROR_SOC_POWER_MODE_UNKNOWN The power mode was unknown.
yihui 1:a607cd9655d7 535 */
yihui 1:a607cd9655d7 536 SVCALL(SD_POWER_MODE_SET, uint32_t, sd_power_mode_set(nrf_power_mode_t power_mode));
yihui 1:a607cd9655d7 537
yihui 1:a607cd9655d7 538 /**@brief Puts the chip in System OFF mode.
yihui 1:a607cd9655d7 539 *
yihui 1:a607cd9655d7 540 * @retval ::NRF_ERROR_SOC_POWER_OFF_SHOULD_NOT_RETURN
yihui 1:a607cd9655d7 541 */
yihui 1:a607cd9655d7 542 SVCALL(SD_POWER_SYSTEM_OFF, uint32_t, sd_power_system_off(void));
yihui 1:a607cd9655d7 543
yihui 1:a607cd9655d7 544 /**@brief Enables or disables the power-fail comparator.
yihui 1:a607cd9655d7 545 *
yihui 1:a607cd9655d7 546 * Enabling this will give a softdevice event (NRF_EVT_POWER_FAILURE_WARNING) when the power failure warning occurs.
yihui 1:a607cd9655d7 547 * The event can be retrieved with sd_evt_get();
yihui 1:a607cd9655d7 548 *
yihui 1:a607cd9655d7 549 * @param[in] pof_enable True if the power-fail comparator should be enabled, false if it should be disabled.
yihui 1:a607cd9655d7 550 *
yihui 1:a607cd9655d7 551 * @retval ::NRF_SUCCESS
yihui 1:a607cd9655d7 552 */
yihui 1:a607cd9655d7 553 SVCALL(SD_POWER_POF_ENABLE, uint32_t, sd_power_pof_enable(uint8_t pof_enable));
yihui 1:a607cd9655d7 554
yihui 1:a607cd9655d7 555 /**@brief Sets the power-fail threshold value.
yihui 1:a607cd9655d7 556 *
yihui 1:a607cd9655d7 557 * @param[in] threshold The power-fail threshold value to use.
yihui 1:a607cd9655d7 558 *
yihui 1:a607cd9655d7 559 * @retval ::NRF_SUCCESS The power failure threshold was set.
yihui 1:a607cd9655d7 560 * @retval ::NRF_ERROR_SOC_POWER_POF_THRESHOLD_UNKNOWN The power failure threshold is unknown.
yihui 1:a607cd9655d7 561 */
yihui 1:a607cd9655d7 562 SVCALL(SD_POWER_POF_THRESHOLD_SET, uint32_t, sd_power_pof_threshold_set(nrf_power_failure_threshold_t threshold));
yihui 1:a607cd9655d7 563
yihui 1:a607cd9655d7 564 /**@brief Sets bits in the NRF_POWER->RAMON register.
yihui 1:a607cd9655d7 565 *
yihui 1:a607cd9655d7 566 * @param[in] ramon Contains the bits needed to be set in the NRF_POWER->RAMON register.
yihui 1:a607cd9655d7 567 *
yihui 1:a607cd9655d7 568 * @retval ::NRF_SUCCESS
yihui 1:a607cd9655d7 569 */
yihui 1:a607cd9655d7 570 SVCALL(SD_POWER_RAMON_SET, uint32_t, sd_power_ramon_set(uint32_t ramon));
yihui 1:a607cd9655d7 571
yihui 1:a607cd9655d7 572 /** @brief Clears bits in the NRF_POWER->RAMON register.
yihui 1:a607cd9655d7 573 *
yihui 1:a607cd9655d7 574 * @param ramon Contains the bits needed to be cleared in the NRF_POWER->RAMON register.
yihui 1:a607cd9655d7 575 *
yihui 1:a607cd9655d7 576 * @retval ::NRF_SUCCESS
yihui 1:a607cd9655d7 577 */
yihui 1:a607cd9655d7 578 SVCALL(SD_POWER_RAMON_CLR, uint32_t, sd_power_ramon_clr(uint32_t ramon));
yihui 1:a607cd9655d7 579
yihui 1:a607cd9655d7 580 /**@brief Get contents of NRF_POWER->RAMON register, indicates power status of ram blocks.
yihui 1:a607cd9655d7 581 *
yihui 1:a607cd9655d7 582 * @param[out] p_ramon Content of NRF_POWER->RAMON register.
yihui 1:a607cd9655d7 583 *
yihui 1:a607cd9655d7 584 * @retval ::NRF_SUCCESS
yihui 1:a607cd9655d7 585 */
yihui 1:a607cd9655d7 586 SVCALL(SD_POWER_RAMON_GET, uint32_t, sd_power_ramon_get(uint32_t * p_ramon));
yihui 1:a607cd9655d7 587
yihui 1:a607cd9655d7 588 /**@brief Set bits in the NRF_POWER->GPREGRET register.
yihui 1:a607cd9655d7 589 *
yihui 1:a607cd9655d7 590 * @param[in] gpregret_msk Bits to be set in the GPREGRET register.
yihui 1:a607cd9655d7 591 *
yihui 1:a607cd9655d7 592 * @retval ::NRF_SUCCESS
yihui 1:a607cd9655d7 593 */
yihui 1:a607cd9655d7 594 SVCALL(SD_POWER_GPREGRET_SET, uint32_t, sd_power_gpregret_set(uint32_t gpregret_msk));
yihui 1:a607cd9655d7 595
yihui 1:a607cd9655d7 596 /**@brief Clear bits in the NRF_POWER->GPREGRET register.
yihui 1:a607cd9655d7 597 *
yihui 1:a607cd9655d7 598 * @param[in] gpregret_msk Bits to be clear in the GPREGRET register.
yihui 1:a607cd9655d7 599 *
yihui 1:a607cd9655d7 600 * @retval ::NRF_SUCCESS
yihui 1:a607cd9655d7 601 */
yihui 1:a607cd9655d7 602 SVCALL(SD_POWER_GPREGRET_CLR, uint32_t, sd_power_gpregret_clr(uint32_t gpregret_msk));
yihui 1:a607cd9655d7 603
yihui 1:a607cd9655d7 604 /**@brief Get contents of the NRF_POWER->GPREGRET register.
yihui 1:a607cd9655d7 605 *
yihui 1:a607cd9655d7 606 * @param[out] p_gpregret Contents of the GPREGRET register.
yihui 1:a607cd9655d7 607 *
yihui 1:a607cd9655d7 608 * @retval ::NRF_SUCCESS
yihui 1:a607cd9655d7 609 */
yihui 1:a607cd9655d7 610 SVCALL(SD_POWER_GPREGRET_GET, uint32_t, sd_power_gpregret_get(uint32_t *p_gpregret));
yihui 1:a607cd9655d7 611
yihui 1:a607cd9655d7 612 /**@brief Sets the DCDC mode.
yihui 1:a607cd9655d7 613 *
yihui 1:a607cd9655d7 614 * Depending on the internal state of the SoftDevice, the mode change may not happen immediately.
yihui 1:a607cd9655d7 615 * The DCDC mode switch will be blocked when occurring in close proximity to radio transmissions. When
yihui 1:a607cd9655d7 616 * the radio transmission is done, the last mode will be used.
yihui 1:a607cd9655d7 617 *
yihui 1:a607cd9655d7 618 * @param[in] dcdc_mode The mode of the DCDC.
yihui 1:a607cd9655d7 619 *
yihui 1:a607cd9655d7 620 * @retval ::NRF_SUCCESS
yihui 1:a607cd9655d7 621 * @retval ::NRF_ERROR_INVALID_PARAM The DCDC mode is invalid.
yihui 1:a607cd9655d7 622 */
yihui 1:a607cd9655d7 623 SVCALL(SD_POWER_DCDC_MODE_SET, uint32_t, sd_power_dcdc_mode_set(nrf_power_dcdc_mode_t dcdc_mode));
yihui 1:a607cd9655d7 624
yihui 1:a607cd9655d7 625 /**@brief Request the high frequency crystal oscillator.
yihui 1:a607cd9655d7 626 *
yihui 1:a607cd9655d7 627 * Will start the high frequency crystal oscillator, the startup time of the crystal varies
yihui 1:a607cd9655d7 628 * and the ::sd_clock_hfclk_is_running function can be polled to check if it has started.
yihui 1:a607cd9655d7 629 *
yihui 1:a607cd9655d7 630 * @see sd_clock_hfclk_is_running
yihui 1:a607cd9655d7 631 * @see sd_clock_hfclk_release
yihui 1:a607cd9655d7 632 *
yihui 1:a607cd9655d7 633 * @retval ::NRF_SUCCESS
yihui 1:a607cd9655d7 634 */
yihui 1:a607cd9655d7 635 SVCALL(SD_CLOCK_HFCLK_REQUEST, uint32_t, sd_clock_hfclk_request(void));
yihui 1:a607cd9655d7 636
yihui 1:a607cd9655d7 637 /**@brief Releases the high frequency crystal oscillator.
yihui 1:a607cd9655d7 638 *
yihui 1:a607cd9655d7 639 * Will stop the high frequency crystal oscillator, this happens immediately.
yihui 1:a607cd9655d7 640 *
yihui 1:a607cd9655d7 641 * @see sd_clock_hfclk_is_running
yihui 1:a607cd9655d7 642 * @see sd_clock_hfclk_request
yihui 1:a607cd9655d7 643 *
yihui 1:a607cd9655d7 644 * @retval ::NRF_SUCCESS
yihui 1:a607cd9655d7 645 */
yihui 1:a607cd9655d7 646 SVCALL(SD_CLOCK_HFCLK_RELEASE, uint32_t, sd_clock_hfclk_release(void));
yihui 1:a607cd9655d7 647
yihui 1:a607cd9655d7 648 /**@brief Checks if the high frequency crystal oscillator is running.
yihui 1:a607cd9655d7 649 *
yihui 1:a607cd9655d7 650 * @see sd_clock_hfclk_request
yihui 1:a607cd9655d7 651 * @see sd_clock_hfclk_release
yihui 1:a607cd9655d7 652 *
yihui 1:a607cd9655d7 653 * @param[out] p_is_running 1 if the external crystal oscillator is running, 0 if not.
yihui 1:a607cd9655d7 654 *
yihui 1:a607cd9655d7 655 * @retval ::NRF_SUCCESS
yihui 1:a607cd9655d7 656 */
yihui 1:a607cd9655d7 657 SVCALL(SD_CLOCK_HFCLK_IS_RUNNING, uint32_t, sd_clock_hfclk_is_running(uint32_t * p_is_running));
yihui 1:a607cd9655d7 658
yihui 1:a607cd9655d7 659 /**@brief Waits for an application event.
yihui 1:a607cd9655d7 660 *
yihui 1:a607cd9655d7 661 * An application event is either an application interrupt or a pended interrupt when the
yihui 1:a607cd9655d7 662 * interrupt is disabled. When the interrupt is enabled it will be taken immediately since
yihui 1:a607cd9655d7 663 * this function will wait in thread mode, then the execution will return in the application's
yihui 1:a607cd9655d7 664 * main thread. When an interrupt is disabled and gets pended it will return to the application's
yihui 1:a607cd9655d7 665 * thread main. The application must ensure that the pended flag is cleared using
yihui 1:a607cd9655d7 666 * ::sd_nvic_ClearPendingIRQ in order to sleep using this function. This is only necessary for
yihui 1:a607cd9655d7 667 * disabled interrupts, as the interrupt handler will clear the pending flag automatically for
yihui 1:a607cd9655d7 668 * enabled interrupts.
yihui 1:a607cd9655d7 669 *
yihui 1:a607cd9655d7 670 * In order to wake up from disabled interrupts, the SEVONPEND flag has to be set in the Cortex-M0
yihui 1:a607cd9655d7 671 * System Control Register (SCR). @sa CMSIS_SCB
yihui 1:a607cd9655d7 672 *
yihui 1:a607cd9655d7 673 * @note If an application interrupt has happened since the last time sd_app_evt_wait was
yihui 1:a607cd9655d7 674 * called this function will return immediately and not go to sleep. This is to avoid race
yihui 1:a607cd9655d7 675 * conditions that can occur when a flag is updated in the interrupt handler and processed
yihui 1:a607cd9655d7 676 * in the main loop.
yihui 1:a607cd9655d7 677 *
yihui 1:a607cd9655d7 678 * @post An application interrupt has happened or a interrupt pending flag is set.
yihui 1:a607cd9655d7 679 *
yihui 1:a607cd9655d7 680 * @retval ::NRF_SUCCESS
yihui 1:a607cd9655d7 681 */
yihui 1:a607cd9655d7 682 SVCALL(SD_APP_EVT_WAIT, uint32_t, sd_app_evt_wait(void));
yihui 1:a607cd9655d7 683
yihui 1:a607cd9655d7 684 /**@brief Get PPI channel enable register contents.
yihui 1:a607cd9655d7 685 *
yihui 1:a607cd9655d7 686 * @param[out] p_channel_enable The contents of the PPI CHEN register.
yihui 1:a607cd9655d7 687 *
yihui 1:a607cd9655d7 688 * @retval ::NRF_SUCCESS
yihui 1:a607cd9655d7 689 */
yihui 1:a607cd9655d7 690 SVCALL(SD_PPI_CHANNEL_ENABLE_GET, uint32_t, sd_ppi_channel_enable_get(uint32_t * p_channel_enable));
yihui 1:a607cd9655d7 691
yihui 1:a607cd9655d7 692 /**@brief Set PPI channel enable register.
yihui 1:a607cd9655d7 693 *
yihui 1:a607cd9655d7 694 * @param[in] channel_enable_set_msk Mask containing the bits to set in the PPI CHEN register.
yihui 1:a607cd9655d7 695 *
yihui 1:a607cd9655d7 696 * @retval ::NRF_SUCCESS
yihui 1:a607cd9655d7 697 */
yihui 1:a607cd9655d7 698 SVCALL(SD_PPI_CHANNEL_ENABLE_SET, uint32_t, sd_ppi_channel_enable_set(uint32_t channel_enable_set_msk));
yihui 1:a607cd9655d7 699
yihui 1:a607cd9655d7 700 /**@brief Clear PPI channel enable register.
yihui 1:a607cd9655d7 701 *
yihui 1:a607cd9655d7 702 * @param[in] channel_enable_clr_msk Mask containing the bits to clear in the PPI CHEN register.
yihui 1:a607cd9655d7 703 *
yihui 1:a607cd9655d7 704 * @retval ::NRF_SUCCESS
yihui 1:a607cd9655d7 705 */
yihui 1:a607cd9655d7 706 SVCALL(SD_PPI_CHANNEL_ENABLE_CLR, uint32_t, sd_ppi_channel_enable_clr(uint32_t channel_enable_clr_msk));
yihui 1:a607cd9655d7 707
yihui 1:a607cd9655d7 708 /**@brief Assign endpoints to a PPI channel.
yihui 1:a607cd9655d7 709 *
yihui 1:a607cd9655d7 710 * @param[in] channel_num Number of the PPI channel to assign.
yihui 1:a607cd9655d7 711 * @param[in] evt_endpoint Event endpoint of the PPI channel.
yihui 1:a607cd9655d7 712 * @param[in] task_endpoint Task endpoint of the PPI channel.
yihui 1:a607cd9655d7 713 *
yihui 1:a607cd9655d7 714 * @retval ::NRF_ERROR_SOC_PPI_INVALID_CHANNEL The channel number is invalid.
yihui 1:a607cd9655d7 715 * @retval ::NRF_SUCCESS
yihui 1:a607cd9655d7 716 */
yihui 1:a607cd9655d7 717 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));
yihui 1:a607cd9655d7 718
yihui 1:a607cd9655d7 719 /**@brief Task to enable a channel group.
yihui 1:a607cd9655d7 720 *
yihui 1:a607cd9655d7 721 * @param[in] group_num Number of the channel group.
yihui 1:a607cd9655d7 722 *
yihui 1:a607cd9655d7 723 * @retval ::NRF_ERROR_SOC_PPI_INVALID_GROUP The group number is invalid
yihui 1:a607cd9655d7 724 * @retval ::NRF_SUCCESS
yihui 1:a607cd9655d7 725 */
yihui 1:a607cd9655d7 726 SVCALL(SD_PPI_GROUP_TASK_ENABLE, uint32_t, sd_ppi_group_task_enable(uint8_t group_num));
yihui 1:a607cd9655d7 727
yihui 1:a607cd9655d7 728 /**@brief Task to disable a channel group.
yihui 1:a607cd9655d7 729 *
yihui 1:a607cd9655d7 730 * @param[in] group_num Number of the PPI group.
yihui 1:a607cd9655d7 731 *
yihui 1:a607cd9655d7 732 * @retval ::NRF_ERROR_SOC_PPI_INVALID_GROUP The group number is invalid.
yihui 1:a607cd9655d7 733 * @retval ::NRF_SUCCESS
yihui 1:a607cd9655d7 734 */
yihui 1:a607cd9655d7 735 SVCALL(SD_PPI_GROUP_TASK_DISABLE, uint32_t, sd_ppi_group_task_disable(uint8_t group_num));
yihui 1:a607cd9655d7 736
yihui 1:a607cd9655d7 737 /**@brief Assign PPI channels to a channel group.
yihui 1:a607cd9655d7 738 *
yihui 1:a607cd9655d7 739 * @param[in] group_num Number of the channel group.
yihui 1:a607cd9655d7 740 * @param[in] channel_msk Mask of the channels to assign to the group.
yihui 1:a607cd9655d7 741 *
yihui 1:a607cd9655d7 742 * @retval ::NRF_ERROR_SOC_PPI_INVALID_GROUP The group number is invalid.
yihui 1:a607cd9655d7 743 * @retval ::NRF_SUCCESS
yihui 1:a607cd9655d7 744 */
yihui 1:a607cd9655d7 745 SVCALL(SD_PPI_GROUP_ASSIGN, uint32_t, sd_ppi_group_assign(uint8_t group_num, uint32_t channel_msk));
yihui 1:a607cd9655d7 746
yihui 1:a607cd9655d7 747 /**@brief Gets the PPI channels of a channel group.
yihui 1:a607cd9655d7 748 *
yihui 1:a607cd9655d7 749 * @param[in] group_num Number of the channel group.
yihui 1:a607cd9655d7 750 * @param[out] p_channel_msk Mask of the channels assigned to the group.
yihui 1:a607cd9655d7 751 *
yihui 1:a607cd9655d7 752 * @retval ::NRF_ERROR_SOC_PPI_INVALID_GROUP The group number is invalid.
yihui 1:a607cd9655d7 753 * @retval ::NRF_SUCCESS
yihui 1:a607cd9655d7 754 */
yihui 1:a607cd9655d7 755 SVCALL(SD_PPI_GROUP_GET, uint32_t, sd_ppi_group_get(uint8_t group_num, uint32_t * p_channel_msk));
yihui 1:a607cd9655d7 756
yihui 1:a607cd9655d7 757 /**@brief Configures the Radio Notification signal.
yihui 1:a607cd9655d7 758 *
yihui 1:a607cd9655d7 759 * @note
yihui 1:a607cd9655d7 760 * - The notification signal latency depends on the interrupt priority settings of SWI used
yihui 1:a607cd9655d7 761 * for notification signal.
yihui 1:a607cd9655d7 762 * - In the period between the ACTIVE signal and the start of the Radio Event, the SoftDevice
yihui 1:a607cd9655d7 763 * will interrupt the application to do Radio Event preparation.
yihui 1:a607cd9655d7 764 * - Using the Radio Notification feature may limit the bandwidth, as the SoftDevice may have
yihui 1:a607cd9655d7 765 * to shorten the connection events to have time for the Radio Notification signals.
yihui 1:a607cd9655d7 766 *
yihui 1:a607cd9655d7 767 * @param[in] type Type of notification signal.
yihui 1:a607cd9655d7 768 * @ref NRF_RADIO_NOTIFICATION_TYPE_NONE shall be used to turn off radio
yihui 1:a607cd9655d7 769 * notification. Using @ref NRF_RADIO_NOTIFICATION_DISTANCE_NONE is
yihui 1:a607cd9655d7 770 * recommended (but not required) to be used with
yihui 1:a607cd9655d7 771 * @ref NRF_RADIO_NOTIFICATION_TYPE_NONE.
yihui 1:a607cd9655d7 772 *
yihui 1:a607cd9655d7 773 * @param[in] distance Distance between the notification signal and start of radio activity.
yihui 1:a607cd9655d7 774 * This parameter is ignored when @ref NRF_RADIO_NOTIFICATION_TYPE_NONE or
yihui 1:a607cd9655d7 775 * @ref NRF_RADIO_NOTIFICATION_TYPE_INT_ON_INACTIVE is used.
yihui 1:a607cd9655d7 776 *
yihui 1:a607cd9655d7 777 * @retval ::NRF_ERROR_INVALID_PARAM The group number is invalid.
yihui 1:a607cd9655d7 778 * @retval ::NRF_SUCCESS
yihui 1:a607cd9655d7 779 */
yihui 1:a607cd9655d7 780 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));
yihui 1:a607cd9655d7 781
yihui 1:a607cd9655d7 782 /**@brief Encrypts a block according to the specified parameters.
yihui 1:a607cd9655d7 783 *
yihui 1:a607cd9655d7 784 * 128-bit AES encryption.
yihui 1:a607cd9655d7 785 *
yihui 1:a607cd9655d7 786 * @param[in, out] p_ecb_data Pointer to the ECB parameters' struct (two input
yihui 1:a607cd9655d7 787 * parameters and one output parameter).
yihui 1:a607cd9655d7 788 *
yihui 1:a607cd9655d7 789 * @retval ::NRF_SUCCESS
yihui 1:a607cd9655d7 790 */
yihui 1:a607cd9655d7 791 SVCALL(SD_ECB_BLOCK_ENCRYPT, uint32_t, sd_ecb_block_encrypt(nrf_ecb_hal_data_t * p_ecb_data));
yihui 1:a607cd9655d7 792
yihui 1:a607cd9655d7 793 /**@brief Gets any pending events generated by the SoC API.
yihui 1:a607cd9655d7 794 *
yihui 1:a607cd9655d7 795 * The application should keep calling this function to get events, until ::NRF_ERROR_NOT_FOUND is returned.
yihui 1:a607cd9655d7 796 *
yihui 1:a607cd9655d7 797 * @param[out] p_evt_id Set to one of the values in @ref NRF_SOC_EVTS, if any events are pending.
yihui 1:a607cd9655d7 798 *
yihui 1:a607cd9655d7 799 * @retval ::NRF_SUCCESS An event was pending. The event id is written in the p_evt_id parameter.
yihui 1:a607cd9655d7 800 * @retval ::NRF_ERROR_NOT_FOUND No pending events.
yihui 1:a607cd9655d7 801 */
yihui 1:a607cd9655d7 802 SVCALL(SD_EVT_GET, uint32_t, sd_evt_get(uint32_t * p_evt_id));
yihui 1:a607cd9655d7 803
yihui 1:a607cd9655d7 804 /**@brief Get the temperature measured on the chip
yihui 1:a607cd9655d7 805 *
yihui 1:a607cd9655d7 806 * This function will block until the temperature measurement is done.
yihui 1:a607cd9655d7 807 * It takes around 50us from call to return.
yihui 1:a607cd9655d7 808 *
yihui 1:a607cd9655d7 809 * @note Pan #28 in PAN-028 v 1.6 "Negative measured values are not represented correctly" is corrected by this function.
yihui 1:a607cd9655d7 810 *
yihui 1:a607cd9655d7 811 * @param[out] p_temp Result of temperature measurement. Die temperature in 0.25 degrees celsius.
yihui 1:a607cd9655d7 812 *
yihui 1:a607cd9655d7 813 * @retval ::NRF_SUCCESS A temperature measurement was done, and the temperature was written to temp
yihui 1:a607cd9655d7 814 */
yihui 1:a607cd9655d7 815 SVCALL(SD_TEMP_GET, uint32_t, sd_temp_get(int32_t * p_temp));
yihui 1:a607cd9655d7 816
yihui 1:a607cd9655d7 817 /**@brief Flash Write
yihui 1:a607cd9655d7 818 *
yihui 1:a607cd9655d7 819 * Commands to write a buffer to flash
yihui 1:a607cd9655d7 820 *
yihui 1:a607cd9655d7 821 * This call initiates the flash access command, and its completion will be communicated to the
yihui 1:a607cd9655d7 822 * application with exactly one of the following events:
yihui 1:a607cd9655d7 823 * - NRF_EVT_FLASH_OPERATION_SUCCESS - The command was successfully completed.
yihui 1:a607cd9655d7 824 * - NRF_EVT_FLASH_OPERATION_ERROR - The command could not be started.
yihui 1:a607cd9655d7 825 *
yihui 1:a607cd9655d7 826 * @note
yihui 1:a607cd9655d7 827 * - This call takes control over the radio and the CPU during flash erase and write to make sure that
yihui 1:a607cd9655d7 828 * they will not interfere with the flash access. This means that all interrupts will be blocked
yihui 1:a607cd9655d7 829 * for a predictable time (depending on the NVMC specification in nRF51 Series Reference Manual
yihui 1:a607cd9655d7 830 * and the command parameters).
yihui 1:a607cd9655d7 831 *
yihui 1:a607cd9655d7 832 *
yihui 1:a607cd9655d7 833 * @param[in] p_dst Pointer to start of flash location to be written.
yihui 1:a607cd9655d7 834 * @param[in] p_src Pointer to buffer with data to be written
yihui 1:a607cd9655d7 835 * @param[in] size Number of 32-bit words to write. Maximum size is 256 32bit words.
yihui 1:a607cd9655d7 836 *
yihui 1:a607cd9655d7 837 * @retval ::NRF_ERROR_INVALID_ADDR Tried to write to a non existing flash address, or p_dst or p_src was unaligned.
yihui 1:a607cd9655d7 838 * @retval ::NRF_ERROR_BUSY The previous command has not yet completed.
yihui 1:a607cd9655d7 839 * @retval ::NRF_ERROR_INVALID_LENGTH Size was 0, or more than 256 words.
yihui 1:a607cd9655d7 840 * @retval ::NRF_ERROR_FORBIDDEN Tried to write to or read from protected location.
yihui 1:a607cd9655d7 841 * @retval ::NRF_SUCCESS The command was accepted.
yihui 1:a607cd9655d7 842 */
yihui 1:a607cd9655d7 843 SVCALL(SD_FLASH_WRITE, uint32_t, sd_flash_write(uint32_t * const p_dst, uint32_t const * const p_src, uint32_t size));
yihui 1:a607cd9655d7 844
yihui 1:a607cd9655d7 845
yihui 1:a607cd9655d7 846 /**@brief Flash Erase page
yihui 1:a607cd9655d7 847 *
yihui 1:a607cd9655d7 848 * Commands to erase a flash page
yihui 1:a607cd9655d7 849 *
yihui 1:a607cd9655d7 850 * This call initiates the flash access command, and its completion will be communicated to the
yihui 1:a607cd9655d7 851 * application with exactly one of the following events:
yihui 1:a607cd9655d7 852 * - NRF_EVT_FLASH_OPERATION_SUCCESS - The command was successfully completed.
yihui 1:a607cd9655d7 853 * - NRF_EVT_FLASH_OPERATION_ERROR - The command could not be started.
yihui 1:a607cd9655d7 854 *
yihui 1:a607cd9655d7 855 * @note
yihui 1:a607cd9655d7 856 * - This call takes control over the radio and the CPU during flash erase and write to make sure that
yihui 1:a607cd9655d7 857 * they will not interfere with the flash access. This means that all interrupts will be blocked
yihui 1:a607cd9655d7 858 * for a predictable time (depending on the NVMC specification in nRF51 Series Reference Manual
yihui 1:a607cd9655d7 859 * and the command parameters).
yihui 1:a607cd9655d7 860 *
yihui 1:a607cd9655d7 861 *
yihui 1:a607cd9655d7 862 * @param[in] page_number Pagenumber of the page to erase
yihui 1:a607cd9655d7 863 * @retval ::NRF_ERROR_INTERNAL If a new session could not be opened due to an internal error.
yihui 1:a607cd9655d7 864 * @retval ::NRF_ERROR_INVALID_ADDR Tried to erase to a non existing flash page.
yihui 1:a607cd9655d7 865 * @retval ::NRF_ERROR_BUSY The previous command has not yet completed.
yihui 1:a607cd9655d7 866 * @retval ::NRF_ERROR_FORBIDDEN Tried to erase a protected page.
yihui 1:a607cd9655d7 867 * @retval ::NRF_SUCCESS The command was accepted.
yihui 1:a607cd9655d7 868 */
yihui 1:a607cd9655d7 869 SVCALL(SD_FLASH_PAGE_ERASE, uint32_t, sd_flash_page_erase(uint32_t page_number));
yihui 1:a607cd9655d7 870
yihui 1:a607cd9655d7 871
yihui 1:a607cd9655d7 872 /**@brief Flash Protection set
yihui 1:a607cd9655d7 873 *
yihui 1:a607cd9655d7 874 * Commands to set the flash protection registers PROTENSETx
yihui 1:a607cd9655d7 875 *
yihui 1:a607cd9655d7 876 * @note To read the values in PROTENSETx you can read them directly. They are only write-protected.
yihui 1:a607cd9655d7 877 *
yihui 1:a607cd9655d7 878 * @param[in] protenset0 Value to be written to PROTENSET0
yihui 1:a607cd9655d7 879 * @param[in] protenset1 Value to be written to PROTENSET1
yihui 1:a607cd9655d7 880 *
yihui 1:a607cd9655d7 881 * @retval ::NRF_ERROR_FORBIDDEN Tried to protect the SoftDevice
yihui 1:a607cd9655d7 882 * @retval ::NRF_SUCCESS Values successfully written to PROTENSETx
yihui 1:a607cd9655d7 883 */
yihui 1:a607cd9655d7 884 SVCALL(SD_FLASH_PROTECT, uint32_t, sd_flash_protect(uint32_t protenset0, uint32_t protenset1));
yihui 1:a607cd9655d7 885
yihui 1:a607cd9655d7 886 /**@brief Opens a session for radio requests.
yihui 1:a607cd9655d7 887 *
yihui 1:a607cd9655d7 888 * @note Only one session can be open at a time.
yihui 1:a607cd9655d7 889 * @note p_radio_signal_callback(NRF_RADIO_CALLBACK_SIGNAL_TYPE_START) will be called when the radio timeslot
yihui 1:a607cd9655d7 890 * starts. From this point the NRF_RADIO and NRF_TIMER0 peripherals can be freely accessed
yihui 1:a607cd9655d7 891 * by the application.
yihui 1:a607cd9655d7 892 * @note p_radio_signal_callback(NRF_RADIO_CALLBACK_SIGNAL_TYPE_TIMER0) is called whenever the NRF_TIMER0
yihui 1:a607cd9655d7 893 * interrupt occurs.
yihui 1:a607cd9655d7 894 * @note p_radio_signal_callback(NRF_RADIO_CALLBACK_SIGNAL_TYPE_RADIO) is called whenever the NRF_RADIO
yihui 1:a607cd9655d7 895 * interrupt occurs.
yihui 1:a607cd9655d7 896 * @note p_radio_signal_callback() will be called at ARM interrupt priority level 0. This
yihui 1:a607cd9655d7 897 * implies that none of the sd_* API calls can be used from p_radio_signal_callback().
yihui 1:a607cd9655d7 898 *
yihui 1:a607cd9655d7 899 * @param[in] p_radio_signal_callback The signal callback.
yihui 1:a607cd9655d7 900 *
yihui 1:a607cd9655d7 901 * @retval ::NRF_ERROR_INVALID_ADDR p_radio_signal_callback is an invalid function pointer.
yihui 1:a607cd9655d7 902 * @retval ::NRF_ERROR_BUSY If session cannot be opened.
yihui 1:a607cd9655d7 903 * @retval ::NRF_ERROR_INTERNAL If a new session could not be opened due to an internal error.
yihui 1:a607cd9655d7 904 * @retval ::NRF_SUCCESS Otherwise.
yihui 1:a607cd9655d7 905 */
yihui 1:a607cd9655d7 906 SVCALL(SD_RADIO_SESSION_OPEN, uint32_t, sd_radio_session_open(nrf_radio_signal_callback_t p_radio_signal_callback));
yihui 1:a607cd9655d7 907
yihui 1:a607cd9655d7 908 /**@brief Closes a session for radio requests.
yihui 1:a607cd9655d7 909 *
yihui 1:a607cd9655d7 910 * @note Any current radio timeslot will be finished before the session is closed.
yihui 1:a607cd9655d7 911 * @note If a radio timeslot is scheduled when the session is closed, it will be canceled.
yihui 1:a607cd9655d7 912 * @note The application cannot consider the session closed until the NRF_EVT_RADIO_SESSION_CLOSED
yihui 1:a607cd9655d7 913 * event is received.
yihui 1:a607cd9655d7 914 *
yihui 1:a607cd9655d7 915 * @retval ::NRF_ERROR_FORBIDDEN If session not opened.
yihui 1:a607cd9655d7 916 * @retval ::NRF_ERROR_BUSY If session is currently being closed.
yihui 1:a607cd9655d7 917 * @retval ::NRF_SUCCESS Otherwise.
yihui 1:a607cd9655d7 918 */
yihui 1:a607cd9655d7 919 SVCALL(SD_RADIO_SESSION_CLOSE, uint32_t, sd_radio_session_close(void));
yihui 1:a607cd9655d7 920
yihui 1:a607cd9655d7 921 /**@brief Requests a radio timeslot.
yihui 1:a607cd9655d7 922 *
yihui 1:a607cd9655d7 923 * @note The timing of the radio timeslot is specified by p_request->distance_us. For the first
yihui 1:a607cd9655d7 924 * request in a session, p_request->distance_us is required to be 0 by convention, and
yihui 1:a607cd9655d7 925 * the timeslot is scheduled at the first possible opportunity. All following radio timeslots are
yihui 1:a607cd9655d7 926 * requested with a distance of p_request->distance_us measured from the start of the
yihui 1:a607cd9655d7 927 * previous radio timeslot.
yihui 1:a607cd9655d7 928 * @note A too small p_request->distance_us will lead to a NRF_EVT_RADIO_BLOCKED event.
yihui 1:a607cd9655d7 929 * @note Timeslots scheduled too close will lead to a NRF_EVT_RADIO_BLOCKED event.
yihui 1:a607cd9655d7 930 * @note See the SoftDevice Specification for more on radio timeslot scheduling, distances and lengths.
yihui 1:a607cd9655d7 931 * @note If an opportunity for the first radio timeslot is not found before 100ms after the call to this
yihui 1:a607cd9655d7 932 * function, it is not scheduled, and instead a NRF_EVT_RADIO_BLOCKED event is sent.
yihui 1:a607cd9655d7 933 * The application may then try to schedule the first radio timeslot again.
yihui 1:a607cd9655d7 934 * @note Successful requests will result in nrf_radio_signal_callback_t(NRF_RADIO_CALLBACK_SIGNAL_TYPE_START).
yihui 1:a607cd9655d7 935 * Unsuccessful requests will result in a NRF_EVT_RADIO_BLOCKED event, see @ref NRF_SOC_EVTS.
yihui 1:a607cd9655d7 936 * @note The jitter in the start time of the radio timeslots is +/- NRF_RADIO_START_JITTER_US us.
yihui 1:a607cd9655d7 937 * @note The nrf_radio_signal_callback_t(NRF_RADIO_CALLBACK_SIGNAL_TYPE_START) call has a latency relative to the
yihui 1:a607cd9655d7 938 * specified radio timeslot start, but this does not affect the actual start time of the timeslot.
yihui 1:a607cd9655d7 939 * @note NRF_TIMER0 is reset at the start of the radio timeslot, and is clocked at 1MHz from the high frequency
yihui 1:a607cd9655d7 940 * (16 MHz) clock source. If p_request->hfclk_force_xtal is true, the high frequency clock is
yihui 1:a607cd9655d7 941 * guaranteed to be clocked from the external crystal.
yihui 1:a607cd9655d7 942 * @note The SoftDevice will neither access the NRF_RADIO peripheral nor the NRF_TIMER0 peripheral
yihui 1:a607cd9655d7 943 * during the radio timeslot.
yihui 1:a607cd9655d7 944 *
yihui 1:a607cd9655d7 945 * @param[in] p_request Pointer to the request parameters.
yihui 1:a607cd9655d7 946 *
yihui 1:a607cd9655d7 947 * @retval ::NRF_ERROR_FORBIDDEN If session not opened or the session is not IDLE.
yihui 1:a607cd9655d7 948 * @retval ::NRF_ERROR_INVALID_ADDR If the p_request pointer is invalid.
yihui 1:a607cd9655d7 949 * @retval ::NRF_ERROR_INVALID_PARAM If the parameters of p_request are not valid.
yihui 1:a607cd9655d7 950 * @retval ::NRF_SUCCESS Otherwise.
yihui 1:a607cd9655d7 951 */
yihui 1:a607cd9655d7 952 SVCALL(SD_RADIO_REQUEST, uint32_t, sd_radio_request(nrf_radio_request_t * p_request ));
yihui 1:a607cd9655d7 953
yihui 1:a607cd9655d7 954 /** @} */
yihui 1:a607cd9655d7 955
yihui 1:a607cd9655d7 956 #endif // NRF_SOC_H__
yihui 1:a607cd9655d7 957
yihui 1:a607cd9655d7 958 /**@} */