version_2.0

Dependents:   cc3000_ping_demo_try_2

Fork of mbed by mbed official

Committer:
bogdanm
Date:
Mon Apr 07 18:28:36 2014 +0100
Revision:
82:6473597d706e
Release 82 of the mbed library

Main changes:

- support for K64F
- Revisited Nordic code structure
- Test infrastructure improvements
- various bug fixes

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bogdanm 82:6473597d706e 1 /*
bogdanm 82:6473597d706e 2 * Copyright (c) 2011 Nordic Semiconductor. All Rights Reserved.
bogdanm 82:6473597d706e 3 *
bogdanm 82:6473597d706e 4 * The information contained herein is confidential property of Nordic Semiconductor. The use,
bogdanm 82:6473597d706e 5 * copying, transfer or disclosure of such information is prohibited except by express written
bogdanm 82:6473597d706e 6 * agreement with Nordic Semiconductor.
bogdanm 82:6473597d706e 7 *
bogdanm 82:6473597d706e 8 */
bogdanm 82:6473597d706e 9 /**
bogdanm 82:6473597d706e 10 @defgroup nrf_sdm_api SoftDevice Manager API
bogdanm 82:6473597d706e 11 @{
bogdanm 82:6473597d706e 12
bogdanm 82:6473597d706e 13 @brief APIs for SoftDevice management.
bogdanm 82:6473597d706e 14
bogdanm 82:6473597d706e 15 */
bogdanm 82:6473597d706e 16
bogdanm 82:6473597d706e 17 /* Header guard */
bogdanm 82:6473597d706e 18 #ifndef NRF_SDM_H__
bogdanm 82:6473597d706e 19 #define NRF_SDM_H__
bogdanm 82:6473597d706e 20
bogdanm 82:6473597d706e 21 #include "nrf_svc.h"
bogdanm 82:6473597d706e 22 #include "nrf51.h"
bogdanm 82:6473597d706e 23 #include "nrf_soc.h"
bogdanm 82:6473597d706e 24 #include "nrf_error_sdm.h"
bogdanm 82:6473597d706e 25
bogdanm 82:6473597d706e 26 /** @addtogroup NRF_SDM_DEFINES Defines
bogdanm 82:6473597d706e 27 * @{ */
bogdanm 82:6473597d706e 28
bogdanm 82:6473597d706e 29 /**@brief SoftDevice Manager SVC Base number. */
bogdanm 82:6473597d706e 30 #define SDM_SVC_BASE 0x10
bogdanm 82:6473597d706e 31
bogdanm 82:6473597d706e 32 /** @} */
bogdanm 82:6473597d706e 33
bogdanm 82:6473597d706e 34 /** @addtogroup NRF_SDM_ENUMS Enumerations
bogdanm 82:6473597d706e 35 * @{ */
bogdanm 82:6473597d706e 36
bogdanm 82:6473597d706e 37 /**@brief nRF SoftDevice Manager API SVC numbers. */
bogdanm 82:6473597d706e 38 enum NRF_SD_SVCS
bogdanm 82:6473597d706e 39 {
bogdanm 82:6473597d706e 40 SD_SOFTDEVICE_ENABLE = SDM_SVC_BASE, /**< ::sd_softdevice_enable */
bogdanm 82:6473597d706e 41 SD_SOFTDEVICE_DISABLE, /**< ::sd_softdevice_disable */
bogdanm 82:6473597d706e 42 SD_SOFTDEVICE_IS_ENABLED, /**< ::sd_softdevice_is_enabled */
bogdanm 82:6473597d706e 43 SD_SOFTDEVICE_FORWARD_TO_APPLICATION,/**< ::sd_softdevice_forward_to_application */
bogdanm 82:6473597d706e 44 SVC_SDM_LAST /**< Placeholder for last SDM SVC */
bogdanm 82:6473597d706e 45 };
bogdanm 82:6473597d706e 46
bogdanm 82:6473597d706e 47 /**@brief Possible lfclk oscillator sources. */
bogdanm 82:6473597d706e 48 enum NRF_CLOCK_LFCLKSRCS
bogdanm 82:6473597d706e 49 {
bogdanm 82:6473597d706e 50 NRF_CLOCK_LFCLKSRC_SYNTH_250_PPM, /**< LFCLK Synthesized from HFCLK. */
bogdanm 82:6473597d706e 51 NRF_CLOCK_LFCLKSRC_XTAL_500_PPM, /**< LFCLK crystal oscillator 500 PPM accuracy. */
bogdanm 82:6473597d706e 52 NRF_CLOCK_LFCLKSRC_XTAL_250_PPM, /**< LFCLK crystal oscillator 250 PPM accuracy. */
bogdanm 82:6473597d706e 53 NRF_CLOCK_LFCLKSRC_XTAL_150_PPM, /**< LFCLK crystal oscillator 150 PPM accuracy. */
bogdanm 82:6473597d706e 54 NRF_CLOCK_LFCLKSRC_XTAL_100_PPM, /**< LFCLK crystal oscillator 100 PPM accuracy. */
bogdanm 82:6473597d706e 55 NRF_CLOCK_LFCLKSRC_XTAL_75_PPM, /**< LFCLK crystal oscillator 75 PPM accuracy. */
bogdanm 82:6473597d706e 56 NRF_CLOCK_LFCLKSRC_XTAL_50_PPM, /**< LFCLK crystal oscillator 50 PPM accuracy. */
bogdanm 82:6473597d706e 57 NRF_CLOCK_LFCLKSRC_XTAL_30_PPM, /**< LFCLK crystal oscillator 30 PPM accuracy. */
bogdanm 82:6473597d706e 58 NRF_CLOCK_LFCLKSRC_XTAL_20_PPM, /**< LFCLK crystal oscillator 20 PPM accuracy. */
bogdanm 82:6473597d706e 59 NRF_CLOCK_LFCLKSRC_RC_250_PPM_250MS_CALIBRATION, /**< LFCLK RC oscillator, 250ms calibration interval.*/
bogdanm 82:6473597d706e 60 NRF_CLOCK_LFCLKSRC_RC_250_PPM_500MS_CALIBRATION, /**< LFCLK RC oscillator, 500ms calibration interval.*/
bogdanm 82:6473597d706e 61 NRF_CLOCK_LFCLKSRC_RC_250_PPM_1000MS_CALIBRATION, /**< LFCLK RC oscillator, 1000ms calibration interval.*/
bogdanm 82:6473597d706e 62 NRF_CLOCK_LFCLKSRC_RC_250_PPM_2000MS_CALIBRATION, /**< LFCLK RC oscillator, 2000ms calibration interval.*/
bogdanm 82:6473597d706e 63 NRF_CLOCK_LFCLKSRC_RC_250_PPM_4000MS_CALIBRATION, /**< LFCLK RC oscillator, 4000ms calibration interval.*/
bogdanm 82:6473597d706e 64 NRF_CLOCK_LFCLKSRC_RC_250_PPM_8000MS_CALIBRATION, /**< LFCLK RC oscillator, 8000ms calibration interval.*/
bogdanm 82:6473597d706e 65 };
bogdanm 82:6473597d706e 66
bogdanm 82:6473597d706e 67 /** @} */
bogdanm 82:6473597d706e 68
bogdanm 82:6473597d706e 69 /** @addtogroup NRF_SDM_TYPES Types
bogdanm 82:6473597d706e 70 * @{ */
bogdanm 82:6473597d706e 71
bogdanm 82:6473597d706e 72 /**@brief Type representing lfclk oscillator source. */
bogdanm 82:6473597d706e 73 typedef uint32_t nrf_clock_lfclksrc_t;
bogdanm 82:6473597d706e 74
bogdanm 82:6473597d706e 75
bogdanm 82:6473597d706e 76 /**@brief SoftDevice Assertion Handler type.
bogdanm 82:6473597d706e 77 *
bogdanm 82:6473597d706e 78 * When an unexpected error occurs within the SoftDevice it will call the SoftDevice assertion handler callback.
bogdanm 82:6473597d706e 79 * The protocol stack will be in an undefined state when this happens and the only way to recover will be to
bogdanm 82:6473597d706e 80 * perform a reset, using e.g. CMSIS NVIC_SystemReset().
bogdanm 82:6473597d706e 81 *
bogdanm 82:6473597d706e 82 * @note This callback is executed in HardFault context, thus SVC functions cannot be called from the SoftDevice assert callback.
bogdanm 82:6473597d706e 83 *
bogdanm 82:6473597d706e 84 * @param[in] pc The program counter of the failed assert.
bogdanm 82:6473597d706e 85 * @param[in] line_number Line number where the assert failed.
bogdanm 82:6473597d706e 86 * @param[in] file_name File name where the assert failed.
bogdanm 82:6473597d706e 87 */
bogdanm 82:6473597d706e 88 typedef void (*softdevice_assertion_handler_t)(uint32_t pc, uint16_t line_number, const uint8_t * p_file_name);
bogdanm 82:6473597d706e 89
bogdanm 82:6473597d706e 90 /** @} */
bogdanm 82:6473597d706e 91
bogdanm 82:6473597d706e 92 /** @addtogroup NRF_SDM_FUNCTIONS Functions
bogdanm 82:6473597d706e 93 * @{ */
bogdanm 82:6473597d706e 94
bogdanm 82:6473597d706e 95 /**@brief Enables the SoftDevice and by extension the protocol stack.
bogdanm 82:6473597d706e 96 *
bogdanm 82:6473597d706e 97 * Idempotent function to enable the SoftDevice.
bogdanm 82:6473597d706e 98 *
bogdanm 82:6473597d706e 99 * @note Some care must be taken if a low frequency clock source is already running when calling this function:
bogdanm 82:6473597d706e 100 * If the LF clock has a different source then the one currently running, it will be stopped. Then, the new
bogdanm 82:6473597d706e 101 * clock source will be started.
bogdanm 82:6473597d706e 102 *
bogdanm 82:6473597d706e 103 * @note This function has no effect when returning with an error.
bogdanm 82:6473597d706e 104 *
bogdanm 82:6473597d706e 105 * @post If return code is ::NRF_SUCCESS
bogdanm 82:6473597d706e 106 * - SoC library and protocol stack APIs are made available
bogdanm 82:6473597d706e 107 * - A portion of RAM will be unavailable (see relevant SDS documentation)
bogdanm 82:6473597d706e 108 * - Some peripherals will be unavailable or available only through the SoC API (see relevant SDS documentation)
bogdanm 82:6473597d706e 109 * - Interrupts will not arrive from protected peripherals or interrupts
bogdanm 82:6473597d706e 110 * - nrf_nvic_ functions must be used instead of CMSIS NVIC_ functions for reliable usage of the softdevice.
bogdanm 82:6473597d706e 111 * - Interrupt latency may be affected by the SoftDevice (see relevant SDS documentation)
bogdanm 82:6473597d706e 112 * - Chosen low frequency clock source will be running
bogdanm 82:6473597d706e 113 *
bogdanm 82:6473597d706e 114 * @param clock_source Low frequency clock source and accuracy. (Note: In the case of XTAL source, the PPM accuracy of the chosen clock source must be greater than or equal to the actual characteristics of your XTAL clock).
bogdanm 82:6473597d706e 115 * @param assertion_handler Callback for SoftDevice assertions.
bogdanm 82:6473597d706e 116 *
bogdanm 82:6473597d706e 117 * @retval ::NRF_SUCCESS
bogdanm 82:6473597d706e 118 * @retval ::NRF_ERROR_SDM_INCORRECT_INTERRUPT_CONFIGURATION SoftDeviceinterrupt is already enabled, or an enabled interrupt has an illegal priority level
bogdanm 82:6473597d706e 119 * @retval ::NRF_ERROR_SDM_LFCLK_SOURCE_UNKNOWN Unknown low frequency clock source selected
bogdanm 82:6473597d706e 120 */
bogdanm 82:6473597d706e 121 SVCALL(SD_SOFTDEVICE_ENABLE, uint32_t, sd_softdevice_enable(nrf_clock_lfclksrc_t clock_source, softdevice_assertion_handler_t assertion_handler));
bogdanm 82:6473597d706e 122
bogdanm 82:6473597d706e 123 /**@brief Disables the SoftDevice and by extension the protocol stack.
bogdanm 82:6473597d706e 124 *
bogdanm 82:6473597d706e 125 * Idempotent function to disable the SoftDevice.
bogdanm 82:6473597d706e 126 *
bogdanm 82:6473597d706e 127 * @post SoC library and protocol stack APIs are made unavailable.
bogdanm 82:6473597d706e 128 * @post All interrupts that was protected by the SoftDevice will be disabled and initialized to priority 0 (highest).
bogdanm 82:6473597d706e 129 * @post All peripherals used by the SoftDevice will be reset to default values.
bogdanm 82:6473597d706e 130 * @post All of RAM become available.
bogdanm 82:6473597d706e 131 * @post All interrupts are forwarded to the application.
bogdanm 82:6473597d706e 132 * @post LFCLK source chosen in ::sd_softdevice_enable will be left running.
bogdanm 82:6473597d706e 133 *
bogdanm 82:6473597d706e 134 * @retval ::NRF_SUCCESS
bogdanm 82:6473597d706e 135 */
bogdanm 82:6473597d706e 136 SVCALL(SD_SOFTDEVICE_DISABLE, uint32_t, sd_softdevice_disable(void));
bogdanm 82:6473597d706e 137
bogdanm 82:6473597d706e 138 /**@brief Check if the SoftDevice is enabled.
bogdanm 82:6473597d706e 139 *
bogdanm 82:6473597d706e 140 * @param[out] p_softdevice_enabled If the SoftDevice is enabled: 1 else 0.
bogdanm 82:6473597d706e 141 *
bogdanm 82:6473597d706e 142 * @retval ::NRF_SUCCESS
bogdanm 82:6473597d706e 143 */
bogdanm 82:6473597d706e 144 SVCALL(SD_SOFTDEVICE_IS_ENABLED, uint32_t, sd_softdevice_is_enabled(uint8_t * p_softdevice_enabled));
bogdanm 82:6473597d706e 145
bogdanm 82:6473597d706e 146 /**@brief Start forwarding interrupts to application.
bogdanm 82:6473597d706e 147 *
bogdanm 82:6473597d706e 148 * This function is only intended to be called when a bootloader is enabled is used.
bogdanm 82:6473597d706e 149 * The bootloader should call this right before it starts the application.
bogdanm 82:6473597d706e 150 * It is recommended that all interrupt sources are off when this is called,
bogdanm 82:6473597d706e 151 * or you could end up having interrupts in the application being executed before main() of the application.
bogdanm 82:6473597d706e 152 *
bogdanm 82:6473597d706e 153 * @retval ::NRF_SUCCESS
bogdanm 82:6473597d706e 154 */
bogdanm 82:6473597d706e 155 SVCALL(SD_SOFTDEVICE_FORWARD_TO_APPLICATION, uint32_t, sd_softdevice_forward_to_application(void));
bogdanm 82:6473597d706e 156
bogdanm 82:6473597d706e 157 /** @} */
bogdanm 82:6473597d706e 158
bogdanm 82:6473597d706e 159 #endif // NRF_SDM_H__
bogdanm 82:6473597d706e 160
bogdanm 82:6473597d706e 161 /**
bogdanm 82:6473597d706e 162 @}
bogdanm 82:6473597d706e 163 */