mbed library sources

Dependents:   frdm_kl05z_gpio_test

Fork of mbed-src by mbed official

Committer:
shaoziyang
Date:
Sat Sep 13 14:25:46 2014 +0000
Revision:
323:9e901b0a5aa1
Parent:
227:7bd0639b8911
test with CLOCK_SETUP = 0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 155:8435094ec241 1 /* mbed Microcontroller Library
mbed_official 155:8435094ec241 2 *******************************************************************************
mbed_official 155:8435094ec241 3 * Copyright (c) 2014, STMicroelectronics
mbed_official 155:8435094ec241 4 * All rights reserved.
mbed_official 155:8435094ec241 5 *
mbed_official 155:8435094ec241 6 * Redistribution and use in source and binary forms, with or without
mbed_official 155:8435094ec241 7 * modification, are permitted provided that the following conditions are met:
mbed_official 155:8435094ec241 8 *
mbed_official 155:8435094ec241 9 * 1. Redistributions of source code must retain the above copyright notice,
mbed_official 155:8435094ec241 10 * this list of conditions and the following disclaimer.
mbed_official 155:8435094ec241 11 * 2. Redistributions in binary form must reproduce the above copyright notice,
mbed_official 155:8435094ec241 12 * this list of conditions and the following disclaimer in the documentation
mbed_official 155:8435094ec241 13 * and/or other materials provided with the distribution.
mbed_official 155:8435094ec241 14 * 3. Neither the name of STMicroelectronics nor the names of its contributors
mbed_official 155:8435094ec241 15 * may be used to endorse or promote products derived from this software
mbed_official 155:8435094ec241 16 * without specific prior written permission.
mbed_official 155:8435094ec241 17 *
mbed_official 155:8435094ec241 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
mbed_official 155:8435094ec241 19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
mbed_official 155:8435094ec241 20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
mbed_official 155:8435094ec241 21 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
mbed_official 155:8435094ec241 22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
mbed_official 155:8435094ec241 23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
mbed_official 155:8435094ec241 24 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
mbed_official 155:8435094ec241 25 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
mbed_official 155:8435094ec241 26 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
mbed_official 155:8435094ec241 27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mbed_official 155:8435094ec241 28 *******************************************************************************
mbed_official 155:8435094ec241 29 */
mbed_official 227:7bd0639b8911 30 #include "mbed_assert.h"
mbed_official 155:8435094ec241 31 #include "spi_api.h"
mbed_official 155:8435094ec241 32
mbed_official 155:8435094ec241 33 #if DEVICE_SPI
mbed_official 155:8435094ec241 34
mbed_official 155:8435094ec241 35 #include <math.h>
mbed_official 155:8435094ec241 36 #include "cmsis.h"
mbed_official 155:8435094ec241 37 #include "pinmap.h"
mbed_official 155:8435094ec241 38
mbed_official 155:8435094ec241 39 static const PinMap PinMap_SPI_MOSI[] = {
mbed_official 155:8435094ec241 40 {PA_11, SPI_2, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_DOWN, GPIO_AF_5)},
mbed_official 155:8435094ec241 41 {PB_5, SPI_3, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_DOWN, GPIO_AF_6)},
mbed_official 155:8435094ec241 42 {PB_15, SPI_2, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_DOWN, GPIO_AF_5)},
mbed_official 155:8435094ec241 43 {PC_12, SPI_3, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_DOWN, GPIO_AF_6)},
mbed_official 155:8435094ec241 44 {NC, NC, 0}
mbed_official 155:8435094ec241 45 };
mbed_official 155:8435094ec241 46
mbed_official 155:8435094ec241 47 static const PinMap PinMap_SPI_MISO[] = {
mbed_official 155:8435094ec241 48 {PA_10, SPI_2, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_DOWN, GPIO_AF_5)},
mbed_official 155:8435094ec241 49 {PB_4, SPI_3, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_DOWN, GPIO_AF_6)},
mbed_official 155:8435094ec241 50 {PB_14, SPI_2, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_DOWN, GPIO_AF_5)},
mbed_official 155:8435094ec241 51 {PC_11, SPI_3, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_DOWN, GPIO_AF_6)},
mbed_official 155:8435094ec241 52 {NC, NC, 0}
mbed_official 155:8435094ec241 53 };
mbed_official 155:8435094ec241 54
mbed_official 155:8435094ec241 55 static const PinMap PinMap_SPI_SCLK[] = {
mbed_official 155:8435094ec241 56 {PB_3, SPI_3, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_DOWN, GPIO_AF_6)},
mbed_official 155:8435094ec241 57 {PB_13, SPI_2, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_DOWN, GPIO_AF_5)},
mbed_official 155:8435094ec241 58 {PC_10, SPI_3, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_DOWN, GPIO_AF_6)},
mbed_official 155:8435094ec241 59 {PF_1, SPI_2, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_DOWN, GPIO_AF_5)},
mbed_official 155:8435094ec241 60 {NC, NC, 0}
mbed_official 155:8435094ec241 61 };
mbed_official 155:8435094ec241 62
mbed_official 155:8435094ec241 63 static const PinMap PinMap_SPI_SSEL[] = {
mbed_official 155:8435094ec241 64 {PA_4, SPI_3, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_DOWN, GPIO_AF_6)},
mbed_official 155:8435094ec241 65 {PA_15, SPI_3, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_DOWN, GPIO_AF_6)},
mbed_official 155:8435094ec241 66 {PB_12, SPI_2, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_DOWN, GPIO_AF_5)},
mbed_official 155:8435094ec241 67 {PF_0, SPI_2, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_DOWN, GPIO_AF_5)},
mbed_official 155:8435094ec241 68 {NC, NC, 0}
mbed_official 155:8435094ec241 69 };
mbed_official 155:8435094ec241 70
mbed_official 155:8435094ec241 71 static void init_spi(spi_t *obj) {
mbed_official 155:8435094ec241 72 SPI_TypeDef *spi = (SPI_TypeDef *)(obj->spi);
mbed_official 155:8435094ec241 73 SPI_InitTypeDef SPI_InitStructure;
mbed_official 155:8435094ec241 74
mbed_official 155:8435094ec241 75 SPI_Cmd(spi, DISABLE);
mbed_official 155:8435094ec241 76
mbed_official 155:8435094ec241 77 SPI_InitStructure.SPI_Mode = obj->mode;
mbed_official 155:8435094ec241 78 SPI_InitStructure.SPI_NSS = obj->nss;
mbed_official 155:8435094ec241 79 SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
mbed_official 155:8435094ec241 80 SPI_InitStructure.SPI_DataSize = obj->bits;
mbed_official 155:8435094ec241 81 SPI_InitStructure.SPI_CPOL = obj->cpol;
mbed_official 155:8435094ec241 82 SPI_InitStructure.SPI_CPHA = obj->cpha;
mbed_official 155:8435094ec241 83 SPI_InitStructure.SPI_BaudRatePrescaler = obj->br_presc;
mbed_official 155:8435094ec241 84 SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;
mbed_official 155:8435094ec241 85 SPI_InitStructure.SPI_CRCPolynomial = 7;
mbed_official 155:8435094ec241 86 SPI_Init(spi, &SPI_InitStructure);
mbed_official 155:8435094ec241 87
mbed_official 155:8435094ec241 88 SPI_RxFIFOThresholdConfig(spi, SPI_RxFIFOThreshold_QF);
mbed_official 155:8435094ec241 89
mbed_official 155:8435094ec241 90 SPI_Cmd(spi, ENABLE);
mbed_official 155:8435094ec241 91 }
mbed_official 155:8435094ec241 92
mbed_official 155:8435094ec241 93 void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel) {
mbed_official 155:8435094ec241 94 // Determine the SPI to use
mbed_official 155:8435094ec241 95 SPIName spi_mosi = (SPIName)pinmap_peripheral(mosi, PinMap_SPI_MOSI);
mbed_official 155:8435094ec241 96 SPIName spi_miso = (SPIName)pinmap_peripheral(miso, PinMap_SPI_MISO);
mbed_official 155:8435094ec241 97 SPIName spi_sclk = (SPIName)pinmap_peripheral(sclk, PinMap_SPI_SCLK);
mbed_official 155:8435094ec241 98 SPIName spi_ssel = (SPIName)pinmap_peripheral(ssel, PinMap_SPI_SSEL);
mbed_official 155:8435094ec241 99
mbed_official 155:8435094ec241 100 SPIName spi_data = (SPIName)pinmap_merge(spi_mosi, spi_miso);
mbed_official 155:8435094ec241 101 SPIName spi_cntl = (SPIName)pinmap_merge(spi_sclk, spi_ssel);
mbed_official 155:8435094ec241 102
mbed_official 155:8435094ec241 103 obj->spi = (SPIName)pinmap_merge(spi_data, spi_cntl);
mbed_official 155:8435094ec241 104
mbed_official 227:7bd0639b8911 105 MBED_ASSERT(obj->spi != (SPIName)NC);
mbed_official 155:8435094ec241 106
mbed_official 155:8435094ec241 107 // Enable SPI clock
mbed_official 155:8435094ec241 108 if (obj->spi == SPI_2) {
mbed_official 155:8435094ec241 109 RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI2, ENABLE);
mbed_official 155:8435094ec241 110 }
mbed_official 155:8435094ec241 111 if (obj->spi == SPI_3) {
mbed_official 155:8435094ec241 112 RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI3, ENABLE);
mbed_official 155:8435094ec241 113 }
mbed_official 155:8435094ec241 114
mbed_official 155:8435094ec241 115 // Configure the SPI pins
mbed_official 155:8435094ec241 116 pinmap_pinout(mosi, PinMap_SPI_MOSI);
mbed_official 155:8435094ec241 117 pinmap_pinout(miso, PinMap_SPI_MISO);
mbed_official 155:8435094ec241 118 pinmap_pinout(sclk, PinMap_SPI_SCLK);
mbed_official 155:8435094ec241 119
mbed_official 155:8435094ec241 120 // Save new values
mbed_official 155:8435094ec241 121 obj->bits = SPI_DataSize_8b;
mbed_official 155:8435094ec241 122 obj->cpol = SPI_CPOL_Low;
mbed_official 155:8435094ec241 123 obj->cpha = SPI_CPHA_1Edge;
mbed_official 155:8435094ec241 124 obj->br_presc = SPI_BaudRatePrescaler_256;
mbed_official 155:8435094ec241 125
mbed_official 155:8435094ec241 126 if (ssel == NC) { // Master
mbed_official 155:8435094ec241 127 obj->mode = SPI_Mode_Master;
mbed_official 155:8435094ec241 128 obj->nss = SPI_NSS_Soft;
mbed_official 155:8435094ec241 129 } else { // Slave
mbed_official 155:8435094ec241 130 pinmap_pinout(ssel, PinMap_SPI_SSEL);
mbed_official 155:8435094ec241 131 obj->mode = SPI_Mode_Slave;
mbed_official 155:8435094ec241 132 obj->nss = SPI_NSS_Soft;
mbed_official 155:8435094ec241 133 }
mbed_official 155:8435094ec241 134
mbed_official 155:8435094ec241 135 init_spi(obj);
mbed_official 155:8435094ec241 136 }
mbed_official 155:8435094ec241 137
mbed_official 155:8435094ec241 138 void spi_free(spi_t *obj) {
mbed_official 155:8435094ec241 139 SPI_TypeDef *spi = (SPI_TypeDef *)(obj->spi);
mbed_official 155:8435094ec241 140 SPI_I2S_DeInit(spi);
mbed_official 155:8435094ec241 141 }
mbed_official 155:8435094ec241 142
mbed_official 155:8435094ec241 143 void spi_format(spi_t *obj, int bits, int mode, int slave) {
mbed_official 155:8435094ec241 144 // Save new values
mbed_official 155:8435094ec241 145 if (bits == 8) {
mbed_official 155:8435094ec241 146 obj->bits = SPI_DataSize_8b;
mbed_official 155:8435094ec241 147 } else {
mbed_official 155:8435094ec241 148 obj->bits = SPI_DataSize_16b;
mbed_official 155:8435094ec241 149 }
mbed_official 155:8435094ec241 150
mbed_official 155:8435094ec241 151 switch (mode) {
mbed_official 155:8435094ec241 152 case 0:
mbed_official 155:8435094ec241 153 obj->cpol = SPI_CPOL_Low;
mbed_official 155:8435094ec241 154 obj->cpha = SPI_CPHA_1Edge;
mbed_official 155:8435094ec241 155 break;
mbed_official 155:8435094ec241 156 case 1:
mbed_official 155:8435094ec241 157 obj->cpol = SPI_CPOL_Low;
mbed_official 155:8435094ec241 158 obj->cpha = SPI_CPHA_2Edge;
mbed_official 155:8435094ec241 159 break;
mbed_official 155:8435094ec241 160 case 2:
mbed_official 155:8435094ec241 161 obj->cpol = SPI_CPOL_High;
mbed_official 155:8435094ec241 162 obj->cpha = SPI_CPHA_1Edge;
mbed_official 155:8435094ec241 163 break;
mbed_official 155:8435094ec241 164 default:
mbed_official 155:8435094ec241 165 obj->cpol = SPI_CPOL_High;
mbed_official 155:8435094ec241 166 obj->cpha = SPI_CPHA_2Edge;
mbed_official 155:8435094ec241 167 break;
mbed_official 155:8435094ec241 168 }
mbed_official 155:8435094ec241 169
mbed_official 155:8435094ec241 170 if (slave == 0) {
mbed_official 155:8435094ec241 171 obj->mode = SPI_Mode_Master;
mbed_official 155:8435094ec241 172 obj->nss = SPI_NSS_Soft;
mbed_official 155:8435094ec241 173 } else {
mbed_official 155:8435094ec241 174 obj->mode = SPI_Mode_Slave;
mbed_official 155:8435094ec241 175 obj->nss = SPI_NSS_Hard;
mbed_official 155:8435094ec241 176 }
mbed_official 155:8435094ec241 177
mbed_official 155:8435094ec241 178 init_spi(obj);
mbed_official 155:8435094ec241 179 }
mbed_official 155:8435094ec241 180
mbed_official 155:8435094ec241 181 void spi_frequency(spi_t *obj, int hz) {
mbed_official 155:8435094ec241 182 // Values depend of PCLK1: 32 MHz if HSI is used, 36 MHz if HSE is used
mbed_official 155:8435094ec241 183 if (hz < 250000) {
mbed_official 155:8435094ec241 184 obj->br_presc = SPI_BaudRatePrescaler_256; // 125 kHz - 141 kHz
mbed_official 155:8435094ec241 185 } else if ((hz >= 250000) && (hz < 500000)) {
mbed_official 155:8435094ec241 186 obj->br_presc = SPI_BaudRatePrescaler_128; // 250 kHz - 280 kHz
mbed_official 155:8435094ec241 187 } else if ((hz >= 500000) && (hz < 1000000)) {
mbed_official 155:8435094ec241 188 obj->br_presc = SPI_BaudRatePrescaler_64; // 500 kHz - 560 kHz
mbed_official 155:8435094ec241 189 } else if ((hz >= 1000000) && (hz < 2000000)) {
mbed_official 155:8435094ec241 190 obj->br_presc = SPI_BaudRatePrescaler_32; // 1 MHz - 1.13 MHz
mbed_official 155:8435094ec241 191 } else if ((hz >= 2000000) && (hz < 4000000)) {
mbed_official 155:8435094ec241 192 obj->br_presc = SPI_BaudRatePrescaler_16; // 2 MHz - 2.25 MHz
mbed_official 155:8435094ec241 193 } else if ((hz >= 4000000) && (hz < 8000000)) {
mbed_official 155:8435094ec241 194 obj->br_presc = SPI_BaudRatePrescaler_8; // 4 MHz - 4.5 MHz
mbed_official 155:8435094ec241 195 } else if ((hz >= 8000000) && (hz < 16000000)) {
mbed_official 155:8435094ec241 196 obj->br_presc = SPI_BaudRatePrescaler_4; // 8 MHz - 9 MHz
mbed_official 155:8435094ec241 197 } else { // >= 16000000
mbed_official 155:8435094ec241 198 obj->br_presc = SPI_BaudRatePrescaler_2; // 16 MHz - 18 MHz
mbed_official 155:8435094ec241 199 }
mbed_official 155:8435094ec241 200 init_spi(obj);
mbed_official 155:8435094ec241 201 }
mbed_official 155:8435094ec241 202
mbed_official 155:8435094ec241 203 static inline int ssp_readable(spi_t *obj) {
mbed_official 155:8435094ec241 204 int status;
mbed_official 155:8435094ec241 205 SPI_TypeDef *spi = (SPI_TypeDef *)(obj->spi);
mbed_official 155:8435094ec241 206 // Check if data is received
mbed_official 155:8435094ec241 207 status = ((SPI_I2S_GetFlagStatus(spi, SPI_I2S_FLAG_RXNE) != RESET) ? 1 : 0);
mbed_official 155:8435094ec241 208 return status;
mbed_official 155:8435094ec241 209 }
mbed_official 155:8435094ec241 210
mbed_official 155:8435094ec241 211 static inline int ssp_writeable(spi_t *obj) {
mbed_official 155:8435094ec241 212 int status;
mbed_official 155:8435094ec241 213 SPI_TypeDef *spi = (SPI_TypeDef *)(obj->spi);
mbed_official 155:8435094ec241 214 // Check if data is transmitted
mbed_official 155:8435094ec241 215 status = ((SPI_I2S_GetFlagStatus(spi, SPI_I2S_FLAG_TXE) != RESET) ? 1 : 0);
mbed_official 155:8435094ec241 216 return status;
mbed_official 155:8435094ec241 217 }
mbed_official 155:8435094ec241 218
mbed_official 155:8435094ec241 219 static inline void ssp_write(spi_t *obj, int value) {
mbed_official 155:8435094ec241 220 SPI_TypeDef *spi = (SPI_TypeDef *)(obj->spi);
mbed_official 155:8435094ec241 221 while (!ssp_writeable(obj));
mbed_official 155:8435094ec241 222 if (obj->bits == SPI_DataSize_8b) {
mbed_official 155:8435094ec241 223 SPI_SendData8(spi, (uint8_t)value);
mbed_official 155:8435094ec241 224 } else {
mbed_official 155:8435094ec241 225 SPI_I2S_SendData16(spi, (uint16_t)value);
mbed_official 155:8435094ec241 226 }
mbed_official 155:8435094ec241 227 }
mbed_official 155:8435094ec241 228
mbed_official 155:8435094ec241 229 static inline int ssp_read(spi_t *obj) {
mbed_official 155:8435094ec241 230 SPI_TypeDef *spi = (SPI_TypeDef *)(obj->spi);
mbed_official 155:8435094ec241 231 while (!ssp_readable(obj));
mbed_official 155:8435094ec241 232 if (obj->bits == SPI_DataSize_8b) {
mbed_official 155:8435094ec241 233 return (int)SPI_ReceiveData8(spi);
mbed_official 155:8435094ec241 234 } else {
mbed_official 155:8435094ec241 235 return (int)SPI_I2S_ReceiveData16(spi);
mbed_official 155:8435094ec241 236 }
mbed_official 155:8435094ec241 237 }
mbed_official 155:8435094ec241 238
mbed_official 155:8435094ec241 239 static inline int ssp_busy(spi_t *obj) {
mbed_official 155:8435094ec241 240 int status;
mbed_official 155:8435094ec241 241 SPI_TypeDef *spi = (SPI_TypeDef *)(obj->spi);
mbed_official 155:8435094ec241 242 status = ((SPI_I2S_GetFlagStatus(spi, SPI_I2S_FLAG_BSY) != RESET) ? 1 : 0);
mbed_official 155:8435094ec241 243 return status;
mbed_official 155:8435094ec241 244 }
mbed_official 155:8435094ec241 245
mbed_official 155:8435094ec241 246 int spi_master_write(spi_t *obj, int value) {
mbed_official 155:8435094ec241 247 ssp_write(obj, value);
mbed_official 155:8435094ec241 248 return ssp_read(obj);
mbed_official 155:8435094ec241 249 }
mbed_official 155:8435094ec241 250
mbed_official 155:8435094ec241 251 int spi_slave_receive(spi_t *obj) {
mbed_official 155:8435094ec241 252 return (ssp_readable(obj) && !ssp_busy(obj)) ? (1) : (0);
mbed_official 155:8435094ec241 253 };
mbed_official 155:8435094ec241 254
mbed_official 155:8435094ec241 255 int spi_slave_read(spi_t *obj) {
mbed_official 155:8435094ec241 256 SPI_TypeDef *spi = (SPI_TypeDef *)(obj->spi);
mbed_official 155:8435094ec241 257 if (obj->bits == SPI_DataSize_8b) {
mbed_official 155:8435094ec241 258 return (int)SPI_ReceiveData8(spi);
mbed_official 155:8435094ec241 259 } else {
mbed_official 155:8435094ec241 260 return (int)SPI_I2S_ReceiveData16(spi);
mbed_official 155:8435094ec241 261 }
mbed_official 155:8435094ec241 262 }
mbed_official 155:8435094ec241 263
mbed_official 155:8435094ec241 264 void spi_slave_write(spi_t *obj, int value) {
mbed_official 155:8435094ec241 265 SPI_TypeDef *spi = (SPI_TypeDef *)(obj->spi);
mbed_official 155:8435094ec241 266 while (!ssp_writeable(obj));
mbed_official 155:8435094ec241 267 if (obj->bits == SPI_DataSize_8b) {
mbed_official 155:8435094ec241 268 SPI_SendData8(spi, (uint8_t)value);
mbed_official 155:8435094ec241 269 } else {
mbed_official 155:8435094ec241 270 SPI_I2S_SendData16(spi, (uint16_t)value);
mbed_official 155:8435094ec241 271 }
mbed_official 155:8435094ec241 272 }
mbed_official 155:8435094ec241 273
mbed_official 155:8435094ec241 274 int spi_busy(spi_t *obj) {
mbed_official 155:8435094ec241 275 return ssp_busy(obj);
mbed_official 155:8435094ec241 276 }
mbed_official 155:8435094ec241 277
mbed_official 155:8435094ec241 278 #endif