Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
mbed-os/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_11/drivers_nrf/hal/nrf_spis.h@0:fbdae7e6d805, 2018-05-14 (annotated)
- Committer:
- borlanic
- Date:
- Mon May 14 11:29:06 2018 +0000
- Revision:
- 0:fbdae7e6d805
BBR
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| borlanic | 0:fbdae7e6d805 | 1 | /* |
| borlanic | 0:fbdae7e6d805 | 2 | * Copyright (c) 2015 Nordic Semiconductor ASA |
| borlanic | 0:fbdae7e6d805 | 3 | * All rights reserved. |
| borlanic | 0:fbdae7e6d805 | 4 | * |
| borlanic | 0:fbdae7e6d805 | 5 | * Redistribution and use in source and binary forms, with or without modification, |
| borlanic | 0:fbdae7e6d805 | 6 | * are permitted provided that the following conditions are met: |
| borlanic | 0:fbdae7e6d805 | 7 | * |
| borlanic | 0:fbdae7e6d805 | 8 | * 1. Redistributions of source code must retain the above copyright notice, this list |
| borlanic | 0:fbdae7e6d805 | 9 | * of conditions and the following disclaimer. |
| borlanic | 0:fbdae7e6d805 | 10 | * |
| borlanic | 0:fbdae7e6d805 | 11 | * 2. Redistributions in binary form, except as embedded into a Nordic Semiconductor ASA |
| borlanic | 0:fbdae7e6d805 | 12 | * integrated circuit in a product or a software update for such product, must reproduce |
| borlanic | 0:fbdae7e6d805 | 13 | * the above copyright notice, this list of conditions and the following disclaimer in |
| borlanic | 0:fbdae7e6d805 | 14 | * the documentation and/or other materials provided with the distribution. |
| borlanic | 0:fbdae7e6d805 | 15 | * |
| borlanic | 0:fbdae7e6d805 | 16 | * 3. Neither the name of Nordic Semiconductor ASA nor the names of its contributors may be |
| borlanic | 0:fbdae7e6d805 | 17 | * used to endorse or promote products derived from this software without specific prior |
| borlanic | 0:fbdae7e6d805 | 18 | * written permission. |
| borlanic | 0:fbdae7e6d805 | 19 | * |
| borlanic | 0:fbdae7e6d805 | 20 | * 4. This software, with or without modification, must only be used with a |
| borlanic | 0:fbdae7e6d805 | 21 | * Nordic Semiconductor ASA integrated circuit. |
| borlanic | 0:fbdae7e6d805 | 22 | * |
| borlanic | 0:fbdae7e6d805 | 23 | * 5. Any software provided in binary or object form under this license must not be reverse |
| borlanic | 0:fbdae7e6d805 | 24 | * engineered, decompiled, modified and/or disassembled. |
| borlanic | 0:fbdae7e6d805 | 25 | * |
| borlanic | 0:fbdae7e6d805 | 26 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
| borlanic | 0:fbdae7e6d805 | 27 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| borlanic | 0:fbdae7e6d805 | 28 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| borlanic | 0:fbdae7e6d805 | 29 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR |
| borlanic | 0:fbdae7e6d805 | 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| borlanic | 0:fbdae7e6d805 | 31 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| borlanic | 0:fbdae7e6d805 | 32 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
| borlanic | 0:fbdae7e6d805 | 33 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| borlanic | 0:fbdae7e6d805 | 34 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| borlanic | 0:fbdae7e6d805 | 35 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| borlanic | 0:fbdae7e6d805 | 36 | * |
| borlanic | 0:fbdae7e6d805 | 37 | */ |
| borlanic | 0:fbdae7e6d805 | 38 | |
| borlanic | 0:fbdae7e6d805 | 39 | |
| borlanic | 0:fbdae7e6d805 | 40 | /** |
| borlanic | 0:fbdae7e6d805 | 41 | * @defgroup nrf_spis_hal SPIS HAL |
| borlanic | 0:fbdae7e6d805 | 42 | * @{ |
| borlanic | 0:fbdae7e6d805 | 43 | * @ingroup nrf_spis |
| borlanic | 0:fbdae7e6d805 | 44 | * |
| borlanic | 0:fbdae7e6d805 | 45 | * @brief Hardware access layer for accessing the SPIS peripheral. |
| borlanic | 0:fbdae7e6d805 | 46 | */ |
| borlanic | 0:fbdae7e6d805 | 47 | |
| borlanic | 0:fbdae7e6d805 | 48 | #ifndef NRF_SPIS_H__ |
| borlanic | 0:fbdae7e6d805 | 49 | #define NRF_SPIS_H__ |
| borlanic | 0:fbdae7e6d805 | 50 | |
| borlanic | 0:fbdae7e6d805 | 51 | #include <stddef.h> |
| borlanic | 0:fbdae7e6d805 | 52 | #include <stdbool.h> |
| borlanic | 0:fbdae7e6d805 | 53 | #include <stdint.h> |
| borlanic | 0:fbdae7e6d805 | 54 | |
| borlanic | 0:fbdae7e6d805 | 55 | #include "nrf.h" |
| borlanic | 0:fbdae7e6d805 | 56 | |
| borlanic | 0:fbdae7e6d805 | 57 | |
| borlanic | 0:fbdae7e6d805 | 58 | /** |
| borlanic | 0:fbdae7e6d805 | 59 | * @brief This value can be used as a parameter for the @ref nrf_spis_pins_set |
| borlanic | 0:fbdae7e6d805 | 60 | * function to specify that a given SPI signal (SCK, MOSI, or MISO) |
| borlanic | 0:fbdae7e6d805 | 61 | * shall not be connected to a physical pin. |
| borlanic | 0:fbdae7e6d805 | 62 | */ |
| borlanic | 0:fbdae7e6d805 | 63 | #define NRF_SPIS_PIN_NOT_CONNECTED 0xFFFFFFFF |
| borlanic | 0:fbdae7e6d805 | 64 | |
| borlanic | 0:fbdae7e6d805 | 65 | |
| borlanic | 0:fbdae7e6d805 | 66 | /** |
| borlanic | 0:fbdae7e6d805 | 67 | * @brief SPIS tasks. |
| borlanic | 0:fbdae7e6d805 | 68 | */ |
| borlanic | 0:fbdae7e6d805 | 69 | typedef enum |
| borlanic | 0:fbdae7e6d805 | 70 | { |
| borlanic | 0:fbdae7e6d805 | 71 | /*lint -save -e30*/ |
| borlanic | 0:fbdae7e6d805 | 72 | NRF_SPIS_TASK_ACQUIRE = offsetof(NRF_SPIS_Type, TASKS_ACQUIRE), ///< Acquire SPI semaphore. |
| borlanic | 0:fbdae7e6d805 | 73 | NRF_SPIS_TASK_RELEASE = offsetof(NRF_SPIS_Type, TASKS_RELEASE), ///< Release SPI semaphore, enabling the SPI slave to acquire it. |
| borlanic | 0:fbdae7e6d805 | 74 | /*lint -restore*/ |
| borlanic | 0:fbdae7e6d805 | 75 | } nrf_spis_task_t; |
| borlanic | 0:fbdae7e6d805 | 76 | |
| borlanic | 0:fbdae7e6d805 | 77 | /** |
| borlanic | 0:fbdae7e6d805 | 78 | * @brief SPIS events. |
| borlanic | 0:fbdae7e6d805 | 79 | */ |
| borlanic | 0:fbdae7e6d805 | 80 | typedef enum |
| borlanic | 0:fbdae7e6d805 | 81 | { |
| borlanic | 0:fbdae7e6d805 | 82 | /*lint -save -e30*/ |
| borlanic | 0:fbdae7e6d805 | 83 | NRF_SPIS_EVENT_END = offsetof(NRF_SPIS_Type, EVENTS_END), ///< Granted transaction completed. |
| borlanic | 0:fbdae7e6d805 | 84 | NRF_SPIS_EVENT_ACQUIRED = offsetof(NRF_SPIS_Type, EVENTS_ACQUIRED) ///< Semaphore acquired. |
| borlanic | 0:fbdae7e6d805 | 85 | /*lint -restore*/ |
| borlanic | 0:fbdae7e6d805 | 86 | } nrf_spis_event_t; |
| borlanic | 0:fbdae7e6d805 | 87 | |
| borlanic | 0:fbdae7e6d805 | 88 | /** |
| borlanic | 0:fbdae7e6d805 | 89 | * @brief SPIS shortcuts. |
| borlanic | 0:fbdae7e6d805 | 90 | */ |
| borlanic | 0:fbdae7e6d805 | 91 | typedef enum |
| borlanic | 0:fbdae7e6d805 | 92 | { |
| borlanic | 0:fbdae7e6d805 | 93 | NRF_SPIS_SHORT_END_ACQUIRE = SPIS_SHORTS_END_ACQUIRE_Msk ///< Shortcut between END event and ACQUIRE task. |
| borlanic | 0:fbdae7e6d805 | 94 | } nrf_spis_short_mask_t; |
| borlanic | 0:fbdae7e6d805 | 95 | |
| borlanic | 0:fbdae7e6d805 | 96 | /** |
| borlanic | 0:fbdae7e6d805 | 97 | * @brief SPIS interrupts. |
| borlanic | 0:fbdae7e6d805 | 98 | */ |
| borlanic | 0:fbdae7e6d805 | 99 | typedef enum |
| borlanic | 0:fbdae7e6d805 | 100 | { |
| borlanic | 0:fbdae7e6d805 | 101 | NRF_SPIS_INT_END_MASK = SPIS_INTENSET_END_Msk, ///< Interrupt on END event. |
| borlanic | 0:fbdae7e6d805 | 102 | NRF_SPIS_INT_ACQUIRED_MASK = SPIS_INTENSET_ACQUIRED_Msk ///< Interrupt on ACQUIRED event. |
| borlanic | 0:fbdae7e6d805 | 103 | } nrf_spis_int_mask_t; |
| borlanic | 0:fbdae7e6d805 | 104 | |
| borlanic | 0:fbdae7e6d805 | 105 | /** |
| borlanic | 0:fbdae7e6d805 | 106 | * @brief SPI modes. |
| borlanic | 0:fbdae7e6d805 | 107 | */ |
| borlanic | 0:fbdae7e6d805 | 108 | typedef enum |
| borlanic | 0:fbdae7e6d805 | 109 | { |
| borlanic | 0:fbdae7e6d805 | 110 | NRF_SPIS_MODE_0, ///< SCK active high, sample on leading edge of clock. |
| borlanic | 0:fbdae7e6d805 | 111 | NRF_SPIS_MODE_1, ///< SCK active high, sample on trailing edge of clock. |
| borlanic | 0:fbdae7e6d805 | 112 | NRF_SPIS_MODE_2, ///< SCK active low, sample on leading edge of clock. |
| borlanic | 0:fbdae7e6d805 | 113 | NRF_SPIS_MODE_3 ///< SCK active low, sample on trailing edge of clock. |
| borlanic | 0:fbdae7e6d805 | 114 | } nrf_spis_mode_t; |
| borlanic | 0:fbdae7e6d805 | 115 | |
| borlanic | 0:fbdae7e6d805 | 116 | /** |
| borlanic | 0:fbdae7e6d805 | 117 | * @brief SPI bit orders. |
| borlanic | 0:fbdae7e6d805 | 118 | */ |
| borlanic | 0:fbdae7e6d805 | 119 | typedef enum |
| borlanic | 0:fbdae7e6d805 | 120 | { |
| borlanic | 0:fbdae7e6d805 | 121 | NRF_SPIS_BIT_ORDER_MSB_FIRST = SPIS_CONFIG_ORDER_MsbFirst, ///< Most significant bit shifted out first. |
| borlanic | 0:fbdae7e6d805 | 122 | NRF_SPIS_BIT_ORDER_LSB_FIRST = SPIS_CONFIG_ORDER_LsbFirst ///< Least significant bit shifted out first. |
| borlanic | 0:fbdae7e6d805 | 123 | } nrf_spis_bit_order_t; |
| borlanic | 0:fbdae7e6d805 | 124 | |
| borlanic | 0:fbdae7e6d805 | 125 | /** |
| borlanic | 0:fbdae7e6d805 | 126 | * @brief SPI semaphore status. |
| borlanic | 0:fbdae7e6d805 | 127 | */ |
| borlanic | 0:fbdae7e6d805 | 128 | typedef enum |
| borlanic | 0:fbdae7e6d805 | 129 | { |
| borlanic | 0:fbdae7e6d805 | 130 | NRF_SPIS_SEMSTAT_FREE = 0, ///< Semaphore is free. |
| borlanic | 0:fbdae7e6d805 | 131 | NRF_SPIS_SEMSTAT_CPU = 1, ///< Semaphore is assigned to the CPU. |
| borlanic | 0:fbdae7e6d805 | 132 | NRF_SPIS_SEMSTAT_SPIS = 2, ///< Semaphore is assigned to the SPI slave. |
| borlanic | 0:fbdae7e6d805 | 133 | NRF_SPIS_SEMSTAT_CPUPENDING = 3 ///< Semaphore is assigned to the SPI, but a handover to the CPU is pending. |
| borlanic | 0:fbdae7e6d805 | 134 | } nrf_spis_semstat_t; |
| borlanic | 0:fbdae7e6d805 | 135 | |
| borlanic | 0:fbdae7e6d805 | 136 | /** |
| borlanic | 0:fbdae7e6d805 | 137 | * @brief SPIS status. |
| borlanic | 0:fbdae7e6d805 | 138 | */ |
| borlanic | 0:fbdae7e6d805 | 139 | typedef enum |
| borlanic | 0:fbdae7e6d805 | 140 | { |
| borlanic | 0:fbdae7e6d805 | 141 | NRF_SPIS_STATUS_OVERREAD = SPIS_STATUS_OVERREAD_Msk, ///< TX buffer over-read detected and prevented. |
| borlanic | 0:fbdae7e6d805 | 142 | NRF_SPIS_STATUS_OVERFLOW = SPIS_STATUS_OVERFLOW_Msk ///< RX buffer overflow detected and prevented. |
| borlanic | 0:fbdae7e6d805 | 143 | } nrf_spis_status_mask_t; |
| borlanic | 0:fbdae7e6d805 | 144 | |
| borlanic | 0:fbdae7e6d805 | 145 | /** |
| borlanic | 0:fbdae7e6d805 | 146 | * @brief Function for activating a specific SPIS task. |
| borlanic | 0:fbdae7e6d805 | 147 | * |
| borlanic | 0:fbdae7e6d805 | 148 | * @param[in] p_spis SPIS instance. |
| borlanic | 0:fbdae7e6d805 | 149 | * @param[in] spis_task Task to activate. |
| borlanic | 0:fbdae7e6d805 | 150 | */ |
| borlanic | 0:fbdae7e6d805 | 151 | __STATIC_INLINE void nrf_spis_task_trigger(NRF_SPIS_Type * p_spis, |
| borlanic | 0:fbdae7e6d805 | 152 | nrf_spis_task_t spis_task); |
| borlanic | 0:fbdae7e6d805 | 153 | |
| borlanic | 0:fbdae7e6d805 | 154 | /** |
| borlanic | 0:fbdae7e6d805 | 155 | * @brief Function for getting the address of a specific SPIS task register. |
| borlanic | 0:fbdae7e6d805 | 156 | * |
| borlanic | 0:fbdae7e6d805 | 157 | * @param[in] p_spis SPIS instance. |
| borlanic | 0:fbdae7e6d805 | 158 | * @param[in] spis_task Requested task. |
| borlanic | 0:fbdae7e6d805 | 159 | * |
| borlanic | 0:fbdae7e6d805 | 160 | * @return Address of the specified task register. |
| borlanic | 0:fbdae7e6d805 | 161 | */ |
| borlanic | 0:fbdae7e6d805 | 162 | __STATIC_INLINE uint32_t nrf_spis_task_address_get(NRF_SPIS_Type const * p_spis, |
| borlanic | 0:fbdae7e6d805 | 163 | nrf_spis_task_t spis_task); |
| borlanic | 0:fbdae7e6d805 | 164 | |
| borlanic | 0:fbdae7e6d805 | 165 | /** |
| borlanic | 0:fbdae7e6d805 | 166 | * @brief Function for clearing a specific SPIS event. |
| borlanic | 0:fbdae7e6d805 | 167 | * |
| borlanic | 0:fbdae7e6d805 | 168 | * @param[in] p_spis SPIS instance. |
| borlanic | 0:fbdae7e6d805 | 169 | * @param[in] spis_event Event to clear. |
| borlanic | 0:fbdae7e6d805 | 170 | */ |
| borlanic | 0:fbdae7e6d805 | 171 | __STATIC_INLINE void nrf_spis_event_clear(NRF_SPIS_Type * p_spis, |
| borlanic | 0:fbdae7e6d805 | 172 | nrf_spis_event_t spis_event); |
| borlanic | 0:fbdae7e6d805 | 173 | |
| borlanic | 0:fbdae7e6d805 | 174 | /** |
| borlanic | 0:fbdae7e6d805 | 175 | * @brief Function for checking the state of a specific SPIS event. |
| borlanic | 0:fbdae7e6d805 | 176 | * |
| borlanic | 0:fbdae7e6d805 | 177 | * @param[in] p_spis SPIS instance. |
| borlanic | 0:fbdae7e6d805 | 178 | * @param[in] spis_event Event to check. |
| borlanic | 0:fbdae7e6d805 | 179 | * |
| borlanic | 0:fbdae7e6d805 | 180 | * @retval true If the event is set. |
| borlanic | 0:fbdae7e6d805 | 181 | * @retval false If the event is not set. |
| borlanic | 0:fbdae7e6d805 | 182 | */ |
| borlanic | 0:fbdae7e6d805 | 183 | __STATIC_INLINE bool nrf_spis_event_check(NRF_SPIS_Type const * p_spis, |
| borlanic | 0:fbdae7e6d805 | 184 | nrf_spis_event_t spis_event); |
| borlanic | 0:fbdae7e6d805 | 185 | |
| borlanic | 0:fbdae7e6d805 | 186 | /** |
| borlanic | 0:fbdae7e6d805 | 187 | * @brief Function for getting the address of a specific SPIS event register. |
| borlanic | 0:fbdae7e6d805 | 188 | * |
| borlanic | 0:fbdae7e6d805 | 189 | * @param[in] p_spis SPIS instance. |
| borlanic | 0:fbdae7e6d805 | 190 | * @param[in] spis_event Requested event. |
| borlanic | 0:fbdae7e6d805 | 191 | * |
| borlanic | 0:fbdae7e6d805 | 192 | * @return Address of the specified event register. |
| borlanic | 0:fbdae7e6d805 | 193 | */ |
| borlanic | 0:fbdae7e6d805 | 194 | __STATIC_INLINE uint32_t nrf_spis_event_address_get(NRF_SPIS_Type const * p_spis, |
| borlanic | 0:fbdae7e6d805 | 195 | nrf_spis_event_t spis_event); |
| borlanic | 0:fbdae7e6d805 | 196 | |
| borlanic | 0:fbdae7e6d805 | 197 | /** |
| borlanic | 0:fbdae7e6d805 | 198 | * @brief Function for enabling specified shortcuts. |
| borlanic | 0:fbdae7e6d805 | 199 | * |
| borlanic | 0:fbdae7e6d805 | 200 | * @param[in] p_spis SPIS instance. |
| borlanic | 0:fbdae7e6d805 | 201 | * @param[in] spis_shorts_mask Shortcuts to enable. |
| borlanic | 0:fbdae7e6d805 | 202 | */ |
| borlanic | 0:fbdae7e6d805 | 203 | __STATIC_INLINE void nrf_spis_shorts_enable(NRF_SPIS_Type * p_spis, |
| borlanic | 0:fbdae7e6d805 | 204 | uint32_t spis_shorts_mask); |
| borlanic | 0:fbdae7e6d805 | 205 | |
| borlanic | 0:fbdae7e6d805 | 206 | /** |
| borlanic | 0:fbdae7e6d805 | 207 | * @brief Function for disabling specified shortcuts. |
| borlanic | 0:fbdae7e6d805 | 208 | * |
| borlanic | 0:fbdae7e6d805 | 209 | * @param[in] p_spis SPIS instance. |
| borlanic | 0:fbdae7e6d805 | 210 | * @param[in] spis_shorts_mask Shortcuts to disable. |
| borlanic | 0:fbdae7e6d805 | 211 | */ |
| borlanic | 0:fbdae7e6d805 | 212 | __STATIC_INLINE void nrf_spis_shorts_disable(NRF_SPIS_Type * p_spis, |
| borlanic | 0:fbdae7e6d805 | 213 | uint32_t spis_shorts_mask); |
| borlanic | 0:fbdae7e6d805 | 214 | |
| borlanic | 0:fbdae7e6d805 | 215 | /** |
| borlanic | 0:fbdae7e6d805 | 216 | * @brief Function for enabling specified interrupts. |
| borlanic | 0:fbdae7e6d805 | 217 | * |
| borlanic | 0:fbdae7e6d805 | 218 | * @param[in] p_spis SPIS instance. |
| borlanic | 0:fbdae7e6d805 | 219 | * @param[in] spis_int_mask Interrupts to enable. |
| borlanic | 0:fbdae7e6d805 | 220 | */ |
| borlanic | 0:fbdae7e6d805 | 221 | __STATIC_INLINE void nrf_spis_int_enable(NRF_SPIS_Type * p_spis, |
| borlanic | 0:fbdae7e6d805 | 222 | uint32_t spis_int_mask); |
| borlanic | 0:fbdae7e6d805 | 223 | |
| borlanic | 0:fbdae7e6d805 | 224 | /** |
| borlanic | 0:fbdae7e6d805 | 225 | * @brief Function for disabling specified interrupts. |
| borlanic | 0:fbdae7e6d805 | 226 | * |
| borlanic | 0:fbdae7e6d805 | 227 | * @param[in] p_spis SPIS instance. |
| borlanic | 0:fbdae7e6d805 | 228 | * @param[in] spis_int_mask Interrupts to disable. |
| borlanic | 0:fbdae7e6d805 | 229 | */ |
| borlanic | 0:fbdae7e6d805 | 230 | __STATIC_INLINE void nrf_spis_int_disable(NRF_SPIS_Type * p_spis, |
| borlanic | 0:fbdae7e6d805 | 231 | uint32_t spis_int_mask); |
| borlanic | 0:fbdae7e6d805 | 232 | |
| borlanic | 0:fbdae7e6d805 | 233 | /** |
| borlanic | 0:fbdae7e6d805 | 234 | * @brief Function for retrieving the state of a given interrupt. |
| borlanic | 0:fbdae7e6d805 | 235 | * |
| borlanic | 0:fbdae7e6d805 | 236 | * @param[in] p_spis SPIS instance. |
| borlanic | 0:fbdae7e6d805 | 237 | * @param[in] spis_int Interrupt to check. |
| borlanic | 0:fbdae7e6d805 | 238 | * |
| borlanic | 0:fbdae7e6d805 | 239 | * @retval true If the interrupt is enabled. |
| borlanic | 0:fbdae7e6d805 | 240 | * @retval false If the interrupt is not enabled. |
| borlanic | 0:fbdae7e6d805 | 241 | */ |
| borlanic | 0:fbdae7e6d805 | 242 | __STATIC_INLINE bool nrf_spis_int_enable_check(NRF_SPIS_Type const * p_spis, |
| borlanic | 0:fbdae7e6d805 | 243 | nrf_spis_int_mask_t spis_int); |
| borlanic | 0:fbdae7e6d805 | 244 | |
| borlanic | 0:fbdae7e6d805 | 245 | /** |
| borlanic | 0:fbdae7e6d805 | 246 | * @brief Function for enabling the SPIS peripheral. |
| borlanic | 0:fbdae7e6d805 | 247 | * |
| borlanic | 0:fbdae7e6d805 | 248 | * @param[in] p_spis SPIS instance. |
| borlanic | 0:fbdae7e6d805 | 249 | */ |
| borlanic | 0:fbdae7e6d805 | 250 | __STATIC_INLINE void nrf_spis_enable(NRF_SPIS_Type * p_spis); |
| borlanic | 0:fbdae7e6d805 | 251 | |
| borlanic | 0:fbdae7e6d805 | 252 | /** |
| borlanic | 0:fbdae7e6d805 | 253 | * @brief Function for disabling the SPIS peripheral. |
| borlanic | 0:fbdae7e6d805 | 254 | * |
| borlanic | 0:fbdae7e6d805 | 255 | * @param[in] p_spis SPIS instance. |
| borlanic | 0:fbdae7e6d805 | 256 | */ |
| borlanic | 0:fbdae7e6d805 | 257 | __STATIC_INLINE void nrf_spis_disable(NRF_SPIS_Type * p_spis); |
| borlanic | 0:fbdae7e6d805 | 258 | |
| borlanic | 0:fbdae7e6d805 | 259 | /** |
| borlanic | 0:fbdae7e6d805 | 260 | * @brief Function for retrieving the SPIS semaphore status. |
| borlanic | 0:fbdae7e6d805 | 261 | * |
| borlanic | 0:fbdae7e6d805 | 262 | * @param[in] p_spis SPIS instance. |
| borlanic | 0:fbdae7e6d805 | 263 | * |
| borlanic | 0:fbdae7e6d805 | 264 | * @returns Current semaphore status. |
| borlanic | 0:fbdae7e6d805 | 265 | */ |
| borlanic | 0:fbdae7e6d805 | 266 | __STATIC_INLINE nrf_spis_semstat_t nrf_spis_semaphore_status_get(NRF_SPIS_Type * p_spis); |
| borlanic | 0:fbdae7e6d805 | 267 | |
| borlanic | 0:fbdae7e6d805 | 268 | /** |
| borlanic | 0:fbdae7e6d805 | 269 | * @brief Function for retrieving the SPIS status. |
| borlanic | 0:fbdae7e6d805 | 270 | * |
| borlanic | 0:fbdae7e6d805 | 271 | * @param[in] p_spis SPIS instance. |
| borlanic | 0:fbdae7e6d805 | 272 | * |
| borlanic | 0:fbdae7e6d805 | 273 | * @returns Current SPIS status. |
| borlanic | 0:fbdae7e6d805 | 274 | */ |
| borlanic | 0:fbdae7e6d805 | 275 | __STATIC_INLINE nrf_spis_status_mask_t nrf_spis_status_get(NRF_SPIS_Type * p_spis); |
| borlanic | 0:fbdae7e6d805 | 276 | |
| borlanic | 0:fbdae7e6d805 | 277 | /** |
| borlanic | 0:fbdae7e6d805 | 278 | * @brief Function for configuring SPIS pins. |
| borlanic | 0:fbdae7e6d805 | 279 | * |
| borlanic | 0:fbdae7e6d805 | 280 | * If a given signal is not needed, pass the @ref NRF_SPIS_PIN_NOT_CONNECTED |
| borlanic | 0:fbdae7e6d805 | 281 | * value instead of its pin number. |
| borlanic | 0:fbdae7e6d805 | 282 | * |
| borlanic | 0:fbdae7e6d805 | 283 | * @param[in] p_spis SPIS instance. |
| borlanic | 0:fbdae7e6d805 | 284 | * @param[in] sck_pin SCK pin number. |
| borlanic | 0:fbdae7e6d805 | 285 | * @param[in] mosi_pin MOSI pin number. |
| borlanic | 0:fbdae7e6d805 | 286 | * @param[in] miso_pin MISO pin number. |
| borlanic | 0:fbdae7e6d805 | 287 | * @param[in] csn_pin CSN pin number. |
| borlanic | 0:fbdae7e6d805 | 288 | */ |
| borlanic | 0:fbdae7e6d805 | 289 | __STATIC_INLINE void nrf_spis_pins_set(NRF_SPIS_Type * p_spis, |
| borlanic | 0:fbdae7e6d805 | 290 | uint32_t sck_pin, |
| borlanic | 0:fbdae7e6d805 | 291 | uint32_t mosi_pin, |
| borlanic | 0:fbdae7e6d805 | 292 | uint32_t miso_pin, |
| borlanic | 0:fbdae7e6d805 | 293 | uint32_t csn_pin); |
| borlanic | 0:fbdae7e6d805 | 294 | |
| borlanic | 0:fbdae7e6d805 | 295 | /** |
| borlanic | 0:fbdae7e6d805 | 296 | * @brief Function for setting the transmit buffer. |
| borlanic | 0:fbdae7e6d805 | 297 | * |
| borlanic | 0:fbdae7e6d805 | 298 | * @param[in] p_spis SPIS instance. |
| borlanic | 0:fbdae7e6d805 | 299 | * @param[in] p_buffer Pointer to the buffer that contains the data to send. |
| borlanic | 0:fbdae7e6d805 | 300 | * @param[in] length Maximum number of data bytes to transmit. |
| borlanic | 0:fbdae7e6d805 | 301 | */ |
| borlanic | 0:fbdae7e6d805 | 302 | __STATIC_INLINE void nrf_spis_tx_buffer_set(NRF_SPIS_Type * p_spis, |
| borlanic | 0:fbdae7e6d805 | 303 | uint8_t const * p_buffer, |
| borlanic | 0:fbdae7e6d805 | 304 | uint8_t length); |
| borlanic | 0:fbdae7e6d805 | 305 | |
| borlanic | 0:fbdae7e6d805 | 306 | /** |
| borlanic | 0:fbdae7e6d805 | 307 | * @brief Function for setting the receive buffer. |
| borlanic | 0:fbdae7e6d805 | 308 | * |
| borlanic | 0:fbdae7e6d805 | 309 | * @param[in] p_spis SPIS instance. |
| borlanic | 0:fbdae7e6d805 | 310 | * @param[in] p_buffer Pointer to the buffer for received data. |
| borlanic | 0:fbdae7e6d805 | 311 | * @param[in] length Maximum number of data bytes to receive. |
| borlanic | 0:fbdae7e6d805 | 312 | */ |
| borlanic | 0:fbdae7e6d805 | 313 | __STATIC_INLINE void nrf_spis_rx_buffer_set(NRF_SPIS_Type * p_spis, |
| borlanic | 0:fbdae7e6d805 | 314 | uint8_t * p_buffer, |
| borlanic | 0:fbdae7e6d805 | 315 | uint8_t length); |
| borlanic | 0:fbdae7e6d805 | 316 | |
| borlanic | 0:fbdae7e6d805 | 317 | /** |
| borlanic | 0:fbdae7e6d805 | 318 | * @brief Function for getting the number of bytes transmitted |
| borlanic | 0:fbdae7e6d805 | 319 | * in the last granted transaction. |
| borlanic | 0:fbdae7e6d805 | 320 | * |
| borlanic | 0:fbdae7e6d805 | 321 | * @param[in] p_spis SPIS instance. |
| borlanic | 0:fbdae7e6d805 | 322 | * |
| borlanic | 0:fbdae7e6d805 | 323 | * @returns Number of bytes transmitted. |
| borlanic | 0:fbdae7e6d805 | 324 | */ |
| borlanic | 0:fbdae7e6d805 | 325 | __STATIC_INLINE uint8_t nrf_spis_tx_amount_get(NRF_SPIS_Type const * p_spis); |
| borlanic | 0:fbdae7e6d805 | 326 | |
| borlanic | 0:fbdae7e6d805 | 327 | /** |
| borlanic | 0:fbdae7e6d805 | 328 | * @brief Function for getting the number of bytes received |
| borlanic | 0:fbdae7e6d805 | 329 | * in the last granted transaction. |
| borlanic | 0:fbdae7e6d805 | 330 | * |
| borlanic | 0:fbdae7e6d805 | 331 | * @param[in] p_spis SPIS instance. |
| borlanic | 0:fbdae7e6d805 | 332 | * |
| borlanic | 0:fbdae7e6d805 | 333 | * @returns Number of bytes received. |
| borlanic | 0:fbdae7e6d805 | 334 | */ |
| borlanic | 0:fbdae7e6d805 | 335 | __STATIC_INLINE uint8_t nrf_spis_rx_amount_get(NRF_SPIS_Type const * p_spis); |
| borlanic | 0:fbdae7e6d805 | 336 | |
| borlanic | 0:fbdae7e6d805 | 337 | /** |
| borlanic | 0:fbdae7e6d805 | 338 | * @brief Function for setting the SPI configuration. |
| borlanic | 0:fbdae7e6d805 | 339 | * |
| borlanic | 0:fbdae7e6d805 | 340 | * @param[in] p_spis SPIS instance. |
| borlanic | 0:fbdae7e6d805 | 341 | * @param[in] spi_mode SPI mode. |
| borlanic | 0:fbdae7e6d805 | 342 | * @param[in] spi_bit_order SPI bit order. |
| borlanic | 0:fbdae7e6d805 | 343 | */ |
| borlanic | 0:fbdae7e6d805 | 344 | __STATIC_INLINE void nrf_spis_configure(NRF_SPIS_Type * p_spis, |
| borlanic | 0:fbdae7e6d805 | 345 | nrf_spis_mode_t spi_mode, |
| borlanic | 0:fbdae7e6d805 | 346 | nrf_spis_bit_order_t spi_bit_order); |
| borlanic | 0:fbdae7e6d805 | 347 | |
| borlanic | 0:fbdae7e6d805 | 348 | /** |
| borlanic | 0:fbdae7e6d805 | 349 | * @brief Function for setting the default character. |
| borlanic | 0:fbdae7e6d805 | 350 | * |
| borlanic | 0:fbdae7e6d805 | 351 | * @param[in] p_spis SPIS instance. |
| borlanic | 0:fbdae7e6d805 | 352 | * @param[in] def Default character that is clocked out in case of |
| borlanic | 0:fbdae7e6d805 | 353 | * an overflow of the RXD buffer. |
| borlanic | 0:fbdae7e6d805 | 354 | */ |
| borlanic | 0:fbdae7e6d805 | 355 | __STATIC_INLINE void nrf_spis_def_set(NRF_SPIS_Type * p_spis, |
| borlanic | 0:fbdae7e6d805 | 356 | uint8_t def); |
| borlanic | 0:fbdae7e6d805 | 357 | |
| borlanic | 0:fbdae7e6d805 | 358 | /** |
| borlanic | 0:fbdae7e6d805 | 359 | * @brief Function for setting the over-read character. |
| borlanic | 0:fbdae7e6d805 | 360 | * |
| borlanic | 0:fbdae7e6d805 | 361 | * @param[in] p_spis SPIS instance. |
| borlanic | 0:fbdae7e6d805 | 362 | * @param[in] orc Over-read character that is clocked out in case of |
| borlanic | 0:fbdae7e6d805 | 363 | * an over-read of the TXD buffer. |
| borlanic | 0:fbdae7e6d805 | 364 | */ |
| borlanic | 0:fbdae7e6d805 | 365 | __STATIC_INLINE void nrf_spis_orc_set(NRF_SPIS_Type * p_spis, |
| borlanic | 0:fbdae7e6d805 | 366 | uint8_t orc); |
| borlanic | 0:fbdae7e6d805 | 367 | |
| borlanic | 0:fbdae7e6d805 | 368 | |
| borlanic | 0:fbdae7e6d805 | 369 | #ifndef SUPPRESS_INLINE_IMPLEMENTATION |
| borlanic | 0:fbdae7e6d805 | 370 | |
| borlanic | 0:fbdae7e6d805 | 371 | __STATIC_INLINE void nrf_spis_task_trigger(NRF_SPIS_Type * p_spis, |
| borlanic | 0:fbdae7e6d805 | 372 | nrf_spis_task_t spis_task) |
| borlanic | 0:fbdae7e6d805 | 373 | { |
| borlanic | 0:fbdae7e6d805 | 374 | *((volatile uint32_t *)((uint8_t *)p_spis + (uint32_t)spis_task)) = 0x1UL; |
| borlanic | 0:fbdae7e6d805 | 375 | } |
| borlanic | 0:fbdae7e6d805 | 376 | |
| borlanic | 0:fbdae7e6d805 | 377 | __STATIC_INLINE uint32_t nrf_spis_task_address_get(NRF_SPIS_Type const * p_spis, |
| borlanic | 0:fbdae7e6d805 | 378 | nrf_spis_task_t spis_task) |
| borlanic | 0:fbdae7e6d805 | 379 | { |
| borlanic | 0:fbdae7e6d805 | 380 | return (uint32_t)p_spis + (uint32_t)spis_task; |
| borlanic | 0:fbdae7e6d805 | 381 | } |
| borlanic | 0:fbdae7e6d805 | 382 | |
| borlanic | 0:fbdae7e6d805 | 383 | __STATIC_INLINE void nrf_spis_event_clear(NRF_SPIS_Type * p_spis, |
| borlanic | 0:fbdae7e6d805 | 384 | nrf_spis_event_t spis_event) |
| borlanic | 0:fbdae7e6d805 | 385 | { |
| borlanic | 0:fbdae7e6d805 | 386 | *((volatile uint32_t *)((uint8_t *)p_spis + (uint32_t)spis_event)) = 0x0UL; |
| borlanic | 0:fbdae7e6d805 | 387 | } |
| borlanic | 0:fbdae7e6d805 | 388 | |
| borlanic | 0:fbdae7e6d805 | 389 | __STATIC_INLINE bool nrf_spis_event_check(NRF_SPIS_Type const * p_spis, |
| borlanic | 0:fbdae7e6d805 | 390 | nrf_spis_event_t spis_event) |
| borlanic | 0:fbdae7e6d805 | 391 | { |
| borlanic | 0:fbdae7e6d805 | 392 | return (bool)*(volatile uint32_t *)((uint8_t *)p_spis + (uint32_t)spis_event); |
| borlanic | 0:fbdae7e6d805 | 393 | } |
| borlanic | 0:fbdae7e6d805 | 394 | |
| borlanic | 0:fbdae7e6d805 | 395 | __STATIC_INLINE uint32_t nrf_spis_event_address_get(NRF_SPIS_Type const * p_spis, |
| borlanic | 0:fbdae7e6d805 | 396 | nrf_spis_event_t spis_event) |
| borlanic | 0:fbdae7e6d805 | 397 | { |
| borlanic | 0:fbdae7e6d805 | 398 | return (uint32_t)p_spis + (uint32_t)spis_event; |
| borlanic | 0:fbdae7e6d805 | 399 | } |
| borlanic | 0:fbdae7e6d805 | 400 | |
| borlanic | 0:fbdae7e6d805 | 401 | __STATIC_INLINE void nrf_spis_shorts_enable(NRF_SPIS_Type * p_spis, |
| borlanic | 0:fbdae7e6d805 | 402 | uint32_t spis_shorts_mask) |
| borlanic | 0:fbdae7e6d805 | 403 | { |
| borlanic | 0:fbdae7e6d805 | 404 | p_spis->SHORTS |= spis_shorts_mask; |
| borlanic | 0:fbdae7e6d805 | 405 | } |
| borlanic | 0:fbdae7e6d805 | 406 | |
| borlanic | 0:fbdae7e6d805 | 407 | __STATIC_INLINE void nrf_spis_shorts_disable(NRF_SPIS_Type * p_spis, |
| borlanic | 0:fbdae7e6d805 | 408 | uint32_t spis_shorts_mask) |
| borlanic | 0:fbdae7e6d805 | 409 | { |
| borlanic | 0:fbdae7e6d805 | 410 | p_spis->SHORTS &= ~(spis_shorts_mask); |
| borlanic | 0:fbdae7e6d805 | 411 | } |
| borlanic | 0:fbdae7e6d805 | 412 | |
| borlanic | 0:fbdae7e6d805 | 413 | __STATIC_INLINE void nrf_spis_int_enable(NRF_SPIS_Type * p_spis, |
| borlanic | 0:fbdae7e6d805 | 414 | uint32_t spis_int_mask) |
| borlanic | 0:fbdae7e6d805 | 415 | { |
| borlanic | 0:fbdae7e6d805 | 416 | p_spis->INTENSET = spis_int_mask; |
| borlanic | 0:fbdae7e6d805 | 417 | } |
| borlanic | 0:fbdae7e6d805 | 418 | |
| borlanic | 0:fbdae7e6d805 | 419 | __STATIC_INLINE void nrf_spis_int_disable(NRF_SPIS_Type * p_spis, |
| borlanic | 0:fbdae7e6d805 | 420 | uint32_t spis_int_mask) |
| borlanic | 0:fbdae7e6d805 | 421 | { |
| borlanic | 0:fbdae7e6d805 | 422 | p_spis->INTENCLR = spis_int_mask; |
| borlanic | 0:fbdae7e6d805 | 423 | } |
| borlanic | 0:fbdae7e6d805 | 424 | |
| borlanic | 0:fbdae7e6d805 | 425 | __STATIC_INLINE bool nrf_spis_int_enable_check(NRF_SPIS_Type const * p_spis, |
| borlanic | 0:fbdae7e6d805 | 426 | nrf_spis_int_mask_t spis_int) |
| borlanic | 0:fbdae7e6d805 | 427 | { |
| borlanic | 0:fbdae7e6d805 | 428 | return (bool)(p_spis->INTENSET & spis_int); |
| borlanic | 0:fbdae7e6d805 | 429 | } |
| borlanic | 0:fbdae7e6d805 | 430 | |
| borlanic | 0:fbdae7e6d805 | 431 | __STATIC_INLINE void nrf_spis_enable(NRF_SPIS_Type * p_spis) |
| borlanic | 0:fbdae7e6d805 | 432 | { |
| borlanic | 0:fbdae7e6d805 | 433 | p_spis->ENABLE = (SPIS_ENABLE_ENABLE_Enabled << SPIS_ENABLE_ENABLE_Pos); |
| borlanic | 0:fbdae7e6d805 | 434 | } |
| borlanic | 0:fbdae7e6d805 | 435 | |
| borlanic | 0:fbdae7e6d805 | 436 | __STATIC_INLINE void nrf_spis_disable(NRF_SPIS_Type * p_spis) |
| borlanic | 0:fbdae7e6d805 | 437 | { |
| borlanic | 0:fbdae7e6d805 | 438 | p_spis->ENABLE = (SPIS_ENABLE_ENABLE_Disabled << SPIS_ENABLE_ENABLE_Pos); |
| borlanic | 0:fbdae7e6d805 | 439 | } |
| borlanic | 0:fbdae7e6d805 | 440 | |
| borlanic | 0:fbdae7e6d805 | 441 | __STATIC_INLINE nrf_spis_semstat_t nrf_spis_semaphore_status_get(NRF_SPIS_Type * p_spis) |
| borlanic | 0:fbdae7e6d805 | 442 | { |
| borlanic | 0:fbdae7e6d805 | 443 | return (nrf_spis_semstat_t) ((p_spis->SEMSTAT & SPIS_SEMSTAT_SEMSTAT_Msk) |
| borlanic | 0:fbdae7e6d805 | 444 | >> SPIS_SEMSTAT_SEMSTAT_Pos); |
| borlanic | 0:fbdae7e6d805 | 445 | } |
| borlanic | 0:fbdae7e6d805 | 446 | |
| borlanic | 0:fbdae7e6d805 | 447 | __STATIC_INLINE nrf_spis_status_mask_t nrf_spis_status_get(NRF_SPIS_Type * p_spis) |
| borlanic | 0:fbdae7e6d805 | 448 | { |
| borlanic | 0:fbdae7e6d805 | 449 | return (nrf_spis_status_mask_t) p_spis->STATUS; |
| borlanic | 0:fbdae7e6d805 | 450 | } |
| borlanic | 0:fbdae7e6d805 | 451 | |
| borlanic | 0:fbdae7e6d805 | 452 | __STATIC_INLINE void nrf_spis_pins_set(NRF_SPIS_Type * p_spis, |
| borlanic | 0:fbdae7e6d805 | 453 | uint32_t sck_pin, |
| borlanic | 0:fbdae7e6d805 | 454 | uint32_t mosi_pin, |
| borlanic | 0:fbdae7e6d805 | 455 | uint32_t miso_pin, |
| borlanic | 0:fbdae7e6d805 | 456 | uint32_t csn_pin) |
| borlanic | 0:fbdae7e6d805 | 457 | { |
| borlanic | 0:fbdae7e6d805 | 458 | p_spis->PSELSCK = sck_pin; |
| borlanic | 0:fbdae7e6d805 | 459 | p_spis->PSELMOSI = mosi_pin; |
| borlanic | 0:fbdae7e6d805 | 460 | p_spis->PSELMISO = miso_pin; |
| borlanic | 0:fbdae7e6d805 | 461 | p_spis->PSELCSN = csn_pin; |
| borlanic | 0:fbdae7e6d805 | 462 | } |
| borlanic | 0:fbdae7e6d805 | 463 | |
| borlanic | 0:fbdae7e6d805 | 464 | __STATIC_INLINE void nrf_spis_tx_buffer_set(NRF_SPIS_Type * p_spis, |
| borlanic | 0:fbdae7e6d805 | 465 | uint8_t const * p_buffer, |
| borlanic | 0:fbdae7e6d805 | 466 | uint8_t length) |
| borlanic | 0:fbdae7e6d805 | 467 | { |
| borlanic | 0:fbdae7e6d805 | 468 | p_spis->TXDPTR = (uint32_t)p_buffer; |
| borlanic | 0:fbdae7e6d805 | 469 | p_spis->MAXTX = length; |
| borlanic | 0:fbdae7e6d805 | 470 | } |
| borlanic | 0:fbdae7e6d805 | 471 | |
| borlanic | 0:fbdae7e6d805 | 472 | __STATIC_INLINE void nrf_spis_rx_buffer_set(NRF_SPIS_Type * p_spis, |
| borlanic | 0:fbdae7e6d805 | 473 | uint8_t * p_buffer, |
| borlanic | 0:fbdae7e6d805 | 474 | uint8_t length) |
| borlanic | 0:fbdae7e6d805 | 475 | { |
| borlanic | 0:fbdae7e6d805 | 476 | p_spis->RXDPTR = (uint32_t)p_buffer; |
| borlanic | 0:fbdae7e6d805 | 477 | p_spis->MAXRX = length; |
| borlanic | 0:fbdae7e6d805 | 478 | } |
| borlanic | 0:fbdae7e6d805 | 479 | |
| borlanic | 0:fbdae7e6d805 | 480 | __STATIC_INLINE uint8_t nrf_spis_tx_amount_get(NRF_SPIS_Type const * p_spis) |
| borlanic | 0:fbdae7e6d805 | 481 | { |
| borlanic | 0:fbdae7e6d805 | 482 | return (uint8_t) p_spis->AMOUNTRX; |
| borlanic | 0:fbdae7e6d805 | 483 | } |
| borlanic | 0:fbdae7e6d805 | 484 | |
| borlanic | 0:fbdae7e6d805 | 485 | __STATIC_INLINE uint8_t nrf_spis_rx_amount_get(NRF_SPIS_Type const * p_spis) |
| borlanic | 0:fbdae7e6d805 | 486 | { |
| borlanic | 0:fbdae7e6d805 | 487 | return (uint8_t) p_spis->AMOUNTTX; |
| borlanic | 0:fbdae7e6d805 | 488 | } |
| borlanic | 0:fbdae7e6d805 | 489 | |
| borlanic | 0:fbdae7e6d805 | 490 | __STATIC_INLINE void nrf_spis_configure(NRF_SPIS_Type * p_spis, |
| borlanic | 0:fbdae7e6d805 | 491 | nrf_spis_mode_t spi_mode, |
| borlanic | 0:fbdae7e6d805 | 492 | nrf_spis_bit_order_t spi_bit_order) |
| borlanic | 0:fbdae7e6d805 | 493 | { |
| borlanic | 0:fbdae7e6d805 | 494 | uint32_t config = (spi_bit_order == NRF_SPIS_BIT_ORDER_MSB_FIRST ? |
| borlanic | 0:fbdae7e6d805 | 495 | SPIS_CONFIG_ORDER_MsbFirst : SPIS_CONFIG_ORDER_LsbFirst); |
| borlanic | 0:fbdae7e6d805 | 496 | |
| borlanic | 0:fbdae7e6d805 | 497 | switch (spi_mode) |
| borlanic | 0:fbdae7e6d805 | 498 | { |
| borlanic | 0:fbdae7e6d805 | 499 | default: |
| borlanic | 0:fbdae7e6d805 | 500 | case NRF_SPIS_MODE_0: |
| borlanic | 0:fbdae7e6d805 | 501 | config |= (SPIS_CONFIG_CPOL_ActiveHigh << SPIS_CONFIG_CPOL_Pos) | |
| borlanic | 0:fbdae7e6d805 | 502 | (SPIS_CONFIG_CPHA_Leading << SPIS_CONFIG_CPHA_Pos); |
| borlanic | 0:fbdae7e6d805 | 503 | break; |
| borlanic | 0:fbdae7e6d805 | 504 | |
| borlanic | 0:fbdae7e6d805 | 505 | case NRF_SPIS_MODE_1: |
| borlanic | 0:fbdae7e6d805 | 506 | config |= (SPIS_CONFIG_CPOL_ActiveHigh << SPIS_CONFIG_CPOL_Pos) | |
| borlanic | 0:fbdae7e6d805 | 507 | (SPIS_CONFIG_CPHA_Trailing << SPIS_CONFIG_CPHA_Pos); |
| borlanic | 0:fbdae7e6d805 | 508 | break; |
| borlanic | 0:fbdae7e6d805 | 509 | |
| borlanic | 0:fbdae7e6d805 | 510 | case NRF_SPIS_MODE_2: |
| borlanic | 0:fbdae7e6d805 | 511 | config |= (SPIS_CONFIG_CPOL_ActiveLow << SPIS_CONFIG_CPOL_Pos) | |
| borlanic | 0:fbdae7e6d805 | 512 | (SPIS_CONFIG_CPHA_Leading << SPIS_CONFIG_CPHA_Pos); |
| borlanic | 0:fbdae7e6d805 | 513 | break; |
| borlanic | 0:fbdae7e6d805 | 514 | |
| borlanic | 0:fbdae7e6d805 | 515 | case NRF_SPIS_MODE_3: |
| borlanic | 0:fbdae7e6d805 | 516 | config |= (SPIS_CONFIG_CPOL_ActiveLow << SPIS_CONFIG_CPOL_Pos) | |
| borlanic | 0:fbdae7e6d805 | 517 | (SPIS_CONFIG_CPHA_Trailing << SPIS_CONFIG_CPHA_Pos); |
| borlanic | 0:fbdae7e6d805 | 518 | break; |
| borlanic | 0:fbdae7e6d805 | 519 | } |
| borlanic | 0:fbdae7e6d805 | 520 | p_spis->CONFIG = config; |
| borlanic | 0:fbdae7e6d805 | 521 | } |
| borlanic | 0:fbdae7e6d805 | 522 | |
| borlanic | 0:fbdae7e6d805 | 523 | __STATIC_INLINE void nrf_spis_orc_set(NRF_SPIS_Type * p_spis, |
| borlanic | 0:fbdae7e6d805 | 524 | uint8_t orc) |
| borlanic | 0:fbdae7e6d805 | 525 | { |
| borlanic | 0:fbdae7e6d805 | 526 | p_spis->ORC = orc; |
| borlanic | 0:fbdae7e6d805 | 527 | } |
| borlanic | 0:fbdae7e6d805 | 528 | |
| borlanic | 0:fbdae7e6d805 | 529 | __STATIC_INLINE void nrf_spis_def_set(NRF_SPIS_Type * p_spis, |
| borlanic | 0:fbdae7e6d805 | 530 | uint8_t def) |
| borlanic | 0:fbdae7e6d805 | 531 | { |
| borlanic | 0:fbdae7e6d805 | 532 | p_spis->DEF = def; |
| borlanic | 0:fbdae7e6d805 | 533 | } |
| borlanic | 0:fbdae7e6d805 | 534 | |
| borlanic | 0:fbdae7e6d805 | 535 | #endif // SUPPRESS_INLINE_IMPLEMENTATION |
| borlanic | 0:fbdae7e6d805 | 536 | |
| borlanic | 0:fbdae7e6d805 | 537 | #endif // NRF_SPIS_H__ |
| borlanic | 0:fbdae7e6d805 | 538 | |
| borlanic | 0:fbdae7e6d805 | 539 | /** @} */ |