To get started with Seeed Tiny BLE, include detecting motion, button and battery level.

Dependencies:   BLE_API eMPL_MPU6050 mbed nRF51822

Committer:
yihui
Date:
Wed Apr 22 07:47:17 2015 +0000
Revision:
1:fc2f9d636751
update libraries; ; delete nRF51822/nordic-sdk/components/gpiote/app_gpiote.c to solve GPIOTE_IRQHandler multiply defined issue. temperarily change nRF51822 library to folder

Who changed what in which revision?

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