1 /* 2 * Copyright (c) 2021 - 2025, Nordic Semiconductor ASA 3 * All rights reserved. 4 * 5 * SPDX-License-Identifier: BSD-3-Clause 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions are met: 9 * 10 * 1. Redistributions of source code must retain the above copyright notice, this 11 * list of conditions and the following disclaimer. 12 * 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 17 * 3. Neither the name of the copyright holder nor the names of its 18 * contributors may be used to endorse or promote products derived from this 19 * software without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 25 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 * POSSIBILITY OF SUCH DAMAGE. 32 */ 33 34 #ifndef NRFX_BELLBOARD_H__ 35 #define NRFX_BELLBOARD_H__ 36 37 #include <nrfx.h> 38 #include <haly/nrfy_bellboard.h> 39 40 #ifdef __cplusplus 41 extern "C" { 42 #endif 43 44 /** 45 * @defgroup nrfx_bellboard BELLBOARD driver 46 * @{ 47 * @ingroup nrf_bellboard 48 * @brief BELLBOARD peripheral driver. 49 */ 50 51 /** @brief Structure for the BELLBOARD driver instance. */ 52 typedef struct 53 { 54 uint8_t drv_inst_idx; ///< Index of the driver instance. For internal use only. 55 uint8_t int_idx; ///< Interrupt index. For internal use only. 56 } nrfx_bellboard_t; 57 58 #ifndef __NRFX_DOXYGEN__ 59 enum { 60 NRFX_INSTANCE_ENUM_LIST(BELLBOARD) 61 NRFX_BELLBOARD_ENABLED_COUNT 62 }; 63 #endif 64 65 /** @brief Macro for creating a BELLBOARD driver instance. */ 66 #define NRFX_BELLBOARD_INSTANCE(id) \ 67 { \ 68 .drv_inst_idx = NRFX_CONCAT(NRFX_BELLBOARD, id, _INST_IDX), \ 69 .int_idx = id, \ 70 } 71 72 /** 73 * @brief Bellboard event handler callback. 74 * 75 * @param[in] event_idx Bellboard event index. 76 * @param[in] p_context User context. 77 */ 78 typedef void (*nrfx_bellboard_event_handler_t)(uint8_t event_idx, void * p_context); 79 80 /** 81 * @brief Initialize BELLBOARD driver instance. 82 * 83 * @param[in] p_instance Pointer to BELLBOARD driver instance. 84 * @param[in] irq_priority Interrupt priority. 85 * @param[in] event_handler Function to be called on bellboard interrupt. 86 * @param[in] p_context User context passed to event handler. 87 * 88 * @retval NRFX_SUCCESS Instance successfully initialized. 89 * @retval NRFX_ERROR_ALREADY Instance already initialized. 90 */ 91 nrfx_err_t nrfx_bellboard_init(nrfx_bellboard_t const * p_instance, 92 uint8_t irq_priority, 93 nrfx_bellboard_event_handler_t event_handler, 94 void * p_context); 95 96 /** 97 * @brief Uninitialize BELLBOARD driver instance. 98 * 99 * @param[in] p_instance Pointer to BELLBOARD driver instance. 100 */ 101 void nrfx_bellboard_uninit(nrfx_bellboard_t const * p_instance); 102 103 /** 104 * @brief Function for checking if the BELLBOARD driver instance is initialized. 105 * 106 * @param[in] p_instance Pointer to BELLBOARD driver instance. 107 * 108 * @retval true Instance is already initialized. 109 * @retval false Instance is not initialized. 110 */ 111 bool nrfx_bellboard_init_check(nrfx_bellboard_t const * p_instance); 112 113 /** 114 * @brief Enable interrupt mask for given bellboard interrupt. 115 * 116 * @param[in] p_instance Pointer to BELLBOARD driver instance. 117 * @param[in] mask Interrupt mask. 118 */ 119 void nrfx_bellboard_int_enable(nrfx_bellboard_t const * p_instance, uint32_t mask); 120 121 /** 122 * @brief Disable interrupt mask for given bellboard interrupt. 123 * 124 * @param[in] p_instance Pointer to BELLBOARD driver instance. 125 * @param[in] mask Interrupt mask. 126 */ 127 void nrfx_bellboard_int_disable(nrfx_bellboard_t const * p_instance, uint32_t mask); 128 129 /** @} */ 130 131 NRFX_INSTANCE_IRQ_HANDLERS_DECLARE(BELLBOARD, bellboard) 132 133 #ifdef __cplusplus 134 } 135 #endif 136 137 #endif // NRFX_BELLBOARD_H__ 138