You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2016/11/23 18:52:12 UTC
[49/70] [abbrv] [partial] incubator-mynewt-core git commit: Remove
non-Apache-compatible Nordic SDK files.
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a1481cb2/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/adc/nrf_drv_adc.h
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/adc/nrf_drv_adc.h b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/adc/nrf_drv_adc.h
deleted file mode 100644
index 3639046..0000000
--- a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/adc/nrf_drv_adc.h
+++ /dev/null
@@ -1,298 +0,0 @@
-/* Copyright (c) 2015 Nordic Semiconductor. All Rights Reserved.
- *
- * The information contained herein is property of Nordic Semiconductor ASA.
- * Terms and conditions of usage are described in detail in NORDIC
- * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
- *
- * Licensees are granted free, non-transferable use of the information. NO
- * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
- * the file.
- *
- */
-
-#include "nrf_adc.h"
-#include "nrf_drv_config.h"
-#include "sdk_errors.h"
-#include <stdbool.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/**
- * @addtogroup nrf_adc ADC HAL and driver
- * @ingroup nrf_drivers
- * @brief Analog-to-digital converter (ADC) APIs.
- * @details The ADC HAL provides basic APIs for accessing the registers of the analog-to-digital converter.
- * The ADC driver provides APIs on a higher level.
- *
- * @defgroup nrf_adc_drv ADC driver
- * @{
- * @ingroup nrf_adc
- * @brief Analog-to-digital converter (ADC) driver.
- */
-
-
-/**
- * @brief Driver event types.
- */
-typedef enum
-{
- NRF_DRV_ADC_EVT_DONE, ///< Event generated when the buffer is filled with samples.
- NRF_DRV_ADC_EVT_SAMPLE, ///< Event generated when the requested channel is sampled.
-} nrf_drv_adc_evt_type_t;
-
-typedef int16_t nrf_adc_value_t;
-
-/**
- * @brief Analog-to-digital converter driver DONE event.
- */
-typedef struct
-{
- nrf_adc_value_t * p_buffer; ///< Pointer to buffer with converted samples.
- uint16_t size; ///< Number of samples in the buffer.
-} nrf_drv_adc_done_evt_t;
-
-/**
- * @brief Analog-to-digital converter driver SAMPLE event.
- */
-typedef struct
-{
- nrf_adc_value_t sample; ///< Converted sample.
-} nrf_drv_adc_sample_evt_t;
-
-/**
- * @brief Analog-to-digital converter driver event.
- */
-typedef struct
-{
- nrf_drv_adc_evt_type_t type; ///< Event type.
- union
- {
- nrf_drv_adc_done_evt_t done; ///< Data for DONE event.
- nrf_drv_adc_sample_evt_t sample; ///< Data for SAMPLE event.
- } data;
-} nrf_drv_adc_evt_t;
-
-/**@brief Macro for initializing the ADC channel with the default configuration. */
-#define NRF_DRV_ADC_DEFAULT_CHANNEL(analog_input) \
- {{{ \
- .resolution = NRF_ADC_CONFIG_RES_10BIT, \
- .input = NRF_ADC_CONFIG_SCALING_INPUT_FULL_SCALE, \
- .reference = NRF_ADC_CONFIG_REF_VBG, \
- .ain = (analog_input) \
- }}, NULL}
-
-/**
- * @brief ADC channel configuration.
- *
- * @note The bit fields reflect bit fields in the ADC CONFIG register.
- */
-typedef struct
-{
- uint32_t resolution :2; ///< 8-10 bit resolution.
- uint32_t input :3; ///< Input selection and scaling.
- uint32_t reference :2; ///< Reference source.
- uint32_t reserved :1; ///< Unused bit fields.
- uint32_t ain :8; ///< Analog input.
- uint32_t external_reference:2; ///< Eternal reference source.
-}nrf_drv_adc_channel_config_t;
-
-// Forward declaration of the nrf_drv_adc_channel_t type.
-typedef struct nrf_drv_adc_channel_s nrf_drv_adc_channel_t;
-
-/**
- * @brief ADC channel.
- *
- * This structure is defined by the user and used by the driver. Therefore, it should
- * not be defined on the stack as a local variable.
- */
-struct nrf_drv_adc_channel_s
-{
- union
- {
- nrf_drv_adc_channel_config_t config; ///< Channel configuration.
- uint32_t data; ///< Raw value.
- } config;
- nrf_drv_adc_channel_t * p_next; ///< Pointer to the next enabled channel (for internal use).
-};
-
-/**
- * @brief ADC configuration.
- */
-typedef struct
-{
- uint8_t interrupt_priority; ///< Priority of ADC interrupt.
-} nrf_drv_adc_config_t;
-
-/** @brief ADC default configuration. */
-#define NRF_DRV_ADC_DEFAULT_CONFIG \
-{ \
- .interrupt_priority = ADC_CONFIG_IRQ_PRIORITY \
-}
-
-/**
- * @brief User event handler prototype.
- *
- * This function is called when the requested number of samples has been processed.
- *
- * @param p_event Event.
- */
-typedef void (*nrf_drv_adc_event_handler_t)(nrf_drv_adc_evt_t const * p_event);
-
-/**
- * @brief Function for initializing the ADC.
- *
- * If a valid event handler is provided, the driver is initialized in non-blocking mode.
- * If event_handler is NULL, the driver works in blocking mode.
- *
- * @param[in] p_config Driver configuration.
- * @param[in] event_handler Event handler provided by the user.
- *
- * @retval NRF_SUCCESS If initialization was successful.
- * @retval NRF_ERROR_INVALID_STATE If the driver is already initialized.
- */
-ret_code_t nrf_drv_adc_init(nrf_drv_adc_config_t const * p_config,
- nrf_drv_adc_event_handler_t event_handler);
-
-/**
- * @brief Function for uninitializing the ADC.
- *
- * This function stops all ongoing conversions and disables all channels.
- */
-void nrf_drv_adc_uninit(void);
-
-/**
- * @brief Function for enabling an ADC channel.
- *
- * This function configures and enables the channel. When @ref nrf_drv_adc_buffer_convert is
- * called, all channels that have been enabled with this function are sampled.
- *
- * @note The channel instance variable @p p_channel is used by the driver as an item
- * in a list. Therefore, it cannot be an automatic variable, and an assertion fails if it is
- * an automatic variable (if asserts are enabled).
- */
-void nrf_drv_adc_channel_enable(nrf_drv_adc_channel_t * const p_channel);
-
-/**
- * @brief Function for disabling an ADC channel.
- */
-void nrf_drv_adc_channel_disable(nrf_drv_adc_channel_t * const p_channel);
-
-/**
- * @brief Function for starting ADC sampling.
- *
- * This function triggers single ADC sampling. If more than one channel is enabled, the driver
- * emulates scanning and all channels are sampled in the order they were enabled.
- */
-void nrf_drv_adc_sample(void);
-
-/**
- * @brief Function for executing a single ADC conversion.
- *
- * This function selects the desired input and starts a single conversion. If a valid pointer
- * is provided for the result, the function blocks until the conversion is completed. Otherwise, the
- * function returns when the conversion is started, and the result is provided in an event (driver
- * must be initialized in non-blocking mode otherwise an assertion will fail). The function will fail if
- * ADC is busy. The channel does not need to be enabled to perform a single conversion.
- *
- * @param[in] p_channel Channel.
- * @param[out] p_value Pointer to the location where the result should be placed. Unless NULL is
- * provided, the function is blocking.
- *
- * @retval NRF_SUCCESS If conversion was successful.
- * @retval NRF_ERROR_BUSY If the ADC driver is busy.
- */
-ret_code_t nrf_drv_adc_sample_convert(nrf_drv_adc_channel_t const * const p_channel,
- nrf_adc_value_t * p_value);
-
-/**
- * @brief Function for converting data to the buffer.
- *
- * If the driver is initialized in non-blocking mode, this function returns when the first conversion
- * is set up. When the buffer is filled, the application is notified by the event handler. If the
- * driver is initialized in blocking mode, the function returns when the buffer is filled.
- *
- * Conversion is done on all enabled channels, but it is not triggered by this
- * function. This function will prepare the ADC for sampling and then
- * wait for the SAMPLE task. Sampling can be triggered manually by the @ref
- * nrf_drv_adc_sample function or by PPI using the @ref NRF_ADC_TASK_START task.
- *
- * @note If more than one channel is enabled, the function emulates scanning, and
- * a single START task will trigger conversion on all enabled channels. For example:
- * If 3 channels are enabled and the user requests 6 samples, the completion event
- * handler will be called after 2 START tasks.
- * @note The application must adjust the sampling frequency. The maximum frequency
- * depends on the sampling timer and the maximum latency of the ADC interrupt. If
- * an interrupt is not handled before the next sampling is triggered, the sample
- * will be lost.
- *
- * @param[in] buffer Result buffer.
- * @param[in] size Buffer size in samples.
- *
- * @retval NRF_SUCCESS If conversion was successful.
- * @retval NRF_ERROR_BUSY If the driver is busy.
- */
-ret_code_t nrf_drv_adc_buffer_convert(nrf_adc_value_t * buffer, uint16_t size);
-
-/**
- * @brief Function for retrieving the ADC state.
- *
- * @retval true If the ADC is busy.
- * @retval false If the ADC is ready.
- */
-bool nrf_drv_adc_is_busy(void);
-
-/**
- * @brief Function for getting the address of the ADC START task.
- *
- * This function is used to get the address of the START task, which can be used to trigger ADC
- * conversion.
- *
- * @return Start task address.
- */
-__STATIC_INLINE uint32_t nrf_drv_adc_start_task_get(void);
-
-/**
- * @brief Function for converting a GPIO pin number to an analog input pin mask to be used in
- * the ADC channel configuration.
- *
- * @param[in] pin GPIO pin.
- *
- * @return Analog input pin mask. The function returns @ref NRF_ADC_CONFIG_INPUT_DISABLED
- * if the specified pin is not an analog input.
- */
-__STATIC_INLINE nrf_adc_config_input_t nrf_drv_adc_gpio_to_ain(uint32_t pin);
-
-#ifndef SUPPRESS_INLINE_IMPLEMENTATION
-
-__STATIC_INLINE uint32_t nrf_drv_adc_start_task_get(void)
-{
- return nrf_adc_task_address_get(NRF_ADC_TASK_START);
-}
-
-__STATIC_INLINE nrf_adc_config_input_t nrf_drv_adc_gpio_to_ain(uint32_t pin)
-{
- // AIN2 - AIN7
- if (pin >= 1 && pin <= 6)
- {
- return (nrf_adc_config_input_t)(1 << (pin+1));
- }
- // AIN0 - AIN1
- else if (pin >= 26 && pin <= 27)
- {
- return (nrf_adc_config_input_t)(1 <<(pin - 26));
- }
- else
- {
- return NRF_ADC_CONFIG_INPUT_DISABLED;
- }
-}
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-/** @} */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a1481cb2/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/ble_flash/ble_flash.c
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/ble_flash/ble_flash.c b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/ble_flash/ble_flash.c
deleted file mode 100644
index 12438cc..0000000
--- a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/ble_flash/ble_flash.c
+++ /dev/null
@@ -1,286 +0,0 @@
-/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
- *
- * The information contained herein is property of Nordic Semiconductor ASA.
- * Terms and conditions of usage are described in detail in NORDIC
- * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
- *
- * Licensees are granted free, non-transferable use of the information. NO
- * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
- * the file.
- *
- */
-
-#include "ble_flash.h"
-#include <stdlib.h>
-#include <stdint.h>
-#include <string.h>
-#include "nrf_soc.h"
-#include "nordic_common.h"
-#include "nrf_error.h"
-#include "nrf.h"
-#include "app_util.h"
-
-
-static volatile bool m_radio_active = false; /**< TRUE if radio is active (or about to become active), FALSE otherwise. */
-
-
-uint16_t ble_flash_crc16_compute(uint8_t * p_data, uint16_t size, uint16_t * p_crc)
-{
- uint16_t i;
- uint16_t crc = (p_crc == NULL) ? 0xffff : *p_crc;
-
- for (i = 0; i < size; i++)
- {
- crc = (unsigned char)(crc >> 8) | (crc << 8);
- crc ^= p_data[i];
- crc ^= (unsigned char)(crc & 0xff) >> 4;
- crc ^= (crc << 8) << 4;
- crc ^= ((crc & 0xff) << 4) << 1;
- }
- return crc;
-}
-
-
-/**@brief Function for erasing a page in flash.
- *
- * @param[in] p_page Pointer to first word in page to be erased.
- */
-static void flash_page_erase(uint32_t * p_page)
-{
- // Turn on flash erase enable and wait until the NVMC is ready.
- NRF_NVMC->CONFIG = (NVMC_CONFIG_WEN_Een << NVMC_CONFIG_WEN_Pos);
- while (NRF_NVMC->READY == NVMC_READY_READY_Busy)
- {
- // Do nothing.
- }
-
- // Erase page.
- NRF_NVMC->ERASEPAGE = (uint32_t)p_page;
- while (NRF_NVMC->READY == NVMC_READY_READY_Busy)
- {
- // Do nothing.
- }
-
- // Turn off flash erase enable and wait until the NVMC is ready.
- NRF_NVMC->CONFIG = (NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos);
- while (NRF_NVMC->READY == NVMC_READY_READY_Busy)
- {
- // Do nothing
- }
-}
-
-
-/**@brief Function for writing one word to flash. Unprotected write, which can interfere with radio communication.
- *
- * @details This function DOES NOT use the m_radio_active variable, but will force the write even
- * when the radio is active. To be used only from @ref ble_flash_page_write.
- *
- * @note Flash location to be written must have been erased previously.
- *
- * @param[in] p_address Pointer to flash location to be written.
- * @param[in] value Value to write to flash.
- */
-static void flash_word_unprotected_write(uint32_t * p_address, uint32_t value)
-{
- // Turn on flash write enable and wait until the NVMC is ready.
- NRF_NVMC->CONFIG = (NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos);
- while (NRF_NVMC->READY == NVMC_READY_READY_Busy)
- {
- // Do nothing.
- }
- *p_address = value;
-
- // Wait flash write to finish
- while (NRF_NVMC->READY == NVMC_READY_READY_Busy)
- {
- // Do nothing.
- }
-
- // Turn off flash write enable and wait until the NVMC is ready.
- NRF_NVMC->CONFIG = (NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos);
- while (NRF_NVMC->READY == NVMC_READY_READY_Busy)
- {
- // Do nothing.
- }
-}
-
-
-/**@brief Function for writing one word to flash.
- *
- * @note Flash location to be written must have been erased previously.
- *
- * @param[in] p_address Pointer to flash location to be written.
- * @param[in] value Value to write to flash.
- */
-static void flash_word_write(uint32_t * p_address, uint32_t value)
-{
- // If radio is active, wait for it to become inactive.
- while (m_radio_active)
- {
- // Do nothing (just wait for radio to become inactive).
- (void) sd_app_evt_wait();
- }
-
- // Turn on flash write enable and wait until the NVMC is ready.
- NRF_NVMC->CONFIG = (NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos);
- while (NRF_NVMC->READY == NVMC_READY_READY_Busy)
- {
- // Do nothing.
- }
-
- *p_address = value;
- // Wait flash write to finish
- while (NRF_NVMC->READY == NVMC_READY_READY_Busy)
- {
- // Do nothing.
- }
- // Turn off flash write enable and wait until the NVMC is ready.
- NRF_NVMC->CONFIG = (NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos);
- while (NRF_NVMC->READY == NVMC_READY_READY_Busy)
- {
- // Do nothing
- }
-}
-
-
-uint32_t ble_flash_word_write(uint32_t * p_address, uint32_t value)
-{
- flash_word_write(p_address, value);
- return NRF_SUCCESS;
-}
-
-
-uint32_t ble_flash_block_write(uint32_t * p_address, uint32_t * p_in_array, uint16_t word_count)
-{
- uint16_t i;
-
- for (i = 0; i < word_count; i++)
- {
- flash_word_write(p_address, p_in_array[i]);
- p_address++;
- }
-
- return NRF_SUCCESS;
-}
-
-
-uint32_t ble_flash_page_erase(uint8_t page_num)
-{
- uint32_t * p_page = (uint32_t *)(BLE_FLASH_PAGE_SIZE * page_num);
- flash_page_erase(p_page);
-
- return NRF_SUCCESS;
-}
-
-
-uint32_t ble_flash_page_write(uint8_t page_num, uint32_t * p_in_array, uint8_t word_count)
-{
- int i;
- uint32_t * p_page;
- uint32_t * p_curr_addr;
- uint16_t in_data_crc;
- uint16_t flash_crc;
- uint32_t flash_header;
-
- p_page = (uint32_t *)(BLE_FLASH_PAGE_SIZE * page_num);
- p_curr_addr = p_page;
-
- // Calculate CRC of the data to write.
- in_data_crc = ble_flash_crc16_compute((uint8_t *)p_in_array,
- word_count * sizeof(uint32_t),
- NULL);
-
- // Compare the calculated to the one in flash.
- flash_header = *p_curr_addr;
- flash_crc = (uint16_t)flash_header;
-
- if (flash_crc == in_data_crc)
- {
- // Data is the same as the data already stored in flash, return without modifying flash.
- return NRF_SUCCESS;
- }
-
- // Erase flash page
- flash_page_erase(p_page);
-
- // Reserve space for magic number (for detecting if flash content is valid).
- p_curr_addr++;
-
- // Reserve space for saving word_count.
- p_curr_addr++;
-
- // Write data
- for (i = 0; i < word_count; i++)
- {
- flash_word_unprotected_write(p_curr_addr, p_in_array[i]);
- p_curr_addr++;
- }
-
- // Write number of elements.
- flash_word_write(p_page + 1, (uint32_t)(word_count));
-
- // Write magic number and CRC to indicate that flash content is valid.
- flash_header = BLE_FLASH_MAGIC_NUMBER | (uint32_t)in_data_crc;
- flash_word_write(p_page, flash_header);
-
- return NRF_SUCCESS;
-}
-
-
-uint32_t ble_flash_page_read(uint8_t page_num, uint32_t * p_out_array, uint8_t * p_word_count)
-{
- int byte_count;
- uint32_t * p_page;
- uint32_t * p_curr_addr;
- uint32_t flash_header;
- uint32_t calc_header;
- uint16_t calc_crc;
- uint32_t tmp;
-
- p_page = (uint32_t *)(BLE_FLASH_PAGE_SIZE * page_num);
- p_curr_addr = p_page;
-
- // Check if block is valid
- flash_header = *p_curr_addr;
- tmp = flash_header & 0xFFFF0000;
- if (tmp != BLE_FLASH_MAGIC_NUMBER)
- {
- *p_word_count = 0;
- return NRF_ERROR_NOT_FOUND;
- }
- p_curr_addr++;
-
- // Read number of elements
- *p_word_count = (uint8_t)(*(p_curr_addr));
- p_curr_addr++;
-
- // Read data
- byte_count = (*p_word_count) * sizeof(uint32_t);
- memcpy(p_out_array, p_curr_addr, byte_count);
-
- // Check CRC
- calc_crc = ble_flash_crc16_compute((uint8_t *)p_out_array,
- (*p_word_count) * sizeof(uint32_t),
- NULL);
- calc_header = BLE_FLASH_MAGIC_NUMBER | (uint32_t)calc_crc;
-
- if (calc_header != flash_header)
- {
- return NRF_ERROR_NOT_FOUND;
- }
-
- return NRF_SUCCESS;
-}
-
-
-uint32_t ble_flash_page_addr(uint8_t page_num, uint32_t ** pp_page_addr)
-{
- *pp_page_addr = (uint32_t *)(BLE_FLASH_PAGE_SIZE * page_num);
- return NRF_SUCCESS;
-}
-
-
-void ble_flash_on_radio_active_evt(bool radio_active)
-{
- m_radio_active = radio_active;
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a1481cb2/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/ble_flash/ble_flash.h
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/ble_flash/ble_flash.h b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/ble_flash/ble_flash.h
deleted file mode 100644
index 080ea5a..0000000
--- a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/ble_flash/ble_flash.h
+++ /dev/null
@@ -1,150 +0,0 @@
-/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
- *
- * The information contained herein is property of Nordic Semiconductor ASA.
- * Terms and conditions of usage are described in detail in NORDIC
- * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
- *
- * Licensees are granted free, non-transferable use of the information. NO
- * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
- * the file.
- *
- */
-
-/** @file
- *
- * @defgroup ble_flash_module Flash Manager
- * @{
- * @ingroup ble_sdk_lib
- * @brief Module for accessing flash memory.
- *
- * @details It contains functions for reading, writing and erasing one page in flash.
- *
- * The module uses the first 32 bits of the flash page to write a magic number in order to
- * determine if the page has been written or not.
- *
- * @note Be careful not to use a page number in the SoftDevice area (which currently occupies the
- * range 0 to 127), or in your application space! In both cases, this would end up
- * with a hard fault.
- */
-
-#ifndef BLE_FLASH_H__
-#define BLE_FLASH_H__
-
-#include <stdint.h>
-#include <stdbool.h>
-#include "nrf.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define BLE_FLASH_PAGE_SIZE ((uint16_t)NRF_FICR->CODEPAGESIZE) /**< Size of one flash page. */
-#define BLE_FLASH_MAGIC_NUMBER 0x45DE0000 /**< Magic value to identify if flash contains valid data. */
-#define BLE_FLASH_EMPTY_MASK 0xFFFFFFFF /**< Bit mask that defines an empty address in flash. */
-
-
-/**@brief Macro for getting the end of the flash available for application.
- *
- * @details The result flash page number indicates the end boundary of the flash available
- * to the application. If a bootloader is used, the end will be the start of the
- * bootloader region. Otherwise, the end will be the size of the flash.
- */
-#define BLE_FLASH_PAGE_END \
- ((NRF_UICR->NRFFW[0] != BLE_FLASH_EMPTY_MASK) \
- ? (NRF_UICR->NRFFW[0] / BLE_FLASH_PAGE_SIZE) \
- : NRF_FICR->CODESIZE)
-
-/**@brief Function for erasing the specified flash page, and then writes the given data to this page.
- *
- * @warning This operation blocks the CPU. DO NOT use while in a connection!
- *
- * @param[in] page_num Page number to update.
- * @param[in] p_in_array Pointer to a RAM area containing the elements to write in flash.
- * This area has to be 32 bits aligned.
- * @param[in] word_count Number of 32 bits words to write in flash.
- *
- * @return NRF_SUCCESS on successful flash write, otherwise an error code.
- */
-uint32_t ble_flash_page_write(uint8_t page_num, uint32_t * p_in_array, uint8_t word_count);
-
-/**@brief Function for reading data from flash to RAM.
- *
- * @param[in] page_num Page number to read.
- * @param[out] p_out_array Pointer to a RAM area where the found data will be written.
- * This area has to be 32 bits aligned.
- * @param[out] p_word_count Number of 32 bits words read.
- *
- * @return NRF_SUCCESS on successful upload, NRF_ERROR_NOT_FOUND if no valid data has been found
- * in flash (first 32 bits not equal to the MAGIC_NUMBER+CRC).
- */
-uint32_t ble_flash_page_read(uint8_t page_num, uint32_t * p_out_array, uint8_t * p_word_count);
-
-/**@brief Function for erasing a flash page.
- *
- * @note This operation blocks the CPU, so it should not be done while the radio is running!
- *
- * @param[in] page_num Page number to erase.
- *
- * @return NRF_SUCCESS on success, an error_code otherwise.
- */
-uint32_t ble_flash_page_erase(uint8_t page_num);
-
-/**@brief Function for writing one word to flash.
- *
- * @note Flash location to be written must have been erased previously.
- *
- * @param[in] p_address Pointer to flash location to be written.
- * @param[in] value Value to write to flash.
- *
- * @return NRF_SUCCESS.
- */
-uint32_t ble_flash_word_write(uint32_t * p_address, uint32_t value);
-
-/**@brief Function for writing a data block to flash.
- *
- * @note Flash locations to be written must have been erased previously.
- *
- * @param[in] p_address Pointer to start of flash location to be written.
- * @param[in] p_in_array Pointer to start of flash block to be written.
- * @param[in] word_count Number of words to be written.
- *
- * @return NRF_SUCCESS.
- */
-uint32_t ble_flash_block_write(uint32_t * p_address, uint32_t * p_in_array, uint16_t word_count);
-
-/**@brief Function for computing pointer to start of specified flash page.
- *
- * @param[in] page_num Page number.
- * @param[out] pp_page_addr Pointer to start of flash page.
- *
- * @return NRF_SUCCESS.
- */
-uint32_t ble_flash_page_addr(uint8_t page_num, uint32_t ** pp_page_addr);
-
-/**@brief Function for calculating a 16 bit CRC using the CRC-16-CCITT scheme.
- *
- * @param[in] p_data Pointer to data on which the CRC is to be calulated.
- * @param[in] size Number of bytes on which the CRC is to be calulated.
- * @param[in] p_crc Initial CRC value (if NULL, a preset value is used as the initial value).
- *
- * @return Calculated CRC.
- */
-uint16_t ble_flash_crc16_compute(uint8_t * p_data, uint16_t size, uint16_t * p_crc);
-
-/**@brief Function for handling flashing module Radio Notification event.
- *
- * @note For flash writing to work safely while in a connection or while advertising, this function
- * MUST be called from the Radio Notification module's event handler (see
- * @ref ble_radio_notification for details).
- *
- * @param[in] radio_active TRUE if radio is active (or about to become active), FALSE otherwise.
- */
-void ble_flash_on_radio_active_evt(bool radio_active);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // BLE_FLASH_H__
-
-/** @} */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a1481cb2/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/clock/nrf_drv_clock.c
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/clock/nrf_drv_clock.c b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/clock/nrf_drv_clock.c
deleted file mode 100644
index 8545117..0000000
--- a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/clock/nrf_drv_clock.c
+++ /dev/null
@@ -1,479 +0,0 @@
-/* Copyright (c) 2015 Nordic Semiconductor. All Rights Reserved.
- *
- * The information contained herein is property of Nordic Semiconductor ASA.
- * Terms and conditions of usage are described in detail in NORDIC
- * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
- *
- * Licensees are granted free, non-transferable use of the information. NO
- * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
- * the file.
- *
- */
-
-#include "nrf_drv_clock.h"
-#include "nrf_error.h"
-#include "nordic_common.h"
-
-#ifdef SOFTDEVICE_PRESENT
-#include "nrf_sdm.h"
-#include "nrf_soc.h"
-#include "app_util_platform.h"
-#else
-#include "app_util_platform.h"
-#endif // SOFTDEVICE_PRESENT
-
-/*lint -save -e652 */
-#define NRF_CLOCK_LFCLK_RC CLOCK_LFCLKSRC_SRC_RC
-#define NRF_CLOCK_LFCLK_Xtal CLOCK_LFCLKSRC_SRC_Xtal
-#define NRF_CLOCK_LFCLK_Synth CLOCK_LFCLKSRC_SRC_Synth
-/*lint -restore */
-
-#define INT_MAX 0xFFFFFFFF
-
-#if (CLOCK_CONFIG_LF_SRC == NRF_CLOCK_LFCLK_RC) && !defined(SOFTDEVICE_PRESENT)
-#define CALIBRATION_SUPPORT 1
-#else
-#define CALIBRATION_SUPPORT 0
-#endif
-typedef enum
-{
- CAL_STATE_IDLE,
- CAL_STATE_CT,
- CAL_STATE_HFCLK_REQ,
- CAL_STATE_CAL,
- CAL_STATE_ABORT,
-} nrf_drv_clock_cal_state_t;
-
-/**@brief CLOCK control block. */
-typedef struct
-{
- volatile uint32_t hfclk_requests; /*< High-frequency clock request counter. */
- volatile nrf_drv_clock_handler_item_t * p_hf_head;
- bool module_initialized; /*< Indicate the state of module */
- volatile bool hfclk_on; /*< High-frequency clock state. */
-#ifndef SOFTDEVICE_PRESENT
- volatile bool lfclk_on; /*< Low-frequency clock state. */
- uint32_t lfclk_requests; /*< Low-frequency clock request counter. */
- volatile nrf_drv_clock_handler_item_t * p_lf_head;
-#if CALIBRATION_SUPPORT
- nrf_drv_clock_handler_item_t cal_hfclk_started_handler_item;
- nrf_drv_clock_event_handler_t cal_done_handler;
- volatile nrf_drv_clock_cal_state_t cal_state;
-#endif //CALIBRATION_SUPPORT
-#endif //SOFTDEVICE_PRESENT
-}nrf_drv_clock_cb_t;
-
-static nrf_drv_clock_cb_t m_clock_cb;
-
-#ifndef SOFTDEVICE_PRESENT
-/**@brief Function for starting LFCLK. This function will return immediately without waiting for start.
- */
-static void lfclk_start(void)
-{
- nrf_clock_event_clear(NRF_CLOCK_EVENT_LFCLKSTARTED);
- nrf_clock_int_enable(NRF_CLOCK_INT_LF_STARTED_MASK);
- nrf_clock_task_trigger(NRF_CLOCK_TASK_LFCLKSTART);
-}
-
-/**@brief Function for stopping LFCLK and calibration (if it was set up).
- */
-static void lfclk_stop(void)
-{
-#if CALIBRATION_SUPPORT
- (void)nrf_drv_clock_calibration_abort();
-#endif //CALIBRATION_SUPPORT
-
- nrf_clock_task_trigger(NRF_CLOCK_TASK_LFCLKSTOP);
- while (nrf_clock_lf_is_running())
- {}
-}
-#endif
-static void hfclk_start(void)
-{
-#ifndef SOFTDEVICE_PRESENT
- nrf_clock_event_clear(NRF_CLOCK_EVENT_HFCLKSTARTED);
- nrf_clock_int_enable(NRF_CLOCK_INT_HF_STARTED_MASK);
- nrf_clock_task_trigger(NRF_CLOCK_TASK_HFCLKSTART);
-#else
- UNUSED_VARIABLE(sd_clock_hfclk_request());
-#endif
-}
-
-static void hfclk_stop(void)
-{
-#ifndef SOFTDEVICE_PRESENT
- nrf_clock_task_trigger(NRF_CLOCK_TASK_HFCLKSTOP);
- while (nrf_clock_hf_is_running(NRF_CLOCK_HFCLK_HIGH_ACCURACY))
- {}
-#else
- UNUSED_VARIABLE(sd_clock_hfclk_release());
-#endif
-}
-
-ret_code_t nrf_drv_clock_init(void)
-{
- uint32_t result = NRF_SUCCESS;
-
- if (m_clock_cb.module_initialized)
- {
- return MODULE_ALREADY_INITIALIZED;
- }
-
- m_clock_cb.p_hf_head = NULL;
- m_clock_cb.hfclk_requests = 0;
-#ifndef SOFTDEVICE_PRESENT
- m_clock_cb.p_lf_head = NULL;
- m_clock_cb.lfclk_requests = 0;
- nrf_clock_xtalfreq_set(CLOCK_CONFIG_XTAL_FREQ);
- nrf_clock_lf_src_set((nrf_clock_lfclk_t)CLOCK_CONFIG_LF_SRC);
- nrf_drv_common_irq_enable(POWER_CLOCK_IRQn, CLOCK_CONFIG_IRQ_PRIORITY);
-#if CALIBRATION_SUPPORT
- m_clock_cb.cal_state = CAL_STATE_IDLE;
-#endif // CALIBRATION_SUPPORT
-#else // SOFTDEVICE_PRESENT
- uint8_t is_enabled;
- result = sd_softdevice_is_enabled(&is_enabled);
- if((result == NRF_SUCCESS) && !is_enabled)
- {
- result = NRF_ERROR_SOFTDEVICE_NOT_ENABLED;
- }
-#endif // SOFTDEVICE_PRESENT
- m_clock_cb.module_initialized = true;
- return result;
-}
-
-void nrf_drv_clock_uninit(void)
-{
- ASSERT(m_clock_cb.module_initialized);
-#ifndef SOFTDEVICE_PRESENT
- nrf_drv_common_irq_disable(POWER_CLOCK_IRQn);
- nrf_clock_int_disable(0xFFFFFFFF);
- lfclk_stop();
-#endif
- hfclk_stop();
- m_clock_cb.module_initialized = false;
-}
-
-static void item_enqueue(nrf_drv_clock_handler_item_t ** p_head,
- nrf_drv_clock_handler_item_t * p_item)
-{
- if (*p_head)
- {
- p_item->p_next = *p_head;
- *p_head = p_item;
- }
- else
- {
- p_item->p_next = NULL;
- *p_head = p_item;
- }
-}
-
-static nrf_drv_clock_handler_item_t * item_dequeue(nrf_drv_clock_handler_item_t ** p_head)
-{
- nrf_drv_clock_handler_item_t * p_item = *p_head;
- if (p_item)
- {
- *p_head = p_item->p_next;
- }
-
- return p_item;
-}
-
-void nrf_drv_clock_lfclk_request(nrf_drv_clock_handler_item_t * p_handler_item)
-{
- ASSERT(m_clock_cb.module_initialized);
-#ifndef SOFTDEVICE_PRESENT
- ASSERT(m_clock_cb.lfclk_requests != INT_MAX);
- CRITICAL_REGION_ENTER();
- if (m_clock_cb.lfclk_on)
- {
- if (p_handler_item)
- {
- p_handler_item->event_handler(NRF_DRV_CLOCK_EVT_LFCLK_STARTED);
- }
- }
- else
- {
-
- if (p_handler_item)
- {
- item_enqueue((nrf_drv_clock_handler_item_t **)&m_clock_cb.p_lf_head, p_handler_item);
- }
- if (m_clock_cb.lfclk_requests == 0)
- {
- lfclk_start();
- }
- }
- m_clock_cb.lfclk_requests++;
- CRITICAL_REGION_EXIT();
-#else
- if (p_handler_item)
- {
- p_handler_item->event_handler(NRF_DRV_CLOCK_EVT_LFCLK_STARTED);
- }
-#endif // SOFTDEVICE_PRESENT
-}
-
-
-void nrf_drv_clock_lfclk_release(void)
-{
- ASSERT(m_clock_cb.module_initialized);
-#ifndef SOFTDEVICE_PRESENT
- ASSERT(m_clock_cb.lfclk_requests > 0);
-
- CRITICAL_REGION_ENTER();
- m_clock_cb.lfclk_requests--;
- if (m_clock_cb.lfclk_requests == 0)
- {
- lfclk_stop();
- m_clock_cb.lfclk_on = false;
- m_clock_cb.p_lf_head = NULL;
- }
- CRITICAL_REGION_EXIT();
-#endif // SOFTDEVICE_PRESENT
-}
-
-
-bool nrf_drv_clock_lfclk_is_running(void)
-{
- ASSERT(m_clock_cb.module_initialized);
- bool result;
-#ifndef SOFTDEVICE_PRESENT
- result = nrf_clock_lf_is_running();
-#else
- result = true;
-#endif
- return result;
-}
-
-void nrf_drv_clock_hfclk_request(nrf_drv_clock_handler_item_t * p_handler_item)
-{
- ASSERT(m_clock_cb.module_initialized);
- ASSERT(m_clock_cb.hfclk_requests != INT_MAX);
-
- CRITICAL_REGION_ENTER();
- if (m_clock_cb.hfclk_on)
- {
- if (p_handler_item)
- {
- p_handler_item->event_handler(NRF_DRV_CLOCK_EVT_HFCLK_STARTED);
- }
- }
- else
- {
- if (p_handler_item)
- {
- item_enqueue((nrf_drv_clock_handler_item_t **)&m_clock_cb.p_hf_head, p_handler_item);
- }
- if (m_clock_cb.hfclk_requests == 0)
- {
- hfclk_start();
- }
- }
- m_clock_cb.hfclk_requests++;
- CRITICAL_REGION_EXIT();
-}
-
-void nrf_drv_clock_hfclk_release(void)
-{
- ASSERT(m_clock_cb.module_initialized);
- ASSERT(m_clock_cb.hfclk_requests > 0);
-
- //disable interrupts CLOCK or SoftDevice events
- CRITICAL_REGION_ENTER();
- m_clock_cb.hfclk_requests--;
- if (m_clock_cb.hfclk_requests == 0)
- {
- hfclk_stop();
- m_clock_cb.hfclk_on = false;
- m_clock_cb.p_hf_head = NULL;
- }
- CRITICAL_REGION_EXIT();
- //enable interrupts CLOCK or SoftDevice events
-}
-
-bool nrf_drv_clock_hfclk_is_running(void)
-{
- bool result;
- ASSERT(m_clock_cb.module_initialized);
-#ifndef SOFTDEVICE_PRESENT
- result = nrf_clock_hf_is_running(NRF_CLOCK_HFCLK_HIGH_ACCURACY);
-#else
- uint32_t is_running;
- UNUSED_VARIABLE(sd_clock_hfclk_is_running(&is_running));
- result = is_running ? true : false;
-#endif
- return result;
-}
-
-#if CALIBRATION_SUPPORT
-static void clock_calibration_hf_started(nrf_drv_clock_evt_type_t event)
-{
- if (m_clock_cb.cal_state == CAL_STATE_ABORT)
- {
- nrf_drv_clock_hfclk_release();
- m_clock_cb.cal_state = CAL_STATE_IDLE;
- if (m_clock_cb.cal_done_handler)
- {
- m_clock_cb.cal_done_handler(NRF_DRV_CLOCK_EVT_CAL_ABORTED);
- }
- }
- else
- {
- nrf_clock_int_enable(NRF_CLOCK_INT_DONE_MASK);
- m_clock_cb.cal_state = CAL_STATE_CAL;
- nrf_clock_task_trigger(NRF_CLOCK_TASK_CAL);
- }
-}
-#endif
-
-ret_code_t nrf_drv_clock_calibration_start(uint8_t interval, nrf_drv_clock_event_handler_t handler)
-{
-#if CALIBRATION_SUPPORT
- ASSERT(m_clock_cb.cal_state == CAL_STATE_IDLE);
- ret_code_t ret = NRF_SUCCESS;
- if (m_clock_cb.lfclk_on == false)
- {
- ret = NRF_ERROR_INVALID_STATE;
- }
- else if (m_clock_cb.cal_state == CAL_STATE_IDLE)
- {
- m_clock_cb.cal_done_handler = handler;
- m_clock_cb.cal_hfclk_started_handler_item.event_handler = clock_calibration_hf_started;
- if (interval == 0)
- {
- m_clock_cb.cal_state = CAL_STATE_HFCLK_REQ;
- nrf_drv_clock_hfclk_request(&m_clock_cb.cal_hfclk_started_handler_item);
- }
- else
- {
- m_clock_cb.cal_state = CAL_STATE_CT;
- nrf_clock_cal_timer_timeout_set(interval);
- nrf_clock_int_enable(NRF_CLOCK_INT_CTTO_MASK);
- nrf_clock_task_trigger(NRF_CLOCK_TASK_CTSTART);
- }
- }
- else
- {
- ret = NRF_ERROR_BUSY;
- }
- return ret;
-#else //CALIBRATION_SUPPORT
- return NRF_ERROR_FORBIDDEN;
-#endif
-}
-
-
-ret_code_t nrf_drv_clock_calibration_abort(void)
-{
-#if CALIBRATION_SUPPORT
- CRITICAL_REGION_ENTER();
- switch(m_clock_cb.cal_state)
- {
- case CAL_STATE_CT:
- nrf_clock_int_disable(NRF_CLOCK_INT_CTTO_MASK);
- nrf_clock_task_trigger(NRF_CLOCK_TASK_CTSTOP);
- m_clock_cb.cal_state = CAL_STATE_IDLE;
- if (m_clock_cb.cal_done_handler)
- {
- m_clock_cb.cal_done_handler(NRF_DRV_CLOCK_EVT_CAL_ABORTED);
- }
- break;
- case CAL_STATE_HFCLK_REQ:
- /* fall through. */
- case CAL_STATE_CAL:
- m_clock_cb.cal_state = CAL_STATE_ABORT;
- break;
- default:
- break;
- }
- CRITICAL_REGION_EXIT();
- return NRF_SUCCESS;
-#else //CALIBRATION_SUPPORT
- return NRF_ERROR_FORBIDDEN;
-#endif
-}
-
-ret_code_t nrf_drv_clock_is_calibrating(bool * p_is_calibrating)
-{
-#if CALIBRATION_SUPPORT
- ASSERT(m_clock_cb.module_initialized);
- *p_is_calibrating = (m_clock_cb.cal_state != CAL_STATE_IDLE);
- return NRF_SUCCESS;
-#else //CALIBRATION_SUPPORT
- return NRF_ERROR_FORBIDDEN;
-#endif
-}
-
-static __INLINE void clock_clk_started_notify(nrf_drv_clock_handler_item_t **p_head,
- nrf_drv_clock_evt_type_t evt_type)
-{
- while(1)
- {
- nrf_drv_clock_handler_item_t * p_item = item_dequeue(p_head);
- if (p_item)
- {
- p_item->event_handler(evt_type);
- }
- else
- {
- break;
- }
- }
-}
-
-#ifndef SOFTDEVICE_PRESENT
-void POWER_CLOCK_IRQHandler(void)
-{
- if (nrf_clock_event_check(NRF_CLOCK_EVENT_HFCLKSTARTED))
- {
- nrf_clock_event_clear(NRF_CLOCK_EVENT_HFCLKSTARTED);
- nrf_clock_int_disable(NRF_CLOCK_INT_HF_STARTED_MASK);
- m_clock_cb.hfclk_on = true;
- clock_clk_started_notify((nrf_drv_clock_handler_item_t **)&m_clock_cb.p_hf_head, NRF_DRV_CLOCK_EVT_HFCLK_STARTED);
- }
- if (nrf_clock_event_check(NRF_CLOCK_EVENT_LFCLKSTARTED))
- {
- nrf_clock_event_clear(NRF_CLOCK_EVENT_LFCLKSTARTED);
- nrf_clock_int_disable(NRF_CLOCK_INT_LF_STARTED_MASK);
- m_clock_cb.lfclk_on = true;
- clock_clk_started_notify((nrf_drv_clock_handler_item_t **)&m_clock_cb.p_lf_head, NRF_DRV_CLOCK_EVT_LFCLK_STARTED);
- }
-#if CALIBRATION_SUPPORT
- if (nrf_clock_event_check(NRF_CLOCK_EVENT_CTTO))
- {
- nrf_clock_event_clear(NRF_CLOCK_EVENT_CTTO);
- nrf_clock_int_disable(NRF_CLOCK_INT_CTTO_MASK);
- nrf_drv_clock_hfclk_request(&m_clock_cb.cal_hfclk_started_handler_item);
- }
-
- if (nrf_clock_event_check(NRF_CLOCK_EVENT_DONE))
- {
- nrf_clock_event_clear(NRF_CLOCK_EVENT_DONE);
- nrf_clock_int_disable(NRF_CLOCK_INT_DONE_MASK);
-
- nrf_drv_clock_hfclk_release();
- nrf_drv_clock_evt_type_t evt_type = (m_clock_cb.cal_state == CAL_STATE_ABORT) ?
- NRF_DRV_CLOCK_EVT_CAL_ABORTED : NRF_DRV_CLOCK_EVT_CAL_DONE;
- m_clock_cb.cal_state = CAL_STATE_IDLE;
- if (m_clock_cb.cal_done_handler)
- {
- m_clock_cb.cal_done_handler(evt_type);
- }
- }
-#endif //CALIBRATION_SUPPORT
-}
-#else
-void nrf_drv_clock_on_soc_event(uint32_t evt_id)
-{
- if (evt_id == NRF_EVT_HFCLKSTARTED)
- {
- clock_clk_started_notify((nrf_drv_clock_handler_item_t **)&m_clock_cb.p_hf_head, NRF_DRV_CLOCK_EVT_HFCLK_STARTED);
- }
-}
-#endif // SOFTDEVICE_PRESENT
-
-#undef NRF_CLOCK_LFCLK_RC
-#undef NRF_CLOCK_LFCLK_Xtal
-#undef NRF_CLOCK_LFCLK_Synth
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a1481cb2/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/clock/nrf_drv_clock.h
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/clock/nrf_drv_clock.h b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/clock/nrf_drv_clock.h
deleted file mode 100644
index 78e13d9..0000000
--- a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/clock/nrf_drv_clock.h
+++ /dev/null
@@ -1,254 +0,0 @@
-/* Copyright (c) 2015 Nordic Semiconductor. All Rights Reserved.
- *
- * The information contained herein is property of Nordic Semiconductor ASA.
- * Terms and conditions of usage are described in detail in NORDIC
- * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
- *
- * Licensees are granted free, non-transferable use of the information. NO
- * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
- * the file.
- *
- */
-
-#ifndef NRF_DRV_CLOCK_H__
-#define NRF_DRV_CLOCK_H__
-
-#include <stdbool.h>
-#include <stdint.h>
-#include "sdk_errors.h"
-#include "nrf_assert.h"
-#include "nrf_clock.h"
-#include "nrf_drv_config.h"
-#include "nrf_drv_common.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- *
- * @addtogroup nrf_clock Clock HAL and driver
- * @ingroup nrf_drivers
- * @brief Clock APIs.
- * @details The clock HAL provides basic APIs for accessing the registers of the clock.
- * The clock driver provides APIs on a higher level.
- *
- * @defgroup nrf_clock_drv Clock driver
- * @{
- * @ingroup nrf_clock
- * @brief Driver for managing the low-frequency clock (LFCLK) and the high-frequency clock (HFCLK).
- */
-
-/**
- * @brief Clock events.
- */
-typedef enum
-{
- NRF_DRV_CLOCK_EVT_HFCLK_STARTED, ///< HFCLK has been started.
- NRF_DRV_CLOCK_EVT_LFCLK_STARTED, ///< LFCLK has been started.
- NRF_DRV_CLOCK_EVT_CAL_DONE, ///< Calibration is done.
- NRF_DRV_CLOCK_EVT_CAL_ABORTED, ///< Calibration has been aborted.
-} nrf_drv_clock_evt_type_t;
-
-/**
- * @brief Clock event handler.
- *
- * @param[in] event Event.
- */
-typedef void (*nrf_drv_clock_event_handler_t)(nrf_drv_clock_evt_type_t event);
-
-// Forward declaration of the nrf_drv_clock_handler_item_t type.
-typedef struct nrf_drv_clock_handler_item_s nrf_drv_clock_handler_item_t;
-
-struct nrf_drv_clock_handler_item_s
-{
- nrf_drv_clock_handler_item_t * p_next; ///< A pointer to the next handler that should be called when the clock is started.
- nrf_drv_clock_event_handler_t event_handler; ///< Function to be called when the clock is started.
-};
-
-/**
- * @brief Function for initializing the nrf_drv_clock module.
- *
- * After initialization, the module is in power off state (clocks are not requested).
- *
- * @retval NRF_SUCCESS If the procedure was successful.
- * @retval MODULE_ALREADY_INITIALIZED If the driver was already initialized.
- * @retval NRF_ERROR_SOFTDEVICE_NOT_ENABLED If the SoftDevice was not enabled.
- */
-ret_code_t nrf_drv_clock_init(void);
-
-/**
- * @brief Function for uninitializing the clock module.
- *
- */
-void nrf_drv_clock_uninit(void);
-
-/**
- * @brief Function for requesting the LFCLK.
- *
- * The low-frequency clock can be requested by different modules
- * or contexts. The driver ensures that the clock will be started only when it is requested
- * the first time. If the clock is not ready but it was already started, the handler item that is
- * provided as an input parameter is added to the list of handlers that will be notified
- * when the clock is started. If the clock is already enabled, user callback is called from the
- * current context.
- *
- * The first request will start the selected LFCLK source. If an event handler is
- * provided, it will be called once the LFCLK is started. If the LFCLK was already started at this
- * time, the event handler will be called from the context of this function. Additionally,
- * the @ref nrf_drv_clock_lfclk_is_running function can be polled to check if the clock has started.
- *
- * @note When a SoftDevice is enabled, the LFCLK is always running and the driver cannot control it.
- *
- * @note The handler item provided by the user cannot be an automatic variable.
- *
- * @param[in] p_handler_item A pointer to the event handler structure.
- */
-void nrf_drv_clock_lfclk_request(nrf_drv_clock_handler_item_t * p_handler_item);
-
-/**
- * @brief Function for releasing the LFCLK.
- *
- * If there are no more requests, the LFCLK source will be stopped.
- *
- * @note When a SoftDevice is enabled, the LFCLK is always running.
- */
-void nrf_drv_clock_lfclk_release(void);
-
-/**
- * @brief Function for checking the LFCLK state.
- *
- * @retval true If the LFCLK is running.
- * @retval false If the LFCLK is not running.
- */
-bool nrf_drv_clock_lfclk_is_running(void);
-
-/**
- * @brief Function for requesting the high-accuracy source HFCLK.
- *
- * The high-accuracy source
- * can be requested by different modules or contexts. The driver ensures that the high-accuracy
- * clock will be started only when it is requested the first time. If the clock is not ready
- * but it was already started, the handler item that is provided as an input parameter is added
- * to the list of handlers that will be notified when the clock is started.
- *
- * If an event handler is provided, it will be called once the clock is started. If the clock was already
- * started at this time, the event handler will be called from the context of this function. Additionally,
- * the @ref nrf_drv_clock_hfclk_is_running function can be polled to check if the clock has started.
- *
- * @note If a SoftDevice is running, the clock is managed by the SoftDevice and all requests are handled by
- * the SoftDevice. This function cannot be called from all interrupt priority levels in that case.
- * @note The handler item provided by the user cannot be an automatic variable.
- *
- * @param[in] p_handler_item A pointer to the event handler structure.
- */
-void nrf_drv_clock_hfclk_request(nrf_drv_clock_handler_item_t * p_handler_item);
-
-/**
- * @brief Function for releasing the high-accuracy source HFCLK.
- *
- * If there are no more requests, the high-accuracy source will be released.
- */
-void nrf_drv_clock_hfclk_release(void);
-
-/**
- * @brief Function for checking the HFCLK state.
- *
- * @retval true If the HFCLK is running (for \nRFXX XTAL source).
- * @retval false If the HFCLK is not running.
- */
-bool nrf_drv_clock_hfclk_is_running(void);
-
-/**
- * @brief Function for starting a single calibration process.
- *
- * This function can also delay the start of calibration by a user-specified value. The delay will use
- * a low-power timer that is part of the CLOCK module. @ref nrf_drv_clock_is_calibrating can be called to
- * check if calibration is still in progress. If a handler is provided, the user can be notified when
- * calibration is completed. The ext calibration can be started from the handler context.
- *
- * The calibration process consists of three phases:
- * - Delay (optional)
- * - Requesting the high-accuracy HFCLK
- * - Hardware-supported calibration
- *
- * @param[in] delay Time after which the calibration will be started (in 0.25 s units).
- * @param[in] handler NULL or user function to be called when calibration is completed or aborted.
- *
- * @retval NRF_SUCCESS If the procedure was successful.
- * @retval NRF_ERROR_FORBIDDEN If a SoftDevice is present or the selected LFCLK source is not an RC oscillator.
- * @retval NRF_ERROR_INVALID_STATE If the low-frequency clock is off.
- * @retval NRF_ERROR_BUSY If calibration is in progress.
- */
-ret_code_t nrf_drv_clock_calibration_start(uint8_t delay, nrf_drv_clock_event_handler_t handler);
-
-/**
- * @brief Function for aborting calibration.
- *
- * This function aborts on-going calibration. If calibration was started, it cannot be stopped. If a handler
- * was provided by @ref nrf_drv_clock_calibration_start, this handler will be called once
- * aborted calibration is completed. @ref nrf_drv_clock_is_calibrating can also be used to check
- * if the system is calibrating.
- *
- * @retval NRF_SUCCESS If the procedure was successful.
- * @retval NRF_ERROR_FORBIDDEN If a SoftDevice is present or the selected LFCLK source is not an RC oscillator.
- */
-ret_code_t nrf_drv_clock_calibration_abort(void);
-
-/**
- * @brief Function for checking if calibration is in progress.
- *
- * This function indicates that the system is
- * in calibration if it is in any of the calibration process phases (see @ref nrf_drv_clock_calibration_start).
- *
- * @param[out] p_is_calibrating True if calibration is in progress, false if not.
- *
- * @retval NRF_SUCCESS If the procedure was successful.
- * @retval NRF_ERROR_FORBIDDEN If a SoftDevice is present or the selected LFCLK source is not an RC oscillator.
- */
-ret_code_t nrf_drv_clock_is_calibrating(bool * p_is_calibrating);
-
-/**@brief Function for returning a requested task address for the clock driver module.
- *
- * @param[in] task One of the peripheral tasks.
- *
- * @return Task address.
- */
-__STATIC_INLINE uint32_t nrf_drv_clock_ppi_task_addr(nrf_clock_task_t task);
-
-/**@brief Function for returning a requested event address for the clock driver module.
- *
- * @param[in] event One of the peripheral events.
- *
- * @return Event address.
- */
-__STATIC_INLINE uint32_t nrf_drv_clock_ppi_event_addr(nrf_clock_event_t event);
-
-/**
- * @brief Function called by the SoftDevice handler if an @ref nrf_soc event is received from the SoftDevice.
- */
-#ifdef SOFTDEVICE_PRESENT
-void nrf_drv_clock_on_soc_event(uint32_t evt_id);
-#endif
-/**
- *@}
- **/
-
-#ifndef SUPPRESS_INLINE_IMPLEMENTATION
-__STATIC_INLINE uint32_t nrf_drv_clock_ppi_task_addr(nrf_clock_task_t task)
-{
- return nrf_clock_task_address_get(task);
-}
-
-__STATIC_INLINE uint32_t nrf_drv_clock_ppi_event_addr(nrf_clock_event_t event)
-{
- return nrf_clock_event_address_get(event);
-}
-#endif //SUPPRESS_INLINE_IMPLEMENTATION
-
-/*lint --flb "Leave library region" */
-#ifdef __cplusplus
-}
-#endif
-
-#endif // NRF_CLOCK_H__
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a1481cb2/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/common/nrf_drv_common.c
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/common/nrf_drv_common.c b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/common/nrf_drv_common.c
deleted file mode 100644
index eff432d..0000000
--- a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/common/nrf_drv_common.c
+++ /dev/null
@@ -1,208 +0,0 @@
-/* Copyright (c) 2015 Nordic Semiconductor. All Rights Reserved.
- *
- * The information contained herein is property of Nordic Semiconductor ASA.
- * Terms and conditions of usage are described in detail in NORDIC
- * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
- *
- * Licensees are granted free, non-transferable use of the information. NO
- * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
- * the file.
- *
- */
-
-#include <stddef.h>
-#include "nrf_drv_common.h"
-#include "nrf_assert.h"
-#include "app_util_platform.h"
-
-#ifdef SOFTDEVICE_PRESENT
-#include "nrf_soc.h"
-#endif
-
-
-#if PERIPHERAL_RESOURCE_SHARING_ENABLED
-
-typedef struct {
- nrf_drv_irq_handler_t handler;
- bool acquired;
-} shared_resource_t;
-
-// SPIM0, SPIS0, SPI0, TWIM0, TWIS0, TWI0
-#if (SPI0_ENABLED || SPIS0_ENABLED || TWI0_ENABLED || TWIS0_ENABLED)
- #define SERIAL_BOX_0_IN_USE
- // [this checking may need a different form in unit tests, hence macro]
- #ifndef IS_SERIAL_BOX_0
- #define IS_SERIAL_BOX_0(p_per_base) (p_per_base == NRF_SPI0)
- #endif
-
- static shared_resource_t m_serial_box_0 = { .acquired = false };
- void SPI0_TWI0_IRQHandler(void)
- {
- ASSERT(m_serial_box_0.handler);
- m_serial_box_0.handler();
- }
-#endif // (SPI0_ENABLED || SPIS0_ENABLED || TWI0_ENABLED || TWIS0_ENABLED)
-
-// SPIM1, SPIS1, SPI1, TWIM1, TWIS1, TWI1
-#if (SPI1_ENABLED || SPIS1_ENABLED || TWI1_ENABLED || TWIS1_ENABLED)
- #define SERIAL_BOX_1_IN_USE
- // [this checking may need a different form in unit tests, hence macro]
- #ifndef IS_SERIAL_BOX_1
- #define IS_SERIAL_BOX_1(p_per_base) (p_per_base == NRF_SPI1)
- #endif
-
- static shared_resource_t m_serial_box_1 = { .acquired = false };
- void SPI1_TWI1_IRQHandler(void)
- {
- ASSERT(m_serial_box_1.handler);
- m_serial_box_1.handler();
- }
-#endif // (SPI1_ENABLED || SPIS1_ENABLED || TWI1_ENABLED || TWIS1_ENABLED)
-
-// SPIM2, SPIS2, SPI2
-#if (SPI2_ENABLED || SPIS2_ENABLED)
- #define SERIAL_BOX_2_IN_USE
- // [this checking may need a different form in unit tests, hence macro]
- #ifndef IS_SERIAL_BOX_2
- #define IS_SERIAL_BOX_2(p_per_base) (p_per_base == NRF_SPI2)
- #endif
-
- static shared_resource_t m_serial_box_2 = { .acquired = false };
- void SPIM2_SPIS2_SPI2_IRQHandler(void)
- {
- ASSERT(m_serial_box_2.handler);
- m_serial_box_2.handler();
- }
-#endif // (SPI2_ENABLED || SPIS2_ENABLED)
-
-// COMP, LPCOMP
-#if (COMP_ENABLED || LPCOMP_ENABLED)
- #define COMP_LPCOMP_IN_USE
-
- #ifndef IS_COMP_LPCOMP
- #define IS_COMP_LPCOMP(p_per_base) ((p_per_base) == NRF_LPCOMP)
- #endif
-
- static shared_resource_t m_comp_lpcomp = { .acquired = false };
- void LPCOMP_IRQHandler(void)
- {
- ASSERT(m_comp_lpcomp.handler);
- m_comp_lpcomp.handler();
- }
-#endif // (COMP_ENABLED || LPCOMP_ENABLED)
-
-#if defined(SERIAL_BOX_0_IN_USE) || \
- defined(SERIAL_BOX_1_IN_USE) || \
- defined(SERIAL_BOX_2_IN_USE) || \
- defined(COMP_LPCOMP_IN_USE)
-static ret_code_t acquire_shared_resource(shared_resource_t * p_resource,
- nrf_drv_irq_handler_t handler)
-{
- bool busy = false;
-
- CRITICAL_REGION_ENTER();
- if (p_resource->acquired)
- {
- busy = true;
- }
- else
- {
- p_resource->acquired = true;
- }
- CRITICAL_REGION_EXIT();
-
- if (busy)
- {
- return NRF_ERROR_BUSY;
- }
-
- p_resource->handler = handler;
- return NRF_SUCCESS;
-}
-#endif
-
-ret_code_t nrf_drv_common_per_res_acquire(void const * p_per_base,
- nrf_drv_irq_handler_t handler)
-{
-#ifdef SERIAL_BOX_0_IN_USE
- if (IS_SERIAL_BOX_0(p_per_base))
- {
- return acquire_shared_resource(&m_serial_box_0, handler);
- }
-#endif
-
-#ifdef SERIAL_BOX_1_IN_USE
- if (IS_SERIAL_BOX_1(p_per_base))
- {
- return acquire_shared_resource(&m_serial_box_1, handler);
- }
-#endif
-
-#ifdef SERIAL_BOX_2_IN_USE
- if (IS_SERIAL_BOX_2(p_per_base))
- {
- return acquire_shared_resource(&m_serial_box_2, handler);
- }
-#endif
-
-#ifdef COMP_LPCOMP_IN_USE
- if (IS_COMP_LPCOMP(p_per_base))
- {
- return acquire_shared_resource(&m_comp_lpcomp, handler);
- }
-#endif
-
- return NRF_ERROR_INVALID_PARAM;
-}
-
-void nrf_drv_common_per_res_release(void const * p_per_base)
-{
-#ifdef SERIAL_BOX_0_IN_USE
- if (IS_SERIAL_BOX_0(p_per_base))
- {
- m_serial_box_0.acquired = false;
- }
- else
-#endif
-
-#ifdef SERIAL_BOX_1_IN_USE
- if (IS_SERIAL_BOX_1(p_per_base))
- {
- m_serial_box_1.acquired = false;
- }
- else
-#endif
-
-#ifdef SERIAL_BOX_2_IN_USE
- if (IS_SERIAL_BOX_2(p_per_base))
- {
- m_serial_box_2.acquired = false;
- }
- else
-#endif
-
-#ifdef COMP_LPCOMP_IN_USE
- if (IS_COMP_LPCOMP(p_per_base))
- {
- m_comp_lpcomp.acquired = false;
- }
- else
-#endif
-
- {}
-}
-
-#endif // PERIPHERAL_RESOURCE_SHARING_ENABLED
-
-
-void nrf_drv_common_irq_enable(IRQn_Type IRQn, uint8_t priority)
-{
-
-#ifdef SOFTDEVICE_PRESENT
- ASSERT((priority == APP_IRQ_PRIORITY_LOW) || (priority == APP_IRQ_PRIORITY_HIGH));
-#endif
-
- NVIC_SetPriority(IRQn, priority);
- NVIC_ClearPendingIRQ(IRQn);
- NVIC_EnableIRQ(IRQn);
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a1481cb2/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/common/nrf_drv_common.h
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/common/nrf_drv_common.h b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/common/nrf_drv_common.h
deleted file mode 100644
index 356ff72..0000000
--- a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/common/nrf_drv_common.h
+++ /dev/null
@@ -1,202 +0,0 @@
-/* Copyright (c) 2015 Nordic Semiconductor. All Rights Reserved.
- *
- * The information contained herein is property of Nordic Semiconductor ASA.
- * Terms and conditions of usage are described in detail in NORDIC
- * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
- *
- * Licensees are granted free, non-transferable use of the information. NO
- * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
- * the file.
- *
- */
-
-#ifndef NRF_DRV_COMMON_H__
-#define NRF_DRV_COMMON_H__
-
-#include <stdint.h>
-#include <stdbool.h>
-#include "nrf.h"
-#include "sdk_errors.h"
-#include "nrf_drv_config.h"
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * @brief Offset of event registers in every peripheral instance
- *
- * This is the offset where event registers start in the every peripheral.
- */
-#define NRF_DRV_COMMON_EVREGS_OFFSET 0x100U
-
-/**
- * @brief Driver state.
- */
-typedef enum
-{
- NRF_DRV_STATE_UNINITIALIZED, /**< Uninitialized. */
- NRF_DRV_STATE_INITIALIZED, /**< Initialized but powered off. */
- NRF_DRV_STATE_POWERED_ON
-} nrf_drv_state_t;
-
-/**
- * @brief Driver power state selection.
- */
-typedef enum
-{
- NRF_DRV_PWR_CTRL_ON, /**< Power on request. */
- NRF_DRV_PWR_CTRL_OFF /**< Power off request. */
-} nrf_drv_pwr_ctrl_t;
-
-/**
- * @brief IRQ handler type.
- */
-typedef void (*nrf_drv_irq_handler_t)(void);
-
-
-#if PERIPHERAL_RESOURCE_SHARING_ENABLED
-
-/**
- * @brief Function for acquiring shared peripheral resources associated with
- * the specified peripheral.
- *
- * Certain resources and registers are shared among peripherals that have
- * the same ID (for example: SPI0, SPIM0, SPIS0, TWI0, TWIM0, and TWIS0).
- * Only one of them can be utilized at a given time. This function reserves
- * proper resources to be used by the specified peripheral.
- * If PERIPHERAL_RESOURCE_SHARING_ENABLED is set to a non-zero value, IRQ
- * handlers for peripherals that are sharing resources with others are
- * implemented by the nrf_drv_common module instead of individual drivers.
- * The drivers must then specify their interrupt handling routines and
- * register them by using this function.
- *
- * @param[in] p_per_base Requested peripheral base pointer.
- * @param[in] handler Interrupt handler to register. May be NULL
- * if interrupts are not used for the peripheral.
- *
- * @retval NRF_SUCCESS If resources were acquired successfully.
- * @retval NRF_ERROR_BUSY If resources were already acquired.
- * @retval NRF_ERROR_INVALID_PARAM If the specified peripheral is not enabled
- * or the peripheral does not share resources
- * with other peripherals.
- */
-ret_code_t nrf_drv_common_per_res_acquire(void const * p_per_base,
- nrf_drv_irq_handler_t handler);
-
-/**
- * @brief Function for releasing shared resources reserved previously by
- * @ref nrf_drv_common_per_res_acquire() for the specified peripheral.
- *
- * @param[in] p_per_base Requested peripheral base pointer.
- */
-void nrf_drv_common_per_res_release(void const * p_per_base);
-
-#endif // PERIPHERAL_RESOURCE_SHARING_ENABLED
-
-
-/**
- * @brief Function sets priority and enables NVIC interrupt
- *
- * @note Function checks if correct priority is used when softdevice is present
- *
- * @param[in] IRQn Interrupt id
- * @param[in] priority Interrupt priority
- */
-void nrf_drv_common_irq_enable(IRQn_Type IRQn, uint8_t priority);
-
-/**
- * @brief Function disables NVIC interrupt
- *
- * @param[in] IRQn Interrupt id
- */
-__STATIC_INLINE void nrf_drv_common_irq_disable(IRQn_Type IRQn);
-
-/**
- * @brief Convert bit position to event code
- *
- * Function for converting the bit position in INTEN register to event code
- * that is equivalent to the offset of the event register from the beginning
- * of peripheral instance.
- *
- * For example the result of this function can be casted directly to
- * the types like @ref nrf_twis_event_t or @ref nrf_rng_events_t...
- *
- * @param bit Bit position in INTEN register
- * @return Event code to be casted to the right enum type or to be used in functions like
- * @ref nrf_rng_event_get
- *
- * @sa nrf_drv_event_to_bitpos
- */
-__STATIC_INLINE uint32_t nrf_drv_bitpos_to_event(uint32_t bit);
-
-/**
- * @brief Convert event code to bit position
- *
- * This function can be used to get bit position in INTEN register from event code.
- *
- * @param event Event code that may be casted from enum values from types like
- * @ref nrf_twis_event_t or @ref nrf_rng_events_t
- * @return Bit position in INTEN register that corresponds to the given code.
- *
- * @sa nrf_drv_bitpos_to_event
- */
-__STATIC_INLINE uint32_t nrf_drv_event_to_bitpos(uint32_t event);
-
-/**
- * @brief Get interrupt number connected with given instance
- *
- * Function returns interrupt number for a given instance of any peripheral.
- * @param[in] pinst Pointer to peripheral registry
- * @return Interrupt number
- */
-__STATIC_INLINE IRQn_Type nrf_drv_get_IRQn(void const * const pinst);
-
-/**
- * @brief Check if given object is in RAM
- *
- * Function for analyzing if given location is placed in RAM.
- * This function is used to determine if we have address that can be supported by EasyDMA.
- * @param[in] ptr Pointer to the object
- * @retval true Object is located in RAM
- * @retval false Object is not located in RAM
- */
-__STATIC_INLINE bool nrf_drv_is_in_RAM(void const * const ptr);
-
-
-#ifndef SUPPRESS_INLINE_IMPLEMENTATION
-
-__STATIC_INLINE void nrf_drv_common_irq_disable(IRQn_Type IRQn)
-{
- NVIC_DisableIRQ(IRQn);
-}
-
-__STATIC_INLINE uint32_t nrf_drv_bitpos_to_event(uint32_t bit)
-{
- return NRF_DRV_COMMON_EVREGS_OFFSET + bit * sizeof(uint32_t);
-}
-
-__STATIC_INLINE uint32_t nrf_drv_event_to_bitpos(uint32_t event)
-{
- return (event - NRF_DRV_COMMON_EVREGS_OFFSET) / sizeof(uint32_t);
-}
-
-__STATIC_INLINE IRQn_Type nrf_drv_get_IRQn(void const * const pinst)
-{
- uint8_t ret = (uint8_t)((uint32_t)pinst>>12U);
- return (IRQn_Type) ret;
-}
-
-__STATIC_INLINE bool nrf_drv_is_in_RAM(void const * const ptr)
-{
- return ((((uintptr_t)ptr) & 0xE0000000u) == 0x20000000u);
-}
-
-#endif // SUPPRESS_INLINE_IMPLEMENTATION
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // NRF_DRV_COMMON_H__
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a1481cb2/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/comp/nrf_drv_comp.c
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/comp/nrf_drv_comp.c b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/comp/nrf_drv_comp.c
deleted file mode 100644
index 26b21d5..0000000
--- a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/comp/nrf_drv_comp.c
+++ /dev/null
@@ -1,174 +0,0 @@
-/* Copyright (c) 2015 Nordic Semiconductor. All Rights Reserved.
- *
- * The information contained herein is property of Nordic Semiconductor ASA.
- * Terms and conditions of usage are described in detail in NORDIC
- * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
- *
- * Licensees are granted free, non-transferable use of the information. NO
- * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
- * the file.
- *
- */
-
-#include "nrf_drv_comp.h"
-
-#include "nrf_assert.h"
-#include "nrf_error.h"
-#include "nrf_soc.h"
-#include "nrf_drv_common.h"
-#include "app_util_platform.h"
-#include <stdbool.h>
-#include <stddef.h>
-#include <stdint.h>
-
-#define COMP_IRQ COMP_LPCOMP_IRQn
-#define COMP_IRQ_HANDLER COMP_LPCOMP_IRQHandler
-
-static comp_events_handler_t m_comp_events_handler = NULL;
-static nrf_drv_state_t m_state = NRF_DRV_STATE_UNINITIALIZED;
-
-static const nrf_drv_comp_config_t m_default_config = NRF_DRV_COMP_CONF_DEFAULT_CONFIG(NRF_COMP_INPUT_0);
-
-static void comp_execute_handler(nrf_comp_event_t event, uint32_t event_mask)
-{
- if ( nrf_comp_event_check(event) && nrf_comp_int_enable_check(event_mask) )
- {
- nrf_comp_event_clear(event);
-
- m_comp_events_handler(event);
- }
-}
-
-#if PERIPHERAL_RESOURCE_SHARING_ENABLED
- #define IRQ_HANDLER_NAME irq_handler_for_comp
- #define IRQ_HANDLER static void IRQ_HANDLER_NAME(void)
-
- IRQ_HANDLER;
-#else
- #define IRQ_HANDLER void COMP_IRQ_HANDLER(void)
-#endif // PERIPHERAL_RESOURCE_SHARING_ENABLED
-
-IRQ_HANDLER
-{
- comp_execute_handler(NRF_COMP_EVENT_READY, COMP_INTENSET_READY_Msk);
- comp_execute_handler(NRF_COMP_EVENT_DOWN, COMP_INTENSET_DOWN_Msk);
- comp_execute_handler(NRF_COMP_EVENT_UP, COMP_INTENSET_UP_Msk);
- comp_execute_handler(NRF_COMP_EVENT_CROSS, COMP_INTENSET_CROSS_Msk);
-}
-
-
-ret_code_t nrf_drv_comp_init(const nrf_drv_comp_config_t * p_config,
- comp_events_handler_t event_handler)
-{
- if (m_state != NRF_DRV_STATE_UNINITIALIZED)
- { // COMP driver is already initialized
- return NRF_ERROR_INVALID_STATE;
- }
-
- if (p_config == NULL)
- {
- p_config = &m_default_config;
- }
-
-#if PERIPHERAL_RESOURCE_SHARING_ENABLED
- if (nrf_drv_common_per_res_acquire(NRF_COMP, IRQ_HANDLER_NAME) != NRF_SUCCESS)
- {
- return NRF_ERROR_BUSY;
- }
-#endif
-
- nrf_comp_task_trigger(NRF_COMP_TASK_STOP);
- nrf_comp_enable();
-
- // Clear events to be sure there are no leftovers.
- nrf_comp_event_clear(NRF_COMP_EVENT_READY);
- nrf_comp_event_clear(NRF_COMP_EVENT_DOWN);
- nrf_comp_event_clear(NRF_COMP_EVENT_UP);
- nrf_comp_event_clear(NRF_COMP_EVENT_CROSS);
-
- nrf_comp_ref_set(p_config->reference);
-
- //If external source is chosen, write to appropriate register.
- if (p_config->reference == COMP_REFSEL_REFSEL_ARef)
- {
- nrf_comp_ext_ref_set(p_config->ext_ref);
- }
-
- nrf_comp_th_set(p_config->threshold);
- nrf_comp_main_mode_set(p_config->main_mode);
- nrf_comp_speed_mode_set(p_config->speed_mode);
- nrf_comp_hysteresis_set(p_config->hyst);
- nrf_comp_isource_set(p_config->isource);
- nrf_comp_shorts_disable(NRF_DRV_COMP_SHORT_STOP_AFTER_CROSS_EVT | NRF_DRV_COMP_SHORT_STOP_AFTER_UP_EVT |
- NRF_DRV_COMP_SHORT_STOP_AFTER_DOWN_EVT);
- nrf_comp_int_disable(COMP_INTENCLR_CROSS_Msk | COMP_INTENCLR_UP_Msk |
- COMP_INTENCLR_DOWN_Msk | COMP_INTENCLR_READY_Msk);
-
- if (event_handler)
- {
- m_comp_events_handler = event_handler;
- }
- else
- {
- return NRF_ERROR_INVALID_PARAM;
- }
-
- nrf_comp_input_select(p_config->input);
-
- nrf_drv_common_irq_enable(COMP_LPCOMP_IRQn, p_config->interrupt_priority);
-
- m_state = NRF_DRV_STATE_INITIALIZED;
-
- return NRF_SUCCESS;
-}
-
-
-void nrf_drv_comp_uninit(void)
-{
- ASSERT(m_state != NRF_DRV_STATE_UNINITIALIZED);
- nrf_drv_common_irq_disable(COMP_LPCOMP_IRQn);
- nrf_comp_disable();
- m_state = NRF_DRV_STATE_UNINITIALIZED;
- m_comp_events_handler = NULL;
-}
-
-void nrf_drv_comp_pin_select(nrf_comp_input_t psel)
-{
- bool comp_enable_state = nrf_comp_enable_check();
- nrf_comp_task_trigger(NRF_COMP_TASK_STOP);
- if(m_state == NRF_DRV_STATE_POWERED_ON)
- {
- m_state = NRF_DRV_STATE_INITIALIZED;
- }
- nrf_comp_disable();
- nrf_comp_input_select(psel);
- if(comp_enable_state == true)
- {
- nrf_comp_enable();
- }
-}
-
-void nrf_drv_comp_start(uint32_t comp_int_mask, uint32_t comp_shorts_mask)
-{
- ASSERT(m_state == NRF_DRV_STATE_INITIALIZED);
- nrf_comp_int_enable(comp_int_mask);
- nrf_comp_shorts_enable(comp_shorts_mask);
- nrf_comp_task_trigger(NRF_COMP_TASK_START);
- m_state = NRF_DRV_STATE_POWERED_ON;
-}
-
-void nrf_drv_comp_stop(void)
-{
- ASSERT(m_state == NRF_DRV_STATE_POWERED_ON);
- nrf_comp_shorts_disable(UINT32_MAX);
- nrf_comp_int_disable(UINT32_MAX);
- nrf_comp_task_trigger(NRF_COMP_TASK_STOP);
- m_state = NRF_DRV_STATE_INITIALIZED;
-}
-
-uint32_t nrf_drv_comp_sample()
-{
- ASSERT(m_state == NRF_DRV_STATE_POWERED_ON);
- nrf_comp_task_trigger(NRF_COMP_TASK_SAMPLE);
- return nrf_comp_result_get();
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a1481cb2/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/comp/nrf_drv_comp.h
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/comp/nrf_drv_comp.h b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/comp/nrf_drv_comp.h
deleted file mode 100644
index b1d8d49..0000000
--- a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/comp/nrf_drv_comp.h
+++ /dev/null
@@ -1,276 +0,0 @@
-/* Copyright (c) 2015 Nordic Semiconductor. All Rights Reserved.
- *
- * The information contained herein is property of Nordic Semiconductor ASA.
- * Terms and conditions of usage are described in detail in NORDIC
- * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
- *
- * Licensees are granted free, non-transferable use of the information. NO
- * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
- * the file.
- *
- */
-
-#ifndef NRF_DRV_COMP_H__
-#define NRF_DRV_COMP_H__
-
-#include "nrf_comp.h"
-#include "sdk_errors.h"
-#include "nrf_drv_common.h"
-#include "nrf_drv_config.h"
-#include "app_util_platform.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * @addtogroup nrf_comp COMP HAL and driver
- * @ingroup nrf_drivers
- * @brief @tagAPI52 Comparator (COMP) APIs.
- * @details The COMP HAL provides basic APIs for accessing the registers of Comparator.
- * The COMP driver provides APIs on a higher level.
- *
- * @defgroup nrf_drivers_comp COMP driver
- * @{
- * @ingroup nrf_comp
- * @brief @tagAPI52 Comparator (COMP) driver.
- */
-
-/**
- * @brief Macro to convert the threshold voltage to an integer value (needed by the COMP_TH register).
- *
- * @param[in] vol Voltage to be changed to COMP_TH register value. This value must not be smaller than
- * reference voltage divided by 64.
- * @param[in] ref Reference voltage.
- */
-#define VOLTAGE_THRESHOLD_TO_INT(vol, ref) (uint8_t)(((vol) > ((ref)/64)) ? (ROUNDED_DIV((vol)*64,(ref))-1) : 0)
-
-/**@brief COMP event handler function type.
- * @param[in] event COMP event.
- */
-typedef void (* comp_events_handler_t)(nrf_comp_event_t event);
-
-/**
- * @enum nrf_drv_comp_short_mask_t
- * @brief COMP shortcut masks.
- */
-typedef enum
-{
- NRF_DRV_COMP_SHORT_STOP_AFTER_CROSS_EVT = COMP_SHORTS_CROSS_STOP_Msk, /*!< Shortcut between the CROSS event and the STOP task. */
- NRF_DRV_COMP_SHORT_STOP_AFTER_UP_EVT = COMP_SHORTS_UP_STOP_Msk, /*!< Shortcut between the UP event and the STOP task. */
- NRF_DRV_COMP_SHORT_STOP_AFTER_DOWN_EVT = COMP_SHORTS_DOWN_STOP_Msk /*!< Shortcut between the DOWN event and the STOP task. */
-}nrf_drv_comp_short_mask_t;
-
-/**
- * @enum nrf_drv_comp_evt_en_mask_t
- * @brief COMP events masks.
- */
-typedef enum
-{
- NRF_DRV_COMP_EVT_EN_CROSS_MASK = COMP_INTENSET_CROSS_Msk, /*!< CROSS event (generated after VIN+ == VIN-). */
- NRF_DRV_COMP_EVT_EN_UP_MASK = COMP_INTENSET_UP_Msk, /*!< UP event (generated when VIN+ crosses VIN- while increasing). */
- NRF_DRV_COMP_EVT_EN_DOWN_MASK = COMP_INTENSET_DOWN_Msk, /*!< DOWN event (generated when VIN+ crosses VIN- while decreasing). */
- NRF_DRV_COMP_EVT_EN_READY_MASK = COMP_INTENSET_READY_Msk /*!< READY event (generated when the module is ready). */
-}nrf_drv_comp_evt_en_mask_t;
-
-/**@brief COMP configuration.
- */
-typedef struct
-{
- nrf_comp_ref_t reference; /**< Reference selection. */
- nrf_comp_ext_ref_t ext_ref; /**< External analog reference selection. */
- nrf_comp_main_mode_t main_mode; /**< Main operation mode. */
- nrf_comp_th_t threshold; /**< Structure holding THDOWN and THUP values needed by the COMP_TH register. */
- nrf_comp_sp_mode_t speed_mode; /**< Speed and power mode. */
- nrf_comp_hyst_t hyst; /**< Comparator hysteresis.*/
- nrf_isource_t isource; /**< Current source selected on analog input. */
- nrf_comp_input_t input; /**< Input to be monitored. */
- uint8_t interrupt_priority; /**< Interrupt priority. */
-} nrf_drv_comp_config_t;
-
-/** @brief COMP threshold default configuration. */
-#define COMP_CONFIG_TH \
-{ \
- .th_down = VOLTAGE_THRESHOLD_TO_INT(0.5, 1.8), \
- .th_up = VOLTAGE_THRESHOLD_TO_INT(1.5, 1.8) \
-}
-
-/** @brief COMP driver default configuration including the COMP HAL configuration. */
-#define NRF_DRV_COMP_CONF_DEFAULT_CONFIG(INPUT) \
- { \
- .reference = COMP_CONFIG_REF, \
- .main_mode = COMP_CONFIG_MAIN_MODE, \
- .threshold = COMP_CONFIG_TH, \
- .speed_mode = COMP_CONFIG_SPEED_MODE, \
- .hyst = COMP_CONFIG_HYST, \
- .isource = COMP_CONFIG_ISOURCE, \
- .input = INPUT, \
- .interrupt_priority = COMP_CONFIG_IRQ_PRIORITY \
- }
-
-/**
- * @brief Function for initializing the COMP driver.
- *
- * This function initializes the COMP driver, but does not enable the peripheral or any interrupts.
- * To start the driver, call the function @ref nrf_drv_comp_start() after initialization.
- *
- * If no configuration structure is provided, the driver is initialized with the default settings.
- *
- * @param[in] p_config Initial configuration. If NULL, the default configuration is used.
- * @param[in] event_handler Handler function.
- *
- * @retval NRF_ERROR_INVALID_PARAM If the configuration is invalid.
- * @retval NRF_ERROR_INVALID_STATE If the driver has already been initialized.
- * @retval NRF_ERROR_BUSY If the LPCOMP driver is initialized.
- */
-ret_code_t nrf_drv_comp_init(const nrf_drv_comp_config_t * p_config,
- comp_events_handler_t event_handler);
-
-
-/**
- * @brief Function for uninitializing the COMP driver.
- *
- * This function uninitializes the COMP driver. The COMP peripheral and
- * its interrupts are disabled, and local variables are cleaned. After this call, you must
- * initialize the driver again by calling nrf_drv_comp_init() if you want to use it.
- *
- * @sa nrf_drv_comp_stop()
- */
-void nrf_drv_comp_uninit(void);
-
-/**
- * @brief Function for setting the analog input.
- *
- * @param[in] psel COMP analog pin selection.
- */
-void nrf_drv_comp_pin_select(nrf_comp_input_t psel);
-
-/**
- * @brief Function for starting the COMP peripheral and interrupts.
- *
- * Before calling this function, the driver must be initialized. This function
- * enables the COMP peripheral and its interrupts.
- *
- * @param[in] comp_evt_en_mask Mask of events to be enabled. This parameter should be built as
- * 'or' of elements from @ref nrf_drv_comp_evt_en_mask_t.
- * @param[in] comp_shorts_mask Mask of shorts to be enabled. This parameter should be built as
- * 'or' of elements from @ref nrf_drv_comp_short_mask_t.
- *
- * @sa nrf_drv_comp_init()
- *
- */
-void nrf_drv_comp_start(uint32_t comp_evt_en_mask, uint32_t comp_shorts_mask);
-
-/**@brief Function for stopping the COMP peripheral.
- *
- * Before calling this function, the driver must be enabled. This function disables the COMP
- * peripheral and its interrupts.
- *
- * @sa nrf_drv_comp_uninit()
- *
- */
-void nrf_drv_comp_stop(void);
-
-/**
- * @brief Function for copying the current state of the comparator result to the RESULT register.
- *
- * @retval 0 If the input voltage is below the threshold (VIN+ < VIN-).
- * @retval 1 If the input voltage is above the threshold (VIN+ > VIN-).
- */
-uint32_t nrf_drv_comp_sample(void);
-
-/**
- * @brief Function for getting the task address.
- *
- * Before calling this function, the driver must be enabled.
- *
- * @param[in] comp_task COMP task.
- *
- * @return Address of the given COMP task.
- */
-__STATIC_INLINE uint32_t nrf_drv_comp_task_address_get(nrf_comp_task_t comp_task)
-{
- return (uint32_t)nrf_comp_task_address_get(comp_task);
-}
-
-/**
- * @brief Function for getting the event address.
- *
- * @param[in] comp_event COMP event.
- *
- * @return Address of the given COMP event.
- */
-__STATIC_INLINE uint32_t nrf_drv_comp_event_address_get(nrf_comp_event_t comp_event)
-{
- return (uint32_t)nrf_comp_event_address_get(comp_event);
-}
-
-/**
- * @brief Function for converting a GPIO pin number to an analog COMP channel.
- *
- * @param[in] pin GPIO pin number.
- *
- * @return COMP channel. The function returns UINT8_MAX
- * if the specified pin is not an analog input.
- */
-__STATIC_INLINE nrf_comp_input_t nrf_drv_comp_gpio_to_ain(uint8_t pin);
-
-/**
- * @brief Function for converting a COMP channel to a GPIO pin number.
- *
- * @param[in] ain COMP channel.
- *
- * @return GPIO pin number. The function returns UINT8_MAX
- * if the specified channel is not a GPIO pin.
- */
-__STATIC_INLINE uint8_t nrf_drv_comp_ain_to_gpio(nrf_comp_input_t ain);
-
-#ifndef SUPPRESS_INLINE_IMPLEMENTATION
-
-__STATIC_INLINE nrf_comp_input_t nrf_drv_comp_gpio_to_ain(uint8_t pin)
-{
- // AIN0 - AIN3
- if ((pin >= 2) && (pin <= 5))
- {
- return (nrf_comp_input_t)(pin-2);
- }
- // AIN4 - AIN7
- else if ((pin >= 28) && (pin <= 31))
- {
- return (nrf_comp_input_t)(pin - 24);
- }
- else
- {
- return (nrf_comp_input_t)UINT8_MAX;
- }
-}
-
-__STATIC_INLINE uint8_t nrf_drv_comp_ain_to_gpio(nrf_comp_input_t ain)
-{
- // AIN0 - AIN3
- if (ain <= 3)
- {
- return (uint8_t)(ain + 2);
- }
- // AIN4 - AIN7
- else if ((ain >= 4) && (ain <= 7))
- {
- return (uint8_t)(ain + 24);
- }
- else
- {
- return UINT8_MAX;
- }
-}
-
-#endif //SUPPRESS_INLINE_IMPLEMENTATION
-
-/**
- *@}
- **/
-
-#ifdef __cplusplus
-}
-#endif
-
- #endif /* NRF_DRV_COMP_H__ */