mirror of https://github.com/ARMmbed/mbed-os.git
Corrected handling of format/frequency
parent
de89be35f8
commit
d22d8af2a2
|
@ -43,16 +43,28 @@ void SPI::format(int bits, int mode) {
|
||||||
lock();
|
lock();
|
||||||
_bits = bits;
|
_bits = bits;
|
||||||
_mode = mode;
|
_mode = mode;
|
||||||
|
// If changing format while you are the owner than just
|
||||||
|
// update format, but if owner is changed than even frequency should be
|
||||||
|
// updated which is done by acquire.
|
||||||
|
if (_owner == this) {
|
||||||
spi_format(&_spi, _bits, _mode, 0);
|
spi_format(&_spi, _bits, _mode, 0);
|
||||||
_owner = this;
|
} else {
|
||||||
|
_acquire();
|
||||||
|
}
|
||||||
unlock();
|
unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SPI::frequency(int hz) {
|
void SPI::frequency(int hz) {
|
||||||
lock();
|
lock();
|
||||||
_hz = hz;
|
_hz = hz;
|
||||||
|
// If changing format while you are the owner than just
|
||||||
|
// update frequency, but if owner is changed than even frequency should be
|
||||||
|
// updated which is done by acquire.
|
||||||
|
if (_owner == this) {
|
||||||
spi_frequency(&_spi, _hz);
|
spi_frequency(&_spi, _hz);
|
||||||
_owner = this;
|
} else {
|
||||||
|
_acquire();
|
||||||
|
}
|
||||||
unlock();
|
unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue