]>
git.gir.st - tmk_keyboard.git/blob - tmk_core/tool/mbed/mbed-sdk/libraries/mbed/common/SPI.cpp
1 /* mbed Microcontroller Library
2 * Copyright (c) 2006-2013 ARM Limited
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 SPI::SPI(PinName mosi
, PinName miso
, PinName sclk
, PinName _unused
) :
27 spi_init(&_spi
, mosi
, miso
, sclk
, NC
);
28 spi_format(&_spi
, _bits
, _mode
, 0);
29 spi_frequency(&_spi
, _hz
);
32 void SPI::format(int bits
, int mode
) {
35 SPI::_owner
= NULL
; // Not that elegant, but works. rmeyer
39 void SPI::frequency(int hz
) {
41 SPI::_owner
= NULL
; // Not that elegant, but works. rmeyer
45 SPI
* SPI::_owner
= NULL
;
47 // ignore the fact there are multiple physical spis, and always update if it wasnt us last
50 spi_format(&_spi
, _bits
, _mode
, 0);
51 spi_frequency(&_spi
, _hz
);
56 int SPI::write(int value
) {
58 return spi_master_write(&_spi
, value
);