Skip to content

Cleanup SPI constructor and destructor #8090

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions drivers/SPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,14 @@ SPI::SPI(PinName mosi, PinName miso, PinName sclk, PinName ssel) :
_write_fill(SPI_FILL_CHAR)
{
// No lock needed in the constructor

spi_init(&_spi, mosi, miso, sclk, ssel);
_acquire();
}

SPI::~SPI()
{
if (_owner == this) {
_owner = NULL;
}
}

void SPI::format(int bits, int mode)
Expand Down
6 changes: 1 addition & 5 deletions drivers/SPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class SPI : private NonCopyable<SPI> {
* @param ssel SPI chip select pin
*/
SPI(PinName mosi, PinName miso, PinName sclk, PinName ssel = NC);
virtual ~SPI();

/** Configure the data transmission format
*
Expand Down Expand Up @@ -272,11 +273,6 @@ class SPI : private NonCopyable<SPI> {

#endif

public:
virtual ~SPI()
{
}

protected:
spi_t _spi;

Expand Down