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.
Dependents: mbed-TFT-example-NCS36510 mbed-Accelerometer-example-NCS36510 mbed-Accelerometer-example-NCS36510
SPIHalfDuplex.cpp
00001 /* mbed Microcontroller Library - SPIHalfDuplex 00002 * Copyright (c) 2010-2011 ARM Limited. All rights reserved. 00003 */ 00004 #include "SPIHalfDuplex.h" 00005 00006 #if DEVICE_SPI 00007 00008 #include "spi_api.h" 00009 #include "pinmap.h" 00010 00011 #define GPIO_MODE 0 00012 #define SPI_MODE 2 00013 00014 namespace mbed { 00015 00016 SPIHalfDuplex::SPIHalfDuplex(PinName mosi, PinName miso, PinName sclk) : SPI(mosi, miso, sclk) { 00017 _mosi = mosi; 00018 _miso = miso; 00019 _sbits = _bits; 00020 } 00021 00022 void SPIHalfDuplex::slave_format(int sbits) { 00023 _sbits = sbits; 00024 } 00025 00026 int SPIHalfDuplex::write(int value) { 00027 int t_bits = _bits; 00028 pin_function(_mosi, SPI_MODE); 00029 int ret_val = SPI::write(value); 00030 if (ret_val != value) { 00031 return -1; 00032 } 00033 format(_sbits, _mode); 00034 pin_function(_mosi, GPIO_MODE); 00035 ret_val = SPI::write(0x55); 00036 format(t_bits, _mode); 00037 pin_function(_mosi, SPI_MODE); 00038 return ret_val; 00039 } 00040 00041 } // end namespace mbed 00042 00043 #endif
Generated on Tue Jul 12 2022 11:02:52 by
