テスト用です。

Dependencies:   mbed

Committer:
jksoft
Date:
Tue Oct 11 11:09:42 2016 +0000
Revision:
0:8468a4403fea
SB??ver;

Who changed what in which revision?

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