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/hal/nrf_twim.h ---------------------------------------------------------------------- diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/hal/nrf_twim.h b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/hal/nrf_twim.h deleted file mode 100644 index 7d4e5cc..0000000 --- a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/hal/nrf_twim.h +++ /dev/null @@ -1,486 +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_TWIM_H__ -#define NRF_TWIM_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup nrf_twim_hal TWIM HAL - * @{ - * @ingroup nrf_twi_master - * - * @brief Hardware access layer for managing the TWIM peripheral. - */ - -#include <stdint.h> -#include <stddef.h> -#include <stdbool.h> - -#include "nrf.h" - -/** - * @brief TWIM tasks. - */ -typedef enum -{ - /*lint -save -e30*/ - NRF_TWIM_TASK_STARTRX = offsetof(NRF_TWIM_Type, TASKS_STARTRX), ///< Start TWI receive sequence. - NRF_TWIM_TASK_STARTTX = offsetof(NRF_TWIM_Type, TASKS_STARTTX), ///< Start TWI transmit sequence. - NRF_TWIM_TASK_STOP = offsetof(NRF_TWIM_Type, TASKS_STOP), ///< Stop TWI transaction. - NRF_TWIM_TASK_SUSPEND = offsetof(NRF_TWIM_Type, TASKS_SUSPEND), ///< Suspend TWI transaction. - NRF_TWIM_TASK_RESUME = offsetof(NRF_TWIM_Type, TASKS_RESUME) ///< Resume TWI transaction. - /*lint -restore*/ -} nrf_twim_task_t; - -/** - * @brief TWIM events. - */ -typedef enum -{ - /*lint -save -e30*/ - NRF_TWIM_EVENT_STOPPED = offsetof(NRF_TWIM_Type, EVENTS_STOPPED), ///< TWI stopped. - NRF_TWIM_EVENT_ERROR = offsetof(NRF_TWIM_Type, EVENTS_ERROR), ///< TWI error. - NRF_TWIM_EVENT_SUSPENDED = 0x148, ///< TWI suspended. - NRF_TWIM_EVENT_RXSTARTED = offsetof(NRF_TWIM_Type, EVENTS_RXSTARTED), ///< Receive sequence started. - NRF_TWIM_EVENT_TXSTARTED = offsetof(NRF_TWIM_Type, EVENTS_TXSTARTED), ///< Transmit sequence started. - NRF_TWIM_EVENT_LASTRX = offsetof(NRF_TWIM_Type, EVENTS_LASTRX), ///< Byte boundary, starting to receive the last byte. - NRF_TWIM_EVENT_LASTTX = offsetof(NRF_TWIM_Type, EVENTS_LASTTX) ///< Byte boundary, starting to transmit the last byte. - /*lint -restore*/ -} nrf_twim_event_t; - -/** - * @brief TWIM shortcuts. - */ -typedef enum -{ - NRF_TWIM_SHORT_LASTTX_STARTRX_MASK = TWIM_SHORTS_LASTTX_STARTRX_Msk, ///< Shortcut between LASTTX event and STARTRX task. - NRF_TWIM_SHORT_LASTTX_SUSPEND_MASK = TWIM_SHORTS_LASTTX_SUSPEND_Msk, ///< Shortcut between LASTTX event and SUSPEND task. - NRF_TWIM_SHORT_LASTTX_STOP_MASK = TWIM_SHORTS_LASTTX_STOP_Msk, ///< Shortcut between LASTTX event and STOP task. - NRF_TWIM_SHORT_LASTRX_STARTTX_MASK = TWIM_SHORTS_LASTRX_STARTTX_Msk, ///< Shortcut between LASTRX event and STARTTX task. - NRF_TWIM_SHORT_LASTRX_STOP_MASK = TWIM_SHORTS_LASTRX_STOP_Msk ///< Shortcut between LASTRX event and STOP task. -} nrf_twim_short_mask_t; - -/** - * @brief TWIM interrupts. - */ -typedef enum -{ - NRF_TWIM_INT_STOPPED_MASK = TWIM_INTENSET_STOPPED_Msk, ///< Interrupt on STOPPED event. - NRF_TWIM_INT_ERROR_MASK = TWIM_INTENSET_ERROR_Msk, ///< Interrupt on ERROR event. - NRF_TWIM_INT_SUSPENDED_MASK = (1 << 18), ///< Interrupt on SUSPENDED event. - NRF_TWIM_INT_RXSTARTED_MASK = TWIM_INTENSET_RXSTARTED_Msk, ///< Interrupt on RXSTARTED event. - NRF_TWIM_INT_TXSTARTED_MASK = TWIM_INTENSET_TXSTARTED_Msk, ///< Interrupt on TXSTARTED event. - NRF_TWIM_INT_LASTRX_MASK = TWIM_INTENSET_LASTRX_Msk, ///< Interrupt on LASTRX event. - NRF_TWIM_INT_LASTTX_MASK = TWIM_INTENSET_LASTTX_Msk ///< Interrupt on LASTTX event. -} nrf_twim_int_mask_t; - -/** - * @brief TWIM master clock frequency. - */ -typedef enum -{ - NRF_TWIM_FREQ_100K = TWIM_FREQUENCY_FREQUENCY_K100, ///< 100 kbps. - NRF_TWIM_FREQ_250K = TWIM_FREQUENCY_FREQUENCY_K250, ///< 250 kbps. - NRF_TWIM_FREQ_400K = TWIM_FREQUENCY_FREQUENCY_K400 ///< 400 kbps. -} nrf_twim_frequency_t; - -/** - * @brief TWIM error source. - */ -typedef enum -{ - NRF_TWIM_ERROR_ADDRESS_NACK = TWIM_ERRORSRC_ANACK_Msk, ///< NACK received after sending the address. - NRF_TWIM_ERROR_DATA_NACK = TWIM_ERRORSRC_DNACK_Msk ///< NACK received after sending a data byte. -} nrf_twim_error_t; - - -/** - * @brief Function for activating a specific TWIM task. - * - * @param[in] p_twim TWIM instance. - * @param[in] task Task to activate. - */ -__STATIC_INLINE void nrf_twim_task_trigger(NRF_TWIM_Type * p_twim, - nrf_twim_task_t task); - -/** - * @brief Function for getting the address of a specific TWIM task register. - * - * @param[in] p_twim TWIM instance. - * @param[in] task Requested task. - * - * @return Address of the specified task register. - */ -__STATIC_INLINE uint32_t * nrf_twim_task_address_get(NRF_TWIM_Type * p_twim, - nrf_twim_task_t task); - -/** - * @brief Function for clearing a specific TWIM event. - * - * @param[in] p_twim TWIM instance. - * @param[in] event Event to clear. - */ -__STATIC_INLINE void nrf_twim_event_clear(NRF_TWIM_Type * p_twim, - nrf_twim_event_t event); - -/** - * @brief Function for checking the state of a specific TWIM event. - * - * @param[in] p_twim TWIM instance. - * @param[in] event Event to check. - * - * @retval true If the event is set. - * @retval false If the event is not set. - */ -__STATIC_INLINE bool nrf_twim_event_check(NRF_TWIM_Type * p_twim, - nrf_twim_event_t event); - -/** - * @brief Function for getting the address of a specific TWIM event register. - * - * @param[in] p_twim TWIM instance. - * @param[in] event Requested event. - * - * @return Address of the specified event register. - */ -__STATIC_INLINE uint32_t * nrf_twim_event_address_get(NRF_TWIM_Type * p_twim, - nrf_twim_event_t event); - -/** - * @brief Function for enabling specified shortcuts. - * - * @param[in] p_twim TWIM instance. - * @param[in] shorts_mask Shortcuts to enable. - */ -__STATIC_INLINE void nrf_twim_shorts_enable(NRF_TWIM_Type * p_twim, - uint32_t shorts_mask); - -/** - * @brief Function for disabling specified shortcuts. - * - * @param[in] p_twim TWIM instance. - * @param[in] shorts_mask Shortcuts to disable. - */ -__STATIC_INLINE void nrf_twim_shorts_disable(NRF_TWIM_Type * p_twim, - uint32_t shorts_mask); - -/** - * @brief Function for enabling specified interrupts. - * - * @param[in] p_twim TWIM instance. - * @param[in] int_mask Interrupts to enable. - */ -__STATIC_INLINE void nrf_twim_int_enable(NRF_TWIM_Type * p_twim, - uint32_t int_mask); - -/** - * @brief Function for disabling specified interrupts. - * - * @param[in] p_twim TWIM instance. - * @param[in] int_mask Interrupts to disable. - */ -__STATIC_INLINE void nrf_twim_int_disable(NRF_TWIM_Type * p_twim, - uint32_t int_mask); - -/** - * @brief Function for checking the state of a given interrupt. - * - * @param[in] p_twim TWIM instance. - * @param[in] int_mask Interrupt to check. - * - * @retval true If the interrupt is enabled. - * @retval false If the interrupt is not enabled. - */ -__STATIC_INLINE bool nrf_twim_int_enable_check(NRF_TWIM_Type * p_twim, - nrf_twim_int_mask_t int_mask); - -/** - * @brief Function for enabling the TWIM peripheral. - * - * @param[in] p_twim TWIM instance. - */ -__STATIC_INLINE void nrf_twim_enable(NRF_TWIM_Type * p_twim); - -/** - * @brief Function for disabling the TWIM peripheral. - * - * @param[in] p_twim TWIM instance. - */ -__STATIC_INLINE void nrf_twim_disable(NRF_TWIM_Type * p_twim); - -/** - * @brief Function for configuring TWI pins. - * - * - * @param[in] p_twim TWIM instance. - * @param[in] scl_pin SCL pin number. - * @param[in] sda_pin SDA pin number. - */ -__STATIC_INLINE void nrf_twim_pins_set(NRF_TWIM_Type * p_twim, - uint32_t scl_pin, - uint32_t sda_pin); - -/** - * @brief Function for setting the TWI master clock frequency. - * - * @param[in] p_twim TWIM instance. - * @param[in] frequency TWI frequency. - */ -__STATIC_INLINE void nrf_twim_frequency_set(NRF_TWIM_Type * p_twim, - nrf_twim_frequency_t frequency); - -/** - * @brief Function for checking the TWI error source. - * - * The error flags are cleared after reading. - * - * @param[in] p_twim TWIM instance. - * - * @return Mask with error source flags. - */ -__STATIC_INLINE uint32_t nrf_twim_errorsrc_get_and_clear(NRF_TWIM_Type * p_twim); - -/** - * @brief Function for setting the address to be used in TWI transfers. - * - * @param[in] p_twim TWIM instance. - * @param[in] address Address to be used in transfers. - */ -__STATIC_INLINE void nrf_twim_address_set(NRF_TWIM_Type * p_twim, - uint8_t address); - -/** - * @brief Function for setting the transmit buffer. - * - * @param[in] p_twim TWIM instance. - * @param[in] p_buffer Pointer to the buffer with data to send. - * @param[in] length Maximum number of data bytes to transmit. - */ -__STATIC_INLINE void nrf_twim_tx_buffer_set(NRF_TWIM_Type * p_twim, - uint8_t const * p_buffer, - uint8_t length); - -/** - * @brief Function for setting the receive buffer. - * - * @param[in] p_twim TWIM instance. - * @param[in] p_buffer Pointer to the buffer for received data. - * @param[in] length Maximum number of data bytes to receive. - */ -__STATIC_INLINE void nrf_twim_rx_buffer_set(NRF_TWIM_Type * p_twim, - uint8_t * p_buffer, - uint8_t length); - -__STATIC_INLINE void nrf_twim_shorts_set(NRF_TWIM_Type * p_twim, - uint32_t shorts_mask); - -__STATIC_INLINE uint32_t nrf_twim_txd_amount_get(NRF_TWIM_Type * p_twim); - -__STATIC_INLINE uint32_t nrf_twim_rxd_amount_get(NRF_TWIM_Type * p_twim); - -/** - * @brief Function for enabling the TX list feature. - * - * @param[in] p_twim TWIM instance. - */ -__STATIC_INLINE void nrf_twim_tx_list_enable(NRF_TWIM_Type * p_twim); - -/** - * @brief Function for disabling the TX list feature. - * - * @param[in] p_twim TWIM instance. - */ -__STATIC_INLINE void nrf_twim_tx_list_disable(NRF_TWIM_Type * p_twim); - -/** - * @brief Function for enabling the RX list feature. - * - * @param[in] p_twim TWIM instance. - */ -__STATIC_INLINE void nrf_twim_rx_list_enable(NRF_TWIM_Type * p_twim); - -/** - * @brief Function for disabling the RX list feature. - * - * @param[in] p_twim TWIM instance. - */ -__STATIC_INLINE void nrf_twim_rx_list_disable(NRF_TWIM_Type * p_twim); - -/** - * @} - */ - - -#ifndef SUPPRESS_INLINE_IMPLEMENTATION - -__STATIC_INLINE void nrf_twim_task_trigger(NRF_TWIM_Type * p_twim, - nrf_twim_task_t task) -{ - *((volatile uint32_t *)((uint8_t *)p_twim + (uint32_t)task)) = 0x1UL; -} - -__STATIC_INLINE uint32_t * nrf_twim_task_address_get(NRF_TWIM_Type * p_twim, - nrf_twim_task_t task) -{ - return (uint32_t *)((uint8_t *)p_twim + (uint32_t)task); -} - -__STATIC_INLINE void nrf_twim_event_clear(NRF_TWIM_Type * p_twim, - nrf_twim_event_t event) -{ - *((volatile uint32_t *)((uint8_t *)p_twim + (uint32_t)event)) = 0x0UL; -} - -__STATIC_INLINE bool nrf_twim_event_check(NRF_TWIM_Type * p_twim, - nrf_twim_event_t event) -{ - return (bool)*(volatile uint32_t *)((uint8_t *)p_twim + (uint32_t)event); -} - -__STATIC_INLINE uint32_t * nrf_twim_event_address_get(NRF_TWIM_Type * p_twim, - nrf_twim_event_t event) -{ - return (uint32_t *)((uint8_t *)p_twim + (uint32_t)event); -} - -__STATIC_INLINE void nrf_twim_shorts_enable(NRF_TWIM_Type * p_twim, - uint32_t shorts_mask) -{ - p_twim->SHORTS |= shorts_mask; -} - -__STATIC_INLINE void nrf_twim_shorts_disable(NRF_TWIM_Type * p_twim, - uint32_t shorts_mask) -{ - p_twim->SHORTS &= ~(shorts_mask); -} - -__STATIC_INLINE void nrf_twim_int_enable(NRF_TWIM_Type * p_twim, - uint32_t int_mask) -{ - p_twim->INTENSET = int_mask; -} - -__STATIC_INLINE void nrf_twim_int_disable(NRF_TWIM_Type * p_twim, - uint32_t int_mask) -{ - p_twim->INTENCLR = int_mask; -} - -__STATIC_INLINE bool nrf_twim_int_enable_check(NRF_TWIM_Type * p_twim, - nrf_twim_int_mask_t int_mask) -{ - return (bool)(p_twim->INTENSET & int_mask); -} - -__STATIC_INLINE void nrf_twim_enable(NRF_TWIM_Type * p_twim) -{ - p_twim->ENABLE = (TWIM_ENABLE_ENABLE_Enabled << TWIM_ENABLE_ENABLE_Pos); -} - -__STATIC_INLINE void nrf_twim_disable(NRF_TWIM_Type * p_twim) -{ - p_twim->ENABLE = (TWIM_ENABLE_ENABLE_Disabled << TWIM_ENABLE_ENABLE_Pos); -} - -__STATIC_INLINE void nrf_twim_pins_set(NRF_TWIM_Type * p_twim, - uint32_t scl_pin, - uint32_t sda_pin) -{ - p_twim->PSEL.SCL = scl_pin; - p_twim->PSEL.SDA = sda_pin; -} - -__STATIC_INLINE void nrf_twim_frequency_set(NRF_TWIM_Type * p_twim, - nrf_twim_frequency_t frequency) -{ - p_twim->FREQUENCY = frequency; -} - -__STATIC_INLINE uint32_t nrf_twim_errorsrc_get_and_clear(NRF_TWIM_Type * p_twim) -{ - uint32_t error_source = p_twim->ERRORSRC; - - // [error flags are cleared by writing '1' on their position] - p_twim->ERRORSRC = error_source; - - return error_source; -} - -__STATIC_INLINE void nrf_twim_address_set(NRF_TWIM_Type * p_twim, - uint8_t address) -{ - p_twim->ADDRESS = address; -} - -__STATIC_INLINE void nrf_twim_tx_buffer_set(NRF_TWIM_Type * p_twim, - uint8_t const * p_buffer, - uint8_t length) -{ - p_twim->TXD.PTR = (uint32_t)p_buffer; - p_twim->TXD.MAXCNT = length; -} - -__STATIC_INLINE void nrf_twim_rx_buffer_set(NRF_TWIM_Type * p_twim, - uint8_t * p_buffer, - uint8_t length) -{ - p_twim->RXD.PTR = (uint32_t)p_buffer; - p_twim->RXD.MAXCNT = length; -} - -__STATIC_INLINE void nrf_twim_shorts_set(NRF_TWIM_Type * p_twim, - uint32_t shorts_mask) -{ - p_twim->SHORTS = shorts_mask; -} - -__STATIC_INLINE uint32_t nrf_twim_txd_amount_get(NRF_TWIM_Type * p_twim) -{ - return p_twim->TXD.AMOUNT; -} - -__STATIC_INLINE uint32_t nrf_twim_rxd_amount_get(NRF_TWIM_Type * p_twim) -{ - return p_twim->RXD.AMOUNT; -} - -__STATIC_INLINE void nrf_twim_tx_list_enable(NRF_TWIM_Type * p_twim) -{ - p_twim->TXD.LIST = 1; -} - -__STATIC_INLINE void nrf_twim_tx_list_disable(NRF_TWIM_Type * p_twim) -{ - p_twim->TXD.LIST = 0; -} - -__STATIC_INLINE void nrf_twim_rx_list_enable(NRF_TWIM_Type * p_twim) -{ - p_twim->RXD.LIST = 1; -} - -__STATIC_INLINE void nrf_twim_rx_list_disable(NRF_TWIM_Type * p_twim) -{ - p_twim->RXD.LIST = 0; -} -#endif // SUPPRESS_INLINE_IMPLEMENTATION - -#ifdef __cplusplus -} -#endif - -#endif // NRF_TWIM_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/hal/nrf_twis.h ---------------------------------------------------------------------- diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/hal/nrf_twis.h b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/hal/nrf_twis.h deleted file mode 100644 index a7b7a1d..0000000 --- a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/hal/nrf_twis.h +++ /dev/null @@ -1,684 +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. - * - */ - -/** - * @ingroup nrf_twis - * @defgroup nrf_twis_hal TWIS HAL - * @{ - * - * @brief @tagAPI52 Hardware access layer for Two Wire Interface Slave with EasyDMA - * (TWIS) peripheral. - */ -#ifndef NRF_TWIS_H__ -#define NRF_TWIS_H__ - -#include "nrf.h" -#include "nrf_drv_config.h" -#include <stdint.h> -#include <stddef.h> -#include <stdbool.h> - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief TWIS tasks - */ -typedef enum -{ - /*lint -save -e30*/ -#ifndef NRF52_PAN_30 /* STOP task is not functional in MPW3 (PAN-30) */ - /* Stop task is not working properly for first release */ - NRF_TWIS_TASK_STOP = offsetof(NRF_TWIS_Type, TASKS_STOP), /**< Stop TWIS transaction */ -#endif - NRF_TWIS_TASK_SUSPEND = offsetof(NRF_TWIS_Type, TASKS_SUSPEND), /**< Suspend TWIS transaction */ - NRF_TWIS_TASK_RESUME = offsetof(NRF_TWIS_Type, TASKS_RESUME), /**< Resume TWIS transaction */ - NRF_TWIS_TASK_PREPARERX = offsetof(NRF_TWIS_Type, TASKS_PREPARERX), /**< Prepare the TWIS slave to respond to a write command */ - NRF_TWIS_TASK_PREPARETX = offsetof(NRF_TWIS_Type, TASKS_PREPARETX) /**< Prepare the TWIS slave to respond to a read command */ - /*lint -restore*/ -} nrf_twis_task_t; - -/** - * @brief TWIS events - */ -typedef enum -{ - /*lint -save -e30*/ - NRF_TWIS_EVENT_STOPPED = offsetof(NRF_TWIS_Type, EVENTS_STOPPED), /**< TWIS stopped */ - NRF_TWIS_EVENT_ERROR = offsetof(NRF_TWIS_Type, EVENTS_ERROR), /**< TWIS error */ - NRF_TWIS_EVENT_RXSTARTED = offsetof(NRF_TWIS_Type, EVENTS_RXSTARTED), /**< Receive sequence started */ - NRF_TWIS_EVENT_TXSTARTED = offsetof(NRF_TWIS_Type, EVENTS_TXSTARTED), /**< Transmit sequence started */ - NRF_TWIS_EVENT_WRITE = offsetof(NRF_TWIS_Type, EVENTS_WRITE), /**< Write command received */ - NRF_TWIS_EVENT_READ = offsetof(NRF_TWIS_Type, EVENTS_READ) /**< Read command received */ - /*lint -restore*/ -} nrf_twis_event_t; - -/** - * @brief TWIS shortcuts - */ -typedef enum -{ - NRF_TWIS_SHORT_WRITE_SUSPEND_MASK = TWIS_SHORTS_WRITE_SUSPEND_Msk, /**< Shortcut between WRITE event and SUSPEND task */ - NRF_TWIS_SHORT_READ_SUSPEND_MASK = TWIS_SHORTS_READ_SUSPEND_Msk, /**< Shortcut between READ event and SUSPEND task */ -} nrf_twis_short_mask_t; - -/** - * @brief TWIS interrupts - */ -typedef enum -{ - NRF_TWIS_INT_STOPPED_MASK = TWIS_INTEN_STOPPED_Msk, /**< Interrupt on STOPPED event */ - NRF_TWIS_INT_ERROR_MASK = TWIS_INTEN_ERROR_Msk, /**< Interrupt on ERROR event */ - NRF_TWIS_INT_RXSTARTED_MASK = TWIS_INTEN_RXSTARTED_Msk, /**< Interrupt on RXSTARTED event */ - NRF_TWIS_INT_TXSTARTED_MASK = TWIS_INTEN_TXSTARTED_Msk, /**< Interrupt on TXSTARTED event */ - NRF_TWIS_INT_WRITE_MASK = TWIS_INTEN_WRITE_Msk, /**< Interrupt on WRITE event */ - NRF_TWIS_INT_READ_MASK = TWIS_INTEN_READ_Msk, /**< Interrupt on READ event */ -} nrf_twis_int_mask_t; - -/** - * @brief TWIS error source - */ -typedef enum -{ - NRF_TWIS_ERROR_OVERFLOW = TWIS_ERRORSRC_OVERFLOW_Msk, /**< RX buffer overflow detected, and prevented */ -#ifdef NRF52_PAN_29 - /* Patched version of bit positions in ERRORSRC register (PAN-29) */ - NRF_TWIS_ERROR_DATA_NACK = 1U << 1, /**< NACK sent after receiving a data byte */ - NRF_TWIS_ERROR_OVERREAD = 1U << 2 /**< TX buffer over-read detected, and prevented */ -#else - /* Code that meets current documentation */ - NRF_TWIS_ERROR_DATA_NACK = TWIS_ERRORSRC_DNACK_Msk, /**< NACK sent after receiving a data byte */ - NRF_TWIS_ERROR_OVERREAD = TWIS_ERRORSRC_OVERREAD_Msk /**< TX buffer over-read detected, and prevented */ -#endif -} nrf_twis_error_t; - -/** - * @brief TWIS address matching configuration - */ -typedef enum -{ - NRF_TWIS_CONFIG_ADDRESS0_MASK = TWIS_CONFIG_ADDRESS0_Msk, /**< Enable or disable address matching on ADDRESS[0] */ - NRF_TWIS_CONFIG_ADDRESS1_MASK = TWIS_CONFIG_ADDRESS1_Msk, /**< Enable or disable address matching on ADDRESS[1] */ - NRF_TWIS_CONFIG_ADDRESS01_MASK = TWIS_CONFIG_ADDRESS0_Msk | TWIS_CONFIG_ADDRESS1_Msk /**< Enable both address matching */ -} nrf_twis_config_addr_mask_t; - -/** - * @brief Variable type to hold amount of data for EasyDMA - * - * Variable of the minimum size that can hold the amount of data to transfer. - * - * @note - * Defined to make it simple to change if EasyDMA would be updated to support more data in - * the future devices to. - */ -typedef uint8_t nrf_twis_amount_t; - -/** - * @brief Smallest variable type to hold TWI address - * - * Variable of the minimum size that can hold single TWI address. - * - * @note - * Defined to make it simple to change if new TWI would support for example - * 10 bit addressing mode. - */ -typedef uint8_t nrf_twis_address_t; - - -/** - * @brief Function for activating a specific TWIS task. - * - * @param[in] p_twis TWIS instance. - * @param task Task. - */ -__STATIC_INLINE void nrf_twis_task_trigger(NRF_TWIS_Type * const p_twis, nrf_twis_task_t task); - -/** - * @brief Function for returning the address of a specific TWIS task register. - * - * @param[in] p_twis TWIS instance. - * @param task Task. - * - * @return Task address. - */ -__STATIC_INLINE uint32_t nrf_twis_task_address_get( - NRF_TWIS_Type const * const p_twis, - nrf_twis_task_t task); - -/** - * @brief Function for clearing a specific event. - * - * @param[in] p_twis TWIS instance. - * @param event Event. - */ -__STATIC_INLINE void nrf_twis_event_clear( - NRF_TWIS_Type * const p_twis, - nrf_twis_event_t event); -/** - * @brief Function for returning the state of a specific event. - * - * @param[in] p_twis TWIS instance. - * @param event Event. - * - * @retval true If the event is set. - * @retval false If the event is not set. - */ -__STATIC_INLINE bool nrf_twis_event_check( - NRF_TWIS_Type const * const p_twis, - nrf_twis_event_t event); - - -/** - * @brief Function for getting and clearing the state of specific event - * - * This function checks the state of the event and clears it. - * @param[in,out] p_twis TWIS instance - * @param event Event. - * - * @retval true If the event was set. - * @retval false If the event was not set. - */ -__STATIC_INLINE bool nrf_twis_event_get_and_clear( - NRF_TWIS_Type * const p_twis, - nrf_twis_event_t event); - - -/** - * @brief Function for returning the address of a specific TWIS event register. - * - * @param[in] p_twis TWIS instance. - * @param event Event. - * - * @return Address. - */ -__STATIC_INLINE uint32_t nrf_twis_event_address_get( - NRF_TWIS_Type const * const p_twis, - nrf_twis_event_t event); - -/** - * @brief Function for setting a shortcut. - * - * @param[in] p_twis TWIS instance. - * @param short_mask Shortcuts mask. - */ -__STATIC_INLINE void nrf_twis_shorts_enable(NRF_TWIS_Type * const p_twis, uint32_t short_mask); - -/** - * @brief Function for clearing shortcuts. - * - * @param[in] p_twis TWIS instance. - * @param short_mask Shortcuts mask. - */ -__STATIC_INLINE void nrf_twis_shorts_disable(NRF_TWIS_Type * const p_twis, uint32_t short_mask); - -/** - * @brief Get the shorts mask - * - * Function returns shorts register. - * @param[in] p_twis TWIS instance. - * @return Flags of currently enabled shortcuts - */ -__STATIC_INLINE uint32_t nrf_twis_shorts_get(NRF_TWIS_Type * const p_twis); - -/** - * @brief Function for enabling selected interrupts. - * - * @param[in] p_twis TWIS instance. - * @param int_mask Interrupts mask. - */ -__STATIC_INLINE void nrf_twis_int_enable(NRF_TWIS_Type * const p_twis, uint32_t int_mask); - -/** - * @brief Function for retrieving the state of selected interrupts. - * - * @param[in] p_twis TWIS instance. - * @param int_mask Interrupts mask. - * - * @retval true If any of selected interrupts is enabled. - * @retval false If none of selected interrupts is enabled. - */ -__STATIC_INLINE bool nrf_twis_int_enable_check(NRF_TWIS_Type const * const p_twis, uint32_t int_mask); - -/** - * @brief Function for disabling selected interrupts. - * - * @param[in] p_twis TWIS instance. - * @param int_mask Interrupts mask. - */ -__STATIC_INLINE void nrf_twis_int_disable(NRF_TWIS_Type * const p_twis, uint32_t int_mask); - -/** - * @brief Function for retrieving and clearing the TWIS error source. - * - * @attention Error sources are cleared after read. - * @param[in] p_twis TWIS instance - * @return Error source mask with values from @ref nrf_twis_error_t. - */ -__STATIC_INLINE uint32_t nrf_twis_error_source_get_and_clear(NRF_TWIS_Type * const p_twis); - -/** - * @brief Get information which of addresses matched - * - * Function returns index in the address table - * that points to the address that already matched. - * @param[in] p_twis TWIS instance - * @return Index of matched address - */ -__STATIC_INLINE uint_fast8_t nrf_twis_match_get(NRF_TWIS_Type const * p_twis); - -/** - * @brief Function for enabling TWIS. - * - * @param[in] p_twis TWIS instance. - */ -__STATIC_INLINE void nrf_twis_enable(NRF_TWIS_Type * const p_twis); - -/** - * @brief Function for disabling TWIS. - * - * @param[in] p_twis TWIS instance. - */ -__STATIC_INLINE void nrf_twis_disable(NRF_TWIS_Type * const p_twis); - -/** - * @brief Function for configuring TWIS pins. - * - * @param[in] p_twis TWIS instance. - * @param scl SCL pin number. - * @param sda SDA pin number. - */ -__STATIC_INLINE void nrf_twis_pins_set(NRF_TWIS_Type * const p_twis, uint32_t scl, uint32_t sda); - -/** - * @brief Function for setting the receive buffer. - * - * @param[in] p_twis TWIS instance. - * @param p_buf Pointer to the buffer for received data. - * @param length Maximum number of data bytes to receive. - */ -__STATIC_INLINE void nrf_twis_rx_buffer_set( - NRF_TWIS_Type * const p_twis, - uint8_t * p_buf, - nrf_twis_amount_t length); - -/** - * @brief Function that prepares TWIS for receiving - * - * This function sets receive buffer and then sets NRF_TWIS_TASK_PREPARERX task. - * @param[in] p_twis TWIS instance. - * @param p_buf Pointer to the buffer for received data. - * @param length Maximum number of data bytes to receive. - */ -__STATIC_INLINE void nrf_twis_rx_prepare( - NRF_TWIS_Type * const p_twis, - uint8_t * p_buf, - nrf_twis_amount_t length); - -/** - * @brief Function for getting number of bytes received in the last transaction. - * - * @param[in] p_twis TWIS instance. - * @return Amount of bytes received. - * */ -__STATIC_INLINE nrf_twis_amount_t nrf_twis_rx_amount_get(NRF_TWIS_Type const * const p_twis); - -/** - * @brief Function for setting the transmit buffer. - * - * @param[in] p_twis TWIS instance. - * @param p_buf Pointer to the buffer with data to send. - * @param length Maximum number of data bytes to transmit. - */ -__STATIC_INLINE void nrf_twis_tx_buffer_set( - NRF_TWIS_Type * const p_twis, - uint8_t const * p_buf, - nrf_twis_amount_t length); - -/** - * @brief Function that prepares TWIS for transmitting - * - * This function sets transmit buffer and then sets NRF_TWIS_TASK_PREPARETX task. - * @param[in] p_twis TWIS instance. - * @param p_buf Pointer to the buffer with data to send. - * @param length Maximum number of data bytes to transmit. - */ -__STATIC_INLINE void nrf_twis_tx_prepare( - NRF_TWIS_Type * const p_twis, - uint8_t const * p_buf, - nrf_twis_amount_t length); - -/** - * @brief Function for getting number of bytes transmitted in the last transaction. - * - * @param[in] p_twis TWIS instance. - * @return Amount of bytes transmitted. - */ -__STATIC_INLINE nrf_twis_amount_t nrf_twis_tx_amount_get(NRF_TWIS_Type const * const p_twis); - -/** - * @brief Function for setting slave address - * - * Function sets the selected address for this TWI interface. - * @param[in] p_twis TWIS instance. - * @param n Index of address to set - * @param addr Addres to set - * @sa nrf_twis_config_address_set - * @sa nrf_twis_config_address_get - */ -__STATIC_INLINE void nrf_twis_address_set( - NRF_TWIS_Type * const p_twis, - uint_fast8_t n, - nrf_twis_address_t addr); - -/** - * @brief Function for retrieving configured slave address - * - * Function gets the selected address for this TWI interface. - * @param[in] p_twis TWIS instance. - * @param n Index of address to get - */ -__STATIC_INLINE nrf_twis_address_t nrf_twis_address_get( - NRF_TWIS_Type const * const p_twis, - uint_fast8_t n); - -/** - * @brief Function for setting the device address configuration. - * - * @param[in] p_twis TWIS instance. - * @param addr_mask Mask of address indexes of what device should answer to. - * - * @sa nrf_twis_address_set - */ -__STATIC_INLINE void nrf_twis_config_address_set( - NRF_TWIS_Type * const p_twis, - nrf_twis_config_addr_mask_t addr_mask); - -/** - * @brief Function for retrieving the device address configuration. - * - * @param[in] p_twis TWIS instance. - * - * @return Mask of address indexes of what device should answer to. - */ -__STATIC_INLINE nrf_twis_config_addr_mask_t nrf_twis_config_address_get( - NRF_TWIS_Type const * const p_twis); - -/** - * @brief Function for setting the over-read character. - * - * @param[in] p_twis TWIS instance. - * @param[in] orc Over-read character. Character clocked out in case of - * over-read of the TXD buffer. - */ -__STATIC_INLINE void nrf_twis_orc_set( - NRF_TWIS_Type * const p_twis, - uint8_t orc); - -/** - * @brief Function for setting the over-read character. - * - * @param[in] p_twis TWIS instance. - * - * @return Over-read character configured for selected instance. - */ -__STATIC_INLINE uint8_t nrf_twis_orc_get(NRF_TWIS_Type const * const p_twis); - - -/** @} */ /* End of nrf_twis_hal */ - -#ifndef SUPPRESS_INLINE_IMPLEMENTATION - -/* ------------------------------------------------------------------------------------------------ - * Internal functions - */ - -/** - * @internal - * @brief Internal function for getting task/event register address - * - * @param[in] p_twis TWIS instance. - * @oaram offset Offset of the register from the instance beginning - * - * @attention offset has to be modulo 4 value. In other case we can get hardware fault. - * @return Pointer to the register - */ -__STATIC_INLINE volatile uint32_t* nrf_twis_getRegPtr(NRF_TWIS_Type * const p_twis, uint32_t offset) -{ - return (volatile uint32_t*)((uint8_t *)p_twis + (uint32_t)offset); -} - -/** - * @internal - * @brief Internal function for getting task/event register address - constant version - * - * @param[in] p_twis TWIS instance. - * @oaram offset Offset of the register from the instance beginning - * - * @attention offset has to be modulo 4 value. In other case we can get hardware fault. - * @return Pointer to the register - */ -__STATIC_INLINE volatile const uint32_t* nrf_twis_getRegPtr_c(NRF_TWIS_Type const * const p_twis, uint32_t offset) -{ - return (volatile const uint32_t*)((uint8_t *)p_twis + (uint32_t)offset); -} - - -/* ------------------------------------------------------------------------------------------------ - * Interface functions definitions - */ - - -void nrf_twis_task_trigger(NRF_TWIS_Type * const p_twis, nrf_twis_task_t task) -{ - *(nrf_twis_getRegPtr(p_twis, (uint32_t)task)) = 1UL; -} - -uint32_t nrf_twis_task_address_get( - NRF_TWIS_Type const * const p_twis, - nrf_twis_task_t task) -{ - return (uint32_t)nrf_twis_getRegPtr_c(p_twis, (uint32_t)task); -} - -void nrf_twis_event_clear( - NRF_TWIS_Type * const p_twis, - nrf_twis_event_t event) -{ - *(nrf_twis_getRegPtr(p_twis, (uint32_t)event)) = 0UL; -} - -bool nrf_twis_event_check( - NRF_TWIS_Type const * const p_twis, - nrf_twis_event_t event) -{ - return (bool)*nrf_twis_getRegPtr_c(p_twis, (uint32_t)event); -} - -bool nrf_twis_event_get_and_clear( - NRF_TWIS_Type * const p_twis, - nrf_twis_event_t event) -{ - bool ret = nrf_twis_event_check(p_twis, event); - if(ret) - { - nrf_twis_event_clear(p_twis, event); - } - return ret; -} - -uint32_t nrf_twis_event_address_get( - NRF_TWIS_Type const * const p_twis, - nrf_twis_event_t event) -{ - return (uint32_t)nrf_twis_getRegPtr_c(p_twis, (uint32_t)event); -} - -void nrf_twis_shorts_enable(NRF_TWIS_Type * const p_twis, uint32_t short_mask) -{ - p_twis->SHORTS |= short_mask; -} - -void nrf_twis_shorts_disable(NRF_TWIS_Type * const p_twis, uint32_t short_mask) -{ - if(~0U == short_mask) - { - /* Optimized version for "disable all" */ - p_twis->SHORTS = 0; - } - else - { - p_twis->SHORTS &= ~short_mask; - } -} - -uint32_t nrf_twis_shorts_get(NRF_TWIS_Type * const p_twis) -{ - return p_twis->SHORTS; -} - -void nrf_twis_int_enable(NRF_TWIS_Type * const p_twis, uint32_t int_mask) -{ - p_twis->INTENSET = int_mask; -} - -bool nrf_twis_int_enable_check(NRF_TWIS_Type const * const p_twis, uint32_t int_mask) -{ - return (bool)(p_twis->INTENSET & int_mask); -} - -void nrf_twis_int_disable(NRF_TWIS_Type * const p_twis, uint32_t int_mask) -{ - p_twis->INTENCLR = int_mask; -} - -uint32_t nrf_twis_error_source_get_and_clear(NRF_TWIS_Type * const p_twis) -{ - uint32_t ret = p_twis->ERRORSRC; - p_twis->ERRORSRC = ret; - return ret; -} - -uint_fast8_t nrf_twis_match_get(NRF_TWIS_Type const * p_twis) -{ - return (uint_fast8_t)p_twis->MATCH; -} - -void nrf_twis_enable(NRF_TWIS_Type * const p_twis) -{ - p_twis->ENABLE = (TWIS_ENABLE_ENABLE_Enabled << TWIS_ENABLE_ENABLE_Pos); -} - -void nrf_twis_disable(NRF_TWIS_Type * const p_twis) -{ - p_twis->ENABLE = (TWIS_ENABLE_ENABLE_Disabled << TWIS_ENABLE_ENABLE_Pos); -} - -void nrf_twis_pins_set(NRF_TWIS_Type * const p_twis, uint32_t scl, uint32_t sda) -{ - p_twis->PSEL.SCL = scl; - p_twis->PSEL.SDA = sda; -} - -void nrf_twis_rx_buffer_set( - NRF_TWIS_Type * const p_twis, - uint8_t * p_buf, - nrf_twis_amount_t length) -{ - p_twis->RXD.PTR = (uint32_t)p_buf; - p_twis->RXD.MAXCNT = length; -} - -__STATIC_INLINE void nrf_twis_rx_prepare( - NRF_TWIS_Type * const p_twis, - uint8_t * p_buf, - nrf_twis_amount_t length) -{ - nrf_twis_rx_buffer_set(p_twis, p_buf, length); - nrf_twis_task_trigger(p_twis, NRF_TWIS_TASK_PREPARERX); -} - -nrf_twis_amount_t nrf_twis_rx_amount_get(NRF_TWIS_Type const * const p_twis) -{ - return (nrf_twis_amount_t)p_twis->RXD.AMOUNT; -} - -void nrf_twis_tx_buffer_set( - NRF_TWIS_Type * const p_twis, - uint8_t const * p_buf, - nrf_twis_amount_t length) -{ - p_twis->TXD.PTR = (uint32_t)p_buf; - p_twis->TXD.MAXCNT = length; -} - -__STATIC_INLINE void nrf_twis_tx_prepare( - NRF_TWIS_Type * const p_twis, - uint8_t const * p_buf, - nrf_twis_amount_t length) -{ - nrf_twis_tx_buffer_set(p_twis, p_buf, length); - nrf_twis_task_trigger(p_twis, NRF_TWIS_TASK_PREPARETX); -} - -nrf_twis_amount_t nrf_twis_tx_amount_get(NRF_TWIS_Type const * const p_twis) -{ - return (nrf_twis_amount_t)p_twis->TXD.AMOUNT; -} - -void nrf_twis_address_set( - NRF_TWIS_Type * const p_twis, - uint_fast8_t n, - nrf_twis_address_t addr) -{ - p_twis->ADDRESS[n] = addr; -} - -nrf_twis_address_t nrf_twis_address_get( - NRF_TWIS_Type const * const p_twis, - uint_fast8_t n) -{ - return (nrf_twis_address_t)p_twis->ADDRESS[n]; -} -void nrf_twis_config_address_set( - NRF_TWIS_Type * const p_twis, - nrf_twis_config_addr_mask_t addr_mask) -{ - /* This is the only configuration in TWIS - just write it without masking */ - p_twis->CONFIG = addr_mask; -} - -nrf_twis_config_addr_mask_t nrf_twis_config_address_get(NRF_TWIS_Type const * const p_twis) -{ - return (nrf_twis_config_addr_mask_t)(p_twis->CONFIG & TWIS_ADDRESS_ADDRESS_Msk); -} - -void nrf_twis_orc_set( - NRF_TWIS_Type * const p_twis, - uint8_t orc) -{ - p_twis->ORC = orc; -} - -uint8_t nrf_twis_orc_get(NRF_TWIS_Type const * const p_twis) -{ - return (uint8_t)p_twis->ORC; -} - -#endif /* SUPPRESS_INLINE_IMPLEMENTATION */ - -#ifdef __cplusplus -} -#endif - -#endif /* NRF_TWIS_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/hal/nrf_uart.h ---------------------------------------------------------------------- diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/hal/nrf_uart.h b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/hal/nrf_uart.h deleted file mode 100644 index cc82f40..0000000 --- a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/hal/nrf_uart.h +++ /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. - * - */ -#ifndef NRF_UART_H__ -#define NRF_UART_H__ - -#include "nrf.h" -#include <stdint.h> -#include <stddef.h> -#include <stdbool.h> - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup nrf_uart_hal UART HAL - * @{ - * @ingroup nrf_uart - * - * @brief Hardware access layer for accessing the UART peripheral. - */ - -#define NRF_UART_PSEL_DISCONNECTED 0xFFFFFFFF - -/** - * @enum nrf_uart_task_t - * @brief UART tasks. - */ -typedef enum -{ - /*lint -save -e30 -esym(628,__INTADDR__)*/ - NRF_UART_TASK_STARTRX = offsetof(NRF_UART_Type, TASKS_STARTRX), /**< Task for starting reception. */ - NRF_UART_TASK_STOPRX = offsetof(NRF_UART_Type, TASKS_STOPRX), /**< Task for stopping reception. */ - NRF_UART_TASK_STARTTX = offsetof(NRF_UART_Type, TASKS_STARTTX), /**< Task for starting transmission. */ - NRF_UART_TASK_STOPTX = offsetof(NRF_UART_Type, TASKS_STOPTX), /**< Task for stopping transmission. */ - NRF_UART_TASK_SUSPEND = offsetof(NRF_UART_Type, TASKS_SUSPEND), /**< Task for suspending UART. */ - /*lint -restore*/ -} nrf_uart_task_t; - -/** - * @enum nrf_uart_event_t - * @brief UART events. - */ -typedef enum -{ - /*lint -save -e30*/ - NRF_UART_EVENT_CTS = offsetof(NRF_UART_Type, EVENTS_CTS), /**< Event from CTS line activation. */ - NRF_UART_EVENT_NCTS = offsetof(NRF_UART_Type, EVENTS_NCTS), /**< Event from CTS line deactivation. */ - NRF_UART_EVENT_RXDRDY = offsetof(NRF_UART_Type, EVENTS_RXDRDY),/**< Event from data ready in RXD. */ - NRF_UART_EVENT_TXDRDY = offsetof(NRF_UART_Type, EVENTS_TXDRDY),/**< Event from data sent from TXD. */ - NRF_UART_EVENT_ERROR = offsetof(NRF_UART_Type, EVENTS_ERROR), /**< Event from error detection. */ - NRF_UART_EVENT_RXTO = offsetof(NRF_UART_Type, EVENTS_RXTO) /**< Event from receiver timeout. */ - /*lint -restore*/ -} nrf_uart_event_t; - -/** - * @enum nrf_uart_int_mask_t - * @brief UART interrupts. - */ -typedef enum -{ - /*lint -save -e30*/ - NRF_UART_INT_MASK_CTS = UART_INTENCLR_CTS_Msk, /**< CTS line activation interrupt. */ - NRF_UART_INT_MASK_NCTS = UART_INTENCLR_NCTS_Msk, /**< CTS line deactivation interrupt. */ - NRF_UART_INT_MASK_RXDRDY = UART_INTENCLR_RXDRDY_Msk, /**< Data ready in RXD interrupt. */ - NRF_UART_INT_MASK_TXDRDY = UART_INTENCLR_TXDRDY_Msk, /**< Data sent from TXD interrupt. */ - NRF_UART_INT_MASK_ERROR = UART_INTENCLR_ERROR_Msk, /**< Error detection interrupt. */ - NRF_UART_INT_MASK_RXTO = UART_INTENCLR_RXTO_Msk /**< Receiver timeout interrupt. */ - /*lint -restore*/ -} nrf_uart_int_mask_t; - -/** - * @enum nrf_uart_baudrate_t - * @brief Baudrates supported by UART. - */ -typedef enum -{ -#ifdef NRF52 - NRF_UART_BAUDRATE_1200 = UARTE_BAUDRATE_BAUDRATE_Baud1200, /**< 1200 baud. */ - NRF_UART_BAUDRATE_2400 = UARTE_BAUDRATE_BAUDRATE_Baud2400, /**< 2400 baud. */ - NRF_UART_BAUDRATE_4800 = UARTE_BAUDRATE_BAUDRATE_Baud4800, /**< 4800 baud. */ - NRF_UART_BAUDRATE_9600 = UARTE_BAUDRATE_BAUDRATE_Baud9600, /**< 9600 baud. */ - NRF_UART_BAUDRATE_14400 = UARTE_BAUDRATE_BAUDRATE_Baud14400, /**< 14400 baud. */ - NRF_UART_BAUDRATE_19200 = UARTE_BAUDRATE_BAUDRATE_Baud19200, /**< 19200 baud. */ - NRF_UART_BAUDRATE_28800 = UARTE_BAUDRATE_BAUDRATE_Baud28800, /**< 28800 baud. */ - NRF_UART_BAUDRATE_38400 = UARTE_BAUDRATE_BAUDRATE_Baud38400, /**< 38400 baud. */ - NRF_UART_BAUDRATE_57600 = UARTE_BAUDRATE_BAUDRATE_Baud57600, /**< 57600 baud. */ - NRF_UART_BAUDRATE_76800 = UARTE_BAUDRATE_BAUDRATE_Baud76800, /**< 76800 baud. */ - NRF_UART_BAUDRATE_115200 = UARTE_BAUDRATE_BAUDRATE_Baud115200, /**< 115200 baud. */ - NRF_UART_BAUDRATE_230400 = UARTE_BAUDRATE_BAUDRATE_Baud230400, /**< 230400 baud. */ - NRF_UART_BAUDRATE_250000 = UARTE_BAUDRATE_BAUDRATE_Baud250000, /**< 250000 baud. */ - NRF_UART_BAUDRATE_460800 = UARTE_BAUDRATE_BAUDRATE_Baud460800, /**< 460800 baud. */ - NRF_UART_BAUDRATE_921600 = UARTE_BAUDRATE_BAUDRATE_Baud921600, /**< 921600 baud. */ - NRF_UART_BAUDRATE_1000000 = UARTE_BAUDRATE_BAUDRATE_Baud1M, /**< 1000000 baud. */ -#else - NRF_UART_BAUDRATE_1200 = UART_BAUDRATE_BAUDRATE_Baud1200, /**< 1200 baud. */ - NRF_UART_BAUDRATE_2400 = UART_BAUDRATE_BAUDRATE_Baud2400, /**< 2400 baud. */ - NRF_UART_BAUDRATE_4800 = UART_BAUDRATE_BAUDRATE_Baud4800, /**< 4800 baud. */ - NRF_UART_BAUDRATE_9600 = UART_BAUDRATE_BAUDRATE_Baud9600, /**< 9600 baud. */ - NRF_UART_BAUDRATE_14400 = UART_BAUDRATE_BAUDRATE_Baud14400, /**< 14400 baud. */ - NRF_UART_BAUDRATE_19200 = UART_BAUDRATE_BAUDRATE_Baud19200, /**< 19200 baud. */ - NRF_UART_BAUDRATE_28800 = UART_BAUDRATE_BAUDRATE_Baud28800, /**< 28800 baud. */ - NRF_UART_BAUDRATE_38400 = UART_BAUDRATE_BAUDRATE_Baud38400, /**< 38400 baud. */ - NRF_UART_BAUDRATE_57600 = UART_BAUDRATE_BAUDRATE_Baud57600, /**< 57600 baud. */ - NRF_UART_BAUDRATE_76800 = UART_BAUDRATE_BAUDRATE_Baud76800, /**< 76800 baud. */ - NRF_UART_BAUDRATE_115200 = UART_BAUDRATE_BAUDRATE_Baud115200, /**< 115200 baud. */ - NRF_UART_BAUDRATE_230400 = UART_BAUDRATE_BAUDRATE_Baud230400, /**< 230400 baud. */ - NRF_UART_BAUDRATE_250000 = UART_BAUDRATE_BAUDRATE_Baud250000, /**< 250000 baud. */ - NRF_UART_BAUDRATE_460800 = UART_BAUDRATE_BAUDRATE_Baud460800, /**< 460800 baud. */ - NRF_UART_BAUDRATE_921600 = UART_BAUDRATE_BAUDRATE_Baud921600, /**< 921600 baud. */ - NRF_UART_BAUDRATE_1000000 = UART_BAUDRATE_BAUDRATE_Baud1M, /**< 1000000 baud. */ -#endif -} nrf_uart_baudrate_t; - -/** - * @enum nrf_uart_error_mask_t - * @brief Types of UART error masks. - */ -typedef enum -{ - NRF_UART_ERROR_OVERRUN_MASK = UART_ERRORSRC_OVERRUN_Msk, /**< Overrun error. */ - NRF_UART_ERROR_PARITY_MASK = UART_ERRORSRC_PARITY_Msk, /**< Parity error. */ - NRF_UART_ERROR_FRAMING_MASK = UART_ERRORSRC_FRAMING_Msk, /**< Framing error. */ - NRF_UART_ERROR_BREAK_MASK = UART_ERRORSRC_BREAK_Msk, /**< Break error. */ -} nrf_uart_error_mask_t; - -/** - * @enum nrf_uart_parity_t - * @brief Types of UART parity modes. - */ -typedef enum -{ - NRF_UART_PARITY_EXCLUDED = UART_CONFIG_PARITY_Excluded << UART_CONFIG_PARITY_Pos, /**< Parity excluded. */ - NRF_UART_PARITY_INCLUDED = UART_CONFIG_PARITY_Included << UART_CONFIG_PARITY_Pos, /**< Parity included. */ -} nrf_uart_parity_t; - -/** - * @enum nrf_uart_hwfc_t - * @brief Types of UART flow control modes. - */ -typedef enum -{ - NRF_UART_HWFC_DISABLED = UART_CONFIG_HWFC_Disabled, /**< HW flow control disabled. */ - NRF_UART_HWFC_ENABLED = UART_CONFIG_HWFC_Enabled, /**< HW flow control enabled. */ -} nrf_uart_hwfc_t; - -/** - * @brief Function for clearing a specific UART event. - * - * @param[in] p_reg UART instance. - * @param[in] event Event to clear. - */ -__STATIC_INLINE void nrf_uart_event_clear(NRF_UART_Type * p_reg, nrf_uart_event_t event); - -/** - * @brief Function for checking the state of a specific UART event. - * - * @param[in] p_reg UART instance. - * @param[in] event Event to check. - * - * @retval True if event is set, False otherwise. - */ -__STATIC_INLINE bool nrf_uart_event_check(NRF_UART_Type * p_reg, nrf_uart_event_t event); - -/** - * @brief Function for returning the address of a specific UART event register. - * - * @param[in] p_reg UART instance. - * @param[in] event Desired event. - * - * @retval Address of specified event register. - */ -__STATIC_INLINE uint32_t nrf_uart_event_address_get(NRF_UART_Type * p_reg, - nrf_uart_event_t event); - -/** - * @brief Function for enabling a specific interrupt. - * - * @param p_reg Instance. - * @param int_mask Interrupts to enable. - */ -__STATIC_INLINE void nrf_uart_int_enable(NRF_UART_Type * p_reg, uint32_t int_mask); - -/** - * @brief Function for retrieving the state of a given interrupt. - * - * @param p_reg Instance. - * @param int_mask Mask of interrupt to check. - * - * @retval true If the interrupt is enabled. - * @retval false If the interrupt is not enabled. - */ -__STATIC_INLINE bool nrf_uart_int_enable_check(NRF_UART_Type * p_reg, uint32_t int_mask); - -/** - * @brief Function for disabling specific interrupts. - * - * @param p_reg Instance. - * @param int_mask Interrupts to disable. - */ -__STATIC_INLINE void nrf_uart_int_disable(NRF_UART_Type * p_reg, uint32_t int_mask); - -/** - * @brief Function for getting error source mask. Function is clearing error source flags after reading. - * - * @param p_reg Instance. - * @return Mask with error source flags. - */ -__STATIC_INLINE uint32_t nrf_uart_errorsrc_get_and_clear(NRF_UART_Type * p_reg); - -/** - * @brief Function for enabling UART. - * - * @param p_reg Instance. - */ -__STATIC_INLINE void nrf_uart_enable(NRF_UART_Type * p_reg); - -/** - * @brief Function for disabling UART. - * - * @param p_reg Instance. - */ -__STATIC_INLINE void nrf_uart_disable(NRF_UART_Type * p_reg); - -/** - * @brief Function for configuring TX/RX pins. - * - * @param p_reg Instance. - * @param pseltxd TXD pin number. - * @param pselrxd RXD pin number. - */ -__STATIC_INLINE void nrf_uart_txrx_pins_set(NRF_UART_Type * p_reg, uint32_t pseltxd, uint32_t pselrxd); - -/** - * @brief Function for disconnecting TX/RX pins. - * - * @param p_reg Instance. - */ -__STATIC_INLINE void nrf_uart_txrx_pins_disconnect(NRF_UART_Type * p_reg); - -/** - * @brief Function for getting TX pin. - * - * @param p_reg Instance. - */ -__STATIC_INLINE uint32_t nrf_uart_tx_pin_get(NRF_UART_Type * p_reg); - -/** - * @brief Function for getting RX pin. - * - * @param p_reg Instance. - */ -__STATIC_INLINE uint32_t nrf_uart_rx_pin_get(NRF_UART_Type * p_reg); - -/** - * @brief Function for getting RTS pin. - * - * @param p_reg Instance. - */ -__STATIC_INLINE uint32_t nrf_uart_rts_pin_get(NRF_UART_Type * p_reg); - -/** - * @brief Function for getting CTS pin. - * - * @param p_reg Instance. - */ -__STATIC_INLINE uint32_t nrf_uart_cts_pin_get(NRF_UART_Type * p_reg); - - -/** - * @brief Function for configuring flow control pins. - * - * @param p_reg Instance. - * @param pselrts RTS pin number. - * @param pselcts CTS pin number. - */ -__STATIC_INLINE void nrf_uart_hwfc_pins_set(NRF_UART_Type * p_reg, - uint32_t pselrts, - uint32_t pselcts); - -/** - * @brief Function for disconnecting flow control pins. - * - * @param p_reg Instance. - */ -__STATIC_INLINE void nrf_uart_hwfc_pins_disconnect(NRF_UART_Type * p_reg); - -/** - * @brief Function for reading RX data. - * - * @param p_reg Instance. - * @return Received byte. - */ -__STATIC_INLINE uint8_t nrf_uart_rxd_get(NRF_UART_Type * p_reg); - -/** - * @brief Function for setting Tx data. - * - * @param p_reg Instance. - * @param txd Byte. - */ -__STATIC_INLINE void nrf_uart_txd_set(NRF_UART_Type * p_reg, uint8_t txd); - -/** - * @brief Function for starting an UART task. - * - * @param p_reg Instance. - * @param task Task. - */ -__STATIC_INLINE void nrf_uart_task_trigger(NRF_UART_Type * p_reg, nrf_uart_task_t task); - -/** - * @brief Function for returning the address of a specific task register. - * - * @param p_reg Instance. - * @param task Task. - * - * @return Task address. - */ -__STATIC_INLINE uint32_t nrf_uart_task_address_get(NRF_UART_Type * p_reg, nrf_uart_task_t task); - -/** - * @brief Function for configuring UART. - * - * @param p_reg Instance. - * @param hwfc Hardware flow control. Enabled if true. - * @param parity Parity. Included if true. - */ -__STATIC_INLINE void nrf_uart_configure(NRF_UART_Type * p_reg, - nrf_uart_parity_t parity, - nrf_uart_hwfc_t hwfc); - -/** - * @brief Function for setting UART baudrate. - * - * @param p_reg Instance. - * @param baudrate Baudrate. - */ -__STATIC_INLINE void nrf_uart_baudrate_set(NRF_UART_Type * p_reg, nrf_uart_baudrate_t baudrate); - -#ifndef SUPPRESS_INLINE_IMPLEMENTATION -__STATIC_INLINE void nrf_uart_event_clear(NRF_UART_Type * p_reg, nrf_uart_event_t event) -{ - *((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event)) = 0x0UL; - -} - -__STATIC_INLINE bool nrf_uart_event_check(NRF_UART_Type * p_reg, nrf_uart_event_t event) -{ - return (bool)*(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event); -} - -__STATIC_INLINE uint32_t nrf_uart_event_address_get(NRF_UART_Type * p_reg, - nrf_uart_event_t event) -{ - return (uint32_t)((uint8_t *)p_reg + (uint32_t)event); -} - -__STATIC_INLINE void nrf_uart_int_enable(NRF_UART_Type * p_reg, uint32_t int_mask) -{ - p_reg->INTENSET = int_mask; -} - -__STATIC_INLINE bool nrf_uart_int_enable_check(NRF_UART_Type * p_reg, uint32_t int_mask) -{ - return (bool)(p_reg->INTENSET & int_mask); -} - -__STATIC_INLINE void nrf_uart_int_disable(NRF_UART_Type * p_reg, uint32_t int_mask) -{ - p_reg->INTENCLR = int_mask; -} - -__STATIC_INLINE uint32_t nrf_uart_errorsrc_get_and_clear(NRF_UART_Type * p_reg) -{ - uint32_t errsrc_mask = p_reg->ERRORSRC; - p_reg->ERRORSRC = errsrc_mask; - return errsrc_mask; -} - -__STATIC_INLINE void nrf_uart_enable(NRF_UART_Type * p_reg) -{ - p_reg->ENABLE = UART_ENABLE_ENABLE_Enabled; -} - -__STATIC_INLINE void nrf_uart_disable(NRF_UART_Type * p_reg) -{ - p_reg->ENABLE = UART_ENABLE_ENABLE_Disabled; -} - -__STATIC_INLINE void nrf_uart_txrx_pins_set(NRF_UART_Type * p_reg, uint32_t pseltxd, uint32_t pselrxd) -{ - p_reg->PSELTXD = pseltxd; - p_reg->PSELRXD = pselrxd; -} - -__STATIC_INLINE void nrf_uart_txrx_pins_disconnect(NRF_UART_Type * p_reg) -{ - nrf_uart_txrx_pins_set(p_reg, NRF_UART_PSEL_DISCONNECTED, NRF_UART_PSEL_DISCONNECTED); -} - -__STATIC_INLINE uint32_t nrf_uart_tx_pin_get(NRF_UART_Type * p_reg) -{ - return p_reg->PSELTXD; -} - -__STATIC_INLINE uint32_t nrf_uart_rx_pin_get(NRF_UART_Type * p_reg) -{ - return p_reg->PSELRXD; -} - -__STATIC_INLINE uint32_t nrf_uart_rts_pin_get(NRF_UART_Type * p_reg) -{ - return p_reg->PSELRTS; -} - -__STATIC_INLINE uint32_t nrf_uart_cts_pin_get(NRF_UART_Type * p_reg) -{ - return p_reg->PSELCTS; -} - -__STATIC_INLINE void nrf_uart_hwfc_pins_set(NRF_UART_Type * p_reg, uint32_t pselrts, uint32_t pselcts) -{ - p_reg->PSELRTS = pselrts; - p_reg->PSELCTS = pselcts; -} - -__STATIC_INLINE void nrf_uart_hwfc_pins_disconnect(NRF_UART_Type * p_reg) -{ - nrf_uart_hwfc_pins_set(p_reg, NRF_UART_PSEL_DISCONNECTED, NRF_UART_PSEL_DISCONNECTED); -} - -__STATIC_INLINE uint8_t nrf_uart_rxd_get(NRF_UART_Type * p_reg) -{ - return p_reg->RXD; -} - -__STATIC_INLINE void nrf_uart_txd_set(NRF_UART_Type * p_reg, uint8_t txd) -{ - p_reg->TXD = txd; -} - -__STATIC_INLINE void nrf_uart_task_trigger(NRF_UART_Type * p_reg, nrf_uart_task_t task) -{ - *((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)task)) = 0x1UL; -} - -__STATIC_INLINE uint32_t nrf_uart_task_address_get(NRF_UART_Type * p_reg, nrf_uart_task_t task) -{ - return (uint32_t)p_reg + (uint32_t)task; -} - -__STATIC_INLINE void nrf_uart_configure(NRF_UART_Type * p_reg, - nrf_uart_parity_t parity, - nrf_uart_hwfc_t hwfc) -{ - p_reg->CONFIG = (uint32_t)parity | (uint32_t)hwfc; -} - -__STATIC_INLINE void nrf_uart_baudrate_set(NRF_UART_Type * p_reg, nrf_uart_baudrate_t baudrate) -{ - p_reg->BAUDRATE = baudrate; -} -#endif //SUPPRESS_INLINE_IMPLEMENTATION -/** @} */ -#ifdef __cplusplus -} -#endif - -#endif //NRF_UART_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/hal/nrf_uarte.h ---------------------------------------------------------------------- diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/hal/nrf_uarte.h b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/hal/nrf_uarte.h deleted file mode 100644 index b1c560d..0000000 --- a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/hal/nrf_uarte.h +++ /dev/null @@ -1,542 +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_UARTE_H__ -#define NRF_UARTE_H__ - -#include "nrf.h" -#include <stdint.h> -#include <stddef.h> -#include <stdbool.h> - -#ifdef __cplusplus -extern "C" { -#endif - -#define NRF_UARTE_PSEL_DISCONNECTED 0xFFFFFFFF - -/** - * @defgroup nrf_uarte_hal UARTE HAL - * @{ - * @ingroup nrf_uart - * - * @brief Hardware access layer for accessing the UARTE peripheral. - */ - -/** - * @enum nrf_uarte_task_t - * @brief UARTE tasks. - */ -typedef enum -{ - /*lint -save -e30*/ - NRF_UARTE_TASK_STARTRX = offsetof(NRF_UARTE_Type, TASKS_STARTRX),///< Start UART receiver. - NRF_UARTE_TASK_STOPRX = offsetof(NRF_UARTE_Type, TASKS_STOPRX), ///< Stop UART receiver. - NRF_UARTE_TASK_STARTTX = offsetof(NRF_UARTE_Type, TASKS_STARTTX),///< Start UART transmitter. - NRF_UARTE_TASK_STOPTX = offsetof(NRF_UARTE_Type, TASKS_STOPTX), ///< Stop UART transmitter. - NRF_UARTE_TASK_FLUSHRX = offsetof(NRF_UARTE_Type, TASKS_FLUSHRX) ///< Flush RX FIFO in RX buffer. - /*lint -restore*/ -} nrf_uarte_task_t; - -/** - * @enum nrf_uarte_event_t - * @brief UARTE events. - */ -typedef enum -{ - /*lint -save -e30*/ - NRF_UARTE_EVENT_CTS = offsetof(NRF_UARTE_Type, EVENTS_CTS), ///< CTS is activated. - NRF_UARTE_EVENT_NCTS = offsetof(NRF_UARTE_Type, EVENTS_NCTS), ///< CTS is deactivated. - NRF_UARTE_EVENT_ENDRX = offsetof(NRF_UARTE_Type, EVENTS_ENDRX), ///< Receive buffer is filled up. - NRF_UARTE_EVENT_ENDTX = offsetof(NRF_UARTE_Type, EVENTS_ENDTX), ///< Last TX byte transmitted. - NRF_UARTE_EVENT_ERROR = offsetof(NRF_UARTE_Type, EVENTS_ERROR), ///< Error detected. - NRF_UARTE_EVENT_RXTO = offsetof(NRF_UARTE_Type, EVENTS_RXTO), ///< Receiver timeout. - NRF_UARTE_EVENT_RXSTARTED = offsetof(NRF_UARTE_Type, EVENTS_RXSTARTED),///< Receiver has started. - NRF_UARTE_EVENT_TXSTARTED = offsetof(NRF_UARTE_Type, EVENTS_TXSTARTED),///< Transmitter has started. - NRF_UARTE_EVENT_TXSTOPPED = offsetof(NRF_UARTE_Type, EVENTS_TXSTOPPED) ///< Transmitted stopped. - /*lint -restore*/ -} nrf_uarte_event_t; - -/** - * @brief Types of UARTE shortcuts. - */ -typedef enum -{ - NRF_UARTE_SHORT_ENDRX_STARTRX = UARTE_SHORTS_ENDRX_STARTRX_Msk,///< Shortcut between ENDRX event and STARTRX task. - NRF_UARTE_SHORT_ENDRX_STOPRX = UARTE_SHORTS_ENDRX_STOPRX_Msk, ///< Shortcut between ENDRX event and STOPRX task. -} nrf_uarte_short_t; - - -/** - * @enum nrf_uarte_int_mask_t - * @brief UARTE interrupts. - */ -typedef enum -{ - NRF_UARTE_INT_CTS_MASK = UARTE_INTENSET_CTS_Msk, ///< Interrupt on CTS event. - NRF_UARTE_INT_NCTSRX_MASK = UARTE_INTENSET_NCTS_Msk, ///< Interrupt on NCTS event. - NRF_UARTE_INT_ENDRX_MASK = UARTE_INTENSET_ENDRX_Msk, ///< Interrupt on ENDRX event. - NRF_UARTE_INT_ENDTX_MASK = UARTE_INTENSET_ENDTX_Msk, ///< Interrupt on ENDTX event. - NRF_UARTE_INT_ERROR_MASK = UARTE_INTENSET_ERROR_Msk, ///< Interrupt on ERROR event. - NRF_UARTE_INT_RXTO_MASK = UARTE_INTENSET_RXTO_Msk, ///< Interrupt on RXTO event. - NRF_UARTE_INT_RXSTARTED_MASK = UARTE_INTENSET_RXSTARTED_Msk,///< Interrupt on RXSTARTED event. - NRF_UARTE_INT_TXSTARTED_MASK = UARTE_INTENSET_TXSTARTED_Msk,///< Interrupt on TXSTARTED event. - NRF_UARTE_INT_TXSTOPPED_MASK = UARTE_INTENSET_TXSTOPPED_Msk ///< Interrupt on TXSTOPPED event. -} nrf_uarte_int_mask_t; - -/** - * @enum nrf_uarte_baudrate_t - * @brief Baudrates supported by UARTE. - */ -typedef enum -{ - NRF_UARTE_BAUDRATE_1200 = UARTE_BAUDRATE_BAUDRATE_Baud1200, ///< 1200 baud. - NRF_UARTE_BAUDRATE_2400 = UARTE_BAUDRATE_BAUDRATE_Baud2400, ///< 2400 baud. - NRF_UARTE_BAUDRATE_4800 = UARTE_BAUDRATE_BAUDRATE_Baud4800, ///< 4800 baud. - NRF_UARTE_BAUDRATE_9600 = UARTE_BAUDRATE_BAUDRATE_Baud9600, ///< 9600 baud. - NRF_UARTE_BAUDRATE_14400 = UARTE_BAUDRATE_BAUDRATE_Baud14400, ///< 14400 baud. - NRF_UARTE_BAUDRATE_19200 = UARTE_BAUDRATE_BAUDRATE_Baud19200, ///< 19200 baud. - NRF_UARTE_BAUDRATE_28800 = UARTE_BAUDRATE_BAUDRATE_Baud28800, ///< 28800 baud. - NRF_UARTE_BAUDRATE_38400 = UARTE_BAUDRATE_BAUDRATE_Baud38400, ///< 38400 baud. - NRF_UARTE_BAUDRATE_57600 = UARTE_BAUDRATE_BAUDRATE_Baud57600, ///< 57600 baud. - NRF_UARTE_BAUDRATE_76800 = UARTE_BAUDRATE_BAUDRATE_Baud76800, ///< 76800 baud. - NRF_UARTE_BAUDRATE_115200 = UARTE_BAUDRATE_BAUDRATE_Baud115200, ///< 115200 baud. - NRF_UARTE_BAUDRATE_230400 = UARTE_BAUDRATE_BAUDRATE_Baud230400, ///< 230400 baud. - NRF_UARTE_BAUDRATE_250000 = UARTE_BAUDRATE_BAUDRATE_Baud250000, ///< 250000 baud. - NRF_UARTE_BAUDRATE_460800 = UARTE_BAUDRATE_BAUDRATE_Baud460800, ///< 460800 baud. - NRF_UARTE_BAUDRATE_921600 = UARTE_BAUDRATE_BAUDRATE_Baud921600, ///< 921600 baud. - NRF_UARTE_BAUDRATE_1000000 = UARTE_BAUDRATE_BAUDRATE_Baud1M, ///< 1000000 baud. -} nrf_uarte_baudrate_t; - -/** - * @enum nrf_uarte_error_mask_t - * @brief Types of UARTE error masks. - */ -typedef enum -{ - NRF_UARTE_ERROR_OVERRUN_MASK = UARTE_ERRORSRC_OVERRUN_Msk, ///< Overrun error. - NRF_UARTE_ERROR_PARITY_MASK = UARTE_ERRORSRC_PARITY_Msk, ///< Parity error. - NRF_UARTE_ERROR_FRAMING_MASK = UARTE_ERRORSRC_FRAMING_Msk, ///< Framing error. - NRF_UARTE_ERROR_BREAK_MASK = UARTE_ERRORSRC_BREAK_Msk, ///< Break error. -} nrf_uarte_error_mask_t; - -/** - * @enum nrf_uarte_parity_t - * @brief Types of UARTE parity modes. - */ -typedef enum -{ - NRF_UARTE_PARITY_EXCLUDED = UARTE_CONFIG_PARITY_Excluded << UARTE_CONFIG_PARITY_Pos, ///< Parity excluded. - NRF_UARTE_PARITY_INCLUDED = UARTE_CONFIG_PARITY_Included << UARTE_CONFIG_PARITY_Pos, ///< Parity included. -} nrf_uarte_parity_t; - -/** - * @enum nrf_uarte_hwfc_t - * @brief Types of UARTE flow control modes. - */ -typedef enum -{ - NRF_UARTE_HWFC_DISABLED = UARTE_CONFIG_HWFC_Disabled << UARTE_CONFIG_HWFC_Pos, ///< HW flow control disabled. - NRF_UARTE_HWFC_ENABLED = UARTE_CONFIG_HWFC_Enabled << UARTE_CONFIG_HWFC_Pos, ///< HW flow control enabled. -} nrf_uarte_hwfc_t; - - -/** - * @brief Function for clearing a specific UARTE event. - * - * @param[in] p_reg UARTE instance. - * @param[in] event Event to clear. - */ -__STATIC_INLINE void nrf_uarte_event_clear(NRF_UARTE_Type * p_reg, nrf_uarte_event_t event); - -/** - * @brief Function for checking the state of a specific UARTE event. - * - * @param[in] p_reg UARTE instance. - * @param[in] event Event to check. - * - * @retval True if event is set, False otherwise. - */ -__STATIC_INLINE bool nrf_uarte_event_check(NRF_UARTE_Type * p_reg, nrf_uarte_event_t event); - -/** - * @brief Function for returning the address of a specific UARTE event register. - * - * @param[in] p_reg UARTE instance. - * @param[in] event Desired event. - * - * @retval Address of specified event register. - */ -__STATIC_INLINE uint32_t nrf_uarte_event_address_get(NRF_UARTE_Type * p_reg, - nrf_uarte_event_t event); - -/** - * @brief Function for enabling UARTE shortcuts. - * - * @param p_reg UARTE instance. - * @param shorts_mask Shortcuts to enable. - */ -__STATIC_INLINE void nrf_uarte_shorts_enable(NRF_UARTE_Type * p_reg, uint32_t shorts_mask); - -/** - * @brief Function for disabling UARTE shortcuts. - * - * @param p_reg UARTE instance. - * @param shorts_mask Shortcuts to disable. - */ -__STATIC_INLINE void nrf_uarte_shorts_disable(NRF_UARTE_Type * p_reg, uint32_t shorts_mask); - -/** - * @brief Function for enabling UARTE interrupts. - * - * @param p_reg Instance. - * @param int_mask Interrupts to enable. - */ -__STATIC_INLINE void nrf_uarte_int_enable(NRF_UARTE_Type * p_reg, uint32_t int_mask); - -/** - * @brief Function for retrieving the state of a given interrupt. - * - * @param p_reg Instance. - * @param int_mask Mask of interrupt to check. - * - * @retval true If the interrupt is enabled. - * @retval false If the interrupt is not enabled. - */ -__STATIC_INLINE bool nrf_uarte_int_enable_check(NRF_UARTE_Type * p_reg, nrf_uarte_int_mask_t int_mask); - -/** - * @brief Function for disabling specific interrupts. - * - * @param p_reg Instance. - * @param int_mask Interrupts to disable. - */ -__STATIC_INLINE void nrf_uarte_int_disable(NRF_UARTE_Type * p_reg, uint32_t int_mask); - -/** - * @brief Function for getting error source mask. Function is clearing error source flags after reading. - * - * @param p_reg Instance. - * @return Mask with error source flags. - */ -__STATIC_INLINE uint32_t nrf_uarte_errorsrc_get_and_clear(NRF_UARTE_Type * p_reg); - -/** - * @brief Function for enabling UARTE. - * - * @param p_reg Instance. - */ -__STATIC_INLINE void nrf_uarte_enable(NRF_UARTE_Type * p_reg); - -/** - * @brief Function for disabling UARTE. - * - * @param p_reg Instance. - */ -__STATIC_INLINE void nrf_uarte_disable(NRF_UARTE_Type * p_reg); - -/** - * @brief Function for configuring TX/RX pins. - * - * @param p_reg Instance. - * @param pseltxd TXD pin number. - * @param pselrxd RXD pin number. - */ -__STATIC_INLINE void nrf_uarte_txrx_pins_set(NRF_UARTE_Type * p_reg, uint32_t pseltxd, uint32_t pselrxd); - -/** - * @brief Function for disconnecting TX/RX pins. - * - * @param p_reg Instance. - */ -__STATIC_INLINE void nrf_uarte_txrx_pins_disconnect(NRF_UARTE_Type * p_reg); - -/** - * @brief Function for getting TX pin. - * - * @param p_reg Instance. - */ -__STATIC_INLINE uint32_t nrf_uarte_tx_pin_get(NRF_UARTE_Type * p_reg); - -/** - * @brief Function for getting RX pin. - * - * @param p_reg Instance. - */ -__STATIC_INLINE uint32_t nrf_uarte_rx_pin_get(NRF_UARTE_Type * p_reg); - -/** - * @brief Function for getting RTS pin. - * - * @param p_reg Instance. - */ -__STATIC_INLINE uint32_t nrf_uarte_rts_pin_get(NRF_UARTE_Type * p_reg); - -/** - * @brief Function for getting CTS pin. - * - * @param p_reg Instance. - */ -__STATIC_INLINE uint32_t nrf_uarte_cts_pin_get(NRF_UARTE_Type * p_reg); - - -/** - * @brief Function for configuring flow control pins. - * - * @param p_reg Instance. - * @param pselrts RTS pin number. - * @param pselcts CTS pin number. - */ -__STATIC_INLINE void nrf_uarte_hwfc_pins_set(NRF_UARTE_Type * p_reg, - uint32_t pselrts, - uint32_t pselcts); - -/** - * @brief Function for disconnecting flow control pins. - * - * @param p_reg Instance. - */ -__STATIC_INLINE void nrf_uarte_hwfc_pins_disconnect(NRF_UARTE_Type * p_reg); - -/** - * @brief Function for starting an UARTE task. - * - * @param p_reg Instance. - * @param task Task. - */ -__STATIC_INLINE void nrf_uarte_task_trigger(NRF_UARTE_Type * p_reg, nrf_uarte_task_t task); - -/** - * @brief Function for returning the address of a specific task register. - * - * @param p_reg Instance. - * @param task Task. - * - * @return Task address. - */ -__STATIC_INLINE uint32_t nrf_uarte_task_address_get(NRF_UARTE_Type * p_reg, nrf_uarte_task_t task); - -/** - * @brief Function for configuring UARTE. - * - * @param p_reg Instance. - * @param hwfc Hardware flow control. Enabled if true. - * @param parity Parity. Included if true. - */ -__STATIC_INLINE void nrf_uarte_configure(NRF_UARTE_Type * p_reg, - nrf_uarte_parity_t parity, - nrf_uarte_hwfc_t hwfc); - - -/** - * @brief Function for setting UARTE baudrate. - * - * @param p_reg Instance. - * @param baudrate Baudrate. - */ -__STATIC_INLINE void nrf_uarte_baudrate_set(NRF_UARTE_Type * p_reg, nrf_uarte_baudrate_t baudrate); - -/** - * @brief Function for setting the transmit buffer. - * - * @param[in] p_reg Instance. - * @param[in] p_buffer Pointer to the buffer with data to send. - * @param[in] length Maximum number of data bytes to transmit. - */ -__STATIC_INLINE void nrf_uarte_tx_buffer_set(NRF_UARTE_Type * p_reg, - uint8_t const * p_buffer, - uint8_t length); - -/** - * @brief Function for getting number of bytes transmitted in the last transaction. - * - * @param[in] p_reg Instance. - * - * @retval Amount of bytes transmitted. - */ -__STATIC_INLINE uint32_t nrf_uarte_tx_amount_get(NRF_UARTE_Type * p_reg); - -/** - * @brief Function for setting the receive buffer. - * - * @param[in] p_reg Instance. - * @param[in] p_buffer Pointer to the buffer for received data. - * @param[in] length Maximum number of data bytes to receive. - */ -__STATIC_INLINE void nrf_uarte_rx_buffer_set(NRF_UARTE_Type * p_reg, - uint8_t * p_buffer, - uint8_t length); - -/** - * @brief Function for getting number of bytes received in the last transaction. - * - * @param[in] p_reg Instance. - * - * @retval Amount of bytes received. - */ -__STATIC_INLINE uint32_t nrf_uarte_rx_amount_get(NRF_UARTE_Type * p_reg); - -#ifndef SUPPRESS_INLINE_IMPLEMENTATION -__STATIC_INLINE void nrf_uarte_event_clear(NRF_UARTE_Type * p_reg, nrf_uarte_event_t event) -{ - *((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event)) = 0x0UL; - -} - -__STATIC_INLINE bool nrf_uarte_event_check(NRF_UARTE_Type * p_reg, nrf_uarte_event_t event) -{ - return (bool)*(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event); -} - -__STATIC_INLINE uint32_t nrf_uarte_event_address_get(NRF_UARTE_Type * p_reg, - nrf_uarte_event_t event) -{ - return (uint32_t)((uint8_t *)p_reg + (uint32_t)event); -} - -__STATIC_INLINE void nrf_uarte_shorts_enable(NRF_UARTE_Type * p_reg, uint32_t shorts_mask) -{ - p_reg->SHORTS |= shorts_mask; -} - -__STATIC_INLINE void nrf_uarte_shorts_disable(NRF_UARTE_Type * p_reg, uint32_t shorts_mask) -{ - p_reg->SHORTS &= ~(shorts_mask); -} - -__STATIC_INLINE void nrf_uarte_int_enable(NRF_UARTE_Type * p_reg, uint32_t int_mask) -{ - p_reg->INTENSET = int_mask; -} - -__STATIC_INLINE bool nrf_uarte_int_enable_check(NRF_UARTE_Type * p_reg, nrf_uarte_int_mask_t int_mask) -{ - return (bool)(p_reg->INTENSET & int_mask); -} - -__STATIC_INLINE void nrf_uarte_int_disable(NRF_UARTE_Type * p_reg, uint32_t int_mask) -{ - p_reg->INTENCLR = int_mask; -} - -__STATIC_INLINE uint32_t nrf_uarte_errorsrc_get_and_clear(NRF_UARTE_Type * p_reg) -{ - uint32_t errsrc_mask = p_reg->ERRORSRC; - p_reg->ERRORSRC = errsrc_mask; - return errsrc_mask; -} - -__STATIC_INLINE void nrf_uarte_enable(NRF_UARTE_Type * p_reg) -{ - p_reg->ENABLE = UARTE_ENABLE_ENABLE_Enabled; -} - -__STATIC_INLINE void nrf_uarte_disable(NRF_UARTE_Type * p_reg) -{ - p_reg->ENABLE = UARTE_ENABLE_ENABLE_Disabled; -} - -__STATIC_INLINE void nrf_uarte_txrx_pins_set(NRF_UARTE_Type * p_reg, uint32_t pseltxd, uint32_t pselrxd) -{ - p_reg->PSEL.TXD = pseltxd; - p_reg->PSEL.RXD = pselrxd; -} - -__STATIC_INLINE void nrf_uarte_txrx_pins_disconnect(NRF_UARTE_Type * p_reg) -{ - nrf_uarte_txrx_pins_set(p_reg, NRF_UARTE_PSEL_DISCONNECTED, NRF_UARTE_PSEL_DISCONNECTED); -} - -__STATIC_INLINE uint32_t nrf_uarte_tx_pin_get(NRF_UARTE_Type * p_reg) -{ - return p_reg->PSEL.TXD; -} - -__STATIC_INLINE uint32_t nrf_uarte_rx_pin_get(NRF_UARTE_Type * p_reg) -{ - return p_reg->PSEL.RXD; -} - -__STATIC_INLINE uint32_t nrf_uarte_rts_pin_get(NRF_UARTE_Type * p_reg) -{ - return p_reg->PSEL.RTS; -} - -__STATIC_INLINE uint32_t nrf_uarte_cts_pin_get(NRF_UARTE_Type * p_reg) -{ - return p_reg->PSEL.CTS; -} - -__STATIC_INLINE void nrf_uarte_hwfc_pins_set(NRF_UARTE_Type * p_reg, uint32_t pselrts, uint32_t pselcts) -{ - p_reg->PSEL.RTS = pselrts; - p_reg->PSEL.CTS = pselcts; -} - -__STATIC_INLINE void nrf_uarte_hwfc_pins_disconnect(NRF_UARTE_Type * p_reg) -{ - nrf_uarte_hwfc_pins_set(p_reg, NRF_UARTE_PSEL_DISCONNECTED, NRF_UARTE_PSEL_DISCONNECTED); -} - -__STATIC_INLINE void nrf_uarte_task_trigger(NRF_UARTE_Type * p_reg, nrf_uarte_task_t task) -{ - *((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)task)) = 0x1UL; -} - -__STATIC_INLINE uint32_t nrf_uarte_task_address_get(NRF_UARTE_Type * p_reg, nrf_uarte_task_t task) -{ - return (uint32_t)p_reg + (uint32_t)task; -} - -__STATIC_INLINE void nrf_uarte_configure(NRF_UARTE_Type * p_reg, - nrf_uarte_parity_t parity, - nrf_uarte_hwfc_t hwfc) -{ - p_reg->CONFIG = (uint32_t)parity | (uint32_t)hwfc; -} - -__STATIC_INLINE void nrf_uarte_baudrate_set(NRF_UARTE_Type * p_reg, nrf_uarte_baudrate_t baudrate) -{ - p_reg->BAUDRATE = baudrate; -} - -__STATIC_INLINE void nrf_uarte_tx_buffer_set(NRF_UARTE_Type * p_reg, - uint8_t const * p_buffer, - uint8_t length) -{ - p_reg->TXD.PTR = (uint32_t)p_buffer; - p_reg->TXD.MAXCNT = length; -} - -__STATIC_INLINE uint32_t nrf_uarte_tx_amount_get(NRF_UARTE_Type * p_reg) -{ - return p_reg->TXD.AMOUNT; -} - -__STATIC_INLINE void nrf_uarte_rx_buffer_set(NRF_UARTE_Type * p_reg, - uint8_t * p_buffer, - uint8_t length) -{ - p_reg->RXD.PTR = (uint32_t)p_buffer; - p_reg->RXD.MAXCNT = length; -} - -__STATIC_INLINE uint32_t nrf_uarte_rx_amount_get(NRF_UARTE_Type * p_reg) -{ - return p_reg->RXD.AMOUNT; -} -#endif //SUPPRESS_INLINE_IMPLEMENTATION -/** @} */ -#ifdef __cplusplus -} -#endif - -#endif //NRF_UARTE_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/hal/nrf_wdt.h ---------------------------------------------------------------------- diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/hal/nrf_wdt.h b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/hal/nrf_wdt.h deleted file mode 100644 index 63bc2fb..0000000 --- a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/drivers_nrf/hal/nrf_wdt.h +++ /dev/null @@ -1,307 +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. - * - */ - -/** - * @defgroup nrf_wdt_hal WDT HAL - * @{ - * @ingroup nrf_wdt - * - * @brief Hardware access layer for accessing the watchdog timer (WDT) peripheral. - */ - -#ifndef NRF_WDT_H__ -#define NRF_WDT_H__ - -#include <stddef.h> -#include <stdbool.h> -#include <stdint.h> - -#include "nrf.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define NRF_WDT_CHANNEL_NUMBER 0x8UL -#define NRF_WDT_RR_VALUE 0x6E524635UL /* Fixed value, shouldn't be modified.*/ - -#define NRF_WDT_TASK_SET 1UL -#define NRF_WDT_EVENT_CLEAR 0UL - -/** - * @enum nrf_wdt_task_t - * @brief WDT tasks. - */ -typedef enum -{ - /*lint -save -e30 -esym(628,__INTADDR__)*/ - NRF_WDT_TASK_START = offsetof(NRF_WDT_Type, TASKS_START), /**< Task for starting WDT. */ - /*lint -restore*/ -} nrf_wdt_task_t; - -/** - * @enum nrf_wdt_event_t - * @brief WDT events. - */ -typedef enum -{ - /*lint -save -e30*/ - NRF_WDT_EVENT_TIMEOUT = offsetof(NRF_WDT_Type, EVENTS_TIMEOUT), /**< Event from WDT time-out. */ - /*lint -restore*/ -} nrf_wdt_event_t; - -/** - * @enum nrf_wdt_behaviour_t - * @brief WDT behavior in CPU SLEEP or HALT mode. - */ -typedef enum -{ - NRF_WDT_BEHAVIOUR_RUN_SLEEP = WDT_CONFIG_SLEEP_Msk, /**< WDT will run when CPU is in SLEEP mode. */ - NRF_WDT_BEHAVIOUR_RUN_HALT = WDT_CONFIG_HALT_Msk, /**< WDT will run when CPU is in HALT mode. */ - NRF_WDT_BEHAVIOUR_RUN_SLEEP_HALT = WDT_CONFIG_SLEEP_Msk | WDT_CONFIG_HALT_Msk, /**< WDT will run when CPU is in SLEEP or HALT mode. */ - NRF_WDT_BEHAVIOUR_PAUSE_SLEEP_HALT = 0, /**< WDT will be paused when CPU is in SLEEP or HALT mode. */ -} nrf_wdt_behaviour_t; - -/** - * @enum nrf_wdt_rr_register_t - * @brief WDT reload request registers. - */ -typedef enum -{ - NRF_WDT_RR0 = 0, /**< Reload request register 0. */ - NRF_WDT_RR1, /**< Reload request register 1. */ - NRF_WDT_RR2, /**< Reload request register 2. */ - NRF_WDT_RR3, /**< Reload request register 3. */ - NRF_WDT_RR4, /**< Reload request register 4. */ - NRF_WDT_RR5, /**< Reload request register 5. */ - NRF_WDT_RR6, /**< Reload request register 6. */ - NRF_WDT_RR7 /**< Reload request register 7. */ -} nrf_wdt_rr_register_t; - -/** - * @enum nrf_wdt_int_mask_t - * @brief WDT interrupts. - */ -typedef enum -{ - NRF_WDT_INT_TIMEOUT_MASK = WDT_INTENSET_TIMEOUT_Msk, /**< WDT interrupt from time-out event. */ -} nrf_wdt_int_mask_t; - -/** - * @brief Function for configuring the watchdog behavior when the CPU is sleeping or halted. - * - * @param behaviour Watchdog behavior when CPU is in SLEEP or HALT mode. - */ -__STATIC_INLINE void nrf_wdt_behaviour_set(nrf_wdt_behaviour_t behaviour) -{ - NRF_WDT->CONFIG = behaviour; -} - - -/** - * @brief Function for starting the watchdog. - * - * @param[in] task Task. - */ -__STATIC_INLINE void nrf_wdt_task_trigger(nrf_wdt_task_t task) -{ - *((volatile uint32_t *)((uint8_t *)NRF_WDT + task)) = NRF_WDT_TASK_SET; -} - - -/** - * @brief Function for clearing the WDT event. - * - * @param[in] event Event. - */ -__STATIC_INLINE void nrf_wdt_event_clear(nrf_wdt_event_t event) -{ - *((volatile uint32_t *)((uint8_t *)NRF_WDT + (uint32_t)event)) = NRF_WDT_EVENT_CLEAR; -} - - -/** - * @brief Function for retrieving the state of the WDT event. - * - * @param[in] event Event. - * - * @retval true If the event is set. - * @retval false If the event is not set. - */ -__STATIC_INLINE bool nrf_wdt_event_check(nrf_wdt_event_t event) -{ - return (bool)*((volatile uint32_t *)((uint8_t *)NRF_WDT + event)); -} - - -/** - * @brief Function for enabling a specific interrupt. - * - * @param[in] int_mask Interrupt. - */ -__STATIC_INLINE void nrf_wdt_int_enable(uint32_t int_mask) -{ - NRF_WDT->INTENSET = int_mask; -} - - -/** - * @brief Function for retrieving the state of given interrupt. - * - * @param[in] int_mask Interrupt. - * - * @retval true Interrupt is enabled. - * @retval false Interrupt is not enabled. - */ -__STATIC_INLINE bool nrf_wdt_int_enable_check(uint32_t int_mask) -{ - return (bool)(NRF_WDT->INTENSET & int_mask); -} - - -/** - * @brief Function for disabling a specific interrupt. - * - * @param[in] int_mask Interrupt. - */ -__STATIC_INLINE void nrf_wdt_int_disable(uint32_t int_mask) -{ - NRF_WDT->INTENCLR = int_mask; -} - - -/** - * @brief Function for returning the address of a specific WDT task register. - * - * @param[in] task Task. - */ -__STATIC_INLINE uint32_t nrf_wdt_task_address_get(nrf_wdt_task_t task) -{ - return ((uint32_t)NRF_WDT + task); -} - - -/** - * @brief Function for returning the address of a specific WDT event register. - * - * @param[in] event Event. - * - * @retval address of requested event register - */ -__STATIC_INLINE uint32_t nrf_wdt_event_address_get(nrf_wdt_event_t event) -{ - return ((uint32_t)NRF_WDT + event); -} - - -/** - * @brief Function for retrieving the watchdog status. - * - * @retval true If the watchdog is started. - * @retval false If the watchdog is not started. - */ -__STATIC_INLINE bool nrf_wdt_started(void) -{ - return (bool)(NRF_WDT->RUNSTATUS); -} - - -/** - * @brief Function for retrieving the watchdog reload request status. - * - * @param[in] rr_register Reload request register to check. - * - * @retval true If a reload request is running. - * @retval false If no reload request is running. - */ -__STATIC_INLINE bool nrf_wdt_request_status(nrf_wdt_rr_register_t rr_register) -{ - return (bool)(((NRF_WDT->REQSTATUS) >> rr_register) & 0x1UL); -} - - -/** - * @brief Function for setting the watchdog reload value. - * - * @param[in] reload_value Watchdog counter initial value. - */ -__STATIC_INLINE void nrf_wdt_reload_value_set(uint32_t reload_value) -{ - NRF_WDT->CRV = reload_value; -} - - -/** - * @brief Function for retrieving the watchdog reload value. - * - * @retval Reload value. - */ -__STATIC_INLINE uint32_t nrf_wdt_reload_value_get(void) -{ - return (uint32_t)NRF_WDT->CRV; -} - - -/** - * @brief Function for enabling a specific reload request register. - * - * @param[in] rr_register Reload request register to enable. - */ -__STATIC_INLINE void nrf_wdt_reload_request_enable(nrf_wdt_rr_register_t rr_register) -{ - NRF_WDT->RREN |= 0x1UL << rr_register; -} - - -/** - * @brief Function for disabling a specific reload request register. - * - * @param[in] rr_register Reload request register to disable. - */ -__STATIC_INLINE void nrf_wdt_reload_request_disable(nrf_wdt_rr_register_t rr_register) -{ - NRF_WDT->RREN &= ~(0x1UL << rr_register); -} - - -/** - * @brief Function for retrieving the status of a specific reload request register. - * - * @param[in] rr_register Reload request register to check. - * - * @retval true If the reload request register is enabled. - * @retval false If the reload request register is not enabled. - */ -__STATIC_INLINE bool nrf_wdt_reload_request_is_enabled(nrf_wdt_rr_register_t rr_register) -{ - return (bool)(NRF_WDT->RREN & (0x1UL << rr_register)); -} - - -/** - * @brief Function for setting a specific reload request register. - * - * @param[in] rr_register Reload request register to set. - */ -__STATIC_INLINE void nrf_wdt_reload_request_set(nrf_wdt_rr_register_t rr_register) -{ - NRF_WDT->RR[rr_register] = NRF_WDT_RR_VALUE; -} - - -#ifdef __cplusplus -} -#endif - -#endif - -/** @} */
