iOSのBLEコントローラアプリ「RCBController」と接続し、コントローラの操作を取得するサンプルプログラムです。 mbed HRM1017で動作を確認しています。 2014.08.20時点でのBLEライブラリに対応しました。

Dependencies:   BLE_API mbed

Fork of BLE_RCBController by Junichi Katsu

Committer:
jksoft
Date:
Wed Aug 20 13:41:01 2014 +0000
Revision:
4:ebda47d22091
Parent:
nRF51822/nordic/nrf-sdk/s110/nrf_soc.h@1:48f6e08a3ac2
?????????

Who changed what in which revision?

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