File tree Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -43,16 +43,28 @@ void SPI::format(int bits, int mode) {
43
43
lock ();
44
44
_bits = bits;
45
45
_mode = mode;
46
- spi_format (&_spi, _bits, _mode, 0 );
47
- _owner = this ;
46
+ // If changing format while you are the owner than just
47
+ // update format, but if owner is changed than even frequency should be
48
+ // updated which is done by acquire.
49
+ if (_owner == this ) {
50
+ spi_format (&_spi, _bits, _mode, 0 );
51
+ } else {
52
+ _acquire ();
53
+ }
48
54
unlock ();
49
55
}
50
56
51
57
void SPI::frequency (int hz) {
52
58
lock ();
53
59
_hz = hz;
54
- spi_frequency (&_spi, _hz);
55
- _owner = this ;
60
+ // If changing format while you are the owner than just
61
+ // update frequency, but if owner is changed than even frequency should be
62
+ // updated which is done by acquire.
63
+ if (_owner == this ) {
64
+ spi_frequency (&_spi, _hz);
65
+ } else {
66
+ _acquire ();
67
+ }
56
68
unlock ();
57
69
}
58
70
You can’t perform that action at this time.
0 commit comments