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.
spi_api_multibyte.c@3:f9aa81ae7c4c, 2017-06-01 (annotated)
- Committer:
- tsungta
- Date:
- Thu Jun 01 03:28:29 2017 +0000
- Revision:
- 3:f9aa81ae7c4c
- Parent:
- 2:c520d7c7739d
- Child:
- 4:8e796b751cd3
API reply and receive are functional ; refer to main.cpp as example
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tsungta | 0:b7415ae44dac | 1 | /* |
tsungta | 0:b7415ae44dac | 2 | * Copyright (c) 2013 Nordic Semiconductor ASA |
tsungta | 0:b7415ae44dac | 3 | * All rights reserved. |
tsungta | 0:b7415ae44dac | 4 | * |
tsungta | 0:b7415ae44dac | 5 | * Redistribution and use in source and binary forms, with or without modification, |
tsungta | 0:b7415ae44dac | 6 | * are permitted provided that the following conditions are met: |
tsungta | 0:b7415ae44dac | 7 | * |
tsungta | 0:b7415ae44dac | 8 | * 1. Redistributions of source code must retain the above copyright notice, this list |
tsungta | 0:b7415ae44dac | 9 | * of conditions and the following disclaimer. |
tsungta | 0:b7415ae44dac | 10 | * |
tsungta | 0:b7415ae44dac | 11 | * 2. Redistributions in binary form, except as embedded into a Nordic Semiconductor ASA |
tsungta | 0:b7415ae44dac | 12 | * integrated circuit in a product or a software update for such product, must reproduce |
tsungta | 0:b7415ae44dac | 13 | * the above copyright notice, this list of conditions and the following disclaimer in |
tsungta | 0:b7415ae44dac | 14 | * the documentation and/or other materials provided with the distribution. |
tsungta | 0:b7415ae44dac | 15 | * |
tsungta | 0:b7415ae44dac | 16 | * 3. Neither the name of Nordic Semiconductor ASA nor the names of its contributors may be |
tsungta | 0:b7415ae44dac | 17 | * used to endorse or promote products derived from this software without specific prior |
tsungta | 0:b7415ae44dac | 18 | * written permission. |
tsungta | 0:b7415ae44dac | 19 | * |
tsungta | 0:b7415ae44dac | 20 | * 4. This software, with or without modification, must only be used with a |
tsungta | 0:b7415ae44dac | 21 | * Nordic Semiconductor ASA integrated circuit. |
tsungta | 0:b7415ae44dac | 22 | * |
tsungta | 0:b7415ae44dac | 23 | * 5. Any software provided in binary or object form under this license must not be reverse |
tsungta | 0:b7415ae44dac | 24 | * engineered, decompiled, modified and/or disassembled. |
tsungta | 0:b7415ae44dac | 25 | * |
tsungta | 0:b7415ae44dac | 26 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
tsungta | 0:b7415ae44dac | 27 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
tsungta | 0:b7415ae44dac | 28 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
tsungta | 0:b7415ae44dac | 29 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR |
tsungta | 0:b7415ae44dac | 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
tsungta | 0:b7415ae44dac | 31 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
tsungta | 0:b7415ae44dac | 32 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
tsungta | 0:b7415ae44dac | 33 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
tsungta | 0:b7415ae44dac | 34 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
tsungta | 0:b7415ae44dac | 35 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
tsungta | 0:b7415ae44dac | 36 | * |
tsungta | 0:b7415ae44dac | 37 | */ |
tsungta | 0:b7415ae44dac | 38 | |
tsungta | 0:b7415ae44dac | 39 | |
tsungta | 0:b7415ae44dac | 40 | #include "spi_api_multibyte.h" |
tsungta | 0:b7415ae44dac | 41 | |
tsungta | 0:b7415ae44dac | 42 | #if DEVICE_SPI |
tsungta | 0:b7415ae44dac | 43 | |
tsungta | 0:b7415ae44dac | 44 | #include "cmsis.h" |
tsungta | 0:b7415ae44dac | 45 | #include "pinmap.h" |
tsungta | 0:b7415ae44dac | 46 | #include "mbed_assert.h" |
tsungta | 0:b7415ae44dac | 47 | #include "mbed_error.h" |
tsungta | 0:b7415ae44dac | 48 | #include "nrf_drv_spi.h" |
tsungta | 0:b7415ae44dac | 49 | #include "nrf_drv_spis.h" |
tsungta | 0:b7415ae44dac | 50 | #include "app_util_platform.h" |
tsungta | 0:b7415ae44dac | 51 | |
tsungta | 0:b7415ae44dac | 52 | #if DEVICE_SPI_ASYNCH |
tsungta | 0:b7415ae44dac | 53 | #define SPI_IDX(obj) ((obj)->spi.spi_idx) |
tsungta | 0:b7415ae44dac | 54 | #else |
tsungta | 0:b7415ae44dac | 55 | #define SPI_IDX(obj) ((obj)->spi_idx) |
tsungta | 0:b7415ae44dac | 56 | #endif |
tsungta | 0:b7415ae44dac | 57 | #define SPI_INFO(obj) (&m_spi_info[SPI_IDX(obj)]) |
tsungta | 0:b7415ae44dac | 58 | #define MASTER_INST(obj) (&m_instances[SPI_IDX(obj)].master) |
tsungta | 0:b7415ae44dac | 59 | #define SLAVE_INST(obj) (&m_instances[SPI_IDX(obj)].slave) |
tsungta | 0:b7415ae44dac | 60 | |
tsungta | 0:b7415ae44dac | 61 | typedef struct { |
tsungta | 0:b7415ae44dac | 62 | bool initialized; |
tsungta | 0:b7415ae44dac | 63 | bool master; |
tsungta | 0:b7415ae44dac | 64 | uint8_t sck_pin; |
tsungta | 0:b7415ae44dac | 65 | uint8_t mosi_pin; |
tsungta | 0:b7415ae44dac | 66 | uint8_t miso_pin; |
tsungta | 0:b7415ae44dac | 67 | uint8_t ss_pin; |
tsungta | 0:b7415ae44dac | 68 | uint8_t spi_mode; |
tsungta | 0:b7415ae44dac | 69 | nrf_drv_spi_frequency_t frequency; |
tsungta | 0:b7415ae44dac | 70 | volatile union { |
tsungta | 0:b7415ae44dac | 71 | bool busy; // master |
tsungta | 0:b7415ae44dac | 72 | bool readable; // slave |
tsungta | 0:b7415ae44dac | 73 | } flag; |
tsungta | 0:b7415ae44dac | 74 | //volatile uint8_t tx_buf; |
tsungta | 0:b7415ae44dac | 75 | //volatile uint8_t rx_buf; |
tsungta | 0:b7415ae44dac | 76 | |
tsungta | 0:b7415ae44dac | 77 | #if DEVICE_SPI_ASYNCH |
tsungta | 0:b7415ae44dac | 78 | uint32_t handler; |
tsungta | 0:b7415ae44dac | 79 | uint32_t event; |
tsungta | 0:b7415ae44dac | 80 | #endif |
tsungta | 0:b7415ae44dac | 81 | } spi_info_t; |
tsungta | 0:b7415ae44dac | 82 | |
tsungta | 1:58f0712d9aa2 | 83 | // #define TEST_STRING "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" //Tsungta, handle 32 bytes per SPI CS cycle |
tsungta | 1:58f0712d9aa2 | 84 | #define TEST_STRING "012" //Tsungta, handle 32 bytes per SPI CS cycle |
tsungta | 3:f9aa81ae7c4c | 85 | #define DATA_LENGTH 32 |
tsungta | 3:f9aa81ae7c4c | 86 | uint8_t m_tx_buf[DATA_LENGTH]; /**< TX buffer. */ |
tsungta | 0:b7415ae44dac | 87 | uint8_t m_rx_buf[sizeof(TEST_STRING)+1]; /**< RX buffer. */ |
tsungta | 3:f9aa81ae7c4c | 88 | int m_length = sizeof(m_tx_buf); /**< Transfer length. */ |
tsungta | 2:c520d7c7739d | 89 | int receive_bytes; |
tsungta | 2:c520d7c7739d | 90 | |
tsungta | 0:b7415ae44dac | 91 | static spi_info_t m_spi_info[SPI_COUNT]; |
tsungta | 0:b7415ae44dac | 92 | |
tsungta | 0:b7415ae44dac | 93 | typedef struct { |
tsungta | 0:b7415ae44dac | 94 | nrf_drv_spi_t master; |
tsungta | 0:b7415ae44dac | 95 | nrf_drv_spis_t slave; |
tsungta | 0:b7415ae44dac | 96 | } sdk_driver_instances_t; |
tsungta | 0:b7415ae44dac | 97 | |
tsungta | 0:b7415ae44dac | 98 | void SPI0_TWI0_IRQHandler(void); |
tsungta | 0:b7415ae44dac | 99 | void SPI1_TWI1_IRQHandler(void); |
tsungta | 0:b7415ae44dac | 100 | void SPIM2_SPIS2_SPI2_IRQHandler(void); |
tsungta | 0:b7415ae44dac | 101 | |
tsungta | 0:b7415ae44dac | 102 | static const peripheral_handler_desc_t spi_hanlder_desc[SPI_COUNT] = { |
tsungta | 0:b7415ae44dac | 103 | #if SPI0_ENABLED |
tsungta | 0:b7415ae44dac | 104 | { |
tsungta | 0:b7415ae44dac | 105 | SPIS0_IRQ, |
tsungta | 0:b7415ae44dac | 106 | (uint32_t) SPI0_TWI0_IRQHandler |
tsungta | 0:b7415ae44dac | 107 | }, |
tsungta | 0:b7415ae44dac | 108 | #endif |
tsungta | 0:b7415ae44dac | 109 | #if SPI1_ENABLED |
tsungta | 0:b7415ae44dac | 110 | { |
tsungta | 0:b7415ae44dac | 111 | SPIS1_IRQ, |
tsungta | 0:b7415ae44dac | 112 | (uint32_t) SPI1_TWI1_IRQHandler |
tsungta | 0:b7415ae44dac | 113 | }, |
tsungta | 0:b7415ae44dac | 114 | #endif |
tsungta | 0:b7415ae44dac | 115 | #if SPI2_ENABLED |
tsungta | 0:b7415ae44dac | 116 | { |
tsungta | 0:b7415ae44dac | 117 | SPIS2_IRQ, |
tsungta | 0:b7415ae44dac | 118 | (uint32_t) SPIM2_SPIS2_SPI2_IRQHandler |
tsungta | 0:b7415ae44dac | 119 | }, |
tsungta | 0:b7415ae44dac | 120 | #endif |
tsungta | 0:b7415ae44dac | 121 | }; |
tsungta | 0:b7415ae44dac | 122 | |
tsungta | 0:b7415ae44dac | 123 | |
tsungta | 0:b7415ae44dac | 124 | static sdk_driver_instances_t m_instances[SPI_COUNT] = { |
tsungta | 0:b7415ae44dac | 125 | #if SPI0_ENABLED |
tsungta | 0:b7415ae44dac | 126 | { |
tsungta | 0:b7415ae44dac | 127 | NRF_DRV_SPI_INSTANCE(0), |
tsungta | 0:b7415ae44dac | 128 | NRF_DRV_SPIS_INSTANCE(0) |
tsungta | 0:b7415ae44dac | 129 | }, |
tsungta | 0:b7415ae44dac | 130 | #endif |
tsungta | 0:b7415ae44dac | 131 | #if SPI1_ENABLED |
tsungta | 0:b7415ae44dac | 132 | { |
tsungta | 0:b7415ae44dac | 133 | NRF_DRV_SPI_INSTANCE(1), |
tsungta | 0:b7415ae44dac | 134 | NRF_DRV_SPIS_INSTANCE(1) |
tsungta | 0:b7415ae44dac | 135 | }, |
tsungta | 0:b7415ae44dac | 136 | #endif |
tsungta | 0:b7415ae44dac | 137 | #if SPI2_ENABLED |
tsungta | 0:b7415ae44dac | 138 | { |
tsungta | 0:b7415ae44dac | 139 | NRF_DRV_SPI_INSTANCE(2), |
tsungta | 0:b7415ae44dac | 140 | NRF_DRV_SPIS_INSTANCE(2) |
tsungta | 0:b7415ae44dac | 141 | }, |
tsungta | 0:b7415ae44dac | 142 | #endif |
tsungta | 0:b7415ae44dac | 143 | }; |
tsungta | 0:b7415ae44dac | 144 | |
tsungta | 0:b7415ae44dac | 145 | static void master_event_handler(uint8_t spi_idx, |
tsungta | 0:b7415ae44dac | 146 | nrf_drv_spi_evt_t const *p_event) |
tsungta | 0:b7415ae44dac | 147 | { |
tsungta | 0:b7415ae44dac | 148 | spi_info_t *p_spi_info = &m_spi_info[spi_idx]; |
tsungta | 0:b7415ae44dac | 149 | |
tsungta | 0:b7415ae44dac | 150 | if (p_event->type == NRF_DRV_SPI_EVENT_DONE) { |
tsungta | 0:b7415ae44dac | 151 | p_spi_info->flag.busy = false; |
tsungta | 0:b7415ae44dac | 152 | if (p_spi_info->handler) { |
tsungta | 0:b7415ae44dac | 153 | void (*handler)(void) = (void (*)(void))p_spi_info->handler; |
tsungta | 0:b7415ae44dac | 154 | p_spi_info->handler = 0; |
tsungta | 0:b7415ae44dac | 155 | handler(); |
tsungta | 0:b7415ae44dac | 156 | } |
tsungta | 0:b7415ae44dac | 157 | } |
tsungta | 0:b7415ae44dac | 158 | } |
tsungta | 0:b7415ae44dac | 159 | #define MASTER_EVENT_HANDLER(idx) \ |
tsungta | 0:b7415ae44dac | 160 | static void master_event_handler_##idx(nrf_drv_spi_evt_t const *p_event) { \ |
tsungta | 0:b7415ae44dac | 161 | master_event_handler(SPI##idx##_INSTANCE_INDEX, p_event); \ |
tsungta | 0:b7415ae44dac | 162 | } |
tsungta | 0:b7415ae44dac | 163 | #if SPI0_ENABLED |
tsungta | 0:b7415ae44dac | 164 | MASTER_EVENT_HANDLER(0) |
tsungta | 0:b7415ae44dac | 165 | #endif |
tsungta | 0:b7415ae44dac | 166 | #if SPI1_ENABLED |
tsungta | 0:b7415ae44dac | 167 | MASTER_EVENT_HANDLER(1) |
tsungta | 0:b7415ae44dac | 168 | #endif |
tsungta | 0:b7415ae44dac | 169 | #if SPI2_ENABLED |
tsungta | 0:b7415ae44dac | 170 | MASTER_EVENT_HANDLER(2) |
tsungta | 0:b7415ae44dac | 171 | #endif |
tsungta | 0:b7415ae44dac | 172 | |
tsungta | 0:b7415ae44dac | 173 | static nrf_drv_spi_handler_t const m_master_event_handlers[SPI_COUNT] = { |
tsungta | 0:b7415ae44dac | 174 | #if SPI0_ENABLED |
tsungta | 0:b7415ae44dac | 175 | master_event_handler_0, |
tsungta | 0:b7415ae44dac | 176 | #endif |
tsungta | 0:b7415ae44dac | 177 | #if SPI1_ENABLED |
tsungta | 0:b7415ae44dac | 178 | master_event_handler_1, |
tsungta | 0:b7415ae44dac | 179 | #endif |
tsungta | 0:b7415ae44dac | 180 | #if SPI2_ENABLED |
tsungta | 0:b7415ae44dac | 181 | master_event_handler_2, |
tsungta | 0:b7415ae44dac | 182 | #endif |
tsungta | 0:b7415ae44dac | 183 | }; |
tsungta | 0:b7415ae44dac | 184 | |
tsungta | 0:b7415ae44dac | 185 | |
tsungta | 0:b7415ae44dac | 186 | static void slave_event_handler(uint8_t spi_idx, |
tsungta | 0:b7415ae44dac | 187 | nrf_drv_spis_event_t event) |
tsungta | 0:b7415ae44dac | 188 | { |
tsungta | 0:b7415ae44dac | 189 | spi_info_t *p_spi_info = &m_spi_info[spi_idx]; |
tsungta | 0:b7415ae44dac | 190 | |
tsungta | 0:b7415ae44dac | 191 | if (event.evt_type == NRF_DRV_SPIS_XFER_DONE) { |
tsungta | 0:b7415ae44dac | 192 | // Signal that there is some data received that could be read. |
tsungta | 2:c520d7c7739d | 193 | if(event.rx_amount == receive_bytes)//Tsungta |
tsungta | 1:58f0712d9aa2 | 194 | p_spi_info->flag.readable = true; |
tsungta | 0:b7415ae44dac | 195 | |
tsungta | 0:b7415ae44dac | 196 | // And prepare for the next transfer. |
tsungta | 0:b7415ae44dac | 197 | // Previous data set in 'spi_slave_write' (if any) has been transmitted, |
tsungta | 0:b7415ae44dac | 198 | // now use the default one, until some new is set by 'spi_slave_write'. |
tsungta | 0:b7415ae44dac | 199 | //m_tx_buf = NRF_DRV_SPIS_DEFAULT_ORC; |
tsungta | 0:b7415ae44dac | 200 | nrf_drv_spis_buffers_set(&m_instances[spi_idx].slave, |
tsungta | 0:b7415ae44dac | 201 | m_tx_buf, m_length, m_rx_buf, m_length); |
tsungta | 0:b7415ae44dac | 202 | } |
tsungta | 0:b7415ae44dac | 203 | } |
tsungta | 0:b7415ae44dac | 204 | #define SLAVE_EVENT_HANDLER(idx) \ |
tsungta | 0:b7415ae44dac | 205 | static void slave_event_handler_##idx(nrf_drv_spis_event_t event) { \ |
tsungta | 0:b7415ae44dac | 206 | slave_event_handler(SPIS##idx##_INSTANCE_INDEX, event); \ |
tsungta | 0:b7415ae44dac | 207 | } |
tsungta | 0:b7415ae44dac | 208 | #if SPIS0_ENABLED |
tsungta | 0:b7415ae44dac | 209 | SLAVE_EVENT_HANDLER(0) |
tsungta | 0:b7415ae44dac | 210 | #endif |
tsungta | 0:b7415ae44dac | 211 | #if SPIS1_ENABLED |
tsungta | 0:b7415ae44dac | 212 | SLAVE_EVENT_HANDLER(1) |
tsungta | 0:b7415ae44dac | 213 | #endif |
tsungta | 0:b7415ae44dac | 214 | #if SPIS2_ENABLED |
tsungta | 0:b7415ae44dac | 215 | SLAVE_EVENT_HANDLER(2) |
tsungta | 0:b7415ae44dac | 216 | #endif |
tsungta | 0:b7415ae44dac | 217 | |
tsungta | 0:b7415ae44dac | 218 | static nrf_drv_spis_event_handler_t const m_slave_event_handlers[SPIS_COUNT] = { |
tsungta | 0:b7415ae44dac | 219 | #if SPIS0_ENABLED |
tsungta | 0:b7415ae44dac | 220 | slave_event_handler_0, |
tsungta | 0:b7415ae44dac | 221 | #endif |
tsungta | 0:b7415ae44dac | 222 | #if SPIS1_ENABLED |
tsungta | 0:b7415ae44dac | 223 | slave_event_handler_1, |
tsungta | 0:b7415ae44dac | 224 | #endif |
tsungta | 0:b7415ae44dac | 225 | #if SPIS2_ENABLED |
tsungta | 0:b7415ae44dac | 226 | slave_event_handler_2, |
tsungta | 0:b7415ae44dac | 227 | #endif |
tsungta | 0:b7415ae44dac | 228 | }; |
tsungta | 0:b7415ae44dac | 229 | |
tsungta | 0:b7415ae44dac | 230 | static void prepare_master_config(nrf_drv_spi_config_t *p_config, |
tsungta | 0:b7415ae44dac | 231 | spi_info_t const *p_spi_info) |
tsungta | 0:b7415ae44dac | 232 | { |
tsungta | 0:b7415ae44dac | 233 | p_config->sck_pin = p_spi_info->sck_pin; |
tsungta | 0:b7415ae44dac | 234 | p_config->mosi_pin = p_spi_info->mosi_pin; |
tsungta | 0:b7415ae44dac | 235 | p_config->miso_pin = p_spi_info->miso_pin; |
tsungta | 0:b7415ae44dac | 236 | p_config->ss_pin = p_spi_info->ss_pin; |
tsungta | 0:b7415ae44dac | 237 | p_config->frequency = p_spi_info->frequency; |
tsungta | 0:b7415ae44dac | 238 | p_config->mode = (nrf_drv_spi_mode_t)p_spi_info->spi_mode; |
tsungta | 0:b7415ae44dac | 239 | |
tsungta | 0:b7415ae44dac | 240 | p_config->irq_priority = SPI1_CONFIG_IRQ_PRIORITY; |
tsungta | 0:b7415ae44dac | 241 | p_config->orc = 0xFF; |
tsungta | 0:b7415ae44dac | 242 | p_config->bit_order = NRF_DRV_SPI_BIT_ORDER_MSB_FIRST; |
tsungta | 0:b7415ae44dac | 243 | } |
tsungta | 0:b7415ae44dac | 244 | |
tsungta | 0:b7415ae44dac | 245 | static void prepare_slave_config(nrf_drv_spis_config_t *p_config, |
tsungta | 0:b7415ae44dac | 246 | spi_info_t const *p_spi_info) |
tsungta | 0:b7415ae44dac | 247 | { |
tsungta | 0:b7415ae44dac | 248 | p_config->sck_pin = p_spi_info->sck_pin; |
tsungta | 0:b7415ae44dac | 249 | p_config->mosi_pin = p_spi_info->mosi_pin; |
tsungta | 0:b7415ae44dac | 250 | p_config->miso_pin = p_spi_info->miso_pin; |
tsungta | 0:b7415ae44dac | 251 | p_config->csn_pin = p_spi_info->ss_pin; |
tsungta | 0:b7415ae44dac | 252 | p_config->mode = (nrf_drv_spis_mode_t)p_spi_info->spi_mode; |
tsungta | 0:b7415ae44dac | 253 | |
tsungta | 0:b7415ae44dac | 254 | p_config->irq_priority = SPIS1_CONFIG_IRQ_PRIORITY; |
tsungta | 0:b7415ae44dac | 255 | p_config->orc = NRF_DRV_SPIS_DEFAULT_ORC; |
tsungta | 0:b7415ae44dac | 256 | p_config->def = NRF_DRV_SPIS_DEFAULT_DEF; |
tsungta | 0:b7415ae44dac | 257 | p_config->bit_order = NRF_DRV_SPIS_BIT_ORDER_MSB_FIRST; |
tsungta | 0:b7415ae44dac | 258 | p_config->csn_pullup = NRF_DRV_SPIS_DEFAULT_CSN_PULLUP; |
tsungta | 0:b7415ae44dac | 259 | p_config->miso_drive = NRF_DRV_SPIS_DEFAULT_MISO_DRIVE; |
tsungta | 0:b7415ae44dac | 260 | } |
tsungta | 0:b7415ae44dac | 261 | |
tsungta | 0:b7415ae44dac | 262 | void spi_init_multibyte(spi_mb_t *obj, |
tsungta | 0:b7415ae44dac | 263 | PinName mosi, PinName miso, PinName sclk, PinName ssel) |
tsungta | 0:b7415ae44dac | 264 | { |
tsungta | 0:b7415ae44dac | 265 | int i; |
tsungta | 0:b7415ae44dac | 266 | for (i = 0; i < SPI_COUNT; ++i) { |
tsungta | 0:b7415ae44dac | 267 | spi_info_t *p_spi_info = &m_spi_info[i]; |
tsungta | 0:b7415ae44dac | 268 | if (!p_spi_info->initialized) { |
tsungta | 0:b7415ae44dac | 269 | |
tsungta | 0:b7415ae44dac | 270 | NVIC_SetVector(spi_hanlder_desc[i].IRQn, spi_hanlder_desc[i].vector); |
tsungta | 0:b7415ae44dac | 271 | |
tsungta | 0:b7415ae44dac | 272 | p_spi_info->sck_pin = (uint8_t)sclk; |
tsungta | 0:b7415ae44dac | 273 | p_spi_info->mosi_pin = (mosi != NC) ? |
tsungta | 0:b7415ae44dac | 274 | (uint8_t)mosi : NRF_DRV_SPI_PIN_NOT_USED; |
tsungta | 0:b7415ae44dac | 275 | p_spi_info->miso_pin = (miso != NC) ? |
tsungta | 0:b7415ae44dac | 276 | (uint8_t)miso : NRF_DRV_SPI_PIN_NOT_USED; |
tsungta | 0:b7415ae44dac | 277 | p_spi_info->ss_pin = (ssel != NC) ? |
tsungta | 0:b7415ae44dac | 278 | (uint8_t)ssel : NRF_DRV_SPI_PIN_NOT_USED; |
tsungta | 0:b7415ae44dac | 279 | p_spi_info->spi_mode = (uint8_t)NRF_DRV_SPI_MODE_0; |
tsungta | 0:b7415ae44dac | 280 | p_spi_info->frequency = NRF_DRV_SPI_FREQ_1M; |
tsungta | 0:b7415ae44dac | 281 | |
tsungta | 0:b7415ae44dac | 282 | // By default each SPI instance is initialized to work as a master. |
tsungta | 0:b7415ae44dac | 283 | // Should the slave mode be used, the instance will be reconfigured |
tsungta | 0:b7415ae44dac | 284 | // appropriately in 'spi_format'. |
tsungta | 0:b7415ae44dac | 285 | nrf_drv_spi_config_t config; |
tsungta | 0:b7415ae44dac | 286 | prepare_master_config(&config, p_spi_info); |
tsungta | 0:b7415ae44dac | 287 | |
tsungta | 0:b7415ae44dac | 288 | nrf_drv_spi_t const *p_spi = &m_instances[i].master; |
tsungta | 0:b7415ae44dac | 289 | ret_code_t ret_code = nrf_drv_spi_init(p_spi, |
tsungta | 0:b7415ae44dac | 290 | &config, m_master_event_handlers[i]); |
tsungta | 0:b7415ae44dac | 291 | if (ret_code == NRF_SUCCESS) { |
tsungta | 0:b7415ae44dac | 292 | p_spi_info->initialized = true; |
tsungta | 0:b7415ae44dac | 293 | p_spi_info->master = true; |
tsungta | 0:b7415ae44dac | 294 | p_spi_info->flag.busy = false; |
tsungta | 0:b7415ae44dac | 295 | #if DEVICE_SPI_ASYNCH |
tsungta | 0:b7415ae44dac | 296 | p_spi_info->handler = 0; |
tsungta | 0:b7415ae44dac | 297 | #endif |
tsungta | 0:b7415ae44dac | 298 | SPI_IDX(obj) = i; |
tsungta | 0:b7415ae44dac | 299 | |
tsungta | 0:b7415ae44dac | 300 | return; |
tsungta | 0:b7415ae44dac | 301 | } |
tsungta | 0:b7415ae44dac | 302 | } |
tsungta | 0:b7415ae44dac | 303 | } |
tsungta | 0:b7415ae44dac | 304 | |
tsungta | 0:b7415ae44dac | 305 | // No available peripheral |
tsungta | 0:b7415ae44dac | 306 | error("No available SPI peripheral\r\n"); |
tsungta | 0:b7415ae44dac | 307 | } |
tsungta | 0:b7415ae44dac | 308 | |
tsungta | 0:b7415ae44dac | 309 | void spi_free_multibyte(spi_mb_t *obj) |
tsungta | 0:b7415ae44dac | 310 | { |
tsungta | 0:b7415ae44dac | 311 | spi_info_t *p_spi_info = SPI_INFO(obj); |
tsungta | 0:b7415ae44dac | 312 | if (p_spi_info->master) { |
tsungta | 0:b7415ae44dac | 313 | nrf_drv_spi_uninit(MASTER_INST(obj)); |
tsungta | 0:b7415ae44dac | 314 | } |
tsungta | 0:b7415ae44dac | 315 | else { |
tsungta | 0:b7415ae44dac | 316 | nrf_drv_spis_uninit(SLAVE_INST(obj)); |
tsungta | 0:b7415ae44dac | 317 | } |
tsungta | 0:b7415ae44dac | 318 | p_spi_info->initialized = false; |
tsungta | 0:b7415ae44dac | 319 | } |
tsungta | 0:b7415ae44dac | 320 | |
tsungta | 0:b7415ae44dac | 321 | int spi_busy_multibyte(spi_mb_t *obj) |
tsungta | 0:b7415ae44dac | 322 | { |
tsungta | 0:b7415ae44dac | 323 | return (int)(SPI_INFO(obj)->flag.busy); |
tsungta | 0:b7415ae44dac | 324 | } |
tsungta | 0:b7415ae44dac | 325 | |
tsungta | 0:b7415ae44dac | 326 | void spi_format_multibyte(spi_mb_t *obj, int bits, int mode, int slave) |
tsungta | 0:b7415ae44dac | 327 | { |
tsungta | 0:b7415ae44dac | 328 | if (bits != 8) { |
tsungta | 0:b7415ae44dac | 329 | error("Only 8-bits SPI is supported\r\n"); |
tsungta | 0:b7415ae44dac | 330 | } |
tsungta | 0:b7415ae44dac | 331 | if (mode > 3) { |
tsungta | 0:b7415ae44dac | 332 | error("SPI format error\r\n"); |
tsungta | 0:b7415ae44dac | 333 | } |
tsungta | 0:b7415ae44dac | 334 | |
tsungta | 0:b7415ae44dac | 335 | spi_info_t *p_spi_info = SPI_INFO(obj); |
tsungta | 0:b7415ae44dac | 336 | |
tsungta | 0:b7415ae44dac | 337 | if (slave) |
tsungta | 0:b7415ae44dac | 338 | { |
tsungta | 0:b7415ae44dac | 339 | nrf_drv_spis_mode_t spi_modes[4] = { |
tsungta | 0:b7415ae44dac | 340 | NRF_DRV_SPIS_MODE_0, |
tsungta | 0:b7415ae44dac | 341 | NRF_DRV_SPIS_MODE_1, |
tsungta | 0:b7415ae44dac | 342 | NRF_DRV_SPIS_MODE_2, |
tsungta | 0:b7415ae44dac | 343 | NRF_DRV_SPIS_MODE_3, |
tsungta | 0:b7415ae44dac | 344 | }; |
tsungta | 0:b7415ae44dac | 345 | nrf_drv_spis_mode_t new_mode = spi_modes[mode]; |
tsungta | 0:b7415ae44dac | 346 | |
tsungta | 0:b7415ae44dac | 347 | // If the peripheral is currently working as a master, the SDK driver |
tsungta | 0:b7415ae44dac | 348 | // it uses needs to be switched from SPI to SPIS. |
tsungta | 0:b7415ae44dac | 349 | if (p_spi_info->master) { |
tsungta | 0:b7415ae44dac | 350 | nrf_drv_spi_uninit(MASTER_INST(obj)); |
tsungta | 0:b7415ae44dac | 351 | } |
tsungta | 0:b7415ae44dac | 352 | // I the SPI mode has to be changed, the SDK's SPIS driver needs to be |
tsungta | 0:b7415ae44dac | 353 | // re-initialized (there is no other way to change its configuration). |
tsungta | 0:b7415ae44dac | 354 | else if (p_spi_info->spi_mode != (uint8_t)new_mode) { |
tsungta | 0:b7415ae44dac | 355 | nrf_drv_spis_uninit(SLAVE_INST(obj)); |
tsungta | 0:b7415ae44dac | 356 | } |
tsungta | 0:b7415ae44dac | 357 | else { |
tsungta | 0:b7415ae44dac | 358 | return; |
tsungta | 0:b7415ae44dac | 359 | } |
tsungta | 0:b7415ae44dac | 360 | |
tsungta | 0:b7415ae44dac | 361 | p_spi_info->spi_mode = (uint8_t)new_mode; |
tsungta | 0:b7415ae44dac | 362 | p_spi_info->master = false; |
tsungta | 0:b7415ae44dac | 363 | p_spi_info->flag.readable = false; |
tsungta | 0:b7415ae44dac | 364 | |
tsungta | 0:b7415ae44dac | 365 | // Initialize SDK's SPIS driver with the new configuration. |
tsungta | 0:b7415ae44dac | 366 | nrf_drv_spis_config_t config; |
tsungta | 0:b7415ae44dac | 367 | prepare_slave_config(&config, p_spi_info); |
tsungta | 0:b7415ae44dac | 368 | (void)nrf_drv_spis_init(SLAVE_INST(obj), &config, |
tsungta | 0:b7415ae44dac | 369 | m_slave_event_handlers[SPI_IDX(obj)]); |
tsungta | 0:b7415ae44dac | 370 | |
tsungta | 0:b7415ae44dac | 371 | // Prepare the slave for transfer. |
tsungta | 0:b7415ae44dac | 372 | //m_tx_buf = NRF_DRV_SPIS_DEFAULT_ORC; |
tsungta | 0:b7415ae44dac | 373 | nrf_drv_spis_buffers_set(SLAVE_INST(obj), |
tsungta | 0:b7415ae44dac | 374 | m_tx_buf, m_length, m_rx_buf, m_length); |
tsungta | 0:b7415ae44dac | 375 | } |
tsungta | 0:b7415ae44dac | 376 | else // master |
tsungta | 0:b7415ae44dac | 377 | { |
tsungta | 0:b7415ae44dac | 378 | nrf_drv_spi_mode_t spi_modes[4] = { |
tsungta | 0:b7415ae44dac | 379 | NRF_DRV_SPI_MODE_0, |
tsungta | 0:b7415ae44dac | 380 | NRF_DRV_SPI_MODE_1, |
tsungta | 0:b7415ae44dac | 381 | NRF_DRV_SPI_MODE_2, |
tsungta | 0:b7415ae44dac | 382 | NRF_DRV_SPI_MODE_3, |
tsungta | 0:b7415ae44dac | 383 | }; |
tsungta | 0:b7415ae44dac | 384 | nrf_drv_spi_mode_t new_mode = spi_modes[mode]; |
tsungta | 0:b7415ae44dac | 385 | |
tsungta | 0:b7415ae44dac | 386 | // If the peripheral is currently working as a slave, the SDK driver |
tsungta | 0:b7415ae44dac | 387 | // it uses needs to be switched from SPIS to SPI. |
tsungta | 0:b7415ae44dac | 388 | if (!p_spi_info->master) { |
tsungta | 0:b7415ae44dac | 389 | nrf_drv_spis_uninit(SLAVE_INST(obj)); |
tsungta | 0:b7415ae44dac | 390 | } |
tsungta | 0:b7415ae44dac | 391 | // I the SPI mode has to be changed, the SDK's SPI driver needs to be |
tsungta | 0:b7415ae44dac | 392 | // re-initialized (there is no other way to change its configuration). |
tsungta | 0:b7415ae44dac | 393 | else if (p_spi_info->spi_mode != (uint8_t)new_mode) { |
tsungta | 0:b7415ae44dac | 394 | nrf_drv_spi_uninit(MASTER_INST(obj)); |
tsungta | 0:b7415ae44dac | 395 | } |
tsungta | 0:b7415ae44dac | 396 | else { |
tsungta | 0:b7415ae44dac | 397 | return; |
tsungta | 0:b7415ae44dac | 398 | } |
tsungta | 0:b7415ae44dac | 399 | |
tsungta | 0:b7415ae44dac | 400 | p_spi_info->spi_mode = (uint8_t)new_mode; |
tsungta | 0:b7415ae44dac | 401 | p_spi_info->master = true; |
tsungta | 0:b7415ae44dac | 402 | p_spi_info->flag.busy = false; |
tsungta | 0:b7415ae44dac | 403 | |
tsungta | 0:b7415ae44dac | 404 | // Initialize SDK's SPI driver with the new configuration. |
tsungta | 0:b7415ae44dac | 405 | nrf_drv_spi_config_t config; |
tsungta | 0:b7415ae44dac | 406 | prepare_master_config(&config, p_spi_info); |
tsungta | 0:b7415ae44dac | 407 | (void)nrf_drv_spi_init(MASTER_INST(obj), &config, |
tsungta | 0:b7415ae44dac | 408 | m_master_event_handlers[SPI_IDX(obj)]); |
tsungta | 0:b7415ae44dac | 409 | } |
tsungta | 0:b7415ae44dac | 410 | } |
tsungta | 0:b7415ae44dac | 411 | |
tsungta | 0:b7415ae44dac | 412 | static nrf_drv_spi_frequency_t freq_translate(int hz) |
tsungta | 0:b7415ae44dac | 413 | { |
tsungta | 0:b7415ae44dac | 414 | nrf_drv_spi_frequency_t frequency; |
tsungta | 0:b7415ae44dac | 415 | if (hz<250000) { //125Kbps |
tsungta | 0:b7415ae44dac | 416 | frequency = NRF_DRV_SPI_FREQ_125K; |
tsungta | 0:b7415ae44dac | 417 | } else if (hz<500000) { //250Kbps |
tsungta | 0:b7415ae44dac | 418 | frequency = NRF_DRV_SPI_FREQ_250K; |
tsungta | 0:b7415ae44dac | 419 | } else if (hz<1000000) { //500Kbps |
tsungta | 0:b7415ae44dac | 420 | frequency = NRF_DRV_SPI_FREQ_500K; |
tsungta | 0:b7415ae44dac | 421 | } else if (hz<2000000) { //1Mbps |
tsungta | 0:b7415ae44dac | 422 | frequency = NRF_DRV_SPI_FREQ_1M; |
tsungta | 0:b7415ae44dac | 423 | } else if (hz<4000000) { //2Mbps |
tsungta | 0:b7415ae44dac | 424 | frequency = NRF_DRV_SPI_FREQ_2M; |
tsungta | 0:b7415ae44dac | 425 | } else if (hz<8000000) { //4Mbps |
tsungta | 0:b7415ae44dac | 426 | frequency = NRF_DRV_SPI_FREQ_4M; |
tsungta | 0:b7415ae44dac | 427 | } else { //8Mbps |
tsungta | 0:b7415ae44dac | 428 | frequency = NRF_DRV_SPI_FREQ_8M; |
tsungta | 0:b7415ae44dac | 429 | } |
tsungta | 0:b7415ae44dac | 430 | return frequency; |
tsungta | 0:b7415ae44dac | 431 | } |
tsungta | 0:b7415ae44dac | 432 | |
tsungta | 0:b7415ae44dac | 433 | void spi_frequency_multibyte(spi_mb_t *obj, int hz) |
tsungta | 0:b7415ae44dac | 434 | { |
tsungta | 0:b7415ae44dac | 435 | spi_info_t *p_spi_info = SPI_INFO(obj); |
tsungta | 0:b7415ae44dac | 436 | nrf_drv_spi_frequency_t new_frequency = freq_translate(hz); |
tsungta | 0:b7415ae44dac | 437 | |
tsungta | 0:b7415ae44dac | 438 | if (p_spi_info->master) |
tsungta | 0:b7415ae44dac | 439 | { |
tsungta | 0:b7415ae44dac | 440 | if (p_spi_info->frequency != new_frequency) { |
tsungta | 0:b7415ae44dac | 441 | p_spi_info->frequency = new_frequency; |
tsungta | 0:b7415ae44dac | 442 | |
tsungta | 0:b7415ae44dac | 443 | nrf_drv_spi_config_t config; |
tsungta | 0:b7415ae44dac | 444 | prepare_master_config(&config, p_spi_info); |
tsungta | 0:b7415ae44dac | 445 | |
tsungta | 0:b7415ae44dac | 446 | nrf_drv_spi_t const *p_spi = MASTER_INST(obj); |
tsungta | 0:b7415ae44dac | 447 | nrf_drv_spi_uninit(p_spi); |
tsungta | 0:b7415ae44dac | 448 | (void)nrf_drv_spi_init(p_spi, &config, |
tsungta | 0:b7415ae44dac | 449 | m_master_event_handlers[SPI_IDX(obj)]); |
tsungta | 0:b7415ae44dac | 450 | } |
tsungta | 0:b7415ae44dac | 451 | } |
tsungta | 0:b7415ae44dac | 452 | // There is no need to set anything in slaves when it comes to frequency, |
tsungta | 0:b7415ae44dac | 453 | // since slaves just synchronize with the clock provided by a master. |
tsungta | 0:b7415ae44dac | 454 | } |
tsungta | 0:b7415ae44dac | 455 | |
tsungta | 0:b7415ae44dac | 456 | int spi_master_write_multibyte(spi_mb_t *obj, int value) |
tsungta | 0:b7415ae44dac | 457 | { |
tsungta | 0:b7415ae44dac | 458 | spi_info_t *p_spi_info = SPI_INFO(obj); |
tsungta | 0:b7415ae44dac | 459 | |
tsungta | 0:b7415ae44dac | 460 | #if DEVICE_SPI_ASYNCH |
tsungta | 0:b7415ae44dac | 461 | while (p_spi_info->flag.busy) { |
tsungta | 0:b7415ae44dac | 462 | } |
tsungta | 0:b7415ae44dac | 463 | #endif |
tsungta | 0:b7415ae44dac | 464 | |
tsungta | 0:b7415ae44dac | 465 | //m_tx_buf = value; |
tsungta | 0:b7415ae44dac | 466 | p_spi_info->flag.busy = true; |
tsungta | 0:b7415ae44dac | 467 | (void)nrf_drv_spi_transfer(MASTER_INST(obj), |
tsungta | 0:b7415ae44dac | 468 | m_tx_buf, m_length, m_rx_buf, m_length); |
tsungta | 0:b7415ae44dac | 469 | while (p_spi_info->flag.busy) { |
tsungta | 0:b7415ae44dac | 470 | } |
tsungta | 0:b7415ae44dac | 471 | |
tsungta | 0:b7415ae44dac | 472 | return m_rx_buf; |
tsungta | 0:b7415ae44dac | 473 | } |
tsungta | 0:b7415ae44dac | 474 | |
tsungta | 2:c520d7c7739d | 475 | int spi_slave_receive_multibyte(spi_mb_t *obj, int bytes) |
tsungta | 0:b7415ae44dac | 476 | { |
tsungta | 2:c520d7c7739d | 477 | receive_bytes = bytes;//Tsungta |
tsungta | 0:b7415ae44dac | 478 | spi_info_t *p_spi_info = SPI_INFO(obj); |
tsungta | 0:b7415ae44dac | 479 | MBED_ASSERT(!p_spi_info->master); |
tsungta | 0:b7415ae44dac | 480 | return p_spi_info->flag.readable; |
tsungta | 0:b7415ae44dac | 481 | ; |
tsungta | 0:b7415ae44dac | 482 | } |
tsungta | 0:b7415ae44dac | 483 | |
tsungta | 0:b7415ae44dac | 484 | int spi_slave_read_multibyte(spi_mb_t *obj) |
tsungta | 0:b7415ae44dac | 485 | { |
tsungta | 0:b7415ae44dac | 486 | spi_info_t *p_spi_info = SPI_INFO(obj); |
tsungta | 0:b7415ae44dac | 487 | MBED_ASSERT(!p_spi_info->master); |
tsungta | 0:b7415ae44dac | 488 | while (!p_spi_info->flag.readable) { |
tsungta | 0:b7415ae44dac | 489 | } |
tsungta | 0:b7415ae44dac | 490 | p_spi_info->flag.readable = false; |
tsungta | 0:b7415ae44dac | 491 | return m_rx_buf; |
tsungta | 0:b7415ae44dac | 492 | } |
tsungta | 0:b7415ae44dac | 493 | |
tsungta | 2:c520d7c7739d | 494 | void spi_slave_write_multibyte(spi_mb_t *obj, uint8_t *value, int bytes) |
tsungta | 0:b7415ae44dac | 495 | { |
tsungta | 0:b7415ae44dac | 496 | spi_info_t *p_spi_info = SPI_INFO(obj); |
tsungta | 0:b7415ae44dac | 497 | MBED_ASSERT(!p_spi_info->master); |
tsungta | 0:b7415ae44dac | 498 | |
tsungta | 3:f9aa81ae7c4c | 499 | //m_tx_buf[] = &value;//Need TO FIX |
tsungta | 3:f9aa81ae7c4c | 500 | memcpy(m_tx_buf, value, bytes); |
tsungta | 3:f9aa81ae7c4c | 501 | m_length = bytes;//Need TO FIX |
tsungta | 0:b7415ae44dac | 502 | } |
tsungta | 0:b7415ae44dac | 503 | |
tsungta | 0:b7415ae44dac | 504 | #if DEVICE_SPI_ASYNCH |
tsungta | 0:b7415ae44dac | 505 | |
tsungta | 0:b7415ae44dac | 506 | void spi_master_transfer_multibyte(spi_mb_t *obj, |
tsungta | 0:b7415ae44dac | 507 | const void *tx, size_t tx_length, |
tsungta | 0:b7415ae44dac | 508 | void *rx, size_t rx_length, uint8_t bit_width, |
tsungta | 0:b7415ae44dac | 509 | uint32_t handler, uint32_t event, DMAUsage hint) |
tsungta | 0:b7415ae44dac | 510 | { |
tsungta | 0:b7415ae44dac | 511 | spi_info_t *p_spi_info = SPI_INFO(obj); |
tsungta | 0:b7415ae44dac | 512 | MBED_ASSERT(p_spi_info->master); |
tsungta | 0:b7415ae44dac | 513 | (void)hint; |
tsungta | 0:b7415ae44dac | 514 | (void)bit_width; |
tsungta | 0:b7415ae44dac | 515 | |
tsungta | 0:b7415ae44dac | 516 | p_spi_info->handler = handler; |
tsungta | 0:b7415ae44dac | 517 | p_spi_info->event = event; |
tsungta | 0:b7415ae44dac | 518 | |
tsungta | 0:b7415ae44dac | 519 | p_spi_info->flag.busy = true; |
tsungta | 0:b7415ae44dac | 520 | (void)nrf_drv_spi_transfer(MASTER_INST(obj), |
tsungta | 0:b7415ae44dac | 521 | (uint8_t const *)tx, tx_length, |
tsungta | 0:b7415ae44dac | 522 | (uint8_t *)rx, rx_length); |
tsungta | 0:b7415ae44dac | 523 | } |
tsungta | 0:b7415ae44dac | 524 | |
tsungta | 0:b7415ae44dac | 525 | uint32_t spi_irq_handler_asynch_multibyte(spi_mb_t *obj) |
tsungta | 0:b7415ae44dac | 526 | { |
tsungta | 0:b7415ae44dac | 527 | spi_info_t *p_spi_info = SPI_INFO(obj); |
tsungta | 0:b7415ae44dac | 528 | MBED_ASSERT(p_spi_info->master); |
tsungta | 0:b7415ae44dac | 529 | return p_spi_info->event & SPI_EVENT_COMPLETE; |
tsungta | 0:b7415ae44dac | 530 | } |
tsungta | 0:b7415ae44dac | 531 | |
tsungta | 0:b7415ae44dac | 532 | uint8_t spi_active_multibyte(spi_mb_t *obj) |
tsungta | 0:b7415ae44dac | 533 | { |
tsungta | 0:b7415ae44dac | 534 | spi_info_t *p_spi_info = SPI_INFO(obj); |
tsungta | 0:b7415ae44dac | 535 | MBED_ASSERT(p_spi_info->master); |
tsungta | 0:b7415ae44dac | 536 | return p_spi_info->flag.busy; |
tsungta | 0:b7415ae44dac | 537 | } |
tsungta | 0:b7415ae44dac | 538 | |
tsungta | 0:b7415ae44dac | 539 | void spi_abort_asynch_multibyte(spi_mb_t *obj) |
tsungta | 0:b7415ae44dac | 540 | { |
tsungta | 0:b7415ae44dac | 541 | MBED_ASSERT(SPI_INFO(obj)->master); |
tsungta | 0:b7415ae44dac | 542 | nrf_drv_spi_abort(MASTER_INST(obj)); |
tsungta | 0:b7415ae44dac | 543 | } |
tsungta | 0:b7415ae44dac | 544 | |
tsungta | 0:b7415ae44dac | 545 | #endif // DEVICE_SPI_ASYNCH |
tsungta | 0:b7415ae44dac | 546 | |
tsungta | 0:b7415ae44dac | 547 | #endif // DEVICE_SPI |