Skip to content

Commit ea2dec0

Browse files
authored
Merge pull request #8090 from deepikabhavnani/spi_4969
Cleanup SPI constructor and destructor
2 parents 1af1a4a + 0a9ff20 commit ea2dec0

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

drivers/SPI.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,14 @@ SPI::SPI(PinName mosi, PinName miso, PinName sclk, PinName ssel) :
4141
_write_fill(SPI_FILL_CHAR)
4242
{
4343
// No lock needed in the constructor
44-
4544
spi_init(&_spi, mosi, miso, sclk, ssel);
46-
_acquire();
45+
}
46+
47+
SPI::~SPI()
48+
{
49+
if (_owner == this) {
50+
_owner = NULL;
51+
}
4752
}
4853

4954
void SPI::format(int bits, int mode)

drivers/SPI.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ class SPI : private NonCopyable<SPI> {
8787
* @param ssel SPI chip select pin
8888
*/
8989
SPI(PinName mosi, PinName miso, PinName sclk, PinName ssel = NC);
90+
virtual ~SPI();
9091

9192
/** Configure the data transmission format
9293
*
@@ -272,11 +273,6 @@ class SPI : private NonCopyable<SPI> {
272273

273274
#endif
274275

275-
public:
276-
virtual ~SPI()
277-
{
278-
}
279-
280276
protected:
281277
spi_t _spi;
282278

0 commit comments

Comments
 (0)