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/i2s/nrf_drv_i2s.c ---------------------------------------------------------------------- diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/i2s/nrf_drv_i2s.c b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/i2s/nrf_drv_i2s.c deleted file mode 100644 index 7d978e9..0000000 --- a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/i2s/nrf_drv_i2s.c +++ /dev/null @@ -1,355 +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_i2s.h" -#include "nrf_drv_common.h" -#include "nrf_gpio.h" -#include "nrf_assert.h" -#include "app_util_platform.h" -#include "sdk_common.h" - -#if (I2S_ENABLED == 0) - #error "I2S not enabled in driver configuration file." -#endif - -// Control block - driver instance local data. -typedef struct -{ - nrf_drv_i2s_data_handler_t handler; - nrf_drv_state_t state; - - bool synchronized_mode : 1; - bool rx_ready : 1; - bool tx_ready : 1; - bool just_started : 1; - uint16_t buffer_half_size; - uint32_t * p_rx_buffer; - uint32_t * p_tx_buffer; -} i2s_control_block_t; -static i2s_control_block_t m_cb; - -#define MODULE_INITIALIZED (m_cb.state == NRF_DRV_STATE_INITIALIZED) -#include "sdk_macros.h" - -static nrf_drv_i2s_config_t const m_default_config = NRF_DRV_I2S_DEFAULT_CONFIG; - - -static void configure_pins(nrf_drv_i2s_config_t const * p_config) -{ - uint32_t mck_pin, sdout_pin, sdin_pin; - - // Configure pins used by the peripheral: - - // - SCK and LRCK (required) - depending on the mode of operation these - // pins are configured as outputs (in Master mode) or inputs (in Slave - // mode). - if (p_config->mode == NRF_I2S_MODE_MASTER) - { - nrf_gpio_cfg_output(p_config->sck_pin); - nrf_gpio_cfg_output(p_config->lrck_pin); - } - else - { - nrf_gpio_cfg_input(p_config->sck_pin, NRF_GPIO_PIN_NOPULL); - nrf_gpio_cfg_input(p_config->lrck_pin, NRF_GPIO_PIN_NOPULL); - } - - // - MCK (optional) - always output, - if (p_config->mck_pin != NRF_DRV_I2S_PIN_NOT_USED) - { - mck_pin = p_config->mck_pin; - nrf_gpio_cfg_output(mck_pin); - } - else - { - mck_pin = NRF_I2S_PIN_NOT_CONNECTED; - } - - // - SDOUT (optional) - always output, - if (p_config->sdout_pin != NRF_DRV_I2S_PIN_NOT_USED) - { - sdout_pin = p_config->sdout_pin; - nrf_gpio_cfg_output(sdout_pin); - } - else - { - sdout_pin = NRF_I2S_PIN_NOT_CONNECTED; - } - - // - SDIN (optional) - always input. - if (p_config->sdin_pin != NRF_DRV_I2S_PIN_NOT_USED) - { - sdin_pin = p_config->sdin_pin; - nrf_gpio_cfg_input(sdin_pin, NRF_GPIO_PIN_NOPULL); - } - else - { - sdin_pin = NRF_I2S_PIN_NOT_CONNECTED; - } - - nrf_i2s_pins_set(NRF_I2S, p_config->sck_pin, p_config->lrck_pin, - mck_pin, sdout_pin, sdin_pin); -} - - -ret_code_t nrf_drv_i2s_init(nrf_drv_i2s_config_t const * p_config, - nrf_drv_i2s_data_handler_t handler) -{ - ASSERT(handler); - if (m_cb.state != NRF_DRV_STATE_UNINITIALIZED) - { - return NRF_ERROR_INVALID_STATE; - } - - if (p_config == NULL) - { - p_config = &m_default_config; - } - - if (!nrf_i2s_configure(NRF_I2S, p_config->mode, - p_config->format, - p_config->alignment, - p_config->sample_width, - p_config->channels, - p_config->mck_setup, - p_config->ratio)) - { - return NRF_ERROR_INVALID_PARAM; - } - configure_pins(p_config); - - m_cb.handler = handler; - - nrf_drv_common_irq_enable(I2S_IRQn, p_config->irq_priority); - - m_cb.state = NRF_DRV_STATE_INITIALIZED; - - return NRF_SUCCESS; -} - - -void nrf_drv_i2s_uninit(void) -{ - ASSERT(m_cb.state != NRF_DRV_STATE_UNINITIALIZED); - - nrf_drv_i2s_stop(); - - nrf_drv_common_irq_disable(I2S_IRQn); - - m_cb.state = NRF_DRV_STATE_UNINITIALIZED; -} - - -ret_code_t nrf_drv_i2s_start(uint32_t * p_rx_buffer, - uint32_t * p_tx_buffer, - uint16_t buffer_size, - uint8_t flags) -{ - ASSERT((p_rx_buffer != NULL) || (p_tx_buffer != NULL)); - - uint16_t buffer_half_size = buffer_size / 2; - ASSERT(buffer_half_size != 0); - - VERIFY_MODULE_INITIALIZED(); - - if ((p_rx_buffer != NULL) && !nrf_drv_is_in_RAM(p_rx_buffer)) - { - return NRF_ERROR_INVALID_ADDR; - } - - if ((p_tx_buffer != NULL) && !nrf_drv_is_in_RAM(p_tx_buffer)) - { - return NRF_ERROR_INVALID_ADDR; - } - - // Initially we set up the peripheral to use the first half of each buffer, - // then in 'I2S_IRQHandler' we will switch to the second half. - nrf_i2s_transfer_set(NRF_I2S, buffer_half_size, p_rx_buffer, p_tx_buffer); - - m_cb.p_rx_buffer = p_rx_buffer; - m_cb.p_tx_buffer = p_tx_buffer; - m_cb.buffer_half_size = buffer_half_size; - m_cb.just_started = true; - - if ((flags & NRF_DRV_I2S_FLAG_SYNCHRONIZED_MODE) && - // [synchronized mode makes sense only when both RX and TX are enabled] - (m_cb.p_rx_buffer != NULL) && (m_cb.p_tx_buffer != NULL)) - { - m_cb.synchronized_mode = true; - m_cb.rx_ready = false; - m_cb.tx_ready = false; - } - else - { - m_cb.synchronized_mode = false; - } - - nrf_i2s_enable(NRF_I2S); - - m_cb.state = NRF_DRV_STATE_POWERED_ON; - - if (m_cb.p_tx_buffer != NULL) - { - // Get from the application the first portion of data to be sent - we - // need to have it in the transmit buffer before we start the transfer. - // Unless the synchronized mode is active. In this mode we must wait - // with this until the first portion of data is received, so here we - // just make sure that there will be silence on the SDOUT line prior - // to that moment. - if (m_cb.synchronized_mode) - { - memset(m_cb.p_tx_buffer, 0, buffer_size); - } - else - { - m_cb.handler(NULL, m_cb.p_tx_buffer, m_cb.buffer_half_size); - } - } - - nrf_i2s_event_clear(NRF_I2S, NRF_I2S_EVENT_RXPTRUPD); - nrf_i2s_event_clear(NRF_I2S, NRF_I2S_EVENT_TXPTRUPD); - nrf_i2s_int_enable(NRF_I2S, - NRF_I2S_INT_RXPTRUPD_MASK | NRF_I2S_INT_TXPTRUPD_MASK); - nrf_i2s_task_trigger(NRF_I2S, NRF_I2S_TASK_START); - - return NRF_SUCCESS; -} - - -void nrf_drv_i2s_stop(void) -{ - ASSERT(m_cb.state != NRF_DRV_STATE_UNINITIALIZED); - - // First disable interrupts, then trigger the STOP task, so no spurious - // RXPTRUPD and TXPTRUPD events (see FTPAN-55) will be processed. - nrf_i2s_int_disable(NRF_I2S, - NRF_I2S_INT_RXPTRUPD_MASK | NRF_I2S_INT_TXPTRUPD_MASK); - - nrf_i2s_task_trigger(NRF_I2S, NRF_I2S_TASK_STOP); - - nrf_i2s_disable(NRF_I2S); - - m_cb.state = NRF_DRV_STATE_INITIALIZED; -} - - -void I2S_IRQHandler(void) -{ - uint32_t * p_data_received = NULL; - uint32_t * p_data_to_send = NULL; - - if (nrf_i2s_event_check(NRF_I2S, NRF_I2S_EVENT_TXPTRUPD)) - { - nrf_i2s_event_clear(NRF_I2S, NRF_I2S_EVENT_TXPTRUPD); - - // If transmission is not enabled, but for some reason the TXPTRUPD - // event has been generated, just ignore it. - if (m_cb.p_tx_buffer != NULL) - { - uint32_t * p_tx_buffer_next; - if (nrf_i2s_tx_buffer_get(NRF_I2S) == m_cb.p_tx_buffer) - { - p_tx_buffer_next = m_cb.p_tx_buffer + m_cb.buffer_half_size; - } - else - { - p_tx_buffer_next = m_cb.p_tx_buffer; - } - nrf_i2s_tx_buffer_set(NRF_I2S, p_tx_buffer_next); - - m_cb.tx_ready = true; - - // Now the part of the buffer that we've configured as "next" should - // be filled by the application with proper data to be sent; - // the peripheral is sending data from the other part of the buffer - // (but it will finish soon...). - p_data_to_send = p_tx_buffer_next; - } - } - - if (nrf_i2s_event_check(NRF_I2S, NRF_I2S_EVENT_RXPTRUPD)) - { - nrf_i2s_event_clear(NRF_I2S, NRF_I2S_EVENT_RXPTRUPD); - - // If reception is not enabled, but for some reason the RXPTRUPD event - // has been generated, just ignore it. - if (m_cb.p_rx_buffer != NULL) - { - uint32_t * p_rx_buffer_next; - if (nrf_i2s_rx_buffer_get(NRF_I2S) == m_cb.p_rx_buffer) - { - p_rx_buffer_next = m_cb.p_rx_buffer + m_cb.buffer_half_size; - } - else - { - p_rx_buffer_next = m_cb.p_rx_buffer; - } - nrf_i2s_rx_buffer_set(NRF_I2S, p_rx_buffer_next); - - m_cb.rx_ready = true; - - // The RXPTRUPD event is generated for the first time right after - // the transfer is started. Since there is no data received yet at - // this point we only update the buffer pointer (it is done above), - // there is no callback to the application. - // [for synchronized mode this has to be handled differently - - // see below] - if (m_cb.just_started && !m_cb.synchronized_mode) - { - m_cb.just_started = false; - } - else - { - // The RXPTRUPD event indicates that from now on the peripheral - // will be filling the part of the buffer that was pointed at - // the time the event has been generated, hence now we can let - // the application process the data stored in the other part of - // the buffer - the one that we've just set to be filled next. - p_data_received = p_rx_buffer_next; - } - } - } - - // Call the data handler passing received data to the application and/or - // requesting data to be sent. - if (!m_cb.synchronized_mode) - { - if ((p_data_received != NULL) || (p_data_to_send != NULL)) - { - m_cb.handler(p_data_received, p_data_to_send, - m_cb.buffer_half_size); - } - } - // In the synchronized mode wait until the events for both RX and TX occur. - // And ignore the initial occurrences of these events, since they only - // indicate that the transfer has started - no data is received yet at - // that moment, so we have got nothing to pass to the application. - else - { - if (m_cb.rx_ready && m_cb.tx_ready) - { - m_cb.rx_ready = false; - m_cb.tx_ready = false; - - if (m_cb.just_started) - { - m_cb.just_started = false; - } - else - { - m_cb.handler(nrf_i2s_rx_buffer_get(NRF_I2S), - nrf_i2s_tx_buffer_get(NRF_I2S), - m_cb.buffer_half_size); - } - } - } -}
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/i2s/nrf_drv_i2s.h ---------------------------------------------------------------------- diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/i2s/nrf_drv_i2s.h b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/i2s/nrf_drv_i2s.h deleted file mode 100644 index b732f64..0000000 --- a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/i2s/nrf_drv_i2s.h +++ /dev/null @@ -1,227 +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. - * - */ - -/**@file - * @addtogroup nrf_i2s I2S HAL and driver - * @ingroup nrf_drivers - * @brief @tagAPI52 Inter-IC Sound (I2S) interface APIs. - * - * @defgroup nrf_drv_i2s I2S driver - * @{ - * @ingroup nrf_i2s - * @brief @tagAPI52 Inter-IC Sound (I2S) interface driver. - */ - - -#ifndef NRF_DRV_I2S_H__ -#define NRF_DRV_I2S_H__ - -#include "nordic_common.h" -#include "nrf_drv_config.h" -#include "nrf_i2s.h" -#include "sdk_errors.h" - - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief This value can be provided instead of a pin number for the signals - * SDOUT, SDIN, and MCK to specify that a given signal is not used - * and therefore does not need to be connected to a pin. - */ -#define NRF_DRV_I2S_PIN_NOT_USED 0xFF - -/** - * @brief Flag indicating that calls to the data handler for RX and TX should - * be synchronized, thus always combined into one call. - * - * Use this flag when calling @ref nrf_drv_i2s_start to force a common call - * to the @ref nrf_drv_i2s_data_handler_t "data handler" for RX and TX data. - * This is useful, for example, when received data should be processed and - * then be sent back. Obviously, this flag is only applicable when both - * directions (RX and TX) are enabled. - */ -#define NRF_DRV_I2S_FLAG_SYNCHRONIZED_MODE 0x01 - -/** - * @brief I2S driver configuration structure. - */ -typedef struct -{ - uint8_t sck_pin; ///< SCK pin number. - uint8_t lrck_pin; ///< LRCK pin number. - uint8_t mck_pin; ///< MCK pin number. - /**< Optional. Use @ref NRF_DRV_I2S_PIN_NOT_USED - * if this signal is not needed. */ - uint8_t sdout_pin; ///< SDOUT pin number. - /**< Optional. Use @ref NRF_DRV_I2S_PIN_NOT_USED - * if this signal is not needed. */ - uint8_t sdin_pin; ///< SDIN pin number. - /**< Optional. Use @ref NRF_DRV_I2S_PIN_NOT_USED - * if this signal is not needed. */ - uint8_t irq_priority; ///< Interrupt priority. - - nrf_i2s_mode_t mode; ///< Mode of operation. - nrf_i2s_format_t format; ///< Frame format. - nrf_i2s_align_t alignment; ///< Alignment of sample within a frame. - nrf_i2s_swidth_t sample_width; ///< Sample width. - nrf_i2s_channels_t channels; ///< Enabled channels. - nrf_i2s_mck_t mck_setup; ///< Master clock setup. - nrf_i2s_ratio_t ratio; ///< MCK/LRCK ratio. -} nrf_drv_i2s_config_t; - -/** - * @brief I2S driver default configuration. - */ -#define NRF_DRV_I2S_DEFAULT_CONFIG \ -{ \ - .sck_pin = I2S_CONFIG_SCK_PIN, \ - .lrck_pin = I2S_CONFIG_LRCK_PIN, \ - .mck_pin = I2S_CONFIG_MCK_PIN, \ - .sdout_pin = I2S_CONFIG_SDOUT_PIN, \ - .sdin_pin = I2S_CONFIG_SDIN_PIN, \ - .irq_priority = I2S_CONFIG_IRQ_PRIORITY, \ - .mode = I2S_CONFIG_MASTER, \ - .format = I2S_CONFIG_FORMAT, \ - .alignment = I2S_CONFIG_ALIGN, \ - .sample_width = I2S_CONFIG_SWIDTH, \ - .channels = I2S_CONFIG_CHANNELS, \ - .mck_setup = I2S_CONFIG_MCK_SETUP, \ - .ratio = I2S_CONFIG_RATIO, \ -} - -/** - * @brief I2S driver data handler type. - * - * A data handling function of this type must be specified during initialization - * of the driver. The driver will call this function when a new portion of data - * is received or a new portion of data should be prepared for transmission. - * The first case is indicated by a non-NULL value in the @p p_data_received - * parameter (which points to the memory containing the received data). - * Similarly, the second case is indicated by a non-NULL value in the - * @p p_data_to_send parameter (which points to where the data to be transmitted - * should be placed). - * - * @note The two cases mentioned above may be indicated separately or combined - * into one call (depending on the environment in which the driver is - * used). Therefore, both parameters should be checked and handled - * properly in every call. @ref NRF_DRV_I2S_FLAG_SYNCHRONIZED_MODE - * "Synchronized mode" can be used to always combine these indications. - * - * @param[in] p_data_received Pointer to the buffer with received data, - * or NULL if the handler is called to prepare - * transmission only. - * @param[out] p_data_to_send Pointer to the buffer where data to be sent - * should be written, or NULL if the handler is - * called for received data only. - * @param[in] number_of_words Length of data received and/or to be written - * (in 32-bit words). This value is always equal to - * half the size of the buffers set by the call - * to the @ref nrf_drv_i2s_start function. - */ -typedef void (* nrf_drv_i2s_data_handler_t)(uint32_t const * p_data_received, - uint32_t * p_data_to_send, - uint16_t number_of_words); - - -/** - * @brief Function for initializing the I2S driver. - * - * @param[in] p_config Pointer to the structure with initial configuration. - * If NULL, the default configuration is used. - * @param[in] handler Data handler provided by the user. Must not be NULL. - * - * @retval NRF_SUCCESS If initialization was successful. - * @retval NRF_ERROR_INVALID_STATE If the driver was already initialized. - * @retval NRF_ERROR_INVALID_PARAM If the requested combination of configuration - * options is not allowed by the I2S peripheral. - */ -ret_code_t nrf_drv_i2s_init(nrf_drv_i2s_config_t const * p_config, - nrf_drv_i2s_data_handler_t handler); - -/** - * @brief Function for uninitializing the I2S driver. - */ -void nrf_drv_i2s_uninit(void); - -/** - * @brief Function for starting the continuous I2S transfer. - * - * The I2S data transfer can be performed in one of three modes: RX (reception) - * only, TX (transmission) only, or in both directions simultaneously. - * The mode is selected by specifying a proper buffer for a given direction - * in the call to this function or by passing NULL instead if this direction - * should be disabled. - * - * The length of the buffer (which is a common value for RX and TX if both - * directions are enabled) is specified in 32-bit words. One 32-bit memory - * word can either contain four 8-bit samples, two 16-bit samples, or one - * right-aligned 24-bit sample sign-extended to a 32-bit value. - * For a detailed memory mapping for different supported configurations, - * see the @linkProductSpecification52. - * - * The provided buffers are logically divided into two parts of equal size. - * One of them is in use by the peripheral (for storing received data or for - * getting data to be transmitted, respectively). The other part is provided - * to the application via a call to the defined @ref nrf_drv_i2s_data_handler_t - * "data handling function", so that the application can process the received - * data or prepare the next portion of data to be sent. The two parts are - * swapped every time @p buffer_size/2 data words are received or transmitted. - * - * Additional options are provided using the @p flags parameter: - * - @ref NRF_DRV_I2S_FLAG_SYNCHRONIZED_MODE - the calls to data handler should - * be done in a synchronized manner (one common call for TX and RX). - * Applicable only when both RX and TX are enabled. - * - * @attention All data exchange is done in the data handler only. In particular, - * no data should be written to the transmit buffer before calling - * this function (a proper call to the data handler to get the first - * portion of data to be sent will be done before the actual transfer - * starts). - * - * @note Peripherals using EasyDMA (like I2S) require the transfer buffers - * to be placed in the Data RAM region. If this condition is not met, - * this function will fail with the error code NRF_ERROR_INVALID_ADDR. - * - * @param[in] p_rx_buffer Pointer to the receive buffer. - * Pass NULL if reception is not required. - * @param[in] p_tx_buffer Pointer to the transmit buffer. - * Pass NULL if transmission is not required. - * @param[in] buffer_size Size of the buffers (in 32-bit words). - * The size must be an even number greater than 0. - * @param[in] flags Transfer options (0 for default settings). - * - * @retval NRF_SUCCESS If the operation was successful. - * @retval NRF_ERROR_INVALID_STATE If a transfer was already started or - * the driver has not been initialized. - * @retval NRF_ERROR_INVALID_ADDR If the provided buffers are not placed - * in the Data RAM region. - */ -ret_code_t nrf_drv_i2s_start(uint32_t * p_rx_buffer, - uint32_t * p_tx_buffer, - uint16_t buffer_size, - uint8_t flags); - -/** - * @brief Function for stopping the I2S transfer. - */ -void nrf_drv_i2s_stop(void); - -#ifdef __cplusplus -} -#endif - -#endif // NRF_DRV_I2S_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/lpcomp/nrf_drv_lpcomp.c ---------------------------------------------------------------------- diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/lpcomp/nrf_drv_lpcomp.c b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/lpcomp/nrf_drv_lpcomp.c deleted file mode 100644 index b1ea6c1..0000000 --- a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/lpcomp/nrf_drv_lpcomp.c +++ /dev/null @@ -1,151 +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_lpcomp.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 LPCOMP_IRQ LPCOMP_IRQn -#define LPCOMP_IRQ_HANDLER LPCOMP_IRQHandler - -static lpcomp_events_handler_t m_lpcomp_events_handler = NULL; -static nrf_drv_state_t m_state = NRF_DRV_STATE_UNINITIALIZED; - -static const nrf_drv_lpcomp_config_t m_default_config = NRF_DRV_LPCONF_DEFAULT_CONFIG; - -#if PERIPHERAL_RESOURCE_SHARING_ENABLED - #define IRQ_HANDLER_NAME irq_handler_for_lpcomp - #define IRQ_HANDLER static void IRQ_HANDLER_NAME(void) - - IRQ_HANDLER; -#else - #define IRQ_HANDLER void LPCOMP_IRQ_HANDLER(void) -#endif // PERIPHERAL_RESOURCE_SHARING_ENABLED - -static void lpcomp_execute_handler(nrf_lpcomp_event_t event, uint32_t event_mask) -{ - if ( nrf_lpcomp_event_check(event) && nrf_lpcomp_int_enable_check(event_mask) ) - { - nrf_lpcomp_event_clear(event); - - m_lpcomp_events_handler(event); - } -} - - -IRQ_HANDLER -{ - lpcomp_execute_handler(NRF_LPCOMP_EVENT_READY, LPCOMP_INTENSET_READY_Msk); - lpcomp_execute_handler(NRF_LPCOMP_EVENT_DOWN, LPCOMP_INTENSET_DOWN_Msk); - lpcomp_execute_handler(NRF_LPCOMP_EVENT_UP, LPCOMP_INTENSET_UP_Msk); - lpcomp_execute_handler(NRF_LPCOMP_EVENT_CROSS, LPCOMP_INTENSET_CROSS_Msk); -} - - -ret_code_t nrf_drv_lpcomp_init(const nrf_drv_lpcomp_config_t * p_config, - lpcomp_events_handler_t events_handler) -{ - if (m_state != NRF_DRV_STATE_UNINITIALIZED) - { // LPCOMP 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_LPCOMP, IRQ_HANDLER_NAME) != NRF_SUCCESS) - { - return NRF_ERROR_BUSY; - } -#endif - - nrf_lpcomp_configure(&(p_config->hal) ); - - if (events_handler) - { - m_lpcomp_events_handler = events_handler; - } - else - { - return NRF_ERROR_INVALID_PARAM; - } - - nrf_lpcomp_input_select(p_config->input); - - switch (p_config->hal.detection) - { - case NRF_LPCOMP_DETECT_UP: - nrf_lpcomp_int_enable(LPCOMP_INTENSET_UP_Msk); - break; - - case NRF_LPCOMP_DETECT_DOWN: - nrf_lpcomp_int_enable(LPCOMP_INTENSET_DOWN_Msk); - break; - - case NRF_LPCOMP_DETECT_CROSS: - nrf_lpcomp_int_enable(LPCOMP_INTENSET_CROSS_Msk); - break; - - default: - break; - } - nrf_lpcomp_shorts_enable(NRF_LPCOMP_SHORT_READY_SAMPLE_MASK); - - nrf_drv_common_irq_enable(LPCOMP_IRQn, p_config->interrupt_priority); - - m_state = NRF_DRV_STATE_INITIALIZED; - - return NRF_SUCCESS; -} - - -void nrf_drv_lpcomp_uninit(void) -{ - ASSERT(m_state != NRF_DRV_STATE_UNINITIALIZED); - nrf_drv_common_irq_disable(LPCOMP_IRQn); - nrf_drv_lpcomp_disable(); - m_state = NRF_DRV_STATE_UNINITIALIZED; - m_lpcomp_events_handler = NULL; -} - -void nrf_drv_lpcomp_enable(void) -{ - ASSERT(m_state == NRF_DRV_STATE_INITIALIZED); - nrf_lpcomp_enable(); - nrf_lpcomp_task_trigger(NRF_LPCOMP_TASK_START); - m_state = NRF_DRV_STATE_POWERED_ON; -} - -void nrf_drv_lpcomp_disable(void) -{ - ASSERT(m_state == NRF_DRV_STATE_POWERED_ON); - nrf_lpcomp_disable(); - nrf_lpcomp_task_trigger(NRF_LPCOMP_TASK_STOP); - m_state = NRF_DRV_STATE_POWERED_ON; -} - -void nrf_drv_lpcomp_event_handler_register(lpcomp_events_handler_t lpcomp_events_handler) -{ - m_lpcomp_events_handler = lpcomp_events_handler; -} - - 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/lpcomp/nrf_drv_lpcomp.h ---------------------------------------------------------------------- diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/lpcomp/nrf_drv_lpcomp.h b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/lpcomp/nrf_drv_lpcomp.h deleted file mode 100644 index eed52d5..0000000 --- a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/lpcomp/nrf_drv_lpcomp.h +++ /dev/null @@ -1,115 +0,0 @@ -/* Copyright (c) 2014 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_LPCOMP_H__ -#define NRF_DRV_LPCOMP_H__ - -#include "nrf_lpcomp.h" -#include "sdk_errors.h" -#include "nrf_drv_common.h" -#include "nrf_drv_config.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup nrf_lpcomp LPCOMP HAL and driver - * @ingroup nrf_drivers - * @brief Low Power Comparator (LPCOMP) APIs. - * @details The LPCOMP HAL provides basic APIs for accessing the registers of Low Power Comparator. - * The LPCOMP driver provides APIs on a higher level. - * - * @defgroup nrf_drivers_lpcomp LPCOMP driver - * @{ - * @ingroup nrf_lpcomp - * @brief Low Power Comparator (LPCOMP) driver. - */ - -/**@brief LPCOMP event handler function type. - * @param[in] event LPCOMP event. - */ -typedef void (* lpcomp_events_handler_t)(nrf_lpcomp_event_t event); - -/**@brief LPCOMP configuration. - */ -typedef struct -{ - nrf_lpcomp_config_t hal; /**< LPCOMP HAL configuration. */ - nrf_lpcomp_input_t input; /**< Input to be monitored. */ - uint8_t interrupt_priority; /**< LPCOMP interrupt priority. */ -} nrf_drv_lpcomp_config_t; - -/** @brief LPCOMP driver default configuration including the LPCOMP HAL configuration. */ -#define NRF_DRV_LPCONF_DEFAULT_CONFIG \ - { \ - .hal = {LPCOMP_CONFIG_REFERENCE , LPCOMP_CONFIG_DETECTION}, \ - .input = LPCOMP_CONFIG_INPUT, \ - .interrupt_priority = LPCOMP_CONFIG_IRQ_PRIORITY \ - } - -/** - * @brief Function for initializing the LPCOMP driver. - * - * This function initializes the LPCOMP driver, but does not enable the peripheral or any interrupts. - * To start the driver, call the function nrf_drv_lpcomp_enable() 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] events_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. - */ -ret_code_t nrf_drv_lpcomp_init(const nrf_drv_lpcomp_config_t * p_config, - lpcomp_events_handler_t events_handler); - - -/** - * @brief Function for uninitializing the LCOMP driver. - * - * This function uninitializes the LPCOMP driver. The LPCOMP peripheral and - * its interrupts are disabled, and local variables are cleaned. After this call, you must - * initialize the driver again by calling nrf_drv_lpcomp_init() if you want to use it. - * - * @sa nrf_drv_lpcomp_disable() - * @sa nrf_drv_lpcomp_init() - */ -void nrf_drv_lpcomp_uninit(void); - -/**@brief Function for enabling the LPCOMP peripheral and interrupts. - * - * Before calling this function, the driver must be initialized. This function - * enables the LPCOMP peripheral and its interrupts. - * - * @sa nrf_drv_lpcomp_disable() - */ -void nrf_drv_lpcomp_enable(void); - -/**@brief Function for disabling the LPCOMP peripheral. - * - * Before calling this function, the driver must be initialized. This function disables the LPCOMP - * peripheral and its interrupts. - * - * @sa nrf_drv_lpcomp_enable() - */ -void nrf_drv_lpcomp_disable(void); - -/** - *@} - **/ - -#ifdef __cplusplus -} -#endif - - #endif /* NRF_DRV_LPCOMP_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/nrf_soc_nosd/nrf_error.h ---------------------------------------------------------------------- diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/nrf_soc_nosd/nrf_error.h b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/nrf_soc_nosd/nrf_error.h deleted file mode 100644 index bff2053..0000000 --- a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/nrf_soc_nosd/nrf_error.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. - * - * The information contained herein is confidential property of Nordic Semiconductor. The use, - * copying, transfer or disclosure of such information is prohibited except by express written - * agreement with Nordic Semiconductor. - * - */ - -/* Header guard */ -#ifndef NRF_ERROR_H__ -#define NRF_ERROR_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/// @cond Make doxygen skip this file - -/** @defgroup NRF_ERRORS_BASE Error Codes Base number definitions - * @{ */ -#define NRF_ERROR_BASE_NUM (0x0) ///< Global error base -#define NRF_ERROR_SDM_BASE_NUM (0x1000) ///< SDM error base -#define NRF_ERROR_SOC_BASE_NUM (0x2000) ///< SoC error base -#define NRF_ERROR_STK_BASE_NUM (0x3000) ///< STK error base -/** @} */ - -#define NRF_SUCCESS (NRF_ERROR_BASE_NUM + 0) ///< Successful command -#define NRF_ERROR_SVC_HANDLER_MISSING (NRF_ERROR_BASE_NUM + 1) ///< SVC handler is missing -#define NRF_ERROR_SOFTDEVICE_NOT_ENABLED (NRF_ERROR_BASE_NUM + 2) ///< SoftDevice has not been enabled -#define NRF_ERROR_INTERNAL (NRF_ERROR_BASE_NUM + 3) ///< Internal Error -#define NRF_ERROR_NO_MEM (NRF_ERROR_BASE_NUM + 4) ///< No Memory for operation -#define NRF_ERROR_NOT_FOUND (NRF_ERROR_BASE_NUM + 5) ///< Not found -#define NRF_ERROR_NOT_SUPPORTED (NRF_ERROR_BASE_NUM + 6) ///< Not supported -#define NRF_ERROR_INVALID_PARAM (NRF_ERROR_BASE_NUM + 7) ///< Invalid Parameter -#define NRF_ERROR_INVALID_STATE (NRF_ERROR_BASE_NUM + 8) ///< Invalid state, operation disallowed in this state -#define NRF_ERROR_INVALID_LENGTH (NRF_ERROR_BASE_NUM + 9) ///< Invalid Length -#define NRF_ERROR_INVALID_FLAGS (NRF_ERROR_BASE_NUM + 10) ///< Invalid Flags -#define NRF_ERROR_INVALID_DATA (NRF_ERROR_BASE_NUM + 11) ///< Invalid Data -#define NRF_ERROR_DATA_SIZE (NRF_ERROR_BASE_NUM + 12) ///< Data size exceeds limit -#define NRF_ERROR_TIMEOUT (NRF_ERROR_BASE_NUM + 13) ///< Operation timed out -#define NRF_ERROR_NULL (NRF_ERROR_BASE_NUM + 14) ///< Null Pointer -#define NRF_ERROR_FORBIDDEN (NRF_ERROR_BASE_NUM + 15) ///< Forbidden Operation -#define NRF_ERROR_INVALID_ADDR (NRF_ERROR_BASE_NUM + 16) ///< Bad Memory Address -#define NRF_ERROR_BUSY (NRF_ERROR_BASE_NUM + 17) ///< Busy - -#ifdef __cplusplus -} -#endif - -#endif // NRF_ERROR_H__ - -/// @endcond -/** - @} -*/ 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/nrf_soc_nosd/nrf_nvic.c ---------------------------------------------------------------------- diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/nrf_soc_nosd/nrf_nvic.c b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/nrf_soc_nosd/nrf_nvic.c deleted file mode 100644 index 3c9657a..0000000 --- a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/nrf_soc_nosd/nrf_nvic.c +++ /dev/null @@ -1,96 +0,0 @@ - /* Copyright (c) 2016 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 <stdlib.h> -#include "nrf_soc.h" -#include "nrf_error.h" - -static uint8_t m_in_critical_region = 0; - -uint32_t sd_nvic_EnableIRQ(IRQn_Type IRQn) -{ - NVIC_EnableIRQ(IRQn); - return NRF_SUCCESS; -} - -uint32_t sd_nvic_DisableIRQ(IRQn_Type IRQn) -{ - NVIC_DisableIRQ(IRQn); - return NRF_SUCCESS; -} - -uint32_t sd_nvic_GetPendingIRQ(IRQn_Type IRQn, uint32_t * p_pending_irq) -{ - if (p_pending_irq != NULL) - { - *p_pending_irq = NVIC_GetPendingIRQ(IRQn); - return NRF_SUCCESS; - } - return NRF_ERROR_NULL; -} - -uint32_t sd_nvic_SetPendingIRQ(IRQn_Type IRQn) -{ - NVIC_SetPendingIRQ(IRQn); - return NRF_SUCCESS; -} - -uint32_t sd_nvic_ClearPendingIRQ(IRQn_Type IRQn) -{ - NVIC_ClearPendingIRQ(IRQn); - return NRF_SUCCESS; -} - -uint32_t sd_nvic_SetPriority(IRQn_Type IRQn, uint32_t priority) -{ - NVIC_SetPriority(IRQn, priority); - return NRF_SUCCESS; -} - -uint32_t sd_nvic_GetPriority(IRQn_Type IRQn, uint32_t * p_priority) -{ - if (p_priority != NULL) - { - *p_priority = NVIC_GetPriority(IRQn); - return NRF_SUCCESS; - } - - return NRF_ERROR_NULL; -} - -uint32_t sd_nvic_SystemReset(void) -{ - NVIC_SystemReset(); - return NRF_SUCCESS; -} - -uint32_t sd_nvic_critical_region_enter(uint8_t * p_is_nested_critical_region) -{ - __disable_irq(); - - *p_is_nested_critical_region = (m_in_critical_region != 0); - m_in_critical_region++; - - return NRF_SUCCESS; -} - -uint32_t sd_nvic_critical_region_exit(uint8_t is_nested_critical_region) -{ - m_in_critical_region--; - - if (is_nested_critical_region == 0) - { - m_in_critical_region = 0; - __enable_irq(); - } - return NRF_SUCCESS; -} 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/nrf_soc_nosd/nrf_nvic.h ---------------------------------------------------------------------- diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/nrf_soc_nosd/nrf_nvic.h b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/nrf_soc_nosd/nrf_nvic.h deleted file mode 100644 index f429d9f..0000000 --- a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/nrf_soc_nosd/nrf_nvic.h +++ /dev/null @@ -1,138 +0,0 @@ -/* Copyright (c) 2014 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_SOC_H__ -#define NRF_SOC_H__ - -#include <stdint.h> -#include "nrf.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/**@brief Enable External Interrupt. - * @note Corresponds to NVIC_EnableIRQ in CMSIS. - * - * @pre{IRQn is valid and not reserved by the stack} - * - * @param[in] IRQn See the NVIC_EnableIRQ documentation in CMSIS. - * - * @retval ::NRF_SUCCESS The interrupt was enabled. - */ -uint32_t sd_nvic_EnableIRQ(IRQn_Type IRQn); - -/**@brief Disable External Interrupt. - * @note Corresponds to NVIC_DisableIRQ in CMSIS. - * - * @pre{IRQn is valid and not reserved by the stack} - * - * @param[in] IRQn See the NVIC_DisableIRQ documentation in CMSIS - * - * @retval ::NRF_SUCCESS The interrupt was disabled. - */ -uint32_t sd_nvic_DisableIRQ(IRQn_Type IRQn); - -/**@brief Get Pending Interrupt. - * @note Corresponds to NVIC_GetPendingIRQ in CMSIS. - * - * @pre{IRQn is valid and not reserved by the stack} - * - * @param[in] IRQn See the NVIC_GetPendingIRQ documentation in CMSIS. - * @param[out] p_pending_irq Return value from NVIC_GetPendingIRQ. - * - * @retval ::NRF_SUCCESS The interrupt is available for the application. - */ -uint32_t sd_nvic_GetPendingIRQ(IRQn_Type IRQn, uint32_t * p_pending_irq); - -/**@brief Set Pending Interrupt. - * @note Corresponds to NVIC_SetPendingIRQ in CMSIS. - * - * @pre{IRQn is valid and not reserved by the stack} - * - * @param[in] IRQn See the NVIC_SetPendingIRQ documentation in CMSIS. - * - * @retval ::NRF_SUCCESS The interrupt is set pending. - */ -uint32_t sd_nvic_SetPendingIRQ(IRQn_Type IRQn); - -/**@brief Clear Pending Interrupt. - * @note Corresponds to NVIC_ClearPendingIRQ in CMSIS. - * - * @pre{IRQn is valid and not reserved by the stack} - * - * @param[in] IRQn See the NVIC_ClearPendingIRQ documentation in CMSIS. - * - * @retval ::NRF_SUCCESS The interrupt pending flag is cleared. - */ -uint32_t sd_nvic_ClearPendingIRQ(IRQn_Type IRQn); - -/**@brief Set Interrupt Priority. - * @note Corresponds to NVIC_SetPriority in CMSIS. - * - * @pre{IRQn is valid and not reserved by the stack} - * @pre{priority is valid and not reserved by the stack} - * - * @param[in] IRQn See the NVIC_SetPriority documentation in CMSIS. - * @param[in] priority A valid IRQ priority for use by the application. - * - * @retval ::NRF_SUCCESS The interrupt and priority level is available for the application. - */ -uint32_t sd_nvic_SetPriority(IRQn_Type IRQn, uint32_t priority); - -/**@brief Get Interrupt Priority. - * @note Corresponds to NVIC_GetPriority in CMSIS. - * - * @pre{IRQn is valid and not reserved by the stack} - * - * @param[in] IRQn See the NVIC_GetPriority documentation in CMSIS. - * @param[out] p_priority Return value from NVIC_GetPriority. - * - * @retval ::NRF_SUCCESS The interrupt priority is returned in p_priority. - */ -uint32_t sd_nvic_GetPriority(IRQn_Type IRQn, uint32_t * p_priority); - -/**@brief System Reset. - * @note Corresponds to NVIC_SystemReset in CMSIS. - * - * @retval ::NRF_ERROR_SOC_NVIC_SHOULD_NOT_RETURN - */ -uint32_t sd_nvic_SystemReset(void); - -/**@brief Enters critical region. - * - * @post Application interrupts will be disabled. - * @sa sd_nvic_critical_region_exit - * - * @param[out] p_is_nested_critical_region 1: If in a nested critical region. - * 0: Otherwise. - * - * @retval ::NRF_SUCCESS - */ -uint32_t sd_nvic_critical_region_enter(uint8_t * p_is_nested_critical_region); - -/**@brief Exit critical region. - * - * @pre Application has entered a critical region using ::sd_nvic_critical_region_enter. - * @post If not in a nested critical region, the application interrupts will restored to the state before ::sd_nvic_critical_region_enter was called. - * - * @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. - * - * @retval ::NRF_SUCCESS - */ -uint32_t sd_nvic_critical_region_exit(uint8_t is_nested_critical_region); - -#ifdef __cplusplus -} -#endif - -#endif /* NRF_SOC_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/nrf_soc_nosd/nrf_soc.c ---------------------------------------------------------------------- diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/nrf_soc_nosd/nrf_soc.c b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/nrf_soc_nosd/nrf_soc.c deleted file mode 100644 index 063b7b9..0000000 --- a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/nrf_soc_nosd/nrf_soc.c +++ /dev/null @@ -1,21 +0,0 @@ - /* Copyright (c) 2014 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 <stdlib.h> -#include "nrf_soc.h" -#include "nrf_error.h" - -uint32_t sd_app_evt_wait(void) -{ - __WFE(); - return NRF_SUCCESS; -} 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/nrf_soc_nosd/nrf_soc.h ---------------------------------------------------------------------- diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/nrf_soc_nosd/nrf_soc.h b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/nrf_soc_nosd/nrf_soc.h deleted file mode 100644 index b64326d..0000000 --- a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/nrf_soc_nosd/nrf_soc.h +++ /dev/null @@ -1,52 +0,0 @@ -/* Copyright (c) 2014 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_SOC_H__ -#define NRF_SOC_H__ - -#include <stdint.h> -#include "nrf.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/**@brief Waits for an application event. - * - * An application event is either an application interrupt or a pended interrupt when the - * interrupt is disabled. When the interrupt is enabled it will be taken immediately since - * this function will wait in thread mode, then the execution will return in the application's - * main thread. When an interrupt is disabled and gets pended it will return to the application's - * thread main. The application must ensure that the pended flag is cleared using - * ::sd_nvic_ClearPendingIRQ in order to sleep using this function. This is only necessary for - * disabled interrupts, as the interrupt handler will clear the pending flag automatically for - * enabled interrupts. - * - * In order to wake up from disabled interrupts, the SEVONPEND flag has to be set in the Cortex-M0 - * System Control Register (SCR). @sa CMSIS_SCB - * - * @note If an application interrupt has happened since the last time sd_app_evt_wait was - * called this function will return immediately and not go to sleep. This is to avoid race - * conditions that can occur when a flag is updated in the interrupt handler and processed - * in the main loop. - * - * @post An application interrupt has happened or a interrupt pending flag is set. - * - * @retval ::NRF_SUCCESS - */ -uint32_t sd_app_evt_wait(void); - -#ifdef __cplusplus -} -#endif - -#endif /* NRF_SOC_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/pdm/nrf_drv_pdm.c ---------------------------------------------------------------------- diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/pdm/nrf_drv_pdm.c b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/pdm/nrf_drv_pdm.c deleted file mode 100644 index 71b7a7a..0000000 --- a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/pdm/nrf_drv_pdm.c +++ /dev/null @@ -1,170 +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_pdm.h" -#include "nrf_assert.h" -#include "nrf_drv_common.h" -#include "nrf_gpio.h" - - -/** @brief PDM interface status. */ -typedef enum -{ - NRF_PDM_STATE_IDLE, - NRF_PDM_STATE_RUNNING, - NRF_PDM_STATE_TRANSITION -} nrf_drv_pdm_state_t; - - -/** @brief PDM interface control block.*/ -typedef struct -{ - nrf_drv_state_t drv_state; ///< Driver state. - nrf_drv_pdm_state_t status; ///< Sampling state. - nrf_drv_pdm_event_handler_t event_handler; ///< Event handler function pointer. - uint16_t buffer_length; ///< Length of a single buffer in 16-bit words. - uint32_t * buffers[2]; ///< Sample buffers. -} nrf_drv_pdm_cb_t; - -static nrf_drv_pdm_cb_t m_cb; - - -void PDM_IRQHandler(void) -{ - if (nrf_pdm_event_check(NRF_PDM_EVENT_END)) - { - nrf_pdm_event_clear(NRF_PDM_EVENT_END); - - //Buffer is ready to process. - if (nrf_pdm_buffer_get() == m_cb.buffers[0]) - { - m_cb.event_handler(m_cb.buffers[1], m_cb.buffer_length); - } - else - { - m_cb.event_handler(m_cb.buffers[0], m_cb.buffer_length); - } - } - else if (nrf_pdm_event_check(NRF_PDM_EVENT_STARTED)) - { - nrf_pdm_event_clear(NRF_PDM_EVENT_STARTED); - m_cb.status = NRF_PDM_STATE_RUNNING; - - //Swap buffer. - if (nrf_pdm_buffer_get() == m_cb.buffers[0]) - { - nrf_pdm_buffer_set(m_cb.buffers[1],m_cb.buffer_length); - } - else - { - nrf_pdm_buffer_set(m_cb.buffers[0],m_cb.buffer_length); - } - } - else if (nrf_pdm_event_check(NRF_PDM_EVENT_STOPPED)) - { - nrf_pdm_event_clear(NRF_PDM_EVENT_STOPPED); - nrf_pdm_disable(); - m_cb.status = NRF_PDM_STATE_IDLE; - } -} - - -ret_code_t nrf_drv_pdm_init(nrf_drv_pdm_config_t const * p_config, - nrf_drv_pdm_event_handler_t event_handler) -{ - if (m_cb.drv_state != NRF_DRV_STATE_UNINITIALIZED) - { - return NRF_ERROR_INVALID_STATE; - } - if ((p_config == NULL) - || (event_handler == NULL)) - { - return NRF_ERROR_INVALID_PARAM; - } - if (p_config->gain_l > NRF_PDM_GAIN_MAXIMUM - || p_config->gain_r > NRF_PDM_GAIN_MAXIMUM - || p_config->buffer_length > NRF_PDM_MAX_BUFFER_SIZE) - { - return NRF_ERROR_INVALID_PARAM; - } - - m_cb.buffers[0] = (uint32_t*)p_config->buffer_a; - m_cb.buffers[1] = (uint32_t*)p_config->buffer_b; - m_cb.buffer_length = p_config->buffer_length; - m_cb.event_handler = event_handler; - m_cb.status = NRF_PDM_STATE_IDLE; - - nrf_pdm_buffer_set(m_cb.buffers[0],m_cb.buffer_length); - nrf_pdm_clock_set(p_config->clock_freq); - nrf_pdm_mode_set(p_config->mode, p_config->edge); - nrf_pdm_gain_set(p_config->gain_l, p_config->gain_r); - - nrf_gpio_cfg_output(p_config->pin_clk); - nrf_gpio_pin_clear(p_config->pin_clk); - nrf_gpio_cfg_input(p_config->pin_din, NRF_GPIO_PIN_NOPULL); - nrf_pdm_psel_connect(p_config->pin_clk, p_config->pin_din); - - m_cb.drv_state = NRF_DRV_STATE_INITIALIZED; - nrf_pdm_int_enable(NRF_PDM_INT_STARTED | NRF_PDM_INT_END | NRF_PDM_INT_STOPPED); - nrf_drv_common_irq_enable(PDM_IRQn, p_config->interrupt_priority); - - return NRF_SUCCESS; -} - - -void nrf_drv_pdm_uninit(void) -{ - nrf_pdm_disable(); - nrf_pdm_psel_disconnect(); - m_cb.drv_state = NRF_DRV_STATE_UNINITIALIZED; -} - - - - -ret_code_t nrf_drv_pdm_start(void) -{ - ASSERT(m_cb.drv_state != NRF_DRV_STATE_UNINITIALIZED); - if (m_cb.status != NRF_PDM_STATE_IDLE) - { - if (m_cb.status == NRF_PDM_STATE_RUNNING) - { - return NRF_SUCCESS; - } - return NRF_ERROR_BUSY; - } - m_cb.status = NRF_PDM_STATE_TRANSITION; - m_cb.drv_state = NRF_DRV_STATE_POWERED_ON; - nrf_pdm_enable(); - nrf_pdm_event_clear(NRF_PDM_EVENT_STARTED); - nrf_pdm_task_trigger(NRF_PDM_TASK_START); - return NRF_SUCCESS; -} - - -ret_code_t nrf_drv_pdm_stop(void) -{ - ASSERT(m_cb.drv_state != NRF_DRV_STATE_UNINITIALIZED); - if (m_cb.status != NRF_PDM_STATE_RUNNING) - { - if (m_cb.status == NRF_PDM_STATE_IDLE) - { - nrf_pdm_disable(); - return NRF_SUCCESS; - } - return NRF_ERROR_BUSY; - } - m_cb.status = NRF_PDM_STATE_TRANSITION; - m_cb.drv_state = NRF_DRV_STATE_INITIALIZED; - nrf_pdm_task_trigger(NRF_PDM_TASK_STOP); - return NRF_SUCCESS; -} 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/pdm/nrf_drv_pdm.h ---------------------------------------------------------------------- diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/pdm/nrf_drv_pdm.h b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/pdm/nrf_drv_pdm.h deleted file mode 100644 index 623785e..0000000 --- a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/pdm/nrf_drv_pdm.h +++ /dev/null @@ -1,175 +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. - * - */ - -/** - * @addtogroup nrf_pdm PDM HAL and driver - * @ingroup nrf_drivers - * @brief @tagAPI52 Pulse density modulation (PDM) interface APIs. - * - * The PDM HAL provides basic APIs for accessing the registers of the PDM interface peripheral. - * The PDM driver provides APIs on a higher level. - * - * @defgroup nrf_drv_pdm PDM driver - * @{ - * @ingroup nrf_pdm - * - * @brief @tagAPI52 Pulse density modulation (PDM) interface driver. - */ - - -#ifndef NRF_DRV_PDM_H__ -#define NRF_DRV_PDM_H__ - -#include "nrf_drv_config.h" -#include "nrf_pdm.h" -#include "sdk_errors.h" - - -#ifdef __cplusplus -extern "C" { -#endif - -#define NRF_PDM_MAX_BUFFER_SIZE 32768 - - -/** - * @brief PDM interface driver configuration structure. - */ -typedef struct -{ - nrf_pdm_mode_t mode; ///< Interface operation mode. - nrf_pdm_edge_t edge; ///< Sampling mode. - uint8_t pin_clk; ///< CLK pin. - uint8_t pin_din; ///< DIN pin. - nrf_pdm_freq_t clock_freq; ///< Clock frequency. - nrf_pdm_gain_t gain_l; ///< Left channel gain. - nrf_pdm_gain_t gain_r; ///< Right channel gain. - uint8_t interrupt_priority; ///< Interrupt priority. - uint16_t buffer_length; ///< Length of a single buffer (in 16-bit words). - int16_t * buffer_a; ///< Sample buffer A (filled first). - int16_t * buffer_b; ///< Sample buffer B (filled after buffer A). -} nrf_drv_pdm_config_t; - - -/** - * @brief Macro for setting @ref nrf_drv_pdm_config_t to default settings - * in single ended mode. - * - * @param PIN_CLK CLK output pin. - * @param PIN_DIN DIN input pin. - * @param BUFF_A Sample buffer A (filled first). - * @param BUFF_B Sample buffer B (filled after buffer A). - * @param BUFF_LEN Length of a single buffer (in 16-bit words). - */ -#define NRF_DRV_PDM_DEFAULT_CONFIG(PIN_CLK, PIN_DIN, BUFF_A, BUFF_B, BUFF_LEN) \ -{ \ - .mode = PDM_CONFIG_MODE, \ - .edge = PDM_CONFIG_EDGE, \ - .pin_clk = PIN_CLK, \ - .pin_din = PIN_DIN, \ - .clock_freq = PDM_CONFIG_CLOCK_FREQ, \ - .gain_l = NRF_PDM_GAIN_DEFAULT, \ - .gain_r = NRF_PDM_GAIN_DEFAULT, \ - .interrupt_priority = PDM_CONFIG_IRQ_PRIORITY, \ - .buffer_length = BUFF_LEN, \ - .buffer_a = BUFF_A, \ - .buffer_b = BUFF_B \ -} - - -/** - * @brief Handler for PDM interface ready events. - * - * This event handler is called when a buffer is full and ready to be processed. - * - * @param[in] p_buffer Sample buffer pointer. - * @param[in] length Buffer length in 16-bit words. - */ -typedef void (*nrf_drv_pdm_event_handler_t)(uint32_t * buffer, uint16_t length); - - -/** - * @brief Function for initializing the PDM interface. - * - * @param[in] p_config Pointer to a configuration structure. If NULL, the default one is used. - * @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. - * @retval NRF_ERROR_INVALID_PARAM If invalid parameters were specified. - */ -ret_code_t nrf_drv_pdm_init(nrf_drv_pdm_config_t const * p_config, - nrf_drv_pdm_event_handler_t event_handler); - - -/** - * @brief Function for uninitializing the PDM interface. - * - * This function stops PDM sampling, if it is in progress. - */ -void nrf_drv_pdm_uninit(void); - - -/** - * @brief Function for getting the address of a PDM interface task. - * - * @param[in] task Task. - * - * @return Task address. - */ -__STATIC_INLINE uint32_t nrf_drv_pdm_task_address_get(nrf_pdm_task_t task) -{ - return nrf_pdm_task_address_get(task); -} - - -/** - * @brief Function for getting the state of the PDM interface. - * - * @retval TRUE If the PDM interface is enabled. - * @retval FALSE If the PDM interface is disabled. - */ -__STATIC_INLINE bool nrf_drv_pdm_enable_check() -{ - return nrf_pdm_enable_check(); -} - - -/** - * @brief Function for starting PDM sampling. - * - * @retval NRF_SUCCESS If sampling was started successfully or was already in progress. - * @retval NRF_ERROR_BUSY If a previous start/stop operation is in progress. - */ -ret_code_t nrf_drv_pdm_start(void); - - -/** - * @brief Function for stopping PDM sampling. - * - * When this function is called, the PDM interface is stopped after finishing - * the current frame. - * The event handler function might be called once more after calling this function. - * - * @retval NRF_SUCCESS If sampling was stopped successfully or was already stopped before. - * @retval NRF_ERROR_BUSY If a previous start/stop operation is in progress. - */ -ret_code_t nrf_drv_pdm_stop(void); - - -#ifdef __cplusplus -} -#endif - -#endif // NRF_DRV_PDM_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/ppi/nrf_drv_ppi.c ---------------------------------------------------------------------- diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/ppi/nrf_drv_ppi.c b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/ppi/nrf_drv_ppi.c deleted file mode 100644 index 706824d..0000000 --- a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/ppi/nrf_drv_ppi.c +++ /dev/null @@ -1,427 +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 <stdlib.h> - -#include "nrf.h" -#include "nrf_drv_ppi.h" -#include "nrf_drv_common.h" -#include "nrf_ppi.h" -#include "app_util_platform.h" -#include "sdk_common.h" - - -static nrf_drv_state_t m_drv_state; /**< Driver state */ -static uint32_t m_channels_allocated; /**< Bitmap representing channels availability. 1 when a channel is allocated, 0 otherwise. */ -static uint8_t m_groups_allocated; /**< Bitmap representing groups availability. 1 when a group is allocated, 0 otherwise.*/ - - -/**@brief Compute a group mask (needed for driver internals, not used for NRF_PPI registers). - * @param[in] group Group number to transform to a mask. - * @retval Group mask. - */ -__STATIC_INLINE uint32_t group_to_mask(nrf_ppi_channel_group_t group) -{ - return (1uL << (uint32_t) group); -} - - -/**@brief Check whether a channel is a programmable channel and can be used by an application. - * @param[in] channel Channel to check. - * @retval true The channel is a programmable application channel. - * false The channel is used by a SoftDevice or is preprogrammed. - */ -__STATIC_INLINE bool is_programmable_app_channel(nrf_ppi_channel_t channel) -{ - return ((NRF_PPI_PROG_APP_CHANNELS_MASK & nrf_drv_ppi_channel_to_mask(channel)) != 0); -} - - -/**@brief Check whether a channels can be used by an application. - * @param[in] channel Channel mask to check. - * @retval true All specified channels can be used by an application. - * false At least one specified channel is used by a SoftDevice. - */ -__STATIC_INLINE bool are_app_channels(uint32_t channel_mask) -{ - //lint -e(587) - return ((~(NRF_PPI_ALL_APP_CHANNELS_MASK) & channel_mask) == 0); -} - - -/**@brief Check whether a channel can be used by an application. - * @param[in] channel Channel to check. - * @retval true The channel can be used by an application. - * false The channel is used by a SoftDevice. - */ -__STATIC_INLINE bool is_app_channel(nrf_ppi_channel_t channel) -{ - return are_app_channels(nrf_drv_ppi_channel_to_mask(channel)); -} - - -/**@brief Check whether a channel group can be used by an application. - * @param[in] group Group to check. - * @retval true The group is an application group. - * false The group is not an application group (this group either does not exist or - * it is used by a SoftDevice). - */ -__STATIC_INLINE bool is_app_group(nrf_ppi_channel_group_t group) -{ - return ((NRF_PPI_ALL_APP_GROUPS_MASK & group_to_mask(group)) != 0); -} - - -/**@brief Check whether a channel is allocated. - * @param[in] channel_num Channel number to check. - * @retval true The channel is allocated. - * false The channel is not allocated. - */ -__STATIC_INLINE bool is_allocated_channel(nrf_ppi_channel_t channel) -{ - return ((m_channels_allocated & nrf_drv_ppi_channel_to_mask(channel)) != 0); -} - - -/**@brief Set channel allocated indication. - * @param[in] channel_num Specifies the channel to set the "allocated" indication. - */ -__STATIC_INLINE void channel_allocated_set(nrf_ppi_channel_t channel) -{ - m_channels_allocated |= nrf_drv_ppi_channel_to_mask(channel); -} - - -/**@brief Clear channel allocated indication. - * @param[in] channel_num Specifies the channel to clear the "allocated" indication. - */ -__STATIC_INLINE void channel_allocated_clr(nrf_ppi_channel_t channel) -{ - m_channels_allocated &= ~nrf_drv_ppi_channel_to_mask(channel); -} - - -/**@brief Clear all allocated channels. - */ -__STATIC_INLINE void channel_allocated_clr_all(void) -{ - m_channels_allocated &= ~NRF_PPI_ALL_APP_CHANNELS_MASK; -} - - -/**@brief Check whether a group is allocated. - * @param[in] group_num Group number to check. - * @retval true The group is allocated. - * false The group is not allocated. - */ -__STATIC_INLINE bool is_allocated_group(nrf_ppi_channel_group_t group) -{ - return ((m_groups_allocated & group_to_mask(group)) != 0); -} - - -/**@brief Set group allocated indication. - * @param[in] group_num Specifies the group to set the "allocated" indication. - */ -__STATIC_INLINE void group_allocated_set(nrf_ppi_channel_group_t group) -{ - m_groups_allocated |= group_to_mask(group); -} - - -/**@brief Clear group allocated indication. - * @param[in] group_num Specifies the group to clear the "allocated" indication. - */ -__STATIC_INLINE void group_allocated_clr(nrf_ppi_channel_group_t group) -{ - m_groups_allocated &= ~group_to_mask(group); -} - - -/**@brief Clear all allocated groups. - */ -__STATIC_INLINE void group_allocated_clr_all() -{ - m_groups_allocated &= ~NRF_PPI_ALL_APP_GROUPS_MASK; -} - - -uint32_t nrf_drv_ppi_init(void) -{ - uint32_t err_code; - - if (m_drv_state == NRF_DRV_STATE_UNINITIALIZED) - { - m_drv_state = NRF_DRV_STATE_INITIALIZED; - err_code = NRF_SUCCESS; - } - else - { - err_code = MODULE_ALREADY_INITIALIZED; - } - - return err_code; -} - - -uint32_t nrf_drv_ppi_uninit(void) -{ - uint32_t mask = NRF_PPI_ALL_APP_GROUPS_MASK; - nrf_ppi_channel_group_t group; - - if (m_drv_state == NRF_DRV_STATE_UNINITIALIZED) - { - return NRF_ERROR_INVALID_STATE; - } - - m_drv_state = NRF_DRV_STATE_UNINITIALIZED; - - // Disable all channels and groups - nrf_ppi_channels_disable(NRF_PPI_ALL_APP_CHANNELS_MASK); - - for (group = NRF_PPI_CHANNEL_GROUP0; mask != 0; mask &= ~group_to_mask(group), group++) - { - if(mask & group_to_mask(group)) - { - nrf_ppi_channel_group_clear(group); - } - } - channel_allocated_clr_all(); - group_allocated_clr_all(); - return NRF_SUCCESS; -} - - -uint32_t nrf_drv_ppi_channel_alloc(nrf_ppi_channel_t * p_channel) -{ - uint32_t err_code; - nrf_ppi_channel_t channel; - uint32_t mask = 0; - - err_code = NRF_ERROR_NO_MEM; - - mask = NRF_PPI_PROG_APP_CHANNELS_MASK; - for (channel = NRF_PPI_CHANNEL0; mask != 0; mask &= ~nrf_drv_ppi_channel_to_mask(channel), channel++) - { - CRITICAL_REGION_ENTER(); - if ((mask & nrf_drv_ppi_channel_to_mask(channel)) && (!is_allocated_channel(channel))) - { - channel_allocated_set(channel); - *p_channel = channel; - err_code = NRF_SUCCESS; - } - CRITICAL_REGION_EXIT(); - if (err_code == NRF_SUCCESS) - { - break; - } - } - - return err_code; -} - - -uint32_t nrf_drv_ppi_channel_free(nrf_ppi_channel_t channel) -{ - if (!is_programmable_app_channel(channel)) - { - return NRF_ERROR_INVALID_PARAM; - } - // First disable this channel - nrf_ppi_channel_disable(channel); - CRITICAL_REGION_ENTER(); - channel_allocated_clr(channel); - CRITICAL_REGION_EXIT(); - return NRF_SUCCESS; -} - - -uint32_t nrf_drv_ppi_channel_assign(nrf_ppi_channel_t channel, uint32_t eep, uint32_t tep) -{ - VERIFY_PARAM_NOT_NULL((uint32_t *)eep); - VERIFY_PARAM_NOT_NULL((uint32_t *)tep); - - if (!is_programmable_app_channel(channel)) - { - return NRF_ERROR_INVALID_PARAM; - } - if (!is_allocated_channel(channel)) - { - return NRF_ERROR_INVALID_STATE; - } - - nrf_ppi_channel_endpoint_setup(channel, eep, tep); - return NRF_SUCCESS; -} - -uint32_t nrf_drv_ppi_channel_fork_assign(nrf_ppi_channel_t channel, uint32_t fork_tep) -{ -#ifdef NRF51 - return NRF_ERROR_NOT_SUPPORTED; -#else - if (!is_programmable_app_channel(channel)) - { - return NRF_ERROR_INVALID_PARAM; - } - if (!is_allocated_channel(channel)) - { - return NRF_ERROR_INVALID_STATE; - } - nrf_ppi_fork_endpoint_setup(channel, fork_tep); - return NRF_SUCCESS; -#endif -} - -uint32_t nrf_drv_ppi_channel_enable(nrf_ppi_channel_t channel) -{ - if (!is_app_channel(channel)) - { - return NRF_ERROR_INVALID_PARAM; - } - if (is_programmable_app_channel(channel) && !is_allocated_channel(channel)) - { - return NRF_ERROR_INVALID_STATE; - } - nrf_ppi_channel_enable(channel); - return NRF_SUCCESS; -} - - -uint32_t nrf_drv_ppi_channel_disable(nrf_ppi_channel_t channel) -{ - if (!is_app_channel(channel)) - { - return NRF_ERROR_INVALID_PARAM; - } - if (is_programmable_app_channel(channel) && !is_allocated_channel(channel)) - { - return NRF_ERROR_INVALID_STATE; - } - nrf_ppi_channel_disable(channel); - return NRF_SUCCESS; -} - - -uint32_t nrf_drv_ppi_group_alloc(nrf_ppi_channel_group_t * p_group) -{ - uint32_t err_code; - uint32_t mask = 0; - nrf_ppi_channel_group_t group; - - err_code = NRF_ERROR_NO_MEM; - - mask = NRF_PPI_ALL_APP_GROUPS_MASK; - for (group = NRF_PPI_CHANNEL_GROUP0; mask != 0; mask &= ~group_to_mask(group), group++) - { - CRITICAL_REGION_ENTER(); - if ((mask & group_to_mask(group)) && (!is_allocated_group(group))) - { - group_allocated_set(group); - *p_group = group; - err_code = NRF_SUCCESS; - } - CRITICAL_REGION_EXIT(); - if (err_code == NRF_SUCCESS) - { - break; - } - } - - return err_code; -} - - -uint32_t nrf_drv_ppi_group_free(nrf_ppi_channel_group_t group) -{ - if (!is_app_group(group)) - { - return NRF_ERROR_INVALID_PARAM; - } - if (!is_allocated_group(group)) - { - return NRF_ERROR_INVALID_STATE; - } - else - nrf_ppi_group_disable(group); - CRITICAL_REGION_ENTER(); - group_allocated_clr(group); - CRITICAL_REGION_EXIT(); - return NRF_SUCCESS; -} - - -uint32_t nrf_drv_ppi_group_enable(nrf_ppi_channel_group_t group) -{ - if (!is_app_group(group)) - { - return NRF_ERROR_INVALID_PARAM; - } - if (!is_allocated_group(group)) - { - return NRF_ERROR_INVALID_STATE; - } - nrf_ppi_group_enable(group); - return NRF_SUCCESS; -} - - -uint32_t nrf_drv_ppi_group_disable(nrf_ppi_channel_group_t group) -{ - if (!is_app_group(group)) - { - return NRF_ERROR_INVALID_PARAM; - } - nrf_ppi_group_disable(group); - return NRF_SUCCESS; -} - -uint32_t nrf_drv_ppi_channels_remove_from_group(uint32_t channel_mask, - nrf_ppi_channel_group_t group) -{ - if (!is_app_group(group)) - { - return NRF_ERROR_INVALID_PARAM; - } - if (!is_allocated_group(group)) - { - return NRF_ERROR_INVALID_STATE; - } - if (!are_app_channels(channel_mask)) - { - return NRF_ERROR_INVALID_PARAM; - } - CRITICAL_REGION_ENTER(); - nrf_ppi_channels_remove_from_group(channel_mask, group); - CRITICAL_REGION_EXIT(); - return NRF_SUCCESS; -} - -uint32_t nrf_drv_ppi_channels_include_in_group(uint32_t channel_mask, - nrf_ppi_channel_group_t group) -{ - if (!is_app_group(group)) - { - return NRF_ERROR_INVALID_PARAM; - } - if (!is_allocated_group(group)) - { - return NRF_ERROR_INVALID_STATE; - } - if (!are_app_channels(channel_mask)) - { - return NRF_ERROR_INVALID_PARAM; - } - CRITICAL_REGION_ENTER(); - nrf_ppi_channels_include_in_group(channel_mask, group); - CRITICAL_REGION_EXIT(); - return NRF_SUCCESS; -} 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/ppi/nrf_drv_ppi.h ---------------------------------------------------------------------- diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/ppi/nrf_drv_ppi.h b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/ppi/nrf_drv_ppi.h deleted file mode 100644 index 27cea57..0000000 --- a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/ppi/nrf_drv_ppi.h +++ /dev/null @@ -1,292 +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_PPI_H -#define NRF_DRV_PPI_H - -#ifdef __cplusplus -extern "C" { -#endif - -/*lint ++flb "Enter library region" */ -#include "sdk_errors.h" -#include "nrf_ppi.h" -#include <stdbool.h> -#include <stdint.h> - -/** @file - * - * @addtogroup nrf_ppi PPI HAL and driver - * @ingroup nrf_drivers - * @brief Programmable Peripheral Interconnect (PPI) APIs. - * - * @details The PPI HAL provides basic APIs for accessing the registers of the PPI. - * The PPI driver provides APIs on a higher level. - * - * @defgroup lib_driver_ppi PPI driver - * @{ - * @ingroup nrf_ppi - * - * @brief Programmable Peripheral Interconnect (PPI) driver. - */ - -#include "sdk_resources.h" - -#ifdef NRF52 - - #define NRF_PPI_ALL_APP_CHANNELS_MASK ((uint32_t)0xFFFFFFFFuL & ~(NRF_PPI_CHANNELS_USED)) /**< All PPI channels available to the application. */ - #define NRF_PPI_PROG_APP_CHANNELS_MASK ((uint32_t)0x000FFFFFuL & ~(NRF_PPI_CHANNELS_USED)) /**< Programmable PPI channels available to the application. */ - #define NRF_PPI_ALL_APP_GROUPS_MASK ((uint32_t)0x0000003FuL & ~(NRF_PPI_GROUPS_USED)) /**< All PPI groups available to the application. */ - -#else - - #define NRF_PPI_ALL_APP_CHANNELS_MASK ((uint32_t)0xFFF0FFFFuL & ~(NRF_PPI_CHANNELS_USED)) /**< All PPI channels available to the application. */ - #define NRF_PPI_PROG_APP_CHANNELS_MASK ((uint32_t)0x0000FFFFuL & ~(NRF_PPI_CHANNELS_USED)) /**< Programmable PPI channels available to the application. */ - #define NRF_PPI_ALL_APP_GROUPS_MASK ((uint32_t)0x0000000FuL & ~(NRF_PPI_GROUPS_USED)) /**< All PPI groups available to the application. */ - -#endif - - -/**@brief Function for initializing PPI module. - * - * @retval NRF_SUCCESS If the module was successfully initialized. - * @retval MODULE_ALREADY_INITIALIZED If the module has already been initialized. - */ -uint32_t nrf_drv_ppi_init(void); - -/**@brief Function for uninitializing the PPI module. - * - * This function also disables all channels and clears the channel groups. - * - * @retval NRF_SUCCESS If the module was successfully uninitialized. - * @retval NRF_ERROR_INVALID_STATE If the module has not been initialized yet. - * @retval NRF_ERROR_INTERNAL If the channels or groups could not be disabled. - */ -uint32_t nrf_drv_ppi_uninit(void); - -/**@brief Function for allocating a PPI channel. - * @details This function allocates the first unused PPI channel. - * - * @param[out] p_channel Pointer to the PPI channel that has been allocated. - * - * @retval NRF_SUCCESS If the channel was successfully allocated. - * @retval NRF_ERROR_NO_MEM If there is no available channel to be used. - */ -uint32_t nrf_drv_ppi_channel_alloc(nrf_ppi_channel_t * p_channel); - -/**@brief Function for freeing a PPI channel. - * @details This function also disables the chosen channel. - * - * @param[in] channel PPI channel to be freed. - * - * @retval NRF_SUCCESS If the channel was successfully freed. - * @retval NRF_ERROR_INVALID_PARAM If the channel is not user-configurable. - */ -uint32_t nrf_drv_ppi_channel_free(nrf_ppi_channel_t channel); - -/**@brief Function for assigning task and event endpoints to the PPI channel. - * - * @param[in] channel PPI channel to be assigned endpoints. - * - * @param[in] eep Event endpoint address. - * - * @param[in] tep Task endpoint address. - * - * @retval NRF_SUCCESS If the channel was successfully assigned. - * @retval NRF_ERROR_INVALID_STATE If the channel is not allocated for the user. - * @retval NRF_ERROR_INVALID_PARAM If the channel is not user-configurable. - */ -uint32_t nrf_drv_ppi_channel_assign(nrf_ppi_channel_t channel, uint32_t eep, uint32_t tep); - -/**@brief Function for assigning or clearing fork endpoint to the PPI channel. - * - * @param[in] channel PPI channel to be assigned endpoints. - * - * @param[in] fork_tep Fork task endpoint address or 0 to clear. - * - * @retval NRF_SUCCESS If the channel was successfully assigned. - * @retval NRF_ERROR_INVALID_STATE If the channel is not allocated for the user. - * @retval NRF_ERROR_INVALID_PARAM If the channel is not user-configurable. - * @retval NRF_ERROR_NOT_SUPPORTED If function is not supported. - */ -uint32_t nrf_drv_ppi_channel_fork_assign(nrf_ppi_channel_t channel, uint32_t fork_tep); - -/**@brief Function for enabling a PPI channel. - * - * @param[in] channel PPI channel to be enabled. - * - * @retval NRF_SUCCESS If the channel was successfully enabled. - * @retval NRF_ERROR_INVALID_STATE If the user-configurable channel is not allocated. - * @retval NRF_ERROR_INVALID_PARAM If the channel cannot be enabled by the user. - */ -uint32_t nrf_drv_ppi_channel_enable(nrf_ppi_channel_t channel); - -/**@brief Function for disabling a PPI channel. - * - * @param[in] channel PPI channel to be disabled. - * - * @retval NRF_SUCCESS If the channel was successfully disabled. - * @retval NRF_ERROR_INVALID_STATE If the user-configurable channel is not allocated. - * @retval NRF_ERROR_INVALID_PARAM If the channel cannot be disabled by the user. - */ -uint32_t nrf_drv_ppi_channel_disable(nrf_ppi_channel_t channel); - -/**@brief Function for allocating a PPI channel group. - * @details This function allocates the first unused PPI group. - * - * @param[out] p_group Pointer to the PPI channel group that has been allocated. - * - * @retval NRF_SUCCESS If the channel group was successfully allocated. - * @retval NRF_ERROR_NO_MEM If there is no available channel group to be used. - */ -uint32_t nrf_drv_ppi_group_alloc(nrf_ppi_channel_group_t * p_group); - -/**@brief Function for freeing a PPI channel group. - * @details This function also disables the chosen group. - * - * @param[in] group PPI channel group to be freed. - * - * @retval NRF_SUCCESS If the channel group was successfully freed. - * @retval NRF_ERROR_INVALID_PARAM If the channel group is not user-configurable. - */ -uint32_t nrf_drv_ppi_group_free(nrf_ppi_channel_group_t group); - -/**@brief Compute a channel mask for NRF_PPI registers. - * - * @param[in] channel Channel number to transform to a mask. - * - * @retval Channel mask. - */ -__STATIC_INLINE uint32_t nrf_drv_ppi_channel_to_mask(nrf_ppi_channel_t channel) -{ - return (1uL << (uint32_t) channel); -} - -/**@brief Function for including multiple PPI channels in a channel group. - * - * @param[in] channel_mask PPI channels to be added. - * @param[in] group Channel group in which to include the channels. - * - * @retval NRF_SUCCESS If the channels was successfully included. - */ -uint32_t nrf_drv_ppi_channels_include_in_group(uint32_t channel_mask, - nrf_ppi_channel_group_t group); - -/**@brief Function for including a PPI channel in a channel group. - * - * @param[in] channel PPI channel to be added. - * @param[in] group Channel group in which to include the channel. - * - * @retval NRF_SUCCESS If the channel was successfully included. - */ -__STATIC_INLINE uint32_t nrf_drv_ppi_channel_include_in_group(nrf_ppi_channel_t channel, - nrf_ppi_channel_group_t group) -{ - return nrf_drv_ppi_channels_include_in_group(nrf_drv_ppi_channel_to_mask(channel), group); -} - -/**@brief Function for removing multiple PPI channels from a channel group. - * - * @param[in] channel_mask PPI channels to be removed. - * @param[in] group Channel group from which to remove the channels. - * - * @retval NRF_SUCCESS If the channel was successfully removed. - */ -uint32_t nrf_drv_ppi_channels_remove_from_group(uint32_t channel_mask, - nrf_ppi_channel_group_t group); - -/**@brief Function for removing a PPI channel from a channel group. - * - * @param[in] channel PPI channel to be removed. - * @param[in] group Channel group from which to remove the channel. - * - * @retval NRF_SUCCESS If the channel was successfully removed. - */ -__STATIC_INLINE uint32_t nrf_drv_ppi_channel_remove_from_group(nrf_ppi_channel_t channel, - nrf_ppi_channel_group_t group) -{ - return nrf_drv_ppi_channels_remove_from_group(nrf_drv_ppi_channel_to_mask(channel), group); -} - -/**@brief Function for clearing a PPI channel group. - * - * @param[in] group Channel group to be cleared. - * - * @retval NRF_SUCCESS If the group was successfully cleared. - */ -__STATIC_INLINE uint32_t nrf_drv_ppi_group_clear(nrf_ppi_channel_group_t group) -{ - return nrf_drv_ppi_channels_remove_from_group(NRF_PPI_ALL_APP_CHANNELS_MASK, group); -} - -/**@brief Function for enabling a PPI channel group. - * - * @param[in] group Channel group to be enabled. - * - * @retval NRF_SUCCESS If the group was successfully enabled. - */ -uint32_t nrf_drv_ppi_group_enable(nrf_ppi_channel_group_t group); - -/**@brief Function for disabling a PPI channel group. - * - * @param[in] group Channel group to be disabled. - * - * @retval NRF_SUCCESS If the group was successfully disabled. - */ -uint32_t nrf_drv_ppi_group_disable(nrf_ppi_channel_group_t group); - -/** - * @brief Function for getting the address of a PPI task. - * - * @param[in] task Task. - * - * @retval Task address. - */ -__STATIC_INLINE uint32_t nrf_drv_ppi_task_addr_get(nrf_ppi_task_t task) -{ - return (uint32_t) nrf_ppi_task_address_get(task); -} - -/** - * @brief Function for getting the address of a PPI group enable task. - * - * @param[in] group PPI channel group - * - * @retval Task address. - */ -__STATIC_INLINE uint32_t nrf_drv_ppi_task_addr_group_enable_get(nrf_ppi_channel_group_t group) -{ - return (uint32_t) nrf_ppi_task_group_enable_address_get(group); -} - -/** - * @brief Function for getting the address of a PPI group enable task. - * - * @param[in] group PPI channel group - * - * @retval Task address. - */ -__STATIC_INLINE uint32_t nrf_drv_ppi_task_addr_group_disable_get(nrf_ppi_channel_group_t group) -{ - return (uint32_t) nrf_ppi_task_group_disable_address_get(group); -} - -/** - *@} - **/ - -/*lint --flb "Leave library region" */ -#ifdef __cplusplus -} -#endif - -#endif // NRF_DRV_PPI_H
