LCOV - code coverage report
Current view: top level - home/jason/ncs-2.0.0/modules/hal/nordic/nrfx/hal - nrf_mutex.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 5 0.0 %
Date: 2022-08-18 11:36:24 Functions: 0 2 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  * Copyright (c) 2019 - 2022, 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 NRF_MUTEX_H__
      35                 :            : #define NRF_MUTEX_H__
      36                 :            : 
      37                 :            : #include <nrfx.h>
      38                 :            : 
      39                 :            : #ifdef __cplusplus
      40                 :            : extern "C" {
      41                 :            : #endif
      42                 :            : 
      43                 :            : /**
      44                 :            :  * @defgroup nrf_mutex_hal MUTEX HAL
      45                 :            :  * @{
      46                 :            :  * @ingroup nrf_mutex
      47                 :            :  * @brief   Hardware access layer for managing the MUTEX peripheral.
      48                 :            :  */
      49                 :            : 
      50                 :            : /**
      51                 :            :  * @brief Function for locking the specified mutex.
      52                 :            :  *
      53                 :            :  * If the specified mutex is already locked, its state remains unchanged.
      54                 :            :  *
      55                 :            :  * @note Faults are not managed by the MUTEX peripheral.
      56                 :            :  *       One consequence is that if a mutex is locked and a fault happens,
      57                 :            :  *       it is the responsibility of the fault handler to release the mutex.
      58                 :            :  *       If a fault handler is not managing the mutex release, the mutex will remain locked.
      59                 :            :  *
      60                 :            :  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
      61                 :            :  * @param[in] mutex Index of the mutex to be locked.
      62                 :            :  *
      63                 :            :  * @retval true  Mutex is successfully locked.
      64                 :            :  * @retval false Mutex was already locked.
      65                 :            :  */
      66                 :            : NRF_STATIC_INLINE bool nrf_mutex_lock(NRF_MUTEX_Type * p_reg, uint8_t mutex);
      67                 :            : 
      68                 :            : /**
      69                 :            :  * @brief Function for unlocking the specified mutex.
      70                 :            :  *
      71                 :            :  * If the specified mutex is already unlocked, its state remains unchanged.
      72                 :            :  *
      73                 :            :  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
      74                 :            :  * @param[in] mutex Index of the mutex to be locked.
      75                 :            :  */
      76                 :            : NRF_STATIC_INLINE void nrf_mutex_unlock(NRF_MUTEX_Type * p_reg, uint8_t mutex);
      77                 :            : 
      78                 :            : #ifndef NRF_DECLARE_ONLY
      79                 :            : 
      80                 :          0 : NRF_STATIC_INLINE bool nrf_mutex_lock(NRF_MUTEX_Type * p_reg, uint8_t mutex)
      81                 :            : {
      82                 :          0 :     return (p_reg->MUTEX[mutex] == MUTEX_MUTEX_MUTEX_Unlocked);
      83                 :            : }
      84                 :            : 
      85                 :          0 : NRF_STATIC_INLINE void nrf_mutex_unlock(NRF_MUTEX_Type * p_reg, uint8_t mutex)
      86                 :            : {
      87                 :          0 :     p_reg->MUTEX[mutex] = MUTEX_MUTEX_MUTEX_Unlocked;
      88                 :          0 : }
      89                 :            : 
      90                 :            : #endif // NRF_DECLARE_ONLY
      91                 :            : 
      92                 :            : /** @} */
      93                 :            : 
      94                 :            : #ifdef __cplusplus
      95                 :            : }
      96                 :            : #endif
      97                 :            : 
      98                 :            : #endif // NRF_MUTEX_H__

Generated by: LCOV version 1.14